File path contains leading or trailing whitespace.
'; // Add display 'block' because display is set to 'none' in formantic\build\semantic.css warningDiv.style.display = 'block'; const inputContainer = document.querySelector('.repo-editor-header'); inputContainer.insertAdjacentElement('beforebegin', warningDiv); } showElem(warningDiv); } else if (warningDiv) { hideElem(warningDiv); } joinTreePath(); }); filenameInput.addEventListener('keydown', function (e) { const sections = queryElems('.breadcrumb span.section'); const dividers = queryElems('.breadcrumb .breadcrumb-divider'); // Jump back to last directory once the filename is empty if (e.code === 'Backspace' && filenameInput.selectionStart === 0 && sections.length > 0) { e.preventDefault(); const lastSection = sections[sections.length - 1]; const lastDivider = dividers.length ? dividers[dividers.length - 1] : null; const value = lastSection.querySelector('a').textContent; filenameInput.value = value + filenameInput.value; this.setSelectionRange(value.length, value.length); lastDivider?.remove(); lastSection.remove(); joinTreePath(); } }); const $form = $('.repository.editor .edit.form'); initEditPreviewTab($form); (async () => { const editor = await createCodeEditor(editArea, filenameInput); // Using events from https://github.com/codedance/jquery.AreYouSure#advanced-usage // to enable or disable the commit button const commitButton = document.querySelector('#commit-button'); const $editForm = $('.ui.edit.form'); const dirtyFileClass = 'dirty-file'; // Disabling the button at the start if ($('input[name="page_has_posted"]').val() !== 'true') { commitButton.disabled = true; } // Registering a custom listener for the file path and the file content $editForm.areYouSure({ silent: true, dirtyClass: dirtyFileClass, fieldSelector: ':input:not(.commit-form-wrapper :input)', change($form) { const dirty = $form[0]?.classList.contains(dirtyFileClass); commitButton.disabled = !dirty; }, }); // Update the editor from query params, if available, // only after the dirtyFileClass initialization const params = new URLSearchParams(window.location.search); const value = params.get('value'); if (value) { editor.setValue(value); } commitButton?.addEventListener('click', (e) => { // A modal which asks if an empty file should be committed if (!editArea.value) { $('#edit-empty-content-modal').modal({ onApprove() { $('.edit.form').trigger('submit'); }, }).modal('show'); e.preventDefault(); } }); })(); } export function renderPreviewPanelContent($previewPanel, data) { $previewPanel.html(data); initMarkupContent(); const $refIssues = $previewPanel.find('p .ref-issue'); attachRefIssueContextPopup($refIssues); }