platejs 54.0.0-beta.2 → 54.0.0-beta.4

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.
Files changed (255) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +56 -0
  3. package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DrUahdTc.d.ts} +2 -2
  4. package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-_7Ka6nY3.d.ts} +7 -3
  5. package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-D3Cb-QwH.d.ts} +7 -7
  6. package/dist/ai/index.d.ts +1 -1
  7. package/dist/ai/react/AIChatPlugin.js +113 -78
  8. package/dist/ai/react/CopilotPlugin.js +1 -1
  9. package/dist/ai/react/index.d.ts +23 -16
  10. package/dist/authored/index.d.ts +4 -4
  11. package/dist/code-block/codemirror/createCodeMirrorAdapter.js +12 -9
  12. package/dist/code-block/codemirror/index.d.ts +1 -1
  13. package/dist/{combobox-DkBGgyd3.d.ts → combobox-Dr0OYZIE.d.ts} +2 -2
  14. package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-DdwE6mYq-BogsHoUO.d.ts} +10 -2
  15. package/dist/compiler/index.d.ts +2 -2
  16. package/dist/{core-BJG8l_mk.d.ts → core-BqR-fEDp.d.ts} +493 -116
  17. package/dist/diff/index.d.ts +2 -2
  18. package/dist/docs/ai.md +4 -3
  19. package/dist/docs/api/core/plate-components.md +0 -19
  20. package/dist/docs/api/core/plate-controller.md +5 -3
  21. package/dist/docs/api/core/plate-plugin.md +3 -0
  22. package/dist/docs/api/core/plate-store.md +3 -3
  23. package/dist/docs/api/core.md +45 -5
  24. package/dist/docs/api/dom.md +11 -4
  25. package/dist/docs/api/editor-transforms.md +2 -1
  26. package/dist/docs/api/react-hooks.md +45 -13
  27. package/dist/docs/authored-changes.md +9 -4
  28. package/dist/docs/basic-blocks.md +42 -29
  29. package/dist/docs/block-placeholder.md +4 -2
  30. package/dist/docs/blockquote.md +5 -3
  31. package/dist/docs/board.md +118 -10
  32. package/dist/docs/code-block.md +47 -0
  33. package/dist/docs/comment.md +2 -2
  34. package/dist/docs/discussion.md +1 -1
  35. package/dist/docs/document-model.md +15 -3
  36. package/dist/docs/docx.md +1 -1
  37. package/dist/docs/dom-coverage.md +5 -0
  38. package/dist/docs/editor.md +50 -4
  39. package/dist/docs/examples/editable-voids.md +2 -3
  40. package/dist/docs/external-text.md +2 -0
  41. package/dist/docs/field.md +370 -0
  42. package/dist/docs/find.md +9 -6
  43. package/dist/docs/form.md +2 -0
  44. package/dist/docs/heading.md +6 -0
  45. package/dist/docs/installation/manual.md +0 -4
  46. package/dist/docs/link.md +3 -3
  47. package/dist/docs/llms.txt +4 -2
  48. package/dist/docs/markdown.md +270 -14
  49. package/dist/docs/plugin-components.md +13 -10
  50. package/dist/docs/plugin-input-rules.md +66 -15
  51. package/dist/docs/prompt-editor.md +205 -0
  52. package/dist/docs/roots.md +8 -6
  53. package/dist/docs/rtl.md +6 -4
  54. package/dist/docs/selection.md +7 -4
  55. package/dist/docs/suggestion.md +1 -1
  56. package/dist/docs/toolbar.md +26 -30
  57. package/dist/docs/upload.md +106 -17
  58. package/dist/docx/export/index.d.ts +3 -3
  59. package/dist/docx/export/lib/docxStaticComponents.js +12 -2
  60. package/dist/docx/export/lib/exportDocx.js +46 -17
  61. package/dist/docx/export/lib/internal/xml-builder.js +11 -16
  62. package/dist/docx/export/lib/reviewPart.js +1 -1
  63. package/dist/docx/export/lib/reviewProjection.js +52 -10
  64. package/dist/docx/import/index.d.ts +4 -4
  65. package/dist/docx/paste/index.d.ts +4 -4
  66. package/dist/dom/index.d.ts +1 -6
  67. package/dist/dom/plite-dom.internal.js +2 -2
  68. package/dist/excalidraw/index.d.ts +3 -2
  69. package/dist/excalidraw/react/index.d.ts +3 -2
  70. package/dist/facade.js +2 -2
  71. package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +13 -5
  72. package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +32 -10
  73. package/dist/features/board/index.d.ts +2 -2
  74. package/dist/features/board/lib/BaseBoardPlugin.js +14 -1
  75. package/dist/features/board/lib/boardStroke.internal.js +13 -1
  76. package/dist/features/board/lib/boardTypes.internal.js +16 -0
  77. package/dist/features/callout/index.d.ts +3 -2
  78. package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -5
  79. package/dist/features/combobox/index.d.ts +2 -2
  80. package/dist/features/comments/BaseCommentsPlugin.js +33 -17
  81. package/dist/features/comments/index.d.ts +1 -1
  82. package/dist/features/date/index.d.ts +3 -2
  83. package/dist/features/details/index.d.ts +3 -2
  84. package/dist/features/details/lib/BaseDetailsPlugin.js +25 -12
  85. package/dist/features/field/index.d.ts +2 -0
  86. package/dist/features/field/index.js +4 -0
  87. package/dist/features/field/lib/BaseFieldPlugin.js +360 -0
  88. package/dist/features/field/lib/applyFieldValues.js +188 -0
  89. package/dist/features/field/lib/fieldRules.internal.js +204 -0
  90. package/dist/features/find/index.d.ts +3 -2
  91. package/dist/features/footnote/index.d.ts +1 -1
  92. package/dist/features/ink/index.d.ts +1 -1
  93. package/dist/features/ink/lib/BaseInkPlugin.js +126 -103
  94. package/dist/features/ink/lib/inkCodec.internal.js +130 -0
  95. package/dist/features/ink/lib/inkGone.internal.js +229 -48
  96. package/dist/features/ink/lib/inkPlaces.internal.js +534 -64
  97. package/dist/features/layout/index.d.ts +1 -1
  98. package/dist/features/link/lib/BaseLinkPlugin.js +6 -4
  99. package/dist/features/lint/index.d.ts +3 -2
  100. package/dist/features/media/index.d.ts +2 -2
  101. package/dist/features/media/index.js +2 -2
  102. package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
  103. package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +206 -4
  104. package/dist/features/mention/index.d.ts +5 -4
  105. package/dist/features/suggestion/index.d.ts +1 -1
  106. package/dist/features/table/index.d.ts +1 -1
  107. package/dist/features/table/lib/BaseTablePlugin.js +64 -15
  108. package/dist/features/table/lib/internal/selection.js +4 -2
  109. package/dist/features/toc/index.d.ts +1 -1
  110. package/dist/features/upload/index.d.ts +2 -2
  111. package/dist/features/upload/lib/BaseUploadPlugin.js +464 -250
  112. package/dist/history/index.d.ts +2 -2
  113. package/dist/html/index.d.ts +3 -3
  114. package/dist/html/server/index.d.ts +1 -1
  115. package/dist/{htmlTypes-DjeFG3P8.d.ts → htmlTypes-eT2ZGDAj.d.ts} +2 -31
  116. package/dist/hyperscript/index.d.ts +1 -1
  117. package/dist/{index-DzD6BIFJ.d.ts → index-B33E1CRJ.d.ts} +295 -6
  118. package/dist/{index-Cl77E9yr.d.ts → index-B7moSod7.d.ts} +2 -2
  119. package/dist/{index-hsC_sOn2.d.ts → index-B8-5Sr7I.d.ts} +35 -5
  120. package/dist/{index-BiQerPJS.d.ts → index-B8QJDAmG.d.ts} +2 -2
  121. package/dist/{index-BBKGrsG3.d.ts → index-BTx5oK7k.d.ts} +1 -1
  122. package/dist/{index-iaZOhA76.d.ts → index-BWPcE4ac-Cto_IsNs.d.ts} +7 -1
  123. package/dist/{index-BU6k1Aev.d.ts → index-BXjLmx1n-CXk17buG.d.ts} +4781 -4584
  124. package/dist/{index-kLKMc-pI.d.ts → index-BXwU9QH6.d.ts} +2 -2
  125. package/dist/{index-DTgaSxKr.d.ts → index-BkwR-5hH.d.ts} +40 -4
  126. package/dist/{index-Bq3sdm3S.d.ts → index-BsV2McRr.d.ts} +5 -4
  127. package/dist/index-C9Fu-P4E.d.ts +773 -0
  128. package/dist/{index-D5W-p9bS.d.ts → index-Ca48r1ng.d.ts} +49 -4
  129. package/dist/{index-CcZbqPqk.d.ts → index-Cob_iBdu.d.ts} +116 -41
  130. package/dist/{index-Bxfvicyy.d.ts → index-CpY7Xnxw.d.ts} +4 -3
  131. package/dist/{index-BkR7-GLI.d.ts → index-DNQXzU-X.d.ts} +2 -2
  132. package/dist/{index-D1CFXA-i.d.ts → index-DPowErHa.d.ts} +471 -141
  133. package/dist/{index-DaM37gF6.d.ts → index-DShbzec2.d.ts} +38 -23
  134. package/dist/{index-DC_MNGyu.d.ts → index-DYdObeFQ.d.ts} +3 -3
  135. package/dist/{index-Bc2Yg_2j.d.ts → index-Dq3Jlj8O-BJ6NxZm0.d.ts} +2 -2
  136. package/dist/{index-CT7miqQN.d.ts → index-DwWQVwQt.d.ts} +29 -11
  137. package/dist/{index-xdmCBvlT.d.ts → index-JWgwL5l3.d.ts} +5 -2
  138. package/dist/{index-DLA2DUR2.d.ts → index-M781pyx9.d.ts} +4 -3
  139. package/dist/{index-DdIRduDG.d.ts → index-d7io3MzC.d.ts} +3 -2
  140. package/dist/index.d.ts +4 -4
  141. package/dist/{react/internal → internal}/penStroke.internal.js +1 -1
  142. package/dist/internal/plugin/OverridePlugin.js +101 -119
  143. package/dist/internal/plugin/collectPlateNodeMappings.js +5 -1
  144. package/dist/internal/plugin/pastedUploadFiles.js +4 -0
  145. package/dist/internal/plugin/resolvePlugin.js +1 -1
  146. package/dist/internal/plugin/resolvePlugins.js +3 -0
  147. package/dist/internal/plugin/uploadDrafts.js +6 -0
  148. package/dist/internal/utils/mergePlugins.js +1 -0
  149. package/dist/lib/plugins/element-id/ElementIdPlugin.js +14 -18
  150. package/dist/lib/plugins/html/HtmlPlugin.js +9 -0
  151. package/dist/lib/plugins/html/htmlSafety.js +1 -1
  152. package/dist/lib/plugins/input-rules/InputRulesPlugin.js +77 -28
  153. package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
  154. package/dist/markdown/index.d.ts +2 -2
  155. package/dist/markdown/index.js +3 -1
  156. package/dist/markdown/lib/MarkdownPlugin.js +14 -11
  157. package/dist/markdown/lib/RawHtmlPlugin.js +26 -0
  158. package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
  159. package/dist/markdown/lib/internal/markdownConversion.js +776 -74
  160. package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
  161. package/dist/markdown/lib/internal/markdownFootnoteWriter.js +35 -0
  162. package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
  163. package/dist/markdown/lib/internal/markdownIntrinsics.js +125 -43
  164. package/dist/markdown/lib/internal/markdownLine.js +5 -3
  165. package/dist/markdown/lib/internal/markdownMappings.js +19 -7
  166. package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
  167. package/dist/markdown/lib/internal/markdownRawHtml.js +353 -0
  168. package/dist/markdown/lib/internal/markdownSegments.js +57 -48
  169. package/dist/markdown/lib/internal/markdownTags.js +29 -9
  170. package/dist/markdown/lib/serializer/convertNodesSerialize.js +10 -8
  171. package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
  172. package/dist/markdown/lib/serializer/listToMdastTree.js +2 -0
  173. package/dist/math/index.d.ts +3 -2
  174. package/dist/math/react/index.d.ts +4 -3
  175. package/dist/migrations/index.d.ts +3 -3
  176. package/dist/migrations/migratePlateV54.js +4 -6
  177. package/dist/migrations/migratePlateV54RetiredMarks.internal.js +23 -8
  178. package/dist/migrations/migratePlateV54Suggestions.internal.js +2 -2
  179. package/dist/migrations/v53-manifest.internal.js +4 -0
  180. package/dist/pagination/index.d.ts +1 -1
  181. package/dist/pagination/react/index.d.ts +4 -4
  182. package/dist/react/components/EditorContentView.internal.js +42 -23
  183. package/dist/react/components/EditorProvider.js +5 -5
  184. package/dist/react/components/Plate.js +102 -128
  185. package/dist/react/components/PlateContainer.js +40 -32
  186. package/dist/react/components/PlateController.js +28 -16
  187. package/dist/react/components/PlateRoot.internal.js +3 -2
  188. package/dist/react/core.js +4 -4
  189. package/dist/react/features/board/BoardSurface.js +116 -87
  190. package/dist/react/features/board/boardClipboard.internal.js +15 -5
  191. package/dist/react/features/board/boardExport.internal.js +470 -0
  192. package/dist/react/features/board/boardGesture.internal.js +6 -3
  193. package/dist/react/features/board/boardIndex.internal.js +7 -18
  194. package/dist/react/features/board/boardPictureStyles.internal.js +415 -0
  195. package/dist/react/features/board/boardPictures.internal.js +19 -13
  196. package/dist/react/features/board/boardView.internal.js +190 -50
  197. package/dist/react/features/board/boardVoice.internal.js +10 -11
  198. package/dist/react/features/board/index.d.ts +108 -18
  199. package/dist/react/features/callout/index.d.ts +3 -2
  200. package/dist/react/features/combobox/index.d.ts +8 -8
  201. package/dist/react/features/comments/index.d.ts +6 -5
  202. package/dist/react/features/date/index.d.ts +4 -3
  203. package/dist/react/features/details/index.d.ts +4 -3
  204. package/dist/react/features/field/FieldPlugin.js +35 -0
  205. package/dist/react/features/field/index.d.ts +315 -0
  206. package/dist/react/features/field/index.js +2 -0
  207. package/dist/react/features/footnote/index.d.ts +7 -6
  208. package/dist/react/features/format-painter/index.d.ts +4 -3
  209. package/dist/react/features/ink/InkContent.js +313 -0
  210. package/dist/react/features/ink/index.d.ts +57 -33
  211. package/dist/react/features/ink/index.js +2 -2
  212. package/dist/react/features/ink/inkCapture.internal.js +39 -17
  213. package/dist/react/features/ink/inkInput.internal.js +1 -1
  214. package/dist/react/features/ink/inkLayout.internal.js +6 -3
  215. package/dist/react/features/ink/inkPaint.internal.js +78 -2
  216. package/dist/react/features/ink/inkPlacement.internal.js +332 -104
  217. package/dist/react/features/ink/inkWatch.internal.js +7 -5
  218. package/dist/react/features/layout/index.d.ts +5 -4
  219. package/dist/react/features/media/index.d.ts +5 -4
  220. package/dist/react/features/mention/index.d.ts +6 -5
  221. package/dist/react/features/resizable/Resizable.js +4 -6
  222. package/dist/react/features/resizable/index.d.ts +5 -5
  223. package/dist/react/features/suggestion/index.d.ts +6 -5
  224. package/dist/react/features/table/TablePlugin.js +4 -11
  225. package/dist/react/features/table/index.d.ts +10 -8
  226. package/dist/react/features/table/useTableResize.js +10 -1
  227. package/dist/react/features/toc/index.d.ts +2 -2
  228. package/dist/react/features/upload/index.d.ts +11 -6
  229. package/dist/react/index.d.ts +6 -6
  230. package/dist/react/index.js +4 -4
  231. package/dist/react/internal/plate-context.js +434 -188
  232. package/dist/react/plite-react.js +2 -2
  233. package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +12 -10
  234. package/dist/react/stores/plate/useEditor.js +32 -14
  235. package/dist/react/stores/plate/useEditorHistory.js +55 -0
  236. package/dist/react/stores/plate/useEditorSelector.js +79 -21
  237. package/dist/react/utils/BlockPlaceholderPlugin.js +5 -2
  238. package/dist/react/utils/pipeRenderElement.internal.js +1 -1
  239. package/dist/react/utils/pluginRenderElement.internal.js +1 -1
  240. package/dist/react/virtualized.d.ts +4 -4
  241. package/dist/{source-CNKy99Th.d.ts → source-BGohy8vH.d.ts} +4 -4
  242. package/dist/static/index.d.ts +18 -18
  243. package/dist/static/internal/renderStaticHtmlWithOverrides.js +2 -2
  244. package/dist/static/internal/staticPresentation.js +4 -4
  245. package/dist/static/internal/writeStaticSelectionClipboardData.js +7 -2
  246. package/dist/tabbable/index.d.ts +1 -1
  247. package/dist/tabbable/react/index.d.ts +3 -3
  248. package/dist/testing/index.d.ts +3 -3
  249. package/dist/yjs/index.d.ts +1 -1
  250. package/dist/yjs/react/index.d.ts +6 -6
  251. package/package.json +20 -2
  252. package/dist/markdown/lib/serializer/convertTextsSerialize.js +0 -163
  253. package/dist/react/components/EditorSelectionView.js +0 -40
  254. package/dist/react/features/ink/InkLayer.js +0 -218
  255. package/dist/react/internal/createPlateTargetScope.js +0 -62
