2021-08-08 00:39:40 +02:00
|
|
|
// Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
2021-10-31 00:29:22 +02:00
|
|
|
import "codemirror/lib/codemirror.css";
|
|
|
|
import "codemirror/addon/fold/foldgutter.css";
|
2022-01-10 03:51:50 +01:00
|
|
|
import "codemirror/theme/monokai.css";
|
2021-08-08 00:39:40 +02:00
|
|
|
import "codemirror/mode/htmlmixed/htmlmixed";
|
|
|
|
import "codemirror/mode/stex/stex";
|
|
|
|
import "codemirror/addon/fold/foldcode";
|
|
|
|
import "codemirror/addon/fold/foldgutter";
|
|
|
|
import "codemirror/addon/fold/xml-fold";
|
2021-11-23 01:27:32 +01:00
|
|
|
import "codemirror/addon/edit/matchtags";
|
|
|
|
import "codemirror/addon/edit/closetag";
|
|
|
|
import "codemirror/addon/display/placeholder";
|
2021-08-08 00:39:40 +02:00
|
|
|
|
2022-02-04 09:36:34 +01:00
|
|
|
import CodeMirror from "codemirror";
|
|
|
|
|
2021-08-08 00:39:40 +02:00
|
|
|
export { CodeMirror };
|
|
|
|
|
|
|
|
export const latex = {
|
|
|
|
name: "stex",
|
|
|
|
inMathMode: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
export const htmlanki = {
|
|
|
|
name: "htmlmixed",
|
|
|
|
tags: {
|
|
|
|
"anki-mathjax": [[null, null, latex]],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-01-10 03:51:50 +01:00
|
|
|
export const lightCodeMirrorTheme = "default";
|
|
|
|
export const darkCodeMirrorTheme = "monokai";
|
|
|
|
|
2021-10-18 14:01:15 +02:00
|
|
|
export const baseOptions: CodeMirror.EditorConfiguration = {
|
2022-01-10 03:51:50 +01:00
|
|
|
theme: lightCodeMirrorTheme,
|
2021-08-08 00:39:40 +02:00
|
|
|
lineWrapping: true,
|
|
|
|
matchTags: { bothTags: true },
|
|
|
|
autoCloseTags: true,
|
2021-10-18 14:01:15 +02:00
|
|
|
extraKeys: { Tab: false, "Shift-Tab": false },
|
|
|
|
tabindex: 0,
|
2021-08-08 00:39:40 +02:00
|
|
|
viewportMargin: Infinity,
|
|
|
|
lineWiseCopyCut: false,
|
|
|
|
};
|
|
|
|
|
2021-10-18 14:01:15 +02:00
|
|
|
export const gutterOptions: CodeMirror.EditorConfiguration = {
|
2021-08-08 00:39:40 +02:00
|
|
|
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
|
|
|
lineNumbers: true,
|
|
|
|
foldGutter: true,
|
|
|
|
};
|
2022-01-08 02:46:01 +01:00
|
|
|
|
|
|
|
export function focusAndCaretAfter(editor: CodeMirror.Editor): void {
|
|
|
|
editor.focus();
|
|
|
|
editor.setCursor(editor.lineCount(), 0);
|
|
|
|
}
|