@octane-xplat/richtext 0.9.0 → 0.10.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 +97 -4
- package/dist/macos/browser.d.ts +1 -0
- package/dist/macos/browser.js +2 -0
- package/dist/native/RichTextEditor.android.js +9 -8
- package/dist/native/octane-client-build.json +1 -1
- package/dist/web/octane-client-build.json +1 -1
- package/package.json +25 -4
- package/platforms/macos/include/XplatEditorHost.h +1 -0
- package/platforms/macos/src/XplatEditorHost.swift +63 -0
- package/src/BrowserEditor.web.ts +107 -0
- package/src/Editor.macos.tsx +9 -0
- package/src/NativeEditor.macos.tsx +81 -0
- package/src/RichTextEditor.android.tsrx +3 -2
- package/src/RichTextEditor.windows.tsrx +15 -0
- package/src/browser-transport.web.ts +119 -0
- package/src/host-session.macos.ts +133 -0
- package/src/index.macos.ts +3 -9
- package/src/types.ts +8 -5
- package/types/browser-transport.d.ts +2 -0
- package/types/index.macos.d.ts +5 -0
- package/types/macos-host.d.ts +11 -0
- package/types/types.d.ts +7 -5
package/README.md
CHANGED
|
@@ -2,21 +2,114 @@
|
|
|
2
2
|
|
|
3
3
|
The native rich-text editing leaf: WordPress Aztec's `AztecText` on Android —
|
|
4
4
|
a `Spannable`-backed `EditText`, not a WebView. iOS mounts an unsupported
|
|
5
|
-
placeholder until the Aztec-iOS Swift facade lands; web
|
|
5
|
+
placeholder until the Aztec-iOS Swift facade lands; web and Windows
|
|
6
6
|
return `supported: false` (the `@octane-xplat/tiptap` facade covers web).
|
|
7
7
|
|
|
8
|
-
```
|
|
8
|
+
```tsx
|
|
9
|
+
import { useState } from 'octane'
|
|
9
10
|
import { RichTextEditor, supported } from '@octane-xplat/richtext'
|
|
11
|
+
import { Text } from '@octane-xplat/ui'
|
|
12
|
+
|
|
13
|
+
export function Notes() {
|
|
14
|
+
const [html, setHtml] = useState('<p>Trip notes</p>')
|
|
15
|
+
return supported ? (
|
|
16
|
+
<RichTextEditor value={html} onChange={setHtml} />
|
|
17
|
+
) : (
|
|
18
|
+
<Text>Editing is unavailable on this target</Text>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
10
21
|
```
|
|
11
22
|
|
|
12
23
|
Content in/out is document HTML via Aztec `fromHtml`/`toPlainHtml`. The
|
|
13
|
-
`
|
|
24
|
+
`ref` callback returns an imperative handle (`getHTML`/`setHTML`,
|
|
14
25
|
`apply(format)`, `linkTo`/`removeLink`, `isActive`, `undo`/`redo`,
|
|
15
26
|
`focus`/`blur`, `native`) once the editor exists, and `onSelectionChange`
|
|
16
27
|
reports the active `RichTextFormat` set at the caret.
|
|
17
28
|
|
|
29
|
+
```tsx
|
|
30
|
+
import { useRef } from 'octane'
|
|
31
|
+
import { RichTextEditor, type RichTextEditorHandle } from '@octane-xplat/richtext'
|
|
32
|
+
import { Button } from '@octane-xplat/ui'
|
|
33
|
+
|
|
34
|
+
export function Formatting() {
|
|
35
|
+
const editor = useRef<RichTextEditorHandle | null>(null)
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<RichTextEditor
|
|
39
|
+
ref={(handle) => {
|
|
40
|
+
editor.current = handle
|
|
41
|
+
}}
|
|
42
|
+
onSelectionChange={({ active }) => console.log(active)}
|
|
43
|
+
/>
|
|
44
|
+
<Button onPress={() => editor.current?.apply('bold')}>Bold</Button>
|
|
45
|
+
<Button
|
|
46
|
+
onPress={() => {
|
|
47
|
+
const handle = editor.current
|
|
48
|
+
if (!handle) return
|
|
49
|
+
handle.setHTML('<p>New note</p>')
|
|
50
|
+
console.log(handle.getHTML(), handle.isActive('bold'))
|
|
51
|
+
handle.linkTo('https://example.com')
|
|
52
|
+
handle.removeLink()
|
|
53
|
+
handle.undo()
|
|
54
|
+
handle.redo()
|
|
55
|
+
handle.focus()
|
|
56
|
+
handle.blur()
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
Try editor commands
|
|
60
|
+
</Button>
|
|
61
|
+
</>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { useRef } from 'octane'
|
|
68
|
+
import { RichTextEditor, type RichTextEditorHandle } from '@octane-xplat/richtext'
|
|
69
|
+
import { Button } from '@octane-xplat/ui'
|
|
70
|
+
|
|
71
|
+
export function Formatting() {
|
|
72
|
+
const editor = useRef<RichTextEditorHandle | null>(null)
|
|
73
|
+
return (
|
|
74
|
+
<>
|
|
75
|
+
<RichTextEditor
|
|
76
|
+
ref={(handle) => {
|
|
77
|
+
editor.current = handle
|
|
78
|
+
}}
|
|
79
|
+
onSelectionChange={({ active }) => console.log(active)}
|
|
80
|
+
/>
|
|
81
|
+
<Button onPress={() => editor.current?.apply('bold')}>Bold</Button>
|
|
82
|
+
<Button
|
|
83
|
+
onPress={() => {
|
|
84
|
+
const handle = editor.current
|
|
85
|
+
if (!handle) return
|
|
86
|
+
handle.setHTML('<p>New note</p>')
|
|
87
|
+
console.log(handle.getHTML(), handle.isActive('bold'))
|
|
88
|
+
handle.linkTo('https://example.com')
|
|
89
|
+
handle.removeLink()
|
|
90
|
+
handle.undo()
|
|
91
|
+
handle.redo()
|
|
92
|
+
handle.focus()
|
|
93
|
+
handle.blur()
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
Try editor commands
|
|
97
|
+
</Button>
|
|
98
|
+
</>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
18
103
|
The Android Aztec dependency (`org.wordpress:aztec:v2.1.7`) arrives through
|
|
19
104
|
the leaf's `platforms/android/include.gradle` — no app-level gradle work.
|
|
20
105
|
See the framework guide for the full contract and the demo:
|
|
21
|
-
[`docs/rich-text.md`](../../docs/rich-text.md) and
|
|
106
|
+
[`docs/app/rich-text.md`](../../docs/app/rich-text.md) and
|
|
22
107
|
[`packages/demos/src/RichTextEditorDemo.tsrx`](../demos/src/RichTextEditorDemo.tsrx).
|
|
108
|
+
|
|
109
|
+
## macOS AppKit
|
|
110
|
+
|
|
111
|
+
The macOS export mounts a bundled local editor document in WKWebView.
|
|
112
|
+
RichText uses StarterKit; Tiptap and Lexical use their existing web facades.
|
|
113
|
+
Wait for `onReady`; synchronous getters return the latest received snapshot
|
|
114
|
+
and commands cross WebKit asynchronously. The `native` handle is the Swift
|
|
115
|
+
host transport. See [AppKit setup and engine limits](../../docs/rich-text.md#macos-appkit-editing).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare const html: string; export default html
|