platejs 54.0.0-beta.2 → 54.0.0-beta.3

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 (237) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +56 -0
  3. package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DY104TqL.d.ts} +2 -2
  4. package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-Deo6n6Fs.d.ts} +7 -3
  5. package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-CJX5bKuv.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-DAOYWuvC.d.ts} +2 -2
  14. package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-Dt-unJZY-DCddmbSD.d.ts} +10 -2
  15. package/dist/compiler/index.d.ts +2 -2
  16. package/dist/{core-BJG8l_mk.d.ts → core-ClHasORr.d.ts} +433 -95
  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 +4 -2
  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/dom.md +14 -4
  24. package/dist/docs/api/editor-transforms.md +2 -1
  25. package/dist/docs/api/react-hooks.md +25 -11
  26. package/dist/docs/authored-changes.md +5 -2
  27. package/dist/docs/basic-blocks.md +42 -29
  28. package/dist/docs/blockquote.md +5 -3
  29. package/dist/docs/board.md +63 -8
  30. package/dist/docs/code-block.md +47 -0
  31. package/dist/docs/discussion.md +1 -1
  32. package/dist/docs/docx.md +1 -1
  33. package/dist/docs/dom-coverage.md +5 -0
  34. package/dist/docs/examples/editable-voids.md +2 -3
  35. package/dist/docs/external-text.md +2 -0
  36. package/dist/docs/field.md +370 -0
  37. package/dist/docs/find.md +9 -6
  38. package/dist/docs/form.md +2 -0
  39. package/dist/docs/heading.md +6 -0
  40. package/dist/docs/installation/manual.md +0 -4
  41. package/dist/docs/link.md +3 -3
  42. package/dist/docs/llms.txt +4 -2
  43. package/dist/docs/markdown.md +176 -8
  44. package/dist/docs/plugin-components.md +13 -10
  45. package/dist/docs/plugin-input-rules.md +4 -12
  46. package/dist/docs/prompt-editor.md +205 -0
  47. package/dist/docs/roots.md +8 -6
  48. package/dist/docs/rtl.md +6 -4
  49. package/dist/docs/selection.md +7 -4
  50. package/dist/docs/suggestion.md +1 -1
  51. package/dist/docs/toolbar.md +26 -30
  52. package/dist/docs/upload.md +106 -17
  53. package/dist/docx/export/index.d.ts +3 -3
  54. package/dist/docx/export/lib/docxStaticComponents.js +12 -2
  55. package/dist/docx/export/lib/exportDocx.js +29 -5
  56. package/dist/docx/export/lib/reviewPart.js +1 -1
  57. package/dist/docx/export/lib/reviewProjection.js +10 -8
  58. package/dist/docx/import/index.d.ts +4 -4
  59. package/dist/docx/paste/index.d.ts +4 -4
  60. package/dist/dom/index.d.ts +1 -6
  61. package/dist/dom/plite-dom.internal.js +2 -2
  62. package/dist/excalidraw/index.d.ts +3 -2
  63. package/dist/excalidraw/react/index.d.ts +3 -2
  64. package/dist/facade.js +2 -2
  65. package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +13 -5
  66. package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +32 -10
  67. package/dist/features/board/index.d.ts +2 -2
  68. package/dist/features/board/lib/BaseBoardPlugin.js +14 -1
  69. package/dist/features/board/lib/boardStroke.internal.js +13 -1
  70. package/dist/features/board/lib/boardTypes.internal.js +16 -0
  71. package/dist/features/callout/index.d.ts +3 -2
  72. package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -5
  73. package/dist/features/combobox/index.d.ts +2 -2
  74. package/dist/features/comments/index.d.ts +1 -1
  75. package/dist/features/date/index.d.ts +3 -2
  76. package/dist/features/details/index.d.ts +3 -2
  77. package/dist/features/details/lib/BaseDetailsPlugin.js +10 -10
  78. package/dist/features/field/index.d.ts +2 -0
  79. package/dist/features/field/index.js +2 -0
  80. package/dist/features/field/lib/BaseFieldPlugin.js +414 -0
  81. package/dist/features/field/lib/fieldRules.internal.js +42 -0
  82. package/dist/features/find/index.d.ts +3 -2
  83. package/dist/features/footnote/index.d.ts +1 -1
  84. package/dist/features/ink/index.d.ts +1 -1
  85. package/dist/features/ink/lib/BaseInkPlugin.js +126 -103
  86. package/dist/features/ink/lib/inkCodec.internal.js +130 -0
  87. package/dist/features/ink/lib/inkGone.internal.js +229 -48
  88. package/dist/features/ink/lib/inkPlaces.internal.js +533 -62
  89. package/dist/features/layout/index.d.ts +1 -1
  90. package/dist/features/link/lib/BaseLinkPlugin.js +6 -4
  91. package/dist/features/lint/index.d.ts +3 -2
  92. package/dist/features/media/index.d.ts +1 -1
  93. package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
  94. package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +6 -2
  95. package/dist/features/mention/index.d.ts +5 -4
  96. package/dist/features/suggestion/index.d.ts +1 -1
  97. package/dist/features/table/index.d.ts +1 -1
  98. package/dist/features/table/lib/BaseTablePlugin.js +14 -8
  99. package/dist/features/table/lib/internal/selection.js +4 -2
  100. package/dist/features/toc/index.d.ts +1 -1
  101. package/dist/features/upload/index.d.ts +2 -2
  102. package/dist/features/upload/lib/BaseUploadPlugin.js +464 -250
  103. package/dist/history/index.d.ts +2 -2
  104. package/dist/html/index.d.ts +3 -3
  105. package/dist/html/server/index.d.ts +1 -1
  106. package/dist/{htmlTypes-DjeFG3P8.d.ts → htmlTypes-cg_cWsaN.d.ts} +2 -31
  107. package/dist/hyperscript/index.d.ts +1 -1
  108. package/dist/{index-D1CFXA-i.d.ts → index-8WO2vI0U.d.ts} +475 -143
  109. package/dist/{index-DaM37gF6.d.ts → index-B5mYEawV.d.ts} +37 -21
  110. package/dist/{index-Bq3sdm3S.d.ts → index-BZWFoUXt.d.ts} +5 -4
  111. package/dist/{index-DdIRduDG.d.ts → index-C0POz7rg.d.ts} +3 -2
  112. package/dist/{index-Bxfvicyy.d.ts → index-C1_JIhL4.d.ts} +4 -3
  113. package/dist/{index-DC_MNGyu.d.ts → index-C35V_hj0.d.ts} +3 -3
  114. package/dist/{index-kLKMc-pI.d.ts → index-C6ql9pKw.d.ts} +2 -2
  115. package/dist/{index-hsC_sOn2.d.ts → index-C9DiGDVj.d.ts} +35 -5
  116. package/dist/{index-DTgaSxKr.d.ts → index-CLsEe3LY.d.ts} +40 -4
  117. package/dist/{index-CT7miqQN.d.ts → index-CdOLsPaW.d.ts} +29 -9
  118. package/dist/{index-DLA2DUR2.d.ts → index-CktYvOgk.d.ts} +4 -3
  119. package/dist/{index-BBKGrsG3.d.ts → index-Cmuluh6f.d.ts} +1 -1
  120. package/dist/{index-BiQerPJS.d.ts → index-CzLwBZpY.d.ts} +2 -2
  121. package/dist/{index-DzD6BIFJ.d.ts → index-D3-2iM1b.d.ts} +7 -5
  122. package/dist/{index-Cl77E9yr.d.ts → index-DKOFvteF.d.ts} +2 -2
  123. package/dist/{index-iaZOhA76.d.ts → index-DPWyk3lG-DOYwohXO.d.ts} +1 -1
  124. package/dist/index-DQnjqtQa.d.ts +678 -0
  125. package/dist/{index-CcZbqPqk.d.ts → index-Do9pj1GK.d.ts} +73 -39
  126. package/dist/{index-BU6k1Aev.d.ts → index-DpltOCot-A2b3p3Eb.d.ts} +4735 -4586
  127. package/dist/{index-Bc2Yg_2j.d.ts → index-HPYawTae-BCUQLEWF.d.ts} +2 -2
  128. package/dist/{index-BkR7-GLI.d.ts → index-baQOK89E.d.ts} +2 -2
  129. package/dist/{index-D5W-p9bS.d.ts → index-oIJAZxc2.d.ts} +49 -4
  130. package/dist/{index-xdmCBvlT.d.ts → index-r7yb77Wy.d.ts} +3 -2
  131. package/dist/index.d.ts +4 -4
  132. package/dist/{react/internal → internal}/penStroke.internal.js +1 -1
  133. package/dist/internal/plugin/OverridePlugin.js +101 -119
  134. package/dist/internal/plugin/collectPlateNodeMappings.js +5 -1
  135. package/dist/internal/plugin/pastedUploadFiles.js +4 -0
  136. package/dist/internal/plugin/resolvePlugin.js +1 -1
  137. package/dist/internal/plugin/resolvePlugins.js +3 -0
  138. package/dist/internal/plugin/uploadDrafts.js +6 -0
  139. package/dist/internal/utils/mergePlugins.js +1 -0
  140. package/dist/lib/plugins/element-id/ElementIdPlugin.js +8 -2
  141. package/dist/lib/plugins/html/HtmlPlugin.js +9 -0
  142. package/dist/lib/plugins/html/htmlSafety.js +1 -1
  143. package/dist/lib/plugins/input-rules/InputRulesPlugin.js +5 -15
  144. package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
  145. package/dist/markdown/index.d.ts +2 -2
  146. package/dist/markdown/index.js +2 -1
  147. package/dist/markdown/lib/MarkdownPlugin.js +16 -9
  148. package/dist/markdown/lib/RawHtmlPlugin.js +24 -0
  149. package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
  150. package/dist/markdown/lib/internal/markdownConversion.js +773 -74
  151. package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
  152. package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
  153. package/dist/markdown/lib/internal/markdownIntrinsics.js +125 -43
  154. package/dist/markdown/lib/internal/markdownLine.js +5 -3
  155. package/dist/markdown/lib/internal/markdownMappings.js +19 -7
  156. package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
  157. package/dist/markdown/lib/internal/markdownRawHtml.js +314 -0
  158. package/dist/markdown/lib/internal/markdownSegments.js +57 -48
  159. package/dist/markdown/lib/internal/markdownTags.js +22 -8
  160. package/dist/markdown/lib/serializer/convertNodesSerialize.js +10 -8
  161. package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
  162. package/dist/markdown/lib/serializer/listToMdastTree.js +2 -0
  163. package/dist/math/index.d.ts +3 -2
  164. package/dist/math/react/index.d.ts +4 -3
  165. package/dist/migrations/index.d.ts +3 -3
  166. package/dist/pagination/index.d.ts +1 -1
  167. package/dist/pagination/react/index.d.ts +4 -4
  168. package/dist/react/components/EditorContentView.internal.js +17 -8
  169. package/dist/react/components/EditorProvider.js +5 -5
  170. package/dist/react/components/Plate.js +103 -122
  171. package/dist/react/components/PlateContainer.js +40 -32
  172. package/dist/react/components/PlateController.js +28 -16
  173. package/dist/react/components/PlateRoot.internal.js +3 -2
  174. package/dist/react/core.js +4 -4
  175. package/dist/react/features/board/BoardSurface.js +116 -87
  176. package/dist/react/features/board/boardClipboard.internal.js +15 -5
  177. package/dist/react/features/board/boardGesture.internal.js +6 -3
  178. package/dist/react/features/board/boardIndex.internal.js +7 -18
  179. package/dist/react/features/board/boardPictures.internal.js +19 -13
  180. package/dist/react/features/board/boardView.internal.js +184 -49
  181. package/dist/react/features/board/boardVoice.internal.js +10 -11
  182. package/dist/react/features/board/index.d.ts +64 -18
  183. package/dist/react/features/callout/index.d.ts +3 -2
  184. package/dist/react/features/combobox/index.d.ts +8 -8
  185. package/dist/react/features/comments/index.d.ts +6 -5
  186. package/dist/react/features/date/index.d.ts +4 -3
  187. package/dist/react/features/details/index.d.ts +4 -3
  188. package/dist/react/features/field/FieldPlugin.js +34 -0
  189. package/dist/react/features/field/index.d.ts +312 -0
  190. package/dist/react/features/field/index.js +2 -0
  191. package/dist/react/features/footnote/index.d.ts +7 -6
  192. package/dist/react/features/format-painter/index.d.ts +4 -3
  193. package/dist/react/features/ink/InkContent.js +313 -0
  194. package/dist/react/features/ink/index.d.ts +57 -29
  195. package/dist/react/features/ink/index.js +2 -2
  196. package/dist/react/features/ink/inkCapture.internal.js +39 -17
  197. package/dist/react/features/ink/inkInput.internal.js +1 -1
  198. package/dist/react/features/ink/inkLayout.internal.js +6 -3
  199. package/dist/react/features/ink/inkPaint.internal.js +78 -2
  200. package/dist/react/features/ink/inkPlacement.internal.js +331 -104
  201. package/dist/react/features/ink/inkWatch.internal.js +7 -5
  202. package/dist/react/features/layout/index.d.ts +5 -4
  203. package/dist/react/features/media/index.d.ts +5 -4
  204. package/dist/react/features/mention/index.d.ts +6 -5
  205. package/dist/react/features/resizable/Resizable.js +4 -6
  206. package/dist/react/features/resizable/index.d.ts +5 -5
  207. package/dist/react/features/suggestion/index.d.ts +6 -5
  208. package/dist/react/features/table/TablePlugin.js +4 -11
  209. package/dist/react/features/table/index.d.ts +8 -7
  210. package/dist/react/features/toc/index.d.ts +2 -2
  211. package/dist/react/features/upload/index.d.ts +11 -6
  212. package/dist/react/index.d.ts +6 -6
  213. package/dist/react/index.js +4 -4
  214. package/dist/react/internal/plate-context.js +425 -188
  215. package/dist/react/plite-react.js +2 -2
  216. package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +12 -10
  217. package/dist/react/stores/plate/useEditor.js +32 -14
  218. package/dist/react/stores/plate/useEditorHistory.js +55 -0
  219. package/dist/react/stores/plate/useEditorSelector.js +66 -21
  220. package/dist/react/utils/pipeRenderElement.internal.js +1 -1
  221. package/dist/react/utils/pluginRenderElement.internal.js +1 -1
  222. package/dist/react/virtualized.d.ts +4 -4
  223. package/dist/{source-CNKy99Th.d.ts → source-aUwpNnAw.d.ts} +4 -4
  224. package/dist/static/index.d.ts +18 -18
  225. package/dist/static/internal/renderStaticHtmlWithOverrides.js +2 -2
  226. package/dist/static/internal/staticPresentation.js +4 -4
  227. package/dist/static/internal/writeStaticSelectionClipboardData.js +7 -2
  228. package/dist/tabbable/index.d.ts +1 -1
  229. package/dist/tabbable/react/index.d.ts +3 -3
  230. package/dist/testing/index.d.ts +3 -3
  231. package/dist/yjs/index.d.ts +1 -1
  232. package/dist/yjs/react/index.d.ts +6 -6
  233. package/package.json +20 -2
  234. package/dist/markdown/lib/serializer/convertTextsSerialize.js +0 -163
  235. package/dist/react/components/EditorSelectionView.js +0 -40
  236. package/dist/react/features/ink/InkLayer.js +0 -218
  237. package/dist/react/internal/createPlateTargetScope.js +0 -62
