| 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"; |
|
|
| |
| export const languageCompartment = new Compartment(); |
| export const readOnlyCompartment = new Compartment(); |
| export const wrapCompartment = new Compartment(); |
| export const vimCompartment = new Compartment(); |
|
|
| |
| |
| |
| |
| 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)", |
| }, |
| |
| ".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)", |
| }, |
| }), |
| ]; |
| } |
|
|