platejs 54.0.0-beta.3 → 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 (150) hide show
  1. package/dist/{AIChatRequestContext-DY104TqL.d.ts → AIChatRequestContext-DrUahdTc.d.ts} +2 -2
  2. package/dist/{BaseSuggestionPlugin-Deo6n6Fs.d.ts → BaseSuggestionPlugin-_7Ka6nY3.d.ts} +4 -4
  3. package/dist/{PlateStatic-CJX5bKuv.d.ts → PlateStatic-D3Cb-QwH.d.ts} +3 -3
  4. package/dist/ai/index.d.ts +1 -1
  5. package/dist/ai/react/index.d.ts +9 -9
  6. package/dist/authored/index.d.ts +3 -3
  7. package/dist/code-block/codemirror/index.d.ts +1 -1
  8. package/dist/{combobox-DAOYWuvC.d.ts → combobox-Dr0OYZIE.d.ts} +2 -2
  9. package/dist/{comparison-types-Dt-unJZY-DCddmbSD.d.ts → comparison-types-DdwE6mYq-BogsHoUO.d.ts} +1 -1
  10. package/dist/compiler/index.d.ts +2 -2
  11. package/dist/{core-ClHasORr.d.ts → core-BqR-fEDp.d.ts} +65 -26
  12. package/dist/diff/index.d.ts +2 -2
  13. package/dist/docs/api/core/plate-controller.md +1 -1
  14. package/dist/docs/api/core.md +45 -5
  15. package/dist/docs/api/dom.md +4 -7
  16. package/dist/docs/api/react-hooks.md +40 -22
  17. package/dist/docs/authored-changes.md +4 -2
  18. package/dist/docs/block-placeholder.md +4 -2
  19. package/dist/docs/board.md +57 -4
  20. package/dist/docs/comment.md +2 -2
  21. package/dist/docs/document-model.md +15 -3
  22. package/dist/docs/editor.md +50 -4
  23. package/dist/docs/llms.txt +1 -1
  24. package/dist/docs/markdown.md +97 -9
  25. package/dist/docs/plugin-input-rules.md +62 -3
  26. package/dist/docx/export/index.d.ts +3 -3
  27. package/dist/docx/export/lib/exportDocx.js +18 -13
  28. package/dist/docx/export/lib/internal/xml-builder.js +11 -16
  29. package/dist/docx/export/lib/reviewProjection.js +43 -3
  30. package/dist/docx/import/index.d.ts +4 -4
  31. package/dist/docx/paste/index.d.ts +4 -4
  32. package/dist/dom/index.d.ts +1 -1
  33. package/dist/excalidraw/index.d.ts +3 -3
  34. package/dist/excalidraw/react/index.d.ts +3 -3
  35. package/dist/facade.js +2 -2
  36. package/dist/features/board/index.d.ts +1 -1
  37. package/dist/features/callout/index.d.ts +3 -3
  38. package/dist/features/combobox/index.d.ts +2 -2
  39. package/dist/features/comments/BaseCommentsPlugin.js +33 -17
  40. package/dist/features/comments/index.d.ts +1 -1
  41. package/dist/features/date/index.d.ts +3 -3
  42. package/dist/features/details/index.d.ts +3 -3
  43. package/dist/features/details/lib/BaseDetailsPlugin.js +15 -2
  44. package/dist/features/field/index.d.ts +2 -2
  45. package/dist/features/field/index.js +4 -2
  46. package/dist/features/field/lib/BaseFieldPlugin.js +51 -105
  47. package/dist/features/field/lib/applyFieldValues.js +188 -0
  48. package/dist/features/field/lib/fieldRules.internal.js +169 -7
  49. package/dist/features/find/index.d.ts +3 -3
  50. package/dist/features/footnote/index.d.ts +1 -1
  51. package/dist/features/ink/index.d.ts +1 -1
  52. package/dist/features/ink/lib/inkGone.internal.js +6 -6
  53. package/dist/features/ink/lib/inkPlaces.internal.js +8 -9
  54. package/dist/features/layout/index.d.ts +1 -1
  55. package/dist/features/lint/index.d.ts +3 -3
  56. package/dist/features/media/index.d.ts +2 -2
  57. package/dist/features/media/index.js +2 -2
  58. package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +200 -2
  59. package/dist/features/mention/index.d.ts +5 -5
  60. package/dist/features/suggestion/index.d.ts +1 -1
  61. package/dist/features/table/index.d.ts +1 -1
  62. package/dist/features/table/lib/BaseTablePlugin.js +50 -7
  63. package/dist/features/toc/index.d.ts +1 -1
  64. package/dist/features/upload/index.d.ts +1 -1
  65. package/dist/history/index.d.ts +2 -2
  66. package/dist/html/index.d.ts +3 -3
  67. package/dist/html/server/index.d.ts +1 -1
  68. package/dist/{htmlTypes-cg_cWsaN.d.ts → htmlTypes-eT2ZGDAj.d.ts} +1 -1
  69. package/dist/hyperscript/index.d.ts +1 -1
  70. package/dist/{index-D3-2iM1b.d.ts → index-B33E1CRJ.d.ts} +291 -4
  71. package/dist/{index-DKOFvteF.d.ts → index-B7moSod7.d.ts} +1 -1
  72. package/dist/{index-C9DiGDVj.d.ts → index-B8-5Sr7I.d.ts} +2 -2
  73. package/dist/{index-CzLwBZpY.d.ts → index-B8QJDAmG.d.ts} +2 -2
  74. package/dist/{index-Cmuluh6f.d.ts → index-BTx5oK7k.d.ts} +1 -1
  75. package/dist/{index-DPWyk3lG-DOYwohXO.d.ts → index-BWPcE4ac-Cto_IsNs.d.ts} +7 -1
  76. package/dist/{index-DpltOCot-A2b3p3Eb.d.ts → index-BXjLmx1n-CXk17buG.d.ts} +75 -27
  77. package/dist/{index-C6ql9pKw.d.ts → index-BXwU9QH6.d.ts} +2 -2
  78. package/dist/{index-CLsEe3LY.d.ts → index-BkwR-5hH.d.ts} +3 -3
  79. package/dist/{index-BZWFoUXt.d.ts → index-BsV2McRr.d.ts} +5 -5
  80. package/dist/{index-DQnjqtQa.d.ts → index-C9Fu-P4E.d.ts} +116 -21
  81. package/dist/{index-oIJAZxc2.d.ts → index-Ca48r1ng.d.ts} +3 -3
  82. package/dist/{index-Do9pj1GK.d.ts → index-Cob_iBdu.d.ts} +47 -6
  83. package/dist/{index-C1_JIhL4.d.ts → index-CpY7Xnxw.d.ts} +4 -4
  84. package/dist/{index-baQOK89E.d.ts → index-DNQXzU-X.d.ts} +1 -1
  85. package/dist/{index-8WO2vI0U.d.ts → index-DPowErHa.d.ts} +18 -20
  86. package/dist/{index-B5mYEawV.d.ts → index-DShbzec2.d.ts} +5 -6
  87. package/dist/{index-C35V_hj0.d.ts → index-DYdObeFQ.d.ts} +3 -3
  88. package/dist/{index-HPYawTae-BCUQLEWF.d.ts → index-Dq3Jlj8O-BJ6NxZm0.d.ts} +1 -1
  89. package/dist/{index-CdOLsPaW.d.ts → index-DwWQVwQt.d.ts} +3 -5
  90. package/dist/{index-r7yb77Wy.d.ts → index-JWgwL5l3.d.ts} +5 -3
  91. package/dist/{index-CktYvOgk.d.ts → index-M781pyx9.d.ts} +4 -4
  92. package/dist/{index-C0POz7rg.d.ts → index-d7io3MzC.d.ts} +3 -3
  93. package/dist/index.d.ts +4 -4
  94. package/dist/lib/plugins/element-id/ElementIdPlugin.js +6 -16
  95. package/dist/lib/plugins/input-rules/InputRulesPlugin.js +73 -14
  96. package/dist/markdown/index.d.ts +2 -2
  97. package/dist/markdown/index.js +2 -1
  98. package/dist/markdown/lib/MarkdownPlugin.js +8 -12
  99. package/dist/markdown/lib/RawHtmlPlugin.js +4 -2
  100. package/dist/markdown/lib/internal/markdownConversion.js +7 -4
  101. package/dist/markdown/lib/internal/markdownFootnoteWriter.js +35 -0
  102. package/dist/markdown/lib/internal/markdownRawHtml.js +40 -1
  103. package/dist/markdown/lib/internal/markdownTags.js +7 -1
  104. package/dist/math/index.d.ts +3 -3
  105. package/dist/math/react/index.d.ts +4 -4
  106. package/dist/migrations/index.d.ts +3 -3
  107. package/dist/migrations/migratePlateV54.js +4 -6
  108. package/dist/migrations/migratePlateV54RetiredMarks.internal.js +23 -8
  109. package/dist/migrations/migratePlateV54Suggestions.internal.js +2 -2
  110. package/dist/migrations/v53-manifest.internal.js +4 -0
  111. package/dist/pagination/index.d.ts +1 -1
  112. package/dist/pagination/react/index.d.ts +2 -2
  113. package/dist/react/components/EditorContentView.internal.js +26 -16
  114. package/dist/react/components/Plate.js +13 -20
  115. package/dist/react/features/board/boardExport.internal.js +470 -0
  116. package/dist/react/features/board/boardPictureStyles.internal.js +415 -0
  117. package/dist/react/features/board/boardView.internal.js +11 -6
  118. package/dist/react/features/board/index.d.ts +50 -6
  119. package/dist/react/features/callout/index.d.ts +3 -3
  120. package/dist/react/features/combobox/index.d.ts +5 -5
  121. package/dist/react/features/comments/index.d.ts +6 -6
  122. package/dist/react/features/date/index.d.ts +4 -4
  123. package/dist/react/features/details/index.d.ts +4 -4
  124. package/dist/react/features/field/FieldPlugin.js +5 -4
  125. package/dist/react/features/field/index.d.ts +19 -16
  126. package/dist/react/features/footnote/index.d.ts +7 -7
  127. package/dist/react/features/format-painter/index.d.ts +4 -4
  128. package/dist/react/features/ink/index.d.ts +5 -9
  129. package/dist/react/features/ink/inkPlacement.internal.js +2 -1
  130. package/dist/react/features/layout/index.d.ts +5 -5
  131. package/dist/react/features/media/index.d.ts +5 -5
  132. package/dist/react/features/mention/index.d.ts +6 -6
  133. package/dist/react/features/suggestion/index.d.ts +6 -6
  134. package/dist/react/features/table/index.d.ts +7 -6
  135. package/dist/react/features/table/useTableResize.js +10 -1
  136. package/dist/react/features/toc/index.d.ts +2 -2
  137. package/dist/react/features/upload/index.d.ts +5 -5
  138. package/dist/react/index.d.ts +6 -6
  139. package/dist/react/internal/plate-context.js +20 -11
  140. package/dist/react/stores/plate/useEditorSelector.js +22 -9
  141. package/dist/react/utils/BlockPlaceholderPlugin.js +5 -2
  142. package/dist/react/virtualized.d.ts +2 -2
  143. package/dist/{source-aUwpNnAw.d.ts → source-BGohy8vH.d.ts} +3 -3
  144. package/dist/static/index.d.ts +5 -5
  145. package/dist/tabbable/index.d.ts +1 -1
  146. package/dist/tabbable/react/index.d.ts +3 -3
  147. package/dist/testing/index.d.ts +2 -2
  148. package/dist/yjs/index.d.ts +1 -1
  149. package/dist/yjs/react/index.d.ts +5 -5
  150. package/package.json +2 -2
