MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / createBaseExtensions

Function createBaseExtensions

src/cm/baseExtensions.ts:41–96  ·  view source on GitHub ↗
(
	options: BaseExtensionOptions = {},
)

Source from the content-addressed store, hash-verified

39 * Base extensions roughly matching the useful parts of CodeMirror's basicSetup
40 */
41export default function createBaseExtensions(
42 options: BaseExtensionOptions = {},
43): Extension[] {
44 const {
45 autoIndent = true,
46 codeFolding = true,
47 autoCloseBrackets = true,
48 bracketMatching: enableBracketMatching = true,
49 highlightActiveLine: enableHighlightActiveLine = true,
50 highlightSelectionMatches: enableHighlightSelectionMatches = true,
51 } = options;
52 const extensions: Extension[] = [
53 highlightSpecialChars(),
54 history(),
55 ];
56
57 if (enableHighlightActiveLine) extensions.push(highlightActiveLineGutter());
58 if (codeFolding) extensions.push(foldGutter());
59 extensions.push(drawSelection());
60 extensions.push(dropCursor());
61 extensions.push(EditorState.allowMultipleSelections.of(true));
62 if (autoIndent) extensions.push(indentOnInput());
63 extensions.push(
64 syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
65 );
66 if (enableBracketMatching) extensions.push(bracketMatching());
67 if (autoCloseBrackets) extensions.push(closeBrackets());
68 extensions.push(rectangularSelection());
69 extensions.push(crosshairCursor());
70 if (enableHighlightActiveLine) extensions.push(highlightActiveLine());
71 if (enableHighlightSelectionMatches) {
72 extensions.push(highlightSelectionMatches());
73 }
74 extensions.push(
75 Prec.highest(keymap.of([{ key: "Tab", run: acceptCompletion }])),
76 );
77 extensions.push(
78 keymap.of([...completionKeymap, ...defaultKeymap, ...historyKeymap]),
79 );
80 extensions.push(
81 // This prevents tooltips from being going out of the editor area
82 tooltips({
83 tooltipSpace: (view) => {
84 const rect = view.dom.getBoundingClientRect();
85 return {
86 top: rect.top,
87 left: rect.left,
88 bottom: window.innerHeight,
89 right: window.innerWidth,
90 };
91 },
92 }),
93 );
94
95 return extensions;
96}

Callers 2

createEditorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected