@coldsmirk/inkstone-codemirror 0.18.0 → 0.19.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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +30 -18
  3. package/package.json +2 -2
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; `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 host surface a consumer configured through `@coldsmirk/inkstone-core`'s `configureEditorSurface` (background and gutter, current line, line numbers, tooltip and panel chrome) 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.js CHANGED
@@ -7,8 +7,8 @@ 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
11
  import { catppuccinLatte, catppuccinMacchiato } from "@catppuccin/codemirror";
11
- import { CODE_FONT_FAMILY } from "@coldsmirk/inkstone-core";
12
12
  import { MergeView } from "@codemirror/merge";
13
13
  //#region src/minimal-replace.ts
14
14
  function minimalReplace(state, externalValue) {
@@ -430,21 +430,31 @@ function completionIconRules() {
430
430
  }
431
431
  function chromeTheme(dark) {
432
432
  const { colors } = dark ? flavors.macchiato : flavors.latte;
433
- const hairline = `1px solid ${alphaOf(colors.overlay0, .35)}`;
433
+ const surface = getEditorSurface(dark) ?? {};
434
+ const hairline = `1px solid ${surface.widgetBorder ?? alphaOf(colors.overlay0, .35)}`;
434
435
  const frame = {
435
436
  border: hairline,
436
- borderRadius: "8px",
437
- boxShadow: dark ? "0 8px 24px rgba(0, 0, 0, 0.5)" : "0 8px 24px rgba(0, 0, 0, 0.12)",
438
- color: colors.text.hex
437
+ borderRadius: inkstoneRadius("large", "8px"),
438
+ boxShadow: inkstoneShadow("large", dark ? "0 8px 24px rgba(0, 0, 0, 0.5)" : "0 8px 24px rgba(0, 0, 0, 0.12)"),
439
+ color: colors.text.hex,
440
+ ...surface.widget !== void 0 && { backgroundColor: surface.widget }
441
+ };
442
+ const gutters = {
443
+ ...surface.background !== void 0 && { backgroundColor: surface.background },
444
+ ...surface.lineNumber !== void 0 && { color: surface.lineNumber }
439
445
  };
440
446
  return EditorView.theme({
441
- "&": { colorScheme: dark ? "dark" : "light" },
447
+ "&": {
448
+ colorScheme: dark ? "dark" : "light",
449
+ ...surface.background !== void 0 && { backgroundColor: surface.background }
450
+ },
451
+ ...Object.keys(gutters).length > 0 && { ".cm-gutters": gutters },
442
452
  ".cm-scroller": { fontFamily: CODE_FONT_FAMILY },
443
453
  ".cm-tooltip": frame,
444
454
  ".cm-tooltip.cm-tooltip-autocomplete": {
445
455
  ...frame,
446
456
  "& > ul": {
447
- borderRadius: "7px",
457
+ borderRadius: `calc(${inkstoneRadius("large", "8px")} - 1px)`,
448
458
  padding: "4px",
449
459
  maxHeight: "16em"
450
460
  },
@@ -452,9 +462,10 @@ function chromeTheme(dark) {
452
462
  display: "flex",
453
463
  alignItems: "center",
454
464
  padding: "3px 8px",
455
- borderRadius: "5px",
465
+ borderRadius: inkstoneRadius("medium", "5px"),
456
466
  lineHeight: "1.45"
457
- }
467
+ },
468
+ ...surface.widgetSelection !== void 0 && { "& > ul > li[aria-selected]": { backgroundColor: surface.widgetSelection } }
458
469
  },
459
470
  ".cm-completionLabel": {
460
471
  minWidth: "0",
@@ -517,7 +528,7 @@ function chromeTheme(dark) {
517
528
  margin: "0",
518
529
  padding: "3px 8px",
519
530
  borderLeftWidth: "3px",
520
- borderRadius: "5px",
531
+ borderRadius: inkstoneRadius("medium", "5px"),
521
532
  lineHeight: "1.45"
522
533
  },
523
534
  ".cm-diagnostic-error": { borderLeftColor: colors.red.hex },
@@ -528,7 +539,7 @@ function chromeTheme(dark) {
528
539
  padding: "2px 6px",
529
540
  backgroundColor: colors.surface1.hex,
530
541
  color: colors.text.hex,
531
- borderRadius: "4px"
542
+ borderRadius: inkstoneRadius("small", "4px")
532
543
  },
533
544
  ".cm-diagnosticSource": {
534
545
  fontSize: "85%",
@@ -536,8 +547,8 @@ function chromeTheme(dark) {
536
547
  opacity: "1"
537
548
  },
538
549
  "&.cm-focused": { outline: "none" },
539
- ".cm-activeLine": { backgroundColor: alphaOf(colors.overlay0, .12) },
540
- ".cm-activeLineGutter": { backgroundColor: alphaOf(colors.overlay0, .12) },
550
+ ".cm-activeLine": { backgroundColor: surface.lineHighlight ?? alphaOf(colors.overlay0, .12) },
551
+ ".cm-activeLineGutter": { backgroundColor: surface.lineHighlight ?? alphaOf(colors.overlay0, .12) },
541
552
  "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": { backgroundColor: alphaOf(colors.blue, dark ? .35 : .25) },
542
553
  ".cm-selectionBackground": { backgroundColor: alphaOf(colors.blue, dark ? .2 : .14) },
543
554
  ".cm-content ::selection": { backgroundColor: alphaOf(colors.blue, dark ? .35 : .25) },
@@ -545,6 +556,7 @@ function chromeTheme(dark) {
545
556
  scrollbarWidth: "thin",
546
557
  scrollbarColor: `${alphaOf(colors.overlay0, .55)} transparent`
547
558
  },
559
+ ...surface.widget !== void 0 && { ".cm-panels": { backgroundColor: surface.widget } },
548
560
  ".cm-panels.cm-panels-top": { borderBottom: hairline },
549
561
  ".cm-panels.cm-panels-bottom": { borderTop: hairline },
550
562
  ".cm-panel.cm-search, .cm-panel.cm-gotoLine": {
@@ -595,7 +607,7 @@ function chromeTheme(dark) {
595
607
  color: colors.overlay1.hex,
596
608
  background: "transparent",
597
609
  border: "none",
598
- borderRadius: "6px",
610
+ borderRadius: inkstoneRadius("medium", "6px"),
599
611
  cursor: "pointer"
600
612
  },
601
613
  ".cm-panel.cm-search button[name=close]:hover": {
@@ -611,9 +623,9 @@ function chromeTheme(dark) {
611
623
  padding: "0 10px",
612
624
  fontSize: "12.5px",
613
625
  color: colors.text.hex,
614
- backgroundColor: colors.base.hex,
626
+ backgroundColor: surface.background ?? colors.base.hex,
615
627
  border: hairline,
616
- borderRadius: "6px"
628
+ borderRadius: inkstoneRadius("medium", "6px")
617
629
  },
618
630
  ".cm-panel .cm-textfield:focus": {
619
631
  outline: "none",
@@ -630,7 +642,7 @@ function chromeTheme(dark) {
630
642
  backgroundImage: "none",
631
643
  backgroundColor: colors.surface0.hex,
632
644
  border: hairline,
633
- borderRadius: "6px",
645
+ borderRadius: inkstoneRadius("medium", "6px"),
634
646
  cursor: "pointer"
635
647
  },
636
648
  ".cm-panel .cm-button:hover": { backgroundColor: colors.surface1.hex },
@@ -688,7 +700,7 @@ function installDiffChrome(root) {
688
700
  style.dataset.inkstone = "codemirror-diff";
689
701
  style.textContent = [
690
702
  "[data-inkstone-diff] > .cm-mergeView { height: 100%; }",
691
- "[data-inkstone-diff] .cm-merge-revert button { color: inherit; border-radius: 4px; }",
703
+ `[data-inkstone-diff] .cm-merge-revert button { color: inherit; border-radius: ${inkstoneRadius("small", "4px")}; }`,
692
704
  "[data-inkstone-diff] .cm-merge-revert button:hover { background-color: color-mix(in srgb, currentColor 15%, transparent); }"
693
705
  ].join("\n");
694
706
  if (root.nodeType === 9) root.head.append(style);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coldsmirk/inkstone-codemirror",
3
- "version": "0.18.0",
3
+ "version": "0.19.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.18.0"
65
+ "@coldsmirk/inkstone-core": "^0.19.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@codemirror/autocomplete": "^6.20.3",