Commit 64421911 authored by Denys Mishunov's avatar Denys Mishunov

Updated blob editor to work with instance

Instead of calling proxy methods on the root editor, we now call
methods directly on the instance.
parent ad2ff7de
import $ from 'jquery';
import { Position } from 'monaco-editor';
import Api from '~/api';
import toast from '~/vue_shared/plugins/global_toast';
import { __ } from '~/locale';
import initPopover from '~/blob/suggest_gitlab_ci_yml';
import { deprecatedCreateFlash as Flash } from '../flash';
import FileTemplateTypeSelector from './template_selectors/type_selector';
import BlobCiYamlSelector from './template_selectors/ci_yaml_selector';
import DockerfileSelector from './template_selectors/dockerfile_selector';
import GitignoreSelector from './template_selectors/gitignore_selector';
import LicenseSelector from './template_selectors/license_selector';
import MetricsDashboardSelector from './template_selectors/metrics_dashboard_selector';
import toast from '~/vue_shared/plugins/global_toast';
import { __ } from '~/locale';
import initPopover from '~/blob/suggest_gitlab_ci_yml';
export default class FileTemplateMediator {
constructor({ editor, currentAction, projectId }) {
......@@ -188,7 +191,14 @@ export default class FileTemplateMediator {
this.editor.focus();
this.editor.navigateFileStart();
if (this.editor.navigateFileStart) {
// ACE. This will be removed and cleaned up
// in https://gitlab.com/gitlab-org/gitlab/-/issues/198610
this.editor.navigateFileStart();
} else {
// Editor Lite
this.editor.setPosition(new Position(1, 1));
}
}
findTemplateSelectorByKey(key) {
......
......@@ -50,20 +50,20 @@ export default class EditBlob {
const fileContentEl = document.getElementById('file-content');
const form = document.querySelector('.js-edit-blob-form');
this.editor = new EditorLite();
const rootEditor = new EditorLite();
if (MarkdownExtension) {
this.editor.use(MarkdownExtension.default);
}
this.editor.createInstance({
this.editor = rootEditor.createInstance({
el: editorEl,
blobPath: fileNameEl.value,
blobContent: editorEl.innerText,
});
if (MarkdownExtension) {
rootEditor.use(MarkdownExtension.default, this.editor);
}
fileNameEl.addEventListener('change', () => {
this.editor.updateModelLanguage(fileNameEl.value);
rootEditor.updateModelLanguage(fileNameEl.value);
});
form.addEventListener('submit', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment