@stll/folio-core 0.54.1 → 0.55.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 (251) hide show
  1. package/dist/ai-edits/apply.d.ts +1 -1
  2. package/dist/ai-edits/apply.js +40 -32
  3. package/dist/ai-edits/headless.d.ts +1 -2
  4. package/dist/ai-edits/headless.js +13 -27
  5. package/dist/ai-edits/read.d.ts +1 -0
  6. package/dist/ai-edits/read.js +7 -2
  7. package/dist/ai-edits/table-mutation-plan.d.ts +2 -1
  8. package/dist/ai-edits/table-mutation-plan.js +39 -1
  9. package/dist/ai-suggestions/apply.d.ts +1 -1
  10. package/dist/ai-suggestions/apply.js +3 -2
  11. package/dist/compare/compare.js +2 -1
  12. package/dist/compare/content-types.d.ts +3 -15
  13. package/dist/controller/canonicalComposition.d.ts +36 -0
  14. package/dist/controller/canonicalComposition.js +168 -0
  15. package/dist/controller/canonicalInput.d.ts +45 -0
  16. package/dist/controller/canonicalInput.js +338 -0
  17. package/dist/controller/canonicalOperations.d.ts +22 -0
  18. package/dist/controller/canonicalOperations.js +85 -0
  19. package/dist/controller/canonicalReview.d.ts +12 -0
  20. package/dist/controller/canonicalReview.js +19 -0
  21. package/dist/controller/canonicalSession.d.ts +149 -0
  22. package/dist/controller/canonicalSession.js +1038 -0
  23. package/dist/controller/canonicalStoryEditor.d.ts +34 -0
  24. package/dist/controller/canonicalStoryEditor.js +82 -0
  25. package/dist/controller/canonicalStructure.d.ts +16 -0
  26. package/dist/controller/canonicalStructure.js +269 -0
  27. package/dist/controller/folioEditor.d.ts +1 -1
  28. package/dist/controller/folioEditor.js +9 -0
  29. package/dist/controller/headerFooterEditorManager.d.ts +4 -0
  30. package/dist/controller/headerFooterEditorManager.js +71 -3
  31. package/dist/controller/hiddenEditorApi.d.ts +35 -0
  32. package/dist/controller/hiddenEditorApi.js +25 -8
  33. package/dist/controller/hiddenEditorManager.d.ts +11 -2
  34. package/dist/controller/hiddenEditorManager.js +456 -30
  35. package/dist/controller/layoutPipeline.d.ts +1 -1
  36. package/dist/controller/layoutPipeline.js +2 -0
  37. package/dist/controller/noteEditorManager.d.ts +4 -0
  38. package/dist/controller/noteEditorManager.js +113 -15
  39. package/dist/docx/attributeRemainder.js +1 -0
  40. package/dist/docx/bookmarkIds.d.ts +11 -0
  41. package/dist/docx/bookmarkIds.js +33 -0
  42. package/dist/docx/canonicalSessionInput.d.ts +11 -0
  43. package/dist/docx/canonicalSessionInput.js +27 -0
  44. package/dist/docx/canonicalStoryRepack.d.ts +10 -0
  45. package/dist/docx/canonicalStoryRepack.js +41 -0
  46. package/dist/docx/contentTypeRegistry.d.ts +8 -0
  47. package/dist/docx/contentTypeRegistry.js +64 -0
  48. package/dist/docx/documentParser.d.ts +14 -1
  49. package/dist/docx/documentParser.js +17 -4
  50. package/dist/docx/drawingIdNormalization.js +23 -8
  51. package/dist/docx/ensureParaIds.d.ts +12 -1
  52. package/dist/docx/ensureParaIds.js +173 -213
  53. package/dist/docx/foldedListNumberFields.d.ts +85 -0
  54. package/dist/docx/foldedListNumberFields.js +267 -0
  55. package/dist/docx/headerFooterVerbatim.d.ts +14 -1
  56. package/dist/docx/headerFooterVerbatim.js +95 -2
  57. package/dist/docx/listNumberingInstances.js +11 -9
  58. package/dist/docx/noteIds.d.ts +9 -0
  59. package/dist/docx/noteIds.js +17 -0
  60. package/dist/docx/noteReferenceMark.d.ts +3 -1
  61. package/dist/docx/noteReferenceMark.js +15 -14
  62. package/dist/docx/numberingIds.d.ts +14 -0
  63. package/dist/docx/numberingIds.js +16 -0
  64. package/dist/docx/numberingParser.d.ts +3 -1
  65. package/dist/docx/numberingParser.js +17 -3
  66. package/dist/docx/numericIdAllocator.d.ts +12 -0
  67. package/dist/docx/numericIdAllocator.js +33 -0
  68. package/dist/docx/numericIdNormalization.d.ts +16 -0
  69. package/dist/docx/numericIdNormalization.js +174 -0
  70. package/dist/docx/packageParts.d.ts +3 -1
  71. package/dist/docx/packageParts.js +65 -16
  72. package/dist/docx/paragraphMarkPropertyPresence.d.ts +9 -0
  73. package/dist/docx/paragraphMarkPropertyPresence.js +21 -0
  74. package/dist/docx/paragraphParser.js +101 -53
  75. package/dist/docx/paragraphPropertySource.d.ts +15 -1
  76. package/dist/docx/paragraphPropertySource.js +76 -22
  77. package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
  78. package/dist/docx/parser.js +19 -6
  79. package/dist/docx/rasterMime.d.ts +64 -0
  80. package/dist/docx/rasterMime.js +116 -0
  81. package/dist/docx/replyToComment.js +13 -6
  82. package/dist/docx/reviewHistoryNamespace.d.ts +4 -0
  83. package/dist/docx/reviewHistoryNamespace.js +4 -0
  84. package/dist/docx/reviewResolutionProvenance.d.ts +25 -0
  85. package/dist/docx/reviewResolutionProvenance.js +153 -0
  86. package/dist/docx/rezip.d.ts +7 -3
  87. package/dist/docx/rezip.js +121 -52
  88. package/dist/docx/runConsolidator.d.ts +2 -58
  89. package/dist/docx/runConsolidator.js +3 -175
  90. package/dist/docx/runParser.d.ts +2 -1
  91. package/dist/docx/runParser.js +156 -116
  92. package/dist/docx/saveDiagnostics.d.ts +11 -0
  93. package/dist/docx/saveDiagnostics.js +0 -0
  94. package/dist/docx/selectiveSave.d.ts +2 -1
  95. package/dist/docx/selectiveSave.js +14 -1
  96. package/dist/docx/selectiveXmlPatch.d.ts +16 -8
  97. package/dist/docx/selectiveXmlPatch.js +74 -2
  98. package/dist/docx/serializer/headerFooterSerializer.d.ts +5 -1
  99. package/dist/docx/serializer/headerFooterSerializer.js +19 -11
  100. package/dist/docx/serializer/noteSerializer.d.ts +2 -2
  101. package/dist/docx/serializer/noteSerializer.js +24 -8
  102. package/dist/docx/serializer/paragraphSerializer.js +41 -4
  103. package/dist/docx/serializer/partNamespaces.js +6 -3
  104. package/dist/docx/serializer/runSerializer.js +8 -5
  105. package/dist/docx/serializer/trackedChangeAttributes.js +7 -1
  106. package/dist/docx/server/build.js +14 -3
  107. package/dist/docx/server/createBilingualDocument.js +10 -9
  108. package/dist/docx/settingsHeaderFooterUpdate.d.ts +5 -0
  109. package/dist/docx/settingsHeaderFooterUpdate.js +90 -0
  110. package/dist/docx/settingsParser.d.ts +1 -2
  111. package/dist/docx/settingsParser.js +5 -6
  112. package/dist/docx/storyBlockReplay.d.ts +11 -0
  113. package/dist/docx/storyBlockReplay.js +367 -0
  114. package/dist/docx/streamingXmlParser.d.ts +31 -1
  115. package/dist/docx/streamingXmlParser.js +136 -21
  116. package/dist/docx/structuralXmlPatch.js +8 -1
  117. package/dist/docx/unzip.d.ts +3 -1
  118. package/dist/docx/unzip.js +36 -16
  119. package/dist/docx/verbatimCapture.d.ts +3 -1
  120. package/dist/docx/verbatimCapture.js +49 -6
  121. package/dist/i18n/messages/ar.gen.d.ts +5 -0
  122. package/dist/i18n/messages/ar.gen.js +656 -0
  123. package/dist/i18n/messages/cs.gen.d.ts +5 -0
  124. package/dist/i18n/messages/cs.gen.js +656 -0
  125. package/dist/i18n/messages/de.gen.d.ts +5 -0
  126. package/dist/i18n/messages/de.gen.js +656 -0
  127. package/dist/i18n/messages/en.gen.d.ts +5 -0
  128. package/dist/i18n/messages/en.gen.js +656 -0
  129. package/dist/i18n/messages/es.gen.d.ts +5 -0
  130. package/dist/i18n/messages/es.gen.js +656 -0
  131. package/dist/i18n/messages/et.gen.d.ts +5 -0
  132. package/dist/i18n/messages/et.gen.js +656 -0
  133. package/dist/i18n/messages/fr.gen.d.ts +5 -0
  134. package/dist/i18n/messages/fr.gen.js +656 -0
  135. package/dist/i18n/messages/he.gen.d.ts +5 -0
  136. package/dist/i18n/messages/he.gen.js +656 -0
  137. package/dist/i18n/messages/hi.gen.d.ts +5 -0
  138. package/dist/i18n/messages/hi.gen.js +656 -0
  139. package/dist/i18n/messages/hu.gen.d.ts +5 -0
  140. package/dist/i18n/messages/hu.gen.js +656 -0
  141. package/dist/i18n/messages/locales.d.ts +5 -0
  142. package/dist/i18n/messages/locales.js +22 -0
  143. package/dist/i18n/messages/lt.gen.d.ts +5 -0
  144. package/dist/i18n/messages/lt.gen.js +656 -0
  145. package/dist/i18n/messages/lv.gen.d.ts +5 -0
  146. package/dist/i18n/messages/lv.gen.js +656 -0
  147. package/dist/i18n/messages/pl.gen.d.ts +5 -0
  148. package/dist/i18n/messages/pl.gen.js +656 -0
  149. package/dist/i18n/messages/pt-BR.gen.d.ts +5 -0
  150. package/dist/i18n/messages/pt-BR.gen.js +656 -0
  151. package/dist/i18n/messages/sk.gen.d.ts +5 -0
  152. package/dist/i18n/messages/sk.gen.js +656 -0
  153. package/dist/i18n/messages/tr.gen.d.ts +5 -0
  154. package/dist/i18n/messages/tr.gen.js +656 -0
  155. package/dist/i18n/messages/zh-CN.gen.d.ts +5 -0
  156. package/dist/i18n/messages/zh-CN.gen.js +656 -0
  157. package/dist/i18n/messages.d.ts +2 -3
  158. package/dist/i18n/messages.js +1 -19
  159. package/dist/internal/noteMarkerAttrs.d.ts +8 -0
  160. package/dist/internal/noteMarkerAttrs.js +16 -0
  161. package/dist/internal/pageBreakRunSourceDescendantIndex.js +1 -0
  162. package/dist/internal/prosemirrorAttrBoundary.d.ts +21 -0
  163. package/dist/internal/prosemirrorAttrBoundary.js +50 -0
  164. package/dist/layout-bridge/convert/fixedTableColumnWidths.d.ts +6 -0
  165. package/dist/layout-bridge/convert/fixedTableColumnWidths.js +23 -0
  166. package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
  167. package/dist/layout-bridge/convert/footnoteLayout.js +3 -3
  168. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
  169. package/dist/layout-bridge/convert/headerFooterLayout.js +1 -0
  170. package/dist/layout-bridge/convert/noteReferences.d.ts +1 -3
  171. package/dist/layout-bridge/convert/noteReferences.js +1 -6
  172. package/dist/layout-bridge/convert/paragraphRuns.js +2 -4
  173. package/dist/layout-bridge/convert/tableConversion.js +4 -1
  174. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +2 -2
  175. package/dist/layout-bridge/convert/toFlowBlocks.js +2 -2
  176. package/dist/layout-painter/index.js +2 -5
  177. package/dist/managers/DocumentLoaderManager.d.ts +1 -0
  178. package/dist/managers/DocumentLoaderManager.js +8 -1
  179. package/dist/markdown/renderBlock.js +15 -1
  180. package/dist/markdown/renderParagraph.js +9 -13
  181. package/dist/markdown/renderRuns.js +3 -2
  182. package/dist/markdown/renderTable.js +2 -0
  183. package/dist/markdown/types.d.ts +3 -9
  184. package/dist/paged-layout/editorScrollRoot.d.ts +15 -0
  185. package/dist/paged-layout/editorScrollRoot.js +72 -0
  186. package/dist/paged-layout/scrollToPmPosition.js +8 -22
  187. package/dist/prosemirror/attrs/index.d.ts +2 -12
  188. package/dist/prosemirror/attrs/index.js +22 -48
  189. package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +2 -1
  190. package/dist/prosemirror/canonicalCommands.d.ts +97 -0
  191. package/dist/prosemirror/canonicalCommands.js +28 -0
  192. package/dist/prosemirror/commands/clearParagraphIndent.d.ts +6 -0
  193. package/dist/prosemirror/commands/clearParagraphIndent.js +25 -0
  194. package/dist/prosemirror/commands/pageBreak.js +15 -1
  195. package/dist/prosemirror/commentIdAllocator.d.ts +15 -22
  196. package/dist/prosemirror/commentIdAllocator.js +50 -25
  197. package/dist/prosemirror/commentReferenceAttrs.d.ts +2 -1
  198. package/dist/prosemirror/conversion/fromProseDoc.js +91 -19
  199. package/dist/prosemirror/conversion/listRenderingDefinition.d.ts +6 -0
  200. package/dist/prosemirror/conversion/listRenderingDefinition.js +97 -0
  201. package/dist/prosemirror/conversion/toProseDoc.d.ts +4 -3
  202. package/dist/prosemirror/conversion/toProseDoc.js +51 -11
  203. package/dist/prosemirror/executeEditorCommand.d.ts +11 -0
  204. package/dist/prosemirror/executeEditorCommand.js +26 -0
  205. package/dist/prosemirror/extensions/StarterKit.js +2 -0
  206. package/dist/prosemirror/extensions/core/HistoryExtension.js +97 -5
  207. package/dist/prosemirror/extensions/core/ParagraphExtension.js +53 -20
  208. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +22 -28
  209. package/dist/prosemirror/extensions/features/ListExtension.js +18 -5
  210. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +5 -2
  211. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +13 -1
  212. package/dist/prosemirror/extensions/marks/TextColorExtension.js +3 -2
  213. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -0
  214. package/dist/prosemirror/extensions/marks/markUtils.js +70 -8
  215. package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.d.ts +6 -0
  216. package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +36 -0
  217. package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +4 -2
  218. package/dist/prosemirror/extensions/nodes/ShapeExtension.js +8 -6
  219. package/dist/prosemirror/listMarker.d.ts +1 -0
  220. package/dist/prosemirror/listMarker.js +16 -7
  221. package/dist/prosemirror/listNumbering.js +26 -5
  222. package/dist/prosemirror/listRenderingAttrs.d.ts +1 -0
  223. package/dist/prosemirror/listRenderingAttrs.js +3 -0
  224. package/dist/prosemirror/markupViewNotes.js +3 -2
  225. package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +2 -1
  226. package/dist/prosemirror/noteReferenceReview.js +5 -3
  227. package/dist/prosemirror/plugins/revisionIds.d.ts +23 -19
  228. package/dist/prosemirror/plugins/revisionIds.js +110 -29
  229. package/dist/prosemirror/plugins/suggestionMode.d.ts +2 -2
  230. package/dist/prosemirror/plugins/suggestionMode.js +246 -42
  231. package/dist/prosemirror/rangeAnchorAttrs.d.ts +2 -1
  232. package/dist/prosemirror/runFormattingFromMarks.d.ts +4 -1
  233. package/dist/prosemirror/runFormattingFromMarks.js +15 -1
  234. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +2 -1
  235. package/dist/prosemirror/runFormattingInlineCarriers.js +4 -1
  236. package/dist/prosemirror/schema/marks.d.ts +2 -0
  237. package/dist/prosemirror/schema/nodes.d.ts +10 -2
  238. package/dist/prosemirror/storyListNumbering.js +11 -9
  239. package/dist/prosemirror/textBoxAnchorAttrs.d.ts +2 -1
  240. package/dist/prosemirror/textInput.d.ts +6 -1
  241. package/dist/prosemirror/textInput.js +14 -3
  242. package/dist/prosemirror/trackedRevisionPath.js +2 -1
  243. package/dist/prosemirror/trackedRunInlineAtoms.d.ts +1 -0
  244. package/dist/prosemirror/trackedRunInlineAtoms.js +1 -0
  245. package/dist/prosemirror/utils/visualLineNavigation.js +6 -8
  246. package/dist/prosemirror/validation.js +4 -0
  247. package/dist/types/content.d.ts +2 -2
  248. package/dist/utils/createDocument.js +2 -2
  249. package/dist/utils/mergeDocumentContent.d.ts +2 -2
  250. package/dist/utils/mergeDocumentContent.js +11 -8
  251. package/package.json +14 -2
