debian-mirror-gitlab/app/assets/javascripts/snippet/snippet_bundle.js

31 lines
795 B
JavaScript
Raw Normal View History

2020-04-08 14:13:33 +05:30
import { initEditorLite } from '~/blob/utils';
2020-03-09 13:42:32 +05:30
import setupCollapsibleInputs from './collapsible_input';
2018-05-09 12:01:36 +05:30
2020-04-08 14:13:33 +05:30
let editor;
const initMonaco = () => {
const editorEl = document.getElementById('editor');
const contentEl = document.querySelector('.snippet-file-content');
const fileNameEl = document.querySelector('.js-snippet-file-name');
const form = document.querySelector('.snippet-form-holder form');
2016-09-13 17:45:13 +05:30
2020-04-08 14:13:33 +05:30
editor = initEditorLite({
el: editorEl,
blobPath: fileNameEl.value,
blobContent: contentEl.value,
2016-09-13 17:45:13 +05:30
});
2020-03-09 13:42:32 +05:30
2020-04-08 14:13:33 +05:30
fileNameEl.addEventListener('change', () => {
editor.updateModelLanguage(fileNameEl.value);
});
form.addEventListener('submit', () => {
contentEl.value = editor.getValue();
});
};
export default () => {
2020-05-24 23:13:21 +05:30
initMonaco();
setupCollapsibleInputs();
2020-04-08 14:13:33 +05:30
};