@@ -24,7 +24,9 @@ Each rule declares a target (`insertText`, `insertBreak`, or `insertData`), an
24
24
  optional `enabled` gate, a `resolve` function that looks at the current
25
25
  selection and returns a match payload, and an `apply` function that performs the
26
26
  transform. The first rule whose `resolve` returns a non-undefined payload gets
27
- to run; if nothing matches, the default transform runs as usual.
27
+ to run; if nothing matches, the default transform runs as usual. An `insertData`
28
+ rule can declare `followUp` instead of `apply` to run after the paste lands, as
29
+ [Follow-up paste rules](#follow-up-paste-rules) describes.
28
30
 
29
31
  Ownership splits cleanly into three lanes:
30
32
 
@@ -679,6 +681,7 @@ rule matches, the original command runs normally.
679
681
  | `enabled` | Policy gate, evaluated first |
680
682
  | `resolve` | Computes the match payload passed to `apply` |
681
683
  | `apply` | Mutates `tx`, then consumes, returns `next(...)`, or returns `decline()` |
684
+ | `followUp` | Replaces `apply` on an `insertData` rule and runs after the paste lands, as its own undo step |
682
685
  | `priority` | Sort order for rules on the same target |
683
686
  | `on` | Block-fence commit mode: `'match'` or `'break'` |
684
687
  | `mimeTypes` | Narrows an `insertData` rule to specific MIME types |
@@ -691,6 +694,60 @@ callout", "only fire when this plugin is active" — belongs in `enabled`. Retur
691
694
  and makes rules harder to compose.
692
695
  </Callout>
693
696
 
697
+ ### Follow-up paste rules
698
+
699
+ An `insertData` rule can declare `followUp` instead of `apply`. A follow-up rule
700
+ leaves the paste alone and runs after it, as its own undo step. One undo takes
701
+ back the follow-up's change and keeps the paste. A second undo takes back the
702
+ paste when history saved nothing between the two.
703
+
704
+ ```ts
705
+ import { defineInputRule, NodeApi } from 'platejs';
706
+
707
+ const spaceAfterPastedLink = defineInputRule({
708
+ target: 'insertData',
709
+ resolve: ({ text }) =>
710
+ text && /^https?:\/\/\S+$/.test(text) ? text : undefined,
711
+ followUp: ({ tx }, link) => {
712
+ const block = tx.nodes.block();
713
+
714
+ if (!block || !NodeApi.string(block[0]).endsWith(link)) return;
715
+
716
+ tx.text.insert(' ', { at: tx.points.end(block[1]) });
717
+ },
718
+ });
719
+ ```
720
+
721
+ - The runtime resolves follow-up rules against the state that `insertData`
722
+ starts from, apart from the rules that have `apply`. The first follow-up rule
723
+ whose `resolve` returns a payload runs, whichever rule took the paste.
724
+ - `followUp` runs only after a local paste that landed content and that undo
725
+ history saved, on the view that pasted. It never runs after a collaborator's
726
+ change, an undo, a redo or a document replacement, in an editor without
727
+ history, or when the view that pasted is read-only. It never runs when the
728
+ paste's commit changed nothing in the root the pasting view edits. It also
729
+ never runs after the editable's paste over a projected selection whose
730
+ deletion removed content, because that deletion runs before `insertData`
731
+ starts.
732
+ - `followUp` gets a transaction and the match, and no range of what the paste
733
+ wrote. A commit listener, a cleanup or an update that wraps the paste can
734
+ change the document before the follow-up runs, so a follow-up finds what it
735
+ acts on from its match and checks it before it writes. A match that a
736
+ follow-up writes at must carry a node key, or a root with its path, because a
737
+ bare path addresses the main root of the view that pasted.
738
+ - The follow-up writes at the pasting view's intent, so in Suggesting mode its
739
+ change is a suggestion. A rule that must not propose checks that intent
740
+ before it writes.
741
+ - `resolve` reads the clipboard data the paste started with. A rule with
742
+ `apply` that rewrites the data through `next(newData)` does not get the new
743
+ data matched again.
744
+ - `resolve` and `followUp` must be synchronous. A `resolve` that returns a
745
+ promise throws before the paste lands, a `followUp` that returns one throws,
746
+ and the editor reports each promise's rejection.
747
+ - Declare a follow-up rule through `defineInputRule`. It checks that `followUp`
748
+ takes what `resolve` returns, and `inputRules` refuses a follow-up rule
749
+ written as a plain object.
750
+
694
751
  ## API Reference
695
752
 
696
753
  Low-level surface. Reach for this when the high-level factories don't cover your case. Everything below is exported from `platejs`.
@@ -731,8 +788,10 @@ const copyrightRule = defineInputRule({
731
788
  ```
732
789
 
733
790
  Use it for raw `insertText`, `insertBreak`, or `insertData` rules. Match payload
734
- types flow from `resolve` into `apply`. The owner-bound overload also exposes
735
- the owner's typed `tx` group without explicit callback annotations.
791
+ types flow from `resolve` into `apply`, or into `followUp` for a
792
+ [follow-up paste rule](#follow-up-paste-rules), which `inputRules` accepts only
793
+ from `defineInputRule`. The owner-bound overload also exposes the owner's typed
794
+ `tx` group without explicit callback annotations.
736
795
 
737
796
  ### createMarkInputRule
738
797
 
@@ -1,6 +1,6 @@
1
- import { st as BasePluginInput, u as Editor } from "../../core-ClHasORr.js";
2
- import { n as EditorStaticProps } from "../../PlateStatic-CJX5bKuv.js";
3
- import { n as DocxComment, r as DocxDiagnostic, t as DocxSource } from "../../source-aUwpNnAw.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;
@@ -4,7 +4,6 @@ import { projectPlateFormatDocument } from "../../../lib/editor/withPlite.js";
4
4
  import { DocumentChange, ElementApi } from "../../../core.js";
5
5
  import { BaseBlockquotePlugin } from "../../../features/basic-nodes/lib/BaseBlockPlugins.js";
6
6
  import { renderStaticHtmlWithOverrides } from "../../../static/internal/renderStaticHtmlWithOverrides.js";
7
- import { AuthoredPlugin } from "../../../authored/AuthoredPlugin.js";
8
7
  import { projectAuthoredRange } from "../../../authored/index.js";
9
8
  import { throwIfDocxAborted } from "../../internal/abort.js";
10
9
  import { acquireDocxSource, docxSourceSchemaMatches } from "../../internal/source.js";
@@ -43,7 +42,7 @@ const mapCommentRanges = (comments, project) => Object.freeze(comments.map((comm
43
42
  const captureExport = (editor, options, comments) => {
44
43
  const snapshot = captureExportSnapshot(editor, options.projection);
45
44
  if (options.projection === "review") {
46
- const review = createReviewProjection(snapshot.stored, (node) => editor.plugin(AuthoredPlugin).read.reviewOf(node), (node) => editor.read.schema.isVoid(node) && editor.read.schema.isInline(node));
45
+ const review = createReviewProjection(editor, snapshot.stored);
47
46
  return Object.freeze({
48
47
  comments,
49
48
  diagnostics: Object.freeze([]),
@@ -265,6 +264,17 @@ const resolveSourceExport = (editor, capture, options, comments) => {
265
264
  });
266
265
  };
267
266
  const isContentLoss = (diagnostic) => diagnostic.code === "missing-static-presentation" || diagnostic.code === "resource-omitted" || diagnostic.code === "unsupported-content" && diagnostic.action === "dropped" || diagnostic.code === "lossy-content" && diagnostic.feature !== "document-metadata" && diagnostic.feature !== "list-marker" && diagnostic.feature !== "list-start" && diagnostic.feature !== "named-root" && diagnostic.feature !== "quote-structure";
267
+ const rejectedLoss = (diagnostics, options) => {
268
+ if ((options.lossPolicy ?? "reject") !== "reject") return null;
269
+ const policyDiagnostics = diagnostics.map((diagnostic) => diagnostic.severity === "warning" && isContentLoss(diagnostic) ? Object.freeze({
270
+ ...diagnostic,
271
+ severity: "error"
272
+ }) : diagnostic);
273
+ return policyDiagnostics.some(({ severity }) => severity === "error") ? Object.freeze({
274
+ diagnostics: Object.freeze(policyDiagnostics),
275
+ ok: false
276
+ }) : null;
277
+ };
268
278
  const generateDocx = async (html, options) => {
269
279
  try {
270
280
  const blob = await exportHtmlToDocx(html, options);
@@ -292,9 +302,12 @@ async function exportDocx(editor, options) {
292
302
  const nativeOnly = nativeOnlyDiagnostics(snapshot.stored);
293
303
  if (sourceResolution.kind === "exact") {
294
304
  throwIfDocxAborted(options.signal);
305
+ const exactDiagnostics = [...nativeOnly, ...capture.review?.diagnostics ?? []];
306
+ const rejected = rejectedLoss(exactDiagnostics, options);
307
+ if (rejected) return rejected;
295
308
  return Object.freeze({
296
309
  blob: sourceResolution.lease.blob,
297
- diagnostics: Object.freeze(nativeOnly),
310
+ diagnostics: Object.freeze(exactDiagnostics),
298
311
  ok: true
299
312
  });
300
313
  }
@@ -346,16 +359,8 @@ async function exportDocx(editor, options) {
346
359
  diagnostics: Object.freeze([...diagnostics, outputFailure]),
347
360
  ok: false
348
361
  });
349
- if ((options.lossPolicy ?? "reject") === "reject") {
350
- const policyDiagnostics = diagnostics.map((diagnostic) => diagnostic.severity === "warning" && isContentLoss(diagnostic) ? Object.freeze({
351
- ...diagnostic,
352
- severity: "error"
353
- }) : diagnostic);
354
- if (policyDiagnostics.some(({ severity }) => severity === "error")) return Object.freeze({
355
- diagnostics: Object.freeze(policyDiagnostics),
356
- ok: false
357
- });
358
- }
362
+ const rejected = rejectedLoss(diagnostics, options);
363
+ if (rejected) return rejected;
359
364
  return Object.freeze({
360
365
  blob,
361
366
  diagnostics: Object.freeze(diagnostics),
@@ -1611,18 +1611,19 @@ const buildTable = async (vNode, attributes, docxDocumentInstance, renderBlocks)
1611
1611
  const tablePropertiesFragment = buildTableProperties(modifiedAttributes);
1612
1612
  tableFragment.import(tablePropertiesFragment);
1613
1613
  const rowSpanMap = /* @__PURE__ */ new Map();
1614
+ let hasGrid = false;
1615
+ const importGrid = (tableGridFragment) => {
1616
+ if (hasGrid) return;
1617
+ hasGrid = true;
1618
+ tableFragment.import(tableGridFragment);
1619
+ };
1614
1620
  if (vNodeHasChildren(vNode)) for (let index = 0; index < (vNode.children || []).length; index++) {
1615
1621
  const childVNode = (vNode.children || [])[index];
1616
- if (childVNode.tagName === "colgroup") {
1617
- const tableGridFragment = buildTableGrid(childVNode, modifiedAttributes);
1618
- tableFragment.import(tableGridFragment);
1619
- } else if (childVNode.tagName === "thead") for (let iteratorIndex = 0; iteratorIndex < (childVNode.children || []).length; iteratorIndex++) {
1622
+ if (childVNode.tagName === "colgroup") importGrid(buildTableGrid(childVNode, modifiedAttributes));
1623
+ else if (childVNode.tagName === "thead") for (let iteratorIndex = 0; iteratorIndex < (childVNode.children || []).length; iteratorIndex++) {
1620
1624
  const grandChildVNode = (childVNode.children || [])[iteratorIndex];
1621
1625
  if (grandChildVNode.tagName === "tr") {
1622
- if (iteratorIndex === 0) {
1623
- const tableGridFragment = buildTableGridFromTableRow(grandChildVNode, modifiedAttributes);
1624
- tableFragment.import(tableGridFragment);
1625
- }
1626
+ if (iteratorIndex === 0) importGrid(buildTableGridFromTableRow(grandChildVNode, modifiedAttributes));
1626
1627
  const tableRowFragment = await buildTableRow(grandChildVNode, modifiedAttributes, rowSpanMap, docxDocumentInstance, renderBlocks);
1627
1628
  tableFragment.import(tableRowFragment);
1628
1629
  }
@@ -1630,19 +1631,13 @@ const buildTable = async (vNode, attributes, docxDocumentInstance, renderBlocks)
1630
1631
  else if (childVNode.tagName === "tbody") for (let iteratorIndex = 0; iteratorIndex < (childVNode.children || []).length; iteratorIndex++) {
1631
1632
  const grandChildVNode = (childVNode.children || [])[iteratorIndex];
1632
1633
  if (grandChildVNode.tagName === "tr") {
1633
- if (iteratorIndex === 0) {
1634
- const tableGridFragment = buildTableGridFromTableRow(grandChildVNode, modifiedAttributes);
1635
- tableFragment.import(tableGridFragment);
1636
- }
1634
+ if (iteratorIndex === 0) importGrid(buildTableGridFromTableRow(grandChildVNode, modifiedAttributes));
1637
1635
  const tableRowFragment = await buildTableRow(grandChildVNode, modifiedAttributes, rowSpanMap, docxDocumentInstance, renderBlocks);
1638
1636
  tableFragment.import(tableRowFragment);
1639
1637
  }
1640
1638
  }
1641
1639
  else if (childVNode.tagName === "tr") {
1642
- if (index === 0) {
1643
- const tableGridFragment = buildTableGridFromTableRow(childVNode, modifiedAttributes);
1644
- tableFragment.import(tableGridFragment);
1645
- }
1640
+ if (index === 0) importGrid(buildTableGridFromTableRow(childVNode, modifiedAttributes));
1646
1641
  const tableRowFragment = await buildTableRow(childVNode, modifiedAttributes, rowSpanMap, docxDocumentInstance, renderBlocks);
1647
1642
  tableFragment.import(tableRowFragment);
1648
1643
  }
@@ -1,4 +1,6 @@
1
1
  import { ElementApi } from "../../../core.js";
2
+ import { AuthoredPlugin } from "../../../authored/AuthoredPlugin.js";
3
+ import { BaseTablePlugin } from "../../../features/table/lib/BaseTablePlugin.js";
2
4
  import { parseDocxHtml } from "../../internal/domParser.js";
3
5
  //#region src/docx/export/lib/reviewProjection.tsx
4
6
  /** Prefix of the tokens that mark where a bound block starts and ends. */
@@ -9,7 +11,34 @@ const holdsMarks = (node) => "authored" in node || ElementApi.isElement(node) &&
9
11
  * Read the review marks of a stored document as Word revisions. Paths are the
10
12
  * stored document's, so ranges into it need no mapping.
11
13
  */
12
- const createReviewProjection = (stored, reviewOf, isInlineVoid) => {
14
+ const createReviewProjection = (editor, stored) => {
15
+ const reviewOf = (node) => editor.plugin(AuthoredPlugin).read.reviewOf(node);
16
+ const tablePlugin = editor.plugin(BaseTablePlugin);
17
+ const { schema } = editor.read;
18
+ const isInlineVoid = (node) => schema.isVoid(node) && schema.isInline(node);
19
+ const gridRoleOf = (node) => {
20
+ const structure = schema.element(node.type)?.structure;
21
+ return structure?.kind === "grid" ? structure.role : null;
22
+ };
23
+ const marksOf = (node) => "authored" in node && node.authored ? reviewOf(node).marks : [];
24
+ const isPlacement = ({ kind }) => kind === "insert" || kind === "delete";
25
+ const placementOf = ({ at, change, inc, kind }) => JSON.stringify([
26
+ kind,
27
+ change,
28
+ inc ?? at
29
+ ]);
30
+ const partsOf = (node) => node.children.flatMap((child) => {
31
+ if (!ElementApi.isElement(child)) return [];
32
+ const role = gridRoleOf(child);
33
+ if (role === "cell") return [child];
34
+ if (role === "row") return [child, ...partsOf(child)];
35
+ return role === null ? partsOf(child) : [];
36
+ });
37
+ const holdsGridChange = (table) => {
38
+ const wholeTableChanges = new Set(marksOf(table).filter(isPlacement).map(placementOf));
39
+ return [table, ...partsOf(table)].some((element) => marksOf(element).some((mark) => isPlacement(mark) ? !wholeTableChanges.has(placementOf(mark)) : mark.kind === "format"));
40
+ };
41
+ const diagnostics = [];
13
42
  const revisionIds = /* @__PURE__ */ new Map();
14
43
  const runs = /* @__PURE__ */ new Map();
15
44
  const structures = /* @__PURE__ */ new Map();
@@ -46,20 +75,31 @@ const createReviewProjection = (stored, reviewOf, isInlineVoid) => {
46
75
  });
47
76
  }
48
77
  if (!ElementApi.isElement(node)) return plain;
78
+ if (root === "main" && gridRoleOf(node) === "grid" && holdsGridChange(node)) diagnostics.push({
79
+ code: "lossy-content",
80
+ feature: "authored-review",
81
+ message: `The table at ${path.join(".")} holds a pending row, column or table format change that Word's revisions cannot carry, so deciding it in Word gives a different table.`,
82
+ path,
83
+ root,
84
+ severity: "warning"
85
+ });
49
86
  const structure = marks.find((mark) => mark.kind !== "insert" && mark.kind !== "delete" && mark.kind !== "joined");
50
87
  if (structure) structures.set(renderKey("element", root, key), revisionOf(structure));
88
+ const shownWidths = tablePlugin.installed && node.type === tablePlugin.schema.type && marks.some((mark) => mark.kind === "format" && mark.key === "columnWidths") ? { columnWidths: tablePlugin.api.columnWidths(node) } : {};
51
89
  return {
52
90
  ...plain,
91
+ ...shownWidths,
53
92
  children: build(node.children, root, path)
54
93
  };
55
94
  });
