@cascivo/editor 0.0.2 → 0.2.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
@@ -16,7 +16,11 @@
16
16
 
17
17
  ---
18
18
 
19
- A lightweight, CSS-native, signal-driven code editor for cascivo. `CodeEditor` overlays a native `<textarea>` on a syntax-highlighted `<pre>`, so the browser owns the caret, selection, IME, undo, and accessibility — JS is limited to a tiny owned tokenizer and scroll-sync. `Highlight` is the read-only renderer for snippets and docs. Zero runtime dependencies, themeable through the cascivo token system.
19
+ A lightweight, CSS-native, signal-driven code editor for cascivo. `CodeEditor` overlays a native `<textarea>` on a syntax-highlighted `<pre>`, so the browser owns the caret, selection, IME, and accessibility — JS adds an owned tokenizer, scroll-sync, and a thin layer of editing affordances. `Highlight` is the read-only renderer for snippets and docs. Zero runtime dependencies, themeable through the cascivo token system.
20
+
21
+ Beyond highlighting it provides the essentials for editing real documents: **owned undo/redo** (`Mod-Z` / `Mod-Shift-Z`) that survives programmatic `value` changes, **selection-preserving, echo-safe controlled sync** (external/remote updates don't jump the caret), **find & replace** (`Mod-F`), a **`Mod-S` save** hook, **per-instance theming** that can switch live, **bracket matching**, an **active-line gutter**, and an imperative **`CodeEditorHandle`**.
22
+
23
+ It is deliberately not a full editor engine: no LSP/IntelliSense, multi-cursor, code folding, minimap, or vim mode — reach for a full framework (Monaco/CodeMirror) if you need those.
20
24
 
21
25
  ## Install
22
26
 
@@ -54,6 +58,47 @@ import { Highlight } from '@cascivo/editor'
54
58
  Ships small, tree-shakeable grammars: `plaintext`, `json`, `javascript`, `typescript`, `css`,
55
59
  `html`, `markdown`, `bash`. Register your own with `registerGrammar(grammar)`.
56
60
 
61
+ ### Large documents
62
+
63
+ The editor edits long Markdown documents — generated docs, concatenated books, big notes —
64
+ well past the old ~5,000-line ceiling. On every render it tokenizes only the **visible window**
65
+ (O(viewport)) rather than the whole document, and an edit re-tokenizes only the **changed
66
+ suffix** until the grammar state reconverges. This is the same overlay + owned-tokenizer model,
67
+ with **zero new dependencies** and **byte-identical highlighting output** — just a persistent
68
+ per-line state index (`LineStateIndex`) feeding a viewport-scoped `tokenizeRange`. Scrolling and
69
+ typing stay smooth well past 50,000 lines.
70
+
71
+ One trade-off: with `wrap` (soft-wrap) on, row heights are variable so DOM windowing is disabled
72
+ and every row renders (O(n) render). Edits stay cheap, but for sustained editing of very large
73
+ documents (≳10,000 lines) disable `wrap`. See [`PERFORMANCE.md`](./PERFORMANCE.md) for the
74
+ measured before/after numbers and the deferred worker-offload boundary.
75
+
76
+ ### Extending the editor
77
+
78
+ Three bounded seams — no plugin lifecycle, no transaction filters (use a full editor
79
+ framework if you need those):
80
+
81
+ - **Key bindings** — pass a `keymap` of `chord → command`. Chords use `Mod` for
82
+ Cmd/Ctrl (e.g. `'Mod-s'`, `'Mod-Shift-z'`, `'Shift-Tab'`); a command returns `true`
83
+ when it handled the event. User bindings merge over (and override) the built-ins.
84
+ - **Decorations** — pass `decorations` (an array, or `(value) => Decoration[]`) to tag
85
+ `{ line, start, end, className }` column ranges; they render as extra classes in the
86
+ highlight layer (the same seam find and bracket-matching use).
87
+ - **Grammars** — register a language with `registerGrammar(grammar)`.
88
+
89
+ ```tsx
90
+ <CodeEditor
91
+ language="markdown"
92
+ onSave={(value) => save(value)} // Mod-S
93
+ keymap={{
94
+ 'Mod-/': ({ textarea, setText }) => {
95
+ /* toggle comment */ return true
96
+ },
97
+ }}
98
+ decorations={(value) => findTodos(value)}
99
+ />
100
+ ```
101
+
57
102
  ### React apps must subscribe to signals
58
103
 
59
104
  `CodeEditor` and `Highlight` are signal-driven. In a plain React app (no Babel signals transform),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cascivo/editor",
3
- "version": "0.0.2",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "description": "Lightweight CSS-native code editor — native textarea overlay + owned zero-dependency tokenizer",
6
6
  "keywords": [
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@cascivo/core": "^0.1.3",
47
- "@cascivo/i18n": "^0.1.5"
47
+ "@cascivo/i18n": "^0.1.6"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@testing-library/jest-dom": "^6.9.1",
package/readme.body.md CHANGED
@@ -1,4 +1,8 @@
1
- A lightweight, CSS-native, signal-driven code editor for cascivo. `CodeEditor` overlays a native `<textarea>` on a syntax-highlighted `<pre>`, so the browser owns the caret, selection, IME, undo, and accessibility — JS is limited to a tiny owned tokenizer and scroll-sync. `Highlight` is the read-only renderer for snippets and docs. Zero runtime dependencies, themeable through the cascivo token system.
1
+ A lightweight, CSS-native, signal-driven code editor for cascivo. `CodeEditor` overlays a native `<textarea>` on a syntax-highlighted `<pre>`, so the browser owns the caret, selection, IME, and accessibility — JS adds an owned tokenizer, scroll-sync, and a thin layer of editing affordances. `Highlight` is the read-only renderer for snippets and docs. Zero runtime dependencies, themeable through the cascivo token system.
2
+
3
+ Beyond highlighting it provides the essentials for editing real documents: **owned undo/redo** (`Mod-Z` / `Mod-Shift-Z`) that survives programmatic `value` changes, **selection-preserving, echo-safe controlled sync** (external/remote updates don't jump the caret), **find & replace** (`Mod-F`), a **`Mod-S` save** hook, **per-instance theming** that can switch live, **bracket matching**, an **active-line gutter**, and an imperative **`CodeEditorHandle`**.
4
+
5
+ It is deliberately not a full editor engine: no LSP/IntelliSense, multi-cursor, code folding, minimap, or vim mode — reach for a full framework (Monaco/CodeMirror) if you need those.
2
6
 
3
7
  ## Install
4
8
 
@@ -36,6 +40,47 @@ import { Highlight } from '@cascivo/editor'
36
40
  Ships small, tree-shakeable grammars: `plaintext`, `json`, `javascript`, `typescript`, `css`,
37
41
  `html`, `markdown`, `bash`. Register your own with `registerGrammar(grammar)`.
38
42
 
43
+ ### Large documents
44
+
45
+ The editor edits long Markdown documents — generated docs, concatenated books, big notes —
46
+ well past the old ~5,000-line ceiling. On every render it tokenizes only the **visible window**
47
+ (O(viewport)) rather than the whole document, and an edit re-tokenizes only the **changed
48
+ suffix** until the grammar state reconverges. This is the same overlay + owned-tokenizer model,
49
+ with **zero new dependencies** and **byte-identical highlighting output** — just a persistent
50
+ per-line state index (`LineStateIndex`) feeding a viewport-scoped `tokenizeRange`. Scrolling and
51
+ typing stay smooth well past 50,000 lines.
52
+
53
+ One trade-off: with `wrap` (soft-wrap) on, row heights are variable so DOM windowing is disabled
54
+ and every row renders (O(n) render). Edits stay cheap, but for sustained editing of very large
55
+ documents (≳10,000 lines) disable `wrap`. See [`PERFORMANCE.md`](./PERFORMANCE.md) for the
56
+ measured before/after numbers and the deferred worker-offload boundary.
57
+
58
+ ### Extending the editor
59
+
60
+ Three bounded seams — no plugin lifecycle, no transaction filters (use a full editor
61
+ framework if you need those):
62
+
63
+ - **Key bindings** — pass a `keymap` of `chord → command`. Chords use `Mod` for
64
+ Cmd/Ctrl (e.g. `'Mod-s'`, `'Mod-Shift-z'`, `'Shift-Tab'`); a command returns `true`
65
+ when it handled the event. User bindings merge over (and override) the built-ins.
66
+ - **Decorations** — pass `decorations` (an array, or `(value) => Decoration[]`) to tag
67
+ `{ line, start, end, className }` column ranges; they render as extra classes in the
68
+ highlight layer (the same seam find and bracket-matching use).
69
+ - **Grammars** — register a language with `registerGrammar(grammar)`.
70
+
71
+ ```tsx
72
+ <CodeEditor
73
+ language="markdown"
74
+ onSave={(value) => save(value)} // Mod-S
75
+ keymap={{
76
+ 'Mod-/': ({ textarea, setText }) => {
77
+ /* toggle comment */ return true
78
+ },
79
+ }}
80
+ decorations={(value) => findTodos(value)}
81
+ />
82
+ ```
83
+
39
84
  ### React apps must subscribe to signals
40
85
 
41
86
  `CodeEditor` and `Highlight` are signal-driven. In a plain React app (no Babel signals transform),