@@ -0,0 +1,226 @@
1
+ import { TextApi } from "../../../core.js";
2
+ import { RawHtmlPlugin } from "../RawHtmlPlugin.js";
3
+ import { encodeRawHtmlLeaves } from "../internal/markdownIntrinsics.js";
4
+ import { getMarkdownMarkWriter } from "../internal/markdownMappings.js";
5
+ //#region src/markdown/lib/serializer/convertPhrasingSerialize.ts
6
+ const SPANNING_KINDS = /* @__PURE__ */ new Set([
7
+ "delete",
8
+ "emphasis",
9
+ "strong"
10
+ ]);
11
+ const LEADING_SPACES = /^ +/;
12
+ const TRAILING_SPACES = / +$/;
13
+ const convertPhrasingSerialize = (nodes, options, encodeInline, hardBreaks) => {
14
+ const { mappings } = options;
15
+ const plainMarkSet = new Set(options.plainMarks);
16
+ const writerOf = (leaf, key) => plainMarkSet.has(key) ? void 0 : getMarkdownMarkWriter(mappings, key, leaf[key]);
17
+ const ownWriterOf = (leaf, key) => leaf[key] && !options.enclosedMarks?.get(leaf)?.has(key) ? writerOf(leaf, key) : void 0;
18
+ const reportOmitted = (leaf) => {
19
+ for (const [key, value] of Object.entries(leaf)) {
20
+ if (key === "text" || !value || key === RawHtmlPlugin.name && options.rawHtml || plainMarkSet.has(key) || writerOf(leaf, key) !== void 0 || options.state.schema.property({
21
+ key,
22
+ placement: "text"
23
+ })?.role === "metadata") continue;
24
+ options.report({
25
+ code: "markdown-property-omitted",
26
+ key,
27
+ message: `Markdown cannot represent text property "${key}"; it was omitted.`,
28
+ model: {
29
+ ...options.modelLocation(leaf),
30
+ property: key
31
+ },
32
+ owner: key,
33
+ phase: "serialize",
34
+ reason: "unsupported",
35
+ severity: "warning"
36
+ });
37
+ }
38
+ };
39
+ const marksOf = (leaf) => {
40
+ const marks = [];
41
+ let code = false;
42
+ for (const key of mappings.markOrder) {
43
+ const writer = ownWriterOf(leaf, key);
44
+ if (!writer) continue;
45
+ switch (writer.kind) {
46
+ case "delete":
47
+ case "emphasis":
48
+ case "strong":
49
+ marks.push({
50
+ container: {
51
+ children: [],
52
+ type: writer.kind
53
+ },
54
+ key
55
+ });
56
+ break;
57
+ case "inlineCode":
58
+ code = true;
59
+ break;
60
+ case "wrap": {
61
+ const node = writer.wrap?.(leaf, options);
62
+ if (node && isMdMarkContainer(node)) marks.push({
63
+ container: {
64
+ ...node,
65
+ children: []
66
+ },
67
+ key
68
+ });
69
+ break;
70
+ }
71
+ }
72
+ }
73
+ return {
74
+ code,
75
+ marks
76
+ };
77
+ };
78
+ const spanningMarksOf = (leaves) => {
79
+ const written = leaves.filter((leaf) => leaf.text);
80
+ return written[0] ? marksOf(written[0]).marks.filter(({ container, key }) => SPANNING_KINDS.has(container.type) && written.every((leaf) => ownWriterOf(leaf, key)?.kind === container.type)) : [];
81
+ };
82
+ const items = [];
83
+ for (const node of nodes) {
84
+ if (TextApi.isText(node)) {
85
+ reportOmitted(node);
86
+ const { code, marks } = marksOf(node);
87
+ if (!code && node[RawHtmlPlugin.name] === true && options.rawHtml && options.rawHtml.refused !== "all" && !options.rawHtml.refused?.has(node)) {
88
+ if (node.text) items.push({
89
+ content: [encodeRawHtmlLeaves([node])],
90
+ marks
91
+ });
92
+ continue;
93
+ }
94
+ const lines = hardBreaks ? node.text.split(/\r?\n/) : [node.text];
95
+ const breakMarks = marks.filter(({ container }) => SPANNING_KINDS.has(container.type));
96
+ lines.forEach((value, index) => {
97
+ if (index > 0) items.push({
98
+ content: [{ type: "break" }],
99
+ marks: breakMarks
100
+ });
101
+ if (value) items.push({
102
+ content: [{
103
+ type: code ? "inlineCode" : "text",
104
+ value
105
+ }],
106
+ marks
107
+ });
108
+ });
109
+ continue;
110
+ }
111
+ const leaves = textsOf(node);
112
+ const spanning = spanningMarksOf(leaves);
113
+ const enclosedMarks = /* @__PURE__ */ new WeakMap();
114
+ for (const leaf of leaves) enclosedMarks.set(leaf, /* @__PURE__ */ new Set([...options.enclosedMarks?.get(leaf) ?? [], ...spanning.map(({ key }) => key)]));
115
+ items.push({
116
+ content: encodeInline(node, spanning.length > 0 ? {
117
+ ...options,
118
+ enclosedMarks
119
+ } : options),
120
+ marks: spanning
121
+ });
122
+ }
123
+ const carries = (item, mark) => !!item?.marks.some((other) => other.key === mark.key && sameContainer(other.container, mark.container));
124
+ const runEnds = items.map(() => /* @__PURE__ */ new Map());
125
+ for (let index = items.length - 1; index >= 0; index -= 1) for (const mark of items[index].marks) runEnds[index].set(mark.key, carries(items[index + 1], mark) ? runEnds[index + 1].get(mark.key) ?? index : index);
126
+ const root = [];
127
+ const own = /* @__PURE__ */ new WeakSet();
128
+ const open = [];
129
+ const target = () => open.at(-1)?.node.children ?? root;
130
+ items.forEach((item, index) => {
131
+ const kept = open.findIndex((entry) => !carries(item, entry.mark));
132
+ if (kept !== -1) open.splice(kept);
133
+ const runEnd = (mark) => runEnds[index].get(mark.key) ?? index;
134
+ const longestRunFirst = (left, right) => runEnd(right) - runEnd(left);
135
+ const opening = item.marks.filter((mark) => !open.some((entry) => entry.mark.key === mark.key)).sort(longestRunFirst);
136
+ for (const mark of opening) {
137
+ const node = {
138
+ ...mark.container,
139
+ children: []
140
+ };
141
+ own.add(node);
142
+ target().push(node);
143
+ open.push({
144
+ mark,
145
+ node
146
+ });
147
+ }
148
+ target().push(...item.content);
149
+ });
150
+ return mergePhrasing(withEdgesOutside(root, own), own);
151
+ };
152
+ const isOwn = (own, node) => !!node && own.has(node);
153
+ const copyOwn = (own, node, children) => {
154
+ const copy = {
155
+ ...node,
156
+ children
157
+ };
158
+ own.add(copy);
159
+ return copy;
160
+ };
161
+ const textsOf = (node) => TextApi.isText(node) ? [node] : "children" in node ? node.children.flatMap(textsOf) : [];
162
+ const isMdMarkContainer = (node) => node.type === "delete" || node.type === "emphasis" || node.type === "mdxJsxTextElement" || node.type === "strong";
163
+ const takeEdgeWhitespace = (children, end) => {
164
+ const taken = [];
165
+ for (;;) {
166
+ const index = end === "start" ? 0 : children.length - 1;
167
+ const edge = children[index];
168
+ if (edge?.type === "break") {
169
+ children.splice(index, 1);
170
+ taken.push(edge);
171
+ continue;
172
+ }
173
+ if (edge?.type !== "text") break;
174
+ const spaces = (end === "start" ? LEADING_SPACES : TRAILING_SPACES).exec(edge.value)?.[0];
175
+ if (!spaces) break;
176
+ taken.push({
177
+ type: "text",
178
+ value: spaces
179
+ });
180
+ const rest = end === "start" ? edge.value.slice(spaces.length) : edge.value.slice(0, -spaces.length);
181
+ if (rest) {
182
+ children[index] = {
183
+ ...edge,
184
+ value: rest
185
+ };
186
+ break;
187
+ }
188
+ children.splice(index, 1);
189
+ }
190
+ return end === "start" ? taken : taken.reverse();
191
+ };
192
+ /**
193
+ * A delimiter run cannot open before or close after a space or a line break,
194
+ * so the spaces and line breaks at the ends of a container are written
195
+ * outside it.
196
+ */
197
+ const withEdgesOutside = (nodes, own) => nodes.flatMap((node) => {
198
+ if (!isOwn(own, node)) return [node];
199
+ const children = withEdgesOutside(node.children, own);
200
+ const before = takeEdgeWhitespace(children, "start");
201
+ const after = takeEdgeWhitespace(children, "end");
202
+ return [
203
+ ...before,
204
+ ...children.some((child) => hasContent(child, own)) ? [copyOwn(own, node, children)] : [],
205
+ ...after
206
+ ];
207
+ });
208
+ const hasContent = (node, own) => node.type === "text" || node.type === "inlineCode" ? node.value !== "" : !isOwn(own, node) || node.children.some((child) => hasContent(child, own));
209
+ const sameContainer = (left, right) => left.type === right.type && (left.type !== "mdxJsxTextElement" || left.name === right.name && JSON.stringify(left.attributes) === JSON.stringify(right.attributes));
210
+ const mergePhrasing = (nodes, own) => {
211
+ const merged = [];
212
+ for (const node of nodes) {
213
+ const last = merged.at(-1);
214
+ if (node.type === "text" && node.value === "") continue;
215
+ if (last?.type === "text" && node.type === "text" || last?.type === "inlineCode" && node.type === "inlineCode") merged[merged.length - 1] = {
216
+ ...last,
217
+ value: last.value + node.value
218
+ };
219
+ else if (isOwn(own, last) && isOwn(own, node) && sameContainer(last, node)) merged[merged.length - 1] = copyOwn(own, last, mergePhrasing([...last.children, ...node.children], own));
220
+ else if (isOwn(own, node)) merged.push(copyOwn(own, node, mergePhrasing(node.children, own)));
221
+ else merged.push(node);
222
+ }
223
+ return merged;
224
+ };
225
+ //#endregion
226
+ export { convertPhrasingSerialize };
@@ -1,4 +1,5 @@
1
1
  import { failInvariant } from "../../../internal/failInvariant.js";
