From 160c23c4abda1cd3e742405bab81469c01163eac Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 3 Jun 2020 13:19:32 +0200 Subject: [PATCH] export monaco editor on window.codeEditors (#11739) Fixes: https://github.com/go-gitea/gitea/issues/10409 Co-authored-by: Lauris BH --- web_src/js/features/codeeditor.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/web_src/js/features/codeeditor.js b/web_src/js/features/codeeditor.js index 0999d05f05c..2e268379b25 100644 --- a/web_src/js/features/codeeditor.js +++ b/web_src/js/features/codeeditor.js @@ -35,6 +35,12 @@ function updateEditor(monaco, editor, filenameInput) { if (language !== newLanguage) monaco.editor.setModelLanguage(model, newLanguage); } +// export editor for customization - https://github.com/go-gitea/gitea/issues/10409 +function exportEditor(editor) { + if (!window.codeEditors) window.codeEditors = []; + if (!window.codeEditors.includes(editor)) window.codeEditors.push(editor); +} + export async function createCodeEditor(textarea, filenameInput, previewFileModes) { const filename = basename(filenameInput.value); const previewLink = document.querySelector('a[data-tab=preview]'); @@ -81,6 +87,8 @@ export async function createCodeEditor(textarea, filenameInput, previewFileModes const loading = document.querySelector('.editor-loading'); if (loading) loading.remove(); + exportEditor(editor); + return editor; }