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
@@ -3,22 +3,22 @@ import { TextApi } from "../../../core.js";
3
3
  import { getMarkdownParagraphType, landsMarkdownParagraph } from "../../../internal/plugin/markdownParagraph.js";
4
4
  import { listItemDepth } from "../../../features/list/lib/listIndex.internal.js";
5
5
  import { encodeMarkdownParagraph, getMarkdownParagraphLanding } from "../internal/markdownIntrinsics.js";
6
- import { convertTextsSerialize } from "./convertTextsSerialize.js";
6
+ import { convertPhrasingSerialize } from "./convertPhrasingSerialize.js";
7
7
  import { reportOmittedProperties } from "./reportOmittedProperties.js";
8
8
  import { continueMarkdownList, isSameMarkdownList, listToMdastTree } from "./listToMdastTree.js";
9
9
  //#region src/markdown/lib/serializer/convertNodesSerialize.ts
10
10
  const NO_CLAIMS = /* @__PURE__ */ new Set();
11
- const convertNodesSerialize = (nodes, options) => {
11
+ const convertNodesSerialize = (nodes, options, { hardBreaks = false } = {}) => {
12
12
  const mdastNodes = [];
13
- let textQueue = [];
13
+ let phrasing = [];
14
14
  const listBlock = [];
15
15
  let restartedFrom;
16
16
  for (let i = 0; i <= nodes.length; i++) {
17
17
  const node = nodes[i];
18
- if (node && TextApi.isText(node)) textQueue.push(node);
18
+ if (node && (TextApi.isText(node) || options.isInline(node))) phrasing.push(node);
19
19
  else {
20
- if (textQueue.length > 0) mdastNodes.push(...convertTextsSerialize(textQueue, options));
21
- textQueue = [];
20
+ if (phrasing.length > 0) mdastNodes.push(...convertPhrasingSerialize(phrasing, options, buildMdastNodes, hardBreaks));
21
+ phrasing = [];
22
22
  if (!node) continue;
23
23
  if (isListElement(node, options) || isListContinuation(listBlock, node)) {
24
24
  listBlock.push(node);
@@ -72,12 +72,14 @@ const buildMdastNodes = (node, options) => {
72
72
  reportOmittedProperties(node, encoded.claimed, options, encoded.owner);
73
73
  return encoded.nodes;
74
74
  };
75
+ const mayContinueListItem = (node) => !!node && !TextApi.isText(node) && node.listType === void 0 && typeof node.indent === "number" && node.indent >= 2;
75
76
  const isListContinuation = (run, node) => {
76
- if (!node || TextApi.isText(node) || node.listType !== void 0 || typeof node.indent !== "number" || node.indent < 2) return false;
77
+ if (!mayContinueListItem(node)) return false;
77
78
  const ownerIndent = node.indent - 1;
78
79
  const owner = run.findLast((block) => listItemDepth(block) <= ownerIndent);
79
80
  return owner !== void 0 && listItemDepth(owner) === ownerIndent && owner.listType !== void 0;
80
81
  };
81
82
  const isListElement = (node, options) => !!node && !TextApi.isText(node) && typeof node.listType === "string" && (node.type === getMarkdownParagraphType(options.registry) || node.type === options.registry.type(PLUGINS.image));
83
+ const mayJoinList = (node, options) => isListElement(node, options) || mayContinueListItem(node);
82
84
  //#endregion
83
- export { buildMdastNodes, convertNodesSerialize, encodeMdastNode };
85
+ export { buildMdastNodes, convertNodesSerialize, encodeMdastNode, mayJoinList };
@@ -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 { Fo as PluginReference, dn as EditorReadMethodTree, iu as TxDeclaredMethod, ji as ElementOf, ss as PropertyStringDescriptor, su as Value, x as BaseRange } from "../index-BXjLmx1n-CXk17buG.js";
2
+ import "../htmlTypes-eT2ZGDAj.js";
3
+ import { Co as PluginReference$1, Eo as PluginSchemaDeclaration, Wr as BlockFenceInputRuleMatch, _ as BasePlugin, _t as NodeInsertOptions, d as InferBaseEditorPlugins, f as InternalBaseEditorWithInstalledPlugins, li as InsertTextInputRule, mt as InternalInstalledSchemaDefinitionsProvider, ti as InsertBreakInputRule, yi as SelectionInputRuleContext } from "../core-BqR-fEDp.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 { iu as TxDeclaredMethod, ss as PropertyStringDescriptor } from "../../index-BXjLmx1n-CXk17buG.js";
2
+ import "../../htmlTypes-eT2ZGDAj.js";
3
+ import { _t as NodeInsertOptions } from "../../core-BqR-fEDp.js";
4
+ import { At as Plugin } from "../../index-DPowErHa.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 { $a as Path, Fc as Selection, Fo as PluginReference, H as Descendant, Ht as EditorJsonValue, Tt as EditorDocumentValue, io as PersistedDocumentInput, ps as Range, yr as EditorStateSchemaApi } from "../index-BXjLmx1n-CXk17buG.js";
2
+ import { h as EditorApplicationSchema } from "../htmlTypes-eT2ZGDAj.js";
3
+ import "../core-BqR-fEDp.js";
4
4
  type NamedEditorApplicationSchema = EditorApplicationSchema & Readonly<{
5
5
  id: string;
6
6
  version: number;
@@ -75,10 +75,7 @@ const createStageMapper = (schema, before, after) => {
75
75
  const shapeDocument = (context, document) => {
76
76
  const inputs = migratePlateV54Inputs({
77
77
  ...context,
78
- document: migratePlateV54RetiredMarks({
79
- ...context,
80
- document
81
- })
78
+ document
82
79
  });
83
80
  const profile = migratePlateV54Profile({
84
81
  ...context,
@@ -112,8 +109,9 @@ const shapeDocument = (context, document) => {
112
109
  */
113
110
  const migrateV54 = (context) => {
114
111
  const schema = context.target.schema;
115
- const legacy = migratePlateV54Suggestions(context.document);
116
- const shapedSource = shapeDocument(context, context.document);
112
+ const source = migratePlateV54RetiredMarks(context);
113
+ const legacy = migratePlateV54Suggestions(source);
114
+ const shapedSource = shapeDocument(context, source);
117
115
  const { ast, codeBlocks, inputs, profile, urls } = shapedSource;
118
116
  const toProfile = createStageMapper(schema, inputs.document, profile);
119
117
  const toAst = createStageMapper(schema, profile, ast);
@@ -1,10 +1,13 @@
1
1
  import { SelectionApi, TextApi, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates } from "../facade.js";
2
2
  import { V53_RETIRED_TEXT_MARKS } from "./v53-manifest.internal.js";
3
+ import { createPropertyOwnership } from "./migratePlateV54Ownership.internal.js";
4
+ import { isRecord } from "./migratePlateV54Suggestions.internal.js";
3
5
  //#region src/migrations/migratePlateV54RetiredMarks.internal.ts
4
6
  const undeclaredRetiredMarks = (target) => {
5
7
  const compiled = getCompiledEditorSchemaFromApi(target.schema);
6
8
  return compiled ? [...V53_RETIRED_TEXT_MARKS].filter((key) => getCompiledPropertyCandidates(compiled, "text", key).length === 0) : [];
7
9
  };
10
+ const changedByLegacyUpdate = (properties, key) => Object.entries(properties).some(([name, data]) => (name === "suggestion" || name.startsWith("suggestion_")) && isRecord(data) && [data.properties, data.newProperties].some((changed) => isRecord(changed) && Object.hasOwn(changed, key)));
8
11
  const withoutKeys = (properties, keys) => {
9
12
  if (!keys.some((key) => Object.hasOwn(properties, key))) return properties;
10
13
  const next = { ...properties };
@@ -15,18 +18,24 @@ const V53_NODE_LISTS = ["caption", "children"];
15
18
  const migratePlateV54RetiredMarks = ({ document, target }) => {
16
19
  const retired = undeclaredRetiredMarks(target);
17
20
  if (retired.length === 0) return document;
18
- const migrateList = (list) => {
19
- const next = list.map(migrateNode);
21
+ const { ownsProperty } = createPropertyOwnership(target);
22
+ const migrateList = (list, context) => {
23
+ const next = list.map((node) => migrateNode(node, context));
20
24
  return next.every((node, index) => node === list[index]) ? list : next;
21
25
  };
22
- const migrateNode = (node) => {
23
- if (TextApi.isText(node)) return withoutKeys(node, retired);
26
+ const migrateNode = (node, context) => {
27
+ if (TextApi.isText(node)) return withoutKeys(node, retired.filter((key) => !changedByLegacyUpdate(node, key)));
24
28
  if (typeof node !== "object" || node === null) return node;
25
29
  const record = node;
30
+ const type = String(record.type);
31
+ const childContext = {
32
+ ancestors: [type, ...context.ancestors],
33
+ root: context.root
34
+ };
26
35
  const changed = V53_NODE_LISTS.flatMap((key) => {
27
36
  const list = record[key];
28
- if (!Array.isArray(list)) return [];
29
- const migrated = migrateList(list);
37
+ if (!Array.isArray(list) || key === "caption" && ownsProperty(type, key, context)) return [];
38
+ const migrated = migrateList(list, childContext);
30
39
  return migrated === list ? [] : [[key, migrated]];
31
40
  });
32
41
  return changed.length > 0 ? {
@@ -34,8 +43,14 @@ const migratePlateV54RetiredMarks = ({ document, target }) => {
34
43
  ...Object.fromEntries(changed)
35
44
  } : record;
36
45
  };
37
- const children = migrateList(document.children);
38
- const roots = document.roots ? Object.fromEntries(Object.entries(document.roots).map(([root, rootChildren]) => [root, migrateList(rootChildren)])) : void 0;
46
+ const children = migrateList(document.children, {
47
+ ancestors: [],
48
+ root: null
49
+ });
50
+ const roots = document.roots ? Object.fromEntries(Object.entries(document.roots).map(([root, rootChildren]) => [root, migrateList(rootChildren, {
51
+ ancestors: [],
52
+ root
53
+ })])) : void 0;
39
54
  if (children === document.children && (!roots || Object.entries(roots).every(([root, rootChildren]) => rootChildren === document.roots?.[root]))) return document;
40
55
  return {
41
56
  ...document,
@@ -59,7 +59,7 @@ const parseSuggestionData = (value, location, keyedId) => {
59
59
  };
60
60
  const legacyKeys = (node) => Object.keys(node).filter((key) => key.startsWith(LEGACY_SUGGESTION_PREFIX));
61
61
  const hasLegacyMetadata = (node) => Object.hasOwn(node, "suggestion") || Object.hasOwn(node, "suggestionData") || Object.hasOwn(node, "suggestionTransient") || legacyKeys(node).length > 0;
62
- const stripLegacyMetadata = (node) => Object.fromEntries(Object.entries(node).filter(([key]) => key !== "suggestion" && !LEGACY_TRANSIENT_KEYS.has(key) && !key.startsWith(LEGACY_SUGGESTION_PREFIX)));
62
+ const stripLegacyMetadata = (node) => Object.fromEntries(Object.entries(node).filter(([key]) => key !== "suggestion" && !LEGACY_TRANSIENT_KEYS.has(key) && !key.startsWith("suggestion_")));
63
63
  const validateProposedProperties = (node, data, location) => {
64
64
  if (data.type !== "update") return;
65
65
  const proposed = data.newProperties ?? {};
@@ -233,4 +233,4 @@ const migratePlateV54ReplacementText = (nodes, text, location) => {
233
233
  };
234
234
  const migratePlateV54DrawingCodeText = (drawing, code) => markedText(code, reviewMarks(drawing).filter(covers));
235
235
  //#endregion
236
- export { migratePlateV54DrawingCodeText, migratePlateV54ReplacementText, migratePlateV54Suggestions };
236
+ export { LEGACY_SUGGESTION_PREFIX, isRecord, migratePlateV54DrawingCodeText, migratePlateV54ReplacementText, migratePlateV54Suggestions };
@@ -176,6 +176,10 @@ const V53_FIRST_PARTY_IDENTITIES = [
176
176
  kind: "element-rename",
177
177
  owner: "paragraph"
178
178
  },
179
+ {
180
+ identity: "rawHtml",
181
+ kind: "mark-retired"
182
+ },
179
183
  {
180
184
  identity: "search_highlight",
181
185
  kind: "transient"
@@ -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 { $a as Path, Ci as Element, Ht as EditorJsonValue, Y as Editor, fr as EditorStateField, ia as NamedRootKey, ji as ElementOf, ps as Range, su as Value, wl as TextOf } from "../index-BXjLmx1n-CXk17buG.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 { Ci as Element, ws as RootKey } from "../../index-BXjLmx1n-CXk17buG.js";
2
+ import { Wn as EditableProps, _n as EditorContentProps } from "../../index-DPowErHa.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 };
@@ -3,9 +3,10 @@ import { failInvariant } from "../../internal/failInvariant.js";
3
3
  import { getCompiledPlatePlugin, getPlateRuntime } from "../../internal/plugin/compilePlateModel.js";
4
4
  import { mergePlateRenderedAttributes } from "../../internal/mergePlateRenderedAttributes.js";
5
5
  import { isEditOnly } from "../../internal/plugin/isEditOnlyDisabled.js";
6
+ import { EditorReadOnlyProvider } from "../plite-react.js";
6
7
  import { useComposedRef } from "../internal/react-helpers.js";
7
- import { getHandlerView } from "../internal/plite-components.js";
8
- import { usePlateModel } from "../internal/plate-context.js";
8
+ import { getHandlerView, useOptionalEditorContext } from "../internal/plite-components.js";
9
+ import { PlateCaretSlots, PlateEditorPlaceholderContext, PlateReadOnlyContext, getPlateTarget, usePlateModel } from "../internal/plate-context.js";
9
10
  import { useEditor } from "../stores/plate/useEditor.js";
10
11
  import { usePlateModelRevision } from "../internal/usePlateModelRevision.js";
11
12
  import { PlateRenderedAttributeProvider } from "../internal/rendered-attributes.js";
@@ -28,9 +29,11 @@ import omit from "lodash/omit.js";
28
29
  //#region src/react/components/EditorContentView.internal.tsx
29
30
  const getPlateContentReadOnly = ({ disabled, plateReadOnly, readOnly }) => disabled ? true : readOnly ?? plateReadOnly ?? false;
30
31
  function EditorContentView(t0) {
31
- const $ = c(15);
32
+ const $ = c(18);
32
33
  const { autoFocusOnEditable, editable, editableExtra, readOnly: readOnlyProp, ref, ...props } = t0;
33
- const { editor, readOnly: plateReadOnly } = usePlateModel();
34
+ const { editor } = usePlateModel();
35
+ const plateReadOnly = React.use(PlateReadOnlyContext);
36
+ const enclosingView = useOptionalEditorContext();
34
37
  const editableRef = useRef(null);
35
38
  const previousElementRef = useRef(null);
36
39
  const [viewGeneration, setViewGeneration] = React.useState(0);
@@ -52,13 +55,14 @@ function EditorContentView(t0) {
52
55
  const combinedRef = useComposedRef(ref, t1);
53
56
  const readOnly = getPlateContentReadOnly({
54
57
  disabled: props.disabled,
55
- plateReadOnly: plateReadOnly ?? editor.read.view.isReadOnly(),
58
+ plateReadOnly,
56
59
  readOnly: readOnlyProp
57
60
  });
58
61
  if (!editor) throw new Error("Editor not found. Render EditorContent inside EditorRoot.");
59
- let t2;
62
+ const t2 = readOnlyProp === void 0 && (enclosingView === null || getPlateTarget(enclosingView) === void 0) ? void 0 : readOnly;
63
+ let t3;
60
64
  if ($[2] !== autoFocusOnEditable || $[3] !== combinedRef || $[4] !== editable || $[5] !== editableExtra || $[6] !== props || $[7] !== readOnly || $[8] !== readOnlyProp) {
61
- t2 = /* @__PURE__ */ React.createElement(EditorContentBranch, {
65
+ t3 = /* @__PURE__ */ React.createElement(EditorContentBranch, {
62
66
  ...props,
63
67
  ref: combinedRef,
64
68
  editableRef,
@@ -75,23 +79,30 @@ function EditorContentView(t0) {
75
79
  $[6] = props;
76
80
  $[7] = readOnly;
77
81
  $[8] = readOnlyProp;
78
- $[9] = t2;
79
- } else t2 = $[9];
80
- let t3;
81
- if ($[10] !== props.root || $[11] !== readOnly || $[12] !== t2 || $[13] !== viewGeneration) {
82
- t3 = /* @__PURE__ */ React.createElement(PlateRoot, {
82
+ $[9] = t3;
83
+ } else t3 = $[9];
84
+ let t4;
85
+ if ($[10] !== props.root || $[11] !== readOnly || $[12] !== t3 || $[13] !== viewGeneration) {
86
+ t4 = /* @__PURE__ */ React.createElement(PlateRoot, {
83
87
  key: viewGeneration,
84
88
  editableRef,
85
89
  readOnly,
86
90
  root: props.root
87
- }, t2);
91
+ }, t3);
88
92
  $[10] = props.root;
89
93
  $[11] = readOnly;
90
- $[12] = t2;
94
+ $[12] = t3;
91
95
  $[13] = viewGeneration;
92
- $[14] = t3;
93
- } else t3 = $[14];
94
- return t3;
96
+ $[14] = t4;
97
+ } else t4 = $[14];
98
+ let t5;
99
+ if ($[15] !== t2 || $[16] !== t4) {
100
+ t5 = /* @__PURE__ */ React.createElement(EditorReadOnlyProvider, { readOnly: t2 }, t4);
101
+ $[15] = t2;
102
+ $[16] = t4;
103
+ $[17] = t5;
104
+ } else t5 = $[17];
105
+ return t5;
95
106
  }
96
107
  function _temp(generation) {
97
108
  return generation + 1;
@@ -217,22 +228,30 @@ function EditorContentBranch({ autoFocusOnEditable, editable: Editable, editable
217
228
  const AfterEditable = plugin_0.slots.afterEditable ?? failInvariant("Expected value to be defined");
218
229
  afterEditable = /* @__PURE__ */ React.createElement(React.Fragment, null, afterEditable, /* @__PURE__ */ React.createElement(AfterEditable, { editableRef }));
219
230
  });
231
+ const caretSlots = getPlateRuntime(editor).pluginCache.slots.caret.flatMap((name_1) => {
232
+ const plugin_1 = getCompiledPlatePlugin(editor, name_1) ?? failInvariant("Expected value to be defined");
233
+ if (isEditOnly(plateReadOnly, plugin_1, "slots")) return [];
234
+ return [{
235
+ Caret: plugin_1.slots.caret ?? failInvariant("Expected value to be defined"),
236
+ name: name_1
237
+ }];
238
+ });
220
239
  let content = /* @__PURE__ */ React.createElement(PlateRenderedAttributeProvider, null, /* @__PURE__ */ React.createElement(Editable, {
221
240
  ...editableExtra,
222
241
  ...editableProps,
223
242
  ref
224
- }), /* @__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");
243
+ }), /* @__PURE__ */ React.createElement(PlateEditorPlaceholderContext, { value: Boolean(editableProps.placeholder) }, /* @__PURE__ */ React.createElement(EditorRefEffect, null)), /* @__PURE__ */ React.createElement(TapOrderEffect, { editableRef }));
244
+ getPlateRuntime(editor).pluginCache.slots.wrapContent.forEach((name_2) => {
245
+ const plugin_2 = getCompiledPlatePlugin(editor, name_2) ?? failInvariant("Expected value to be defined");
246
+ if (isEditOnly(plateReadOnly, plugin_2, "slots")) return;
247
+ const WrapContent = plugin_2.slots.wrapContent ?? failInvariant("Expected value to be defined");
229
248
  content = /* @__PURE__ */ React.createElement(WrapContent, null, content);
230
249
  });
231
250
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(EditorContentStateEffect, {
232
251
  autoFocusOnEditable,
233
252
  editor,
234
253
  readOnly: plateReadOnly
235
- }), beforeEditable, content, afterEditable);
254
+ }), beforeEditable, content, afterEditable, caretSlots.length > 0 && /* @__PURE__ */ React.createElement(PlateCaretSlots, { slots: caretSlots }));
236
255
  }
237
256
  function EditorContentStateEffect(t0) {
238
257
  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;