diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /app/assets/javascripts/blob_edit | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'app/assets/javascripts/blob_edit')
-rw-r--r-- | app/assets/javascripts/blob_edit/blob_bundle.js | 22 | ||||
-rw-r--r-- | app/assets/javascripts/blob_edit/edit_blob.js | 13 |
2 files changed, 20 insertions, 15 deletions
diff --git a/app/assets/javascripts/blob_edit/blob_bundle.js b/app/assets/javascripts/blob_edit/blob_bundle.js index f84e39baa53..678044687a9 100644 --- a/app/assets/javascripts/blob_edit/blob_bundle.js +++ b/app/assets/javascripts/blob_edit/blob_bundle.js @@ -38,9 +38,20 @@ const initPopovers = () => { } }; +export const initUploadForm = () => { + const uploadBlobForm = $('.js-upload-blob-form'); + if (uploadBlobForm.length) { + const method = uploadBlobForm.data('method'); + + new BlobFileDropzone(uploadBlobForm, method); + new NewCommitForm(uploadBlobForm); + + disableButtonIfEmptyField(uploadBlobForm.find('.js-commit-message'), '.btn-upload-file'); + } +}; + export default () => { const editBlobForm = $('.js-edit-blob-form'); - const uploadBlobForm = $('.js-upload-blob-form'); const deleteBlobForm = $('.js-delete-blob-form'); if (editBlobForm.length) { @@ -80,14 +91,7 @@ export default () => { window.onbeforeunload = () => ''; } - if (uploadBlobForm.length) { - const method = uploadBlobForm.data('method'); - - new BlobFileDropzone(uploadBlobForm, method); - new NewCommitForm(uploadBlobForm); - - disableButtonIfEmptyField(uploadBlobForm.find('.js-commit-message'), '.btn-upload-file'); - } + initUploadForm(); if (deleteBlobForm.length) { new NewCommitForm(deleteBlobForm); diff --git a/app/assets/javascripts/blob_edit/edit_blob.js b/app/assets/javascripts/blob_edit/edit_blob.js index e6b0a6fc1c5..1bc51aa1d6f 100644 --- a/app/assets/javascripts/blob_edit/edit_blob.js +++ b/app/assets/javascripts/blob_edit/edit_blob.js @@ -5,7 +5,8 @@ import { BLOB_EDITOR_ERROR, BLOB_PREVIEW_ERROR } from './constants'; import TemplateSelectorMediator from '../blob/file_template_mediator'; import { addEditorMarkdownListeners } from '~/lib/utils/text_markdown'; import EditorLite from '~/editor/editor_lite'; -import FileTemplateExtension from '~/editor/editor_file_template_ext'; +import { FileTemplateExtension } from '~/editor/editor_file_template_ext'; +import { insertFinalNewline } from '~/lib/utils/text_utility'; export default class EditBlob { // The options object has: @@ -16,11 +17,11 @@ export default class EditBlob { if (this.options.isMarkdown) { import('~/editor/editor_markdown_ext') - .then(MarkdownExtension => { - this.editor.use(MarkdownExtension.default); + .then(({ EditorMarkdownExtension: MarkdownExtension } = {}) => { + this.editor.use(new MarkdownExtension()); addEditorMarkdownListeners(this.editor); }) - .catch(() => createFlash(BLOB_EDITOR_ERROR)); + .catch(e => createFlash(`${BLOB_EDITOR_ERROR}: ${e}`)); } this.initModePanesAndLinks(); @@ -42,14 +43,14 @@ export default class EditBlob { blobPath: fileNameEl.value, blobContent: editorEl.innerText, }); - this.editor.use(FileTemplateExtension); + this.editor.use(new FileTemplateExtension()); fileNameEl.addEventListener('change', () => { this.editor.updateModelLanguage(fileNameEl.value); }); form.addEventListener('submit', () => { - fileContentEl.value = this.editor.getValue(); + fileContentEl.value = insertFinalNewline(this.editor.getValue()); }); } |