@@ -0,0 +1,205 @@
1
+ # Prompt Editor
2
+
3
+ A chat message field that holds @ chips and sends on Enter.
4
+
5
+ _Registry item `prompt-editor-demo`: `npx shadcn@latest add @plate/prompt-editor-demo`._
6
+
7
+ `PromptEditor` is the message field of a chat form, in place of a text area. Typing @ opens a menu of the app's `items`, and a picked item becomes a chip. Enter presses the form's Send button. The message is a string, the typed text with each chip written as a `<mention>` tag.
8
+
9
+ ## Installation
10
+
11
+ _Registry item `prompt-editor`: `npx shadcn@latest add @plate/prompt-editor`._
12
+
13
+ The registry item adds `prompt-editor.tsx` and the `mention` and `inline-combobox` items it imports.
14
+
15
+ ## Usage
16
+
17
+ ```tsx
18
+ 'use client';
19
+
20
+ import * as React from 'react';
21
+
22
+ import { ArrowUpIcon } from 'lucide-react';
23
+
24
+ import { PromptEditor } from '@/components/editor/prompt-editor';
25
+ import {
26
+ InputGroup,
27
+ InputGroupAddon,
28
+ InputGroupButton,
29
+ } from '@/components/ui/input-group';
30
+
31
+ const items = [
32
+ { label: 'Spec', ref: 'docs/spec.md' },
33
+ { label: 'Changelog', ref: 'docs/changelog.md' },
34
+ ];
35
+
36
+ export function ChatForm({ onSend }: { onSend: (message: string) => void }) {
37
+ const [message, setMessage] = React.useState('');
38
+
39
+ return (
40
+ <form
41
+ onSubmit={(event) => {
42
+ event.preventDefault();
43
+ onSend(message);
44
+ setMessage('');
45
+ }}
46
+ >
47
+ <InputGroup>
48
+ <PromptEditor
49
+ items={items}
50
+ placeholder="Ask anything..."
51
+ value={message}
52
+ onChange={setMessage}
53
+ />
54
+ <InputGroupAddon align="block-end">
55
+ <InputGroupButton
56
+ aria-label="Send"
57
+ className="ml-auto rounded-full"
58
+ disabled={!message.trim()}
59
+ size="icon-sm"
60
+ type="submit"
61
+ variant="default"
62
+ >
63
+ <ArrowUpIcon />
64
+ </InputGroupButton>
65
+ </InputGroupAddon>
66
+ </InputGroup>
67
+ </form>
68
+ );
69
+ }
70
+ ```
71
+
72
+ Enter presses the form's first submit button, so the form sends from `onSubmit` as it does for a text area. Enter does nothing while that button is disabled, so disable it while the message is empty or a reply streams.
73
+
74
+ `InputGroup` keeps the height of one line until it holds a block addon. Without one, give it `className="h-auto"` so it grows with the field.
75
+
76
+ ## Examples
77
+
78
+ ### AI SDK chat
79
+
80
+ The demo sends the message and its attached files through the AI SDK's `useChat`, with a local transport that streams a fixed reply instead of calling a model. Pasted and dropped files go to `onFiles`, and removing one moves focus back to the field through its `ref`.
81
+
82
+ _Registry item `prompt-editor-demo`: `npx shadcn@latest add @plate/prompt-editor-demo`._
83
+
84
+ ### AI Elements
85
+
86
+ AI Elements' `PromptInput` reads the message from the form's data under `message`, the name its own text area uses. Give the field that `name` and put it where `PromptInputTextarea` goes:
87
+
88
+ ```tsx
89
+ import {
90
+ PromptInput,
91
+ PromptInputBody,
92
+ PromptInputFooter,
93
+ PromptInputSubmit,
94
+ PromptInputTools,
95
+ } from '@/components/ai-elements/prompt-input';
96
+ import { PromptEditor } from '@/components/editor/prompt-editor';
97
+
98
+ <PromptInput onSubmit={({ text }) => sendMessage({ text })}>
99
+ <PromptInputBody>
100
+ <PromptEditor items={items} name="message" placeholder="Ask anything..." />
101
+ </PromptInputBody>
102
+ <PromptInputFooter>
103
+ <PromptInputTools />
104
+ <PromptInputSubmit status={status} />
105
+ </PromptInputFooter>
106
+ </PromptInput>;
107
+ ```
108
+
109
+ `PromptInput` attaches the files dropped on its form itself. For pasted files, pass `add` from `usePromptInputAttachments()` as `onFiles`, in a component inside `PromptInput`.
110
+
111
+ ### AI Elements with its provider
112
+
113
+ Under `PromptInputProvider`, `PromptInput` reads the message from the provider instead of the form's data. Connect the field through `value` and `onChange`:
114
+
115
+ ```tsx
116
+ import {
117
+ PromptInput,
118
+ PromptInputBody,
119
+ PromptInputProvider,
120
+ usePromptInputController,
121
+ } from '@/components/ai-elements/prompt-input';
122
+ import { PromptEditor } from '@/components/editor/prompt-editor';
123
+
124
+ function MessageField() {
125
+ const { textInput } = usePromptInputController();
126
+
127
+ return (
128
+ <PromptEditor
129
+ items={items}
130
+ value={textInput.value}
131
+ onChange={textInput.setInput}
132
+ />
133
+ );
134
+ }
135
+
136
+ <PromptInputProvider>
137
+ <PromptInput onSubmit={({ text }) => sendMessage({ text })}>
138
+ <PromptInputBody>
139
+ <MessageField />
140
+ </PromptInputBody>
141
+ </PromptInput>
142
+ </PromptInputProvider>;
143
+ ```
144
+
145
+ ## Message
146
+
147
+ The message holds one line per paragraph, joined with `\n`. A chip is `<mention ref="docs/spec.md">Spec</mention>`. Its `ref` and label escape `&`, `<` and `>`, and its `ref` also escapes `"`. The rest of the text is what the user typed. The app's server reads each `ref` and gives the model what the chip points to.
148
+
149
+ A `value` sets the same shape back: each tag becomes a chip, and each `\n` starts a paragraph.
150
+
151
+ ## Behavior
152
+
153
+ - Enter, and Ctrl, Cmd or Alt with Enter, press the form's first submit button. Enter outside a form or while that button is disabled sends nothing and keeps the draft.
154
+ - Shift+Enter breaks the line.
155
+ - Enter while an input method composes sends nothing.
156
+ - With the @ menu showing a match, Enter and Tab pick it. When the menu finds nothing, Enter sends the typed text.
157
+ - Without `items`, a typed @ stays text.
158
+ - A pasted or dropped file goes to `onFiles` and never into the text. A disabled field passes no file on.
159
+ - A paste keeps plain lines and chips only. A pasted chip stays a chip when `items` holds its `ref` and label, and becomes its label as text otherwise.
160
+ - A form reset that no listener cancels clears the field.
161
+ - A `value` other than the last message the field reported replaces the text and puts the caret at the end. A change the app turns down, such as one past a length limit, puts the app's `value` back, as a controlled text area does.
162
+
163
+ Edit `PromptEditorPlugin` in the copied `prompt-editor.tsx` to change these rules.
164
+
165
+ ## Limits
166
+
167
+ - The field fires no `input` event while the user types, so a form `onInput` listener never runs for it. Read changes through `onChange`.
168
+ - A class that changes the field's minimum height needs `!`, such as `min-h-24!`, because the editable sets an inline minimum height while the placeholder shows.
169
+ - AI Elements clears the field whenever it clears its own text area. That includes a send the app refuses without the provider and a failed send with it.
170
+
171
+ ## API Reference
172
+
173
+ ### PromptEditor
174
+
175
+ <API name="PromptEditor">
176
+ <APIProps>
177
+ <APIItem name="items" type="readonly { label: string; ref: string }[]" optional>
178
+ What the @ menu offers. The menu matches the start of any word in a label, or the start of a `ref`.
179
+ </APIItem>
180
+ <APIItem name="name" type="string" optional>
181
+ The key the message takes in the form's `FormData`.
182
+ </APIItem>
183
+ <APIItem name="value" type="string" optional>
184
+ The message of a controlled field.
185
+ </APIItem>
186
+ <APIItem name="onChange" type="(message: string) => void" optional>
187
+ Called with the message after each change, and before Enter sends.
188
+ </APIItem>
189
+ <APIItem name="onFiles" type="(files: File[]) => void" optional>
190
+ Called with the files of a paste or a drop.
191
+ </APIItem>
192
+ <APIItem name="placeholder" type="string" optional>
193
+ The text shown while the field is empty.
194
+ </APIItem>
195
+ <APIItem name="disabled" type="boolean" optional>
196
+ Turns off editing and file handling.
197
+ </APIItem>
198
+ <APIItem name="className" type="string" optional>
199
+ Classes for the editable.
200
+ </APIItem>
201
+ <APIItem name="ref" type="React.Ref<{ focus: () => void }>" optional>
202
+ Gives the app `focus()`.
203
+ </APIItem>
204
+ </APIProps>
205
+ </API>
@@ -277,12 +277,14 @@ const SyncedBlock = ({ attributes, element, slots }) => (
277
277
  A root whose blocks are selected as whole objects, such as a board's shapes,
278
278
  can give focus to an element of its own instead of its editable. Pass
279
279
  `nodeSelectionFocus`, a ref to that element. That element takes focus when the
280
- editor moves focus into the root, as after an undo, while there is no selection
281
- or a node selection holds only the root's top-level blocks. It does not take
282
- focus while the editor shows a caret or a text selection, or on a call to
283
- `editor.api.dom.focus()`, which focuses the root's editable. Unless the element
284
- is a control, such as a button, the editor reads no keys from it, so it must
285
- handle the keys it needs, such as undo and redo through the `onKeyDown` of
280
+ editor moves focus into the root, as after an undo or on a call to
281
+ `editor.api.dom.focus()`, while there is no selection or a node selection holds
282
+ only the root's top-level blocks. It does not take focus while the editor shows
283
+ a caret or a text selection, and a click that selects an object in the root
284
+ focuses the editable. Keep the element mounted across renders. When the render
285
+ that follows a focus call replaces it, focus falls to the page. Unless the
286
+ element is a control, such as a button, the editor reads no keys from it, so it
287
+ must handle the keys it needs, such as undo and redo through the `onKeyDown` of
286
288
  `useEditorHistory`.
287
289
 
288
290
  ```tsx
package/dist/docs/rtl.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Right-to-left
2
2
 
3
- Edit Hebrew, Arabic and other right-to-left documents.
3
+ Edit Arabic, Hebrew and other right-to-left documents.
4
4
 
5
5
  _Example `rtl-demo` in the Plate repository: `apps/www/src/registry/examples/rtl-demo.tsx`, `apps/www/src/registry/examples/values/rtl-value.tsx`._
6
6
 
7
- Plate lays out each block by its own text. A Hebrew or Arabic paragraph starts at the right, an English paragraph in the same document starts at the left, and the editor UI mirrors with the page.
7
+ Plate lays out each block by its own text. An Arabic or Hebrew paragraph starts at the right, an English paragraph in the same document starts at the left, and the editor UI mirrors with the page.
8
8
 
9
9
  ## Setup
10
10
 
@@ -23,7 +23,7 @@ export default function RootLayout({
23
23
  children: React.ReactNode;
24
24
  }) {
25
25
  return (
26
- <html lang="he" dir="rtl">
26
+ <html lang="ar" dir="rtl">
27
27
  <body>
28
28
  <DirectionProvider direction="rtl">{children}</DirectionProvider>
29
29
  </body>
@@ -32,11 +32,13 @@ export default function RootLayout({
32
32
  }
33
33
  ```
34
34
 
35
+ In a Radix style, pass `dir="rtl"` instead, because Radix's types require it.
36
+
35
37
  Plate's editor UI uses start and end classes, so it needs no `rtl` setting in `components.json` and works the same with one. shadcn's [RTL guide](https://ui.shadcn.com/docs/rtl) covers fonts and the rest of your app.
36
38
 
37
39
  ## Text direction
38
40
 
39
- Each text block, such as a paragraph, heading or list item, takes its direction from its first Hebrew, Arabic or Latin letter. A block without one, such as an empty line or a line of digits, follows the editor. Typing a first letter in the other script flips the block.
41
+ Each text block, such as a paragraph, heading or list item, takes its direction from its first Arabic, Hebrew or Latin letter. A block without one, such as an empty line or a line of digits, follows the editor. Typing a first letter in the other script flips the block.
40
42
 
41
43
  Arrow keys follow the block's direction, so in a right-to-left block ArrowLeft moves forward through the text.
42
44
 
@@ -85,8 +85,9 @@ model updates back to the DOM. Application code should not patch
85
85
  _Example `inactive-selection-demo` in the Plate repository: `apps/www/src/registry/examples/inactive-selection-demo.tsx`._
86
86
 
87
87
  Plate `EditorContent` renders an inactive selection when focus moves to a marked
88
- control. The behavior is built in; it does not require a prop, plugin, kit, or
89
- copied selection state.
88
+ control, or when a click on a marked control takes focus from the editor
89
+ without focusing the control, as Safari on Mac does for buttons. The behavior is
90
+ built in; it does not require a prop, plugin, kit, or copied selection state.
90
91
 
91
92
  ### Mark a focus target
92
93
 
@@ -102,7 +103,8 @@ ancestor:
102
103
  The exact `EditorContent` that loses focus reads its live canonical selection. An
103
104
  expanded range renders a highlight. A collapsed range renders a caret. Focus
104
105
  returning to the editor or moving to an unmarked target removes the inactive
105
- paint.
106
+ paint. A click outside a marked control removes it too, unless the click lands
107
+ on a non-editable part of an editor, such as a void's controls.
106
108
 
107
109
  This marker only keeps the selection painted while focus is elsewhere. To let a
108
110
  widget inside a node handle its own input, use the
@@ -131,9 +133,10 @@ The copied `Editor` registry component already styles both hooks.
131
133
  | Focus target | Inactive paint |
132
134
  | --- | --- |
133
135
  | Marked control or composed ancestor | One highlight or caret from the originating `EditorContent` |
136
+ | Nothing, after a click on a marked control | One highlight or caret from the originating `EditorContent` |
134
137
  | The editor | None; the browser owns the active selection |
135
138
  | Any unmarked control | None |
136
- | Window blur or missing focus target | None |
139
+ | Window blur, or nothing after any other click | None |
137
140
 
138
141
  The marker controls presentation only. It does not modify the document,
139
142
  selection, history, clipboard, or collaboration state.
@@ -164,7 +164,7 @@ const { activeId, setActiveId } = useActiveSuggestion();
164
164
 
165
165
  `useSuggestionChanges(path)` returns the native `AuthoredChange` records of the block at that path of the mounted view. A nested block's path returns its own changes and those of a container around it that the preview takes away. It never returns the pending wrap or unwrap of a container the view still shows, which that container's own path returns. It rereads on each commit that changes the document or its state and when the review delta names the path's top-level block, and keeps its result stable while those records are unchanged. A change's `ranges` stay places of the stored document on every view.
166
166
 
167
- `useSuggestionGroups(blockKey)` returns the review cards of the block with that key, as `read.groups` summaries. A nested block's key reads that block's own cards. It rereads when the component that calls it renders and when the review delta names the block, which happens when a change reaches or leaves that block or one of its changes moves to another card. A delta names top-level blocks only, so for a nested block's key it rereads only when that component renders. An edit to the same card in another block does neither, so a summary's `changeCount` or `revision` can trail; read `editor.plugin(AuthoredPlugin).read.groupOf(card.id)` when a control needs the current one. Read a card's changes a page at a time with `read.changes({ group: card.id })`.
167
+ `useSuggestionGroups(blockKey)` returns the review cards of the block with that key, as `read.groups` summaries. A nested block's key reads that block's own cards. It rereads when the component that calls it renders and when the review delta names the block, which happens when a change reaches or leaves that block or one of its changes moves to another card. A delta names top-level blocks only, so for a nested block's key it rereads only when that component renders. An edit to the same card in another block does neither, so a summary's `changeCount` or `revision` can trail; read `editor.plugin(AuthoredPlugin).read.groupOf(card.id)` when a control needs the current one. Read a card's changes a page at a time with `read.changes({ group: card.id })`, or the changes and parts a review card shows with `read.groupDetails(card.id, { limit })`.
168
168
 
169
169
  In the current view, clicking a marked element activates the first card its `data-editor-authored-groups` attribute names. Clicking unmarked editor content clears it. In Safari with an input method such as WeType, a tap gets no click of its own, so its press activates or clears instead. A drag clears the active card when the card under the pointer changes from the one where the drag started, or when the pointer leaves the editor. Unmounting the view, switching it to another intent or preview, or deciding the card also clears stale active state. Use `setActiveId` when a custom card or control needs to activate a card directly.
170
170
 
@@ -74,7 +74,7 @@ const fixedToolbarPlugin = definePlugin('fixedToolbar', {
74
74
 
75
75
  const floatingToolbarPlugin = definePlugin('floatingToolbar', {
76
76
  slots: {
77
- afterEditable: () => <FloatingToolbar />,
77
+ caret: () => <FloatingToolbar />,
78
78
  },
79
79
  });
80
80
 
@@ -88,7 +88,7 @@ const editor = createEditor({
88
88
  ```
89
89
 
90
90
  - `slots.beforeContainer`: Renders [`FixedToolbar`](/docs/components/fixed-toolbar) before the editor scroll container
91
- - `slots.afterEditable`: Renders [`FloatingToolbar`](/docs/components/floating-toolbar) as an overlay after the editor
91
+ - `slots.caret`: Renders [`FloatingToolbar`](/docs/components/floating-toolbar) as an overlay after the editor, on the view that holds the caret
92
92
 
93
93
  Place the editor container in an `EditorFrame`. The fixed toolbar and scroll
94
94
  container then occupy separate rows inside the same bounded layout.
@@ -121,39 +121,35 @@ Similarly, you can customize the floating toolbar by editing `components/editor/
121
121
 
122
122
  _Registry item `floating-toolbar`: `npx shadcn@latest add @plate/floating-toolbar`._
123
123
 
124
- ### Act on the view that holds the selection
124
+ ### Act where the caret is
125
125
 
126
126
  A nested view, such as the text of a [board](/docs/board) note, is an Editable
127
- of its own inside the page's Editable. A toolbar that a page slot renders gets
128
- the page editor from `useEditor()`. Wrap the buttons that should act on the
129
- nested view in `EditorSelectionView`:
127
+ of its own inside the page's Editable. Where a toolbar renders decides the view
128
+ it acts on:
129
+
130
+ - Outside every editing area, such as in `beforeContainer` where the fixed
131
+ toolbar renders, `useEditor()` returns the editor of the root that holds the
132
+ caret. With the caret in a note, the copied fixed toolbar's mark buttons
133
+ change the note.
134
+ - A plugin's `caret` slot renders after the Editable and follows the caret into
135
+ the views mounted inside its editing area. The copied floating toolbar, link
136
+ toolbar and AI menu render there, so they open beside selected note text.
137
+ - Inside an editing area, every other slot, such as `afterEditable`, keeps that
138
+ area's view.
130
139
 
131
140
  ```tsx
132
- import { EditorSelectionView } from 'platejs/react';
141
+ import { definePlugin } from 'platejs/react';
133
142
 
134
- <ToolbarGroup>
135
- <EditorSelectionView>
136
- <MarkToolbarButton plugin={HighlightPlugin} tooltip="Highlight">
137
- <HighlighterIcon />
138
- </MarkToolbarButton>
139
- <CommentToolbarButton />
140
- </EditorSelectionView>
141
- <AllCommentsButton />
142
- </ToolbarGroup>
143
+ const FloatingToolbarPlugin = definePlugin('floatingToolbar', {
144
+ slots: { caret: () => <FloatingToolbar /> },
145
+ });
143
146
  ```
144
147
 
145
- Inside it, `useEditor()`, `useEditableRef()`, `useEditorFocused()` and
146
- `useFocusedLast()` answer for the view whose root holds the selection. Children
147
- keep the page editor when the selection is on the page or no view of its root
148
- is mounted inside the page's Editable. A button outside the wrapper, such as
149
- All comments here, acts on the page.
150
-
151
- The copied `FloatingToolbar` wraps its whole body and positions itself against
152
- `useEditableRef()`, so it opens beside selected note text. There it shows Ask
153
- AI, the mark buttons and Comment. The copied `FixedToolbarButtons` wraps its
154
- mark, color, highlight and comment buttons. Undo, Insert and Turn into sit
155
- outside the wrapper and act on the page. The copied AI menu wraps itself the
156
- same way.
148
+ In the `caret` slot, `useEditor()`, `useEditableRef()`, `useEditorFocused()`
149
+ and `useFocusedLast()` answer for the view that holds the caret while that view
150
+ is mounted inside the slot's editing area, and for the slot's own view
151
+ otherwise. So a header `EditorContent`'s floating toolbar stays on the header
152
+ while the caret is in the body.
157
153
 
158
154
  ### Creating custom button
159
155
 
@@ -288,8 +284,8 @@ Plugin that renders a floating toolbar that appears on text selection.
288
284
 
289
285
  <API name="FloatingToolbarKit">
290
286
  <APIOptions>
291
- <APIItem name="slots.afterEditable" type="EditableSiblingComponent">
292
- Renders the floating toolbar as an overlay after the editor. Contains FloatingToolbarButtons by default.
287
+ <APIItem name="slots.caret" type="EditableSiblingComponent">
288
+ Renders the floating toolbar as an overlay after the editor, on the view that holds the caret. Contains FloatingToolbarButtons by default.
293
289
  </APIItem>
294
290
  </APIOptions>
295
291
  </API>
@@ -62,7 +62,7 @@ characters, and a positive `FILES_MAX_UPLOAD_SIZE`. Implement
62
62
  `resolveFilesAccess` in the copied `lib/files.ts` for your session and document
63
63
  ACL before accepting requests. It checks read and write access, including on
64
64
  the proxy upload `PUT`. The route's `documentId` is an application document ID,
65
- not an authorization token. Use 1–128 letters, digits, underscores, or hyphens
65
+ not an authorization token. Use 1 to 128 letters, digits, underscores, or hyphens
66
66
  for that ID. Return a stable tenant/document namespace shared by authorized
67
67
  collaborators.
68
68
 
@@ -129,6 +129,7 @@ the active `documentId`, as in the configuration above.
129
129
  editor.plugin(UploadPlugin).update.submit(files, { after: blockKey });
130
130
  editor.plugin(UploadPlugin).update.submit(files, { slot: draftKey });
131
131
  editor.plugin(UploadPlugin).api.cancel(draftKey);
132
+ editor.plugin(UploadPlugin).api.fitsAfter(draftKey);
132
133
  ```
133
134
 
134
135
  `submit` accepts `File[]` or `FileList`. It validates the whole batch before
@@ -138,6 +139,9 @@ draft. A cancel, a removal of the draft, a later update that replaces the whole
138
139
  document, or a destroyed editor before then sends no request, and an undo that
139
140
  brings the draft back does not restart it. A slot
140
141
  option fills an existing draft; block placement options insert new drafts.
142
+ A slot submit of several files gives the draft the first file and inserts a
143
+ draft for each other file after it. When those drafts do not fit there,
144
+ `submit` refuses the batch as `does-not-fit`.
141
145
  Without a placement option, `submit` inserts at the selection and replaces the
142
146
  selection's block when it is empty, as a paste does.
143
147
  Cancellation leaves an idle draft. A failed live task keeps its `File` for
@@ -150,6 +154,76 @@ element. A custom renderer can read
150
154
  `AggregateProgress` with `loaded`, `total`, and `fraction` (`0` to `1`).
151
155
  Unmounting a renderer does not restart an upload.
152
156
 
157
+ `api.fitsAfter(draftKey)` says whether a second draft of the same kind fits
158
+ after the draft, where a slot submit puts the draft of a second file. It writes
159
+ nothing and returns `false` for a key that names no upload draft. It reads the
160
+ committed document, so inside an update it does not see the drafts that update
161
+ inserted. The copied `UploadElement` asks it each time its file picker opens, and
162
+ the picker takes several files only when the answer is `true`. So a draft that is
163
+ the only block its container holds, such as the draft in a board's
164
+ [image shape](/docs/board#picture-files), picks one file.
165
+
166
+ ## Insert drafts yourself
167
+
168
+ `submit` inserts its drafts as blocks. A container that wraps each draft in an
169
+ element of its own, such as a gallery card or a board's
170
+ [image shape](/docs/board#picture-files), inserts the drafts itself. In one
171
+ update, check the batch with `admit`, insert the drafts it returns, then name
172
+ each file's draft with `fill`:
173
+
174
+ ```ts
175
+ import { BaseUploadPlugin } from 'platejs/upload';
176
+
177
+ editor.update((tx) => {
178
+ const batch = tx.plugin(BaseUploadPlugin).admit(files, { kind: 'image' });
179
+
180
+ if (!batch || 'failure' in batch) return;
181
+
182
+ tx.blocks.insert(
183
+ batch.drafts.map((draft) => ({ children: [draft], type: 'card' })),
184
+ { at: [0] }
185
+ );
186
+ batch.fill(
187
+ batch.drafts.flatMap((_draft, index) => tx.key([index, 0]) ?? [])
188
+ );
189
+ });
190
+ ```
191
+
192
+ Here `card` is an element of your app whose content takes one `image` or
193
+ `upload` element. The sample puts each draft in a card at the top of the
194
+ document, then reads each draft's key from the place where it sits.
195
+
196
+ `admit(files, { kind })` writes nothing and returns one of three values:
197
+
198
+ | Value | When |
199
+ | --- | --- |
200
+ | `undefined` | There is nothing to do: the list is empty, the view is a preview, or the editor is read-only or destroyed. |
201
+ | `{ failure }` | Upload refuses the batch. It passes `failure` to `onError` once, after the update commits. |
202
+ | `{ drafts, fill }` | The batch passed. `drafts` holds one new draft per file, in file order. |
203
+
204
+ With `kind`, a file of another upload kind refuses the batch before every other
205
+ check. The failure is `unsupported-file-type`. Its `files` hold only the files
206
+ of another kind and its `allowedTypes` hold the file types of `kind`, so you
207
+ can call `admit` again without those files. After that check, `admit` runs the
208
+ checks that `submit` runs: `rules`, `maxFiles`, the `client` and `getUrl`, and
209
+ an installed media plugin for each kind.
210
+
211
+ Upload does not track the drafts that `admit` returns. Insert them anywhere in
212
+ the same update, then call `fill(keys)` with the node key of each file's draft,
213
+ in file order. `fill` checks every key before it gives any file a draft:
214
+
215
+ - It takes one key per file, and no key twice.
216
+ - Each key names a live upload draft of its file's kind, outside a read-only
217
+ element.
218
+ - No named draft got a file earlier in the same update, from `submit` or `fill`.
219
+ - The batch has not been filled yet.
220
+
221
+ A failed check throws an error that names `fill` and gives no file a draft, and
222
+ a correct `fill` can follow a caught error. Each upload starts after the update
223
+ commits, as with `submit`. A draft that no `fill` names stays an idle draft and
224
+ uploads nothing. The batch lives for the update that admitted it, so call
225
+ `fill` inside that update.
226
+
153
227
  ## Dropped files
154
228
 
155
229
  The React `UploadPlugin` lands files dropped into the editor at the block edge
@@ -204,25 +278,37 @@ export const MyFileDropPlugin = definePlugin('myFileDrop', {
204
278
 
205
279
  An editor whose `UploadPlugin` has a `client`, a `getUrl`, and a rule with
206
280
  `kind: 'image'` uploads the pictures whose bytes come with a paste. These are
207
- raster `data` addresses in pasted HTML or in the editor's own clipboard, and the
281
+ raster `data` addresses in pasted HTML or in the editor's own clipboard, the
208
282
  pictures that [Word paste](/docs/docx#paste-from-word) rebuilds from the RTF
209
- copy. Each picture becomes an upload draft where it landed, so the document
210
- never stores its `data` address. Its upload starts after the paste commits, and
211
- the finished image keeps the picture's alt text, width, and caption. Without
212
- those three settings, pasted pictures stay as pasted. The copied `UploadKit`
213
- sets all three.
283
+ copy, and pictures with a `blob` address, such as a picture copied from Word in
284
+ Safari. A `blob` address works only in the tab that pasted it, so the paste
285
+ reads its bytes while it runs. Each picture becomes an upload draft where it
286
+ landed, so the document never stores its `data` or `blob` address. Its upload
287
+ starts after the paste commits, and the finished image keeps the picture's alt
288
+ text, width, and caption. Without those three settings, pasted pictures stay as
289
+ pasted. The copied `UploadKit` sets all three.
290
+
291
+ A `blob` picture uploads only when its bytes are a GIF, JPEG, PNG or WebP
292
+ image. Its file takes that type from the bytes and a name such as `image.png`.
293
+ A `blob` picture whose read fails, or whose bytes are of another kind, such as
294
+ SVG, keeps its pasted address while the other pictures upload. The paste reads
295
+ with a synchronous request. So a page whose Content Security Policy sets
296
+ `connect-src` without `blob:` keeps every `blob` picture as pasted, and so does
297
+ a page whose Permissions Policy blocks `sync-xhr` in Chromium. A real Word paste
298
+ in Safari is not yet tested.
214
299
 
215
300
  The paste checks its pictures as one batch against `rules` and `maxFiles`, as
216
- `submit` does. When those rules refuse the batch, every picture stays as pasted with
217
- its `data` address, so saves and collaborators still get its bytes, and
218
- `onError` runs once. The kit's image rule allows three files, so a paste of four
219
- or more pictures keeps them all as pasted. A picture whose address does not
220
- decode, or whose draft cannot sit where the picture landed, also stays as
221
- pasted while the other pictures upload.
301
+ `submit` does. When those rules refuse the batch, every picture keeps the
302
+ address it was pasted with, and `onError` runs once. The paste reads its
303
+ pictures in document order and stops once it holds more than the batch allows,
304
+ so `onError` gets the pictures read up to then. The kit's image rule allows
305
+ three files, so a paste of four or more pictures keeps them all as pasted. A
306
+ picture whose address does not decode, or whose draft cannot sit where the
307
+ picture landed, also stays as pasted while the other pictures upload.
222
308
 
223
309
  One undo removes the paste and its drafts and stops their uploads. Redo brings
224
- back the drafts without starting an upload. In a Suggesting view, the drafts and
225
- the finished images are the view author's suggestion.
310
+ back the drafts without starting an upload. A paste in a Suggesting view or into
311
+ a preview keeps every picture as pasted.
226
312
 
227
313
  A paste does not upload:
228
314
 
@@ -230,8 +316,8 @@ A paste does not upload:
230
316
  address, and the image plugin turns a plain-text picture link into such an
231
317
  image.
232
318
  - A picture that was in the document before the paste.
233
- - A picture from Word in Safari. Its `blob` address works only in the tab that
234
- pasted it.
319
+ - A picture inside a content root the paste adds, such as a copied card's body.
320
+ A paste that adds such a root also keeps every `blob` picture as pasted.
235
321
 
236
322
  An HTML drop uploads its pictures the same way. With the React `UploadPlugin`,
237
323
  a drop that carries files uploads those files instead, as
@@ -245,7 +331,10 @@ a drop that carries files uploads those files instead, as
245
331
  | `UploadPlugin` from `platejs/upload/react` | React adapter that lands dropped files at the block edge under the pointer. |
246
332
  | `UploadPlugin.configure({ initialState })` | Set `client: UploadClient`, synchronous `getUrl: (file: UploadOutcome) => string`, `rules`, `maxFiles`, and `onError`. |
247
333
  | `editor.plugin(UploadPlugin).update.submit(files, options)` | Insert a validated batch or fill a draft slot. Slot and block placement options are mutually exclusive. |
334
+ | `tx.plugin(BaseUploadPlugin).admit(files, { kind? })` | Check a batch for drafts the caller inserts itself. It writes nothing and returns `undefined`, an `UploadRefusal` or an `UploadAdmission`. |
335
+ | `fill(keys)` of an `UploadAdmission` | Give each file the draft its node key names, in file order. It throws when a key fails a check. |
248
336
  | `editor.plugin(UploadPlugin).api.cancel(key)` | Abort the live task for one draft. |
337
+ | `editor.plugin(UploadPlugin).api.fitsAfter(key)` | Say whether a second draft of the same kind fits after the draft at `key`. It writes nothing. |
249
338
 
250
339
  The draft has persisted type `upload` and a required `kind`, while its
251
340
  `File`, progress, and failure stay in editor state. Completed media stores a
@@ -1,6 +1,6 @@
1
- import { st as BasePluginInput, u as Editor } from "../../core-BJG8l_mk.js";
2
- import { n as EditorStaticProps } from "../../PlateStatic-DhNv2ejp.js";
3
- import { n as DocxComment, r as DocxDiagnostic, t as DocxSource } from "../../source-CNKy99Th.js";
1
+ import { st as BasePluginInput, u as Editor } from "../../core-BqR-fEDp.js";
2
+ import { n as EditorStaticProps } from "../../PlateStatic-D3Cb-QwH.js";
3
+ import { n as DocxComment, r as DocxDiagnostic, t as DocxSource } from "../../source-BGohy8vH.js";
4
4
  type UnitValue = number | string;
5
5
  type Margins = {
6
6
  bottom?: UnitValue;
@@ -1,6 +1,7 @@
1
1
  import { BaseHeadingPlugin } from "../../../features/basic-nodes/lib/BaseHeadingPlugins.js";
2
2
  import { BaseCodeBlockPlugin } from "../../../features/code-block/lib/BaseCodeBlockPlugin.js";
3
3
  import { BaseListPlugin, ListType } from "../../../features/list/lib/BaseListPlugin.js";
4
+ import { getDefaultElementTag } from "../../../internal/plugin/defaultElementTag.js";
4
5
  import { EditorElement } from "../../../static/components/plite-nodes.js";
5
6
  import { BaseCalloutPlugin } from "../../../features/callout/lib/BaseCalloutPlugin.js";
6
7
  import { BaseFootnoteDefinitionPlugin, BaseFootnotePlugin } from "../../../features/footnote/lib/BaseFootnotePlugin.js";
@@ -349,8 +350,17 @@ const listItemOf = (editor, element, path, list) => {
349
350
  default: return;
350
351
  }
351
352
  };
352
- const docxStaticOverrides = (story) => Object.freeze({
353
- components: DOCX_STATIC_COMPONENTS,
353
+ const textComponent = (text) => function DocxText(props) {
354
+ return /* @__PURE__ */ React.createElement(EditorElement, {
355
+ ...props,
356
+ as: getDefaultElementTag(props.attributes)
357
+ }, text({ node: props.element }), props.children);
358
+ };
359
+ const docxStaticOverrides = (story, textFormats) => Object.freeze({
360
+ components: {
361
+ ...DOCX_STATIC_COMPONENTS,
362
+ ...Object.fromEntries(textFormats.map(({ plugin, text }) => [plugin, textComponent(text)]))
363
+ },
354
364
  slots: { [BaseListPlugin.name]: { wrapNodeChildren: null } },
355
365
  wrapElement: ({ attributes, children, editor, element, path }) => {
356
366
  const item = editor.plugin(BaseListPlugin).installed ? listItemOf(editor, element, path, {