@@ -1,3 +1,4 @@
1
+ import { createNumberingIdAllocator } from "../docx/numberingIds.js";
1
2
  import { getCachedNumberingMap, isBulletLevel } from "../docx/numberingParser.js";
2
3
  import { paragraphNumberingLevel, paragraphNumberingReference, paragraphNumberingReferenceId } from "../docx/numberingReference.js";
3
4
  import { expectParagraphAttrs } from "./attrs/index.js";
@@ -20,16 +21,11 @@ const remappedAbstractNumId = (abstractNumId, remap) => {
20
21
  if (abstractNumId === null || abstractNumId === void 0 || remap.baseAbstractNumIds.has(abstractNumId)) return abstractNumId;
21
22
  let next = remap.abstractNumIds.get(abstractNumId);
22
23
  if (next === void 0) {
23
- next = remap.nextAbstractNumId++;
24
+ next = remap.abstractIds.next();
24
25
  remap.abstractNumIds.set(abstractNumId, next);
25
26
  }
26
27
  return next;
27
28
  };
28
- const maxOf = (ids, floor) => {
29
- let max = floor;
30
- for (const id of ids) max = Math.max(max, id);
31
- return max;
32
- };
33
29
  /**
34
30
  * The story in `state` as it should be written into a package whose numbering
35
31
  * is now `numbering`, and that numbering completed with the story's lists.
@@ -41,10 +37,16 @@ const storyListNumbering = (state, numbering) => {
41
37
  const definedMap = numbering ? getCachedNumberingMap(numbering) : null;
42
38
  const referenced = /* @__PURE__ */ new Set();
