platejs 54.0.0-beta.13 → 54.0.0-beta.15
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/dist/{EditorStatic-CKG5xM3y.d.ts → EditorStatic-ldAMJg-F.d.ts} +4 -4
- package/dist/ai/index.d.ts +2 -2
- package/dist/ai/lib/aiDraftSession.js +9 -7
- package/dist/ai/lib/aiPolicy.internal.js +43 -6
- package/dist/ai/lib/editorAgent.js +30 -21
- package/dist/ai/lib/editorAgentSync.internal.js +2 -2
- package/dist/ai/lib/lockedContext.js +5 -4
- package/dist/ai/react/copilotInline.internal.js +6 -5
- package/dist/ai/react/index.d.ts +7 -7
- package/dist/ai/react/useEditorAgent.js +14 -3
- package/dist/authored/index.d.ts +4 -4
- package/dist/{authored-CJL7S8qI-BxC9ip4d.d.ts → authored-Cux94E76-fEDdP_BS.d.ts} +3 -3
- package/dist/clipboard-format-key-B_rCped5-BJzbgrSZ.d.ts +1 -0
- package/dist/code-block/codemirror/index.d.ts +2 -2
- package/dist/{comment-anchor.internal-DTBP1huU.d.ts → comment-anchor.internal-Ck30WbG4.d.ts} +2 -2
- package/dist/compiler/index.d.ts +3 -3
- package/dist/{core-CTB0OBoh.d.ts → core-DoxvjG5W.d.ts} +69 -23
- package/dist/diff/index.d.ts +2 -2
- package/dist/docs/agents/skills.md +6 -2
- package/dist/docs/agents.md +1 -1
- package/dist/docs/ai-agents.md +8 -4
- package/dist/docs/ai.md +5 -0
- package/dist/docs/api/plate.md +15 -7
- package/dist/docs/api/react-hooks.md +32 -2
- package/dist/docs/authored-changes.md +4 -0
- package/dist/docs/block-menu.md +4 -0
- package/dist/docs/board.md +4 -0
- package/dist/docs/callout.md +63 -9
- package/dist/docs/collaboration.md +6 -1
- package/dist/docs/combobox.md +9 -2
- package/dist/docs/comment.md +8 -4
- package/dist/docs/components/toolbar-buttons.md +1 -1
- package/dist/docs/copilot.md +4 -0
- package/dist/docs/deck.md +173 -0
- package/dist/docs/details.md +4 -0
- package/dist/docs/diff.md +4 -0
- package/dist/docs/discussion.md +4 -0
- package/dist/docs/dnd.md +4 -0
- package/dist/docs/docx.md +6 -0
- package/dist/docs/emoji.md +2 -2
- package/dist/docs/equation.md +4 -0
- package/dist/docs/examples/collaboration-example.md +4 -0
- package/dist/docs/examples/export.md +41 -31
- package/dist/docs/examples/merge.md +4 -0
- package/dist/docs/examples/version-history.md +4 -0
- package/dist/docs/field.md +4 -0
- package/dist/docs/footnote.md +4 -0
- package/dist/docs/format-painter.md +1 -1
- package/dist/docs/html.md +4 -0
- package/dist/docs/index.md +4 -0
- package/dist/docs/ink.md +6 -0
- package/dist/docs/installation/manual.md +2 -4
- package/dist/docs/installation/next.md +1 -3
- package/dist/docs/installation/plate-ui.md +6 -2
- package/dist/docs/installation/rsc.md +1 -1
- package/dist/docs/installation.md +4 -0
- package/dist/docs/link.md +6 -0
- package/dist/docs/lint.md +18 -0
- package/dist/docs/llms.txt +4 -1
- package/dist/docs/lock.md +34 -2
- package/dist/docs/markdown.md +8 -0
- package/dist/docs/media.md +4 -0
- package/dist/docs/mention.md +5 -0
- package/dist/docs/mobile.md +415 -0
- package/dist/docs/pagination.md +4 -0
- package/dist/docs/prompt-editor.md +17 -1
- package/dist/docs/reference.md +192 -0
- package/dist/docs/roots.md +34 -0
- package/dist/docs/serializing.md +23 -0
- package/dist/docs/slash-command.md +58 -4
- package/dist/docs/static.md +29 -20
- package/dist/docs/suggestion.md +4 -0
- package/dist/docs/sync.md +4 -0
- package/dist/docs/table.md +31 -0
- package/dist/docs/toc.md +14 -0
- package/dist/docs/toolbar.md +4 -0
- package/dist/docs/unit-testing.md +4 -0
- package/dist/docs/upload.md +4 -0
- package/dist/docx/export/index.d.ts +5 -5
- package/dist/docx/import/index.d.ts +5 -5
- package/dist/docx/paste/index.d.ts +4 -4
- package/dist/dom/index.d.ts +1 -1
- package/dist/features/basic-nodes/lib/BaseMarkPlugins.js +1 -1
- package/dist/features/basic-styles/lib/BaseFormattingPlugin.js +61 -28
- package/dist/features/basic-styles/lib/BaseStylePlugins.js +28 -7
- package/dist/features/board/index.d.ts +1 -1
- package/dist/features/callout/index.d.ts +2 -160
- package/dist/features/callout/lib/BaseCalloutPlugin.js +109 -9
- package/dist/features/column/index.d.ts +1 -1
- package/dist/features/comments/index.d.ts +2 -2
- package/dist/features/date/index.d.ts +3 -3
- package/dist/features/details/index.d.ts +3 -3
- package/dist/features/field/index.d.ts +1 -1
- package/dist/features/field/lib/BaseFieldPlugin.js +111 -53
- package/dist/features/field/lib/fieldCache.internal.js +9 -21
- package/dist/features/find/index.d.ts +3 -3
- package/dist/features/footnote/index.d.ts +3 -3
- package/dist/features/ink/index.d.ts +1 -1
- package/dist/features/link/lib/BaseLinkPlugin.js +5 -2
- package/dist/features/lint/index.d.ts +3 -3
- package/dist/features/list/lib/listKeyboard.internal.js +7 -2
- package/dist/features/lock/index.d.ts +1 -1
- package/dist/features/media/index.d.ts +1 -1
- package/dist/features/mention/index.d.ts +1 -1
- package/dist/features/reference/index.d.ts +240 -0
- package/dist/features/reference/index.js +2 -0
- package/dist/features/reference/lib/BaseReferencePlugin.js +598 -0
- package/dist/features/table/index.d.ts +2 -2
- package/dist/features/toc/index.d.ts +1 -1
- package/dist/features/upload/index.d.ts +1 -1
- package/dist/history/index.d.ts +1 -1
- package/dist/html/index.d.ts +4 -4
- package/dist/html/server/index.d.ts +2 -2
- package/dist/html/server/serverCssParser.internal.js +14 -25
- package/dist/html/server/serverCssStyle.internal.js +4 -7
- package/dist/{htmlConversion-Y-M6PLRi.d.ts → htmlConversion-CHcWrkh5.d.ts} +2 -2
- package/dist/{htmlTypes-CNhoCFjK.d.ts → htmlTypes-9HQ8p7c5.d.ts} +3 -3
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/index-1JPYTyFo.d.ts +305 -0
- package/dist/index-B-SGl9uM.d.ts +1 -0
- package/dist/{index-qqrnWAk_.d.ts → index-B048Z6JD.d.ts} +7 -7
- package/dist/index-BFkl1TNK.d.ts +1 -0
- package/dist/{index-DYuqsDrP.d.ts → index-BRwhNV78.d.ts} +3 -3
- package/dist/{index-B0R9sXv2-T1dxG9oM.d.ts → index-BYv6zIL_-DWmaXzbX.d.ts} +4 -4
- package/dist/{index-B-8L9f6a2.d.ts → index-Bm8V8SS4.d.ts} +5 -5
- package/dist/{index-B8JeECEk.d.ts → index-BujEk356.d.ts} +2 -2
- package/dist/{index-CHud6Aa-.d.ts → index-C4KIDKwP.d.ts} +3 -3
- package/dist/{index-B4aToRMv.d.ts → index-CAFKQNqu.d.ts} +3 -3
- package/dist/{index-Bqva6PJc.d.ts → index-CXJwwbAJ.d.ts} +3 -3
- package/dist/index-CfqQvdcO.d.ts +3 -0
- package/dist/{index-D54VPeky.d.ts → index-Cj09P2Qp.d.ts} +2 -2
- package/dist/{index-mcBtG6pK-CitQV9Bq.d.ts → index-CnumypT3-DGx8_6Ye.d.ts} +2 -2
- package/dist/{index-CWutqVQ_-BO-UgVeK.d.ts → index-DTTSk3WQ-D0TA0B5z.d.ts} +1 -1
- package/dist/{index-CLPMcGC5.d.ts → index-DsKfZoY4.d.ts} +4 -4
- package/dist/{index-UYpvOBXG.d.ts → index-UrJ6V3_e.d.ts} +2 -2
- package/dist/{index-DXCdafUk.d.ts → index-UuSQ_p3c.d.ts} +43 -20
- package/dist/{index-BEXBAmJf.d.ts → index-YNMmixU5.d.ts} +3 -3
- package/dist/{index-CXd5hwaH.d.ts → index-Zj4bj9bZ.d.ts} +1 -1
- package/dist/{index-BfJKfAwk.d.ts → index-eWzk-bcU.d.ts} +3 -3
- package/dist/{index-DhsryaAC.d.ts → index-h2HH9Rw8.d.ts} +1 -1
- package/dist/{index-DJhwDkfd.d.ts → index-l9R_LyGx.d.ts} +3 -3
- package/dist/{index-BFWK852j.d.ts → index-lD9iIU3j.d.ts} +3 -3
- package/dist/{index-D3bhjdRz.d.ts → index-lgeYbG68.d.ts} +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/internal/plugin/compilePlateModel.js +24 -5
- package/dist/internal/plugin/pluginInjectNodeProps.js +33 -5
- package/dist/internal/utils/urlPolicy.js +11 -1
- package/dist/lib/editor/withPlite.js +8 -6
- package/dist/lib/plugins/html/cssLexer.internal.js +144 -37
- package/dist/lib/plugins/html/cssSafety.internal.js +100 -0
- package/dist/lib/plugins/html/htmlDecode.internal.js +2 -2
- package/dist/lib/plugins/html/htmlMatcher.internal.js +1 -1
- package/dist/lib/plugins/html/htmlRules.internal.js +2 -13
- package/dist/lib/plugins/html/htmlSafety.js +28 -27
- package/dist/lib/plugins/html/htmlSerialize.internal.js +16 -2
- package/dist/lib/plugins/html/htmlStyleInline.internal.js +38 -31
- package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +27 -1
- package/dist/markdown/index.d.ts +1 -1
- package/dist/markdown/lib/internal/markdownAttributes.js +16 -7
- package/dist/markdown/lib/internal/markdownMappings.js +123 -16
- package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +16 -1
- package/dist/math/index.d.ts +3 -3
- package/dist/math/react/index.d.ts +4 -4
- package/dist/migrations/index.d.ts +4 -4
- package/dist/migrations/migratePlateV54Urls.internal.js +63 -1
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/react/PaginationPlugin.js +46 -43
- package/dist/pagination/react/index.d.ts +13 -7
- package/dist/{protocol-CSuP7AWG-DAorqpaF.d.ts → protocol-CYflJUT3-CRJPCqOO.d.ts} +1 -1
- package/dist/react/authored/index.d.ts +4 -4
- package/dist/react/components/PlateView.js +7 -1
- package/dist/react/features/board/index.d.ts +5 -5
- package/dist/react/features/callout/index.d.ts +93 -4
- package/dist/react/features/column/index.d.ts +5 -5
- package/dist/react/features/combobox/combobox.internal.js +35 -22
- package/dist/react/features/combobox/comboboxOwner.internal.js +29 -2
- package/dist/react/features/combobox/index.d.ts +8 -6
- package/dist/react/features/comments/index.d.ts +6 -6
- package/dist/react/features/date/index.d.ts +4 -4
- package/dist/react/features/details/index.d.ts +4 -4
- package/dist/react/features/field/FieldPlugin.js +2 -2
- package/dist/react/features/field/index.d.ts +5 -5
- package/dist/react/features/footnote/index.d.ts +4 -4
- package/dist/react/features/format-painter/FormatPainterPlugin.js +27 -34
- package/dist/react/features/format-painter/index.d.ts +4 -4
- package/dist/react/features/ink/index.d.ts +5 -5
- package/dist/react/features/lock/index.d.ts +5 -5
- package/dist/react/features/media/index.d.ts +5 -5
- package/dist/react/features/mention/index.d.ts +4 -4
- package/dist/react/features/table/index.d.ts +6 -6
- package/dist/react/features/toc/index.d.ts +2 -2
- package/dist/react/features/upload/index.d.ts +5 -5
- package/dist/react/index.d.ts +6 -6
- package/dist/react/virtualized.d.ts +3 -3
- package/dist/refusal-VX2Y6Wmd-BJzbgrSZ.d.ts +1 -0
- package/dist/{registerEditorTools-Cl-o_Wnq.d.ts → registerEditorTools-DoRs57-M.d.ts} +16 -8
- package/dist/shared-room-BZxUmqjV-BJzbgrSZ.d.ts +1 -0
- package/dist/skills/plate/SKILL.md +4 -3
- package/dist/skills/plate/references/ai-and-agents.md +2 -2
- package/dist/skills/plate/references/pricing.md +3 -3
- package/dist/skills/plate/references/setup.md +6 -0
- package/dist/skills/plate/references/ui-and-sync.md +4 -3
- package/dist/{source-DUP5aKcT.d.ts → source-PTxjcq4_.d.ts} +3 -3
- package/dist/static/index.d.ts +23 -9
- package/dist/static/internal/staticPendingMedia.internal.js +2 -1
- package/dist/static/internal/staticPresentation.js +1 -0
- package/dist/static/renderStaticHtml.js +85 -39
- package/dist/{storage-EzfLDqRy-Cu4DQ-Rf.d.ts → storage-CkRL-SHq-CBP6PGqr.d.ts} +2 -2
- package/dist/sync/cloudflare/index.d.ts +3 -3
- package/dist/sync/index.d.ts +4 -4
- package/dist/sync/postgres/index.d.ts +1 -1
- package/dist/sync/react/index.d.ts +6 -6
- package/dist/sync/server/index.d.ts +5 -5
- package/dist/tabbable/react/index.d.ts +4 -4
- package/dist/testing/index.d.ts +3 -3
- package/dist/{transport-DAforzBt-BFwAhC-N.d.ts → transport-2koNcrqA-Dp_RYE3n.d.ts} +1 -1
- package/dist/utils/plate-keys.js +1 -0
- package/dist/{widths-BjIZxtaJ.d.ts → widths-DN1W6m66.d.ts} +5 -5
- package/package.json +9 -2
- package/dist/clipboard-format-key-D9rnh20X-CR00YA0H.d.ts +0 -1
- package/dist/index-CKAkaSJK.d.ts +0 -3
- package/dist/index-CxyK4HrT.d.ts +0 -1
- package/dist/index-zcb_RtZC.d.ts +0 -1
- package/dist/refusal-DCzeB9nD-CR00YA0H.d.ts +0 -1
- package/dist/shared-room-Bg8qMvm1-CR00YA0H.d.ts +0 -1
- /package/dist/{tx-only-CWT-IURY-BqIFhy44.d.ts → tx-only-x32UA-pQ-OQbgWQrN.d.ts} +0 -0
|
@@ -257,8 +257,8 @@ Finally, Plate UI includes more advanced editor components as overlays, menus, b
|
|
|
257
257
|
# Install a menu for AI features
|
|
258
258
|
npx shadcn@latest add @plate/ai-menu
|
|
259
259
|
|
|
260
|
-
# Install a
|
|
261
|
-
npx shadcn@latest add @plate/
|
|
260
|
+
# Install a floating toolbar for text selections
|
|
261
|
+
npx shadcn@latest add @plate/floating-toolbar
|
|
262
262
|
```
|
|
263
263
|
|
|
264
264
|
These components are typically included as part of their respective Feature Kits but can be installed individually for custom setups.
|
|
@@ -298,3 +298,7 @@ See [Upload Files](/docs/upload) before accepting upload requests.
|
|
|
298
298
|
|
|
299
299
|
Each `platejs` release ships docs that match its version. See
|
|
300
300
|
[Agents](/docs/agents) to point your coding agent at them.
|
|
301
|
+
|
|
302
|
+
## Pro and Business
|
|
303
|
+
|
|
304
|
+
Plate Pro delivers copy-owned `@plate-pro/*` shadcn slices, the `Potion v2` and `Paper v2` flagship templates, and the `plate-upgrade` skill for repeatable upgrades across customized Plate UI files with zero private `.npmrc` packages. See [Pricing](/pricing).
|
|
@@ -30,8 +30,8 @@ Create an editor in the Server Component and render it with
|
|
|
30
30
|
|
|
31
31
|
```tsx title="app/documents/page.tsx" showLineNumbers
|
|
32
32
|
import { createEditor, type Value } from 'platejs';
|
|
33
|
-
import { EditorStatic } from 'platejs/static';
|
|
34
33
|
|
|
34
|
+
import { EditorStatic } from '@/components/editor/editor-static';
|
|
35
35
|
import { BaseEditorKit } from '@/components/editor/plugins-static';
|
|
36
36
|
|
|
37
37
|
const value: Value = [
|
|
@@ -65,3 +65,7 @@ Once the editor runs, use these docs to customize it:
|
|
|
65
65
|
- [Plugin](/docs/plugin) explains plugin configuration.
|
|
66
66
|
- [Plugin Components](/docs/plugin-components) explains node and mark rendering.
|
|
67
67
|
- [Troubleshooting](/docs/troubleshooting) covers common setup issues.
|
|
68
|
+
|
|
69
|
+
## Pro and Business
|
|
70
|
+
|
|
71
|
+
Need a full collaborative workspace or repeatable upgrades across customized Plate UI files? Plate Pro provides the `Potion v2` and `Paper v2` flagship templates, copy-owned `@plate-pro/*` slices, and the `plate-deploy-cloudflare`, `plate-deploy-vercel`, and `plate-upgrade` coding-agent skills. See [Pricing](/pricing).
|
package/dist/docs/link.md
CHANGED
|
@@ -284,3 +284,9 @@ link.api.triggerInsert({ focused: true });
|
|
|
284
284
|
link.api.submit();
|
|
285
285
|
link.api.unlink();
|
|
286
286
|
```
|
|
287
|
+
|
|
288
|
+
## Pro and Business
|
|
289
|
+
|
|
290
|
+
For cross-document links that survive page renames, Plate Pro ships `@plate-pro/sources` with a D1 and in-memory backlink index, cycle-guarded transclusion, and workspace citation drift checks alongside the `Potion v2` and `Paper v2` flagship templates.
|
|
291
|
+
|
|
292
|
+
For live inline GitHub PR, Linear issue, and HubSpot CRM status chips (`@plate/smart-chip`, where documents store canonical URLs only and Markdown exports degrade to plain links), Plate Pro ships `@plate-pro/smart-chips` (a self-hosted Cloudflare Worker connector and tenant-bound webhook cache) and Plate Business extends `@plate-business/security-kernel` and `plate verify` CI with AES-256-GCM AAD-bound per-viewer OAuth token isolation, SSRF guards, wire-level field redaction, and CRDT metadata smuggle protection. See [Pricing](/pricing).
|
package/dist/docs/lint.md
CHANGED
|
@@ -432,6 +432,24 @@ Replace a finding's text with one of its fixes, as its own undo step.
|
|
|
432
432
|
| `severity` | `'error' \| 'info' \| 'warning'` | The severity of the rule's findings. |
|
|
433
433
|
| `check` | `(text: string, context: { block: Element; editor: Editor; signal: AbortSignal }) => Iterable<LintMatch> \| PromiseLike<Iterable<LintMatch>>` | Checks one block's content text (with `U+FFFC` at each inline void). Each `LintMatch` is `{ start, end, message, fixes? }`, with UTF-16 offsets into `text` and optional `string \| LintFix` fixes. |
|
|
434
434
|
|
|
435
|
+
## Compliance guardrails
|
|
436
|
+
|
|
437
|
+
Install the copied `guardrails` item alongside `lint` to enforce terminology, banned claims (with optional cross-block disclosures), and checksummed DLP detectors (Luhn credit cards, SSN, IBAN, AWS keys, private keys, and API tokens) over `BaseLintPlugin`:
|
|
438
|
+
|
|
439
|
+
```bash
|
|
440
|
+
npx shadcn@latest add @plate/guardrails
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
_Example `guardrails-demo` in the Plate repository: `apps/www/src/registry/examples/guardrails-demo.tsx`._
|
|
444
|
+
|
|
445
|
+
_Switch compliance presets, inspect the AI draft preview gate before applying, fix evasion-resistant banned claims and test secrets with one click, or add the FINRA disclosure to clear cached claim findings across blocks._
|
|
446
|
+
|
|
447
|
+
`guardrails-engine.ts` normalizes default-ignorable characters, combining marks, `NFKC` compatibility forms, Cyrillic and Greek lookalikes, and bidi override spans back to exact UTF-16 offsets while suppressing fixes that would split multi-character ligatures. In collaborative apps enforcing server-side `onAdmit` policy rules, live `BaseLintPlugin` squiggles flag edits as the user types while refused sync batches surface through the sync client's `keptItems()` review queue.
|
|
448
|
+
|
|
449
|
+
## Pro and Business
|
|
450
|
+
|
|
451
|
+
For teams scaling compliance guardrails into production workflows, [Plate Pro](/pricing) includes `@plate-pro/guardrails` (Vale-compatible rulepack import, org-over-team precedence merging with SHA-256 pinning, LanguageTool `AnnotatedText` and grounded LLM adapters with length-preserving pre-egress DLP scrubbing, and a Cloudflare check Worker deployed via `plate-deploy-cloudflare`). [Plate Business](/pricing) adds server-side `onAdmit`, comment-mutation, and pre-export compliance gates inside `@plate-business/security-kernel` and `@plate-business/compliance-pdf` plus automated evasion and export-leak CI checks in `plate verify`.
|
|
452
|
+
|
|
435
453
|
## Related docs
|
|
436
454
|
|
|
437
455
|
- [Find](/docs/find)
|
package/dist/docs/llms.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Plate docs for platejs@54.0.0-beta.
|
|
1
|
+
# Plate docs for platejs@54.0.0-beta.15
|
|
2
2
|
|
|
3
3
|
These pages match the installed `platejs` version. A `/docs/<path>` link in a page is the file `<path>.md` in this folder when the list below names it, and `/docs` is `index.md`. Read the pages your task needs before you write editor code.
|
|
4
4
|
|
|
@@ -55,6 +55,7 @@ These pages match the installed `platejs` version. A `/docs/<path>` link in a pa
|
|
|
55
55
|
- [Copilot](copilot.md): Streaming inline AI text completions with rich ghost text.
|
|
56
56
|
- [Date](date.md) (`platejs/date`): Inline void date elements with one authored string value.
|
|
57
57
|
- [Debugging](debugging.md): Debugging in Plate.
|
|
58
|
+
- [Deck](deck.md): Present structured documents and board frames as a live slide deck with speaker notes and 16:9 print export.
|
|
58
59
|
- [Decorations and annotations](decorations.md): Paint transient ranges and retain application-owned range identities.
|
|
59
60
|
- [Details](details.md) (`platejs/details`): Add collapsible disclosure blocks with editable summary headers.
|
|
60
61
|
- [Diff & Merge](diff.md) (`platejs/diff`): Compare immutable Plate documents, resolve three-way merge conflicts, and apply checked diffs in one undoable step.
|
|
@@ -112,6 +113,7 @@ These pages match the installed `platejs` version. A `/docs/<path>` link in a pa
|
|
|
112
113
|
- [Markdown](markdown.md) (`platejs/markdown`): Parse Markdown documents, slices, and inline content, and serialize Plate documents to Markdown.
|
|
113
114
|
- [Media](media.md) (`platejs/media`): Embed and manage images, videos, audio, files, and external embeds.
|
|
114
115
|
- [Mention](mention.md) (`platejs/mention`): Inline markable void mentions completed from text typed after a trigger.
|
|
116
|
+
- [Mobile WebView](mobile.md): Embed a Plate editor in Expo, React Native, SwiftUI, Android, or Flutter through a typed JSON postMessage bridge.
|
|
115
117
|
- [Multi Select](multi-select.md): Select, copy, drag, and delete multiple blocks at once.
|
|
116
118
|
- [Navigation Feedback](navigation-feedback.md): Highlight the destination of a TOC, footnote, search, or custom navigation jump.
|
|
117
119
|
- [Pagination](pagination.md) (`platejs/pagination`): Render a Plate editor on measured pages with zero-remount Pageless and Paged switching.
|
|
@@ -124,6 +126,7 @@ These pages match the installed `platejs` version. A `/docs/<path>` link in a pa
|
|
|
124
126
|
- [Plugin Shortcuts](plugin-shortcuts.md): Configure keyboard shortcuts on Plate plugins.
|
|
125
127
|
- [Plugin Configuration](plugin.md): Configure and customize Plate plugins, schema, state, and lifecycle hooks.
|
|
126
128
|
- [Prompt Editor](prompt-editor.md): Build chat message inputs with inline @ mention chips that send on Enter.
|
|
129
|
+
- [Reference](reference.md) (`platejs/reference`): Insert rename-safe wikilinks, backlinks, hover transclusion cards, and version-pinned citations.
|
|
127
130
|
- [Releases](releases.md): Browse package release notes and Plate UI registry changelog updates.
|
|
128
131
|
- [Roots](roots.md): Use extra roots for headers, footers, synced blocks, captions, and other editable regions.
|
|
129
132
|
- [Right-to-left](rtl.md): Edit Arabic, Hebrew and other right-to-left documents.
|
package/dist/docs/lock.md
CHANGED
|
@@ -16,9 +16,10 @@ _Try editing or dragging a locked block to see it refuse writes while keeping te
|
|
|
16
16
|
- Protect locked clauses and locked table cells during AI edits by replacing locked blocks with indexed `<Locked ref="lN" />` Markdown AST placeholders, rewriting unlocked runs around them in one reviewable proposal, and excluding locked cells from multi-cell table edits with live writability revalidation.
|
|
17
17
|
- Drop `locked` on copy, paste, duplicate, and block splits while preserving `data-editor-html-locked="true"` on programmatic HTML serialization and reporting `property-dropped` / `markdown-property-omitted` warnings on DOCX and Markdown export.
|
|
18
18
|
- Skip standalone lock toggles in undo history while blocking local undo replays that would mutate a currently locked block, and commit lock toggles directly in Suggesting mode without recording a formatting suggestion.
|
|
19
|
+
- Enforce locked blocks and locked content roots during MIT `SyncServer` peer admission (`'sync-admit'`), refusing unauthorized peer writes with a non-abuse `'policy'` receipt (`code: 'block-locked'`) while keeping `lockWriteExemption` fills, standalone `edit` lock toggles, and trusted `server.run` turns working.
|
|
19
20
|
- Announce refused edits on locked blocks to screen readers with cooldown throttling.
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
`BaseLockPlugin` protects locked blocks in both client editors (preventing accidental edits, deletes, drags, and undo replays) and MIT `SyncServer` rooms (refusing stale or compromised peer writes tagged with `'sync-admit'`). It enforces document-level lock integrity, not per-user role authorization or wire read redaction: restrict which `edit` peers may lock or unlock blocks in `SyncServerOptions.onAdmit`, and use Plate Business for section/field ACLs and wire redaction.
|
|
22
23
|
|
|
23
24
|
## Kit usage
|
|
24
25
|
|
|
@@ -167,18 +168,45 @@ const selectionMarkdown = serializeAISelectionMarkdown(editor, {
|
|
|
167
168
|
});
|
|
168
169
|
```
|
|
169
170
|
|
|
171
|
+
### Server sync admission (`'sync-admit'`)
|
|
172
|
+
|
|
173
|
+
Install `BaseLockPlugin` inside the `editor` factory passed to `createSyncServer` from `platejs/sync/server` so locked blocks hold against stale or compromised peer submits, not only client UI checks.
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
import { createEditor } from 'platejs';
|
|
177
|
+
import { BaseFieldPlugin } from 'platejs/field';
|
|
178
|
+
import { BaseLockPlugin } from 'platejs/lock';
|
|
179
|
+
import { createSyncServer, memoryStorage } from 'platejs/sync/server';
|
|
180
|
+
|
|
181
|
+
const server = createSyncServer({
|
|
182
|
+
authorize: ({ token }) => ({ access: 'edit', actor: token, decide: true }),
|
|
183
|
+
editor: () =>
|
|
184
|
+
createEditor({
|
|
185
|
+
plugins: [BaseFieldPlugin, BaseLockPlugin],
|
|
186
|
+
}),
|
|
187
|
+
storage: memoryStorage(),
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
When `SyncServer` evaluates a peer submit, it tags the room editor admission commit with `'sync-admit'` (alongside `'collaboration'` and `'history-skip'`). `BaseLockPlugin` runs its full admission checks on `'sync-admit'` commits while continuing to accept settled remote collaboration broadcasts that omit `'sync-admit'`.
|
|
192
|
+
|
|
193
|
+
- **Refused peer writes:** Text edits, property changes, deletes, wraps, unwraps, moves, merges, and authored `decide` commits touching a locked block or locked content root are refused with a non-abuse `'policy'` receipt (`{ status: 'refused', reason: 'policy', code: 'block-locked' }`) reported to `onRefused`. Combining an unlock with a content edit in one peer submit is refused, and `suggest` peers cannot insert a locked pending suggestion or toggle `locked`.
|
|
194
|
+
- **Allowed server writes:** Validated `lockWriteExemption` writes (such as `BaseFieldPlugin` inline field fills) inside locked blocks pass peer admission. Standalone `locked` toggles from authorized `edit` peers pass admission when no pending authored insertion sits on the node. Trusted `server.run` turns commit with `source: 'server'` (without `'sync-admit'`), so server code can unlock, edit, and relock a block in one turn.
|
|
195
|
+
- **Per-actor lock authority:** `BaseLockPlugin` does not decide which `edit` peers may lock or unlock blocks. Add role checks for `locked` transitions in `SyncServerOptions.onAdmit` and return `{ allow: false, reason: 'policy', code: 'lock-authority' }` for unauthorized actors.
|
|
196
|
+
|
|
170
197
|
## Behavior
|
|
171
198
|
|
|
172
199
|
- **Selection, copy, and Cut.** Users can select, search, and copy (`Mod+C`) text inside locked blocks. Pasted copies drop `locked` so copied clauses become editable at the destination. Native Cut (`Mod+X`) and drag-handle Cut refuse before modifying the clipboard or removing blocks.
|
|
173
200
|
- **Enter at block edges.** Pressing `Enter` inside a locked block is refused. Pressing `Enter` at the exact start or end of a locked block inserts a new unlocked sibling using the parent's default block (a paragraph at the document root).
|
|
174
201
|
- **History and Suggesting mode.** Standalone `.lock()`, `.unlock()`, and `.toggle()` updates skip undo history and commit directly in Suggesting mode without creating a formatting suggestion. Local undo or redo steps that would edit a currently locked block are refused without dropping the undo stack.
|
|
202
|
+
- **Sync server admission (`'sync-admit'`).** When `BaseLockPlugin` is installed on a `SyncServer` room editor, peer candidate writes tagged with `'sync-admit'` obey the same lock guards and return non-abuse `'policy'` receipts with `code: 'block-locked'`, while settled broadcasts without `'sync-admit'` and trusted `server.run` turns apply normally. Locking a block that already holds pending suggestions refuses peer `decide` commits until an authorized `edit` peer unlocks the block.
|
|
175
203
|
- **HTML, Markdown, and DOCX.** Programmatic `editor.api.html.serialize()` and `editor.api.html.parse()` round-trip `data-editor-html-locked="true"`. Clipboard paste drops `locked`. Markdown serialization reports a `markdown-property-omitted` warning, and `exportDocx` reports a `property-dropped` warning for locked blocks.
|
|
176
204
|
|
|
177
205
|
## Plugins
|
|
178
206
|
|
|
179
207
|
### `BaseLockPlugin`
|
|
180
208
|
|
|
181
|
-
Headless plugin from `platejs/lock`. Declares the optional boolean `locked` property on block elements, enforces per-section commit protection and structural/transfer vetoes, handles edge `Enter` insertion, maps HTML/DOCX formats, and announces throttled refusal messages to screen readers.
|
|
209
|
+
Headless plugin from `platejs/lock`. Declares the optional boolean `locked` property on block elements, enforces per-section commit protection across local edits, undo replays, and MIT `SyncServer` peer admission (`'sync-admit'`), enforces structural/transfer vetoes, handles edge `Enter` insertion, maps HTML/DOCX formats, and announces throttled refusal messages to screen readers.
|
|
182
210
|
|
|
183
211
|
### `LockPlugin`
|
|
184
212
|
|
|
@@ -259,3 +287,7 @@ Helper from `platejs/ai` that serializes the selected blocks for multi-block AI
|
|
|
259
287
|
### `serializeAISelectionMarkdown(editor, options?)`
|
|
260
288
|
|
|
261
289
|
Helper from `platejs/ai` that serializes the active selection to Markdown without mutating the editor, splicing `<Selection>` markers into a cloned JSON copy when `includeSelectionMarkers` is `true`.
|
|
290
|
+
|
|
291
|
+
## Pro and Business
|
|
292
|
+
|
|
293
|
+
Plate Pro ships `@plate-pro/disclosure` for audience document projection and compartmentalized counterparty sub-rooms, `@plate-pro/playbooks` for versioned clause playbooks and counterparty Word `.docx` redline round-trips with WebCrypto SHA-256 receipts, and `@plate-pro/approvals` for section `CODEOWNERS` sign-offs, auto-lock on approval, expiring `Verified` freshness cron workers, and revision-pinned read confirmations. Plate Business adds `@plate-business/security-kernel` for server-enforced section and field ACLs, `policy.playbooks` ethical-wall isolation and deviation ledgers, `onAdmit` approved-section lock authority and stale-approval dismissal, 21 CFR Part 11 WORM sign-off and read-confirmation ledgers, spec-to-code execution gates, and wire-level read redaction, verified by `plate verify`. See [Pricing](/pricing).
|
package/dist/docs/markdown.md
CHANGED
|
@@ -816,3 +816,11 @@ Exports from `platejs/markdown`:
|
|
|
816
816
|
| `MarkdownPlugin` | `const` | `MarkdownPlugin: BasePlugin<Readonly<{` | - |
|
|
817
817
|
| `parseMarkdown` | `const` | `parseMarkdown: (source: string, options: MarkdownParseOptions) => MarkdownDocumentParseResult` | - |
|
|
818
818
|
| `serializeMarkdown` | `const` | `serializeMarkdown: (document: EditorDocumentValue, options: MarkdownSerializeOptions) => MarkdownSerializeResult` | - |
|
|
819
|
+
|
|
820
|
+
## Git/MDX Sync Workbench
|
|
821
|
+
|
|
822
|
+
For visual editing over Git `.md` and `.mdx` repositories without reformatting untouched blocks, YAML/TOML comments, reference definitions, or MDX islands, install the copied MIT workbench (`npx shadcn@latest add @plate/gitsync`) or try the live demo at [Git/MDX Sync & Living RFCs](/blocks/gitsync-demo).
|
|
823
|
+
|
|
824
|
+
## Pro and Business
|
|
825
|
+
|
|
826
|
+
Plate Pro ships `@plate-pro/docs-press` for `llmstxt.org` v2.1 `/llms.txt`, per-page `.md`, and `Accept: text/markdown` content negotiation, `@plate-pro/disclosure` for clean audience Markdown exports, and `@plate-pro/gitsync` for diff-minimal GitHub and GitLab `.md`/`.mdx` pull requests, frontmatter preservation, and living RFC checklists deployed with `plate-deploy-cloudflare`. Plate Business adds `@plate-business/security-kernel` for redacted `/llms.txt` feeds plus pre-merge secret scanning, internal-section redaction, offline link/anchor checks, signed `pgs1.` seals, and `plate verify` CI probes. See [Pricing](/pricing).
|
package/dist/docs/media.md
CHANGED
|
@@ -634,3 +634,7 @@ export type ParsedMediaEmbed =
|
|
|
634
634
|
url: string;
|
|
635
635
|
};
|
|
636
636
|
```
|
|
637
|
+
|
|
638
|
+
## Pro and Business
|
|
639
|
+
|
|
640
|
+
Plate Pro includes Cloudflare R2 media uploads in the `Potion v2` and `Paper v2` flagship templates and `plate-deploy-cloudflare` skill. Plate Business adds `@plate-business/compliance-pdf` and `@plate-business/security-kernel` for SSRF-hardened raster media inlining and allowlisted remote media guards. See [Pricing](/pricing).
|
package/dist/docs/mention.md
CHANGED
|
@@ -153,6 +153,7 @@ The popup opens when the user types `@` and the [combobox rules](/docs/combobox#
|
|
|
153
153
|
|------|--------|
|
|
154
154
|
| Typed text matches `trigger` | `string` prop on `InlineCombobox` (`'@'` in `MentionCombobox`). |
|
|
155
155
|
| Previous character matches `triggerPreviousCharPattern` | Defaults to `/^\s?$/`; `MentionCombobox` uses `/^$\|^[\s"']$/`. |
|
|
156
|
+
| Not inside `inputRuleVeto` | Built into `useCombobox`; skips code blocks, inline code, and custom veto elements or marks. |
|
|
156
157
|
| `triggerQuery(editor)` returns true | Optional app veto for custom contexts. |
|
|
157
158
|
|
|
158
159
|
Until an item is selected, `@` and the query are ordinary text in the document. Escape closes the popup and keeps that text.
|
|
@@ -182,3 +183,7 @@ Exports with a fixed `@` prefix (`@${label ?? ref}`). DOCX export carries instal
|
|
|
182
183
|
| `editor.plugin(MentionPlugin).update.insert({ ref, label? }, options?)` | `BaseMentionPlugin` update | Inserts the mention node at the current selection (or `options.at`), optionally adding a trailing space at block end when `options.trailingSpace` is `true`. |
|
|
183
184
|
| `useCombobox` | `platejs/combobox/react` | Opens the popup on a typed `@` and completes the query. |
|
|
184
185
|
| `inline-combobox` | Copied registry UI | Handles the listbox and keyboard navigation for the mention popup, and exports the `rankOptions` that orders its items. |
|
|
186
|
+
|
|
187
|
+
## Pro and Business
|
|
188
|
+
|
|
189
|
+
Plate Pro ships `@plate-pro/context-chips` for multi-source `@` context registries and server-side `<mention>` XML context expansion. Plate Business adds `@plate-business/security-kernel` for fail-closed context-chip ACLs and redaction before model calls. See [Pricing](/pricing).
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
# Mobile WebView
|
|
2
|
+
|
|
3
|
+
Embed a Plate editor in Expo, React Native, SwiftUI, Android, or Flutter through a typed JSON postMessage bridge.
|
|
4
|
+
|
|
5
|
+
Embed the full Plate editor inside mobile apps without native Objective-C or Kotlin editor modules. Compile your Plate editor into one local HTML asset with `vite-plugin-singlefile`, then drive it from `react-native-webview`, SwiftUI `WKWebView`, Android `WebView`, or Flutter over a copy-and-own typed JSON `postMessage` bridge.
|
|
6
|
+
|
|
7
|
+
This architecture reuses every Plate plugin, mobile `KeyboardToolbar`, and IME behavior inside the WebView while keeping host toolbars, navigation, offline storage, and authentication native. Use this bridge for full block editing; for simple single-field chat or comment inputs, use a native input library such as `react-native-enriched-html` or `enriched-markdown` and exchange content with Plate's [HTML](/docs/html) or [Markdown](/docs/markdown) codecs.
|
|
8
|
+
|
|
9
|
+
_Example `mobile-webview-bridge-demo` in the Plate repository: `apps/www/src/registry/examples/mobile-webview-bridge-demo.tsx`._
|
|
10
|
+
|
|
11
|
+
_Edit text, run native toolbar commands, change the bottom inset, or trigger a simulated WKWebView reload to watch lastContent replay._
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Copy the zero-native-code bridge into your project:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx shadcn@latest add @plate/mobile-webview-bridge
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This adds `mobile-webview-bridge.ts`, which exports the wire types, boundary parsers, WebView attachment helper (`attachEditorMobileBridge`), host controller (`createMobileBridgeHostController`), and `injectJavaScript` encoder (`encodeHostMessageForInjectJavaScript`).
|
|
22
|
+
|
|
23
|
+
_Registry item `mobile-webview-bridge`: `npx shadcn@latest add @plate/mobile-webview-bridge`._
|
|
24
|
+
|
|
25
|
+
## Single-file Vite bundle
|
|
26
|
+
|
|
27
|
+
Bundle your Plate editor into one self-contained `dist/index.html` file so the mobile app loads the editor offline with zero remote web dependency.
|
|
28
|
+
|
|
29
|
+
Install Vite and `vite-plugin-singlefile` in your web editor bundle package:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install platejs vite vite-plugin-singlefile @vitejs/plugin-react
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Configure Vite to inline every script and stylesheet into one HTML file:
|
|
36
|
+
|
|
37
|
+
```ts title="editor-bundle/vite.config.ts"
|
|
38
|
+
import viteReact from '@vitejs/plugin-react';
|
|
39
|
+
import { defineConfig } from 'vite';
|
|
40
|
+
import { viteSingleFile } from 'vite-plugin-singlefile';
|
|
41
|
+
|
|
42
|
+
export default defineConfig({
|
|
43
|
+
build: {
|
|
44
|
+
cssCodeSplit: false,
|
|
45
|
+
outDir: 'dist',
|
|
46
|
+
target: 'es2020',
|
|
47
|
+
},
|
|
48
|
+
plugins: [viteReact(), viteSingleFile()],
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Create the HTML entry point with a viewport meta tag that respects safe-area insets:
|
|
53
|
+
|
|
54
|
+
```html title="editor-bundle/index.html"
|
|
55
|
+
<!doctype html>
|
|
56
|
+
<html lang="en">
|
|
57
|
+
<head>
|
|
58
|
+
<meta charset="UTF-8" />
|
|
59
|
+
<meta
|
|
60
|
+
name="viewport"
|
|
61
|
+
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, viewport-fit=cover"
|
|
62
|
+
/>
|
|
63
|
+
<title>Editor</title>
|
|
64
|
+
</head>
|
|
65
|
+
<body>
|
|
66
|
+
<div id="root"></div>
|
|
67
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
68
|
+
</body>
|
|
69
|
+
</html>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Mount Plate and attach `attachEditorMobileBridge` in your entry file. Bind `--editor-mobile-inset-bottom` to your scroll container padding so the document clears the native keyboard and accessory toolbar.
|
|
73
|
+
|
|
74
|
+
```tsx title="editor-bundle/src/main.tsx"
|
|
75
|
+
import * as React from 'react';
|
|
76
|
+
import { createRoot } from 'react-dom/client';
|
|
77
|
+
import { createEditor, EditorRoot } from 'platejs/react';
|
|
78
|
+
|
|
79
|
+
import { BasicBlocksKit } from '@/components/editor/basic-blocks';
|
|
80
|
+
import { BasicMarksKit } from '@/components/editor/basic-marks';
|
|
81
|
+
import { Editor, EditorContainer, EditorFrame } from '@/components/editor/editor';
|
|
82
|
+
import { ListKit } from '@/components/editor/list';
|
|
83
|
+
import { attachEditorMobileBridge } from '@/components/editor/mobile-webview-bridge';
|
|
84
|
+
|
|
85
|
+
function MobileEditorApp() {
|
|
86
|
+
const [editor] = React.useState(() =>
|
|
87
|
+
createEditor({
|
|
88
|
+
plugins: [...BasicBlocksKit, ...BasicMarksKit, ...ListKit],
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
const [readOnly, setReadOnly] = React.useState(false);
|
|
92
|
+
|
|
93
|
+
React.useEffect(() => {
|
|
94
|
+
const bridge = attachEditorMobileBridge(editor, {
|
|
95
|
+
onReadOnlyChange: setReadOnly,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return () => bridge.dispose();
|
|
99
|
+
}, [editor]);
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div style={{ height: '100dvh', paddingBottom: 'var(--editor-mobile-inset-bottom, 0px)' }}>
|
|
103
|
+
<EditorRoot editor={editor} readOnly={readOnly}>
|
|
104
|
+
<EditorFrame>
|
|
105
|
+
<EditorContainer>
|
|
106
|
+
<Editor placeholder="Start writing..." variant="none" />
|
|
107
|
+
</EditorContainer>
|
|
108
|
+
</EditorFrame>
|
|
109
|
+
</EditorRoot>
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const rootElement = document.getElementById('root');
|
|
115
|
+
|
|
116
|
+
if (rootElement) {
|
|
117
|
+
createRoot(rootElement).render(<MobileEditorApp />);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Run `npx vite build` to generate `editor-bundle/dist/index.html`, then ship that file inside your Expo, SwiftUI, Android, or Flutter bundle.
|
|
122
|
+
|
|
123
|
+
## Expo (`react-native-webview`) example
|
|
124
|
+
|
|
125
|
+
Use standard `react-native-webview` inside Expo rather than `@expo/dom-webview` (`'use dom'`) or native-module keyboard swizzles. `createMobileBridgeHostController` tracks `lastContent` on every `change` frame and replays `init` and `setInset` automatically when iOS terminates the `WKWebView` content process (`onContentProcessDidTerminate`).
|
|
126
|
+
|
|
127
|
+
Install `react-native-webview` in your Expo app:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npx expo install react-native-webview
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Wrap `WebView` with `createMobileBridgeHostController` and forward keyboard height to `setInset`:
|
|
134
|
+
|
|
135
|
+
```tsx title="app/components/PlateWebViewEditor.tsx"
|
|
136
|
+
import * as React from 'react';
|
|
137
|
+
import { Keyboard, Pressable, Text, View } from 'react-native';
|
|
138
|
+
import { WebView, type WebViewMessageEvent } from 'react-native-webview';
|
|
139
|
+
import type { Value } from 'platejs';
|
|
140
|
+
|
|
141
|
+
import {
|
|
142
|
+
createMobileBridgeHostController,
|
|
143
|
+
encodeHostMessageForInjectJavaScript,
|
|
144
|
+
type MobileEditorStateSnapshot,
|
|
145
|
+
} from './mobile-webview-bridge';
|
|
146
|
+
|
|
147
|
+
export function PlateWebViewEditor({
|
|
148
|
+
authToken,
|
|
149
|
+
editorHtml,
|
|
150
|
+
initialValue,
|
|
151
|
+
onChange,
|
|
152
|
+
readOnly = false,
|
|
153
|
+
}: {
|
|
154
|
+
authToken?: string;
|
|
155
|
+
editorHtml: string;
|
|
156
|
+
initialValue: Value;
|
|
157
|
+
onChange?: (value: Value) => void;
|
|
158
|
+
readOnly?: boolean;
|
|
159
|
+
}) {
|
|
160
|
+
const webViewRef = React.useRef<WebView | null>(null);
|
|
161
|
+
const [editorState, setEditorState] =
|
|
162
|
+
React.useState<MobileEditorStateSnapshot | null>(null);
|
|
163
|
+
|
|
164
|
+
const hostRef = React.useRef(
|
|
165
|
+
createMobileBridgeHostController({
|
|
166
|
+
authToken,
|
|
167
|
+
initialValue,
|
|
168
|
+
onChange,
|
|
169
|
+
onState: setEditorState,
|
|
170
|
+
readOnly,
|
|
171
|
+
send: (message) => {
|
|
172
|
+
webViewRef.current?.injectJavaScript(
|
|
173
|
+
encodeHostMessageForInjectJavaScript(message)
|
|
174
|
+
);
|
|
175
|
+
},
|
|
176
|
+
})
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
React.useEffect(() => {
|
|
180
|
+
hostRef.current.setReadOnly(readOnly);
|
|
181
|
+
}, [readOnly]);
|
|
182
|
+
|
|
183
|
+
React.useEffect(() => {
|
|
184
|
+
hostRef.current.setAuthToken(authToken);
|
|
185
|
+
}, [authToken]);
|
|
186
|
+
|
|
187
|
+
React.useEffect(() => {
|
|
188
|
+
const showSub = Keyboard.addListener('keyboardDidShow', (event) => {
|
|
189
|
+
hostRef.current.setInset(event.endCoordinates.height);
|
|
190
|
+
});
|
|
191
|
+
const hideSub = Keyboard.addListener('keyboardDidHide', () => {
|
|
192
|
+
hostRef.current.setInset(0);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
return () => {
|
|
196
|
+
showSub.remove();
|
|
197
|
+
hideSub.remove();
|
|
198
|
+
};
|
|
199
|
+
}, []);
|
|
200
|
+
|
|
201
|
+
const handleMessage = (event: WebViewMessageEvent) => {
|
|
202
|
+
hostRef.current.handleWebViewMessage(event.nativeEvent.data);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const handleProcessTerminate = () => {
|
|
206
|
+
hostRef.current.handleWebViewTerminate();
|
|
207
|
+
webViewRef.current?.reload();
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<View style={{ flex: 1 }}>
|
|
212
|
+
<WebView
|
|
213
|
+
hideKeyboardAccessoryView
|
|
214
|
+
keyboardDisplayRequiresUserAction={false}
|
|
215
|
+
onContentProcessDidTerminate={handleProcessTerminate}
|
|
216
|
+
onMessage={handleMessage}
|
|
217
|
+
originWhitelist={['*']}
|
|
218
|
+
ref={webViewRef}
|
|
219
|
+
source={{ html: editorHtml }}
|
|
220
|
+
style={{ flex: 1 }}
|
|
221
|
+
/>
|
|
222
|
+
|
|
223
|
+
<View style={{ flexDirection: 'row', gap: 8, padding: 8 }}>
|
|
224
|
+
<Pressable
|
|
225
|
+
onPress={() => {
|
|
226
|
+
void hostRef.current.sendCommand('bold');
|
|
227
|
+
}}
|
|
228
|
+
>
|
|
229
|
+
<Text style={{ fontWeight: editorState?.active.bold ? '700' : '400' }}>
|
|
230
|
+
Bold
|
|
231
|
+
</Text>
|
|
232
|
+
</Pressable>
|
|
233
|
+
<Pressable
|
|
234
|
+
disabled={!editorState?.canUndo}
|
|
235
|
+
onPress={() => {
|
|
236
|
+
void hostRef.current.sendCommand('undo');
|
|
237
|
+
}}
|
|
238
|
+
>
|
|
239
|
+
<Text>Undo</Text>
|
|
240
|
+
</Pressable>
|
|
241
|
+
<Pressable
|
|
242
|
+
disabled={!editorState?.canRedo}
|
|
243
|
+
onPress={() => {
|
|
244
|
+
void hostRef.current.sendCommand('redo');
|
|
245
|
+
}}
|
|
246
|
+
>
|
|
247
|
+
<Text>Redo</Text>
|
|
248
|
+
</Pressable>
|
|
249
|
+
</View>
|
|
250
|
+
</View>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## SwiftUI `WKWebView` example
|
|
256
|
+
|
|
257
|
+
The exact same `dist/index.html` asset runs inside SwiftUI with zero JavaScript changes. Register a `WKScriptMessageHandler` named `"editorBridge"` (`attachEditorMobileBridge` posts to `window.webkit.messageHandlers.editorBridge.postMessage` automatically), keep the latest JSON `change` payload in `lastContentJSON`, and replay `init` inside `webViewWebContentProcessDidTerminate`.
|
|
258
|
+
|
|
259
|
+
```swift title="PlateWebView.swift"
|
|
260
|
+
import SwiftUI
|
|
261
|
+
import WebKit
|
|
262
|
+
|
|
263
|
+
final class PlateWebViewCoordinator: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
|
|
264
|
+
weak var webView: WKWebView?
|
|
265
|
+
var lastContentJSON: String
|
|
266
|
+
var readOnly: Bool
|
|
267
|
+
var bottomInset: Double = 0
|
|
268
|
+
var onStateChange: (([String: Any]) -> Void)?
|
|
269
|
+
var onValueChange: ((String) -> Void)?
|
|
270
|
+
private var nextCommandId = 1
|
|
271
|
+
|
|
272
|
+
init(initialValueJSON: String, readOnly: Bool = false) {
|
|
273
|
+
self.lastContentJSON = initialValueJSON
|
|
274
|
+
self.readOnly = readOnly
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
func userContentController(
|
|
278
|
+
_ userContentController: WKUserContentController,
|
|
279
|
+
didReceive message: WKScriptMessage
|
|
280
|
+
) {
|
|
281
|
+
guard
|
|
282
|
+
let raw = message.body as? String,
|
|
283
|
+
let data = raw.data(using: .utf8),
|
|
284
|
+
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
|
|
285
|
+
let type = json["type"] as? String
|
|
286
|
+
else { return }
|
|
287
|
+
|
|
288
|
+
switch type {
|
|
289
|
+
case "ready":
|
|
290
|
+
replayInit()
|
|
291
|
+
case "change":
|
|
292
|
+
if let value = json["value"],
|
|
293
|
+
let encoded = try? JSONSerialization.data(withJSONObject: value),
|
|
294
|
+
let valueJSON = String(data: encoded, encoding: .utf8) {
|
|
295
|
+
lastContentJSON = valueJSON
|
|
296
|
+
onValueChange?(valueJSON)
|
|
297
|
+
}
|
|
298
|
+
case "state":
|
|
299
|
+
onStateChange?(json)
|
|
300
|
+
default:
|
|
301
|
+
break
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
|
|
306
|
+
webView.reload()
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
func replayInit() {
|
|
310
|
+
let payload = "{\"type\":\"init\",\"value\":\(lastContentJSON),\"readOnly\":\(readOnly ? "true" : "false")}"
|
|
311
|
+
deliver(rawJSON: payload)
|
|
312
|
+
if bottomInset > 0 {
|
|
313
|
+
setInset(bottom: bottomInset)
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
func sendCommand(_ name: String) {
|
|
318
|
+
let id = "swift-\(nextCommandId)"
|
|
319
|
+
nextCommandId += 1
|
|
320
|
+
let payload = "{\"type\":\"command\",\"id\":\"\(id)\",\"name\":\"\(name)\"}"
|
|
321
|
+
deliver(rawJSON: payload)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
func setInset(bottom: Double) {
|
|
325
|
+
bottomInset = max(0, bottom)
|
|
326
|
+
deliver(rawJSON: "{\"type\":\"setInset\",\"bottom\":\(bottomInset)}")
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
private func deliver(rawJSON: String) {
|
|
330
|
+
guard let escaped = try? JSONSerialization.data(withJSONObject: [rawJSON]),
|
|
331
|
+
let arrayString = String(data: escaped, encoding: .utf8) else { return }
|
|
332
|
+
let literal = String(arrayString.dropFirst().dropLast())
|
|
333
|
+
webView?.evaluateJavaScript(
|
|
334
|
+
"window.__editorMobileBridge&&window.__editorMobileBridge.receive(\(literal));true;"
|
|
335
|
+
)
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
struct PlateWebView: UIViewRepresentable {
|
|
340
|
+
let html: String
|
|
341
|
+
let coordinator: PlateWebViewCoordinator
|
|
342
|
+
|
|
343
|
+
func makeCoordinator() -> PlateWebViewCoordinator {
|
|
344
|
+
coordinator
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
func makeUIView(context: Context) -> WKWebView {
|
|
348
|
+
let controller = WKUserContentController()
|
|
349
|
+
controller.add(context.coordinator, name: "editorBridge")
|
|
350
|
+
|
|
351
|
+
let config = WKWebViewConfiguration()
|
|
352
|
+
config.userContentController = controller
|
|
353
|
+
|
|
354
|
+
let webView = WKWebView(frame: .zero, configuration: config)
|
|
355
|
+
webView.navigationDelegate = context.coordinator
|
|
356
|
+
context.coordinator.webView = webView
|
|
357
|
+
webView.loadHTMLString(html, baseURL: nil)
|
|
358
|
+
return webView
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
func updateUIView(_ uiView: WKWebView, context: Context) {}
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Bridge protocol
|
|
366
|
+
|
|
367
|
+
Every message crosses the WebView boundary as serialized JSON. The bridge ignores unrelated `window` messages and validates every field before touching editor state.
|
|
368
|
+
|
|
369
|
+
### Host to editor
|
|
370
|
+
|
|
371
|
+
| Message | Payload | Behavior |
|
|
372
|
+
| --- | --- | --- |
|
|
373
|
+
| `init` | `{ type: 'init', value, readOnly?, authToken? }` | Replaces editor content with `history.skip()` without emitting an echo `change`, updates read-only state, forwards `authToken` to `onAuthToken` (for API or sync auth where `file://` cookies are unavailable), and flushes a fresh `state` snapshot. |
|
|
374
|
+
| `command` | `{ type: 'command', id, name, args? }` | Runs a built-in or custom command, refuses mutating commands while `readOnly` is true, posts a matching `result` frame, and flushes `state`. |
|
|
375
|
+
| `setInset` | `{ type: 'setInset', bottom }` | Sets `--editor-mobile-inset-bottom` to `<bottom>px` and calls `onInsetChange` so scroll padding clears the native keyboard. |
|
|
376
|
+
|
|
377
|
+
### Editor to host
|
|
378
|
+
|
|
379
|
+
| Message | Payload | Behavior |
|
|
380
|
+
| --- | --- | --- |
|
|
381
|
+
| `ready` | `{ type: 'ready' }` | Emitted once per mounted WebView after attaching listeners. Triggers initial `init` or automatic `lastContent` replay after a `WKWebView` Jetsam reload. |
|
|
382
|
+
| `state` | `{ type: 'state', selection, active, canUndo, canRedo, readOnly }` | Coalesced over a 10ms window (`stateCoalesceMs`) and deduplicated so rapid typing never floods the native thread. |
|
|
383
|
+
| `change` | `{ type: 'change', value }` | Emitted on document commits so the host updates `lastContent` and persists edits. |
|
|
384
|
+
| `result` | `{ type: 'result', id, ok, error? }` | Settles the matching `command` request by `id`. |
|
|
385
|
+
|
|
386
|
+
### Built-in and custom commands
|
|
387
|
+
|
|
388
|
+
`attachEditorMobileBridge` ships built-in handlers for `bold`, `italic`, `underline`, `strikethrough`, `code`, `highlight`, `paragraph`, `heading` (`{ level: 1..6 }`), `h1` through `h6`, `blockquote`, `bulletedList`, `numberedList`, `todoList`, `undo`, `redo`, `focus`, `blur`, and `setValue`. Extend or override commands with `options.commands` and expose custom active flags with `options.readActive`:
|
|
389
|
+
|
|
390
|
+
```ts
|
|
391
|
+
const customCommands = {
|
|
392
|
+
insertDivider: (currentEditor) => {
|
|
393
|
+
currentEditor.update((tx) => {
|
|
394
|
+
tx.nodes.insert({ children: [{ text: '' }], type: 'hr' });
|
|
395
|
+
});
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
attachEditorMobileBridge(editor, {
|
|
400
|
+
commands: customCommands,
|
|
401
|
+
onAuthToken: (token) => {
|
|
402
|
+
setBearerToken(token);
|
|
403
|
+
},
|
|
404
|
+
});
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
## Limits
|
|
408
|
+
|
|
409
|
+
- **Memory floor:** Each mounted `WKWebView` or Android `WebView` adds roughly 30 to 80 MB of process memory. Reuse a single editor WebView per screen instead of mounting one per list row.
|
|
410
|
+
- **Inline native views:** The bridge keeps all document blocks inside HTML and CSS; it does not embed native UIKit or Android views inside the text flow.
|
|
411
|
+
- **Native device verification:** Browser and unit tests prove the JSON protocol, command execution, 10ms state coalescing, and `lastContent` replay. Verify keyboard accessories, IME composition, and Jetsam process recovery on real iOS and Android devices before App Store release.
|
|
412
|
+
|
|
413
|
+
## Pro and Business
|
|
414
|
+
|
|
415
|
+
Plate Pro ships `@plate-pro/potion-mobile` for a complete Expo and `react-native-webview` companion layered on `@plate/mobile-webview-bridge` (native Expo Router tabs, `@better-auth/expo` Bearer auth without `file://` cookies, `expo-sqlite` offline cache and search, Cloudflare Durable Object `Origin: null` sync gateway, biometric lock, and iOS Jetsam recovery), paired with the `plate-deploy-expo` 1-command EAS Build and Submit skill. See [Pricing](/pricing).
|
package/dist/docs/pagination.md
CHANGED
|
@@ -181,3 +181,7 @@ measurement activates after hydration without swapping the editable DOM node.
|
|
|
181
181
|
`PageLayoutSnapshot` (or `null` when disabled).
|
|
182
182
|
- `useTableRowPageBreak(element)`: returns the spacer height in pixels for a
|
|
183
183
|
table row element starting on a new page.
|
|
184
|
+
|
|
185
|
+
## Pro and Business
|
|
186
|
+
|
|
187
|
+
Plate Pro ships `@plate-pro/docs-press` for CSS `@page` print stylesheets and Typst PDF workers matching paged document layouts. Plate Business adds `@plate-business/compliance-pdf` for zero-network redacted PDF rendering with `preferCSSPageSize`, forensic watermarks, and signed SHA-256 attestations. See [Pricing](/pricing).
|