mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-04 23:13:41 +08:00
e711290d8b
Had to do some manual fixing of the app.js file due to misplaced comments
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
import {
|
|
EditorView, keymap, drawSelection, highlightActiveLine, dropCursor,
|
|
rectangularSelection, lineNumbers, highlightActiveLineGutter,
|
|
} from '@codemirror/view';
|
|
import {bracketMatching} from '@codemirror/language';
|
|
import {
|
|
defaultKeymap, history, historyKeymap, indentWithTab,
|
|
} from '@codemirror/commands';
|
|
import {EditorState} from '@codemirror/state';
|
|
import {getTheme} from './themes';
|
|
|
|
/**
|
|
* @param {Element} parentEl
|
|
* @return {(Extension[]|{extension: Extension}|readonly Extension[])[]}
|
|
*/
|
|
function common(parentEl) {
|
|
return [
|
|
getTheme(parentEl),
|
|
lineNumbers(),
|
|
highlightActiveLineGutter(),
|
|
drawSelection(),
|
|
dropCursor(),
|
|
bracketMatching(),
|
|
rectangularSelection(),
|
|
highlightActiveLine(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param {Element} parentEl
|
|
* @return {*[]}
|
|
*/
|
|
export function viewerExtensions(parentEl) {
|
|
return [
|
|
...common(parentEl),
|
|
keymap.of([
|
|
...defaultKeymap,
|
|
]),
|
|
EditorState.readOnly.of(true),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param {Element} parentEl
|
|
* @return {*[]}
|
|
*/
|
|
export function editorExtensions(parentEl) {
|
|
return [
|
|
...common(parentEl),
|
|
history(),
|
|
keymap.of([
|
|
...defaultKeymap,
|
|
...historyKeymap,
|
|
indentWithTab,
|
|
]),
|
|
EditorView.lineWrapping,
|
|
];
|
|
}
|