2020-03-09 09:07:45 +00:00
|
|
|
import { initEditorLite } from '~/blob/utils';
|
2020-02-13 15:08:52 +00:00
|
|
|
import setupCollapsibleInputs from './collapsible_input';
|
2018-03-09 20:18:59 +00:00
|
|
|
|
2020-02-28 15:09:13 +00:00
|
|
|
let editor;
|
|
|
|
|
|
|
|
const initMonaco = () => {
|
|
|
|
const editorEl = document.getElementById('editor');
|
|
|
|
const contentEl = document.querySelector('.snippet-file-content');
|
2020-03-05 18:08:19 +00:00
|
|
|
const fileNameEl = document.querySelector('.js-snippet-file-name');
|
2020-02-28 15:09:13 +00:00
|
|
|
const form = document.querySelector('.snippet-form-holder form');
|
|
|
|
|
2020-03-09 09:07:45 +00:00
|
|
|
editor = initEditorLite({
|
2020-02-28 15:09:13 +00:00
|
|
|
el: editorEl,
|
|
|
|
blobPath: fileNameEl.value,
|
|
|
|
blobContent: contentEl.value,
|
2016-06-24 18:26:11 +00:00
|
|
|
});
|
2020-02-13 15:08:52 +00:00
|
|
|
|
2020-02-28 15:09:13 +00:00
|
|
|
fileNameEl.addEventListener('change', () => {
|
|
|
|
editor.updateModelLanguage(fileNameEl.value);
|
|
|
|
});
|
|
|
|
|
|
|
|
form.addEventListener('submit', () => {
|
|
|
|
contentEl.value = editor.getValue();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export default () => {
|
2020-05-06 09:10:02 +00:00
|
|
|
initMonaco();
|
|
|
|
setupCollapsibleInputs();
|
2020-02-28 15:09:13 +00:00
|
|
|
};
|