Skip to content

Commit

Permalink
export monaco editor on window.codeEditors (go-gitea#11739)
Browse files Browse the repository at this point in the history
Fixes: go-gitea#10409

Co-authored-by: Lauris BH <[email protected]>
  • Loading branch information
2 people authored and Yohann Delafollye committed Jul 31, 2020
1 parent a01d040 commit b33f2d4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions web_src/js/features/codeeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]');
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit b33f2d4

Please sign in to comment.