2
+ import { TextApi } from "../../../core.js";
2
3
  import { getMarkdownParagraphType } from "../../../internal/plugin/markdownParagraph.js";
3
4
  import { getDocumentListOrdinal } from "../../../features/list/lib/listIndex.internal.js";
4
5
  import { encodeMarkdownParagraph } from "../internal/markdownIntrinsics.js";
@@ -226,6 +227,7 @@ const listToMdastTree = (nodes, options) => {
226
227
  node
227
228
  });
228
229
  openNestedList(listItem, stackTop, currentIndent, nextNode);
230
+ if (listItem.checked === null && listItem.children[1]?.type === "list" && node.type === paragraphType && node.children.every((child) => TextApi.isText(child) && !child.text)) listItem.children.shift();
229
231
  }
230
232
  return root;
231
233
  };
@@ -1,5 +1,6 @@
1
- import { Aa as PluginReference, Mc as ElementOf, Qo as TxDeclaredMethod, Ru as BaseRange, eo as Value, vl as PropertyStringDescriptor, xr as EditorReadMethodTree } from "../index-BU6k1Aev.js";
2
- import { Co as PluginSchemaDeclaration, Wr as BlockFenceInputRuleMatch, _ as BasePlugin, _t as NodeInsertOptions, bo as PluginReference$1, d as InferBaseEditorPlugins, ei as InsertBreakInputRule, f as InternalBaseEditorWithInstalledPlugins, gi as SelectionInputRuleContext, mt as InternalInstalledSchemaDefinitionsProvider, oi as InsertTextInputRule } from "../core-BJG8l_mk.js";
1
+ import { Mo as PluginReference, eu as TxDeclaredMethod, is as PropertyStringDescriptor, ki as ElementOf, ru as Value, un as EditorReadMethodTree, x as BaseRange } from "../index-DpltOCot-A2b3p3Eb.js";
2
+ import "../htmlTypes-cg_cWsaN.js";
3
+ import { Wr as BlockFenceInputRuleMatch, _ as BasePlugin, _t as NodeInsertOptions, d as InferBaseEditorPlugins, ei as InsertBreakInputRule, f as InternalBaseEditorWithInstalledPlugins, gi as SelectionInputRuleContext, mt as InternalInstalledSchemaDefinitionsProvider, oi as InsertTextInputRule, wo as PluginSchemaDeclaration, xo as PluginReference$1 } from "../core-ClHasORr.js";
3
4
  declare const BaseEquationPlugin: BasePlugin<Readonly<{
4
5
  formats: true;
5
6
  }> & Readonly<{
@@ -1,6 +1,7 @@
1
- import { Qo as TxDeclaredMethod, vl as PropertyStringDescriptor } from "../../index-BU6k1Aev.js";
2
- import { _t as NodeInsertOptions } from "../../core-BJG8l_mk.js";
3
- import { At as Plugin } from "../../index-D1CFXA-i.js";
1
+ import { eu as TxDeclaredMethod, is as PropertyStringDescriptor } from "../../index-DpltOCot-A2b3p3Eb.js";
2
+ import "../../htmlTypes-cg_cWsaN.js";
3
+ import { _t as NodeInsertOptions } from "../../core-ClHasORr.js";
4
+ import { At as Plugin } from "../../index-8WO2vI0U.js";
4
5
  declare const EquationPlugin: Plugin<Readonly<{
5
6
  formats: true;
6
7
  }> & Readonly<{
@@ -1,6 +1,6 @@
1
- import { $u as EditorJsonValue, Aa as PluginReference, Ju as Path, Ln as EditorDocumentValue, Os as Descendant, Wr as EditorStateSchemaApi, gs as Selection, ta as PersistedDocumentInput, zu as Range } from "../index-BU6k1Aev.js";
2
- import { h as EditorApplicationSchema } from "../htmlTypes-DjeFG3P8.js";
3
- import "../core-BJG8l_mk.js";
1
+ import { H as Descendant, Mc as Selection, Mo as PluginReference, Tt as EditorDocumentValue, Vt as EditorJsonValue, Za as Path, no as PersistedDocumentInput, us as Range, vr as EditorStateSchemaApi } from "../index-DpltOCot-A2b3p3Eb.js";
2
+ import { h as EditorApplicationSchema } from "../htmlTypes-cg_cWsaN.js";
3
+ import "../core-ClHasORr.js";
4
4
  type NamedEditorApplicationSchema = EditorApplicationSchema & Readonly<{
5
5
  id: string;
6
6
  version: number;
@@ -1,4 +1,4 @@
1
- import { $u as EditorJsonValue, Ec as Element, Ju as Path, Lr as EditorStateField, Mc as ElementOf, Qi as NamedRootKey, eo as Value, ln as Editor, wc as TextOf, zu as Range } from "../index-BU6k1Aev.js";
1
+ import { Si as Element, Vt as EditorJsonValue, Y as Editor, Za as Path, dr as EditorStateField, ki as ElementOf, na as NamedRootKey, ru as Value, us as Range, xl as TextOf } from "../index-DpltOCot-A2b3p3Eb.js";
2
2
  type PagePreset = 'a4' | 'letter';
3
3
  type PageMargins = number | Readonly<{
4
4
  bottom: number;
@@ -1,7 +1,7 @@
1
- import { Ba as RootKey, Ec as Element } from "../../index-BU6k1Aev.js";
2
- import { Cr as EditableProps, _n as EditorContentProps } from "../../index-D1CFXA-i.js";
1
+ import { Si as Element, xs as RootKey } from "../../index-DpltOCot-A2b3p3Eb.js";
2
+ import { Wn as EditableProps, _n as EditorContentProps } from "../../index-8WO2vI0U.js";
3
3
  import { MeasurePagesOptions, NodeFragmentationPlan, NodeFragmentationProvider, PageLayoutBlock, PageLayoutBlockStyle, PageLayoutEngine, PageLayoutEngineInput, PageLayoutEngineOutput, PageLayoutFragment, PageLayoutMode, PageLayoutPage, PageLayoutRun, PageLayoutSize, PageLayoutSnapshot, PageLayoutTextStyle, PageLayoutTypography, PageMargins, PagePreset, PageRect, PageSettings, PageSettingsJson, PageSettingsSource, PretextPageLayoutEngineOptions, createEstimatedPageLayoutEngine, createPretextPageLayoutEngine, measurePages, pageSettingsCodec } from "../index.js";
4
- import React, { CSSProperties, ReactNode, RefObject } from "react";
4
+ import React$1, { CSSProperties, ReactNode, RefObject } from "react";
5
5
  declare const usePageLayout: (editableRef: RefObject<HTMLDivElement | null>) => PageLayoutSnapshot | null;
6
6
  type MountedFragment = Readonly<{
7
7
  pageIndex: number;
@@ -33,5 +33,5 @@ type PagedEditorContentProps<TElement extends Element = Element, TRoot extends R
33
33
  * renderers, handlers and slots, laid out by `PagedEditable`. The app owns
34
34
  * `fragmentation` sizes and `typography`; keep both stable across renders.
35
35
  */
36
- declare const PagedEditorContent: <TElement extends Element = Element, TRoot extends RootKey = RootKey>({ engine, fragmentation, page, pageView, renderPage, typography, virtualize, ...props }: PagedEditorContentProps<TElement, TRoot>) => React.JSX.Element;
36
+ declare const PagedEditorContent: <TElement extends Element = Element, TRoot extends RootKey = RootKey>({ engine, fragmentation, page, pageView, renderPage, typography, virtualize, ...props }: PagedEditorContentProps<TElement, TRoot>) => React$1.JSX.Element;
37
37
  export { MeasurePagesOptions, NodeFragmentationPlan, NodeFragmentationProvider, PageLayoutBlock, PageLayoutBlockStyle, PageLayoutEngine, PageLayoutEngineInput, PageLayoutEngineOutput, PageLayoutFragment, PageLayoutMode, PageLayoutPage, PageLayoutRun, PageLayoutSize, PageLayoutSnapshot, PageLayoutTextStyle, PageLayoutTypography, PageMargins, PagePreset, PageRect, PageSettings, PageSettingsJson, PageSettingsSource, type PagedEditablePageAttributes, type PagedEditablePageView, type PagedEditableRenderPageProps, PagedEditorContent, type PagedEditorContentProps, PretextPageLayoutEngineOptions, createEstimatedPageLayoutEngine, createPretextPageLayoutEngine, measurePages, pageSettingsCodec, usePageLayout, usePageLayoutFragments };
@@ -5,7 +5,7 @@ import { mergePlateRenderedAttributes } from "../../internal/mergePlateRenderedA
5
5
  import { isEditOnly } from "../../internal/plugin/isEditOnlyDisabled.js";
6
6
  import { useComposedRef } from "../internal/react-helpers.js";
7
7
  import { getHandlerView } from "../internal/plite-components.js";
8
- import { usePlateModel } from "../internal/plate-context.js";
8
+ import { PlateCaretSlots, PlateReadOnlyContext, usePlateModel } from "../internal/plate-context.js";
9
9
  import { useEditor } from "../stores/plate/useEditor.js";
10
10
  import { usePlateModelRevision } from "../internal/usePlateModelRevision.js";
11
11
  import { PlateRenderedAttributeProvider } from "../internal/rendered-attributes.js";
@@ -30,7 +30,8 @@ const getPlateContentReadOnly = ({ disabled, plateReadOnly, readOnly }) => disab
30
30
  function EditorContentView(t0) {
31
31
  const $ = c(15);
32
32
  const { autoFocusOnEditable, editable, editableExtra, readOnly: readOnlyProp, ref, ...props } = t0;
33
- const { editor, readOnly: plateReadOnly } = usePlateModel();
33
+ const { editor } = usePlateModel();
34
+ const plateReadOnly = React.use(PlateReadOnlyContext);
34
35
  const editableRef = useRef(null);
35
36
  const previousElementRef = useRef(null);
36
37
  const [viewGeneration, setViewGeneration] = React.useState(0);
@@ -52,7 +53,7 @@ function EditorContentView(t0) {
52
53
  const combinedRef = useComposedRef(ref, t1);
53
54
  const readOnly = getPlateContentReadOnly({
54
55
  disabled: props.disabled,
55
- plateReadOnly: plateReadOnly ?? editor.read.view.isReadOnly(),
56
+ plateReadOnly,
56
57
  readOnly: readOnlyProp
57
58
  });
58
59
  if (!editor) throw new Error("Editor not found. Render EditorContent inside EditorRoot.");
@@ -217,22 +218,30 @@ function EditorContentBranch({ autoFocusOnEditable, editable: Editable, editable
217
218
  const AfterEditable = plugin_0.slots.afterEditable ?? failInvariant("Expected value to be defined");
218
219
  afterEditable = /* @__PURE__ */ React.createElement(React.Fragment, null, afterEditable, /* @__PURE__ */ React.createElement(AfterEditable, { editableRef }));
219
220
  });
221
+ const caretSlots = getPlateRuntime(editor).pluginCache.slots.caret.flatMap((name_1) => {
222
+ const plugin_1 = getCompiledPlatePlugin(editor, name_1) ?? failInvariant("Expected value to be defined");
223
+ if (isEditOnly(plateReadOnly, plugin_1, "slots")) return [];
224
+ return [{
225
+ Caret: plugin_1.slots.caret ?? failInvariant("Expected value to be defined"),
226
+ name: name_1
227
+ }];
228
+ });
220
229
  let content = /* @__PURE__ */ React.createElement(PlateRenderedAttributeProvider, null, /* @__PURE__ */ React.createElement(Editable, {
221
230
  ...editableExtra,
222
231
  ...editableProps,
223
232
  ref
224
233
  }), /* @__PURE__ */ React.createElement(EditorRefEffect, null), /* @__PURE__ */ React.createElement(TapOrderEffect, { editableRef }));
225
- getPlateRuntime(editor).pluginCache.slots.wrapContent.forEach((name_1) => {
226
- const plugin_1 = getCompiledPlatePlugin(editor, name_1) ?? failInvariant("Expected value to be defined");
227
- if (isEditOnly(plateReadOnly, plugin_1, "slots")) return;
228
- const WrapContent = plugin_1.slots.wrapContent ?? failInvariant("Expected value to be defined");
234
+ getPlateRuntime(editor).pluginCache.slots.wrapContent.forEach((name_2) => {
235
+ const plugin_2 = getCompiledPlatePlugin(editor, name_2) ?? failInvariant("Expected value to be defined");
236
+ if (isEditOnly(plateReadOnly, plugin_2, "slots")) return;
237
+ const WrapContent = plugin_2.slots.wrapContent ?? failInvariant("Expected value to be defined");
229
238
  content = /* @__PURE__ */ React.createElement(WrapContent, null, content);
230
239
  });
231
240
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(EditorContentStateEffect, {
232
241
  autoFocusOnEditable,
233
242
  editor,
234
243
  readOnly: plateReadOnly
235
- }), beforeEditable, content, afterEditable);
244
+ }), beforeEditable, content, afterEditable, caretSlots.length > 0 && /* @__PURE__ */ React.createElement(PlateCaretSlots, { slots: caretSlots }));
236
245
  }
237
246
  function EditorContentStateEffect(t0) {
238
247
  const $ = c(5);
@@ -1,4 +1,4 @@
1
- import { PlateTargetProvider, getPlateTarget } from "../internal/plate-context.js";
1
+ import { PlateScopeContext, getPlateTarget, useFixedScope } from "../internal/plate-context.js";
2
2
  import React from "react";
3
3
  import { c } from "react/compiler-runtime";
4
4
  //#region src/react/components/EditorProvider.tsx
@@ -18,12 +18,12 @@ function EditorProvider(t0) {
18
18
  $[0] = editor;
19
19
  $[1] = t1;
20
20
  } else t1 = $[1];
21
- const target = t1;
21
+ const scope = useFixedScope(t1);
22
22
  let t2;
23
- if ($[2] !== children || $[3] !== target) {
24
- t2 = /* @__PURE__ */ React.createElement(PlateTargetProvider, { target }, children);
23
+ if ($[2] !== children || $[3] !== scope) {
24
+ t2 = /* @__PURE__ */ React.createElement(PlateScopeContext, { value: scope }, children);
25
25
  $[2] = children;
26
- $[3] = target;
26
+ $[3] = scope;
27
27
  $[4] = t2;
28
28
  } else t2 = $[4];
29
29
  return t2;