@coldsmirk/inkstone-codemirror 0.28.0 → 0.29.0

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.
package/README.md CHANGED
@@ -13,7 +13,7 @@ Part of [inkstone](https://github.com/coldsmirk/inkstone). For a drop-in React c
13
13
  - **MiniJinja** — `language: "minijinja"` for standalone templates, or `minijinja-<host>` mixed variants (`minijinja-html`, `-xml`, `-json`, `-yaml`, `-css`, `-scss`, `-sass`, `-less`, `-markdown`; the SQL family — `-sql` plus every dialect id: `-mysql`, `-pgsql`, `-sqlite`, `-mssql`, `-mariadb`, `-plsql`, `-cassandra`, `-hive`, `-sparksql`, `-gql`, `-gpsql`, `-esper`; and the config/deploy hosts `-toml`, `-ini`, `-env`, `-shell`, `-dockerfile`, `-nginx`) that overlay MiniJinja tooling on the host grammar. A parser adapter supports MiniJinja whitespace control, dotted namespace assignments, and comma-separated `set` assignments beyond the upstream Jinja grammar; a linter flags non-MiniJinja tags, and autocomplete is restricted to MiniJinja's real tags / filters / tests / functions.
14
14
  - **Context completion** — `normalizeContext({ schema })` (JSON Schema) or `normalizeContext({ sample })` (representative value) builds an `EditorContext`; dispatch it with `setMinijinjaContext` to make `{{ }}` / `{% if %}` / `{% for %}` complete the render context's variables and walk member access (`user.address.city`). `minijinjaContextField`, `resolveMembers`, and `typeAtPath` expose the underlying pieces.
15
15
  - **SQL schema completion** — dispatch `setSqlSchema.of({ tables })` for dialect-aware table and column completion in the Lezer-backed `sql`, `mysql`, `pgsql`, `sqlite`, `mssql`, `mariadb`, `plsql`, and `cassandra` languages plus their `minijinja-*` variants. Legacy stream-mode SQL languages do not consume schemas. Install `sqlSchemaField` in your static extensions to dispatch the schema before the lazy grammar arrives.
16
- - **Catppuccin theming** — `defaultThemeExtensions(dark, height?, width?, fontSize?, lineHeight?)`, the latte/macchiato flavor pair plus chrome polish (completion tooltip, icons, hover/lint tooltips, search panel) and sizing. The polish paints the roles a consumer configured through `@coldsmirk/inkstone-core`'s `configureEditorSurface` — background and gutter, the current line and its number, caret, selection, scrollbars, the tooltip and panel chrome and its text, the accent, and the diagnostic severities, which color every mark `@codemirror/lint` draws (squiggle, point, gutter marker, message bar) — and reads the host's `--inkstone-radius-*` / `--inkstone-shadow-*` tokens for corners and elevation, each falling back to its own look; `mergeTheme(dark)` / `installDiffChrome(root)` / `diffChromeColor(dark)` / `installDiffControlKeyboardSupport(container)` extend it to `@codemirror/merge`'s diff surfaces (see the `merge-chrome` module docs for the assembly). This is the identity `@coldsmirk/inkstone-react`'s components ship by default.
16
+ - **Catppuccin theming** — `defaultThemeExtensions(dark, height?, width?, fontSize?, lineHeight?)`, the latte/macchiato flavor pair plus chrome polish (completion tooltip, icons, hover/lint tooltips, search panel) and sizing. The polish paints the roles a consumer configured through `@coldsmirk/inkstone-core`'s `configureEditorColors` — background and gutter, the current line and its number, caret, selection, scrollbars, the tooltip and panel chrome and its text, the accent, and the diagnostic severities, which color every mark `@codemirror/lint` draws (squiggle, point, gutter marker) and the severity's mark that leads its message — and reads the host's `--inkstone-radius-*` / `--inkstone-shadow-*` tokens for corners and elevation, each falling back to its own look; `mergeTheme(dark)` / `installDiffChrome(root)` / `diffChromeColor(dark)` / `installDiffControlKeyboardSupport(container)` extend it to `@codemirror/merge`'s diff surfaces (see the `merge-chrome` module docs for the assembly). This is the identity `@coldsmirk/inkstone-react`'s components ship by default.
17
17
  - **`searchPhrasesZhCn`** — an opt-in `EditorState.phrases` table localizing the search panel to Simplified Chinese.
18
18
 
19
19
  ## Install
package/dist/index.d.ts CHANGED
@@ -555,7 +555,7 @@ declare const searchPhrasesZhCn: Extension;
555
555
  * original side, insertions green on the modified side (the package scopes sides through the
556
556
  * cm-merge-a / cm-merge-b classes it places on each editor root), and the collapsed-lines bar
557
557
  * drops its hardcoded grays for the chrome's own: a host's muted text and selection plane
558
- * (`configureEditorSurface`), else the flavor's. Regular theme precedence — it beats the merge
558
+ * (`configureEditorColors`), else the flavor's. Regular theme precedence — it beats the merge
559
559
  * package's baseTheme by CodeMirror's theme-over-base contract, and a caller theme layered
560
560
  * after it still overrides it.
561
561
  */
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { defaultKeymap, history, historyKeymap, indentWithTab } from "@codemirro
7
7
  import { LanguageSupport, StreamLanguage, bracketMatching, codeFolding, foldGutter, foldKeymap, indentOnInput } from "@codemirror/language";
8
8
  import { highlightSelectionMatches, searchKeymap } from "@codemirror/search";
9
9
  import { flavors } from "@catppuccin/palette";
10
- import { CODE_FONT_FAMILY, getEditorSurface, inkstoneRadius, inkstoneShadow } from "@coldsmirk/inkstone-core";
10
+ import { CODE_FONT_FAMILY, getEditorColors, inkstoneRadius, inkstoneShadow } from "@coldsmirk/inkstone-core";
11
11
  import { catppuccinLatte, catppuccinMacchiato } from "@catppuccin/codemirror";
12
12
  import { MergeView } from "@codemirror/merge";
13
13
  //#region src/minimal-replace.ts
@@ -466,44 +466,44 @@ function diagnosticRules(palette) {
466
466
  }
467
467
  function chromeTheme(dark) {
468
468
  const { colors } = dark ? flavors.macchiato : flavors.latte;
469
- const surface = getEditorSurface(dark) ?? {};
470
- const hairline = `1px solid ${surface.widgetBorder ?? alphaOf(colors.overlay0, .35)}`;
471
- const controlFill = surface.widgetSelection ?? colors.surface1.hex;
472
- const foreground = surface.widgetForeground ?? colors.text.hex;
473
- const muted = surface.widgetForegroundMuted ?? colors.overlay1.hex;
474
- const label = surface.widgetForegroundMuted ?? colors.subtext0.hex;
475
- const accent = surface.accent ?? colors.blue.hex;
476
- const selection = surface.selection ?? alphaOf(colors.blue, dark ? .35 : .25);
477
- const blurredSelection = surface.selection === void 0 ? alphaOf(colors.blue, dark ? .2 : .14) : fade(surface.selection, 50);
469
+ const host = getEditorColors(dark) ?? {};
470
+ const hairline = `1px solid ${host.widgetBorder ?? alphaOf(colors.overlay0, .35)}`;
471
+ const controlFill = host.widgetSelection ?? colors.surface1.hex;
472
+ const foreground = host.widgetForeground ?? colors.text.hex;
473
+ const muted = host.widgetForegroundMuted ?? colors.overlay1.hex;
474
+ const label = host.widgetForegroundMuted ?? colors.subtext0.hex;
475
+ const accent = host.accent ?? colors.blue.hex;
476
+ const selection = host.selection ?? alphaOf(colors.blue, dark ? .35 : .25);
477
+ const blurredSelection = host.selection === void 0 ? alphaOf(colors.blue, dark ? .2 : .14) : fade(host.selection, 50);
478
478
  const frame = {
479
479
  border: hairline,
480
480
  borderRadius: inkstoneRadius("large", "8px"),
481
481
  boxShadow: inkstoneShadow("large", dark ? "0 8px 24px rgba(0, 0, 0, 0.5)" : "0 8px 24px rgba(0, 0, 0, 0.12)"),
482
482
  color: foreground,
483
- ...surface.widget !== void 0 && { backgroundColor: surface.widget }
483
+ ...host.widget !== void 0 && { backgroundColor: host.widget }
484
484
  };
485
485
  const gutters = {
486
- ...surface.background !== void 0 && { backgroundColor: surface.background },
487
- ...surface.lineNumber !== void 0 && { color: surface.lineNumber }
486
+ ...host.background !== void 0 && { backgroundColor: host.background },
487
+ ...host.lineNumber !== void 0 && { color: host.lineNumber }
488
488
  };
489
- const caret = surface.cursor === void 0 ? {} : {
490
- ".cm-content": { caretColor: surface.cursor },
491
- ".cm-cursor, .cm-dropCursor": { borderLeftColor: surface.cursor }
489
+ const caret = host.cursor === void 0 ? {} : {
490
+ ".cm-content": { caretColor: host.cursor },
491
+ ".cm-cursor, .cm-dropCursor": { borderLeftColor: host.cursor }
492
492
  };
493
- const tooltipArrow = surface.widget === void 0 ? {} : {
493
+ const tooltipArrow = host.widget === void 0 ? {} : {
494
494
  ".cm-tooltip .cm-tooltip-arrow:before": {
495
- borderTopColor: surface.widgetBorder ?? "transparent",
496
- borderBottomColor: surface.widgetBorder ?? "transparent"
495
+ borderTopColor: host.widgetBorder ?? "transparent",
496
+ borderBottomColor: host.widgetBorder ?? "transparent"
497
497
  },
498
498
  ".cm-tooltip .cm-tooltip-arrow:after": {
499
- borderTopColor: surface.widget,
500
- borderBottomColor: surface.widget
499
+ borderTopColor: host.widget,
500
+ borderBottomColor: host.widget
501
501
  }
502
502
  };
503
503
  return EditorView.theme({
504
504
  "&": {
505
505
  colorScheme: dark ? "dark" : "light",
506
- ...surface.background !== void 0 && { backgroundColor: surface.background }
506
+ ...host.background !== void 0 && { backgroundColor: host.background }
507
507
  },
508
508
  ...Object.keys(gutters).length > 0 && { ".cm-gutters": gutters },
509
509
  ...caret,
@@ -527,7 +527,7 @@ function chromeTheme(dark) {
527
527
  },
528
528
  "& > ul > li[aria-selected]": {
529
529
  color: foreground,
530
- ...surface.widgetSelection !== void 0 && { backgroundColor: surface.widgetSelection }
530
+ ...host.widgetSelection !== void 0 && { backgroundColor: host.widgetSelection }
531
531
  }
532
532
  },
533
533
  ".cm-completionLabel": {
@@ -609,10 +609,10 @@ function chromeTheme(dark) {
609
609
  },
610
610
  ".cm-diagnostic > *": { gridColumn: "2" },
611
611
  ...diagnosticRules({
612
- error: surface.error ?? colors.red.hex,
613
- warning: surface.warning ?? colors.peach.hex,
614
- info: surface.info ?? colors.blue.hex,
615
- hint: surface.hint ?? colors.overlay1.hex
612
+ error: host.error ?? colors.red.hex,
613
+ warning: host.warning ?? colors.peach.hex,
614
+ info: host.info ?? colors.blue.hex,
615
+ hint: host.hint ?? colors.overlay1.hex
616
616
  }),
617
617
  ".cm-diagnosticAction": {
618
618
  justifySelf: "start",
@@ -635,21 +635,21 @@ function chromeTheme(dark) {
635
635
  },
636
636
  ".cm-panel.cm-panel-lint [name=close]": { color: muted },
637
637
  "&.cm-focused": { outline: "none" },
638
- ".cm-activeLine": { backgroundColor: surface.lineHighlight ?? alphaOf(colors.overlay0, .12) },
638
+ ".cm-activeLine": { backgroundColor: host.lineHighlight ?? alphaOf(colors.overlay0, .12) },
639
639
  ".cm-activeLineGutter": {
640
- backgroundColor: surface.lineHighlight ?? alphaOf(colors.overlay0, .12),
641
- ...surface.lineNumberActive !== void 0 && { color: surface.lineNumberActive }
640
+ backgroundColor: host.lineHighlight ?? alphaOf(colors.overlay0, .12),
641
+ ...host.lineNumberActive !== void 0 && { color: host.lineNumberActive }
642
642
  },
643
643
  "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": { backgroundColor: selection },
644
644
  ".cm-selectionBackground": { backgroundColor: blurredSelection },
645
645
  ".cm-content ::selection": { backgroundColor: selection },
646
646
  ".cm-scroller, .cm-tooltip-autocomplete > ul, .cm-tooltip.cm-completionInfo": {
647
647
  scrollbarWidth: "thin",
648
- scrollbarColor: `${surface.scrollbar ?? alphaOf(colors.overlay0, .55)} transparent`
648
+ scrollbarColor: `${host.scrollbar ?? alphaOf(colors.overlay0, .55)} transparent`
649
649
  },
650
650
  ".cm-panels": {
651
651
  color: foreground,
652
- ...surface.widget !== void 0 && { backgroundColor: surface.widget }
652
+ ...host.widget !== void 0 && { backgroundColor: host.widget }
653
653
  },
654
654
  ".cm-panels.cm-panels-top": { borderBottom: hairline },
655
655
  ".cm-panels.cm-panels-bottom": { borderTop: hairline },
@@ -717,7 +717,7 @@ function chromeTheme(dark) {
717
717
  padding: "0 10px",
718
718
  fontSize: "12.5px",
719
719
  color: foreground,
720
- backgroundColor: surface.background ?? colors.base.hex,
720
+ backgroundColor: host.background ?? colors.base.hex,
721
721
  border: hairline,
722
722
  borderRadius: inkstoneRadius("medium", "6px")
723
723
  },
@@ -768,8 +768,8 @@ function defaultThemeExtensions(dark, height, width, fontSize, lineHeight) {
768
768
  //#region src/merge-chrome.ts
769
769
  function mergeTheme(dark) {
770
770
  const { colors } = dark ? flavors.macchiato : flavors.latte;
771
- const surface = getEditorSurface(dark) ?? {};
772
- const band = surface.widgetSelection ?? colors.surface0.hex;
771
+ const host = getEditorColors(dark) ?? {};
772
+ const band = host.widgetSelection ?? colors.surface0.hex;
773
773
  const removed = colors.red;
774
774
  const added = colors.green;
775
775
  const underline = (color) => `linear-gradient(${alphaOf(color, .5)}, ${alphaOf(color, .5)}) bottom/100% 2px no-repeat`;
@@ -781,13 +781,13 @@ function mergeTheme(dark) {
781
781
  "&.cm-merge-a .cm-changedLineGutter": { background: removed.hex },
782
782
  "&.cm-merge-b .cm-changedLineGutter": { background: added.hex },
783
783
  ".cm-collapsedLines": {
784
- color: surface.widgetForegroundMuted ?? colors.subtext0.hex,
784
+ color: host.widgetForegroundMuted ?? colors.subtext0.hex,
785
785
  background: `linear-gradient(to bottom, transparent 0, ${band} 30%, ${band} 70%, transparent 100%)`
786
786
  }
787
787
  }, { dark });
788
788
  }
789
789
  function diffChromeColor(dark) {
790
- return getEditorSurface(dark)?.widgetForegroundMuted ?? (dark ? flavors.macchiato : flavors.latte).colors.overlay1.hex;
790
+ return getEditorColors(dark)?.widgetForegroundMuted ?? (dark ? flavors.macchiato : flavors.latte).colors.overlay1.hex;
791
791
  }
792
792
  const DIFF_CHROME_STYLE_SELECTOR = "style[data-inkstone=\"codemirror-diff\"]";
793
793
  function installDiffChrome(root) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coldsmirk/inkstone-codemirror",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "Framework-agnostic CodeMirror 6 plumbing: a controlled editor host (create-once, external-value reconcile, in-place theme swap), the standard document extension bundle, and the editors' catppuccin theming.",
5
5
  "keywords": [
6
6
  "codemirror",
@@ -62,7 +62,7 @@
62
62
  "@codemirror/lint": "^6.9.7",
63
63
  "@codemirror/merge": "^6.12.2",
64
64
  "@lezer/common": "^1.5.2",
65
- "@coldsmirk/inkstone-core": "^0.28.0"
65
+ "@coldsmirk/inkstone-core": "^0.29.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@codemirror/autocomplete": "^6.20.3",