2023-06-02 15:24:32 +02:00
|
|
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
|
|
import {
|
|
|
|
autocompletion,
|
|
|
|
closeBrackets,
|
|
|
|
closeBracketsKeymap,
|
|
|
|
completionKeymap,
|
|
|
|
} from '@codemirror/autocomplete';
|
|
|
|
import { defaultKeymap, history, historyKeymap } from '@codemirror/commands';
|
2023-06-05 18:02:44 +02:00
|
|
|
import { css as langCss } from '@codemirror/lang-css';
|
|
|
|
import { sass as langSass } from '@codemirror/lang-sass';
|
2023-06-02 15:24:32 +02:00
|
|
|
import {
|
|
|
|
bracketMatching,
|
|
|
|
defaultHighlightStyle,
|
|
|
|
foldGutter,
|
|
|
|
foldKeymap,
|
|
|
|
indentOnInput,
|
|
|
|
syntaxHighlighting,
|
|
|
|
} from '@codemirror/language';
|
|
|
|
import { lintKeymap } from '@codemirror/lint';
|
|
|
|
import { highlightSelectionMatches, searchKeymap } from '@codemirror/search';
|
2023-06-02 16:53:32 +02:00
|
|
|
import { EditorState } from '@codemirror/state';
|
2023-06-02 15:24:32 +02:00
|
|
|
import {
|
|
|
|
crosshairCursor,
|
|
|
|
drawSelection,
|
|
|
|
dropCursor,
|
|
|
|
highlightActiveLine,
|
|
|
|
highlightActiveLineGutter,
|
|
|
|
highlightSpecialChars,
|
|
|
|
keymap,
|
|
|
|
lineNumbers,
|
|
|
|
rectangularSelection,
|
|
|
|
} from '@codemirror/view';
|
|
|
|
|
2023-06-05 18:02:44 +02:00
|
|
|
import { playgroundHighlightStyle, playgroundTheme } from './theme.js';
|
|
|
|
|
2023-06-02 16:53:32 +02:00
|
|
|
const editorSetup = (() => [
|
2023-06-05 18:02:44 +02:00
|
|
|
[
|
|
|
|
lineNumbers(),
|
|
|
|
highlightActiveLineGutter(),
|
|
|
|
highlightSpecialChars(),
|
|
|
|
history(),
|
|
|
|
// foldGutter(),
|
|
|
|
// drawSelection(),
|
|
|
|
dropCursor(),
|
|
|
|
// EditorState.allowMultipleSelections.of(true),
|
|
|
|
indentOnInput(),
|
|
|
|
syntaxHighlighting(playgroundHighlightStyle),
|
|
|
|
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
|
|
|
bracketMatching(),
|
|
|
|
closeBrackets(),
|
|
|
|
autocompletion(),
|
|
|
|
// rectangularSelection(),
|
|
|
|
// crosshairCursor(),
|
|
|
|
highlightActiveLine(),
|
|
|
|
highlightSelectionMatches(),
|
|
|
|
keymap.of([
|
|
|
|
...closeBracketsKeymap,
|
|
|
|
...defaultKeymap,
|
|
|
|
...searchKeymap,
|
|
|
|
...historyKeymap,
|
|
|
|
...foldKeymap,
|
|
|
|
...completionKeymap,
|
|
|
|
...lintKeymap,
|
|
|
|
]),
|
|
|
|
],
|
|
|
|
langSass(),
|
|
|
|
playgroundTheme,
|
2023-06-02 15:24:32 +02:00
|
|
|
])();
|
2023-06-02 16:53:32 +02:00
|
|
|
|
|
|
|
const outputSetup = (() => [
|
2023-06-05 18:02:44 +02:00
|
|
|
[
|
|
|
|
lineNumbers(),
|
|
|
|
highlightSpecialChars(),
|
|
|
|
// foldGutter(),
|
|
|
|
syntaxHighlighting(playgroundHighlightStyle),
|
|
|
|
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
|
|
|
highlightActiveLine(),
|
|
|
|
EditorState.readOnly.of(true),
|
|
|
|
],
|
|
|
|
langCss(),
|
|
|
|
playgroundTheme,
|
2023-06-02 16:53:32 +02:00
|
|
|
])();
|
|
|
|
|
|
|
|
export { editorSetup, outputSetup };
|