43
39
  const colliding = /* @__PURE__ */ new Set();
40
+ const existingAbstractNumIds = /* @__PURE__ */ new Set([...(numbering?.abstractNums ?? []).map(({ abstractNumId }) => abstractNumId), ...(packageDefinitions?.abstractNums ?? []).map(({ abstractNumId }) => abstractNumId)]);
44
41
  state.doc.descendants((node) => {
45
42
  if (node.type.name !== "paragraph") return true;
46
43
  for (const numId of paragraphListReferences(node)) referenced.add(numId);
47
44
  const attrs = expectParagraphAttrs(node);
45
+ if (typeof attrs.listAbstractNumId === "number") existingAbstractNumIds.add(attrs.listAbstractNumId);
46
+ for (const change of attrs._propertyChanges ?? []) {
47
+ const abstractId = change.previousFormatting?.listAbstractNumId;
48
+ if (typeof abstractId === "number") existingAbstractNumIds.add(abstractId);
49
+ }
48
50
  const numId = paragraphNumberingReferenceId(attrs.numPr);
49
51
  if (numId !== void 0 && !storyBase.has(numId) && definedMap?.hasNumbering(numId)) {
50
52
  const level = definedMap.getLevel(numId, paragraphNumberingLevel(attrs.numPr) ?? 0);
@@ -56,12 +58,12 @@ const storyListNumbering = (state, numbering) => {
56
58
  doc: state.doc,
57
59
  numbering: completeNumberingForDoc(numbering, state.doc)
58
60
  };
59
- let nextNumId = maxOf([...defined, ...referenced], 0) + 1;
61
+ const numIds = createNumberingIdAllocator("num", [...defined, ...referenced]);
60
62
  const remap = {
61
- numIds: new Map([...colliding].map((numId) => [numId, nextNumId++])),
63
+ numIds: new Map([...colliding].map((numId) => [numId, numIds.next()])),
62
64
  baseAbstractNumIds: new Set((packageDefinitions?.abstractNums ?? []).map(({ abstractNumId }) => abstractNumId)),
63
65
  abstractNumIds: /* @__PURE__ */ new Map(),
64
- nextAbstractNumId: maxOf((numbering?.abstractNums ?? []).map(({ abstractNumId }) => abstractNumId), -1) + 1
66
+ abstractIds: createNumberingIdAllocator("abstract", existingAbstractNumIds)
65
67
  };
66
68
  const tr = new Transform(state.doc);
67
69
  state.doc.descendants((node, pos) => {
@@ -1,5 +1,6 @@
1
1
  import { TextBoxAnchorAttrs } from "./schema/nodes.js";
2
- import { ReadProseMirrorAttrsResult } from "./attrs/index.js";
2
+ import { ReadProseMirrorAttrsResult } from "../internal/prosemirrorAttrBoundary.js";
3
+ import "./attrs/index.js";
3
4
  import { Node } from "prosemirror-model";
4
5
  //#region src/prosemirror/textBoxAnchorAttrs.d.ts
5
6
  declare const readTextBoxAnchorAttrs: (node: Node) => ReadProseMirrorAttrsResult<TextBoxAnchorAttrs>;
@@ -15,7 +15,12 @@ type TextInput = {
15
15
  declare const dispatchEditorTextInput: <TView extends TextInputDispatchTarget<TView>>(view: TView, input: string | TextInput) => void;
16
16
  /** Shared DOM boundary for editor runtimes and standalone suggestion views. */
17
17
  declare const handleEditorBeforeInput: (view: EditorView, event: InputEvent) => boolean;
18
+ /**
19
+ * Plugin compositionend handlers run before ProseMirror queues its final DOM
20
+ * flush. A second microtask runs after that flush and sees the committed state.
21
+ */
22
+ declare const afterNativeCompositionFlush: (callback: () => void) => void;
18
23
  /** Route committed text through the model before the browser mutates mark spans. */
19
24
  declare const createTextInputPlugin: () => Plugin<any>;
20
25
  //#endregion
21
- export { createTextInputPlugin, dispatchEditorTextInput, handleEditorBeforeInput };
26
+ export { afterNativeCompositionFlush, createTextInputPlugin, dispatchEditorTextInput, handleEditorBeforeInput };
@@ -4,7 +4,11 @@ const dispatchEditorTextInput = (view, input) => {
4
4
  const { from, to } = typeof input === "string" ? view.state.selection : input;
5
5
  const text = typeof input === "string" ? input : input.text;
6
6
  const defaultTransaction = () => {
7
- if (!(view.state.selection instanceof AllSelection)) return view.state.tr.insertText(text, from, to);
7
+ const { selection } = view.state;
8
+ if (!(selection instanceof AllSelection)) {
9
+ const tr = view.state.tr.insertText(text, from, to);
10
+ return !selection.empty && selection.from === from && selection.to === to ? tr.setSelection(TextSelection.create(tr.doc, from + text.length)) : tr;
11
+ }
8
12
  const start = Selection.atStart(view.state.doc);
9
13
  const end = Selection.atEnd(view.state.doc);
10
14
  const last = end.$to.parent;
@@ -45,6 +49,13 @@ const handleEditorBeforeInput = (view, event) => {
45
49
  });
46
50
  return true;
47
51
  };
52
+ /**
53
+ * Plugin compositionend handlers run before ProseMirror queues its final DOM
54
+ * flush. A second microtask runs after that flush and sees the committed state.
55
+ */
56
+ const afterNativeCompositionFlush = (callback) => {
57
+ queueMicrotask(() => queueMicrotask(callback));
58
+ };
48
59
  /** Route committed text through the model before the browser mutates mark spans. */
49
60
  const createTextInputPlugin = () => {
50
61
  const compositions = /* @__PURE__ */ new WeakMap();
@@ -55,7 +66,7 @@ const createTextInputPlugin = () => {
55
66
  },
56
67
  compositionend(view, event) {
57
68
  compositions.set(view, event);
58
- queueMicrotask(() => {
69
+ afterNativeCompositionFlush(() => {
59
70
  if (compositions.get(view) === event) compositions.delete(view);
60
71
  });
61
72
  return false;
@@ -67,4 +78,4 @@ const createTextInputPlugin = () => {
67
78
  } } });
68
79
  };
69
80
  //#endregion
70
- export { createTextInputPlugin, dispatchEditorTextInput, handleEditorBeforeInput };
81
+ export { afterNativeCompositionFlush, createTextInputPlugin, dispatchEditorTextInput, handleEditorBeforeInput };
@@ -18,7 +18,8 @@ const trackedRevisionLayerOf = (mark, node) => {
18
18
  ...attrs.date ? { date: attrs.date } : {},
19
19
  ...attrs.utcDate ? { utcDate: attrs.utcDate } : {},
20
20
  ...attrs.initials ? { initials: attrs.initials } : {},
21
- outerWrapperCount: attrs._docxOuterWrapperCount ?? inlineWrapperStackOf(node).length
21
+ outerWrapperCount: attrs._docxOuterWrapperCount ?? inlineWrapperStackOf(node).length,
22
+ ...attrs._docxResolutionJoins == null ? {} : { resolutionJoins: attrs._docxResolutionJoins }
22
23
  };
23
24
  };
24
25
  /** The deletion's ancestor path, with the insertion it sits in as the outermost layer. */
@@ -17,6 +17,7 @@ declare const TRACKED_RUN_INLINE_ATOM_DISPOSITIONS: Readonly<{
17
17
  readonly image: "carry";
18
18
  readonly math: "carry";
19
19
  readonly moveRangeBoundary: "carry";
20
+ readonly noteMarker: "carry";
20
21
  readonly pageBreakRun: "page-break-carrier";
21
22
  readonly preservedXml: "carry";
22
23
  readonly rangeAnchor: "transparent";
@@ -16,6 +16,7 @@ const TRACKED_RUN_INLINE_ATOM_DISPOSITIONS = Object.freeze({
16
16
  image: "carry",
17
17
  math: "carry",
18
18
  moveRangeBoundary: "carry",
19
+ noteMarker: "carry",
19
20
  pageBreakRun: "page-break-carrier",
20
21
  preservedXml: "carry",
21
22
  rangeAnchor: "transparent",
@@ -1,7 +1,7 @@
1
1
  import { findCollapsedLineEdgeCaretTarget } from "../../layout-bridge/dom/clickToPositionDom.js";
2
2
  import { findBodyEmptyRuns, findBodyPmSpans } from "../../layout-bridge/dom/findBodyPmSpans.js";
3
3
  import { createTextStreamRange, descendantTextNodes, totalTextLength } from "../../layout-bridge/dom/textStreamDom.js";
4
- import { findVerticalScrollParent } from "../../utils/findVerticalScrollParent.js";
4
+ import { scrollEditorElementIntoView } from "../../paged-layout/editorScrollRoot.js";
5
5
  import { Selection, TextSelection } from "prosemirror-state";
6
6
  //#region src/prosemirror/utils/visualLineNavigation.ts
7
7
  /**
@@ -24,13 +24,11 @@ function createVisualLineState() {
24
24
  return { step: null };
25
25
  }
26
26
  function scrollIntoViewIfNeeded(el) {
27
- const container = findVerticalScrollParent(el);
28
- if (!container) return;
29
- const elRect = el.getBoundingClientRect();
30
- const containerRect = container.getBoundingClientRect();
31
- const margin = 40;
32
- if (elRect.bottom > containerRect.bottom - margin) container.scrollTop += elRect.bottom - containerRect.bottom + margin;
33
- else if (elRect.top < containerRect.top + margin) container.scrollTop -= containerRect.top - elRect.top + margin;
27
+ scrollEditorElementIntoView(el, {
28
+ block: "nearest",
29
+ margin: 40,
30
+ behavior: "instant"
31
+ });
34
32
  }
35
33
  /** @internal */
36
34
  function getCaretClientX(container, pmPos) {
@@ -1,3 +1,4 @@
1
+ import { readNoteMarkerAttrs } from "../internal/noteMarkerAttrs.js";
1
2
  import { readBlockCustomXmlAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readInlineWrapperMarkAttrs, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readParagraphAttrs, readPreservedBlockAttrs, readPreservedXmlAttrs, readRunFormattingOverrideMarkAttrs, readRunIdentityMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs } from "./attrs/index.js";
2
3
  import { readBookmarkBoundaryAttrs } from "./bookmarkBoundaryAttrs.js";
3
4
  import { readCommentReferenceAttrs } from "./commentReferenceAttrs.js";
@@ -203,6 +204,9 @@ const validateNodeAttrs = (node, path, issues) => {
203
204
  case "symbol":
204
205
  appendAttrIssues(path, readSymbolAttrs(node), issues);
205
206
  return;
207
+ case "noteMarker":
208
+ appendAttrIssues(path, readNoteMarkerAttrs(node), issues);
209
+ return;
206
210
  case "preservedXml":
207
211
  appendAttrIssues(path, readPreservedXmlAttrs(node), issues);
208
212
  return;
@@ -1,2 +1,2 @@
1
- import { BlockContent, BlockSdt, BookmarkEnd, BookmarkStart, BreakContent, Column, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, ComplexField, Deletion, DisplacedByCustomXml, DocumentBackground, DocumentBackgroundDrawing, DocumentBody, DrawingContent, DrawingGroupChild, DrawingRawXmlMode, EffectExtentSlots, Endnote, EndnotePosition, EndnoteProperties, Field, FieldCharContent, FieldType, FooterReference, Footnote, FootnotePosition, FootnoteProperties, HeaderFooter, HeaderFooterType, HeaderReference, Hyperlink, Image, ImageCrop, ImagePadding, ImagePosition, ImageSize, ImageTransform, ImageWrap, ImageWrapPolygon, InlineSdt, Insertion, InstrTextContent, LineNumberRestart, MathEquation, MoveFrom, MoveFromRangeEnd, MoveFromRangeStart, MoveTo, MoveToRangeEnd, MoveToRangeStart, NoBreakHyphenContent, NoteNumberRestart, NoteReferenceContent, PageOrientation, Paragraph, ParagraphContent, ParagraphPropertyChange, PositionalTab, PositionedBookmarkMarker, PreservedAttribute, PreservedBlock, PreservedInline, PropertyChangeInfo, Run, RunContent, RunPropertyChange, SdtProperties, SdtType, Section, SectionProperties, SectionStart, Shape, ShapeAlternateContent, ShapeContent, ShapeFill, ShapeGeometryAdjustment, ShapeOutline, ShapeTextBody, ShapeType, SimpleField, SoftHyphenContent, SymbolContent, TabContent, Table, TableCell, TableCellBlock, TableCellPropertyChange, TableRow, TableRowPropertyChange, TableStructuralChangeInfo, TextBox, TextContent, TrackedChangeInfo, TrackedRunChange, TrackedRunContent, VerticalAlign, WrapDistanceSlots } from "@stll/docx-core/model";
2
- export type { BlockContent, BlockSdt, BookmarkEnd, BookmarkStart, BreakContent, Column, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, ComplexField, Deletion, DisplacedByCustomXml, DocumentBackground, DocumentBackgroundDrawing, DocumentBody, DrawingContent, DrawingGroupChild, DrawingRawXmlMode, EffectExtentSlots, Endnote, EndnotePosition, EndnoteProperties, Field, FieldCharContent, FieldType, FooterReference, Footnote, FootnotePosition, FootnoteProperties, HeaderFooter, HeaderFooterType, HeaderReference, Hyperlink, Image, ImageCrop, ImagePadding, ImagePosition, ImageSize, ImageTransform, ImageWrap, ImageWrapPolygon, InlineSdt, Insertion, InstrTextContent, LineNumberRestart, MathEquation, MoveFrom, MoveFromRangeEnd, MoveFromRangeStart, MoveTo, MoveToRangeEnd, MoveToRangeStart, NoBreakHyphenContent, NoteNumberRestart, NoteReferenceContent, PageOrientation, Paragraph, ParagraphContent, ParagraphPropertyChange, PositionalTab, PositionedBookmarkMarker, PreservedAttribute, PreservedBlock, PreservedInline, PropertyChangeInfo, Run, RunContent, RunPropertyChange, SdtProperties, SdtType, Section, SectionProperties, SectionStart, Shape, ShapeAlternateContent, ShapeContent, ShapeFill, ShapeGeometryAdjustment, ShapeOutline, ShapeTextBody, ShapeType, SimpleField, SoftHyphenContent, SymbolContent, TabContent, Table, TableCell, TableCellBlock, TableCellPropertyChange, TableRow, TableRowPropertyChange, TableStructuralChangeInfo, TextBox, TextContent, TrackedChangeInfo, TrackedRunChange, TrackedRunContent, VerticalAlign, WrapDistanceSlots };
1
+ import { BlockContent, BlockSdt, BookmarkEnd, BookmarkStart, BreakContent, Column, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, ComplexField, Deletion, DisplacedByCustomXml, DocumentBackground, DocumentBackgroundDrawing, DocumentBody, DrawingContent, DrawingGroupChild, DrawingRawXmlMode, EffectExtentSlots, Endnote, EndnotePosition, EndnoteProperties, Field, FieldCharContent, FieldType, FoldedListNumber, FooterReference, Footnote, FootnotePosition, FootnoteProperties, HeaderFooter, HeaderFooterType, HeaderReference, Hyperlink, Image, ImageCrop, ImagePadding, ImagePosition, ImageSize, ImageTransform, ImageWrap, ImageWrapPolygon, InlineSdt, Insertion, InstrTextContent, LineNumberRestart, MathEquation, MoveFrom, MoveFromRangeEnd, MoveFromRangeStart, MoveTo, MoveToRangeEnd, MoveToRangeStart, NoBreakHyphenContent, NoteNumberRestart, NoteReferenceContent, PageOrientation, Paragraph, ParagraphContent, ParagraphPropertyChange, PositionalTab, PositionedBookmarkMarker, PreservedAttribute, PreservedBlock, PreservedInline, PropertyChangeInfo, Run, RunContent, RunPropertyChange, SdtProperties, SdtType, Section, SectionProperties, SectionStart, Shape, ShapeAlternateContent, ShapeContent, ShapeFill, ShapeGeometryAdjustment, ShapeOutline, ShapeTextBody, ShapeType, SimpleField, SoftHyphenContent, SymbolContent, TabContent, Table, TableCell, TableCellBlock, TableCellPropertyChange, TableRow, TableRowPropertyChange, TableStructuralChangeInfo, TextBox, TextContent, TrackedChangeInfo, TrackedRunChange, TrackedRunContent, VerticalAlign, WrapDistanceSlots } from "@stll/docx-core/model";
2
+ export type { BlockContent, BlockSdt, BookmarkEnd, BookmarkStart, BreakContent, Column, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, ComplexField, Deletion, DisplacedByCustomXml, DocumentBackground, DocumentBackgroundDrawing, DocumentBody, DrawingContent, DrawingGroupChild, DrawingRawXmlMode, EffectExtentSlots, Endnote, EndnotePosition, EndnoteProperties, Field, FieldCharContent, FieldType, FoldedListNumber, FooterReference, Footnote, FootnotePosition, FootnoteProperties, HeaderFooter, HeaderFooterType, HeaderReference, Hyperlink, Image, ImageCrop, ImagePadding, ImagePosition, ImageSize, ImageTransform, ImageWrap, ImageWrapPolygon, InlineSdt, Insertion, InstrTextContent, LineNumberRestart, MathEquation, MoveFrom, MoveFromRangeEnd, MoveFromRangeStart, MoveTo, MoveToRangeEnd, MoveToRangeStart, NoBreakHyphenContent, NoteNumberRestart, NoteReferenceContent, PageOrientation, Paragraph, ParagraphContent, ParagraphPropertyChange, PositionalTab, PositionedBookmarkMarker, PreservedAttribute, PreservedBlock, PreservedInline, PropertyChangeInfo, Run, RunContent, RunPropertyChange, SdtProperties, SdtType, Section, SectionProperties, SectionStart, Shape, ShapeAlternateContent, ShapeContent, ShapeFill, ShapeGeometryAdjustment, ShapeOutline, ShapeTextBody, ShapeType, SimpleField, SoftHyphenContent, SymbolContent, TabContent, Table, TableCell, TableCellBlock, TableCellPropertyChange, TableRow, TableRowPropertyChange, TableStructuralChangeInfo, TextBox, TextContent, TrackedChangeInfo, TrackedRunChange, TrackedRunContent, VerticalAlign, WrapDistanceSlots };
@@ -2,7 +2,7 @@ import { BUILT_IN_STYLE_NAME, builtInHeadingStyleName } from "../docx/builtInSty
2
2
  import "../docx/defaultParagraphStyle.js";
3
3
  import { createParseWarningCollector } from "../docx/parseContext.js";
4
4
  import { formatParseWarnings } from "../docx/parseWarningMessage.js";
5
- import "../docx/settingsParser.js";
5
+ import { DEFAULT_TAB_STOP_TWIPS as DEFAULT_TAB_STOP_TWIPS$1 } from "../docx/settingsParser.js";
6
6
  import { STYLE_SET_PART, normalizeDocumentStyleSet } from "../style-sets/styleSetNormalization.js";
7
7
  import "../style-sets/types.js";
8
8
  import { panic } from "better-result";
@@ -405,7 +405,7 @@ function createEmptyDocument(options = {}) {
405
405
  if (styleSet?.numbering) docxPackage.numbering = structuredClone(styleSet.numbering);
406
406
  if (styleSet?.theme) docxPackage.theme = structuredClone(styleSet.theme);
407
407
  if (styleSet?.fontTable) docxPackage.fontTable = structuredClone(styleSet.fontTable);
408
- const settings = styleSet?.settings ? structuredClone(styleSet.settings) : { defaultTabStop: 720 };
408
+ const settings = styleSet?.settings ? structuredClone(styleSet.settings) : { defaultTabStop: DEFAULT_TAB_STOP_TWIPS$1 };
409
409
  settings.compatibilityMode ??= NEW_DOCUMENT_COMPATIBILITY_MODE;
410
410
  docxPackage.settings = settings;
411
411
  const parseWarnings = styleSetWarnings();
@@ -9,8 +9,8 @@ import { document_d_exports } from "../types/document.js";
9
9
  * merging markdown (or any other document) into a styled preset keeps that
10
10
  * preset's look. Only `source`'s numbering — the `w:abstractNum`/`w:num`
11
11
  * definitions its content's `numPr` references — travels with it, and every
12
- * `abstractNumId`/`numId` it carries is renumbered to sit strictly above
13
- * whatever `target` already uses. This is unconditional (not just on a
12
+ * `abstractNumId`/`numId` it carries moves to a fresh bounded id, preferring
13
+ * ids above the loaded range. This is unconditional (not just on a
14
14
  * detected collision): it is simpler to reason about, and makes repeated
15
15
  * merges into the same target safe too (merging two sources that each mint
16
16
  * `numId` 1 does not collide with each other either).
@@ -1,3 +1,4 @@
1
+ import { createNumberingIdAllocator } from "../docx/numberingIds.js";
1
2
  import { paragraphNumberingReferenceId } from "../docx/numberingReference.js";
2
3
  import { cloneParagraphWithoutPropertySource } from "../docx/paragraphPropertySource.js";
3
4
  //#region src/utils/mergeDocumentContent.ts
@@ -10,8 +11,8 @@ import { cloneParagraphWithoutPropertySource } from "../docx/paragraphPropertySo
10
11
  * merging markdown (or any other document) into a styled preset keeps that
11
12
  * preset's look. Only `source`'s numbering — the `w:abstractNum`/`w:num`
12
13
  * definitions its content's `numPr` references — travels with it, and every
13
- * `abstractNumId`/`numId` it carries is renumbered to sit strictly above
14
- * whatever `target` already uses. This is unconditional (not just on a
14
+ * `abstractNumId`/`numId` it carries moves to a fresh bounded id, preferring
15
+ * ids above the loaded range. This is unconditional (not just on a
15
16
  * detected collision): it is simpler to reason about, and makes repeated
16
17
  * merges into the same target safe too (merging two sources that each mint
17
18
  * `numId` 1 does not collide with each other either).
@@ -53,11 +54,13 @@ function mergeDocumentContent(target, source) {
53
54
  }
54
55
  };
55
56
  function remapContentNumbering(content, numbering) {
56
- const abstractNumIdBase = Math.max(0, ...(targetNumbering?.abstractNums ?? []).map((abstractNum) => abstractNum.abstractNumId));
57
- const numIdBase = Math.max(0, ...(targetNumbering?.nums ?? []).map((num) => num.numId));
57
+ const existingAbstractIds = [...(targetNumbering?.abstractNums ?? []).map(({ abstractNumId }) => abstractNumId), ...numbering.abstractNums.map(({ abstractNumId }) => abstractNumId)];
58
+ const existingNumIds = [...(targetNumbering?.nums ?? []).map(({ numId }) => numId), ...numbering.nums.map(({ numId }) => numId)];
59
+ const abstractIds = createNumberingIdAllocator("abstract", existingAbstractIds);
60
+ const numIds = createNumberingIdAllocator("num", existingNumIds);
58
61
  const abstractNumIdRemap = /* @__PURE__ */ new Map();
59
- const remappedAbstractNums = numbering.abstractNums.map((abstractNum, index) => {
60
- const remappedAbstractNumId = abstractNumIdBase + index + 1;
62
+ const remappedAbstractNums = numbering.abstractNums.map((abstractNum) => {
63
+ const remappedAbstractNumId = abstractIds.next();
61
64
  abstractNumIdRemap.set(abstractNum.abstractNumId, remappedAbstractNumId);
62
65
  return {
63
66
  ...abstractNum,
@@ -65,8 +68,8 @@ function mergeDocumentContent(target, source) {
65
68
  };
66
69
  });
67
70
  const numIdRemap = /* @__PURE__ */ new Map();
68
- const remappedNums = numbering.nums.map((num, index) => {
69
- const remappedNumId = numIdBase + index + 1;
71
+ const remappedNums = numbering.nums.map((num) => {
72
+ const remappedNumId = numIds.next();
70
73
  numIdRemap.set(num.numId, remappedNumId);
71
74
  return {
72
75
  ...num,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-core",
3
- "version": "0.54.1",
3
+ "version": "0.55.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",
@@ -38,6 +38,18 @@
38
38
  "types": "./dist/index.d.ts",
39
39
  "import": "./dist/index.js"
40
40
  },
41
+ "./i18n/messages/*": {
42
+ "types": "./dist/i18n/messages/*.gen.d.ts",
43
+ "import": "./dist/i18n/messages/*.gen.js"
44
+ },
45
+ "./i18n/messages/*.gen": {
46
+ "types": "./dist/i18n/messages/*.gen.d.ts",
47
+ "import": "./dist/i18n/messages/*.gen.js"
48
+ },
49
+ "./i18n/messages/locales": {
50
+ "types": "./dist/i18n/messages/locales.d.ts",
51
+ "import": "./dist/i18n/messages/locales.js"
52
+ },
41
53
  "./markdown": {
42
54
  "types": "./dist/markdown/index.d.ts",
43
55
  "import": "./dist/markdown/index.js"
@@ -134,7 +146,7 @@
134
146
  "perf": "bun scripts/profile-editor.ts"
135
147
  },
136
148
  "dependencies": {
137
- "@stll/docx-core": "^0.30.0",
149
+ "@stll/docx-core": "^0.31.0",
138
150
  "@stll/docx-utils": "^0.1.0",
139
151
  "@stll/template-conditions": "^0.6.2",
140
152
  "better-result": "3.0.1",