@stll/folio-core 0.68.0 → 0.69.0

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 (177) hide show
  1. package/dist/ai-edits/headless.js +2 -2
  2. package/dist/ai-edits/newListNumbering.d.ts +14 -1
  3. package/dist/ai-edits/newListNumbering.js +24 -1
  4. package/dist/ai-edits/pending-suggestions.js +2 -2
  5. package/dist/controller/canonicalClipboard.js +2 -2
  6. package/dist/controller/canonicalComposition.js +34 -5
  7. package/dist/controller/canonicalInput.js +4 -6
  8. package/dist/controller/canonicalLockGuard.d.ts +17 -2
  9. package/dist/controller/canonicalLockGuard.js +46 -1
  10. package/dist/controller/canonicalProjectionBlocks.d.ts +79 -0
  11. package/dist/controller/canonicalProjectionBlocks.js +75 -0
  12. package/dist/controller/canonicalPublicOperations.js +476 -100
  13. package/dist/controller/canonicalSeedContent.d.ts +12 -0
  14. package/dist/controller/canonicalSeedContent.js +131 -0
  15. package/dist/controller/canonicalSession.d.ts +53 -21
  16. package/dist/controller/canonicalSession.js +489 -210
  17. package/dist/controller/canonicalSourceNormalization.d.ts +21 -0
  18. package/dist/controller/canonicalSourceNormalization.js +148 -0
  19. package/dist/controller/canonicalStoryEditor.d.ts +1 -1
  20. package/dist/controller/canonicalStoryEditor.js +16 -12
  21. package/dist/controller/folioEditor.js +3 -0
  22. package/dist/controller/headerFooterEditorManager.d.ts +5 -0
  23. package/dist/controller/headerFooterEditorManager.js +7 -2
  24. package/dist/controller/hiddenEditorApi.d.ts +11 -2
  25. package/dist/controller/hiddenEditorApi.js +3 -0
  26. package/dist/controller/hiddenEditorManager.d.ts +7 -0
  27. package/dist/controller/hiddenEditorManager.js +66 -11
  28. package/dist/controller/layoutPipeline.js +2 -1
  29. package/dist/controller/layoutSession.d.ts +3 -0
  30. package/dist/controller/layoutSession.js +3 -1
  31. package/dist/controller/noteEditorManager.d.ts +5 -0
  32. package/dist/controller/noteEditorManager.js +7 -2
  33. package/dist/display-list/dom/renderDisplayListToDom.js +9 -7
  34. package/dist/document-operations.d.ts +1 -1
  35. package/dist/docx/canonicalSave.js +7 -2
  36. package/dist/docx/commentAnchorIndex.d.ts +19 -0
  37. package/dist/docx/commentAnchorIndex.js +55 -1
  38. package/dist/docx/containerChildren.js +1 -1
  39. package/dist/docx/contentTypeRegistry.js +1 -1
  40. package/dist/docx/hostCommentThreads.d.ts +11 -1
  41. package/dist/docx/hostCommentThreads.js +25 -2
  42. package/dist/docx/listModelNormalization.js +4 -5
  43. package/dist/docx/listNumberingInstances.d.ts +1 -1
  44. package/dist/docx/listNumberingInstances.js +2 -2
  45. package/dist/docx/numberingIds.d.ts +6 -0
  46. package/dist/docx/numberingIds.js +6 -1
  47. package/dist/docx/numberingReferenceNormalization.d.ts +4 -0
  48. package/dist/docx/numberingReferenceNormalization.js +12 -2
  49. package/dist/docx/paragraphPropertySource.d.ts +22 -0
  50. package/dist/docx/paragraphPropertySource.js +85 -16
  51. package/dist/docx/parser.js +2 -0
  52. package/dist/docx/removeHeaderFooterParts.js +1 -1
  53. package/dist/docx/reviewResolutionProvenance.js +72 -19
  54. package/dist/docx/serializer/documentSerializer.js +2 -1
  55. package/dist/docx/serializer/partNamespaces.d.ts +1 -1
  56. package/dist/docx/serializer/partNamespaces.js +1 -1
  57. package/dist/docx/server/build.d.ts +1 -1
  58. package/dist/docx/storyBlockReplay.js +15 -2
  59. package/dist/docx/structuralXmlPatch.js +25 -4
  60. package/dist/docx/xmlParser.d.ts +1 -1
  61. package/dist/docx/xmlParser.js +2 -3
  62. package/dist/i18n/messages/ar.gen.js +1 -0
  63. package/dist/i18n/messages/catalogs.gen.d.ts +17 -0
  64. package/dist/i18n/messages/catalogs.gen.js +17 -0
  65. package/dist/i18n/messages/cs.gen.js +1 -0
  66. package/dist/i18n/messages/de.gen.js +1 -0
  67. package/dist/i18n/messages/en.gen.js +1 -0
  68. package/dist/i18n/messages/es.gen.js +1 -0
  69. package/dist/i18n/messages/et.gen.js +1 -0
  70. package/dist/i18n/messages/fr.gen.js +1 -0
  71. package/dist/i18n/messages/he.gen.js +1 -0
  72. package/dist/i18n/messages/hi.gen.js +1 -0
  73. package/dist/i18n/messages/hu.gen.js +1 -0
  74. package/dist/i18n/messages/lt.gen.js +1 -0
  75. package/dist/i18n/messages/lv.gen.js +1 -0
  76. package/dist/i18n/messages/messages.gen.d.ts +1 -0
  77. package/dist/i18n/messages/pl.gen.js +1 -0
  78. package/dist/i18n/messages/pt-BR.gen.js +1 -0
  79. package/dist/i18n/messages/sk.gen.js +1 -0
  80. package/dist/i18n/messages/tr.gen.js +1 -0
  81. package/dist/i18n/messages/zh-CN.gen.js +1 -0
  82. package/dist/internal/pageBreakRunDescendantIndex.d.ts +7 -2
  83. package/dist/internal/pageBreakRunDescendantIndex.js +12 -3
  84. package/dist/internal/subtreeHolds.d.ts +12 -0
  85. package/dist/internal/subtreeHolds.js +25 -0
  86. package/dist/internal/wholeStoryRevisionResolution.js +1 -1
  87. package/dist/layout-bridge/cellSelectionHighlight.js +3 -3
  88. package/dist/layout-bridge/convert/flowBlockPostprocessing.js +20 -12
  89. package/dist/layout-bridge/convert/flowConversionShared.d.ts +15 -1
  90. package/dist/layout-bridge/convert/flowConversionShared.js +9 -1
  91. package/dist/layout-bridge/convert/paragraphAttrs.d.ts +15 -4
  92. package/dist/layout-bridge/convert/paragraphAttrs.js +11 -4
  93. package/dist/layout-bridge/convert/paragraphBlockCache.d.ts +26 -0
  94. package/dist/layout-bridge/convert/paragraphBlockCache.js +137 -0
  95. package/dist/layout-bridge/convert/paragraphConversion.d.ts +12 -2
  96. package/dist/layout-bridge/convert/paragraphConversion.js +37 -5
  97. package/dist/layout-bridge/convert/paragraphRuns.d.ts +2 -2
  98. package/dist/layout-bridge/convert/sectionBoundaries.js +16 -0
  99. package/dist/layout-bridge/convert/toFlowBlocks.js +144 -15
  100. package/dist/layout-bridge/convert/topLevelConversion.d.ts +74 -0
  101. package/dist/layout-bridge/convert/topLevelConversion.js +109 -0
  102. package/dist/layout-bridge/dom/clickToPositionDom.js +41 -40
  103. package/dist/layout-bridge/dom/findBodyPmSpans.js +4 -3
  104. package/dist/layout-bridge/dom/findHfPmSpans.js +10 -15
  105. package/dist/layout-bridge/dom/imeCaretAnchor.d.ts +8 -0
  106. package/dist/layout-bridge/dom/imeCaretAnchor.js +71 -7
  107. package/dist/layout-bridge/dom/textStreamDom.js +3 -2
  108. package/dist/layout-bridge/headerFooterLayout.js +12 -11
  109. package/dist/layout-bridge/tableInsertHover.js +2 -1
  110. package/dist/layout-engine/measure/cache.d.ts +2 -0
  111. package/dist/layout-engine/measure/cache.js +6 -1
  112. package/dist/layout-engine/measure/paragraphKeyMemo.d.ts +8 -0
  113. package/dist/layout-engine/measure/paragraphKeyMemo.js +92 -0
  114. package/dist/layout-engine/types.d.ts +6 -0
  115. package/dist/layout-painter/imageLayout.js +2 -1
  116. package/dist/layout-painter/pageShellStyles.d.ts +10 -0
  117. package/dist/layout-painter/pageShellStyles.js +32 -0
  118. package/dist/layout-painter/reconcileRenderedContent.d.ts +19 -0
  119. package/dist/layout-painter/reconcileRenderedContent.js +117 -0
  120. package/dist/layout-painter/renderFragment.js +4 -6
  121. package/dist/layout-painter/renderImage.js +2 -2
  122. package/dist/layout-painter/renderPage.js +8 -29
  123. package/dist/layout-painter/renderParagraph.js +3 -3
  124. package/dist/layout-painter/renderTable.js +9 -12
  125. package/dist/layout-painter/renderTextBox.js +2 -2
  126. package/dist/layout-painter/sdtBoundary.js +3 -2
  127. package/dist/paged-layout/blockGeometry.js +3 -2
  128. package/dist/paged-layout/editorScrollRoot.d.ts +9 -0
  129. package/dist/paged-layout/editorScrollRoot.js +10 -1
  130. package/dist/paged-layout/rangeProjection.js +5 -4
  131. package/dist/paged-layout/scrollToPmPosition.js +3 -3
  132. package/dist/paged-layout/selectionViewportRect.d.ts +6 -0
  133. package/dist/paged-layout/selectionViewportRect.js +8 -2
  134. package/dist/prosemirror/attrs/index.js +1 -0
  135. package/dist/prosemirror/commands/comments.d.ts +5 -2
  136. package/dist/prosemirror/commands/comments.js +88 -8
  137. package/dist/prosemirror/commentRecords.d.ts +137 -0
  138. package/dist/prosemirror/commentRecords.js +400 -0
  139. package/dist/prosemirror/conversion/fromProseDoc.js +9 -3
  140. package/dist/prosemirror/conversion/index.d.ts +1 -1
  141. package/dist/prosemirror/conversion/toProseDoc.d.ts +13 -4
  142. package/dist/prosemirror/conversion/toProseDoc.js +126 -38
  143. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +22 -0
  144. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +61 -32
  145. package/dist/prosemirror/extensions/marks/CommentExtension.js +3 -1
  146. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +3 -1
  147. package/dist/prosemirror/index.d.ts +1 -1
  148. package/dist/prosemirror/nativeSelection.d.ts +33 -0
  149. package/dist/prosemirror/nativeSelection.js +74 -0
  150. package/dist/prosemirror/numberedRefFields.d.ts +2 -0
  151. package/dist/prosemirror/numberedRefFields.js +16 -5
  152. package/dist/prosemirror/paragraphMarkJoin.d.ts +6 -8
  153. package/dist/prosemirror/paragraphMarkJoin.js +155 -16
  154. package/dist/prosemirror/plugins/contentControlWidgets.js +2 -2
  155. package/dist/prosemirror/plugins/documentNumbering.js +33 -14
  156. package/dist/prosemirror/plugins/suggestionMode.js +13 -1
  157. package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +23 -1
  158. package/dist/prosemirror/runIdentityAcrossRevisions.js +57 -8
  159. package/dist/prosemirror/schema/marks.d.ts +7 -1
  160. package/dist/prosemirror/storyListNumbering.js +7 -2
  161. package/dist/prosemirror/tableResize.d.ts +10 -9
  162. package/dist/prosemirror/tableResize.js +60 -49
  163. package/dist/prosemirror/textInput.d.ts +30 -1
  164. package/dist/prosemirror/textInput.js +144 -17
  165. package/dist/prosemirror/utils/visualLineNavigation.js +20 -18
  166. package/dist/prosemirror/validation.d.ts +19 -0
  167. package/dist/prosemirror/validation.js +78 -5
  168. package/dist/render-dom/HeaderFooterSelectionOverlay.js +5 -4
  169. package/dist/render-dom/RenderedDomContext.js +7 -6
  170. package/dist/types/canonicalCapabilities.d.ts +12 -11
  171. package/dist/types/canonicalCapabilities.js +12 -13
  172. package/dist/utils/findMatchView.js +4 -3
  173. package/dist/utils/formatToStyle.d.ts +1 -1
  174. package/dist/utils/mergeDocumentContent.js +2 -2
  175. package/dist/utils/paintedPositions.d.ts +60 -0
  176. package/dist/utils/paintedPositions.js +101 -0
  177. package/package.json +2 -3
