@nonoun/native-codemirror 0.2.0 → 0.2.2

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.
@@ -18,7 +18,6 @@ import type { Extension } from '@codemirror/state';
18
18
  * - Active line + gutter highlighting
19
19
  * - Selection drawing and special character highlighting
20
20
  * - Indent on input
21
- * - Line wrapping
22
21
  */
23
- export declare const nuiBaseExtensions: Extension;
22
+ export declare const NBaseExtensions: Extension;
24
23
  //# sourceMappingURL=base-extensions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-extensions.d.ts","sourceRoot":"","sources":["../src/base-extensions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAwBnD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAmC/B,CAAC"}
1
+ {"version":3,"file":"base-extensions.d.ts","sourceRoot":"","sources":["../src/base-extensions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAuBnD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,EAAE,SAgC7B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,WAAW,EACtB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,UAAU,CAuBZ"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,WAAW,EACtB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,UAAU,CA4BZ"}
package/dist/index.d.ts CHANGED
@@ -7,8 +7,8 @@
7
7
  * factory function. Also re-exports key CodeMirror APIs so consumer
8
8
  * packages can import through this single dependency.
9
9
  */
10
- export { nuiTheme, nuiHighlightStyle, nuiSyntaxHighlighting } from './theme.ts';
11
- export { nuiBaseExtensions } from './base-extensions.ts';
10
+ export { NTheme, NHighlightStyle, NSyntaxHighlighting } from './theme.ts';
11
+ export { NBaseExtensions } from './base-extensions.ts';
12
12
  export { createEditorView } from './factory.ts';
13
13
  export type { CreateEditorOptions } from './factory.ts';
14
14
  export { EditorView, keymap, Decoration, ViewPlugin, WidgetType, lineNumbers, highlightActiveLine, highlightActiveLineGutter, drawSelection, } from '@codemirror/view';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,qBAAqB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M,EACN,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,yBAAyB,EACzB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAMlE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACtF,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhE,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,GACd,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAMzF,OAAO,EACL,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * nui-codemirror.css
2
+ * n-codemirror.css
3
3
  *
4
4
  * CodeMirror chrome styles for NativeUI integration.
5
5
  * Scoped to @layer ui with zero-specificity :where() selectors.
@@ -15,21 +15,36 @@
15
15
  * --------------------------------------------------------------------- */
16
16
 
17
17
  :where(.cm-editor) {
18
- border-radius: var(--n-radius, 8px);
18
+ /* CodeMirror chrome tokens */
19
+ --n-cm-scrollbar: #484c52;
20
+ --n-cm-scrollbar-hover: #5e6167;
21
+ --n-cm-match-bg: #314050;
22
+
23
+ /*border-radius: var(--n-radius, 8px);*/
19
24
  overflow: hidden;
20
25
  font-variant-ligatures: contextual;
21
26
  line-height: 1.6;
22
27
  }
23
28
 
29
+ :where(.cm-content):focus-visible,
24
30
  :where(.cm-editor.cm-focused) {
25
31
  outline: none;
26
32
  }
27
33
 
28
34
  /* -----------------------------------------------------------------------
29
- * Scroller
35
+ * Scroller — structural fallbacks
36
+ *
37
+ * WHY: CodeMirror's base theme injects display: flex !important on
38
+ * .cm-scroller via a JS <style> tag (unlayered). In @layer ui,
39
+ * !important declarations beat unlayered !important (reverse layer
40
+ * order), so these serve as authoritative structural rules that
41
+ * ensure the horizontal gutter+content layout works even if the
42
+ * base theme's <style> tag fails to inject or gets removed by HMR.
30
43
  * --------------------------------------------------------------------- */
31
44
 
32
45
  :where(.cm-scroller) {
46
+ display: flex !important;
47
+ align-items: flex-start !important;
33
48
  overflow: auto;
34
49
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code',
35
50
  ui-monospace, SFMono-Regular, Menlo, monospace;
@@ -54,7 +69,7 @@
54
69
 
55
70
  :where(.cm-scroller) {
56
71
  scrollbar-width: thin;
57
- scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
72
+ scrollbar-color: var(--n-cm-scrollbar) transparent;
58
73
  }
59
74
 
60
75
  :where(.cm-scroller)::-webkit-scrollbar {
@@ -67,12 +82,12 @@
67
82
  }
68
83
 
69
84
  :where(.cm-scroller)::-webkit-scrollbar-thumb {
70
- background: rgba(255, 255, 255, 0.15);
85
+ background: var(--n-cm-scrollbar);
71
86
  border-radius: 4px;
72
87
  }
73
88
 
74
89
  :where(.cm-scroller)::-webkit-scrollbar-thumb:hover {
75
- background: rgba(255, 255, 255, 0.25);
90
+ background: var(--n-cm-scrollbar-hover);
76
91
  }
77
92
 
78
93
  :where(.cm-scroller)::-webkit-scrollbar-corner {
@@ -135,6 +150,17 @@
135
150
 
136
151
  :where(.cm-content) {
137
152
  padding: 8px 0;
153
+ /* WHY: UA stylesheets may set color on [contenteditable] based on the
154
+ inherited color-scheme (e.g. CanvasText → black in light mode).
155
+ Explicit `color: inherit` as an author rule overrides the UA color,
156
+ preserving the theme's color set on .cm-editor. */
157
+ color: inherit;
158
+ /* Structural fallback — matches CM base theme */
159
+ flex-grow: 2;
160
+ flex-shrink: 0;
161
+ white-space: pre;
162
+ word-wrap: normal;
163
+ min-height: 100%;
138
164
  }
139
165
 
140
166
  :where(.cm-line) {
@@ -146,7 +172,7 @@
146
172
  * --------------------------------------------------------------------- */
147
173
 
148
174
  :where(.cm-selectionMatch) {
149
- background-color: rgba(97, 175, 239, 0.15);
175
+ background-color: var(--n-cm-match-bg);
150
176
  border-radius: 2px;
151
177
  }
152
178
  }
@@ -1,5 +1,5 @@
1
- import { Decoration as e, EditorView as t, EditorView as n, ViewPlugin as r, WidgetType as i, drawSelection as a, drawSelection as o, highlightActiveLine as s, highlightActiveLine as ee, highlightActiveLineGutter as te, highlightActiveLineGutter as c, highlightSpecialChars as ne, keymap as re, keymap as ie, lineNumbers as ae, lineNumbers as oe } from "@codemirror/view";
2
- import { HighlightStyle as l, HighlightStyle as u, bracketMatching as d, bracketMatching as f, foldGutter as p, foldGutter as m, foldKeymap as se, indentOnInput as ce, indentOnInput as le, syntaxHighlighting as ue, syntaxHighlighting as de, syntaxTree as fe } from "@codemirror/language";
1
+ import { Decoration as e, EditorView as t, EditorView as n, ViewPlugin as r, WidgetType as i, drawSelection as a, drawSelection as o, highlightActiveLine as s, highlightActiveLine as c, highlightActiveLineGutter as ee, highlightActiveLineGutter as te, highlightSpecialChars as ne, keymap as l, keymap as re, lineNumbers as ie, lineNumbers as ae } from "@codemirror/view";
2
+ import { HighlightStyle as oe, HighlightStyle as u, bracketMatching as d, bracketMatching as f, foldGutter as p, foldGutter as m, foldKeymap as se, indentOnInput as ce, indentOnInput as le, syntaxHighlighting as ue, syntaxHighlighting as de, syntaxTree as fe } from "@codemirror/language";
3
3
  import { tags as h, tags as g } from "@lezer/highlight";
4
4
  import { defaultKeymap as _, defaultKeymap as v, history as y, history as b, historyKeymap as x, historyKeymap as S, redo as C, undo as w } from "@codemirror/commands";
5
5
  import { autocompletion as T, autocompletion as E, closeBrackets as D, closeBrackets as O, closeBracketsKeymap as k, closeBracketsKeymap as A, completionKeymap as j, completionKeymap as M } from "@codemirror/autocomplete";
@@ -360,12 +360,11 @@ const X = n.theme({
360
360
  f(),
361
361
  O(),
362
362
  E(),
363
- oe(),
363
+ ae(),
364
364
  m(),
365
- ee(),
366
365
  c(),
367
- n.lineWrapping,
368
- ie.of([
366
+ te(),
367
+ re.of([
369
368
  ...A,
370
369
  ...v,
371
370
  ...S,
@@ -392,7 +391,7 @@ const X = n.theme({
392
391
  *
393
392
  * @example
394
393
  * ```ts
395
- * import { createEditorView } from '@nonoun/nui-codemirror';
394
+ * import { createEditorView } from '@nonoun/native-codemirror';
396
395
  *
397
396
  * const view = createEditorView(document.getElementById('editor')!, {
398
397
  * doc: 'console.log("hello");',
@@ -412,7 +411,8 @@ function me(e, t) {
412
411
  doc: r,
413
412
  extensions: o
414
413
  }),
415
- parent: e
414
+ parent: e,
415
+ root: e.ownerDocument
416
416
  });
417
417
  }
418
- export { N as Compartment, e as Decoration, pe as EditorState, t as EditorView, l as HighlightStyle, F as StateEffect, I as StateField, r as ViewPlugin, i as WidgetType, T as autocompletion, d as bracketMatching, D as closeBrackets, k as closeBracketsKeymap, j as completionKeymap, me as createEditorView, _ as defaultKeymap, a as drawSelection, p as foldGutter, s as highlightActiveLine, te as highlightActiveLineGutter, y as history, x as historyKeymap, ce as indentOnInput, re as keymap, ae as lineNumbers, $ as nuiBaseExtensions, Z as nuiHighlightStyle, Q as nuiSyntaxHighlighting, X as nuiTheme, C as redo, ue as syntaxHighlighting, fe as syntaxTree, h as tags, w as undo };
418
+ export { N as Compartment, e as Decoration, pe as EditorState, t as EditorView, oe as HighlightStyle, $ as NBaseExtensions, Z as NHighlightStyle, Q as NSyntaxHighlighting, X as NTheme, F as StateEffect, I as StateField, r as ViewPlugin, i as WidgetType, T as autocompletion, d as bracketMatching, D as closeBrackets, k as closeBracketsKeymap, j as completionKeymap, me as createEditorView, _ as defaultKeymap, a as drawSelection, p as foldGutter, s as highlightActiveLine, ee as highlightActiveLineGutter, y as history, x as historyKeymap, ce as indentOnInput, l as keymap, ie as lineNumbers, C as redo, ue as syntaxHighlighting, fe as syntaxTree, h as tags, w as undo };
package/dist/theme.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * with { dark: true } and HighlightStyle.define() for syntax tokens.
7
7
  */
8
8
  import { HighlightStyle } from '@codemirror/language';
9
- export declare const nuiTheme: import("@codemirror/state").Extension;
10
- export declare const nuiHighlightStyle: HighlightStyle;
11
- export declare const nuiSyntaxHighlighting: import("@codemirror/state").Extension;
9
+ export declare const NTheme: import("@codemirror/state").Extension;
10
+ export declare const NHighlightStyle: HighlightStyle;
11
+ export declare const NSyntaxHighlighting: import("@codemirror/state").Extension;
12
12
  //# sourceMappingURL=theme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,cAAc,EAAsB,MAAM,sBAAsB,CAAC;AA0B1E,eAAO,MAAM,QAAQ,uCAqKpB,CAAC;AAMF,eAAO,MAAM,iBAAiB,gBAoF5B,CAAC;AAEH,eAAO,MAAM,qBAAqB,uCAAwC,CAAC"}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,cAAc,EAAsB,MAAM,sBAAsB,CAAC;AA0B1E,eAAO,MAAM,MAAM,uCAqKlB,CAAC;AAMF,eAAO,MAAM,eAAe,gBAoF1B,CAAC;AAEH,eAAO,MAAM,mBAAmB,uCAAsC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nonoun/native-codemirror",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Shared CodeMirror 6 integration layer for @nonoun/native-ui ecosystem",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -31,7 +31,7 @@
31
31
  "scripts": {
32
32
  "build": "npm run build:js && npm run build:css && npm run build:types",
33
33
  "build:js": "vite build",
34
- "build:css": "cp src/css/native-codemirror.css dist/native-codemirror.css",
34
+ "build:css": "cp src/css/codemirror.css dist/native-codemirror.css",
35
35
  "build:types": "tsc -p tsconfig.build.json"
36
36
  },
37
37
  "publishConfig": {