56
95
  const rootValue = (nodes) => nodes.filter((node) => ElementApi.isElement(node));
57
96
  const roots = Object.fromEntries(Object.entries(stored.roots ?? {}).map(([root, nodes]) => [root, rootValue(build(nodes, root, []))]));
97
+ const children = rootValue(build(stored.children, "main", []));
58
98
  return Object.freeze({
59
99
  bound: stored.children.flatMap((node, index) => holdsMarks(node) ? [index] : []),
60
- diagnostics: Object.freeze([]),
100
+ diagnostics: Object.freeze(diagnostics),
61
101
  document: Object.freeze({
62
- children: rootValue(build(stored.children, "main", [])),
102
+ children,
63
103
  ...Object.keys(roots).length > 0 ? { roots } : {}
64
104
  }),
65
105
  runs,
@@ -1,7 +1,7 @@
1
- import { Mo as PluginReference, Tt as EditorDocumentValue, ru as Value } from "../../index-DpltOCot-A2b3p3Eb.js";
2
- import { h as EditorApplicationSchema } from "../../htmlTypes-cg_cWsaN.js";
3
- import "../../core-ClHasORr.js";
4
- import { a as DocxImportLimits, i as DocxErrorDiagnostic, n as DocxComment, o as DocxSourceLocation, r as DocxDiagnostic, s as DocxWarningDiagnostic, t as DocxSource } from "../../source-aUwpNnAw.js";
1
+ import { Fo as PluginReference, Tt as EditorDocumentValue, su as Value } from "../../index-BXjLmx1n-CXk17buG.js";
2
+ import { h as EditorApplicationSchema } from "../../htmlTypes-eT2ZGDAj.js";
3
+ import "../../core-BqR-fEDp.js";
4
+ import { a as DocxImportLimits, i as DocxErrorDiagnostic, n as DocxComment, o as DocxSourceLocation, r as DocxDiagnostic, s as DocxWarningDiagnostic, t as DocxSource } from "../../source-BGohy8vH.js";
5
5
  type DocxImportOptions<TRetainSource extends boolean = false> = Readonly<{
6
6
  limits?: Partial<DocxImportLimits>;
7
7
  lossPolicy?: 'allow' | 'reject';
@@ -1,7 +1,7 @@
1
- import { ru as Value } from "../../index-DpltOCot-A2b3p3Eb.js";
2
- import { a as HtmlEditorSerializeOptions, d as HtmlSerializeResult, f as HtmlSliceParseResult, i as HtmlEditorParseOptions, r as HtmlDocumentParseResult } from "../../htmlTypes-cg_cWsaN.js";
3
- import { _ as BasePlugin, xo as PluginReference, yo as PluginDependency } from "../../core-ClHasORr.js";
4
- import "../../index-C35V_hj0.js";
1
+ import { su as Value } from "../../index-BXjLmx1n-CXk17buG.js";
2
+ import { a as HtmlEditorSerializeOptions, d as HtmlSerializeResult, f as HtmlSliceParseResult, i as HtmlEditorParseOptions, r as HtmlDocumentParseResult } from "../../htmlTypes-eT2ZGDAj.js";
3
+ import { Co as PluginReference, _ as BasePlugin, xo as PluginDependency } from "../../core-BqR-fEDp.js";
4
+ import "../../index-DYdObeFQ.js";
5
5
  /** Normalizes Word clipboard payloads before the installed HTML parser runs. */
6
6
  declare const WordPastePlugin: BasePlugin<Readonly<{
7
7
  readonly dependencies: readonly [PluginReference<"html"> & PluginDependency<Readonly<{
@@ -1,2 +1,2 @@
1
- import { A as DataTransferSnapshot, B as domCommands, C as DOMVisualPointOptions, D as DataTransferFormat, E as DataTransferEncodeContext, F as KeyboardEventLike, H as usesAppleDOMHotkeys, I as ScrollIntoViewOptions, L as ScrollIntoViewTarget, M as HotkeyMatchOptions, N as HotkeyPlatform, O as DataTransferFormatPhase, P as HotkeySpec, R as ariaKeyShortcuts, S as DOMVisualPoint, T as DataTransferDiagnostic, U as writeDataTransferFragment, V as isHotkey, _ as DOMRange, b as DOMStaticRange, f as DOMElement, g as DOMPoint, i as DOMClipboardApi, k as DataTransferSchemaClaim, n as ClipboardSliceWrite, p as DOMNode, r as DOMApi, t as ClipboardSliceRead, v as DOMResolutionError, w as DataTransferDecodeContext, x as DOMText, y as DOMSelection, z as dataTransferFormats } from "../index-B5mYEawV.js";
1
+ import { A as DataTransferSnapshot, B as domCommands, C as DOMVisualPointOptions, D as DataTransferFormat, E as DataTransferEncodeContext, F as KeyboardEventLike, H as usesAppleDOMHotkeys, I as ScrollIntoViewOptions, L as ScrollIntoViewTarget, M as HotkeyMatchOptions, N as HotkeyPlatform, O as DataTransferFormatPhase, P as HotkeySpec, R as ariaKeyShortcuts, S as DOMVisualPoint, T as DataTransferDiagnostic, U as writeDataTransferFragment, V as isHotkey, _ as DOMRange, b as DOMStaticRange, f as DOMElement, g as DOMPoint, i as DOMClipboardApi, k as DataTransferSchemaClaim, n as ClipboardSliceWrite, p as DOMNode, r as DOMApi, t as ClipboardSliceRead, v as DOMResolutionError, w as DataTransferDecodeContext, x as DOMText, y as DOMSelection, z as dataTransferFormats } from "../index-DShbzec2.js";
2
2
  export { type ClipboardSliceRead, type ClipboardSliceWrite, type DOMApi, type DOMClipboardApi, type DOMElement, type DOMNode, type DOMPoint, type DOMRange, DOMResolutionError, type DOMSelection, type DOMStaticRange, type DOMText, type DOMVisualPoint, type DOMVisualPointOptions, type DataTransferDecodeContext, type DataTransferDiagnostic, type DataTransferEncodeContext, type DataTransferFormat, type DataTransferFormatPhase, type DataTransferSchemaClaim, type DataTransferSnapshot, type HotkeyMatchOptions, type HotkeyPlatform, type HotkeySpec, type KeyboardEventLike, type ScrollIntoViewOptions, type ScrollIntoViewTarget, ariaKeyShortcuts, dataTransferFormats, domCommands, isHotkey, usesAppleDOMHotkeys, writeDataTransferFragment };
@@ -1,6 +1,6 @@
1
- import { Qo as PropertyJsonDescriptor, Vt as EditorJsonValue, ki as ElementOf } from "../index-DpltOCot-A2b3p3Eb.js";
2
- import "../htmlTypes-cg_cWsaN.js";
3
- import { _ as BasePlugin } from "../core-ClHasORr.js";
1
+ import { Ht as EditorJsonValue, ji as ElementOf, ts as PropertyJsonDescriptor } from "../index-BXjLmx1n-CXk17buG.js";
2
+ import "../htmlTypes-eT2ZGDAj.js";
3
+ import { _ as BasePlugin } from "../core-BqR-fEDp.js";
4
4
  type ExcalidrawElementData = {
5
5
  elements: readonly EditorJsonValue[];
6
6
  files?: Readonly<Record<string, EditorJsonValue>>;
@@ -1,6 +1,6 @@
1
- import { Qo as PropertyJsonDescriptor, Vt as EditorJsonValue } from "../../index-DpltOCot-A2b3p3Eb.js";
2
- import "../../htmlTypes-cg_cWsaN.js";
3
- import { At as Plugin } from "../../index-8WO2vI0U.js";
1
+ import { Ht as EditorJsonValue, ts as PropertyJsonDescriptor } from "../../index-BXjLmx1n-CXk17buG.js";
2
+ import "../../htmlTypes-eT2ZGDAj.js";
3
+ import { At as Plugin } from "../../index-DPowErHa.js";
4
4
  import { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types";
5
5
  declare const ExcalidrawPlugin: Plugin<Readonly<{}> & Readonly<{
6
6
  name: "excalidraw";
package/dist/facade.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import { ContentSlice, DocumentChange, EditorSchemaValidationError, ElementApi, NodeApi, PathApi, PointApi, RangeApi, SelectionApi, TextApi, createEditor, defineEditorSchema, definePlugin as defineRuntimePlugin, definePluginPoint, editorCommands, editorReads, getEditorRuntimeOwner, locateAt, property, readEditorSelection, schema, target, transfer, txLocate, txSelection } from "plitejs";
2
- import { EDITOR_DOCUMENT_FIELDS as EDITOR_DOCUMENT_FIELDS$1, EditorRefusalError, MAIN_ROOT_KEY, afterActiveTransactionEnds, assertDetachedSelectionSupported, assertEditorDocumentContainers, attachTransactionSpecAfterCommit, canPlaceBlocksAtPath, canonicalRecordJson, claimsHistoryReplay, completePersistedDocumentFields, configureAuthoredView, containsCompleteEditorSchema, createDetachedEditorSchema as createDetachedEditorSchema$1, createEditorOwner, fitSlicePlacements, getActiveEditorTransaction, getActiveEditorUpdateId, getActiveEditorUpdateTags, getAuthoredUpdateView, getCaretOwner, getCarriedCaretEditor, getCompiledEditorSchema as getCompiledEditorSchema$1, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates, getDocumentValueNode, getEditorAuthoredDocumentCapability as getEditorAuthoredDocumentCapability$1, getEditorCommitNode, getEditorCommitSnapshot, getEditorCommitValue, getEditorDocumentShapeIssueMessage, getEditorRuntimeRootKeys, getEditorUpdateRoot, getInstalledPlugin, getPluginContributions, getReaderRange, getRecordSetVersion, getSchemaElementSourceReference, getSelectionDOMRange, getSnapshotVersion, getTextSearchScope, getValueRecords, getViewAuthor, getViewPresentation as getViewPresentation$1, holdsCaret, isAuthorId, isDocumentView, isEditorPublishingCommit, isEnvelopeInput as isEnvelopeInput$1, isPlugin as isRuntimePlugin, landNodePropertiesAt, mapDetachedSelectionThroughChange, mapSemanticUpdateMethodArguments, markRootViewUsed, normalizeSetValues, notifyObservers, placeElementAt, preserveCompiledSchemaPropertyIdentity, projectEditorView, readAuthoredView, readCaretViewIn, readDocumentRange, readDocumentRecord as readDocumentRecord$1, readElementPropertyWrites, readPersistedEnvelope as readPersistedEnvelope$1, readRecord, readRootEntries, readRootViewUse, readShownDocument, readShownRecords, readShownViewUse, readStoredEditorDocument, readViewPage, recordSetChanges, recordSetIds, registerEditorTransactionGuard, rejectEditorRecord, repairEditorValue, reportEditorLifecycleError as reportEditorLifecycleError$1, runEditorObserver, sameResult, scheduleAfterCommitNotification, setEditorStateViewTransform, setEditorTransactionViewTransform, setSelectionAsView, shouldMergeNodesRemovePrevNode, snapshotEditorJsonValue, subscribeCaretTarget, subscribeEditorViewState, subscribeShownViewUse, txStored, vetoesWrite, withDocumentViewRead, withEditorUpdateRootScope, withMountedPresentation, withStoredAuthoredRead, withTransactionSpecDraftRead } from "plitejs/internal";
3
- export { ContentSlice, DocumentChange, EDITOR_DOCUMENT_FIELDS$1 as EDITOR_DOCUMENT_FIELDS, EditorRefusalError, EditorSchemaValidationError, ElementApi, MAIN_ROOT_KEY, NodeApi, PathApi, PointApi, RangeApi, SelectionApi, TextApi, afterActiveTransactionEnds, assertDetachedSelectionSupported, assertEditorDocumentContainers, attachTransactionSpecAfterCommit, canPlaceBlocksAtPath, canonicalRecordJson, claimsHistoryReplay, completePersistedDocumentFields, configureAuthoredView, containsCompleteEditorSchema, createDetachedEditorSchema$1 as createDetachedEditorSchema, createEditor, createEditorOwner, defineEditorSchema, definePluginPoint, defineRuntimePlugin, editorCommands, editorReads, fitSlicePlacements, getActiveEditorTransaction, getActiveEditorUpdateId, getActiveEditorUpdateTags, getAuthoredUpdateView, getCaretOwner, getCarriedCaretEditor, getCompiledEditorSchema$1 as getCompiledEditorSchema, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates, getDocumentValueNode, getEditorAuthoredDocumentCapability$1 as getEditorAuthoredDocumentCapability, getEditorCommitNode, getEditorCommitSnapshot, getEditorCommitValue, getEditorDocumentShapeIssueMessage, getEditorRuntimeOwner, getEditorRuntimeRootKeys, getEditorUpdateRoot, getInstalledPlugin, getPluginContributions, getReaderRange, getRecordSetVersion, getSchemaElementSourceReference, getSelectionDOMRange, getSnapshotVersion, getTextSearchScope, getValueRecords, getViewAuthor, getViewPresentation$1 as getViewPresentation, holdsCaret, isAuthorId, isDocumentView, isEditorPublishingCommit, isEnvelopeInput$1 as isEnvelopeInput, isRuntimePlugin, landNodePropertiesAt, locateAt, mapDetachedSelectionThroughChange, mapSemanticUpdateMethodArguments, markRootViewUsed, normalizeSetValues, notifyObservers, placeElementAt, preserveCompiledSchemaPropertyIdentity, projectEditorView, property, readAuthoredView, readCaretViewIn, readDocumentRange, readDocumentRecord$1 as readDocumentRecord, readEditorSelection, readElementPropertyWrites, readPersistedEnvelope$1 as readPersistedEnvelope, readRecord, readRootEntries, readRootViewUse, readShownDocument, readShownRecords, readShownViewUse, readStoredEditorDocument, readViewPage, recordSetChanges, recordSetIds, registerEditorTransactionGuard, rejectEditorRecord, repairEditorValue, reportEditorLifecycleError$1 as reportEditorLifecycleError, runEditorObserver, sameResult, scheduleAfterCommitNotification, schema, setEditorStateViewTransform, setEditorTransactionViewTransform, setSelectionAsView, shouldMergeNodesRemovePrevNode, snapshotEditorJsonValue, subscribeCaretTarget, subscribeEditorViewState, subscribeShownViewUse, target, transfer, txLocate, txSelection, txStored, vetoesWrite, withDocumentViewRead, withEditorUpdateRootScope, withMountedPresentation, withStoredAuthoredRead, withTransactionSpecDraftRead };
2
+ import { EDITOR_DOCUMENT_FIELDS as EDITOR_DOCUMENT_FIELDS$1, EditorRefusalError, MAIN_ROOT_KEY, afterActiveTransactionEnds, assertDetachedSelectionSupported, assertEditorDocumentContainers, attachTransactionSpecAfterCommit, canPlaceBlocksAtPath, canonicalRecordJson, claimsHistoryReplay, completePersistedDocumentFields, configureAuthoredView, containsCompleteEditorSchema, createAuthoredEditorView, createDetachedEditorSchema as createDetachedEditorSchema$1, createEditorOwner, fitSlicePlacements, getActiveCommandEditor, getActiveEditorTransaction, getActiveEditorUpdateId, getActiveEditorUpdateTags, getAuthoredUpdateView, getCaretOwner, getCarriedCaretEditor, getCompiledEditorSchema as getCompiledEditorSchema$1, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates, getDocumentValueNode, getEditorAuthoredDocumentCapability as getEditorAuthoredDocumentCapability$1, getEditorCommitNode, getEditorCommitSnapshot, getEditorCommitValue, getEditorDocumentShapeIssueMessage, getEditorRuntimeRootKeys, getEditorUpdateRoot, getInstalledPlugin, getPluginContributions, getReaderRange, getRecordSetVersion, getSchemaElementSourceReference, getSelectionDOMRange, getSnapshotVersion, getTextSearchScope, getValueRecords, getViewAuthor, getViewPresentation as getViewPresentation$1, holdsCaret, isAuthorId, isDocumentView, isEditorPublishingCommit, isEnvelopeInput as isEnvelopeInput$1, isPlugin as isRuntimePlugin, landNodePropertiesAt, mapDetachedSelectionThroughChange, mapSemanticUpdateMethodArguments, markRootViewUsed, normalizeSetValues, notifyObservers, placeElementAt, preserveCompiledSchemaPropertyIdentity, projectEditorView, readAuthoredView, readCaretViewIn, readDocumentRange, readDocumentRecord as readDocumentRecord$1, readEditorCommitHistoryEntry, readElementById, readElementPropertyWrites, readPersistedEnvelope as readPersistedEnvelope$1, readRecord, readRootEntries, readRootViewUse, readShownDocument, readShownPreview, readShownRecords, readShownViewUse, readStoredEditorDocument, readViewPage, recordSetChanges, recordSetIds, registerEditorTransactionGuard, rejectEditorRecord, repairEditorValue, reportEditorLifecycleError as reportEditorLifecycleError$1, runEditorObserver, sameResult, scheduleAfterCommitNotification, setEditorStateViewTransform, setEditorTransactionViewTransform, setSelectionAsView, shouldMergeNodesRemovePrevNode, snapshotEditorJsonValue, subscribeCaretTarget, subscribeEditorViewState, subscribeShownViewUse, txStored, vetoesWrite, withDocumentViewRead, withEditorUpdateRootScope, withMountedPresentation, withStoredAuthoredRead, withTransactionSpecDraftRead } from "plitejs/internal";
3
+ export { ContentSlice, DocumentChange, EDITOR_DOCUMENT_FIELDS$1 as EDITOR_DOCUMENT_FIELDS, EditorRefusalError, EditorSchemaValidationError, ElementApi, MAIN_ROOT_KEY, NodeApi, PathApi, PointApi, RangeApi, SelectionApi, TextApi, afterActiveTransactionEnds, assertDetachedSelectionSupported, assertEditorDocumentContainers, attachTransactionSpecAfterCommit, canPlaceBlocksAtPath, canonicalRecordJson, claimsHistoryReplay, completePersistedDocumentFields, configureAuthoredView, containsCompleteEditorSchema, createAuthoredEditorView, createDetachedEditorSchema$1 as createDetachedEditorSchema, createEditor, createEditorOwner, defineEditorSchema, definePluginPoint, defineRuntimePlugin, editorCommands, editorReads, fitSlicePlacements, getActiveCommandEditor, getActiveEditorTransaction, getActiveEditorUpdateId, getActiveEditorUpdateTags, getAuthoredUpdateView, getCaretOwner, getCarriedCaretEditor, getCompiledEditorSchema$1 as getCompiledEditorSchema, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates, getDocumentValueNode, getEditorAuthoredDocumentCapability$1 as getEditorAuthoredDocumentCapability, getEditorCommitNode, getEditorCommitSnapshot, getEditorCommitValue, getEditorDocumentShapeIssueMessage, getEditorRuntimeOwner, getEditorRuntimeRootKeys, getEditorUpdateRoot, getInstalledPlugin, getPluginContributions, getReaderRange, getRecordSetVersion, getSchemaElementSourceReference, getSelectionDOMRange, getSnapshotVersion, getTextSearchScope, getValueRecords, getViewAuthor, getViewPresentation$1 as getViewPresentation, holdsCaret, isAuthorId, isDocumentView, isEditorPublishingCommit, isEnvelopeInput$1 as isEnvelopeInput, isRuntimePlugin, landNodePropertiesAt, locateAt, mapDetachedSelectionThroughChange, mapSemanticUpdateMethodArguments, markRootViewUsed, normalizeSetValues, notifyObservers, placeElementAt, preserveCompiledSchemaPropertyIdentity, projectEditorView, property, readAuthoredView, readCaretViewIn, readDocumentRange, readDocumentRecord$1 as readDocumentRecord, readEditorCommitHistoryEntry, readEditorSelection, readElementById, readElementPropertyWrites, readPersistedEnvelope$1 as readPersistedEnvelope, readRecord, readRootEntries, readRootViewUse, readShownDocument, readShownPreview, readShownRecords, readShownViewUse, readStoredEditorDocument, readViewPage, recordSetChanges, recordSetIds, registerEditorTransactionGuard, rejectEditorRecord, repairEditorValue, reportEditorLifecycleError$1 as reportEditorLifecycleError, runEditorObserver, sameResult, scheduleAfterCommitNotification, schema, setEditorStateViewTransform, setEditorTransactionViewTransform, setSelectionAsView, shouldMergeNodesRemovePrevNode, snapshotEditorJsonValue, subscribeCaretTarget, subscribeEditorViewState, subscribeShownViewUse, target, transfer, txLocate, txSelection, txStored, vetoesWrite, withDocumentViewRead, withEditorUpdateRootScope, withMountedPresentation, withStoredAuthoredRead, withTransactionSpecDraftRead };
@@ -1,2 +1,2 @@
1
- import { A as BoardShapeEntry, C as BoardArrowEnd, D as BoardArrowEntry, F as BoardPlace, I as BoardRestackDirection, M as BoardShapePlace, O as BoardFrameEntry, R as BoardSize, S as BoardArrowAnchor, T as BoardArrowSide, _ as BaseBoardFramePlugin, a as BoardElement, b as BoardArrowElement, d as BoardNoteElement, f as BaseBoardImagePlugin, g as BoardGeoElement, h as BoardGeo, i as BoardDefinition, j as BoardFramePlace, k as BoardMemberEntry, m as BaseBoardGeoPlugin, n as BoardStrokeElement, p as BoardImageElement, r as BaseBoardPlugin, s as BoardStrokePath, t as BaseBoardStrokePlugin, u as BaseBoardNotePlugin, v as BoardFrameElement, w as BoardArrowEnds, x as BoardArrowEndInput, y as BaseBoardArrowPlugin, z as defineBoardShape } from "../../index-oIJAZxc2.js";
1
+ import { A as BoardShapeEntry, C as BoardArrowEnd, D as BoardArrowEntry, F as BoardPlace, I as BoardRestackDirection, M as BoardShapePlace, O as BoardFrameEntry, R as BoardSize, S as BoardArrowAnchor, T as BoardArrowSide, _ as BaseBoardFramePlugin, a as BoardElement, b as BoardArrowElement, d as BoardNoteElement, f as BaseBoardImagePlugin, g as BoardGeoElement, h as BoardGeo, i as BoardDefinition, j as BoardFramePlace, k as BoardMemberEntry, m as BaseBoardGeoPlugin, n as BoardStrokeElement, p as BoardImageElement, r as BaseBoardPlugin, s as BoardStrokePath, t as BaseBoardStrokePlugin, u as BaseBoardNotePlugin, v as BoardFrameElement, w as BoardArrowEnds, x as BoardArrowEndInput, y as BaseBoardArrowPlugin, z as defineBoardShape } from "../../index-Ca48r1ng.js";
2
2
  export { BaseBoardArrowPlugin, BaseBoardFramePlugin, BaseBoardGeoPlugin, BaseBoardImagePlugin, BaseBoardNotePlugin, BaseBoardPlugin, BaseBoardStrokePlugin, type BoardArrowAnchor, BoardArrowElement, type BoardArrowEnd, BoardArrowEndInput, type BoardArrowEnds, type BoardArrowEntry, type BoardArrowSide, BoardDefinition, BoardElement, BoardFrameElement, type BoardFrameEntry, type BoardFramePlace, BoardGeo, BoardGeoElement, BoardImageElement, type BoardMemberEntry, BoardNoteElement, type BoardPlace, type BoardRestackDirection, type BoardShapeEntry, type BoardShapePlace, type BoardSize, BoardStrokeElement, type BoardStrokePath, defineBoardShape };
@@ -1,6 +1,6 @@
1
- import { Vt as EditorJsonValue, is as PropertyStringDescriptor, ki as ElementOf, ls as PropertyValueOptions } from "../../index-DpltOCot-A2b3p3Eb.js";
2
- import "../../htmlTypes-cg_cWsaN.js";
3
- import { _ as BasePlugin } from "../../core-ClHasORr.js";
1
+ import { Ht as EditorJsonValue, fs as PropertyValueOptions, ji as ElementOf, ss as PropertyStringDescriptor } from "../../index-BXjLmx1n-CXk17buG.js";
2
+ import "../../htmlTypes-eT2ZGDAj.js";
3
+ import { _ as BasePlugin } from "../../core-BqR-fEDp.js";
4
4
  declare const BaseCalloutPlugin: BasePlugin<Readonly<{
5
5
  formats: true;
6
6
  rules: true;
@@ -1,3 +1,3 @@
1
- import { n as ComboboxState, t as ComboboxEditor } from "../../combobox-DAOYWuvC.js";
2
- import { n as filterWords, t as FilterWordsOptions } from "../../index-Cmuluh6f.js";
1
+ import { n as ComboboxState, t as ComboboxEditor } from "../../combobox-Dr0OYZIE.js";
2
+ import { n as filterWords, t as FilterWordsOptions } from "../../index-BTx5oK7k.js";
3
3
  export { ComboboxEditor, ComboboxState, FilterWordsOptions, filterWords };
@@ -1,4 +1,4 @@
1
- import { notifyObservers, readDocumentRange, runEditorObserver, subscribeEditorViewState } from "../../facade.js";
1
+ import { notifyObservers, readDocumentRange, runEditorObserver, subscribeEditorViewState, withStoredAuthoredRead } from "../../facade.js";
2
2
  import { definePlugin } from "../../lib/plugin/definePlugin.js";
3
3
  import { readEditorAuthor } from "../../lib/editor/editorUser.internal.js";
4
4
  import { nanoid } from "../../lib/libs/nanoid.js";
@@ -208,7 +208,10 @@ const BaseCommentsPlugin = definePlugin("comments", {
208
208
  if (observed) return observed.annotations;
209
209
  let annotations = passiveIndexes.get(view);
210
210
  if (!annotations) {
211
- annotations = createAnnotationStore(view, () => sourcesByRoot.get(view.read.view.root()) ?? [], { id: "comments" });
211
+ annotations = createAnnotationStore(view, () => sourcesByRoot.get(view.read.view.root()) ?? [], {
212
+ hideEmpty: true,
213
+ id: "comments"
214
+ });
212
215
  passiveIndexes.set(view, annotations);
213
216
  }
214
217
  return annotations;
@@ -260,7 +263,7 @@ const BaseCommentsPlugin = definePlugin("comments", {
260
263
  if (changed && !changed(root)) return;
261
264
  group.forEach(({ anchor, id }) => {
262
265
  present.add(id);
263
- const range = anchor.resolve(view);
266
+ const range = textIn(view, anchor.resolve(view));
264
267
  if (ranges.has(id) && isEqual(ranges.get(id), range)) return;
265
268
  ranges.set(id, range);
266
269
  ids.add(id);
@@ -288,9 +291,17 @@ const BaseCommentsPlugin = definePlugin("comments", {
288
291
  queueChange(() => deliver(listeners, "commit-listener", change));
289
292
  };
290
293
  changedIds();
294
+ let schema = view.read.schema.identity();
291
295
  const stopCommits = view.subscribeCommit((commit) => {
292
- if (commit && !commit.changed.hasAny("document")) return;
293
- announce(changedIds(commit && ((root) => commit.changed.has("document", root)), !commit || commit.changed.hasAny("structure") || commit.changed.hasAny("properties")), "editor");
296
+ const next = view.read.schema.identity();
297
+ const reconfigured = next !== schema;
298
+ schema = next;
299
+ if (!commit || reconfigured) {
300
+ announce(changedIds(), "editor");
301
+ return;
302
+ }
303
+ if (!commit.changed.hasAny("document")) return;
304
+ announce(changedIds((root) => commit.changed.has("document", root), commit.changed.hasAny("structure") || commit.changed.hasAny("properties")), "editor");
294
305
  });
295
306
  const stopProjection = subscribeEditorViewState(view, (change) => {
296
307
  if (change === "authored") announce(changedIds(), "editor");
@@ -410,6 +421,8 @@ const BaseCommentsPlugin = definePlugin("comments", {
410
421
  if (destroyed) return;
411
422
  store.set({ activeIds: Object.freeze([...new Set(ids)]) });
412
423
  };
424
+ const textIn = (view, range) => range && !view.read.ranges.isEmpty(range) ? range : null;
425
+ const storedText = (anchor) => withStoredAuthoredRead(editor, () => textIn(editor, anchor.resolve()));
413
426
  const syncSource = () => {
414
427
  sourcesByRoot = /* @__PURE__ */ new Map();
415
428
  anchors.forEach((anchor, id) => {
@@ -451,7 +464,8 @@ const BaseCommentsPlugin = definePlugin("comments", {
451
464
  return range;
452
465
  };
453
466
  const commandRange = (view, value) => assertTextRange(view, readDocumentRange(value, { view: view.read.view.root() }));
454
- const resolveIn = (view, anchor) => anchor.root === view.read.view.root() || isPageView(view) ? anchor.resolve(view) : null;
467
+ const rangeIn = (view, anchor) => anchor.root === view.read.view.root() || isPageView(view) ? anchor.resolve(view) : null;
468
+ const resolveIn = (view, anchor) => textIn(view, rangeIn(view, anchor));
455
469
  const locationRoot = (location) => {
456
470
  if (PathApi.isPath(location)) return void 0;
457
471
  return PointApi.isPoint(location) ? location.root : SelectionApi.root(location);
@@ -640,7 +654,7 @@ const BaseCommentsPlugin = definePlugin("comments", {
640
654
  });
641
655
  return result;
642
656
  };
643
- const commitMutation = async (id, operation, proposed, anchor, { afterWrite, isCurrent = () => true } = {}) => {
657
+ const commitMutation = async (id, operation, proposed, anchor, { afterWrite, isCurrent = () => true, allowEmpty = false } = {}) => {
644
658
  const previous = threads.get(id) ?? null;
645
659
  const generation = generations.get(id) ?? 0;
646
660
  if (destroyed || !isCurrent()) return { status: "stale" };
@@ -656,14 +670,15 @@ const BaseCommentsPlugin = definePlugin("comments", {
656
670
  try {
657
671
  let range = null;
658
672
  if (location) {
659
- if (location.resolve()) {
673
+ const written = () => allowEmpty ? location.resolve() : storedText(location);
674
+ if (written()) {
660
675
  rangesAwaitingMutate.set(id, location);
661
676
  announceRanges();
662
677
  if (isStale()) {
663
678
  dropUnwritten();
664
679
  return { status: "stale" };
665
680
  }
666
- range = location.resolve();
681
+ range = written();
667
682
  }
668
683
  if (!range) {
669
684
  dropUnwritten();
@@ -744,7 +759,8 @@ const BaseCommentsPlugin = definePlugin("comments", {
744
759
  afterWrite: (canonical) => {
745
760
  value = canonical;
746
761
  },
747
- isCurrent: () => sameThread(threads.get(thread.id) ?? null, transition.previous)
762
+ isCurrent: () => sameThread(threads.get(thread.id) ?? null, transition.previous),
763
+ allowEmpty: true
748
764
  });
749
765
  if (mutation.status !== "applied") return {
750
766
  status: "applied",
@@ -858,7 +874,7 @@ const BaseCommentsPlugin = definePlugin("comments", {
858
874
  let range;
859
875
  if (input.target.type === "range") {
860
876
  range = commandRange(commandEditor, input.target.range);
861
- if (RangeApi.isCollapsed(range)) return null;
877
+ if (commandEditor.read.ranges.isEmpty(range)) return null;
862
878
  } else if (!input.target.id) return null;
863
879
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
864
880
  const userId = readEditorAuthor(commandEditor);
@@ -922,11 +938,11 @@ const BaseCommentsPlugin = definePlugin("comments", {
922
938
  begin: (at = commandEditor.read.selection()) => {
923
939
  if (!at || destroyed) return false;
924
940
  let range = commandRange(commandEditor, at);
925
- if (RangeApi.isCollapsed(range)) {
926
- const block = commandEditor.read.nodes.block({ at: range });
941
+ if (commandEditor.read.ranges.isEmpty(range)) {
942
+ const block = commandEditor.read.nodes.block({ at: RangeApi.start(range) });
927
943
  range = block ? commandEditor.read.ranges.get(block[0]) ?? null : null;
928
944
  }
929
- if (!range || RangeApi.isCollapsed(range)) return false;
945
+ if (!range || commandEditor.read.ranges.isEmpty(range)) return false;
930
946
  const anchor = commandEditor.anchor(range, {
931
947
  association: "inward",
932
948
  deletion: "nearest"
@@ -1159,8 +1175,8 @@ const BaseCommentsPlugin = definePlugin("comments", {
1159
1175
  const annotations = root === viewRoot ? viewIndexes.get(commandEditor)?.annotations : void 0;
1160
1176
  if (!annotations) return Object.freeze([...anchors].flatMap(([id, anchor]) => {
1161
1177
  if (anchor.root !== root || threads.get(id)?.resolution) return [];
1162
- const range = resolveIn(commandEditor, anchor);
1163
- return range && RangeApi.includes(range, location) ? [id] : [];
1178
+ const range = rangeIn(commandEditor, anchor);
1179
+ return range && RangeApi.includes(range, location) && textIn(commandEditor, range) ? [id] : [];
1164
1180
  }));
1165
1181
  return Object.freeze([...new Map(nodeKeysAt(commandEditor, location).flatMap((key) => annotations.getAnnotationsAt(key).map((annotation) => [annotation.id, annotation]))).values()].filter(({ id, range }) => !threads.get(id)?.resolution && range && RangeApi.includes(range, location)).sort((left, right) => (sourceOrder.get(left.id) ?? 0) - (sourceOrder.get(right.id) ?? 0)).map(({ id }) => id));
1166
1182
  },
@@ -1171,7 +1187,7 @@ const BaseCommentsPlugin = definePlugin("comments", {
1171
1187
  if (thread.target.type === "change") return thread.target;
1172
1188
  const anchor = anchors.get(id);
1173
1189
  const range = anchor && resolveIn(commandEditor, anchor);
1174
- return range && !RangeApi.isCollapsed(range) ? freezeComment({
1190
+ return range ? freezeComment({
1175
1191
  type: "range",
1176
1192
  status: "attached",
1177
1193
  range: structuredClone(range)
@@ -1,2 +1,2 @@
1
- import { S as SavedComments, _ as CommentsLoadIssue, a as CommentDataValue, b as CreateCommentThreadInput, c as CommentMutationRequest, d as CommentRanges, f as CommentResolution, g as CommentsChange, h as CommentUser, i as CommentDataList, l as CommentMutationResult, m as CommentThread, n as CommentAttachment, o as CommentMessage, p as CommentTarget, r as CommentData, s as CommentMutationDecision, t as BaseCommentsPlugin, u as CommentOperation, v as CommentsPluginState, x as PendingComment, y as CommentsSnapshot } from "../../index-C1_JIhL4.js";
1
+ import { S as SavedComments, _ as CommentsLoadIssue, a as CommentDataValue, b as CreateCommentThreadInput, c as CommentMutationRequest, d as CommentRanges, f as CommentResolution, g as CommentsChange, h as CommentUser, i as CommentDataList, l as CommentMutationResult, m as CommentThread, n as CommentAttachment, o as CommentMessage, p as CommentTarget, r as CommentData, s as CommentMutationDecision, t as BaseCommentsPlugin, u as CommentOperation, v as CommentsPluginState, x as PendingComment, y as CommentsSnapshot } from "../../index-CpY7Xnxw.js";
2
2
  export { BaseCommentsPlugin, CommentAttachment, CommentData, CommentDataList, CommentDataValue, CommentMessage, CommentMutationDecision, CommentMutationRequest, CommentMutationResult, CommentOperation, CommentRanges, CommentResolution, CommentTarget, CommentThread, CommentUser, CommentsChange, CommentsLoadIssue, CommentsPluginState, CommentsSnapshot, CreateCommentThreadInput, PendingComment, SavedComments };
@@ -1,6 +1,6 @@
1
- import { eu as TxDeclaredMethod, is as PropertyStringDescriptor, ki as ElementOf } from "../../index-DpltOCot-A2b3p3Eb.js";
2
- import "../../htmlTypes-cg_cWsaN.js";
3
- import { _ as BasePlugin, _t as NodeInsertOptions } from "../../core-ClHasORr.js";
1
+ import { iu as TxDeclaredMethod, ji as ElementOf, ss as PropertyStringDescriptor } from "../../index-BXjLmx1n-CXk17buG.js";
2
+ import "../../htmlTypes-eT2ZGDAj.js";
3
+ import { _ as BasePlugin, _t as NodeInsertOptions } from "../../core-BqR-fEDp.js";
4
4
  declare const BaseDatePlugin: BasePlugin<Readonly<{
5
5
  readonly __pluginWritableProperties: Readonly<{
6
6
  descriptor: PropertyStringDescriptor<{
@@ -1,6 +1,6 @@
1
- import { Ds as SchemaContentPrefixSlot, Ki as Location, Pa as NodeSelection, Ps as SchemaContentRule, Qo as PropertyJsonDescriptor, Vt as EditorJsonValue, eu as TxDeclaredMethod, ki as ElementOf, ws as SchemaContentDefault, xa as NodeKey } from "../../index-DpltOCot-A2b3p3Eb.js";
2
- import "../../htmlTypes-cg_cWsaN.js";
3
- import { Qn as HeadingLevel, _ as BasePlugin, ct as BlockInsertOptions, lt as BlockUpsertOptions, xo as PluginReference, yo as PluginDependency } from "../../core-ClHasORr.js";
1
+ import { As as SchemaContentPrefixSlot, Ca as NodeKey, Ds as SchemaContentDefault, Ht as EditorJsonValue, Ia as NodeSelection, Ji as Location, Ls as SchemaContentRule, iu as TxDeclaredMethod, ji as ElementOf, ts as PropertyJsonDescriptor } from "../../index-BXjLmx1n-CXk17buG.js";
2
+ import "../../htmlTypes-eT2ZGDAj.js";
3
+ import { Co as PluginReference, Qn as HeadingLevel, _ as BasePlugin, ct as BlockInsertOptions, lt as BlockUpsertOptions, xo as PluginDependency } from "../../core-BqR-fEDp.js";
4
4
  declare const isSummaryHeadingLevel: (value: unknown) => value is HeadingLevel;
5
5
  type BaseDetailsViewState = {
6
6
  openKeys: Set<NodeKey>;