diff --git a/ts/components/DropdownMenu.svelte b/ts/components/DropdownMenu.svelte index 830f19009..0ca9c38f6 100644 --- a/ts/components/DropdownMenu.svelte +++ b/ts/components/DropdownMenu.svelte @@ -26,5 +26,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html .dropdown-menu { background-color: var(--frame-bg); border-color: var(--medium-border); + min-width: 1rem; } diff --git a/ts/editor/MathjaxHandleEditor.svelte b/ts/editor/MathjaxHandleEditor.svelte index d204d2dde..e1489a393 100644 --- a/ts/editor/MathjaxHandleEditor.svelte +++ b/ts/editor/MathjaxHandleEditor.svelte @@ -23,36 +23,43 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const codeMirrorOptions = { mode: latex, theme: "monokai", - /* lineNumbers: true, */ - /* lineWrapping: true, */ - /* foldGutter: true, */ - /* gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], */ - /* matchTags: { bothTags: true }, */ - /* extraKeys: { Tab: false, "Shift-Tab": false }, */ - /* viewportMargin: Infinity, */ - /* lineWiseCopyCut: false, */ - /* autofocus: true, */ + lineWrapping: true, + matchTags: { bothTags: true }, + extraKeys: { Tab: false, "Shift-Tab": false }, + viewportMargin: Infinity, + lineWiseCopyCut: false, + autofocus: true, }; let codeMirror: CodeMirror; + function onInput() { + dispatch("update", { mathjax: codeMirror.getValue() }); + } + function openCodemirror(textarea: HTMLTextAreaElement): void { codeMirror = CodeMirror.fromTextArea(textarea, codeMirrorOptions); - codeMirror.setCursor(codeMirror.lineCount(), 0); + codeMirror.on("change", onInput); } const dispatch = createEventDispatcher(); let textarea: HTMLTextAreaElement; - onMount(() => textarea.focus()); - - function onInput() { - dispatch("update", { mathjax: textarea.value }); - } + onMount(() => { + codeMirror.focus(); + codeMirror.setCursor(codeMirror.lineCount(), 0); + }); -