diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-24 00:10:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-24 00:10:02 +0300 |
commit | abd24a801e8dbe0942558dd2b2cad90e7e01938e (patch) | |
tree | 27b00caff863be07505fa60e63ece1d55f10e2b9 /app/assets/javascripts/editor | |
parent | fee19ef336bc64155e0d9e8697834ff529bb6d93 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/editor')
-rw-r--r-- | app/assets/javascripts/editor/source_editor.js | 48 | ||||
-rw-r--r-- | app/assets/javascripts/editor/source_editor_instance.js | 4 |
2 files changed, 2 insertions, 50 deletions
diff --git a/app/assets/javascripts/editor/source_editor.js b/app/assets/javascripts/editor/source_editor.js index 81ddf8d77fa..26fbd1f4d8a 100644 --- a/app/assets/javascripts/editor/source_editor.js +++ b/app/assets/javascripts/editor/source_editor.js @@ -26,26 +26,6 @@ export default class SourceEditor { registerLanguages(...languages); } - static pushToImportsArray(arr, toImport) { - arr.push(import(toImport)); - } - - static loadExtensions(extensions) { - if (!extensions) { - return Promise.resolve(); - } - const promises = []; - const extensionsArray = typeof extensions === 'string' ? extensions.split(',') : extensions; - - extensionsArray.forEach((ext) => { - const prefix = ext.includes('/') ? '' : 'editor/'; - const trimmedExt = ext.replace(/^\//, '').trim(); - SourceEditor.pushToImportsArray(promises, `~/${prefix}${trimmedExt}`); - }); - - return Promise.all(promises); - } - static mixIntoInstance(source, inst) { if (!inst) { return; @@ -71,23 +51,6 @@ export default class SourceEditor { }); } - static manageDefaultExtensions(instance, el, extensions) { - SourceEditor.loadExtensions(extensions, instance) - .then((modules) => { - if (modules) { - modules.forEach((module) => { - instance.use(module.default); - }); - } - }) - .then(() => { - el.dispatchEvent(new Event(EDITOR_READY_EVENT)); - }) - .catch((e) => { - throw e; - }); - } - static createEditorModel({ blobPath, blobContent, @@ -187,7 +150,6 @@ export default class SourceEditor { blobContent = '', blobOriginalContent = '', blobGlobalId = uuids()[0], - extensions = [], isDiff = false, ...instanceOptions } = {}) { @@ -218,9 +180,8 @@ export default class SourceEditor { SourceEditor.instanceDisposeModels(this, instance, model); }); - SourceEditor.manageDefaultExtensions(instance, el, extensions); - this.instances.push(instance); + el.dispatchEvent(new CustomEvent(EDITOR_READY_EVENT, { instance })); return instance; } @@ -234,11 +195,4 @@ export default class SourceEditor { dispose() { this.instances.forEach((instance) => instance.dispose()); } - - use(exts) { - this.instances.forEach((inst) => { - inst.use(exts); - }); - return this; - } } diff --git a/app/assets/javascripts/editor/source_editor_instance.js b/app/assets/javascripts/editor/source_editor_instance.js index e0ca4ea518b..052a73d7091 100644 --- a/app/assets/javascripts/editor/source_editor_instance.js +++ b/app/assets/javascripts/editor/source_editor_instance.js @@ -73,9 +73,7 @@ export default class EditorInstance { if (methodExtension) { const extension = extensionsStore.get(methodExtension); - return (...args) => { - return extension.api[prop].call(seInstance, ...args, receiver); - }; + return (...args) => extension.api[prop].call(seInstance, receiver, ...args); } return Reflect.get(seInstance[prop] ? seInstance : target, prop, receiver); }, |