2778b9220c
* Remove unnecessary stopPropagation of mathjax-overlay events * Use CodeMirror component for MathjaxHandle * Refactor ResizeObserver code in MathjaxHandle * Wrap setRange in CodeMirror in try/catch * Add Mathjax Editor bottom margin * Add custom Enter and Shift+Enter shortcuts for the MathjaxHandle * Format * Move placeCaretAfter to domlib * Move focus back to field after editing Mathjax * Put Cursor after Mathjax after accepting * Add delete button for Mathjax * Change border color of mathjax menu * Refactor into MathjaxMenu * Put caretKeyword in variable * Use one ResizeObserver for all Mathjax images * Add minmimum width for Mathjax editor * is still smaller than minimal window width * Add bazel directories to .prettierignore and format from root * exclude ftl/usage (dae) the json files that live there are output from our tooling, and formatting them means an extra step each time we want to update them also exclude .mypy_cache, which is output by scripts/mypy* * minor ftl tweak: newline -> new line (dae)
60 lines
1.6 KiB
Svelte
60 lines
1.6 KiB
Svelte
<!--
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
-->
|
|
<script lang="ts">
|
|
import CodeMirror from "../CodeMirror.svelte";
|
|
import type { Writable } from "svelte/store";
|
|
import { baseOptions, latex } from "../code-mirror";
|
|
import { getPlatformString } from "../../lib/shortcuts";
|
|
import { noop } from "../../lib/functional";
|
|
import * as tr from "../../lib/ftl";
|
|
|
|
export let acceptShortcut: string;
|
|
export let newlineShortcut: string;
|
|
|
|
export let code: Writable<string>;
|
|
|
|
const configuration = {
|
|
...Object.assign({}, baseOptions, {
|
|
extraKeys: {
|
|
...(baseOptions.extraKeys as CodeMirror.KeyMap),
|
|
[acceptShortcut]: noop,
|
|
[newlineShortcut]: noop,
|
|
},
|
|
}),
|
|
placeholder: tr.editingMathjaxPlaceholder({
|
|
accept: getPlatformString(acceptShortcut),
|
|
newline: getPlatformString(newlineShortcut),
|
|
}),
|
|
mode: latex,
|
|
};
|
|
</script>
|
|
|
|
<div class="mathjax-editor">
|
|
<CodeMirror
|
|
{code}
|
|
{configuration}
|
|
on:change={({ detail }) => code.set(detail)}
|
|
on:blur
|
|
autofocus
|
|
/>
|
|
</div>
|
|
|
|
<style lang="scss">
|
|
.mathjax-editor {
|
|
:global(.CodeMirror) {
|
|
max-width: 28rem;
|
|
min-width: 14rem;
|
|
margin-bottom: 0.25rem;
|
|
}
|
|
|
|
:global(.CodeMirror-placeholder) {
|
|
font-family: sans-serif;
|
|
font-size: 55%;
|
|
text-align: center;
|
|
color: var(--slightly-grey-text);
|
|
}
|
|
}
|
|
</style>
|