Download src/modules/editor/lib/extensions.ts from lekmikdok/termix: direct link, hf CLI and curl.
- Browser
- Download file 3.47 kB
-
https://huggingface.co/spaces/lekmikdok/termix/resolve/main/src/modules/editor/lib/extensions.ts
- Command line
-
hf download hf://spaces/lekmikdok/termix/src/modules/editor/lib/extensions.ts
-
curl -L -o extensions.ts https://huggingface.co/spaces/lekmikdok/termix/resolve/main/src/modules/editor/lib/extensions.ts
3.47 kB
| import { detectMonoFontFamily } from "@/lib/fonts"; | |
| import { indentUnit } from "@codemirror/language"; | |
| import { lintGutter } from "@codemirror/lint"; | |
| import { search } from "@codemirror/search"; | |
| import { Compartment, EditorState, type Extension } from "@codemirror/state"; | |
| import { EditorView } from "@codemirror/view"; | |
| // Compartments allow runtime reconfiguration without rebuilding state. | |
| export const languageCompartment = new Compartment(); | |
| export const readOnlyCompartment = new Compartment(); | |
| export const wrapCompartment = new Compartment(); | |
| export const vimCompartment = new Compartment(); | |
| // Only what basicSetup doesn't already cover, to avoid duplicate extensions. | |
| // basicSetup gives us line numbers, fold gutter, history, indentOnInput, | |
| // bracketMatching, closeBrackets, autocompletion, highlightActiveLine, | |
| // highlightSelectionMatches and the search keymap. | |
| export function buildSharedExtensions(): Extension[] { | |
| return [ | |
| indentUnit.of(" "), | |
| EditorState.tabSize.of(2), | |
| search({ top: true }), | |
| lintGutter(), | |
| EditorView.theme({ | |
| "&, &.cm-editor, &.cm-editor.cm-focused": { | |
| backgroundColor: "transparent !important", | |
| color: "var(--foreground)", | |
| outline: "none", | |
| padding: "8px", | |
| }, | |
| ".cm-scroller": { | |
| fontFamily: detectMonoFontFamily(), | |
| fontSize: "13px", | |
| lineHeight: "1.55", | |
| backgroundColor: "transparent !important", | |
| }, | |
| ".cm-content": { | |
| caretColor: "var(--foreground)", | |
| backgroundColor: "transparent !important", | |
| }, | |
| ".cm-gutters": { | |
| backgroundColor: "transparent !important", | |
| color: "var(--muted-foreground)", | |
| }, | |
| ".cm-gutter-lint": { | |
| width: "0px", | |
| }, | |
| ".cm-gutter": { backgroundColor: "transparent !important" }, | |
| ".cm-lineNumbers .cm-gutterElement": { | |
| opacity: "0.55", | |
| }, | |
| ".cm-foldGutter": { width: "10px" }, | |
| ".cm-foldGutter .cm-gutterElement": { | |
| color: "var(--muted-foreground)", | |
| opacity: "0.5", | |
| }, | |
| ".cm-activeLine": { | |
| borderTopRightRadius: "5px", | |
| borderBottomRightRadius: "5px", | |
| backgroundColor: | |
| "color-mix(in srgb, var(--foreground) 4%, transparent)", | |
| }, | |
| ".cm-lineNumbers .cm-activeLineGutter": { | |
| borderTopLeftRadius: "5px", | |
| borderBottomLeftRadius: "5px", | |
| userSelect: "none", | |
| }, | |
| ".cm-cursor, .cm-dropCursor": { | |
| borderLeftColor: "var(--foreground)", | |
| }, | |
| // Vim normal-mode block cursor — translucent foreground, no rose hue. | |
| ".cm-fat-cursor": { | |
| background: | |
| "color-mix(in srgb, var(--foreground) 35%, transparent) !important", | |
| outline: | |
| "1px solid color-mix(in srgb, var(--foreground) 55%, transparent) !important", | |
| color: "var(--foreground) !important", | |
| }, | |
| "&:not(.cm-focused) .cm-fat-cursor": { | |
| background: "transparent !important", | |
| outline: | |
| "1px solid color-mix(in srgb, var(--foreground) 35%, transparent) !important", | |
| }, | |
| ".cm-selectionBackground, &.cm-focused .cm-selectionBackground, ::selection": | |
| { | |
| backgroundColor: | |
| "color-mix(in srgb, var(--foreground) 18%, transparent) !important", | |
| }, | |
| ".cm-panels": { | |
| backgroundColor: "var(--popover)", | |
| color: "var(--popover-foreground)", | |
| borderColor: "var(--border)", | |
| }, | |
| }), | |
| ]; | |
| } | |