@cascivo/editor 0.0.2 → 0.1.1

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,32 @@ 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
+ ### Extending the editor
62
+
63
+ Three bounded seams — no plugin lifecycle, no transaction filters (use a full editor
64
+ framework if you need those):
65
+
66
+ - **Key bindings** — pass a `keymap` of `chord → command`. Chords use `Mod` for
67
+ Cmd/Ctrl (e.g. `'Mod-s'`, `'Mod-Shift-z'`, `'Shift-Tab'`); a command returns `true`
68
+ when it handled the event. User bindings merge over (and override) the built-ins.
69
+ - **Decorations** — pass `decorations` (an array, or `(value) => Decoration[]`) to tag
70
+ `{ line, start, end, className }` column ranges; they render as extra classes in the
71
+ highlight layer (the same seam find and bracket-matching use).
72
+ - **Grammars** — register a language with `registerGrammar(grammar)`.
73
+
74
+ ```tsx
75
+ <CodeEditor
76
+ language="markdown"
77
+ onSave={(value) => save(value)} // Mod-S
78
+ keymap={{
79
+ 'Mod-/': ({ textarea, setText }) => {
80
+ /* toggle comment */ return true
81
+ },
82
+ }}
83
+ decorations={(value) => findTodos(value)}
84
+ />
85
+ ```
86
+
57
87
  ### React apps must subscribe to signals
58
88
 
59
89
  `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.1.1",
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,32 @@ 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
+ ### Extending the editor
44
+
45
+ Three bounded seams — no plugin lifecycle, no transaction filters (use a full editor
46
+ framework if you need those):
47
+
48
+ - **Key bindings** — pass a `keymap` of `chord → command`. Chords use `Mod` for
49
+ Cmd/Ctrl (e.g. `'Mod-s'`, `'Mod-Shift-z'`, `'Shift-Tab'`); a command returns `true`
50
+ when it handled the event. User bindings merge over (and override) the built-ins.
51
+ - **Decorations** — pass `decorations` (an array, or `(value) => Decoration[]`) to tag
52
+ `{ line, start, end, className }` column ranges; they render as extra classes in the
53
+ highlight layer (the same seam find and bracket-matching use).
54
+ - **Grammars** — register a language with `registerGrammar(grammar)`.
55
+
56
+ ```tsx
57
+ <CodeEditor
58
+ language="markdown"
59
+ onSave={(value) => save(value)} // Mod-S
60
+ keymap={{
61
+ 'Mod-/': ({ textarea, setText }) => {
62
+ /* toggle comment */ return true
63
+ },
64
+ }}
65
+ decorations={(value) => findTodos(value)}
66
+ />
67
+ ```
68
+
39
69
  ### React apps must subscribe to signals
40
70
 
41
71
  `CodeEditor` and `Highlight` are signal-driven. In a plain React app (no Babel signals transform),