@octane-xplat/lexical 0.0.1 → 0.11.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Alec Larson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,4 +1,172 @@
1
- # @octane-xplat/lexical
1
+ # `@octane-xplat/lexical`
2
2
 
3
- This is a placeholder stub published to reserve the package name ahead of the
4
- first automated release. It has no supported API.
3
+ The unified rich-text facade, lexical flavor: one `LexicalEditor` component
4
+ across web and native. Web renders a fixed-plugin `LexicalComposer` through
5
+ `@octanejs/lexical`; Android renders the `@octane-xplat/richtext` leaf
6
+ (WordPress Aztec on Android, iOS stub) and layers lexical serialized editor
7
+ state on top through the DOM-free slices (`lexical`, `@lexical/html`, the
8
+ Aztec-shaped node packages) with a `zeed-dom` parse shim. DOM-bound lexical code stays out of Android execution — divergence lives at the
9
+ file-suffix boundary.
10
+
11
+ ```tsx
12
+ import { useState } from 'octane'
13
+ import { LexicalEditor, supported } from '@octane-xplat/lexical'
14
+ import { Text } from '@octane-xplat/ui'
15
+
16
+ export function Notes() {
17
+ const [html, setHtml] = useState('<p>Trip notes</p>')
18
+ return supported ? (
19
+ <LexicalEditor value={html} onChange={setHtml} />
20
+ ) : (
21
+ <Text>Editing is unavailable on this target</Text>
22
+ )
23
+ }
24
+ ```
25
+
26
+ `value`/`onChange` exchange document HTML. `getJSON`/`setJSON` exchange
27
+ lexical serialized editor state (`EditorState.toJSON()`): synchronous on
28
+ web, bridged on Android after `onJSONReady(true)` — the lazy bridge reports
29
+ `false` (and `getJSON()` returns `null`) on runtimes that cannot host the
30
+ document-model modules. On Android, HTML is the canonical interchange
31
+ format; serialized state is a best-effort mapping.
32
+
33
+ ```tsx
34
+ import { useRef, useState } from 'octane'
35
+ import { LexicalEditor, type LexicalEditorHandle } from '@octane-xplat/lexical'
36
+ import { Button } from '@octane-xplat/ui'
37
+
38
+ export function DocumentCopy() {
39
+ const editor = useRef<LexicalEditorHandle | null>(null)
40
+ const [html, setHtml] = useState('<p>Trip notes</p>')
41
+ const [jsonReady, setJsonReady] = useState(false)
42
+ return (
43
+ <>
44
+ <LexicalEditor
45
+ value={html}
46
+ onChange={setHtml}
47
+ ref={(handle) => {
48
+ editor.current = handle
49
+ }}
50
+ onReady={() => setJsonReady(editor.current?.getJSON() != null)}
51
+ onJSONReady={setJsonReady}
52
+ />
53
+ <Button
54
+ isDisabled={!jsonReady}
55
+ onPress={() => {
56
+ const document = editor.current?.getJSON()
57
+ if (document) editor.current?.setJSON(document)
58
+ }}
59
+ >
60
+ Round-trip document
61
+ </Button>
62
+ </>
63
+ )
64
+ }
65
+ ```
66
+
67
+ On web, `web.nodes` adds custom Lexical node classes to the facade's built-in
68
+ nodes, and `web.plugins` renders additional Octane plugin components inside
69
+ the Lexical composer. Set `replaceNodes` to `true` when `web.nodes` should be
70
+ the full custom node registry. Set `replacePlugins` to `true` to replace the
71
+ default history, list, link, and autofocus plugins with your own composition;
72
+ the rich-text surface and facade change/ref bindings remain installed. This
73
+ lets a custom node keep its Lexical JSON type and HTML representation during
74
+ a round-trip.
75
+
76
+ ```tsx
77
+ import { LexicalEditor } from '@octane-xplat/lexical'
78
+ import { BadgeNode, BadgePlugin } from './lexical-extensions'
79
+
80
+ export function NoteEditor() {
81
+ return (
82
+ <LexicalEditor
83
+ value='<p><span data-badge>Voyager</span></p>'
84
+ web={{ nodes: [BadgeNode], plugins: <BadgePlugin /> }}
85
+ />
86
+ )
87
+ }
88
+ ```
89
+
90
+ The `web` options are ignored on native. Native still edits with Aztec on
91
+ Android and uses the fixed headless conversion node set for JSON. Caller
92
+ plugins, custom nodes, browser views, and arbitrary JavaScript transforms do
93
+ not run there. Apps replacing the web defaults can set both replacement
94
+ options and register the node classes Lexical requires for their documents.
95
+
96
+ ```tsx
97
+ import { LexicalEditor } from '@octane-xplat/lexical'
98
+ import { BadgeNode, BadgePlugin } from './lexical-extensions'
99
+
100
+ export function NoteEditor() {
101
+ return (
102
+ <LexicalEditor
103
+ web={{ replaceNodes: true, nodes: [BadgeNode], replacePlugins: true, plugins: <BadgePlugin /> }}
104
+ />
105
+ )
106
+ }
107
+ ```
108
+
109
+ ## Engine and feature boundary
110
+
111
+ | Target | Editing engine | `web` options | Caller plugins, custom nodes, and browser views |
112
+ | --- | --- | --- | --- |
113
+ | Web | Lexical `LexicalComposer` with the facade's default nodes and plugins | `nodes`, `plugins`, and replacement flags apply | Supported by the web Lexical engine |
114
+ | Android | WordPress Aztec `AztecText`; a headless Lexical editor converts serialized state to and from HTML | Ignored | Unsupported; no live Lexical editor, plugin, transform, custom node, or browser view runs |
115
+ | iOS | Unsupported placeholder from `@octane-xplat/richtext` | Ignored | Unsupported; `supported` is `false` |
116
+ | macOS AppKit | Bundled Lexical editor in WKWebView | Ignored by the AppKit host | Unsupported through this facade |
117
+
118
+ On Android, save HTML as the canonical document. Lexical serialized state is
119
+ a best-effort conversion through the fixed built-in node set; it is not a live
120
+ Lexical editor state that supports commands or plugins.
121
+ The 2026-10-06 [Aztec nested-tree run](../../docs/verify/nested-tree-editor.md)
122
+ preserved nested wrappers, attributes, and child order through synthetic text
123
+ edits and save/reopen, but flattened paragraphs and accumulated `<br>` elements
124
+ on reopen. That run exercised the shared Aztec HTML leaf, not Lexical's JSON
125
+ conversion or structural commands. See the
126
+ [per-row capability record](../../docs/notes/editor-capabilities.md).
127
+
128
+ ```tsx
129
+ import { useState } from 'octane'
130
+ import { LexicalEditor, supported } from '@octane-xplat/lexical'
131
+ import { Text } from '@octane-xplat/ui'
132
+
133
+ export function Notes() {
134
+ const [html, setHTML] = useState('<p>Travel notes</p>')
135
+ return supported ? (
136
+ <LexicalEditor value={html} editable onChange={setHTML} />
137
+ ) : (
138
+ <Text>Editing is unavailable on this target</Text>
139
+ )
140
+ }
141
+ ```
142
+
143
+ Focus callbacks report focus entering or leaving the editable surface.
144
+ `onJSONReady(true)` fires once the web editor handle exists, so `getJSON()` is
145
+ available from `onReady` and after readiness. On native, `onJSONReady` still
146
+ reports when the lazy conversion bridge settles.
147
+
148
+ ```tsx
149
+ <LexicalEditor
150
+ onJSONReady={(ready) => console.log('JSON ready:', ready)}
151
+ onFocus={() => console.log('Editor focused')}
152
+ onBlur={() => console.log('Editor blurred')}
153
+ />
154
+ ```
155
+
156
+ There is no live `LexicalEditor` on Android: no `dispatchCommand`, no node
157
+ transforms; `native` returns the `AztecText` and the headless editor used for
158
+ conversions is an internal detail.
159
+
160
+ The lexical family pins to `0.51.0` and `@octanejs/lexical` to `0.2.0`
161
+ (peers `octane ^0.6.0`). `@lexical/link` carries a workspace patch for its
162
+ ICU-dependent URL-matcher literal. See
163
+ [`docs/app/rich-text.md`](../../docs/app/rich-text.md) for the shared contract,
164
+ format vocabulary, and known limits.
165
+
166
+ ## macOS AppKit
167
+
168
+ The macOS export mounts a bundled local editor document in WKWebView.
169
+ RichText uses StarterKit; Tiptap and Lexical use their existing web facades.
170
+ Wait for `onReady`; synchronous getters return the latest received snapshot
171
+ and commands cross WebKit asynchronously. The `native` handle is the Swift
172
+ host transport. See [AppKit setup and engine limits](../../docs/app/rich-text.md#macos-appkit-editing).
@@ -0,0 +1 @@
1
+ declare const html: string; export default html