@@ -1,5 +1,6 @@
1
1
  import { findHfCaretSpan, findHfPmSpans } from "../layout-bridge/dom/findHfPmSpans.js";
2
2
  import { createTextStreamRange, descendantTextNodes, totalTextLength } from "../layout-bridge/dom/textStreamDom.js";
3
+ import { readPaintedEnd, readPaintedStart } from "../utils/paintedPositions.js";
3
4
  // src/render-dom/HeaderFooterSelectionOverlay.ts
4
5
  const CARET_CLASS = "folio-hf-selection-caret";
5
6
  const RANGE_CLASS = "folio-hf-selection-rect";
@@ -25,8 +26,8 @@ const resolveHeaderFooterSelectionGeometry = (pagesContainer, selection, zoom) =
25
26
  let left = hit.edge === "right" ? anchorRect.right : anchorRect.left;
26
27
  let top = anchorRect.top;
27
28
  let height = anchorRect.height || 16;
28
- const pmStart = Number.parseInt(hit.element.dataset["pmStart"] ?? "", 10);
29
- const pmEnd = Number.parseInt(hit.element.dataset["pmEnd"] ?? "", 10);
29
+ const pmStart = readPaintedStart(hit.element) ?? NaN;
30
+ const pmEnd = readPaintedEnd(hit.element) ?? NaN;
30
31
  const textNodes = descendantTextNodes(hit.element);
