Skip to content

Commit 160c23c

Browse files
silverwindlafriks
andauthored
export monaco editor on window.codeEditors (#11739)
Fixes: #10409 Co-authored-by: Lauris BH <[email protected]>
1 parent 4280d44 commit 160c23c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

web_src/js/features/codeeditor.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ function updateEditor(monaco, editor, filenameInput) {
3535
if (language !== newLanguage) monaco.editor.setModelLanguage(model, newLanguage);
3636
}
3737

38+
// export editor for customization - https://github.com/go-gitea/gitea/issues/10409
39+
function exportEditor(editor) {
40+
if (!window.codeEditors) window.codeEditors = [];
41+
if (!window.codeEditors.includes(editor)) window.codeEditors.push(editor);
42+
}
43+
3844
export async function createCodeEditor(textarea, filenameInput, previewFileModes) {
3945
const filename = basename(filenameInput.value);
4046
const previewLink = document.querySelector('a[data-tab=preview]');
@@ -81,6 +87,8 @@ export async function createCodeEditor(textarea, filenameInput, previewFileModes
8187
const loading = document.querySelector('.editor-loading');
8288
if (loading) loading.remove();
8389

90+
exportEditor(editor);
91+
8492
return editor;
8593
}
8694

0 commit comments

Comments
 (0)