mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-10-19 22:27:20 +02:00
fix: fall back to plain text for unsupported editor modes
This commit is contained in:
1 parent
d68c9e6106
commit
64ae393200
6 files changed
+23
-7
No files matched your search
@@ -97,7 +97,9 @@ export const codeEditor = {
|
||||
beforeUnmount(el) { el._editorDisposed = true; el._editor?.destroy(); },
|
||||
};
|
||||
function applyEditorOptions(el, options = {}) {
|
||||
if (options.mode) el._editor.session.setMode("ace/mode/" + options.mode);
|
||||
const modes = window.ace.require("ace/ext/modelist").modesByName;
|
||||
const mode = Object.hasOwn(modes, options.mode) ? options.mode : "text";
|
||||
el._editor.session.setMode("ace/mode/" + mode);
|
||||
if (options.theme) el._editor.setTheme("ace/theme/" + options.theme);
|
||||
el._editor.setReadOnly(options.readOnly !== false);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user