31
32
  if (textNodes.length > 0 && Number.isFinite(pmStart) && Number.isFinite(pmEnd)) {
32
33
  const offset = Math.min(Math.max(0, selection.from - pmStart), totalTextLength(textNodes));
@@ -53,8 +54,8 @@ const resolveHeaderFooterSelectionGeometry = (pagesContainer, selection, zoom) =
53
54
  const to = Math.max(selection.from, selection.to);
54
55
  const ranges = [];
55
56
  for (const span of findHfPmSpans(pageScope, selection.kind, selection.rId)) {
56
- const spanStart = Number.parseInt(span.dataset["pmStart"] ?? "", 10);
57
- const spanEnd = Number.parseInt(span.dataset["pmEnd"] ?? "", 10);
57
+ const spanStart = readPaintedStart(span) ?? NaN;
58
+ const spanEnd = readPaintedEnd(span) ?? NaN;
58
59
  if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) continue;
59
60
  if (spanEnd <= from || spanStart >= to) continue;
60
61
  const textNodes = descendantTextNodes(span);
@@ -2,6 +2,7 @@ import { findCollapsedLineEdgeCaretTarget, findParagraphGapCaretTarget } from ".
2
2
  import { findBodyEmptyRuns, findBodyPmSpans } from "../layout-bridge/dom/findBodyPmSpans.js";
3
3
  import { createTextStreamRange, descendantTextNodes, measurePaintedSpanRange, totalTextLength } from "../layout-bridge/dom/textStreamDom.js";
4
4
  import { closestHtmlElement } from "../utils/domGuards.js";
5
+ import { readPaintedEnd, readPaintedStart } from "../utils/paintedPositions.js";
5
6
  // src/render-dom/RenderedDomContext.ts
6
7
  /**
7
8
  * Framework-neutral mapping from ProseMirror positions to the DOM emitted by
@@ -29,8 +30,8 @@ var RenderedDomContextImpl = class {
29
30
  height: lineHeightFor(collapsedTarget.span, this.#zoom)
30
31
  };
31
32
  for (const span of spans) {
32
- const pmStart = Number(span.dataset["pmStart"]);
33
- const pmEnd = Number(span.dataset["pmEnd"]);
33
+ const pmStart = readPaintedStart(span) ?? NaN;
34
+ const pmEnd = readPaintedEnd(span) ?? NaN;
34
35
  if (!(span.classList.contains("layout-run-tab") ? pmPos >= pmStart && pmPos < pmEnd : pmPos >= pmStart && pmPos <= pmEnd)) continue;
35
36
  const spanRect = span.getBoundingClientRect();
36
37
  if (span.classList.contains("layout-run-tab")) return {
@@ -63,8 +64,8 @@ var RenderedDomContextImpl = class {
63
64
  for (const emptyRun of findBodyEmptyRuns(this.#pagesContainer)) {
64
65
  const paragraph = closestHtmlElement(emptyRun, ".layout-paragraph");
65
66
  if (!paragraph) continue;
66
- const pmStart = Number(paragraph.dataset["pmStart"]);
67
- const pmEnd = Number(paragraph.dataset["pmEnd"]);
67
+ const pmStart = readPaintedStart(paragraph) ?? NaN;
68
+ const pmEnd = readPaintedEnd(paragraph) ?? NaN;
68
69
  if (pmPos < pmStart || pmPos > pmEnd) continue;
69
70
  const rect = emptyRun.getBoundingClientRect();
70
71
  return {
@@ -77,8 +78,8 @@ var RenderedDomContextImpl = class {
77
78
  }
78
79
  findElementsForRange(from, to) {
79
80
  return findBodyPmSpans(this.#pagesContainer).filter((span) => {
80
- const pmStart = Number(span.dataset["pmStart"]);
81
- return Number(span.dataset["pmEnd"]) > from && pmStart < to;
81
+ const pmStart = readPaintedStart(span) ?? NaN;
82
+ return (readPaintedEnd(span) ?? NaN) > from && pmStart < to;
82
83
  });
83
84
  }
84
85
  getRectsForRange(from, to) {
@@ -24,7 +24,6 @@ export declare const CANONICAL_GAP: {
24
24
  readonly publicTableStructure: "publicOps.tableStructure";
25
25
  readonly publicPendingParagraphMarkProperties: "publicOps.pendingParagraphMarkProperties";
26
26
  readonly publicHeadlessSession: "publicOps.headlessSession";
27
- readonly publicSecondaryStories: "publicOps.secondaryStories";
28
27
  };
29
28
  export type CanonicalGap = (typeof CANONICAL_GAP)[keyof typeof CANONICAL_GAP];
30
29
  /**
@@ -40,10 +39,19 @@ export declare const CANONICAL_RULE_MESSAGE_KEYS: {
40
39
  readonly contentControlLock: "editor.contentLocked";
41
40
  };
42
41
  /**
43
- * What a host shows for a refusal: the editor's own message for a rule the
44
- * document states, which a host translates, and the session's for a gap.
42
+ * The editor message, in the folio catalog, a host shows for a refusal under
43
+ * any gap: the change cannot be made here yet.
45
44
  */
46
- export declare const canonicalRefusalNotice: (ground: CanonicalRefusalGround, message: string, translate: (key: (typeof CANONICAL_RULE_MESSAGE_KEYS)[CanonicalRule]) => string) => string;
45
+ export declare const CANONICAL_GAP_MESSAGE_KEY: "editor.changeUnavailable";
46
+ /** A catalog key a refusal notice reads. */
47
+ export type CanonicalRefusalMessageKey = (typeof CANONICAL_RULE_MESSAGE_KEYS)[CanonicalRule] | typeof CANONICAL_GAP_MESSAGE_KEY;
48
+ /**
49
+ * What a host shows for a refusal, always from the folio catalog, which the
50
+ * host translates: the editor's own message for a rule the document states,
51
+ * and that the change cannot be made here yet for a gap. The session's own
52
+ * message describes the refusal for logs and `onError`, never for the user.
53
+ */
54
+ export declare const canonicalRefusalNotice: (ground: CanonicalRefusalGround, translate: (key: CanonicalRefusalMessageKey) => string) => string;
47
55
  /**
48
56
  * The ground for a refusal: a capability the session does not have yet, or a
49
57
  * rule the document states. A host tells "not supported yet" from "not
@@ -197,13 +205,6 @@ export declare const CANONICAL_CAPABILITIES: {
197
205
  readonly adapters: readonly ["react", "vue"];
198
206
  readonly summary: "Separate paragraph property edits refuse while the paragraph mark is pending deletion; atomic merge properties remain supported.";
199
207
  };
200
- readonly "publicOps.secondaryStories": {
201
- readonly owner: "document-operations";
202
- readonly defaultSessionMutation: "pm-public-operations";
203
- readonly kind: "refusal";
204
- readonly adapters: readonly ["react", "vue"];
205
- readonly summary: "Public secondary-story batches refuse until canonical story routing is available.";
206
- };
207
208
  readonly "publicOps.headlessSession": {
208
209
  readonly owner: "document-operations";
209
210
  readonly defaultSessionMutation: "pm-headless-reviewer";
@@ -24,8 +24,7 @@ const CANONICAL_GAP = {
24
24
  publicUnsupportedInline: "publicOps.unsupportedInline",
25
25
  publicTableStructure: "publicOps.tableStructure",
26
26
  publicPendingParagraphMarkProperties: "publicOps.pendingParagraphMarkProperties",
27
- publicHeadlessSession: "publicOps.headlessSession",
28
- publicSecondaryStories: "publicOps.secondaryStories"
27
+ publicHeadlessSession: "publicOps.headlessSession"
29
28
  };
30
29
  /**
31
30
  * Rules a document states for itself. A refusal under one is the correct
@@ -35,10 +34,17 @@ const CANONICAL_RULE = { contentControlLock: "contentControlLock" };
35
34
  /** The editor message, in the folio catalog, a host shows for a refusal under each rule. */
36
35
  const CANONICAL_RULE_MESSAGE_KEYS = { contentControlLock: "editor.contentLocked" };
37
36
  /**
38
- * What a host shows for a refusal: the editor's own message for a rule the
39
- * document states, which a host translates, and the session's for a gap.
37
+ * The editor message, in the folio catalog, a host shows for a refusal under
38
+ * any gap: the change cannot be made here yet.
40
39
  */
41
- const canonicalRefusalNotice = (ground, message, translate) => ground.rule === void 0 ? message : translate(CANONICAL_RULE_MESSAGE_KEYS[ground.rule]);
40
+ const CANONICAL_GAP_MESSAGE_KEY = "editor.changeUnavailable";
41
+ /**
42
+ * What a host shows for a refusal, always from the folio catalog, which the
43
+ * host translates: the editor's own message for a rule the document states,
44
+ * and that the change cannot be made here yet for a gap. The session's own
45
+ * message describes the refusal for logs and `onError`, never for the user.
46
+ */
47
+ const canonicalRefusalNotice = (ground, translate) => translate(ground.rule === void 0 ? CANONICAL_GAP_MESSAGE_KEY : CANONICAL_RULE_MESSAGE_KEYS[ground.rule]);
42
48
  const CANONICAL_CAPABILITIES = {
43
49
  [CANONICAL_GAP.authorityRouting]: {
44
50
  owner: "controller",
@@ -178,13 +184,6 @@ const CANONICAL_CAPABILITIES = {
178
184
  adapters: ["react", "vue"],
179
185
  summary: "Separate paragraph property edits refuse while the paragraph mark is pending deletion; atomic merge properties remain supported."
180
186
  },
181
- [CANONICAL_GAP.publicSecondaryStories]: {
182
- owner: "document-operations",
183
- defaultSessionMutation: "pm-public-operations",
184
- kind: "refusal",
185
- adapters: ["react", "vue"],
186
- summary: "Public secondary-story batches refuse until canonical story routing is available."
187
- },
188
187
  [CANONICAL_GAP.publicHeadlessSession]: {
189
188
  owner: "document-operations",
190
189
  defaultSessionMutation: "pm-headless-reviewer",
@@ -205,4 +204,4 @@ const CANONICAL_CAPABILITIES = {
205
204
  */
206
205
  const usesCanonicalSession = (session, _gap) => session === "canonical";
207
206
  const canonicalRefusalMessage = (gap, message) => `[${gap}] ${message}`;
208
- export { CANONICAL_CAPABILITIES, CANONICAL_GAP, CANONICAL_RULE, CANONICAL_RULE_MESSAGE_KEYS, canonicalRefusalMessage, canonicalRefusalNotice, usesCanonicalSession };
207
+ export { CANONICAL_CAPABILITIES, CANONICAL_GAP, CANONICAL_GAP_MESSAGE_KEY, CANONICAL_RULE, CANONICAL_RULE_MESSAGE_KEYS, canonicalRefusalMessage, canonicalRefusalNotice, usesCanonicalSession };
@@ -3,6 +3,7 @@ import { selectSectionHeaderFooterRIds } from "../layout-painter/renderPage.js";
3
3
  import { getEditorScrollRoot, scrollEditorElementIntoView } from "../paged-layout/editorScrollRoot.js";
4
4
  import { headerFooterToProseDoc, toProseDoc } from "../prosemirror/conversion/toProseDoc.js";
5
5
  import { resolveFindMatchRanges } from "../prosemirror/findReplaceSelection.js";
6
+ import { PAINTED_RANGE_SELECTOR, readPaintedEnd, readPaintedStart } from "./paintedPositions.js";
6
7
  import { OP_STORIES, documentStories, storyBody } from "@stll/docx-core/ops";
7
8
  // src/utils/findMatchView.ts
8
9
  const storyKey = (story) => {
@@ -195,7 +196,7 @@ const createFindMatchView = (options) => {
195
196
  marks.clear();
196
197
  targets.clear();
197
198
  const spans = /* @__PURE__ */ new Map();
198
- for (const span of container.querySelectorAll(".layout-page span[data-pm-start][data-pm-end], .layout-page span[data-decoration-start][data-decoration-end]")) {
199
+ for (const span of container.querySelectorAll(`.layout-page span${PAINTED_RANGE_SELECTOR}, .layout-page span[data-decoration-start][data-decoration-end]`)) {
199
200
  const key = spanStoryKey(span);
200
201
  const group = spans.get(key);
201
202
  if (group) group.push(span);
@@ -400,6 +401,6 @@ const createFindMatchView = (options) => {
400
401
  }
401
402
  };
402
403
  };
403
- const spanStart = (span) => Number(span.dataset["pmStart"] ?? span.dataset["decorationStart"]);
404
- const spanEnd = (span) => Number(span.dataset["pmEnd"] ?? span.dataset["decorationEnd"]);
404
+ const spanStart = (span) => readPaintedStart(span) ?? Number(span.dataset["decorationStart"]);
405
+ const spanEnd = (span) => readPaintedEnd(span) ?? Number(span.dataset["decorationEnd"]);
405
406
  export { createFindMatchView, getRenderedSearchStories, resolveDocumentFindRanges };
@@ -1,5 +1,5 @@
1
- import { ColorValue } from "../types/colors.js";
2
1
  import { document_d_exports } from "../types/document.js";
2
+ import { ColorValue } from "../types/colors.js";
3
3
  import { Properties } from "csstype";
4
4
  type CSSProperties = Properties<string | number>;
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { createNumberingIdAllocator } from "../docx/numberingIds.js";
1
+ import { createNumberingIdAllocator, numberingNumIdsTaken } from "../docx/numberingIds.js";
2
2
  import { paragraphNumberingReferenceId } from "../docx/numberingReference.js";
3
3
  import { cloneParagraphWithoutPropertySource } from "../docx/paragraphPropertySource.js";
4
4
  // src/utils/mergeDocumentContent.ts
@@ -62,7 +62,7 @@ function mergeDocumentContent(target, source) {
62
62
  };
63
63
  function remapContentNumbering(content, numbering) {
64
64
  const existingAbstractIds = [...(targetNumbering?.abstractNums ?? []).map(({ abstractNumId }) => abstractNumId), ...numbering.abstractNums.map(({ abstractNumId }) => abstractNumId)];
65
- const existingNumIds = [...(targetNumbering?.nums ?? []).map(({ numId }) => numId), ...numbering.nums.map(({ numId }) => numId)];
65
+ const existingNumIds = [...numberingNumIdsTaken(targetNumbering), ...numberingNumIdsTaken(numbering)];
66
66
  const abstractIds = createNumberingIdAllocator("abstract", existingAbstractIds);
67
67
  const numIds = createNumberingIdAllocator("num", existingNumIds);
68
68
  const abstractNumIdRemap = /* @__PURE__ */ new Map();
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The one owner of the editor positions a painted element carries.
3
+ *
4
+ * The painter marks the elements it draws with the editor document positions
5
+ * they show: a run, a paragraph line, a table, a table cell, an image, a text
6
+ * box, a content-control boundary. Hit testing, caret and selection drawing,
7
+ * scrolling to a position and the hosts' pointer handling read them back.
8
+ *
9
+ * How a position is stored on an element is this module's business alone:
10
+ * every write and every read goes through it, and the
11
+ * `folio-painted-positions/position-attribute-owner` lint rule forbids
12
+ * touching the attributes anywhere else. That keeps the storage free to
13
+ * change in one place, for instance to positions relative to the painted
14
+ * block, without auditing every reader.
15
+ */
16
+ /** Elements that show where they start. */
17
+ export declare const PAINTED_START_SELECTOR = "[data-pm-start]";
18
+ /** Elements that show where they start and where they end. */
19
+ export declare const PAINTED_RANGE_SELECTOR = "[data-pm-start][data-pm-end]";
20
+ /** Elements that carry any painted position. */
21
+ export declare const PAINTED_POSITION_SELECTOR: string;
22
+ /** Elements that show a range starting exactly at `position`. */
23
+ export declare const paintedStartSelector: (position: number) => string;
24
+ /**
25
+ * The attributes a node can differ in from a fresh painting of it while still
26
+ * showing the same thing: an edit before it shifts them and nothing else.
27
+ */
28
+ export declare const PAINTED_POSITION_ATTRIBUTES: ReadonlySet<string>;
29
+ /** An element that can carry painted positions. */
30
+ export type PaintedElement = Pick<HTMLElement, "dataset">;
31
+ /** Where the content `element` shows starts. */
32
+ export declare const readPaintedStart: (element: PaintedElement) => number | undefined;
33
+ /** Where the content `element` shows ends. */
34
+ export declare const readPaintedEnd: (element: PaintedElement) => number | undefined;
35
+ /** Where the table a table handle or overlay element belongs to starts. */
36
+ export declare const readPaintedTableStart: (element: PaintedElement) => number | undefined;
37
+ /** The raw content-control boundary key a painted box carries. */
38
+ export declare const readPaintedContentControlKey: (element: PaintedElement) => string | undefined;
39
+ /** Whether `element` shows where it starts. */
40
+ export declare const hasPaintedStart: (element: PaintedElement) => boolean;
41
+ /** Whether `element` shows where it starts and where it ends. */
42
+ export declare const hasPaintedRange: (element: PaintedElement) => boolean;
43
+ /** Mark `element` as showing content that starts at `position`. */
44
+ export declare const writePaintedStart: (element: PaintedElement, position: number) => void;
45
+ /** Mark `element` as showing content that ends at `position`. */
46
+ export declare const writePaintedEnd: (element: PaintedElement, position: number) => void;
47
+ /**
48
+ * Mark `element` with the range it shows. A side left `undefined` is not
49
+ * written, as for a fragment that knows only one of them.
50
+ */
51
+ export declare const writePaintedRange: (element: PaintedElement, start: number | undefined, end: number | undefined) => void;
52
+ /** Mark a table handle or overlay element with its table's start. */
53
+ export declare const writePaintedTableStart: (element: PaintedElement, position: number) => void;
54
+ /** Mark a content-control box with the boundary it draws. */
55
+ export declare const writePaintedContentControlKey: (element: PaintedElement, position: number) => void;
56
+ /**
57
+ * Move every painted position under `root` (not `root` itself) by `delta`,
58
+ * for content an edit before it moved without changing it.
59
+ */
60
+ export declare const shiftPaintedPositions: (root: ParentNode, delta: number) => void;
@@ -0,0 +1,101 @@
1
+ // src/utils/paintedPositions.ts
2
+ /**
3
+ * The one owner of the editor positions a painted element carries.
4
+ *
5
+ * The painter marks the elements it draws with the editor document positions
6
+ * they show: a run, a paragraph line, a table, a table cell, an image, a text
7
+ * box, a content-control boundary. Hit testing, caret and selection drawing,
8
+ * scrolling to a position and the hosts' pointer handling read them back.
9
+ *
10
+ * How a position is stored on an element is this module's business alone:
11
+ * every write and every read goes through it, and the
12
+ * `folio-painted-positions/position-attribute-owner` lint rule forbids
13
+ * touching the attributes anywhere else. That keeps the storage free to
14
+ * change in one place, for instance to positions relative to the painted
15
+ * block, without auditing every reader.
16
+ */
17
+ const START_ATTRIBUTE = "data-pm-start";
18
+ const END_ATTRIBUTE = "data-pm-end";
19
+ const TABLE_START_ATTRIBUTE = "data-table-pm-start";
20
+ const CONTENT_CONTROL_ATTRIBUTE = "data-sdt-pm-pos";
21
+ /** Elements that show where they start. */
22
+ const PAINTED_START_SELECTOR = `[${START_ATTRIBUTE}]`;
23
+ /** Elements that show where they start and where they end. */
24
+ const PAINTED_RANGE_SELECTOR = `[${START_ATTRIBUTE}][${END_ATTRIBUTE}]`;
25
+ /** Elements that carry any painted position. */
26
+ const PAINTED_POSITION_SELECTOR = [
27
+ START_ATTRIBUTE,
28
+ END_ATTRIBUTE,
29
+ TABLE_START_ATTRIBUTE
30
+ ].map((attribute) => `[${attribute}]`).join(", ");
31
+ /** Elements that show a range starting exactly at `position`. */
32
+ const paintedStartSelector = (position) => `[${START_ATTRIBUTE}="${String(position)}"]`;
33
+ /**
34
+ * The attributes a node can differ in from a fresh painting of it while still
35
+ * showing the same thing: an edit before it shifts them and nothing else.
36
+ */
37
+ const PAINTED_POSITION_ATTRIBUTES = /* @__PURE__ */ new Set([
38
+ START_ATTRIBUTE,
39
+ END_ATTRIBUTE,
40
+ TABLE_START_ATTRIBUTE,
41
+ CONTENT_CONTROL_ATTRIBUTE
42
+ ]);
43
+ /** A painted value, or `undefined` when the element carries none. */
44
+ const readPosition = (element, key) => {
45
+ const value = element.dataset[key];
46
+ return value === void 0 || value === "" ? void 0 : Number(value);
47
+ };
48
+ /** Where the content `element` shows starts. */
49
+ const readPaintedStart = (element) => readPosition(element, "pmStart");
50
+ /** Where the content `element` shows ends. */
51
+ const readPaintedEnd = (element) => readPosition(element, "pmEnd");
52
+ /** Where the table a table handle or overlay element belongs to starts. */
53
+ const readPaintedTableStart = (element) => readPosition(element, "tablePmStart");
54
+ /** The raw content-control boundary key a painted box carries. */
55
+ const readPaintedContentControlKey = (element) => element.dataset["sdtPmPos"];
56
+ /** Whether `element` shows where it starts. */
57
+ const hasPaintedStart = (element) => readPaintedStart(element) !== void 0;
58
+ /** Whether `element` shows where it starts and where it ends. */
59
+ const hasPaintedRange = (element) => readPaintedStart(element) !== void 0 && readPaintedEnd(element) !== void 0;
60
+ /** Mark `element` as showing content that starts at `position`. */
61
+ const writePaintedStart = (element, position) => {
62
+ element.dataset["pmStart"] = String(position);
63
+ };
64
+ /** Mark `element` as showing content that ends at `position`. */
65
+ const writePaintedEnd = (element, position) => {
66
+ element.dataset["pmEnd"] = String(position);
67
+ };
68
+ /**
69
+ * Mark `element` with the range it shows. A side left `undefined` is not
70
+ * written, as for a fragment that knows only one of them.
71
+ */
72
+ const writePaintedRange = (element, start, end) => {
73
+ if (start !== void 0) writePaintedStart(element, start);
74
+ if (end !== void 0) writePaintedEnd(element, end);
75
+ };
76
+ /** Mark a table handle or overlay element with its table's start. */
77
+ const writePaintedTableStart = (element, position) => {
78
+ element.dataset["tablePmStart"] = String(position);
79
+ };
80
+ /** Mark a content-control box with the boundary it draws. */
81
+ const writePaintedContentControlKey = (element, position) => {
82
+ element.dataset["sdtPmPos"] = String(position);
83
+ };
84
+ const shiftPosition = (element, key, delta) => {
85
+ const value = element.dataset[key];
86
+ if (value === void 0) return;
87
+ const position = Number(value);
88
+ if (Number.isFinite(position)) element.dataset[key] = String(position + delta);
89
+ };
90
+ /**
91
+ * Move every painted position under `root` (not `root` itself) by `delta`,
92
+ * for content an edit before it moved without changing it.
93
+ */
94
+ const shiftPaintedPositions = (root, delta) => {
95
+ for (const element of root.querySelectorAll(PAINTED_POSITION_SELECTOR)) {
96
+ shiftPosition(element, "pmStart", delta);
97
+ shiftPosition(element, "pmEnd", delta);
98
+ shiftPosition(element, "tablePmStart", delta);
99
+ }
100
+ };
101
+ export { PAINTED_POSITION_ATTRIBUTES, PAINTED_POSITION_SELECTOR, PAINTED_RANGE_SELECTOR, PAINTED_START_SELECTOR, hasPaintedRange, hasPaintedStart, paintedStartSelector, readPaintedContentControlKey, readPaintedEnd, readPaintedStart, readPaintedTableStart, shiftPaintedPositions, writePaintedContentControlKey, writePaintedEnd, writePaintedRange, writePaintedStart, writePaintedTableStart };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-core",
3
- "version": "0.68.0",
3
+ "version": "0.69.0",
4
4
  "description": "Headless, framework-neutral core of folio: the OOXML (.docx) parser, document model, ProseMirror integration, and page-layout engine. No React.",
5
5
  "keywords": [
6
6
  "document-model",
@@ -173,8 +173,7 @@
173
173
  "perf": "bun scripts/profile-editor.ts"
174
174
  },
175
175
  "dependencies": {
176
- "@stll/docx-core": "^0.43.0",
177
- "@stll/docx-utils": "^0.2.0",
176
+ "@stll/docx-core": "^0.43.1",
178
177
  "@stll/template-conditions": "^0.6.2",
179
178
  "@stll/utf8-boundaries": "0.2.0",
180
179
  "better-result": "3.0.1",