@dou-ui/code 0.1.0-alpha.22 → 0.1.0-alpha.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"extension.js","names":[],"sources":["../src/extension.ts"],"sourcesContent":["import type { CodeMessages } from './locale'\nimport { type Component, type InjectionKey, type VNodeChild, inject } from 'vue'\nimport type { CodeKeymap } from './core/keymap'\nimport type { CodeSelection } from './core/selection'\nimport type { CodeText } from './core/text'\nimport type { CodeState, CodeTransaction, CodeTransactionResult } from './core/transaction'\nimport type { CodeEditorExpose } from './types'\n\n/** How bad a diagnostic is, worst first. */\nexport type CodeDiagnosticSeverity = 'error' | 'warning' | 'info' | 'hint'\n\n/** A fix offered with a diagnostic. */\nexport interface CodeDiagnosticAction {\n label: string\n /** Makes the fix, usually with `context.transact`. */\n run: (context: CodeExtensionContext, diagnostic: CodeDiagnostic) => void\n}\n\n/**\n * A problem found in the text, from `from` to `to` (offsets in the text,\n * the same as a language service's ranges). An empty range marks the\n * character after it.\n */\nexport interface CodeDiagnostic {\n from: number\n to: number\n severity: CodeDiagnosticSeverity\n message: string\n /** Who found it, shown after the message, e.g. the name of a linter. */\n source?: string\n /** Fixes, shown under the message and with `Mod` + `.`. */\n actions?: CodeDiagnosticAction[]\n}\n\n/**\n * How a part of the text is drawn. Marks and line classes only change how\n * the text looks (colors, backgrounds, underlines, borders), never its\n * size, so the cursor still lands where the characters are; an inline\n * widget takes its own room in the line.\n */\nexport type CodeDecoration =\n /**\n * Classes on the characters from `from` to `to`. `style` sets inline\n * styles on them as well, e.g. a CSS variable holding a person's color;\n * where marks overlap, the later one's styles win.\n */\n | {\n type: 'mark'\n from: number\n to: number\n class: string\n title?: string\n style?: Readonly<Record<string, string>>\n }\n /** A class on a whole line (`line` from 1), e.g. a tinted background. */\n | { type: 'line'; line: number; class: string }\n /**\n * Something drawn inside a line, before the character at `pos`, such as\n * a color swatch or a parameter's name. It isn't text: the cursor steps\n * over it and copying leaves it out. `width` in px saves measuring it;\n * without it the widget is measured once drawn, and the width is kept by\n * `id`.\n */\n | { type: 'inline'; pos: number; render: () => VNodeChild; width?: number; id?: string }\n\n/**\n * A component drawn between lines, across the editor, e.g. a review\n * comment. The lines below move down to make room, and it moves with the\n * text as lines are added or removed above it.\n */\nexport interface CodeWidget {\n /** Tells widgets apart, unique among one extension's; its measured height is kept by it. */\n id: string\n /**\n * Where it is: below the line of text position `pos`, or below line\n * `line` (from 1); above with `position: 'above'`. Give one of them.\n */\n pos?: number\n line?: number\n /** Defaults to `below`. */\n position?: 'above' | 'below'\n render: () => VNodeChild\n /** Its height in px before it has been drawn and measured; defaults to one line. */\n height?: number\n /** What it is, read out when the cursor moves onto its line, e.g. \"戴兜的评论\". */\n label?: string\n}\n\n/** Something drawn in a column beside the line numbers, on line `line` (from 1). */\nexport interface CodeGutterMarker {\n line: number\n /** Drawn in the middle of the column. */\n icon?: Component\n /** Short text, when there is no icon. */\n text?: string\n class?: string\n /**\n * Shown on hover. Required when the column has `onPress`: the marker is\n * then a button, and this is its name.\n */\n title?: string\n /**\n * When the marker shows: `always`, or `hover`, out of sight until its\n * line is hovered, holds the cursor, or the marker has the focus, e.g. a\n * \"comment\" mark offered on every line. Defaults to `always`.\n */\n visible?: 'always' | 'hover'\n}\n\n/**\n * The marker a column shows on every line without one of its own, out of\n * sight until the line is hovered (as `visible: 'hover'`), e.g. \"add a\n * breakpoint\" offered on every line.\n */\nexport interface CodeGutterHoverMarker extends Pick<CodeGutterMarker, 'icon' | 'text' | 'class'> {\n /**\n * Its name, as a marker's `title`; a function names the marker of each\n * line, e.g. \"Add a breakpoint on line 3\". It is called for every line in\n * view, often: keep it quick.\n */\n title?: string | ((line: number) => string)\n}\n\n/** A column of the gutter, left of the line numbers. */\nexport interface CodeGutter {\n name: string\n /** In px. Defaults to 16. */\n width?: number\n /** The markers on the lines in view; reactive state read here updates them. */\n markers?: (context: CodeExtensionContext) => CodeGutterMarker[]\n /** A marker on every other line, shown on hover. */\n hoverMarker?: CodeGutterHoverMarker\n /**\n * Where `onPress` answers: `any` cell of the column (the default), e.g. to\n * set a breakpoint on an empty line, or only its `markers`.\n */\n pressOn?: 'any' | 'markers'\n /**\n * A press on the column, on line `line`, e.g. to set a breakpoint. A\n * marker in such a column is a button: the one on the cursor's line is\n * reached with Escape then Shift+Tab, and Enter or Space presses it. A\n * finger or pen presses when it lifts in place; a tap on a marker still\n * out of sight first moves the cursor to its line, which shows it.\n */\n onPress?: (\n line: number,\n event: PointerEvent | KeyboardEvent,\n context: CodeExtensionContext,\n ) => void\n}\n\n/** An undo history that takes the place of the editor's own, e.g. one shared with others. */\nexport interface CodeHistoryHandler {\n /** `false` when there is nothing to undo. */\n undo: () => boolean\n redo: () => boolean\n /** Read in templates and computed values: keep them reactive. */\n canUndo: () => boolean\n canRedo: () => boolean\n /** The next change starts a new undo step, e.g. when the editor loses focus. */\n close?: () => void\n}\n\n/** A bar above or below the text, inside the editor's frame. */\nexport interface CodePanel {\n /** Tells panels apart, unique among one extension's. */\n name: string\n /** Defaults to `bottom`. */\n position?: 'top' | 'bottom'\n render: () => VNodeChild\n}\n\n/** What a completion is, shown as its icon. */\nexport type CodeCompletionKind =\n | 'keyword'\n | 'function'\n | 'method'\n | 'variable'\n | 'property'\n | 'constant'\n | 'class'\n | 'type'\n | 'module'\n | 'snippet'\n | 'text'\n\n/** One entry of the completion list. */\nexport interface CodeCompletion {\n /** Shown, and matched against what was typed. */\n label: string\n kind?: CodeCompletionKind\n /** Short, after the label, e.g. a type. */\n detail?: string\n /** Longer, below the list while this entry is picked: text, or a function returning VNodes. */\n info?: string | (() => VNodeChild)\n /** What goes into the text, if not the label. */\n insert?: string\n /** Inserted as a snippet instead: `${1:name}` places to fill in, Tab to the next, `$0` where it ends. */\n snippet?: string\n /** Moves the entry up (positive) or down among equally good matches. */\n boost?: number\n}\n\n/** What a completion source is asked with. */\nexport interface CodeCompletionRequest {\n /** The cursor. */\n pos: number\n /** The word right before the cursor, by the language's word characters; empty when there is none. */\n word: { from: number; to: number; text: string }\n /** Asked for from the keyboard (`Ctrl` + `Space`, `Alt` + `Esc`) rather than by typing. */\n explicit: boolean\n /** Aborted when the answer is no longer wanted, so a slow source can stop. */\n signal: AbortSignal\n}\n\n/** What a hover or signature source is asked with. */\nexport interface CodePositionRequest {\n /** The position asked about: under the pointer, or the cursor. */\n pos: number\n /** Aborted when the answer is no longer wanted, so a slow source can stop. */\n signal: AbortSignal\n}\n\n/** What a completion source answers: entries to put in place of `from`–cursor. */\nexport interface CodeCompletionResult {\n from: number\n options: CodeCompletion[]\n}\n\n/** Text shown on hover, or with the cursor on it from the keyboard. */\nexport interface CodeHoverResult {\n /** What it is about, `from`–`to`; defaults to the word under the pointer. */\n from?: number\n to?: number\n /** Plain text, or a render function for anything else. */\n content: string | (() => VNodeChild)\n}\n\n/** The parameters of the call the cursor is in. */\nexport interface CodeSignatureResult {\n /** The whole signature, e.g. `slice(start, end)`. */\n label: string\n /** Each parameter as `[from, to]` in `label`. */\n params: Array<[number, number]>\n /** Which parameter the cursor is at, from 0. */\n active: number\n /** Shown under the signature: text, or a function returning VNodes. */\n info?: string | (() => VNodeChild)\n}\n\nexport interface CodeExtension {\n name: string\n /** Higher runs first: its keys and hooks come before others. Defaults to 100. */\n priority?: number\n /** Keys tried before the built-in ones, and after the `keymap` prop. */\n keymap?: (context: CodeExtensionContext) => CodeKeymap\n /**\n * How parts of the text look, read while drawing: reactive state read\n * here updates them. Asked for the lines in view (`context.visible`),\n * which is all that needs them.\n */\n decorations?: (context: CodeExtensionContext) => CodeDecoration[]\n /** Columns beside the line numbers. */\n gutters?: CodeGutter[]\n /**\n * Components between lines. Unlike decorations, these are asked for the\n * whole text, since their heights place every line after them; keep\n * them few (comments, not one per line).\n */\n widgets?: (context: CodeExtensionContext) => CodeWidget[]\n /**\n * Lines left out of view: line numbers (from 1, not text positions), from\n * line `from` to line `to`, both left out,\n * e.g. the unchanged lines of a diff. Unlike a fold, nothing marks the\n * spot; put a widget there for that. Asked for the whole text; reactive\n * state read here updates them. Moving up and down steps over them.\n */\n hide?: (context: CodeExtensionContext) => Array<{ from: number; to: number }>\n /** Bars above or below the text; reactive state read here updates them. */\n panels?: (context: CodeExtensionContext) => CodePanel[]\n /**\n * Finds problems in the text. Run when the editor mounts and again a\n * moment after the text stops changing; an answer that arrives after\n * the text changed again is dropped, and the next run follows it.\n * Meanwhile the problems found move with the text.\n */\n lint?: (\n context: CodeExtensionContext,\n ) => CodeDiagnostic[] | null | undefined | Promise<CodeDiagnostic[] | null | undefined>\n /**\n * Offers completions while typing (after a word character or one of\n * `completionTriggers`) and on `Ctrl` + `Space` or `Alt` + `Esc`. Answers from every\n * extension are put in one list; a Promise is waited for, and dropped\n * when the text has moved on.\n */\n completion?: (\n request: CodeCompletionRequest,\n context: CodeExtensionContext,\n ) => CodeCompletionResult | null | undefined | Promise<CodeCompletionResult | null | undefined>\n /** Characters that ask for completions when typed, such as `.`. */\n completionTriggers?: string[]\n /**\n * Text about a position, shown on hover and with `Mod` + `I`. A Promise\n * is waited for; `signal` aborts when the pointer moves on.\n */\n hover?: (\n request: CodePositionRequest,\n context: CodeExtensionContext,\n ) => CodeHoverResult | null | undefined | Promise<CodeHoverResult | null | undefined>\n /**\n * The parameters of the call around the cursor, shown while typing its\n * arguments. A Promise is waited for, and dropped when the cursor has\n * moved on.\n */\n signature?: (\n request: CodePositionRequest,\n context: CodeExtensionContext,\n ) => CodeSignatureResult | null | undefined | Promise<CodeSignatureResult | null | undefined>\n /**\n * Sees every change before it is applied, in priority order, and may add\n * to it (positions are in the text before the change). Undo, redo, new\n * `v-model` values and other people's changes (`action: 'remote'`) don't\n * come through here.\n */\n transaction?: (tr: CodeTransaction, context: CodeExtensionContext) => void\n /**\n * Runs after every step the editor took, with the text and selection\n * already updated: typing, commands, undo and redo, new `v-model`\n * values and other people's changes. `result.meta.action` tells them\n * apart.\n */\n update?: (result: CodeTransactionResult, context: CodeExtensionContext) => void\n /**\n * Replaces the editor's undo history; the first extension that has one\n * wins. Called once per list of extensions: return the same handler\n * each time.\n */\n history?: (context: CodeExtensionContext) => CodeHistoryHandler\n /**\n * Buttons added to the toolbar shown over the selection on touch screens,\n * after cut, copy, paste and select all. Read again as the selection\n * changes.\n */\n menu?: (context: CodeExtensionContext) => CodeMenuItem[]\n /** Runs once the editor is mounted. Return a function to run when it unmounts. */\n setup?: (context: CodeExtensionContext) => void | (() => void)\n}\n\n/** A button of the touch toolbar, from an extension's `menu`. */\nexport interface CodeMenuItem {\n label: string\n run: (context: CodeExtensionContext) => void\n}\n\n/** What an extension sees of the editor: its instance, plus a little more. */\nexport interface CodeExtensionContext extends CodeEditorExpose {\n /** The text and selection now; reading them in `decorations` or `panels` follows every change. */\n readonly state: CodeState\n readonly doc: CodeText\n readonly selection: CodeSelection\n /** The lines in view: line numbers (from 1, not text positions), both ends in view. */\n readonly visible: { readonly from: number; readonly to: number }\n /** The problems found now, by all linters and the `diagnostics` prop, in text order. */\n readonly diagnostics: readonly CodeDiagnostic[]\n /** Whether the editor has focus; reading it in reactive code follows it. */\n readonly focused: boolean\n /** The editor's texts, in DouUI's locale or as given by the `messages` prop. */\n readonly messages: CodeMessages\n /** Reads a message out to screen readers. */\n announce: (message: string) => void\n /**\n * Runs the linter of the extension named `name` again now (every linter\n * without a name), for problems that arrive by themselves, such as ones a\n * server pushes.\n */\n relint: (name?: string) => void\n}\n\n/** Types an extension; returns it as it is. */\nexport function defineCodeExtension(extension: CodeExtension): CodeExtension {\n return extension\n}\n\nexport const CODE_EDITOR_KEY: InjectionKey<CodeExtensionContext> = Symbol('DouCodeEditor')\n\n/**\n * Internal: told each widget height an editor measures, by `extension/id`;\n * DouCodeDiff leaves a blank of the same height across from it.\n */\nexport const WIDGET_HEIGHT_KEY: InjectionKey<((key: string, height: number) => void) | null> =\n Symbol('DouCodeWidgetHeight')\n\n/** The editor a panel or gutter component is drawn in. */\nexport function useCodeEditor(): CodeExtensionContext {\n const context = inject(CODE_EDITOR_KEY, null)\n if (!context)\n throw new Error('[@dou-ui/code] useCodeEditor() must be called inside <DouCodeEditor>')\n return context\n}\n"],"mappings":";;;AA2XA,SAAgB,oBAAoB,WAAyC;CAC3E,OAAO;AACT;AAEA,IAAa,kBAAsD,OAAO,eAAe;;;;;AAMzF,IAAa,oBACX,OAAO,qBAAqB;;AAG9B,SAAgB,gBAAsC;CACpD,MAAM,UAAU,OAAO,iBAAiB,IAAI;CAC5C,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,sEAAsE;CACxF,OAAO;AACT"}
1
+ {"version":3,"file":"extension.js","names":[],"sources":["../src/extension.ts"],"sourcesContent":["import type { CodeMessages } from './locale'\nimport { type Component, type InjectionKey, type VNodeChild, inject } from 'vue'\nimport type { CodeKeymap } from './core/keymap'\nimport type { CodeSelection } from './core/selection'\nimport type { CodeText } from './core/text'\nimport type { CodeState, CodeTransaction, CodeTransactionResult } from './core/transaction'\nimport type { CodeEditorExpose } from './types'\n\n/** How bad a diagnostic is, worst first. */\nexport type CodeDiagnosticSeverity = 'error' | 'warning' | 'info' | 'hint'\n\n/** A fix offered with a diagnostic. */\nexport interface CodeDiagnosticAction {\n label: string\n /** Makes the fix, usually with `context.transact`. */\n run: (context: CodeExtensionContext, diagnostic: CodeDiagnostic) => void\n}\n\n/**\n * A problem found in the text, from `from` to `to` (offsets in the text,\n * the same as a language service's ranges). An empty range marks the\n * character after it.\n */\nexport interface CodeDiagnostic {\n from: number\n to: number\n severity: CodeDiagnosticSeverity\n message: string\n /** Who found it, shown after the message, e.g. the name of a linter. */\n source?: string\n /** Fixes, shown under the message and with `Mod` + `.`. */\n actions?: CodeDiagnosticAction[]\n}\n\n/**\n * How a part of the text is drawn. Marks and line classes only change how\n * the text looks (colors, backgrounds, underlines, borders), never its\n * size, so the cursor still lands where the characters are; an inline\n * widget takes its own room in the line.\n */\nexport type CodeDecoration =\n /**\n * Classes on the characters from `from` to `to`. `style` sets inline\n * styles on them as well, e.g. a CSS variable holding a person's color;\n * where marks overlap, the later one's styles win.\n */\n | {\n type: 'mark'\n from: number\n to: number\n class: string\n title?: string\n style?: Readonly<Record<string, string>>\n }\n /** A class on a whole line (`line` from 1), e.g. a tinted background. */\n | { type: 'line'; line: number; class: string }\n /**\n * Something drawn inside a line, before the character at `pos`, such as\n * a color swatch or a parameter's name. It isn't text: the cursor steps\n * over it and copying leaves it out. `width` in px saves measuring it;\n * without it the widget is measured once drawn, and the width is kept by\n * `id`.\n */\n | { type: 'inline'; pos: number; render: () => VNodeChild; width?: number; id?: string }\n\n/**\n * A component drawn between lines, across the editor, e.g. a review\n * comment. The lines below move down to make room, and it moves with the\n * text as lines are added or removed above it.\n */\nexport interface CodeWidget {\n /** Tells widgets apart, unique among one extension's; its measured height is kept by it. */\n id: string\n /**\n * Where it is: below the line of text position `pos`, or below line\n * `line` (from 1); above with `position: 'above'`. Give one of them.\n */\n pos?: number\n line?: number\n /** Defaults to `below`. */\n position?: 'above' | 'below'\n render: () => VNodeChild\n /** Its height in px before it has been drawn and measured; defaults to one line. */\n height?: number\n /** What it is, read out when the cursor moves onto its line, e.g. \"戴兜的评论\". */\n label?: string\n /**\n * Draws across the gutter too, taking the full width of the editor's view.\n * Off by default, so widgets start beside the gutter, aligned with the text.\n */\n fullWidth?: boolean\n}\n\n/** Something drawn in a column beside the line numbers, on line `line` (from 1). */\nexport interface CodeGutterMarker {\n line: number\n /** Drawn in the middle of the column. */\n icon?: Component\n /** Short text, when there is no icon. */\n text?: string\n class?: string\n /**\n * Shown on hover. Required when the column has `onPress`: the marker is\n * then a button, and this is its name.\n */\n title?: string\n /**\n * When the marker shows: `always`, or `hover`, out of sight until its\n * line is hovered, holds the cursor, or the marker has the focus, e.g. a\n * \"comment\" mark offered on every line. Defaults to `always`.\n */\n visible?: 'always' | 'hover'\n}\n\n/**\n * The marker a column shows on every line without one of its own, out of\n * sight until the line is hovered (as `visible: 'hover'`), e.g. \"add a\n * breakpoint\" offered on every line.\n */\nexport interface CodeGutterHoverMarker extends Pick<CodeGutterMarker, 'icon' | 'text' | 'class'> {\n /**\n * Its name, as a marker's `title`; a function names the marker of each\n * line, e.g. \"Add a breakpoint on line 3\". It is called for every line in\n * view, often: keep it quick.\n */\n title?: string | ((line: number) => string)\n}\n\n/** A column of the gutter, left of the line numbers. */\nexport interface CodeGutter {\n name: string\n /** In px. Defaults to 16 (or 18 when `overlay` is set). */\n width?: number\n /**\n * Draws markers floating over the gutter's right edge without reserving a\n * dedicated column width (0px layout footprint). Best paired with\n * `hoverMarker` or `visible: 'hover'` for row actions such as adding review\n * comments. Empty rows take no pointer events.\n */\n overlay?: boolean\n /** The markers on the lines in view; reactive state read here updates them. */\n markers?: (context: CodeExtensionContext) => CodeGutterMarker[]\n /** A marker on every other line, shown on hover. */\n hoverMarker?: CodeGutterHoverMarker\n /**\n * Where `onPress` answers: `any` cell of the column (the default), e.g. to\n * set a breakpoint on an empty line, or only its `markers`.\n */\n pressOn?: 'any' | 'markers'\n /**\n * A press on the column, on line `line`, e.g. to set a breakpoint. A\n * marker in such a column is a button: the one on the cursor's line is\n * reached with Escape then Shift+Tab, and Enter or Space presses it. A\n * finger or pen presses when it lifts in place; a tap on a marker still\n * out of sight first moves the cursor to its line, which shows it.\n */\n onPress?: (\n line: number,\n event: PointerEvent | KeyboardEvent,\n context: CodeExtensionContext,\n ) => void\n}\n\n/** An undo history that takes the place of the editor's own, e.g. one shared with others. */\nexport interface CodeHistoryHandler {\n /** `false` when there is nothing to undo. */\n undo: () => boolean\n redo: () => boolean\n /** Read in templates and computed values: keep them reactive. */\n canUndo: () => boolean\n canRedo: () => boolean\n /** The next change starts a new undo step, e.g. when the editor loses focus. */\n close?: () => void\n}\n\n/** A bar above or below the text, inside the editor's frame. */\nexport interface CodePanel {\n /** Tells panels apart, unique among one extension's. */\n name: string\n /** Defaults to `bottom`. */\n position?: 'top' | 'bottom'\n render: () => VNodeChild\n}\n\n/** What a completion is, shown as its icon. */\nexport type CodeCompletionKind =\n | 'keyword'\n | 'function'\n | 'method'\n | 'variable'\n | 'property'\n | 'constant'\n | 'class'\n | 'type'\n | 'module'\n | 'snippet'\n | 'text'\n\n/** One entry of the completion list. */\nexport interface CodeCompletion {\n /** Shown, and matched against what was typed. */\n label: string\n kind?: CodeCompletionKind\n /** Short, after the label, e.g. a type. */\n detail?: string\n /** Longer, below the list while this entry is picked: text, or a function returning VNodes. */\n info?: string | (() => VNodeChild)\n /** What goes into the text, if not the label. */\n insert?: string\n /** Inserted as a snippet instead: `${1:name}` places to fill in, Tab to the next, `$0` where it ends. */\n snippet?: string\n /** Moves the entry up (positive) or down among equally good matches. */\n boost?: number\n}\n\n/** What a completion source is asked with. */\nexport interface CodeCompletionRequest {\n /** The cursor. */\n pos: number\n /** The word right before the cursor, by the language's word characters; empty when there is none. */\n word: { from: number; to: number; text: string }\n /** Asked for from the keyboard (`Ctrl` + `Space`, `Alt` + `Esc`) rather than by typing. */\n explicit: boolean\n /** Aborted when the answer is no longer wanted, so a slow source can stop. */\n signal: AbortSignal\n}\n\n/** What a hover or signature source is asked with. */\nexport interface CodePositionRequest {\n /** The position asked about: under the pointer, or the cursor. */\n pos: number\n /** Aborted when the answer is no longer wanted, so a slow source can stop. */\n signal: AbortSignal\n}\n\n/** What a completion source answers: entries to put in place of `from`–cursor. */\nexport interface CodeCompletionResult {\n from: number\n options: CodeCompletion[]\n}\n\n/** Text shown on hover, or with the cursor on it from the keyboard. */\nexport interface CodeHoverResult {\n /** What it is about, `from`–`to`; defaults to the word under the pointer. */\n from?: number\n to?: number\n /** Plain text, or a render function for anything else. */\n content: string | (() => VNodeChild)\n}\n\n/** The parameters of the call the cursor is in. */\nexport interface CodeSignatureResult {\n /** The whole signature, e.g. `slice(start, end)`. */\n label: string\n /** Each parameter as `[from, to]` in `label`. */\n params: Array<[number, number]>\n /** Which parameter the cursor is at, from 0. */\n active: number\n /** Shown under the signature: text, or a function returning VNodes. */\n info?: string | (() => VNodeChild)\n}\n\nexport interface CodeExtension {\n name: string\n /** Higher runs first: its keys and hooks come before others. Defaults to 100. */\n priority?: number\n /** Keys tried before the built-in ones, and after the `keymap` prop. */\n keymap?: (context: CodeExtensionContext) => CodeKeymap\n /**\n * How parts of the text look, read while drawing: reactive state read\n * here updates them. Asked for the lines in view (`context.visible`),\n * which is all that needs them.\n */\n decorations?: (context: CodeExtensionContext) => CodeDecoration[]\n /** Columns beside the line numbers. */\n gutters?: CodeGutter[]\n /**\n * Components between lines. Unlike decorations, these are asked for the\n * whole text, since their heights place every line after them; keep\n * them few (comments, not one per line).\n */\n widgets?: (context: CodeExtensionContext) => CodeWidget[]\n /**\n * Lines left out of view: line numbers (from 1, not text positions), from\n * line `from` to line `to`, both left out,\n * e.g. the unchanged lines of a diff. Unlike a fold, nothing marks the\n * spot; put a widget there for that. Asked for the whole text; reactive\n * state read here updates them. Moving up and down steps over them.\n */\n hide?: (context: CodeExtensionContext) => Array<{ from: number; to: number }>\n /** Bars above or below the text; reactive state read here updates them. */\n panels?: (context: CodeExtensionContext) => CodePanel[]\n /**\n * Finds problems in the text. Run when the editor mounts and again a\n * moment after the text stops changing; an answer that arrives after\n * the text changed again is dropped, and the next run follows it.\n * Meanwhile the problems found move with the text.\n */\n lint?: (\n context: CodeExtensionContext,\n ) => CodeDiagnostic[] | null | undefined | Promise<CodeDiagnostic[] | null | undefined>\n /**\n * Offers completions while typing (after a word character or one of\n * `completionTriggers`) and on `Ctrl` + `Space` or `Alt` + `Esc`. Answers from every\n * extension are put in one list; a Promise is waited for, and dropped\n * when the text has moved on.\n */\n completion?: (\n request: CodeCompletionRequest,\n context: CodeExtensionContext,\n ) => CodeCompletionResult | null | undefined | Promise<CodeCompletionResult | null | undefined>\n /** Characters that ask for completions when typed, such as `.`. */\n completionTriggers?: string[]\n /**\n * Text about a position, shown on hover and with `Mod` + `I`. A Promise\n * is waited for; `signal` aborts when the pointer moves on.\n */\n hover?: (\n request: CodePositionRequest,\n context: CodeExtensionContext,\n ) => CodeHoverResult | null | undefined | Promise<CodeHoverResult | null | undefined>\n /**\n * The parameters of the call around the cursor, shown while typing its\n * arguments. A Promise is waited for, and dropped when the cursor has\n * moved on.\n */\n signature?: (\n request: CodePositionRequest,\n context: CodeExtensionContext,\n ) => CodeSignatureResult | null | undefined | Promise<CodeSignatureResult | null | undefined>\n /**\n * Sees every change before it is applied, in priority order, and may add\n * to it (positions are in the text before the change). Undo, redo, new\n * `v-model` values and other people's changes (`action: 'remote'`) don't\n * come through here.\n */\n transaction?: (tr: CodeTransaction, context: CodeExtensionContext) => void\n /**\n * Runs after every step the editor took, with the text and selection\n * already updated: typing, commands, undo and redo, new `v-model`\n * values and other people's changes. `result.meta.action` tells them\n * apart.\n */\n update?: (result: CodeTransactionResult, context: CodeExtensionContext) => void\n /**\n * Replaces the editor's undo history; the first extension that has one\n * wins. Called once per list of extensions: return the same handler\n * each time.\n */\n history?: (context: CodeExtensionContext) => CodeHistoryHandler\n /**\n * Buttons added to the toolbar shown over the selection on touch screens,\n * after cut, copy, paste and select all. Read again as the selection\n * changes.\n */\n menu?: (context: CodeExtensionContext) => CodeMenuItem[]\n /** Runs once the editor is mounted. Return a function to run when it unmounts. */\n setup?: (context: CodeExtensionContext) => void | (() => void)\n}\n\n/** A button of the touch toolbar, from an extension's `menu`. */\nexport interface CodeMenuItem {\n label: string\n run: (context: CodeExtensionContext) => void\n}\n\n/** What an extension sees of the editor: its instance, plus a little more. */\nexport interface CodeExtensionContext extends CodeEditorExpose {\n /** The text and selection now; reading them in `decorations` or `panels` follows every change. */\n readonly state: CodeState\n readonly doc: CodeText\n readonly selection: CodeSelection\n /** The lines in view: line numbers (from 1, not text positions), both ends in view. */\n readonly visible: { readonly from: number; readonly to: number }\n /** The problems found now, by all linters and the `diagnostics` prop, in text order. */\n readonly diagnostics: readonly CodeDiagnostic[]\n /** Whether the editor has focus; reading it in reactive code follows it. */\n readonly focused: boolean\n /** The editor's texts, in DouUI's locale or as given by the `messages` prop. */\n readonly messages: CodeMessages\n /** Reads a message out to screen readers. */\n announce: (message: string) => void\n /**\n * Runs the linter of the extension named `name` again now (every linter\n * without a name), for problems that arrive by themselves, such as ones a\n * server pushes.\n */\n relint: (name?: string) => void\n}\n\n/** Types an extension; returns it as it is. */\nexport function defineCodeExtension(extension: CodeExtension): CodeExtension {\n return extension\n}\n\nexport const CODE_EDITOR_KEY: InjectionKey<CodeExtensionContext> = Symbol('DouCodeEditor')\n\n/**\n * Internal: told each widget height an editor measures, by `extension/id`;\n * DouCodeDiff leaves a blank of the same height across from it.\n */\nexport const WIDGET_HEIGHT_KEY: InjectionKey<((key: string, height: number) => void) | null> =\n Symbol('DouCodeWidgetHeight')\n\n/** The editor a panel or gutter component is drawn in. */\nexport function useCodeEditor(): CodeExtensionContext {\n const context = inject(CODE_EDITOR_KEY, null)\n if (!context)\n throw new Error('[@dou-ui/code] useCodeEditor() must be called inside <DouCodeEditor>')\n return context\n}\n"],"mappings":";;;AAuYA,SAAgB,oBAAoB,WAAyC;CAC3E,OAAO;AACT;AAEA,IAAa,kBAAsD,OAAO,eAAe;;;;;AAMzF,IAAa,oBACX,OAAO,qBAAqB;;AAG9B,SAAgB,gBAAsC;CACpD,MAAM,UAAU,OAAO,iBAAiB,IAAI;CAC5C,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,sEAAsE;CACxF,OAAO;AACT"}
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- @layer dou.components{.dou-code-editor{--dou-code-editor-font-size:var(--dou-font-size-sm);--dou-code-editor-line-height:20px;--dou-code-editor-padding-y:8px;--dou-code-editor-padding-x:12px;--dou-code-editor-bg:var(--dou-color-bg-surface);--dou-code-editor-gutter-bg:var(--dou-code-editor-bg);--dou-code-editor-gutter-text:var(--dou-color-text-tertiary);--dou-code-editor-border:var(--dou-color-border);--dou-code-editor-border-focus:color-mix(in oklab,var(--dou-color-focus)70%,var(--dou-color-text));--dou-code-editor-cursor:var(--dou-color-text);--dou-code-editor-active-line:color-mix(in oklab,var(--dou-color-text)4%,transparent);--dou-code-editor-selection:color-mix(in oklab,var(--dou-color-primary)20%,transparent);--dou-code-editor-match:color-mix(in oklab,var(--dou-color-warning)22%,transparent);--dou-code-editor-match-current:color-mix(in oklab,var(--dou-color-warning-text)80%,transparent);--dou-code-editor-match-mark:color-mix(in oklab,var(--dou-color-warning)60%,transparent);--dou-code-editor-bracket:color-mix(in oklab,var(--dou-color-text)35%,transparent);--dou-code-editor-error:var(--dou-color-danger-text);--dou-code-editor-warning:var(--dou-color-warning-text);--dou-code-editor-info:var(--dou-color-primary-text);--dou-code-editor-bracket-unmatched:color-mix(in oklab,var(--dou-color-danger-text)70%,transparent);position:relative;display:flex;box-sizing:border-box;min-height:calc(var(--dou-code-editor-line-height) + 2*var(--dou-code-editor-padding-y) + 2px);overflow:hidden;border:1px solid var(--dou-code-editor-border);border-radius:var(--dou-radius-container);background-color:var(--dou-code-editor-bg);color:var(--dou-color-text);font-family:var(--dou-font-family-mono);font-size:var(--dou-code-editor-font-size);font-variant-ligatures:none;line-height:var(--dou-code-editor-line-height);transition:border-color var(--dou-motion-duration-fast)var(--dou-motion-easing);flex-direction:column;width:100%;min-width:0}.dou-code-editor.is-focused{border-color:var(--dou-code-editor-border-focus)}.dou-code-editor:not(.is-bordered){min-height:calc(var(--dou-code-editor-line-height) + 2*var(--dou-code-editor-padding-y));border:0;border-radius:0}.dou-code-editor:not(.is-focused){--dou-code-editor-selection:color-mix(in oklab,var(--dou-color-text)10%,transparent)}.dou-code-editor.is-disabled{color:var(--dou-color-text-disabled);cursor:not-allowed}.dou-code-editor__body{position:relative;display:flex;flex:auto;min-height:0}.dou-code-editor__scroller{position:relative;overflow:auto;overscroll-behavior-x:contain;scrollbar-width:thin;flex:auto;min-width:0;min-height:0}.dou-code-editor:not(.is-scroll-y)>.dou-code-editor__body>.dou-code-editor__scroller{overflow-x:auto;overflow-y:hidden}.dou-code-editor__minimap{position:relative;overflow:hidden;box-shadow:inset 1px 0 0 color-mix(in oklab,var(--dou-color-text)6%,transparent);color:var(--dou-color-text-tertiary);cursor:default;touch-action:none;user-select:none;flex:none;width:96px}.dou-code-editor__minimap-canvas{position:absolute;width:100%;height:100%;inset:0}.dou-code-editor__minimap-view{position:absolute;background-color:color-mix(in oklab,var(--dou-color-text)6%,transparent);transition:background-color var(--dou-motion-duration-fast)var(--dou-motion-easing);top:0;left:0;right:0}.dou-code-editor__minimap:hover .dou-code-editor__minimap-view{background-color:color-mix(in oklab,var(--dou-color-text)9%,transparent)}.dou-code-editor__minimap:active .dou-code-editor__minimap-view{background-color:color-mix(in oklab,var(--dou-color-text)12%,transparent)}.dou-code-editor__sizer{position:relative;display:flex;box-sizing:border-box;width:max-content;min-width:100%}.dou-code-editor__gutter{position:sticky;z-index:2;box-sizing:border-box;width:var(--dou-code-editor-gutter);background-color:var(--dou-code-editor-gutter-bg);color:var(--dou-code-editor-gutter-text);font-variant-numeric:tabular-nums;cursor:default;user-select:none;-webkit-user-select:none;touch-action:manipulation;flex:none;left:0}.dou-code-editor__numbers{position:absolute;will-change:transform;top:0;left:0;right:0}.dou-code-editor__number{position:relative;box-sizing:border-box;height:var(--dou-code-editor-line-height);padding:0 12px 0 calc(16px + var(--dou-code-editor-gutter-cells,0px));text-align:right}.dou-code-editor__number.is-active{color:var(--dou-color-text-secondary)}.dou-code-editor.is-foldable .dou-code-editor__number{padding-right:24px}.dou-code-editor__fold-toggle{position:absolute;display:flex;height:var(--dou-code-editor-line-height);color:var(--dou-color-text-tertiary);cursor:pointer;opacity:0;transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing);justify-content:center;align-items: center;width:14px;font-size:12px;top:0;right:6px}.dou-code-editor__gutter:hover .dou-code-editor__fold-toggle{opacity:1}.dou-code-editor__fold-toggle.is-folded{opacity:1}.dou-code-editor__fold-toggle:hover{color:var(--dou-color-text)}@media (pointer:coarse){.dou-code-editor__fold-toggle{opacity:1}.dou-code-editor__fold-toggle:before{position:absolute;content:"";inset:-4px -6px}}.dou-code-editor__content{position:relative;cursor:text;touch-action:manipulation;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;flex:auto;min-width:0}.dou-code-editor.is-disabled .dou-code-editor__content{cursor:not-allowed}.dou-code-editor__lines,.dou-code-editor__matches,.dou-code-editor__brackets,.dou-code-editor__selections,.dou-code-editor__cursors{position:absolute;pointer-events:none;top:0;left:0}.dou-code-editor__lines{will-change:transform;right:0}.dou-code-editor__line{box-sizing:border-box;height:var(--dou-code-editor-line-height);padding:0 var(--dou-code-editor-padding-x);white-space:pre;tab-size:var(--dou-code-editor-tab-size,2)}.dou-code-editor__line.is-wrapped{height:auto}.dou-code-editor__row{box-sizing:border-box;height:var(--dou-code-editor-line-height)}.dou-code-editor__fold-marker{display:inline-block;box-sizing:border-box;border:1px solid var(--dou-color-border);background-color:var(--dou-color-bg-muted);color:var(--dou-color-text-secondary);vertical-align:1px;cursor:pointer;pointer-events:auto;border-radius:4px;height:16px;margin-left:6px;padding:0 6px;font-size:12px;line-height:14px}.dou-code-editor__fold-marker:hover{color:var(--dou-color-text)}.dou-code-editor__line :-webkit-any(.dou-syntax-heading,.dou-syntax-strong){font-weight:inherit}.dou-code-editor__line :-moz-any(.dou-syntax-heading,.dou-syntax-strong){font-weight:inherit}.dou-code-editor__line :is(.dou-syntax-heading,.dou-syntax-strong){font-weight:inherit}.dou-code-editor__compose{text-decoration:underline;text-decoration-color:var(--dou-color-text-tertiary);text-underline-offset:3px}.dou-code-editor__probe{position:absolute;visibility:hidden;white-space:pre;pointer-events:none;top:0;left:0}.dou-code-editor__active-line{position:absolute;height:var(--dou-code-editor-line-height);background-color:var(--dou-code-editor-active-line);pointer-events:none;top:0;left:0;right:0}.dou-code-editor:not(.is-focused) .dou-code-editor__active-line{background-color:#0000}.dou-code-editor__match{position:absolute;box-sizing:border-box;height:var(--dou-code-editor-line-height);background-color:var(--dou-code-editor-match);border-radius:2px;top:0;left:0}.dou-code-editor__match.is-current{box-shadow:inset 0 0 0 1px var(--dou-code-editor-match-current)}.dou-code-editor__marks{position:absolute;z-index:3;pointer-events:none;width:6px;top:0;bottom:0;right:0}.dou-code-editor__mark{position:absolute;background-color:var(--dou-code-editor-match-mark);border-radius:1px;width:6px;height:2px;right:0}.dou-code-editor__mark.is-current{background-color:var(--dou-code-editor-match-current);height:3px}.dou-code-editor__live{position:absolute;overflow:hidden;clip-path:inset(50%);white-space:nowrap;width:1px;height:1px}.dou-code-editor__search{position:absolute;z-index:4;display:flex;container-type:inline-size;pointer-events:none;justify-content:flex-end;top:6px;left:6px;right:14px}.dou-code-editor__search>*{pointer-events:auto}.dou-code-editor__bracket{position:absolute;box-sizing:border-box;height:var(--dou-code-editor-line-height);border:1px solid var(--dou-code-editor-bracket);border-radius:2px;top:0;left:0}.dou-code-editor__bracket.is-unmatched{border-color:var(--dou-code-editor-bracket-unmatched)}.dou-code-editor__selection{position:absolute;height:var(--dou-code-editor-line-height);background-color:var(--dou-code-editor-selection);border-radius:2px;top:0;left:0}.dou-code-editor__cursor{position:absolute;height:var(--dou-code-editor-line-height);background-color:var(--dou-code-editor-cursor);animation:1.2s step-end .5s infinite dou-code-editor-blink;border-radius:1px;width:2px;top:0;left:0}.dou-code-editor.is-readonly .dou-code-editor__cursor{opacity:.4;animation:none}@media (prefers-reduced-motion:reduce){.dou-code-editor__cursor{animation:none}}.dou-code-editor__placeholder{position:absolute;top:var(--dou-code-editor-padding-y);left:var(--dou-code-editor-padding-x);color:var(--dou-color-text-tertiary);white-space:pre;pointer-events:none}.dou-code-editor__input{position:absolute;z-index:-1;box-sizing:border-box;width:calc(100% - var(--dou-code-editor-padding-x));overflow:hidden;outline:none;color:#0000;caret-color:transparent;font:inherit;font-size:max(var(--dou-font-size-input-min),var(--dou-code-editor-font-size));line-height:inherit;letter-spacing:inherit;white-space:pre;tab-size:var(--dou-code-editor-tab-size,2);resize:none;pointer-events:none;background:0 0;border:0;min-width:1px;margin:0;padding:0}.dou-code-editor__input::selection{background:0 0}}@layer dou.components{.dou-code-editor__problem{text-decoration-line:underline;text-decoration-style:wavy;text-decoration-thickness:1px;text-decoration-skip-ink:none;text-underline-offset:3px}.dou-code-editor__problem.is-error{text-decoration-color:var(--dou-code-editor-error)}.dou-code-editor__problem.is-warning{text-decoration-color:var(--dou-code-editor-warning)}.dou-code-editor__problem.is-info{text-decoration-color:var(--dou-code-editor-info)}.dou-code-editor__problem.is-hint{text-decoration-style:dotted;text-decoration-color:var(--dou-color-text-tertiary)}.dou-code-editor__cells{position:absolute;display:flex;top:0;bottom:0;left:0}.dou-code-editor__cell{display:inline-grid;grid-template-rows:var(--dou-code-editor-line-height);grid-auto-flow:column;position:relative;font-size:var(--dou-font-size-sm);flex:none;place-content: start center;align-items: center;height:100%}.dou-code-editor__cell[data-gutter-cell]{cursor:pointer}.dou-code-editor.is-disabled .dou-code-editor__cell[data-gutter-cell]{cursor:default}.dou-code-editor__cell[role=button]{border-radius:var(--dou-radius-control)}.dou-code-editor__cell[role=button]:focus-visible{outline:none}.dou-code-editor__cell[role=button]:focus-visible:after{position:absolute;box-sizing:border-box;height:var(--dou-code-editor-line-height);border:2px solid var(--dou-color-focus);border-radius:var(--dou-radius-control);content:"";pointer-events:none;top:0;left:0;right:0}.dou-code-editor__cell>svg{width:14px;height:14px}.dou-code-editor__cell.is-on-hover{opacity:0;transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing)}.dou-code-editor:not(.is-disabled) .dou-code-editor__number:-webkit-any(:hover,.is-hovered)>.dou-code-editor__cells>.dou-code-editor__cell.is-on-hover{opacity:1}.dou-code-editor:not(.is-disabled) .dou-code-editor__number:-moz-any(:hover,.is-hovered)>.dou-code-editor__cells>.dou-code-editor__cell.is-on-hover{opacity:1}.dou-code-editor:not(.is-disabled) .dou-code-editor__number:is(:hover,.is-hovered)>.dou-code-editor__cells>.dou-code-editor__cell.is-on-hover{opacity:1}.dou-code-editor.is-focused .dou-code-editor__number.is-active>.dou-code-editor__cells>.dou-code-editor__cell.is-on-hover{opacity:1}.dou-code-editor__cell.is-on-hover:focus-visible{opacity:1}.dou-code-editor__problem-icon.is-error{color:var(--dou-code-editor-error)}.dou-code-editor__problem-icon.is-warning{color:var(--dou-code-editor-warning)}.dou-code-editor__problem-icon.is-info{color:var(--dou-code-editor-info)}.dou-code-editor__problem-icon.is-hint{color:var(--dou-color-text-tertiary)}.dou-code-editor__problem-mark.is-error{background-color:var(--dou-code-editor-error)}.dou-code-editor__problem-mark.is-warning{background-color:var(--dou-code-editor-warning)}.dou-code-editor__problem-mark.is-info{background-color:var(--dou-code-editor-info)}.dou-code-editor__problem-mark.is-hint{background-color:var(--dou-color-text-tertiary)}.dou-code-editor__floating{display:contents}.dou-code-editor__floating.is-outside{--dou-code-editor-font-size:var(--dou-font-size-sm);--dou-code-editor-bg:var(--dou-color-bg-surface);--dou-code-editor-error:var(--dou-color-danger-text);--dou-code-editor-warning:var(--dou-color-warning-text);--dou-code-editor-info:var(--dou-color-primary-text);position:absolute;display:block;color:var(--dou-color-text);transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing);width:0;height:0;line-height:20px;top:0;left:0}.dou-code-editor__floating.is-outside.is-scrolling{opacity:0;pointer-events:none;transition:none}.dou-code-editor__floating.is-outside.is-fixed{position:fixed}.dou-code-editor__problems{position:absolute;z-index:6;box-sizing:border-box;display:flex;border:1px solid var(--dou-color-border);border-radius:var(--dou-radius-control);background-color:var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);white-space:normal;overflow-y:auto;overscroll-behavior:contain;flex-direction:column;gap:4px;width:max-content;max-width:min(440px,100% - 8px);padding:6px;line-height:20px;top:0;left:0}.dou-code-editor__problems>*{flex-shrink:0}.dou-code-editor__problem-item{display:flex;align-items: flex-start;gap:6px;padding:0 2px}.dou-code-editor__problem-item.is-error{--dou-code-editor-problem:var(--dou-code-editor-error)}.dou-code-editor__problem-item.is-warning{--dou-code-editor-problem:var(--dou-code-editor-warning)}.dou-code-editor__problem-item.is-info{--dou-code-editor-problem:var(--dou-code-editor-info)}.dou-code-editor__problem-item.is-hint{--dou-code-editor-problem:var(--dou-color-text-tertiary)}.dou-code-editor__problem-severity{color:var(--dou-code-editor-problem);flex:none;width:14px;height:20px}.dou-code-editor__problem-message{overflow-wrap:anywhere;color:var(--dou-color-text);min-width:0}.dou-code-editor__problem-source{color:var(--dou-color-text-tertiary);margin-left:8px}.dou-code-editor__fixes{display:flex;border-top:1px solid var(--dou-color-border-subtle);flex-wrap:wrap;gap:2px;padding-top:4px}.dou-code-editor__fix{display:inline-flex;border-radius:calc(var(--dou-radius-control) - 2px);color:var(--dou-color-primary-text);font:inherit;cursor:pointer;background:0 0;border:0;align-items: center;height:24px;padding:0 8px}.dou-code-editor__fix.is-active{background-color:color-mix(in oklab,var(--dou-color-text)6%,transparent)}.dou-code-editor__fix:hover{background-color:color-mix(in oklab,var(--dou-color-text)6%,transparent)}@media (pointer:coarse){.dou-code-editor__fix{height:36px}}.dou-code-editor__hover{color:var(--dou-color-text);overflow-wrap:anywhere;white-space:pre-wrap;padding:0 2px}.dou-code-editor__hover+.dou-code-editor__problem-item{border-top:1px solid var(--dou-color-border-subtle);padding-top:4px}.dou-code-lsp-markup{display:flex;white-space:normal;flex-direction:column;gap:6px}.dou-code-lsp-markup__text{white-space:pre-wrap;margin:0}.dou-code-lsp-markup__code{font-family:var(--dou-font-family-mono);white-space:pre-wrap;margin:0}.dou-code-lsp-markup__inline{font-family:var(--dou-font-family-mono)}.dou-code-editor__completions{position:absolute;z-index:7;box-sizing:border-box;display:flex;border:1px solid var(--dou-color-border);border-radius:var(--dou-radius-control);background-color:var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);font-family:var(--dou-font-family-mono);font-size:var(--dou-code-editor-font-size);flex-direction:column;width:max-content;min-width:min(200px,100%);max-height:264px;padding:4px;line-height:20px;top:0;left:0}.dou-code-editor__completion-list{overflow-y:auto;overscroll-behavior:contain;flex:0 auto;min-height:28px}.dou-code-editor__completion{display:flex;border-radius:calc(var(--dou-radius-control) - 2px);color:var(--dou-color-text);cursor:pointer;align-items: center;gap:8px;height:28px;padding:0 8px 0 6px}.dou-code-editor__completion.is-active{background-color:color-mix(in oklab,var(--dou-color-text)8%,transparent)}@media (hover:hover){.dou-code-editor__completion:not(.is-active):hover{background-color:color-mix(in oklab,var(--dou-color-text)4%,transparent)}}@media (pointer:coarse){.dou-code-editor__completion{height:36px}}.dou-code-editor__completion-kind{color:var(--dou-color-text-tertiary);flex:none;width:16px;height:16px}.dou-code-editor__completion-label{overflow:hidden;text-overflow:ellipsis;white-space:pre;flex:none;max-width:75%}.dou-code-editor__completion-match{color:var(--dou-color-primary-text);background:0 0;font-weight:600}.dou-code-editor__completion-detail{overflow:hidden;color:var(--dou-color-text-tertiary);font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);text-overflow:ellipsis;white-space:nowrap;flex:0 auto;min-width:0;margin-left:auto;padding-left:16px}.dou-code-editor__completion-info{border-top:1px solid var(--dou-color-border-subtle);color:var(--dou-color-text-secondary);font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);white-space:pre-wrap;overflow-wrap:anywhere;flex:none;max-width:400px;margin-top:4px;padding:6px 6px 2px}.dou-code-editor__signature{position:absolute;z-index:6;box-sizing:border-box;border:1px solid var(--dou-color-border);border-radius:var(--dou-radius-control);background-color:var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);font-size:var(--dou-font-size-sm);overflow-y:auto;pointer-events:none;width:max-content;max-width:min(440px,100% - 8px);padding:4px 8px;line-height:20px;top:0;left:0}.dou-code-editor__signature-label{color:var(--dou-color-text-secondary);font-family:var(--dou-font-family-mono);font-size:var(--dou-code-editor-font-size);overflow-wrap:anywhere}.dou-code-editor__signature-active{color:var(--dou-color-text);text-decoration:underline;text-underline-offset:3px;font-weight:600}.dou-code-editor__signature-info{color:var(--dou-color-text-tertiary);font-family:var(--dou-font-family);white-space:pre-wrap}.dou-code-editor__field{box-shadow:inset 0 0 0 1px var(--dou-color-border-strong);border-radius:2px}.dou-code-editor__widgets{position:absolute;z-index:3;top:0;left:0}.dou-code-editor__widget{position:absolute;box-sizing:border-box;cursor:auto;font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);white-space:normal;user-select:text;-webkit-user-select:text;display:flow-root;line-height:20px;top:0;left:0}.dou-code-editor__inline{display:inline-block;vertical-align:top;height:var(--dou-code-editor-line-height);white-space:nowrap}.dou-code-editor__panels{font-family:var(--dou-font-family);flex:none}.dou-code-editor__panels.is-top{border-bottom:1px solid var(--dou-color-border-subtle)}.dou-code-editor__panels.is-bottom{border-top:1px solid var(--dou-color-border-subtle)}.dou-code-editor__handle{position:absolute;z-index:5;touch-action:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;width:0;height:0;top:0;left:0}.dou-code-editor__handle:before{position:absolute;content:"";width:36px;height:36px;top:-6px}.dou-code-editor__handle:after{position:absolute;background-color:var(--dou-color-primary);content:"";width:14px;height:14px;top:0}.dou-code-editor__handle.is-start:before{left:-27px}.dou-code-editor__handle.is-start:after{border-radius:50% 0 50% 50%;right:0}.dou-code-editor__handle.is-end:before{left:-9px}.dou-code-editor__handle.is-end:after{border-radius:0 50% 50%;left:0}.dou-code-editor__handle.is-caret:before{left:-18px}.dou-code-editor__handle.is-caret:after{border-radius:0 50% 50%;width:12px;height:12px;top:4px;left:-6px;transform:rotate(45deg)}.dou-code-editor__magnifier{position:absolute;z-index:6;box-sizing:border-box;overflow:hidden;border:1px solid var(--dou-color-border);background:linear-gradient(var(--dou-code-editor-bg),var(--dou-code-editor-bg)),var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);pointer-events:none;border-radius:999px;width:128px;top:0;left:0}.dou-code-editor__magnifier-text{position:absolute;height:var(--dou-code-editor-line-height);margin-top:calc(var(--dou-code-editor-line-height)/-2);white-space:pre;tab-size:var(--dou-code-editor-tab-size);transform-origin:0 50%;top:50%;left:0}.dou-code-editor__magnifier-caret{position:absolute;height:calc(var(--dou-code-editor-line-height)*1.5);background-color:var(--dou-color-primary);border-radius:1px;width:2px;top:50%;translate:0 -50%}.dou-code-editor__menu{position:absolute;z-index:6;display:flex;border:1px solid var(--dou-color-border);border-radius:calc(var(--dou-radius-control) + 2px);background-color:var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);font-family:var(--dou-font-family);white-space:nowrap;gap:2px;padding:2px;top:0;left:0}.dou-code-editor__menu-button{display:inline-flex;border-radius:var(--dou-radius-control);color:var(--dou-color-text);font:inherit;font-size:var(--dou-font-size-sm);cursor:pointer;-webkit-tap-highlight-color:transparent;background:0 0;border:0;align-items: center;min-width:36px;height:36px;padding:0 12px;line-height:1}.dou-code-editor__menu-button:active{background-color:color-mix(in oklab,var(--dou-color-text)8%,transparent)}@media (hover:hover){.dou-code-editor__menu-button:hover{background-color:color-mix(in oklab,var(--dou-color-text)5%,transparent)}}.dou-code-editor__keys{position:absolute;box-sizing:border-box;display:flex;border:1px solid color-mix(in oklab,var(--dou-color-text)10%,transparent);background-color:color-mix(in oklab,var(--dou-color-bg-surface)92%,transparent);box-shadow:var(--dou-shadow-md);-webkit-backdrop-filter:blur(20px)saturate(1.8);backdrop-filter:blur(20px)saturate(1.8);transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing);border-radius:22px;height:44px;padding:0 3px 0 0;top:0;left:0}.dou-code-editor__keys.is-fixed{position:fixed}.dou-code-editor__keys.is-scrolling{opacity:0;pointer-events:none;transition:none}.dou-code-editor__keys>.dou-code-keys{background-color:#0000;border-top:0;flex:auto;min-width:0;height:42px}.dou-code-editor__keys>.dou-code-keys .dou-code-keys__scroll{padding:0}.dou-code-editor__keys>.dou-code-keys .dou-code-keys__arrows{position:relative;box-shadow:none;padding:0 0 0 5px}.dou-code-editor__keys>.dou-code-keys .dou-code-keys__arrows:before{position:absolute;background-color:var(--dou-color-border-subtle);content:"";width:1px;top:10px;bottom:10px;left:0}.dou-code-editor__keys>.dou-code-keys .dou-code-keys__key{border-radius:18px}.dou-code-editor__keys-grip{display:flex;color:var(--dou-color-text-tertiary);cursor:grab;touch-action:none;-webkit-tap-highlight-color:transparent;background:0 0;border:0;flex:none;justify-content:center;align-items: center;width:36px;margin:0;padding:0 0 0 6px}.dou-code-editor__keys-grip>svg{width:18px;height:18px}.dou-code-editor__keys-grip:active{cursor:grabbing}.dou-code-editor__keys-grip:focus-visible{outline:2px solid var(--dou-color-focus);outline-offset:-4px;border-radius:18px}.dou-code-keys{display:flex;box-sizing:border-box;border-top:1px solid var(--dou-color-border);background-color:var(--dou-color-bg-surface);color:var(--dou-color-text);font-family:var(--dou-font-family-mono);font-size:var(--dou-font-size-md);user-select:none;-webkit-user-select:none;height:45px}.dou-code-keys__scroll{display:flex;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:none;touch-action:pan-x;flex:auto;align-items: center;gap:2px;min-width:0;padding:0 4px}.dou-code-keys__scroll::-webkit-scrollbar{display:none}.dou-code-keys__arrows{display:flex;box-shadow:-1px 0 0 var(--dou-color-border-subtle);flex:none;align-items: center;gap:2px;padding:0 4px}.dou-code-keys__stick{position:relative;color:var(--dou-color-text-tertiary);cursor:grab;touch-action:none;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;background:0 0;border:0;border-radius:50%;flex:none;width:36px;height:36px;margin:0;padding:0}.dou-code-keys__stick:focus-visible{outline:2px solid var(--dou-color-focus);outline-offset:0}.dou-code-keys__pad{position:absolute;z-index:1;display:flex;box-sizing:border-box;background-color:var(--dou-color-bg-muted);box-shadow:inset 0 0 0 1px var(--dou-color-border-subtle);pointer-events:none;transition-property:width,height,margin,background-color,box-shadow,translate;transition-duration:var(--dou-motion-duration-normal);transition-timing-function:var(--dou-motion-easing);border-radius:50%;justify-content:center;align-items: center;width:32px;height:32px;margin:-16px 0 0 -16px;top:50%;left:50%}.dou-code-keys__way{position:absolute;opacity:0;transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing);width:16px;height:16px}.dou-code-keys__way.is-up{top:8px}.dou-code-keys__way.is-down{bottom:8px}.dou-code-keys__way.is-left{left:8px}.dou-code-keys__way.is-right{right:8px}.dou-code-keys__thumb{box-sizing:border-box;background-color:var(--dou-color-bg-surface);box-shadow:0 0 0 1px color-mix(in oklab,var(--dou-color-text)14%,transparent),var(--dou-shadow-sm);transition-property:width,height,transform;transition-duration:var(--dou-motion-duration-normal);transition-timing-function:var(--dou-motion-easing-spring);border-radius:50%;width:18px;height:18px}.dou-code-keys__stick.is-held{cursor:grabbing}.dou-code-keys__stick.is-held .dou-code-keys__pad{background-color:var(--dou-color-bg-surface);box-shadow:inset 0 0 0 1px var(--dou-color-border),var(--dou-shadow-lg);transition-duration:var(--dou-motion-duration-slow);transition-timing-function:var(--dou-motion-easing-spring);width:104px;height:104px;margin:-52px 0 0 -52px}.dou-code-keys__stick.is-held .dou-code-keys__way{opacity:1}.dou-code-keys__stick.is-held .dou-code-keys__thumb{background-color:color-mix(in oklab,var(--dou-color-text)8%,var(--dou-color-bg-surface));width:40px;height:40px;transition-property:width,height}.dou-code-keys__key{display:inline-flex;box-sizing:border-box;border-radius:var(--dou-radius-control);color:inherit;font:inherit;cursor:pointer;touch-action:pan-x;-webkit-tap-highlight-color:transparent;transition-property:background-color,transform;transition-duration:var(--dou-motion-duration-fast);transition-timing-function:var(--dou-motion-easing-exit);background:0 0;border:0;flex:none;justify-content:center;align-items: center;min-width:36px;height:36px;padding:0 8px;line-height:1}.dou-code-keys__key>svg{color:var(--dou-color-text-secondary);width:18px;height:18px}@media (hover:hover){.dou-code-keys__key:hover{background-color:color-mix(in oklab,var(--dou-color-text)5%,transparent)}}.dou-code-keys__key.is-pressed{background-color:color-mix(in oklab,var(--dou-color-text)10%,transparent);transition-duration:var(--dou-motion-duration-slow);transition-timing-function:var(--dou-motion-easing-spring);transform:scale(1.12)}}@layer dou.components{.dou-code-input{--dou-code-input-height:var(--dou-control-height-md);display:block;width:100%;min-width:0}.dou-code-input .dou-code-editor{--dou-code-editor-padding-x:var(--dou-control-padding-x-md);--dou-code-editor-padding-y:calc((var(--dou-code-input-height) - var(--dou-code-editor-line-height) - 2px)/2);min-height:var(--dou-code-input-height);border-radius:var(--dou-radius-control);transition-property:border-color,box-shadow}@media (hover:hover){.dou-code-input .dou-code-editor:not(:-webkit-any(.is-focused,.is-disabled)):hover{--dou-code-editor-border:var(--dou-color-border-strong)}.dou-code-input .dou-code-editor:not(:-moz-any(.is-focused,.is-disabled)):hover{--dou-code-editor-border:var(--dou-color-border-strong)}.dou-code-input .dou-code-editor:not(:is(.is-focused,.is-disabled)):hover{--dou-code-editor-border:var(--dou-color-border-strong)}}.dou-code-input .dou-code-editor__marks{display:none}.dou-code-input:not(.is-multiline) .dou-code-editor{height:var(--dou-code-input-height)}.dou-code-input:not(.is-multiline) .dou-code-editor .dou-code-editor__scroller{scrollbar-width:none}.dou-code-input:not(.is-multiline) .dou-code-editor .dou-code-editor__scroller::-webkit-scrollbar{display:none}.dou-code-input.is-multiline .dou-code-editor{min-height:calc(var(--dou-code-input-min-rows,1)*var(--dou-code-editor-line-height) + 2*var(--dou-code-editor-padding-y) + 2px);max-height:calc(var(--dou-code-input-max-rows,6)*var(--dou-code-editor-line-height) + 2*var(--dou-code-editor-padding-y) + 2px)}.dou-code-input.is-invalid .dou-code-editor{--dou-code-editor-border:color-mix(in oklab,var(--dou-color-danger)55%,var(--dou-color-border));--dou-code-editor-border-focus:var(--dou-color-danger)}.dou-code-input--sm{--dou-code-input-height:var(--dou-control-height-sm)}.dou-code-input--sm .dou-code-editor{--dou-code-editor-padding-x:var(--dou-control-padding-x-sm)}.dou-code-input--lg{--dou-code-input-height:var(--dou-control-height-lg)}.dou-code-input--lg .dou-code-editor{--dou-code-editor-padding-x:var(--dou-control-padding-x-lg)}}@keyframes dou-code-peer-name{to{opacity:0;visibility:hidden}}@keyframes dou-code-editor-blink{50%{opacity:0}}@layer dou.components{.dou-code-diff{--dou-code-diff-removed:color-mix(in oklab,var(--dou-color-danger)10%,transparent);--dou-code-diff-added:color-mix(in oklab,var(--dou-color-success)10%,transparent);--dou-code-diff-removed-word:color-mix(in oklab,var(--dou-color-danger-text)30%,transparent);--dou-code-diff-added-word:color-mix(in oklab,var(--dou-color-success-text)30%,transparent);--dou-code-diff-border:var(--dou-color-border);--dou-code-diff-toolbar-bg:var(--dou-color-bg-surface);--dou-code-diff-toolbar-top:0px;position:relative;display:flex;box-sizing:border-box;overflow:clip;border:1px solid var(--dou-code-diff-border);border-radius:var(--dou-radius-container);background-color:var(--dou-color-bg-surface);transition:border-color var(--dou-motion-duration-fast)var(--dou-motion-easing);flex-direction:column;width:100%;min-width:0}.dou-code-diff:focus-within{border-color:color-mix(in oklab,var(--dou-color-focus)70%,var(--dou-color-text))}.dou-code-diff:not(.is-bordered){border:0;border-radius:0}.dou-code-diff__toolbar{display:flex;border-bottom:1px solid var(--dou-code-diff-border);background-color:var(--dou-code-diff-toolbar-bg);font-size:var(--dou-font-size-sm);flex:none;align-items: center;gap:2px;min-height:36px;padding:0 6px 0 12px}@media (pointer:coarse){.dou-code-diff__toolbar{min-height:44px}}.dou-code-diff__toolbar.is-sticky{position:sticky;top:var(--dou-code-diff-toolbar-top);z-index:4}.dou-code-diff__title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:auto;min-width:0;margin-inline-end:8px}.dou-code-diff__stats{display:flex;overflow:hidden;white-space:nowrap;flex:auto;align-items: center;gap:8px;min-width:0}.dou-code-diff__title+.dou-code-diff__stats{flex:none;margin-inline-end:4px}.dou-code-diff__count{font-family:var(--dou-font-family-mono);font-variant-numeric:tabular-nums}.dou-code-diff__count.is-added{color:var(--dou-color-success-text)}.dou-code-diff__count.is-removed{color:var(--dou-color-danger-text)}.dou-code-diff__summary{overflow:hidden;color:var(--dou-color-text-secondary);text-overflow:ellipsis}.dou-code-diff__hidden-text{position:absolute;overflow:hidden;clip-path:inset(50%);white-space:nowrap;width:1px;height:1px}.dou-code-diff__toolbar .dou-button{flex:none}@media (pointer:coarse){.dou-code-diff__toolbar .dou-button{position:relative;min-width:36px;min-height:36px}.dou-code-diff__toolbar .dou-button:after{position:absolute;content:"";inset:-2px}}.dou-code-diff__body{display:grid;grid-template-rows:minmax(0,1fr);grid-template-columns:minmax(0,1fr);isolation:isolate;flex:auto;min-height:0}.dou-code-diff--split>.dou-code-diff__body{grid-template-rows:auto minmax(0,1fr);grid-template-columns:minmax(0,1fr)minmax(0,1fr)}.dou-code-diff__label{border-bottom:1px solid var(--dou-code-diff-border);color:var(--dou-color-text-secondary);padding:4px 12px;font-size:12px}.dou-code-diff__label:nth-child(2){border-left:1px solid var(--dou-code-diff-border)}.dou-code-diff__side{display:flex;flex-direction:column;min-width:0;min-height:0}.dou-code-diff__side.is-modified{border-left:1px solid var(--dou-code-diff-border)}.dou-code-diff__side>.dou-code-editor{flex:auto}.dou-code-diff__line.is-removed{background-color:var(--dou-code-diff-removed)}.dou-code-diff__line.is-added{background-color:var(--dou-code-diff-added)}.dou-code-diff__word.is-removed{background-color:var(--dou-code-diff-removed-word)}.dou-code-diff__word.is-added{background-color:var(--dou-code-diff-added-word)}.dou-code-editor__cell.dou-code-diff__sign{font-family:var(--dou-font-family-mono)}.dou-code-editor__cell.dou-code-diff__sign:after{position:absolute;z-index:-1;top:0;bottom:0;left:calc(100% - var(--dou-code-editor-gutter-cells));width:var(--dou-code-editor-gutter);content:"";pointer-events:none}.dou-code-editor__cell.dou-code-diff__sign.is-removed{color:var(--dou-color-danger-text)}.dou-code-editor__cell.dou-code-diff__sign.is-removed:after{background-color:var(--dou-code-diff-removed)}.dou-code-editor__cell.dou-code-diff__sign.is-added{color:var(--dou-color-success-text)}.dou-code-editor__cell.dou-code-diff__sign.is-added:after{background-color:var(--dou-code-diff-added)}.dou-code-editor__cell.dou-code-diff__number{box-sizing:border-box;color:var(--dou-code-editor-gutter-text);font-family:var(--dou-font-family-mono);font-size:inherit;font-variant-numeric:tabular-nums;justify-content:flex-end;padding-right:8px}.dou-code-diff__widget{display:flow-root}.dou-code-diff--split>.dou-code-diff__body{position:relative}.dou-code-diff__spans{position:absolute;z-index:3;overflow:hidden;pointer-events:none;left:0;right:0}.dou-code-diff__span{position:absolute;display:flow-root;box-sizing:border-box;font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);pointer-events:auto;transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing);line-height:20px;top:0;left:0;right:0}.dou-code-diff__span:not(.is-placed){visibility:hidden;opacity:0;transition:none}.dou-code-diff__filler{background-image:repeating-linear-gradient(-45deg,transparent 0 6px,color-mix(in oklab,var(--dou-color-text)5%,transparent)6px 7px)}.dou-code-diff__bar{display:flex;box-sizing:border-box;border:0;border-block:1px solid var(--dou-code-diff-border);background-color:color-mix(in oklab,var(--dou-color-text)3%,transparent);color:var(--dou-color-text-secondary);font:inherit;text-align:left;cursor:pointer;align-items: center;gap:6px;width:100%;height:28px;margin:0;padding:0 12px;font-size:12px}@media (hover:hover){.dou-code-diff__bar:hover{background-color:color-mix(in oklab,var(--dou-color-text)6%,transparent);color:var(--dou-color-text)}}.dou-code-diff__bar:focus-visible{outline:2px solid var(--dou-color-focus);outline-offset:-2px}@media (pointer:coarse){.dou-code-diff__bar{height:36px}}.dou-code-diff__bar-icon{flex:none;font-size:14px}.dou-code-diff__live{position:absolute;overflow:hidden;clip-path:inset(50%);white-space:nowrap;width:1px;height:1px}.dou-code-peer{position:relative;z-index:1;display:inline-block;height:var(--dou-code-editor-line-height);vertical-align:top;pointer-events:none;width:0}.dou-code-peer:before{content:"";position:absolute;background-color:var(--dou-code-peer-color);border-radius:1px;width:2px;height:100%;top:0;left:-1px}.dou-code-peer__name{position:absolute;background-color:var(--dou-code-peer-color);color:oklch(from var(--dou-code-peer-color)clamp(.2,(.66 - l)*100,.99)0 0);font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);white-space:nowrap;user-select:none;animation:dou-code-peer-name var(--dou-motion-duration-fast)var(--dou-motion-easing)3s forwards;border-radius:4px 4px 4px 0;padding:0 6px;line-height:18px;bottom:100%;left:-1px}.dou-code-peer.is-below .dou-code-peer__name{border-radius:0 4px 4px;top:100%;bottom:auto}.dou-code-peer-selection{background-color:color-mix(in oklab,var(--dou-code-peer-color)20%,transparent)}}
1
+ @layer dou.components{.dou-code-editor{--dou-code-editor-font-size:var(--dou-font-size-sm);--dou-code-editor-line-height:20px;--dou-code-editor-padding-y:8px;--dou-code-editor-padding-x:12px;--dou-code-editor-gutter-padding-left:16px;--dou-code-editor-gutter-padding-right:12px;--dou-code-editor-gutter-overlay-offset:-4px;--dou-code-editor-bg:var(--dou-color-bg-surface);--dou-code-editor-gutter-bg:var(--dou-code-editor-bg);--dou-code-editor-gutter-text:var(--dou-color-text-tertiary);--dou-code-editor-border:var(--dou-color-border);--dou-code-editor-border-focus:color-mix(in oklab,var(--dou-color-focus)70%,var(--dou-color-text));--dou-code-editor-cursor:var(--dou-color-text);--dou-code-editor-active-line:color-mix(in oklab,var(--dou-color-text)4%,transparent);--dou-code-editor-selection:color-mix(in oklab,var(--dou-color-primary)20%,transparent);--dou-code-editor-match:color-mix(in oklab,var(--dou-color-warning)22%,transparent);--dou-code-editor-match-current:color-mix(in oklab,var(--dou-color-warning-text)80%,transparent);--dou-code-editor-match-mark:color-mix(in oklab,var(--dou-color-warning)60%,transparent);--dou-code-editor-bracket:color-mix(in oklab,var(--dou-color-text)35%,transparent);--dou-code-editor-error:var(--dou-color-danger-text);--dou-code-editor-warning:var(--dou-color-warning-text);--dou-code-editor-info:var(--dou-color-primary-text);--dou-code-editor-bracket-unmatched:color-mix(in oklab,var(--dou-color-danger-text)70%,transparent);position:relative;display:flex;box-sizing:border-box;min-height:calc(var(--dou-code-editor-line-height) + 2*var(--dou-code-editor-padding-y) + 2px);overflow:hidden;border:1px solid var(--dou-code-editor-border);border-radius:var(--dou-radius-container);background-color:var(--dou-code-editor-bg);color:var(--dou-color-text);font-family:var(--dou-font-family-mono);font-size:var(--dou-code-editor-font-size);font-variant-ligatures:none;line-height:var(--dou-code-editor-line-height);transition:border-color var(--dou-motion-duration-fast)var(--dou-motion-easing);flex-direction:column;width:100%;min-width:0}.dou-code-editor.is-focused{border-color:var(--dou-code-editor-border-focus)}.dou-code-editor:not(.is-bordered){min-height:calc(var(--dou-code-editor-line-height) + 2*var(--dou-code-editor-padding-y));border:0;border-radius:0}.dou-code-editor:not(.is-focused){--dou-code-editor-selection:color-mix(in oklab,var(--dou-color-text)10%,transparent)}.dou-code-editor.is-disabled{color:var(--dou-color-text-disabled);cursor:not-allowed}.dou-code-editor__body{position:relative;display:flex;flex:auto;min-height:0}.dou-code-editor__scroller{position:relative;overflow:auto;overscroll-behavior-x:contain;scrollbar-width:thin;flex:auto;min-width:0;min-height:0}.dou-code-editor:not(.is-scroll-y)>.dou-code-editor__body>.dou-code-editor__scroller{overflow-x:auto;overflow-y:hidden}.dou-code-editor__minimap{position:relative;overflow:hidden;box-shadow:inset 1px 0 0 color-mix(in oklab,var(--dou-color-text)6%,transparent);color:var(--dou-color-text-tertiary);cursor:default;touch-action:none;user-select:none;flex:none;width:96px}.dou-code-editor__minimap-canvas{position:absolute;width:100%;height:100%;inset:0}.dou-code-editor__minimap-view{position:absolute;background-color:color-mix(in oklab,var(--dou-color-text)6%,transparent);transition:background-color var(--dou-motion-duration-fast)var(--dou-motion-easing);top:0;left:0;right:0}.dou-code-editor__minimap:hover .dou-code-editor__minimap-view{background-color:color-mix(in oklab,var(--dou-color-text)9%,transparent)}.dou-code-editor__minimap:active .dou-code-editor__minimap-view{background-color:color-mix(in oklab,var(--dou-color-text)12%,transparent)}.dou-code-editor__sizer{position:relative;display:flex;box-sizing:border-box;width:max-content;min-width:100%}.dou-code-editor__gutter{position:sticky;z-index:2;box-sizing:border-box;width:var(--dou-code-editor-gutter);background-color:var(--dou-code-editor-gutter-bg);color:var(--dou-code-editor-gutter-text);font-variant-numeric:tabular-nums;cursor:default;user-select:none;-webkit-user-select:none;touch-action:manipulation;flex:none;left:0}.dou-code-editor__numbers{position:absolute;will-change:transform;top:0;left:0;right:0}.dou-code-editor__number{position:relative;box-sizing:border-box;height:var(--dou-code-editor-line-height);padding:0 var(--dou-code-editor-gutter-padding-right)0 calc(var(--dou-code-editor-gutter-padding-left) + var(--dou-code-editor-gutter-cells,0px));text-align:right}.dou-code-editor__number.is-active{color:var(--dou-color-text-secondary)}.dou-code-editor.is-foldable>.dou-code-editor__body>.dou-code-editor__scroller>.dou-code-editor__sizer>.dou-code-editor__gutter>.dou-code-editor__numbers>.dou-code-editor__number{padding-right:calc(var(--dou-code-editor-gutter-padding-right) + 12px)}.dou-code-editor:not(.is-line-numbers)>.dou-code-editor__body>.dou-code-editor__scroller>.dou-code-editor__sizer>.dou-code-editor__gutter>.dou-code-editor__numbers>.dou-code-editor__number{padding:0}.dou-code-editor__fold-toggle{position:absolute;display:flex;height:var(--dou-code-editor-line-height);color:var(--dou-color-text-tertiary);cursor:pointer;opacity:0;transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing);justify-content:center;align-items: center;width:14px;font-size:12px;top:0;right:6px}.dou-code-editor__gutter:hover .dou-code-editor__fold-toggle{opacity:1}.dou-code-editor__fold-toggle.is-folded{opacity:1}.dou-code-editor__fold-toggle:hover{color:var(--dou-color-text)}@media (pointer:coarse){.dou-code-editor__fold-toggle{opacity:1}.dou-code-editor__fold-toggle:before{position:absolute;content:"";inset:-4px -6px}}.dou-code-editor__content{position:relative;cursor:text;touch-action:manipulation;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;flex:auto;min-width:0}.dou-code-editor.is-disabled .dou-code-editor__content{cursor:not-allowed}.dou-code-editor__lines,.dou-code-editor__matches,.dou-code-editor__brackets,.dou-code-editor__selections,.dou-code-editor__cursors{position:absolute;pointer-events:none;top:0;left:0}.dou-code-editor__lines{will-change:transform;right:0}.dou-code-editor__line{box-sizing:border-box;height:var(--dou-code-editor-line-height);padding:0 var(--dou-code-editor-padding-x);white-space:pre;tab-size:var(--dou-code-editor-tab-size,2)}.dou-code-editor__line.is-wrapped{height:auto}.dou-code-editor__row{box-sizing:border-box;height:var(--dou-code-editor-line-height)}.dou-code-editor__fold-marker{display:inline-block;box-sizing:border-box;border:1px solid var(--dou-color-border);background-color:var(--dou-color-bg-muted);color:var(--dou-color-text-secondary);vertical-align:1px;cursor:pointer;pointer-events:auto;border-radius:4px;height:16px;margin-left:6px;padding:0 6px;font-size:12px;line-height:14px}.dou-code-editor__fold-marker:hover{color:var(--dou-color-text)}.dou-code-editor__line :-webkit-any(.dou-syntax-heading,.dou-syntax-strong){font-weight:inherit}.dou-code-editor__line :-moz-any(.dou-syntax-heading,.dou-syntax-strong){font-weight:inherit}.dou-code-editor__line :is(.dou-syntax-heading,.dou-syntax-strong){font-weight:inherit}.dou-code-editor__compose{text-decoration:underline;text-decoration-color:var(--dou-color-text-tertiary);text-underline-offset:3px}.dou-code-editor__probe{position:absolute;visibility:hidden;white-space:pre;pointer-events:none;top:0;left:0}.dou-code-editor__active-line{position:absolute;height:var(--dou-code-editor-line-height);background-color:var(--dou-code-editor-active-line);pointer-events:none;top:0;left:0;right:0}.dou-code-editor:not(.is-focused) .dou-code-editor__active-line{background-color:#0000}.dou-code-editor__match{position:absolute;box-sizing:border-box;height:var(--dou-code-editor-line-height);background-color:var(--dou-code-editor-match);border-radius:2px;top:0;left:0}.dou-code-editor__match.is-current{box-shadow:inset 0 0 0 1px var(--dou-code-editor-match-current)}.dou-code-editor__marks{position:absolute;z-index:3;pointer-events:none;width:6px;top:0;bottom:0;right:0}.dou-code-editor__mark{position:absolute;background-color:var(--dou-code-editor-match-mark);border-radius:1px;width:6px;height:2px;right:0}.dou-code-editor__mark.is-current{background-color:var(--dou-code-editor-match-current);height:3px}.dou-code-editor__live{position:absolute;overflow:hidden;clip-path:inset(50%);white-space:nowrap;width:1px;height:1px}.dou-code-editor__search{position:absolute;z-index:4;display:flex;container-type:inline-size;pointer-events:none;justify-content:flex-end;top:6px;left:6px;right:14px}.dou-code-editor__search>*{pointer-events:auto}.dou-code-editor__bracket{position:absolute;box-sizing:border-box;height:var(--dou-code-editor-line-height);border:1px solid var(--dou-code-editor-bracket);border-radius:2px;top:0;left:0}.dou-code-editor__bracket.is-unmatched{border-color:var(--dou-code-editor-bracket-unmatched)}.dou-code-editor__selection{position:absolute;height:var(--dou-code-editor-line-height);background-color:var(--dou-code-editor-selection);border-radius:2px;top:0;left:0}.dou-code-editor__cursor{position:absolute;height:var(--dou-code-editor-line-height);background-color:var(--dou-code-editor-cursor);animation:1.2s step-end .5s infinite dou-code-editor-blink;border-radius:1px;width:2px;top:0;left:0}.dou-code-editor.is-readonly .dou-code-editor__cursor{opacity:.4;animation:none}@media (prefers-reduced-motion:reduce){.dou-code-editor__cursor{animation:none}}.dou-code-editor__placeholder{position:absolute;top:var(--dou-code-editor-padding-y);left:var(--dou-code-editor-padding-x);color:var(--dou-color-text-tertiary);white-space:pre;pointer-events:none}.dou-code-editor__input{position:absolute;z-index:-1;box-sizing:border-box;width:calc(100% - var(--dou-code-editor-padding-x));overflow:hidden;outline:none;color:#0000;caret-color:transparent;font:inherit;font-size:max(var(--dou-font-size-input-min),var(--dou-code-editor-font-size));line-height:inherit;letter-spacing:inherit;white-space:pre;tab-size:var(--dou-code-editor-tab-size,2);resize:none;pointer-events:none;background:0 0;border:0;min-width:1px;margin:0;padding:0}.dou-code-editor__input::selection{background:0 0}}@layer dou.components{.dou-code-editor__problem{text-decoration-line:underline;text-decoration-style:wavy;text-decoration-thickness:1px;text-decoration-skip-ink:none;text-underline-offset:3px}.dou-code-editor__problem.is-error{text-decoration-color:var(--dou-code-editor-error)}.dou-code-editor__problem.is-warning{text-decoration-color:var(--dou-code-editor-warning)}.dou-code-editor__problem.is-info{text-decoration-color:var(--dou-code-editor-info)}.dou-code-editor__problem.is-hint{text-decoration-style:dotted;text-decoration-color:var(--dou-color-text-tertiary)}.dou-code-editor__cells{position:absolute;display:flex;top:0;bottom:0;left:0}.dou-code-editor__cell{display:inline-grid;grid-template-rows:var(--dou-code-editor-line-height);grid-auto-flow:column;position:relative;font-size:var(--dou-font-size-sm);flex:none;place-content: start center;align-items: center;height:100%}.dou-code-editor__cell[data-gutter-cell]{cursor:pointer}.dou-code-editor.is-disabled .dou-code-editor__cell[data-gutter-cell]{cursor:default}.dou-code-editor__cell[role=button]{border-radius:var(--dou-radius-control)}.dou-code-editor__cell[role=button]:focus-visible{outline:none}.dou-code-editor__cell[role=button]:focus-visible:after{position:absolute;box-sizing:border-box;height:var(--dou-code-editor-line-height);border:2px solid var(--dou-color-focus);border-radius:var(--dou-radius-control);content:"";pointer-events:none;top:0;left:0;right:0}.dou-code-editor__cell>svg{width:14px;height:14px}.dou-code-editor__cell.is-on-hover{opacity:0;transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing)}.dou-code-editor:not(.is-disabled) .dou-code-editor__number:-webkit-any(:hover,.is-hovered)>.dou-code-editor__cells>.dou-code-editor__cell.is-on-hover{opacity:1}.dou-code-editor:not(.is-disabled) .dou-code-editor__number:-moz-any(:hover,.is-hovered)>.dou-code-editor__cells>.dou-code-editor__cell.is-on-hover{opacity:1}.dou-code-editor:not(.is-disabled) .dou-code-editor__number:is(:hover,.is-hovered)>.dou-code-editor__cells>.dou-code-editor__cell.is-on-hover{opacity:1}.dou-code-editor.is-focused .dou-code-editor__number.is-active>.dou-code-editor__cells>.dou-code-editor__cell.is-on-hover{opacity:1}.dou-code-editor__cell.is-on-hover:focus-visible{opacity:1}.dou-code-editor__overlays{position:absolute;top:0;right:var(--dou-code-editor-gutter-overlay-offset,-4px);z-index:1;display:flex;height:var(--dou-code-editor-line-height);pointer-events:none;align-items: center;gap:2px}.dou-code-editor.is-gutter-empty>.dou-code-editor__body>.dou-code-editor__scroller>.dou-code-editor__sizer>.dou-code-editor__gutter>.dou-code-editor__numbers>.dou-code-editor__number>.dou-code-editor__overlays{left:2px;right:auto}.dou-code-editor__cell.is-overlay{display:inline-flex;box-sizing:border-box;border:1px solid var(--dou-color-border);border-radius:var(--dou-radius-control);background-color:var(--dou-code-editor-bg);box-shadow:var(--dou-shadow-sm);color:var(--dou-color-text-secondary);pointer-events:auto;transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing),background-color var(--dou-motion-duration-fast)var(--dou-motion-easing),border-color var(--dou-motion-duration-fast)var(--dou-motion-easing),color var(--dou-motion-duration-fast)var(--dou-motion-easing);height:18px;font-size:12px;line-height:1}.dou-code-editor__cell.is-overlay>svg{width:12px;height:12px}@media (hover:hover){.dou-code-editor__cell.is-overlay:hover{border-color:var(--dou-color-border-strong);background-color:var(--dou-color-bg-muted);color:var(--dou-color-text)}}.dou-code-editor__cell.is-overlay[role=button]:focus-visible:after{height:auto;inset:-1px}@media (pointer:coarse){.dou-code-editor__cell.is-overlay:before{position:absolute;content:"";inset:-6px}}.dou-code-editor__cell.is-overlay.is-on-hover{opacity:0;pointer-events:none}.dou-code-editor:not(.is-disabled)>.dou-code-editor__body>.dou-code-editor__scroller>.dou-code-editor__sizer>.dou-code-editor__gutter>.dou-code-editor__numbers>.dou-code-editor__number:-webkit-any(:hover,.is-hovered)>.dou-code-editor__overlays>.dou-code-editor__cell.is-overlay.is-on-hover{opacity:1;pointer-events:auto}.dou-code-editor:not(.is-disabled)>.dou-code-editor__body>.dou-code-editor__scroller>.dou-code-editor__sizer>.dou-code-editor__gutter>.dou-code-editor__numbers>.dou-code-editor__number:-moz-any(:hover,.is-hovered)>.dou-code-editor__overlays>.dou-code-editor__cell.is-overlay.is-on-hover{opacity:1;pointer-events:auto}.dou-code-editor:not(.is-disabled)>.dou-code-editor__body>.dou-code-editor__scroller>.dou-code-editor__sizer>.dou-code-editor__gutter>.dou-code-editor__numbers>.dou-code-editor__number:is(:hover,.is-hovered)>.dou-code-editor__overlays>.dou-code-editor__cell.is-overlay.is-on-hover{opacity:1;pointer-events:auto}.dou-code-editor.is-focused>.dou-code-editor__body>.dou-code-editor__scroller>.dou-code-editor__sizer>.dou-code-editor__gutter>.dou-code-editor__numbers>.dou-code-editor__number.is-active>.dou-code-editor__overlays>.dou-code-editor__cell.is-overlay.is-on-hover{opacity:1;pointer-events:auto}.dou-code-editor__cell.is-overlay.is-on-hover:focus-visible{opacity:1;pointer-events:auto}.dou-code-editor__problem-icon.is-error{color:var(--dou-code-editor-error)}.dou-code-editor__problem-icon.is-warning{color:var(--dou-code-editor-warning)}.dou-code-editor__problem-icon.is-info{color:var(--dou-code-editor-info)}.dou-code-editor__problem-icon.is-hint{color:var(--dou-color-text-tertiary)}.dou-code-editor__problem-mark.is-error{background-color:var(--dou-code-editor-error)}.dou-code-editor__problem-mark.is-warning{background-color:var(--dou-code-editor-warning)}.dou-code-editor__problem-mark.is-info{background-color:var(--dou-code-editor-info)}.dou-code-editor__problem-mark.is-hint{background-color:var(--dou-color-text-tertiary)}.dou-code-editor__floating{display:contents}.dou-code-editor__floating.is-outside{--dou-code-editor-font-size:var(--dou-font-size-sm);--dou-code-editor-bg:var(--dou-color-bg-surface);--dou-code-editor-error:var(--dou-color-danger-text);--dou-code-editor-warning:var(--dou-color-warning-text);--dou-code-editor-info:var(--dou-color-primary-text);position:absolute;display:block;color:var(--dou-color-text);transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing);width:0;height:0;line-height:20px;top:0;left:0}.dou-code-editor__floating.is-outside.is-scrolling{opacity:0;pointer-events:none;transition:none}.dou-code-editor__floating.is-outside.is-fixed{position:fixed}.dou-code-editor__problems{position:absolute;z-index:6;box-sizing:border-box;display:flex;border:1px solid var(--dou-color-border);border-radius:var(--dou-radius-control);background-color:var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);white-space:normal;overflow-y:auto;overscroll-behavior:contain;flex-direction:column;gap:4px;width:max-content;max-width:min(440px,100% - 8px);padding:6px;line-height:20px;top:0;left:0}.dou-code-editor__problems>*{flex-shrink:0}.dou-code-editor__problem-item{display:flex;align-items: flex-start;gap:6px;padding:0 2px}.dou-code-editor__problem-item.is-error{--dou-code-editor-problem:var(--dou-code-editor-error)}.dou-code-editor__problem-item.is-warning{--dou-code-editor-problem:var(--dou-code-editor-warning)}.dou-code-editor__problem-item.is-info{--dou-code-editor-problem:var(--dou-code-editor-info)}.dou-code-editor__problem-item.is-hint{--dou-code-editor-problem:var(--dou-color-text-tertiary)}.dou-code-editor__problem-severity{color:var(--dou-code-editor-problem);flex:none;width:14px;height:20px}.dou-code-editor__problem-message{overflow-wrap:anywhere;color:var(--dou-color-text);min-width:0}.dou-code-editor__problem-source{color:var(--dou-color-text-tertiary);margin-left:8px}.dou-code-editor__fixes{display:flex;border-top:1px solid var(--dou-color-border-subtle);flex-wrap:wrap;gap:2px;padding-top:4px}.dou-code-editor__fix{display:inline-flex;border-radius:calc(var(--dou-radius-control) - 2px);color:var(--dou-color-primary-text);font:inherit;cursor:pointer;background:0 0;border:0;align-items: center;height:24px;padding:0 8px}.dou-code-editor__fix.is-active{background-color:color-mix(in oklab,var(--dou-color-text)6%,transparent)}.dou-code-editor__fix:hover{background-color:color-mix(in oklab,var(--dou-color-text)6%,transparent)}@media (pointer:coarse){.dou-code-editor__fix{height:36px}}.dou-code-editor__hover{color:var(--dou-color-text);overflow-wrap:anywhere;white-space:pre-wrap;padding:0 2px}.dou-code-editor__hover+.dou-code-editor__problem-item{border-top:1px solid var(--dou-color-border-subtle);padding-top:4px}.dou-code-lsp-markup{display:flex;white-space:normal;flex-direction:column;gap:6px}.dou-code-lsp-markup__text{white-space:pre-wrap;margin:0}.dou-code-lsp-markup__code{font-family:var(--dou-font-family-mono);white-space:pre-wrap;margin:0}.dou-code-lsp-markup__inline{font-family:var(--dou-font-family-mono)}.dou-code-editor__completions{position:absolute;z-index:7;box-sizing:border-box;display:flex;border:1px solid var(--dou-color-border);border-radius:var(--dou-radius-control);background-color:var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);font-family:var(--dou-font-family-mono);font-size:var(--dou-code-editor-font-size);flex-direction:column;width:max-content;min-width:min(200px,100%);max-height:264px;padding:4px;line-height:20px;top:0;left:0}.dou-code-editor__completion-list{overflow-y:auto;overscroll-behavior:contain;flex:0 auto;min-height:28px}.dou-code-editor__completion{display:flex;border-radius:calc(var(--dou-radius-control) - 2px);color:var(--dou-color-text);cursor:pointer;align-items: center;gap:8px;height:28px;padding:0 8px 0 6px}.dou-code-editor__completion.is-active{background-color:color-mix(in oklab,var(--dou-color-text)8%,transparent)}@media (hover:hover){.dou-code-editor__completion:not(.is-active):hover{background-color:color-mix(in oklab,var(--dou-color-text)4%,transparent)}}@media (pointer:coarse){.dou-code-editor__completion{height:36px}}.dou-code-editor__completion-kind{color:var(--dou-color-text-tertiary);flex:none;width:16px;height:16px}.dou-code-editor__completion-label{overflow:hidden;text-overflow:ellipsis;white-space:pre;flex:none;max-width:75%}.dou-code-editor__completion-match{color:var(--dou-color-primary-text);background:0 0;font-weight:600}.dou-code-editor__completion-detail{overflow:hidden;color:var(--dou-color-text-tertiary);font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);text-overflow:ellipsis;white-space:nowrap;flex:0 auto;min-width:0;margin-left:auto;padding-left:16px}.dou-code-editor__completion-info{border-top:1px solid var(--dou-color-border-subtle);color:var(--dou-color-text-secondary);font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);white-space:pre-wrap;overflow-wrap:anywhere;flex:none;max-width:400px;margin-top:4px;padding:6px 6px 2px}.dou-code-editor__signature{position:absolute;z-index:6;box-sizing:border-box;border:1px solid var(--dou-color-border);border-radius:var(--dou-radius-control);background-color:var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);font-size:var(--dou-font-size-sm);overflow-y:auto;pointer-events:none;width:max-content;max-width:min(440px,100% - 8px);padding:4px 8px;line-height:20px;top:0;left:0}.dou-code-editor__signature-label{color:var(--dou-color-text-secondary);font-family:var(--dou-font-family-mono);font-size:var(--dou-code-editor-font-size);overflow-wrap:anywhere}.dou-code-editor__signature-active{color:var(--dou-color-text);text-decoration:underline;text-underline-offset:3px;font-weight:600}.dou-code-editor__signature-info{color:var(--dou-color-text-tertiary);font-family:var(--dou-font-family);white-space:pre-wrap}.dou-code-editor__field{box-shadow:inset 0 0 0 1px var(--dou-color-border-strong);border-radius:2px}.dou-code-editor__widgets{position:absolute;z-index:3;overflow-x:clip;pointer-events:none;inset:0}.dou-code-editor__widget-slot{position:absolute;top:0;right:0;left:var(--dou-code-editor-gutter,0px);pointer-events:none}.dou-code-editor__widget-slot.is-full-width{left:0}.dou-code-editor__widget{position:sticky;left:var(--dou-code-editor-gutter,0px);box-sizing:border-box;width:var(--dou-code-editor-widget-width,100%);pointer-events:auto;cursor:auto;font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);white-space:normal;user-select:text;-webkit-user-select:text;display:flow-root;max-width:100%;line-height:20px}.dou-code-editor__widget.is-full-width{width:var(--dou-code-editor-view-width,100%);left:0}.dou-code-editor__inline{display:inline-block;vertical-align:top;height:var(--dou-code-editor-line-height);white-space:nowrap}.dou-code-editor__panels{font-family:var(--dou-font-family);flex:none}.dou-code-editor__panels.is-top{border-bottom:1px solid var(--dou-color-border-subtle)}.dou-code-editor__panels.is-bottom{border-top:1px solid var(--dou-color-border-subtle)}.dou-code-editor__handle{position:absolute;z-index:5;touch-action:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;width:0;height:0;top:0;left:0}.dou-code-editor__handle:before{position:absolute;content:"";width:36px;height:36px;top:-6px}.dou-code-editor__handle:after{position:absolute;background-color:var(--dou-color-primary);content:"";width:14px;height:14px;top:0}.dou-code-editor__handle.is-start:before{left:-27px}.dou-code-editor__handle.is-start:after{border-radius:50% 0 50% 50%;right:0}.dou-code-editor__handle.is-end:before{left:-9px}.dou-code-editor__handle.is-end:after{border-radius:0 50% 50%;left:0}.dou-code-editor__handle.is-caret:before{left:-18px}.dou-code-editor__handle.is-caret:after{border-radius:0 50% 50%;width:12px;height:12px;top:4px;left:-6px;transform:rotate(45deg)}.dou-code-editor__magnifier{position:absolute;z-index:6;box-sizing:border-box;overflow:hidden;border:1px solid var(--dou-color-border);background:linear-gradient(var(--dou-code-editor-bg),var(--dou-code-editor-bg)),var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);pointer-events:none;border-radius:999px;width:128px;top:0;left:0}.dou-code-editor__magnifier-text{position:absolute;height:var(--dou-code-editor-line-height);margin-top:calc(var(--dou-code-editor-line-height)/-2);white-space:pre;tab-size:var(--dou-code-editor-tab-size);transform-origin:0 50%;top:50%;left:0}.dou-code-editor__magnifier-caret{position:absolute;height:calc(var(--dou-code-editor-line-height)*1.5);background-color:var(--dou-color-primary);border-radius:1px;width:2px;top:50%;translate:0 -50%}.dou-code-editor__menu{position:absolute;z-index:6;display:flex;border:1px solid var(--dou-color-border);border-radius:calc(var(--dou-radius-control) + 2px);background-color:var(--dou-color-bg-surface);box-shadow:var(--dou-shadow-md);font-family:var(--dou-font-family);white-space:nowrap;gap:2px;padding:2px;top:0;left:0}.dou-code-editor__menu-button{display:inline-flex;border-radius:var(--dou-radius-control);color:var(--dou-color-text);font:inherit;font-size:var(--dou-font-size-sm);cursor:pointer;-webkit-tap-highlight-color:transparent;background:0 0;border:0;align-items: center;min-width:36px;height:36px;padding:0 12px;line-height:1}.dou-code-editor__menu-button:active{background-color:color-mix(in oklab,var(--dou-color-text)8%,transparent)}@media (hover:hover){.dou-code-editor__menu-button:hover{background-color:color-mix(in oklab,var(--dou-color-text)5%,transparent)}}.dou-code-editor__keys{position:absolute;box-sizing:border-box;display:flex;border:1px solid color-mix(in oklab,var(--dou-color-text)10%,transparent);background-color:color-mix(in oklab,var(--dou-color-bg-surface)92%,transparent);box-shadow:var(--dou-shadow-md);-webkit-backdrop-filter:blur(20px)saturate(1.8);backdrop-filter:blur(20px)saturate(1.8);transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing);border-radius:22px;height:44px;padding:0 3px 0 0;top:0;left:0}.dou-code-editor__keys.is-fixed{position:fixed}.dou-code-editor__keys.is-scrolling{opacity:0;pointer-events:none;transition:none}.dou-code-editor__keys>.dou-code-keys{background-color:#0000;border-top:0;flex:auto;min-width:0;height:42px}.dou-code-editor__keys>.dou-code-keys .dou-code-keys__scroll{padding:0}.dou-code-editor__keys>.dou-code-keys .dou-code-keys__arrows{position:relative;box-shadow:none;padding:0 0 0 5px}.dou-code-editor__keys>.dou-code-keys .dou-code-keys__arrows:before{position:absolute;background-color:var(--dou-color-border-subtle);content:"";width:1px;top:10px;bottom:10px;left:0}.dou-code-editor__keys>.dou-code-keys .dou-code-keys__key{border-radius:18px}.dou-code-editor__keys-grip{display:flex;color:var(--dou-color-text-tertiary);cursor:grab;touch-action:none;-webkit-tap-highlight-color:transparent;background:0 0;border:0;flex:none;justify-content:center;align-items: center;width:36px;margin:0;padding:0 0 0 6px}.dou-code-editor__keys-grip>svg{width:18px;height:18px}.dou-code-editor__keys-grip:active{cursor:grabbing}.dou-code-editor__keys-grip:focus-visible{outline:2px solid var(--dou-color-focus);outline-offset:-4px;border-radius:18px}.dou-code-keys{display:flex;box-sizing:border-box;border-top:1px solid var(--dou-color-border);background-color:var(--dou-color-bg-surface);color:var(--dou-color-text);font-family:var(--dou-font-family-mono);font-size:var(--dou-font-size-md);user-select:none;-webkit-user-select:none;height:45px}.dou-code-keys__scroll{display:flex;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:none;touch-action:pan-x;flex:auto;align-items: center;gap:2px;min-width:0;padding:0 4px}.dou-code-keys__scroll::-webkit-scrollbar{display:none}.dou-code-keys__arrows{display:flex;box-shadow:-1px 0 0 var(--dou-color-border-subtle);flex:none;align-items: center;gap:2px;padding:0 4px}.dou-code-keys__stick{position:relative;color:var(--dou-color-text-tertiary);cursor:grab;touch-action:none;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;background:0 0;border:0;border-radius:50%;flex:none;width:36px;height:36px;margin:0;padding:0}.dou-code-keys__stick:focus-visible{outline:2px solid var(--dou-color-focus);outline-offset:0}.dou-code-keys__pad{position:absolute;z-index:1;display:flex;box-sizing:border-box;background-color:var(--dou-color-bg-muted);box-shadow:inset 0 0 0 1px var(--dou-color-border-subtle);pointer-events:none;transition-property:width,height,margin,background-color,box-shadow,translate;transition-duration:var(--dou-motion-duration-normal);transition-timing-function:var(--dou-motion-easing);border-radius:50%;justify-content:center;align-items: center;width:32px;height:32px;margin:-16px 0 0 -16px;top:50%;left:50%}.dou-code-keys__way{position:absolute;opacity:0;transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing);width:16px;height:16px}.dou-code-keys__way.is-up{top:8px}.dou-code-keys__way.is-down{bottom:8px}.dou-code-keys__way.is-left{left:8px}.dou-code-keys__way.is-right{right:8px}.dou-code-keys__thumb{box-sizing:border-box;background-color:var(--dou-color-bg-surface);box-shadow:0 0 0 1px color-mix(in oklab,var(--dou-color-text)14%,transparent),var(--dou-shadow-sm);transition-property:width,height,transform;transition-duration:var(--dou-motion-duration-normal);transition-timing-function:var(--dou-motion-easing-spring);border-radius:50%;width:18px;height:18px}.dou-code-keys__stick.is-held{cursor:grabbing}.dou-code-keys__stick.is-held .dou-code-keys__pad{background-color:var(--dou-color-bg-surface);box-shadow:inset 0 0 0 1px var(--dou-color-border),var(--dou-shadow-lg);transition-duration:var(--dou-motion-duration-slow);transition-timing-function:var(--dou-motion-easing-spring);width:104px;height:104px;margin:-52px 0 0 -52px}.dou-code-keys__stick.is-held .dou-code-keys__way{opacity:1}.dou-code-keys__stick.is-held .dou-code-keys__thumb{background-color:color-mix(in oklab,var(--dou-color-text)8%,var(--dou-color-bg-surface));width:40px;height:40px;transition-property:width,height}.dou-code-keys__key{display:inline-flex;box-sizing:border-box;border-radius:var(--dou-radius-control);color:inherit;font:inherit;cursor:pointer;touch-action:pan-x;-webkit-tap-highlight-color:transparent;transition-property:background-color,transform;transition-duration:var(--dou-motion-duration-fast);transition-timing-function:var(--dou-motion-easing-exit);background:0 0;border:0;flex:none;justify-content:center;align-items: center;min-width:36px;height:36px;padding:0 8px;line-height:1}.dou-code-keys__key>svg{color:var(--dou-color-text-secondary);width:18px;height:18px}@media (hover:hover){.dou-code-keys__key:hover{background-color:color-mix(in oklab,var(--dou-color-text)5%,transparent)}}.dou-code-keys__key.is-pressed{background-color:color-mix(in oklab,var(--dou-color-text)10%,transparent);transition-duration:var(--dou-motion-duration-slow);transition-timing-function:var(--dou-motion-easing-spring);transform:scale(1.12)}}@layer dou.components{.dou-code-input{--dou-code-input-height:var(--dou-control-height-md);display:block;width:100%;min-width:0}.dou-code-input .dou-code-editor{--dou-code-editor-padding-x:var(--dou-control-padding-x-md);--dou-code-editor-padding-y:calc((var(--dou-code-input-height) - var(--dou-code-editor-line-height) - 2px)/2);min-height:var(--dou-code-input-height);border-radius:var(--dou-radius-control);transition-property:border-color,box-shadow}@media (hover:hover){.dou-code-input .dou-code-editor:not(:-webkit-any(.is-focused,.is-disabled)):hover{--dou-code-editor-border:var(--dou-color-border-strong)}.dou-code-input .dou-code-editor:not(:-moz-any(.is-focused,.is-disabled)):hover{--dou-code-editor-border:var(--dou-color-border-strong)}.dou-code-input .dou-code-editor:not(:is(.is-focused,.is-disabled)):hover{--dou-code-editor-border:var(--dou-color-border-strong)}}.dou-code-input .dou-code-editor__marks{display:none}.dou-code-input:not(.is-multiline) .dou-code-editor{height:var(--dou-code-input-height)}.dou-code-input:not(.is-multiline) .dou-code-editor .dou-code-editor__scroller{scrollbar-width:none}.dou-code-input:not(.is-multiline) .dou-code-editor .dou-code-editor__scroller::-webkit-scrollbar{display:none}.dou-code-input.is-multiline .dou-code-editor{min-height:calc(var(--dou-code-input-min-rows,1)*var(--dou-code-editor-line-height) + 2*var(--dou-code-editor-padding-y) + 2px);max-height:calc(var(--dou-code-input-max-rows,6)*var(--dou-code-editor-line-height) + 2*var(--dou-code-editor-padding-y) + 2px)}.dou-code-input.is-invalid .dou-code-editor{--dou-code-editor-border:color-mix(in oklab,var(--dou-color-danger)55%,var(--dou-color-border));--dou-code-editor-border-focus:var(--dou-color-danger)}.dou-code-input--sm{--dou-code-input-height:var(--dou-control-height-sm)}.dou-code-input--sm .dou-code-editor{--dou-code-editor-padding-x:var(--dou-control-padding-x-sm)}.dou-code-input--lg{--dou-code-input-height:var(--dou-control-height-lg)}.dou-code-input--lg .dou-code-editor{--dou-code-editor-padding-x:var(--dou-control-padding-x-lg)}}@keyframes dou-code-peer-name{to{opacity:0;visibility:hidden}}@keyframes dou-code-editor-blink{50%{opacity:0}}@layer dou.components{.dou-code-diff{--dou-code-diff-removed:color-mix(in oklab,var(--dou-color-danger)10%,transparent);--dou-code-diff-added:color-mix(in oklab,var(--dou-color-success)10%,transparent);--dou-code-diff-removed-word:color-mix(in oklab,var(--dou-color-danger-text)30%,transparent);--dou-code-diff-added-word:color-mix(in oklab,var(--dou-color-success-text)30%,transparent);--dou-code-diff-border:var(--dou-color-border);--dou-code-diff-toolbar-bg:var(--dou-color-bg-surface);--dou-code-diff-toolbar-top:0px;position:relative;display:flex;box-sizing:border-box;overflow:clip;border:1px solid var(--dou-code-diff-border);border-radius:var(--dou-radius-container);background-color:var(--dou-color-bg-surface);transition:border-color var(--dou-motion-duration-fast)var(--dou-motion-easing);flex-direction:column;width:100%;min-width:0}.dou-code-diff:focus-within{border-color:color-mix(in oklab,var(--dou-color-focus)70%,var(--dou-color-text))}.dou-code-diff:not(.is-bordered){border:0;border-radius:0}.dou-code-diff__toolbar{display:flex;border-bottom:1px solid var(--dou-code-diff-border);background-color:var(--dou-code-diff-toolbar-bg);font-size:var(--dou-font-size-sm);flex:none;align-items: center;gap:2px;min-height:36px;padding:0 6px 0 12px}@media (pointer:coarse){.dou-code-diff__toolbar{min-height:44px}}.dou-code-diff__toolbar.is-sticky{position:sticky;top:var(--dou-code-diff-toolbar-top);z-index:4}.dou-code-diff__title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:auto;min-width:0;margin-inline-end:8px}.dou-code-diff__stats{display:flex;overflow:hidden;white-space:nowrap;flex:auto;align-items: center;gap:8px;min-width:0}.dou-code-diff__title+.dou-code-diff__stats{flex:none;margin-inline-end:4px}.dou-code-diff__count{font-family:var(--dou-font-family-mono);font-variant-numeric:tabular-nums}.dou-code-diff__count.is-added{color:var(--dou-color-success-text)}.dou-code-diff__count.is-removed{color:var(--dou-color-danger-text)}.dou-code-diff__summary{overflow:hidden;color:var(--dou-color-text-secondary);text-overflow:ellipsis}.dou-code-diff__hidden-text{position:absolute;overflow:hidden;clip-path:inset(50%);white-space:nowrap;width:1px;height:1px}.dou-code-diff__toolbar .dou-button{flex:none}@media (pointer:coarse){.dou-code-diff__toolbar .dou-button{position:relative;min-width:36px;min-height:36px}.dou-code-diff__toolbar .dou-button:after{position:absolute;content:"";inset:-2px}}.dou-code-diff__body{display:grid;grid-template-rows:minmax(0,1fr);grid-template-columns:minmax(0,1fr);isolation:isolate;flex:auto;min-height:0}.dou-code-diff--split>.dou-code-diff__body{grid-template-rows:auto minmax(0,1fr);grid-template-columns:minmax(0,1fr)minmax(0,1fr)}.dou-code-diff--split>.dou-code-diff__body>.dou-code-diff__side>.dou-code-editor{--dou-code-editor-gutter-padding-left:6px;--dou-code-editor-gutter-padding-right:8px;--dou-code-editor-padding-x:8px}.dou-code-diff--split>.dou-code-diff__body>.dou-code-diff__side>.dou-code-editor>.dou-code-editor__body>.dou-code-editor__scroller>.dou-code-editor__sizer>.dou-code-editor__gutter>.dou-code-editor__numbers>.dou-code-editor__number{font-size:12px}.dou-code-diff--split>.dou-code-diff__body>.dou-code-diff__side>.dou-code-editor>.dou-code-editor__body>.dou-code-editor__scroller>.dou-code-editor__sizer>.dou-code-editor__gutter>.dou-code-editor__numbers>.dou-code-editor__number>.dou-code-editor__overlays{right:auto;left:calc(var(--dou-code-editor-gutter-cells,16px) - 15px)}.dou-code-diff--inline>.dou-code-diff__body>.dou-code-editor{--dou-code-editor-padding-x:6px;--dou-code-editor-gutter-overlay-offset:-2px}.dou-code-diff__label{border-bottom:1px solid var(--dou-code-diff-border);color:var(--dou-color-text-secondary);padding:4px 12px;font-size:12px}.dou-code-diff__label:nth-child(2){border-left:1px solid var(--dou-code-diff-border)}.dou-code-diff__side{display:flex;flex-direction:column;min-width:0;min-height:0}.dou-code-diff__side.is-modified{border-left:1px solid var(--dou-code-diff-border)}.dou-code-diff__side>.dou-code-editor{flex:auto}.dou-code-diff__line.is-removed{background-color:var(--dou-code-diff-removed)}.dou-code-diff__line.is-added{background-color:var(--dou-code-diff-added)}.dou-code-diff__word.is-removed{background-color:var(--dou-code-diff-removed-word)}.dou-code-diff__word.is-added{background-color:var(--dou-code-diff-added-word)}.dou-code-editor__cell.dou-code-diff__sign{font-family:var(--dou-font-family-mono)}.dou-code-editor__cell.dou-code-diff__sign:after{position:absolute;z-index:-1;top:0;bottom:0;left:calc(100% - var(--dou-code-editor-gutter-cells));width:var(--dou-code-editor-gutter);content:"";pointer-events:none}.dou-code-editor__cell.dou-code-diff__sign.is-removed{color:var(--dou-color-danger-text)}.dou-code-editor__cell.dou-code-diff__sign.is-removed:after{background-color:var(--dou-code-diff-removed)}.dou-code-editor__cell.dou-code-diff__sign.is-added{color:var(--dou-color-success-text)}.dou-code-editor__cell.dou-code-diff__sign.is-added:after{background-color:var(--dou-code-diff-added)}.dou-code-editor__cell.dou-code-diff__number{box-sizing:border-box;color:var(--dou-code-editor-gutter-text);font-family:var(--dou-font-family-mono);font-variant-numeric:tabular-nums;justify-content:flex-end;padding:0 6px;font-size:12px}.dou-code-editor__cell.dou-code-diff__number.is-modified{padding-left:2px}.dou-code-diff.is-compact>.dou-code-diff__body>.dou-code-editor>.dou-code-editor__body>.dou-code-editor__scroller>.dou-code-editor__sizer>.dou-code-editor__gutter>.dou-code-editor__numbers>.dou-code-editor__number>.dou-code-editor__cells>.dou-code-editor__cell.dou-code-diff__number{padding:0 4px;font-size:11px}.dou-code-diff.is-compact>.dou-code-diff__body>.dou-code-editor>.dou-code-editor__body>.dou-code-editor__scroller>.dou-code-editor__sizer>.dou-code-editor__gutter>.dou-code-editor__numbers>.dou-code-editor__number>.dou-code-editor__cells>.dou-code-editor__cell.dou-code-diff__number.is-modified{padding-left:2px}.dou-code-diff.is-compact>.dou-code-diff__body>.dou-code-editor>.dou-code-editor__body>.dou-code-editor__scroller>.dou-code-editor__sizer>.dou-code-editor__gutter>.dou-code-editor__numbers>.dou-code-editor__number>.dou-code-editor__cells>.dou-code-editor__cell.dou-code-diff__sign{font-size:12px}.dou-code-diff__widget{display:flow-root}.dou-code-diff--split>.dou-code-diff__body{position:relative}.dou-code-diff__spans{position:absolute;z-index:3;overflow:hidden;pointer-events:none;left:0;right:0}.dou-code-diff__span{position:absolute;display:flow-root;box-sizing:border-box;font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);pointer-events:auto;transition:opacity var(--dou-motion-duration-fast)var(--dou-motion-easing);line-height:20px;top:0;left:0;right:0}.dou-code-diff__span:not(.is-placed){visibility:hidden;opacity:0;transition:none}.dou-code-diff__filler{background-color:var(--dou-code-editor-bg);background-image:repeating-linear-gradient(-45deg,transparent 0 6px,color-mix(in oklab,var(--dou-color-text)5%,transparent)6px 7px)}.dou-code-diff__bar{display:flex;box-sizing:border-box;border:0;border-block:1px solid var(--dou-code-diff-border);background-color:color-mix(in oklab,var(--dou-color-text)3%,var(--dou-code-editor-bg));color:var(--dou-color-text-secondary);font:inherit;text-align:left;cursor:pointer;align-items: center;gap:6px;width:100%;height:28px;margin:0;padding:0 12px;font-size:12px}@media (hover:hover){.dou-code-diff__bar:hover{background-color:color-mix(in oklab,var(--dou-color-text)6%,var(--dou-code-editor-bg));color:var(--dou-color-text)}}.dou-code-diff__bar:focus-visible{outline:2px solid var(--dou-color-focus);outline-offset:-2px}@media (pointer:coarse){.dou-code-diff__bar{height:36px}}.dou-code-diff__bar-icon{flex:none;font-size:14px}.dou-code-diff__live{position:absolute;overflow:hidden;clip-path:inset(50%);white-space:nowrap;width:1px;height:1px}.dou-code-peer{position:relative;z-index:1;display:inline-block;height:var(--dou-code-editor-line-height);vertical-align:top;pointer-events:none;width:0}.dou-code-peer:before{content:"";position:absolute;background-color:var(--dou-code-peer-color);border-radius:1px;width:2px;height:100%;top:0;left:-1px}.dou-code-peer__name{position:absolute;background-color:var(--dou-code-peer-color);color:oklch(from var(--dou-code-peer-color)clamp(.2,(.66 - l)*100,.99)0 0);font-family:var(--dou-font-family);font-size:var(--dou-font-size-sm);white-space:nowrap;user-select:none;animation:dou-code-peer-name var(--dou-motion-duration-fast)var(--dou-motion-easing)3s forwards;border-radius:4px 4px 4px 0;padding:0 6px;line-height:18px;bottom:100%;left:-1px}.dou-code-peer.is-below .dou-code-peer__name{border-radius:0 4px 4px;top:100%;bottom:auto}.dou-code-peer-selection{background-color:color-mix(in oklab,var(--dou-code-peer-color)20%,transparent)}}
@@ -89,6 +89,11 @@ export interface CodeWidget {
89
89
  height?: number;
90
90
  /** What it is, read out when the cursor moves onto its line, e.g. "戴兜的评论". */
91
91
  label?: string;
92
+ /**
93
+ * Draws across the gutter too, taking the full width of the editor's view.
94
+ * Off by default, so widgets start beside the gutter, aligned with the text.
95
+ */
96
+ fullWidth?: boolean;
92
97
  }
93
98
  /** Something drawn in a column beside the line numbers, on line `line` (from 1). */
94
99
  export interface CodeGutterMarker {
@@ -126,8 +131,15 @@ export interface CodeGutterHoverMarker extends Pick<CodeGutterMarker, 'icon' | '
126
131
  /** A column of the gutter, left of the line numbers. */
127
132
  export interface CodeGutter {
128
133
  name: string;
129
- /** In px. Defaults to 16. */
134
+ /** In px. Defaults to 16 (or 18 when `overlay` is set). */
130
135
  width?: number;
136
+ /**
137
+ * Draws markers floating over the gutter's right edge without reserving a
138
+ * dedicated column width (0px layout footprint). Best paired with
139
+ * `hoverMarker` or `visible: 'hover'` for row actions such as adding review
140
+ * comments. Empty rows take no pointer events.
141
+ */
142
+ overlay?: boolean;
131
143
  /** The markers on the lines in view; reactive state read here updates them. */
132
144
  markers?: (context: CodeExtensionContext) => CodeGutterMarker[];
133
145
  /** A marker on every other line, shown on hover. */
@@ -330,8 +330,14 @@ export interface CodeDiffHoverMarker extends Omit<CodeGutterHoverMarker, 'title'
330
330
  /** A column of `DouCodeDiff`'s gutter, left of the line numbers. */
331
331
  export interface CodeDiffGutter {
332
332
  name: string;
333
- /** In px. Defaults to 16. */
333
+ /** In px. Defaults to 16 (or 18 when rendered as an overlay). */
334
334
  width?: number;
335
+ /**
336
+ * Floats markers over the gutter's right edge without reserving a dedicated
337
+ * column width: `true` always overlays, `'compact'` overlays only in narrow
338
+ * containers (`< 480px`). Defaults to `false`.
339
+ */
340
+ overlay?: boolean | 'compact';
335
341
  markers?: CodeDiffGutterMarker[];
336
342
  /**
337
343
  * A marker on every other line, shown on hover. With `side`, the other
@@ -7,9 +7,15 @@ export declare class Measure {
7
7
  padY: number;
8
8
  /** Space before and after each line (`--dou-code-editor-padding-x`). */
9
9
  padX: number;
10
+ /** Space left of line numbers in the gutter (`--dou-code-editor-gutter-padding-left`). */
11
+ gutterPadLeft: number;
12
+ /** Space right of line numbers in the gutter (`--dou-code-editor-gutter-padding-right`). */
13
+ gutterPadRight: number;
10
14
  tabSize: number;
11
15
  private widths;
12
16
  constructor(probe: () => HTMLElement | null | undefined);
17
+ /** Reads the CSS padding variables; returns `true` when any changed. */
18
+ refreshPadding(): boolean;
13
19
  /** Reads the cell width and line height again, e.g. after the font changed. */
14
20
  refresh(tabSize: number): void;
15
21
  /** Width of one character as drawn. */
@@ -20,11 +20,33 @@ var Measure = class {
20
20
  padY = 8;
21
21
  /** Space before and after each line (`--dou-code-editor-padding-x`). */
22
22
  padX = 12;
23
+ /** Space left of line numbers in the gutter (`--dou-code-editor-gutter-padding-left`). */
24
+ gutterPadLeft = 16;
25
+ /** Space right of line numbers in the gutter (`--dou-code-editor-gutter-padding-right`). */
26
+ gutterPadRight = 12;
23
27
  tabSize = 2;
24
28
  widths = /* @__PURE__ */ new Map();
25
29
  constructor(probe) {
26
30
  this.probe = probe;
27
31
  }
32
+ /** Reads the CSS padding variables; returns `true` when any changed. */
33
+ refreshPadding() {
34
+ const el = this.probe();
35
+ if (!el) return false;
36
+ el.style.padding = "var(--dou-code-editor-padding-y, 8px) var(--dou-code-editor-padding-x, 12px) var(--dou-code-editor-gutter-padding-left, 16px) var(--dou-code-editor-gutter-padding-right, 12px)";
37
+ const style = getComputedStyle(el);
38
+ const padY = px(style.paddingTop, 8);
39
+ const padX = px(style.paddingRight, 12);
40
+ const gutterPadLeft = px(style.paddingBottom, 16);
41
+ const gutterPadRight = px(style.paddingLeft, 12);
42
+ el.style.padding = "";
43
+ const changed = padY !== this.padY || padX !== this.padX || gutterPadLeft !== this.gutterPadLeft || gutterPadRight !== this.gutterPadRight;
44
+ this.padY = padY;
45
+ this.padX = padX;
46
+ this.gutterPadLeft = gutterPadLeft;
47
+ this.gutterPadRight = gutterPadRight;
48
+ return changed;
49
+ }
28
50
  /** Reads the cell width and line height again, e.g. after the font changed. */
29
51
  refresh(tabSize) {
30
52
  this.tabSize = tabSize;
@@ -36,11 +58,7 @@ var Measure = class {
36
58
  if (rect.width > 0) this.cell = rect.width / 64;
37
59
  if (rect.height > 0) this.lineHeight = Math.round(rect.height);
38
60
  el.textContent = "";
39
- el.style.padding = "var(--dou-code-editor-padding-y, 8px) var(--dou-code-editor-padding-x, 12px)";
40
- const style = getComputedStyle(el);
41
- this.padY = px(style.paddingTop, 8);
42
- this.padX = px(style.paddingLeft, 12);
43
- el.style.padding = "";
61
+ this.refreshPadding();
44
62
  }
45
63
  /** Width of one character as drawn. */
46
64
  width(cluster) {
@@ -1 +1 @@
1
- {"version":3,"file":"measure.js","names":[],"sources":["../../src/view/measure.ts"],"sourcesContent":["import { clusterStarts, isAscii } from '../core/chars'\n\n/**\n * Text metrics without reading layout per line: every plain ASCII\n * character is one monospace cell, and anything else (CJK, emoji, accents)\n * is measured once in the page's own font and remembered. Tabs reach to\n * the next tab stop.\n */\n/** A length read from computed styles, in px. */\nfunction px(value: string, fallback: number) {\n const n = Number.parseFloat(value)\n return Number.isFinite(n) ? Math.max(0, n) : fallback\n}\n\nexport class Measure {\n /** Width of one monospace cell. */\n cell = 8\n lineHeight = 20\n /** Space above the first line and below the last (`--dou-code-editor-padding-y`). */\n padY = 8\n /** Space before and after each line (`--dou-code-editor-padding-x`). */\n padX = 12\n tabSize = 2\n private widths = new Map<string, number>()\n\n constructor(private readonly probe: () => HTMLElement | null | undefined) {}\n\n /** Reads the cell width and line height again, e.g. after the font changed. */\n refresh(tabSize: number) {\n this.tabSize = tabSize\n this.widths.clear()\n const el = this.probe()\n if (!el) return\n el.textContent = 'x'.repeat(64)\n const rect = el.getBoundingClientRect()\n if (rect.width > 0) this.cell = rect.width / 64\n if (rect.height > 0) this.lineHeight = Math.round(rect.height)\n el.textContent = ''\n // Through a padding, so a calc() in the variable comes out in pixels.\n el.style.padding =\n 'var(--dou-code-editor-padding-y, 8px) var(--dou-code-editor-padding-x, 12px)'\n const style = getComputedStyle(el)\n this.padY = px(style.paddingTop, 8)\n this.padX = px(style.paddingLeft, 12)\n el.style.padding = ''\n }\n\n /** Width of one character as drawn. */\n width(cluster: string): number {\n const code = cluster.charCodeAt(0)\n if (cluster.length === 1 && code >= 0x20 && code < 0x7f) return this.cell\n let width = this.widths.get(cluster)\n if (width !== undefined) return width\n const el = this.probe()\n if (el) {\n el.textContent = cluster\n width = el.getBoundingClientRect().width\n el.textContent = ''\n }\n // No layout (tests, a hidden editor): wide scripts take two cells.\n if (!width)\n width = /[ᄀ-ᅟ⺀-꓏가-힣豈-﫿︰-﹏＀-⦆¢-₩]|[\\ud83c-\\ud83e]/.test(cluster)\n ? this.cell * 2\n : this.cell\n // Only keep it once the page has fonts, so a fallback guess isn't kept forever.\n if (el?.isConnected) this.widths.set(cluster, width)\n return width\n }\n\n private tab(x: number) {\n const stop = this.cell * this.tabSize\n return (Math.floor(x / stop + 1e-6) + 1) * stop\n }\n\n /** The x of column `col` in `text`, from the line's start. */\n x(text: string, col: number): number {\n col = Math.min(col, text.length)\n if (isAscii(text)) {\n if (!text.includes('\\t')) return col * this.cell\n let x = 0\n for (let i = 0; i < col; i++) x = text.charCodeAt(i) === 9 ? this.tab(x) : x + this.cell\n return x\n }\n let x = 0\n const starts = clusterStarts(text)\n for (let i = 0; i < starts.length - 1 && starts[i]! < col; i++) {\n const cluster = text.slice(starts[i], starts[i + 1])\n x = cluster === '\\t' ? this.tab(x) : x + this.width(cluster)\n }\n return x\n }\n\n /** The column nearest to `x` in `text`, on a character boundary. */\n col(text: string, x: number): number {\n if (x <= 0) return 0\n if (isAscii(text) && !text.includes('\\t'))\n return Math.min(text.length, Math.round(x / this.cell))\n let left = 0\n const ascii = isAscii(text)\n const starts = ascii ? null : clusterStarts(text)\n const count = ascii ? text.length : starts!.length - 1\n for (let i = 0; i < count; i++) {\n const from = ascii ? i : starts![i]!\n const to = ascii ? i + 1 : starts![i + 1]!\n const cluster = text.slice(from, to)\n const right = cluster === '\\t' ? this.tab(left) : left + this.width(cluster)\n if (x < (left + right) / 2) return from\n if (x < right) return to\n left = right\n }\n return text.length\n }\n}\n"],"mappings":";;;;;;;;;AASA,SAAS,GAAG,OAAe,UAAkB;CAC3C,MAAM,IAAI,OAAO,WAAW,KAAK;CACjC,OAAO,OAAO,SAAS,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,IAAI;AAC/C;AAEA,IAAa,UAAb,MAAqB;CAWU;;CAT7B,OAAO;CACP,aAAa;;CAEb,OAAO;;CAEP,OAAO;CACP,UAAU;CACV,yBAAiB,IAAI,IAAoB;CAEzC,YAAY,OAA8D;EAA7C,KAAA,QAAA;CAA8C;;CAG3E,QAAQ,SAAiB;EACvB,KAAK,UAAU;EACf,KAAK,OAAO,MAAM;EAClB,MAAM,KAAK,KAAK,MAAM;EACtB,IAAI,CAAC,IAAI;EACT,GAAG,cAAc,IAAI,OAAO,EAAE;EAC9B,MAAM,OAAO,GAAG,sBAAsB;EACtC,IAAI,KAAK,QAAQ,GAAG,KAAK,OAAO,KAAK,QAAQ;EAC7C,IAAI,KAAK,SAAS,GAAG,KAAK,aAAa,KAAK,MAAM,KAAK,MAAM;EAC7D,GAAG,cAAc;EAEjB,GAAG,MAAM,UACP;EACF,MAAM,QAAQ,iBAAiB,EAAE;EACjC,KAAK,OAAO,GAAG,MAAM,YAAY,CAAC;EAClC,KAAK,OAAO,GAAG,MAAM,aAAa,EAAE;EACpC,GAAG,MAAM,UAAU;CACrB;;CAGA,MAAM,SAAyB;EAC7B,MAAM,OAAO,QAAQ,WAAW,CAAC;EACjC,IAAI,QAAQ,WAAW,KAAK,QAAQ,MAAQ,OAAO,KAAM,OAAO,KAAK;EACrE,IAAI,QAAQ,KAAK,OAAO,IAAI,OAAO;EACnC,IAAI,UAAU,KAAA,GAAW,OAAO;EAChC,MAAM,KAAK,KAAK,MAAM;EACtB,IAAI,IAAI;GACN,GAAG,cAAc;GACjB,QAAQ,GAAG,sBAAsB,CAAC,CAAC;GACnC,GAAG,cAAc;EACnB;EAEA,IAAI,CAAC,OACH,QAAQ,0CAA0C,KAAK,OAAO,IAC1D,KAAK,OAAO,IACZ,KAAK;EAEX,IAAI,IAAI,aAAa,KAAK,OAAO,IAAI,SAAS,KAAK;EACnD,OAAO;CACT;CAEA,IAAY,GAAW;EACrB,MAAM,OAAO,KAAK,OAAO,KAAK;EAC9B,QAAQ,KAAK,MAAM,IAAI,OAAO,IAAI,IAAI,KAAK;CAC7C;;CAGA,EAAE,MAAc,KAAqB;EACnC,MAAM,KAAK,IAAI,KAAK,KAAK,MAAM;EAC/B,IAAI,QAAQ,IAAI,GAAG;GACjB,IAAI,CAAC,KAAK,SAAS,GAAI,GAAG,OAAO,MAAM,KAAK;GAC5C,IAAI,IAAI;GACR,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK,IAAI,KAAK,WAAW,CAAC,MAAM,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK;GACpF,OAAO;EACT;EACA,IAAI,IAAI;EACR,MAAM,SAAS,cAAc,IAAI;EACjC,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,SAAS,KAAK,OAAO,KAAM,KAAK,KAAK;GAC9D,MAAM,UAAU,KAAK,MAAM,OAAO,IAAI,OAAO,IAAI,EAAE;GACnD,IAAI,YAAY,MAAO,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,MAAM,OAAO;EAC7D;EACA,OAAO;CACT;;CAGA,IAAI,MAAc,GAAmB;EACnC,IAAI,KAAK,GAAG,OAAO;EACnB,IAAI,QAAQ,IAAI,KAAK,CAAC,KAAK,SAAS,GAAI,GACtC,OAAO,KAAK,IAAI,KAAK,QAAQ,KAAK,MAAM,IAAI,KAAK,IAAI,CAAC;EACxD,IAAI,OAAO;EACX,MAAM,QAAQ,QAAQ,IAAI;EAC1B,MAAM,SAAS,QAAQ,OAAO,cAAc,IAAI;EAChD,MAAM,QAAQ,QAAQ,KAAK,SAAS,OAAQ,SAAS;EACrD,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,KAAK;GAC9B,MAAM,OAAO,QAAQ,IAAI,OAAQ;GACjC,MAAM,KAAK,QAAQ,IAAI,IAAI,OAAQ,IAAI;GACvC,MAAM,UAAU,KAAK,MAAM,MAAM,EAAE;GACnC,MAAM,QAAQ,YAAY,MAAO,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,MAAM,OAAO;GAC3E,IAAI,KAAK,OAAO,SAAS,GAAG,OAAO;GACnC,IAAI,IAAI,OAAO,OAAO;GACtB,OAAO;EACT;EACA,OAAO,KAAK;CACd;AACF"}
1
+ {"version":3,"file":"measure.js","names":[],"sources":["../../src/view/measure.ts"],"sourcesContent":["import { clusterStarts, isAscii } from '../core/chars'\n\n/**\n * Text metrics without reading layout per line: every plain ASCII\n * character is one monospace cell, and anything else (CJK, emoji, accents)\n * is measured once in the page's own font and remembered. Tabs reach to\n * the next tab stop.\n */\n/** A length read from computed styles, in px. */\nfunction px(value: string, fallback: number) {\n const n = Number.parseFloat(value)\n return Number.isFinite(n) ? Math.max(0, n) : fallback\n}\n\nexport class Measure {\n /** Width of one monospace cell. */\n cell = 8\n lineHeight = 20\n /** Space above the first line and below the last (`--dou-code-editor-padding-y`). */\n padY = 8\n /** Space before and after each line (`--dou-code-editor-padding-x`). */\n padX = 12\n /** Space left of line numbers in the gutter (`--dou-code-editor-gutter-padding-left`). */\n gutterPadLeft = 16\n /** Space right of line numbers in the gutter (`--dou-code-editor-gutter-padding-right`). */\n gutterPadRight = 12\n tabSize = 2\n private widths = new Map<string, number>()\n\n constructor(private readonly probe: () => HTMLElement | null | undefined) {}\n\n /** Reads the CSS padding variables; returns `true` when any changed. */\n refreshPadding(): boolean {\n const el = this.probe()\n if (!el) return false\n // Through a padding, so a calc() in the variable comes out in pixels.\n el.style.padding =\n 'var(--dou-code-editor-padding-y, 8px) var(--dou-code-editor-padding-x, 12px) var(--dou-code-editor-gutter-padding-left, 16px) var(--dou-code-editor-gutter-padding-right, 12px)'\n const style = getComputedStyle(el)\n const padY = px(style.paddingTop, 8)\n const padX = px(style.paddingRight, 12)\n const gutterPadLeft = px(style.paddingBottom, 16)\n const gutterPadRight = px(style.paddingLeft, 12)\n el.style.padding = ''\n const changed =\n padY !== this.padY ||\n padX !== this.padX ||\n gutterPadLeft !== this.gutterPadLeft ||\n gutterPadRight !== this.gutterPadRight\n this.padY = padY\n this.padX = padX\n this.gutterPadLeft = gutterPadLeft\n this.gutterPadRight = gutterPadRight\n return changed\n }\n\n /** Reads the cell width and line height again, e.g. after the font changed. */\n refresh(tabSize: number) {\n this.tabSize = tabSize\n this.widths.clear()\n const el = this.probe()\n if (!el) return\n el.textContent = 'x'.repeat(64)\n const rect = el.getBoundingClientRect()\n if (rect.width > 0) this.cell = rect.width / 64\n if (rect.height > 0) this.lineHeight = Math.round(rect.height)\n el.textContent = ''\n this.refreshPadding()\n }\n\n /** Width of one character as drawn. */\n width(cluster: string): number {\n const code = cluster.charCodeAt(0)\n if (cluster.length === 1 && code >= 0x20 && code < 0x7f) return this.cell\n let width = this.widths.get(cluster)\n if (width !== undefined) return width\n const el = this.probe()\n if (el) {\n el.textContent = cluster\n width = el.getBoundingClientRect().width\n el.textContent = ''\n }\n // No layout (tests, a hidden editor): wide scripts take two cells.\n if (!width)\n width = /[ᄀ-ᅟ⺀-꓏가-힣豈-﫿︰-﹏＀-⦆¢-₩]|[\\ud83c-\\ud83e]/.test(cluster)\n ? this.cell * 2\n : this.cell\n // Only keep it once the page has fonts, so a fallback guess isn't kept forever.\n if (el?.isConnected) this.widths.set(cluster, width)\n return width\n }\n\n private tab(x: number) {\n const stop = this.cell * this.tabSize\n return (Math.floor(x / stop + 1e-6) + 1) * stop\n }\n\n /** The x of column `col` in `text`, from the line's start. */\n x(text: string, col: number): number {\n col = Math.min(col, text.length)\n if (isAscii(text)) {\n if (!text.includes('\\t')) return col * this.cell\n let x = 0\n for (let i = 0; i < col; i++) x = text.charCodeAt(i) === 9 ? this.tab(x) : x + this.cell\n return x\n }\n let x = 0\n const starts = clusterStarts(text)\n for (let i = 0; i < starts.length - 1 && starts[i]! < col; i++) {\n const cluster = text.slice(starts[i], starts[i + 1])\n x = cluster === '\\t' ? this.tab(x) : x + this.width(cluster)\n }\n return x\n }\n\n /** The column nearest to `x` in `text`, on a character boundary. */\n col(text: string, x: number): number {\n if (x <= 0) return 0\n if (isAscii(text) && !text.includes('\\t'))\n return Math.min(text.length, Math.round(x / this.cell))\n let left = 0\n const ascii = isAscii(text)\n const starts = ascii ? null : clusterStarts(text)\n const count = ascii ? text.length : starts!.length - 1\n for (let i = 0; i < count; i++) {\n const from = ascii ? i : starts![i]!\n const to = ascii ? i + 1 : starts![i + 1]!\n const cluster = text.slice(from, to)\n const right = cluster === '\\t' ? this.tab(left) : left + this.width(cluster)\n if (x < (left + right) / 2) return from\n if (x < right) return to\n left = right\n }\n return text.length\n }\n}\n"],"mappings":";;;;;;;;;AASA,SAAS,GAAG,OAAe,UAAkB;CAC3C,MAAM,IAAI,OAAO,WAAW,KAAK;CACjC,OAAO,OAAO,SAAS,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,IAAI;AAC/C;AAEA,IAAa,UAAb,MAAqB;CAeU;;CAb7B,OAAO;CACP,aAAa;;CAEb,OAAO;;CAEP,OAAO;;CAEP,gBAAgB;;CAEhB,iBAAiB;CACjB,UAAU;CACV,yBAAiB,IAAI,IAAoB;CAEzC,YAAY,OAA8D;EAA7C,KAAA,QAAA;CAA8C;;CAG3E,iBAA0B;EACxB,MAAM,KAAK,KAAK,MAAM;EACtB,IAAI,CAAC,IAAI,OAAO;EAEhB,GAAG,MAAM,UACP;EACF,MAAM,QAAQ,iBAAiB,EAAE;EACjC,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC;EACnC,MAAM,OAAO,GAAG,MAAM,cAAc,EAAE;EACtC,MAAM,gBAAgB,GAAG,MAAM,eAAe,EAAE;EAChD,MAAM,iBAAiB,GAAG,MAAM,aAAa,EAAE;EAC/C,GAAG,MAAM,UAAU;EACnB,MAAM,UACJ,SAAS,KAAK,QACd,SAAS,KAAK,QACd,kBAAkB,KAAK,iBACvB,mBAAmB,KAAK;EAC1B,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,gBAAgB;EACrB,KAAK,iBAAiB;EACtB,OAAO;CACT;;CAGA,QAAQ,SAAiB;EACvB,KAAK,UAAU;EACf,KAAK,OAAO,MAAM;EAClB,MAAM,KAAK,KAAK,MAAM;EACtB,IAAI,CAAC,IAAI;EACT,GAAG,cAAc,IAAI,OAAO,EAAE;EAC9B,MAAM,OAAO,GAAG,sBAAsB;EACtC,IAAI,KAAK,QAAQ,GAAG,KAAK,OAAO,KAAK,QAAQ;EAC7C,IAAI,KAAK,SAAS,GAAG,KAAK,aAAa,KAAK,MAAM,KAAK,MAAM;EAC7D,GAAG,cAAc;EACjB,KAAK,eAAe;CACtB;;CAGA,MAAM,SAAyB;EAC7B,MAAM,OAAO,QAAQ,WAAW,CAAC;EACjC,IAAI,QAAQ,WAAW,KAAK,QAAQ,MAAQ,OAAO,KAAM,OAAO,KAAK;EACrE,IAAI,QAAQ,KAAK,OAAO,IAAI,OAAO;EACnC,IAAI,UAAU,KAAA,GAAW,OAAO;EAChC,MAAM,KAAK,KAAK,MAAM;EACtB,IAAI,IAAI;GACN,GAAG,cAAc;GACjB,QAAQ,GAAG,sBAAsB,CAAC,CAAC;GACnC,GAAG,cAAc;EACnB;EAEA,IAAI,CAAC,OACH,QAAQ,0CAA0C,KAAK,OAAO,IAC1D,KAAK,OAAO,IACZ,KAAK;EAEX,IAAI,IAAI,aAAa,KAAK,OAAO,IAAI,SAAS,KAAK;EACnD,OAAO;CACT;CAEA,IAAY,GAAW;EACrB,MAAM,OAAO,KAAK,OAAO,KAAK;EAC9B,QAAQ,KAAK,MAAM,IAAI,OAAO,IAAI,IAAI,KAAK;CAC7C;;CAGA,EAAE,MAAc,KAAqB;EACnC,MAAM,KAAK,IAAI,KAAK,KAAK,MAAM;EAC/B,IAAI,QAAQ,IAAI,GAAG;GACjB,IAAI,CAAC,KAAK,SAAS,GAAI,GAAG,OAAO,MAAM,KAAK;GAC5C,IAAI,IAAI;GACR,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK,IAAI,KAAK,WAAW,CAAC,MAAM,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK;GACpF,OAAO;EACT;EACA,IAAI,IAAI;EACR,MAAM,SAAS,cAAc,IAAI;EACjC,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,SAAS,KAAK,OAAO,KAAM,KAAK,KAAK;GAC9D,MAAM,UAAU,KAAK,MAAM,OAAO,IAAI,OAAO,IAAI,EAAE;GACnD,IAAI,YAAY,MAAO,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,MAAM,OAAO;EAC7D;EACA,OAAO;CACT;;CAGA,IAAI,MAAc,GAAmB;EACnC,IAAI,KAAK,GAAG,OAAO;EACnB,IAAI,QAAQ,IAAI,KAAK,CAAC,KAAK,SAAS,GAAI,GACtC,OAAO,KAAK,IAAI,KAAK,QAAQ,KAAK,MAAM,IAAI,KAAK,IAAI,CAAC;EACxD,IAAI,OAAO;EACX,MAAM,QAAQ,QAAQ,IAAI;EAC1B,MAAM,SAAS,QAAQ,OAAO,cAAc,IAAI;EAChD,MAAM,QAAQ,QAAQ,KAAK,SAAS,OAAQ,SAAS;EACrD,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,KAAK;GAC9B,MAAM,OAAO,QAAQ,IAAI,OAAQ;GACjC,MAAM,KAAK,QAAQ,IAAI,IAAI,OAAQ,IAAI;GACvC,MAAM,UAAU,KAAK,MAAM,MAAM,EAAE;GACnC,MAAM,QAAQ,YAAY,MAAO,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,MAAM,OAAO;GAC3E,IAAI,KAAK,OAAO,SAAS,GAAG,OAAO;GACnC,IAAI,IAAI,OAAO,OAAO;GACtB,OAAO;EACT;EACA,OAAO,KAAK;CACd;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dou-ui/code",
3
- "version": "0.1.0-alpha.22",
3
+ "version": "0.1.0-alpha.24",
4
4
  "description": "DouUI 的代码编辑器:大文件流畅编辑、输入法友好、多光标与协同",
5
5
  "keywords": [
6
6
  "vue",
@@ -63,10 +63,10 @@
63
63
  "build": "vite build && vue-tsc -p tsconfig.build.json && bun scripts/build-style.ts"
64
64
  },
65
65
  "dependencies": {
66
- "@dou-ui/icons": "0.1.0-alpha.22"
66
+ "@dou-ui/icons": "0.1.0-alpha.24"
67
67
  },
68
68
  "peerDependencies": {
69
- "dou-ui": "0.1.0-alpha.22",
69
+ "dou-ui": "0.1.0-alpha.24",
70
70
  "vue": "^3.5.0",
71
71
  "yjs": "^13.6.0",
72
72
  "shiki": "^1.0.0 || ^2.0.0 || ^3.0.0"