summaryrefslogtreecommitdiffstats
path: root/web_src/js
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2020-06-03 13:19:32 +0200
committerGitHub <noreply@github.com>2020-06-03 14:19:32 +0300
commit160c23c4abda1cd3e742405bab81469c01163eac (patch)
tree6fd7e4e322d32a4f8a000fab432faf755e36a444 /web_src/js
parent4280d44a45d8e89b8d47c0187088c9387e8b233c (diff)
downloadgitea-160c23c4abda1cd3e742405bab81469c01163eac.tar.gz
gitea-160c23c4abda1cd3e742405bab81469c01163eac.zip
export monaco editor on window.codeEditors (#11739)
Fixes: https://github.com/go-gitea/gitea/issues/10409 Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'web_src/js')
-rw-r--r--web_src/js/features/codeeditor.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/web_src/js/features/codeeditor.js b/web_src/js/features/codeeditor.js
index 0999d05f05..2e268379b2 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;
}