@stll/folio-core 0.66.2 → 0.67.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 (119) hide show
  1. package/dist/ai-edits/apply.js +45 -10
  2. package/dist/ai-edits/batch-claims.js +5 -3
  3. package/dist/ai-edits/clean-text.js +4 -1
  4. package/dist/ai-edits/read.js +6 -4
  5. package/dist/ai-edits/snapshot.js +24 -14
  6. package/dist/ai-edits/table-cell-mutations.js +3 -2
  7. package/dist/ai-edits/table-row-column-mutations.js +20 -6
  8. package/dist/controller/canonicalComposition.d.ts +1 -1
  9. package/dist/controller/canonicalComposition.js +76 -18
  10. package/dist/controller/canonicalInput.d.ts +0 -1
  11. package/dist/controller/canonicalInput.js +19 -1
  12. package/dist/controller/canonicalSession.js +1 -2
  13. package/dist/controller/hiddenEditorManager.d.ts +6 -0
  14. package/dist/controller/hiddenEditorManager.js +3 -1
  15. package/dist/controller/layoutPipeline.d.ts +2 -0
  16. package/dist/controller/layoutPipeline.js +7 -3
  17. package/dist/controller/layoutSession.d.ts +1 -0
  18. package/dist/display-list/build/tablePrimitives.d.ts +3 -1
  19. package/dist/display-list/build/tablePrimitives.js +29 -13
  20. package/dist/docx/chartPreview.d.ts +4 -1
  21. package/dist/docx/chartPreview.js +26 -15
  22. package/dist/docx/mainDocumentPart.d.ts +6 -0
  23. package/dist/docx/mainDocumentPart.js +65 -0
  24. package/dist/docx/packageParts.d.ts +1 -1
  25. package/dist/docx/packageParts.js +10 -4
  26. package/dist/docx/previewBudget.d.ts +6 -0
  27. package/dist/docx/previewBudget.js +7 -1
  28. package/dist/docx/rezip.js +4 -4
  29. package/dist/docx/shapeAlternateContent.js +19 -0
  30. package/dist/docx/unzip.js +2 -0
  31. package/dist/i18n/messages/ar.gen.js +1 -0
  32. package/dist/i18n/messages/catalogs.gen.d.ts +17 -0
  33. package/dist/i18n/messages/catalogs.gen.js +17 -0
  34. package/dist/i18n/messages/cs.gen.js +1 -0
  35. package/dist/i18n/messages/de.gen.js +1 -0
  36. package/dist/i18n/messages/en.gen.js +1 -0
  37. package/dist/i18n/messages/es.gen.js +1 -0
  38. package/dist/i18n/messages/et.gen.js +1 -0
  39. package/dist/i18n/messages/fr.gen.js +1 -0
  40. package/dist/i18n/messages/he.gen.js +1 -0
  41. package/dist/i18n/messages/hi.gen.js +1 -0
  42. package/dist/i18n/messages/hu.gen.js +1 -0
  43. package/dist/i18n/messages/lt.gen.js +1 -0
  44. package/dist/i18n/messages/lv.gen.js +1 -0
  45. package/dist/i18n/messages/messages.gen.d.ts +1 -0
  46. package/dist/i18n/messages/pl.gen.js +1 -0
  47. package/dist/i18n/messages/pt-BR.gen.js +1 -0
  48. package/dist/i18n/messages/sk.gen.js +1 -0
  49. package/dist/i18n/messages/tr.gen.js +1 -0
  50. package/dist/i18n/messages/zh-CN.gen.js +1 -0
  51. package/dist/internal/wholeStoryRevisionResolution.js +57 -12
  52. package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +10 -0
  53. package/dist/layout-bridge/convert/altChunkPlaceholder.js +70 -0
  54. package/dist/layout-bridge/convert/fixedTableColumnWidths.js +2 -1
  55. package/dist/layout-bridge/convert/flowConversionShared.d.ts +10 -0
  56. package/dist/layout-bridge/convert/flowConversionShared.js +11 -1
  57. package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
  58. package/dist/layout-bridge/convert/footnoteLayout.js +4 -1
  59. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
  60. package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
  61. package/dist/layout-bridge/convert/tableConversion.js +6 -2
  62. package/dist/layout-bridge/convert/toFlowBlocks.js +4 -0
  63. package/dist/layout-bridge/engine/clickToPosition.js +5 -1
  64. package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
  65. package/dist/layout-engine/measure/tableCellFloating.js +1 -0
  66. package/dist/layout-engine/measure/tableVisibleBand.d.ts +16 -0
  67. package/dist/layout-engine/measure/tableVisibleBand.js +28 -0
  68. package/dist/layout-engine/tableLayout.js +7 -4
  69. package/dist/layout-engine/tableRowBreak.d.ts +10 -0
  70. package/dist/layout-engine/tableRowBreak.js +151 -36
  71. package/dist/layout-engine/types.d.ts +7 -2
  72. package/dist/layout-painter/previewSvg.d.ts +8 -0
  73. package/dist/layout-painter/previewSvg.js +47 -0
  74. package/dist/layout-painter/renderImage.js +2 -1
  75. package/dist/layout-painter/renderPage.d.ts +1 -0
  76. package/dist/layout-painter/renderPage.js +6 -3
  77. package/dist/layout-painter/renderParagraph.js +3 -2
  78. package/dist/layout-painter/renderTable.d.ts +5 -2
  79. package/dist/layout-painter/renderTable.js +33 -19
  80. package/dist/prosemirror/anchoredTextBoxes.d.ts +2 -1
  81. package/dist/prosemirror/commands/comments.js +20 -7
  82. package/dist/prosemirror/commands/deleteBesideInlineAnchor.d.ts +9 -0
  83. package/dist/prosemirror/commands/deleteBesideInlineAnchor.js +36 -0
  84. package/dist/prosemirror/commands/pastePlainText.d.ts +6 -0
  85. package/dist/prosemirror/commands/pastePlainText.js +13 -3
  86. package/dist/prosemirror/commands/resolveAllTableChanges.js +30 -2
  87. package/dist/prosemirror/commentReferenceIntegrity.d.ts +8 -2
  88. package/dist/prosemirror/commentReferenceIntegrity.js +19 -4
  89. package/dist/prosemirror/conversion/fromProseDoc.js +39 -4
  90. package/dist/prosemirror/conversion/toProseDoc.js +6 -4
  91. package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +3 -1
  92. package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -9
  93. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +46 -11
  94. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
  95. package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -3
  96. package/dist/prosemirror/extensions/features/ListExtension.js +22 -1
  97. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +5 -0
  98. package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
  99. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +8 -4
  100. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -1
  101. package/dist/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js +2 -1
  102. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +4 -3
  103. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +2 -1
  104. package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +2 -1
  105. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +2 -1
  106. package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +2 -1
  107. package/dist/prosemirror/extensions/nodes/TableExtension.js +87 -7
  108. package/dist/prosemirror/extensions/nodes/inlineAnchorDom.d.ts +11 -0
  109. package/dist/prosemirror/extensions/nodes/inlineAnchorDom.js +21 -0
  110. package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -8
  111. package/dist/prosemirror/plugins/suggestionMode.js +175 -21
  112. package/dist/prosemirror/rowGridOmissions.d.ts +11 -0
  113. package/dist/prosemirror/rowGridOmissions.js +21 -0
  114. package/dist/prosemirror/tableGridMutation.d.ts +19 -2
  115. package/dist/prosemirror/tableGridMutation.js +118 -15
  116. package/dist/prosemirror/tablePositionedBookmarks.d.ts +2 -0
  117. package/dist/prosemirror/tablePositionedBookmarks.js +80 -0
  118. package/dist/prosemirror/validation.js +1 -1
  119. package/package.json +2 -2
@@ -44,6 +44,86 @@ const removeTableRow = (tr, { map, table, tableStart }, row) => {
44
44
  column += colspan;
45
45
  }
46
46
  };
47
+ /** A placeholder for an absent grid position is not a cell a row can keep. */
48
+ const rowHoldsNoCells = (row, besides) => {
49
+ let holdsCell = false;
50
+ row.forEach((cell) => {
51
+ holdsCell ||= cell !== besides && cell.attrs["_omittedGridSlot"] == null;
52
+ });
53
+ return !holdsCell;
54
+ };
55
+ const omittedSlotOf = (cell) => cell?.attrs["_omittedGridSlot"];
56
+ /**
57
+ * The placeholder a new column's place in a row falls to, if any. Nothing can
58
+ * stand after what a row omits at its end or before what it omits at its start:
59
+ * a cell there would move on save, so the omission grows instead.
60
+ */
61
+ const omittedSlotTakingColumn = (map, table, row, column) => {
62
+ const left = column > 0 ? map.map[row * map.width + column - 1] : void 0;
63
+ if (left !== void 0 && omittedSlotOf(table.nodeAt(left)) === "after") return left;
64
+ const right = column < map.width ? map.map[row * map.width + column] : void 0;
65
+ return right !== void 0 && omittedSlotOf(table.nodeAt(right)) === "before" ? right : null;
66
+ };
67
+ /**
68
+ * Size what rows omit to the width their cells now reach. A column whose cells
69
+ * went takes the same column out of a row that omits it; removing a tracked
70
+ * column's last cell does not otherwise reach such a row.
71
+ */
72
+ const reconcileOmittedGridSlots = (tr, tablePosition, previousTable, removedColumn) => {
73
+ const table = tr.doc.nodeAt(tablePosition);
74
+ if (!table || table.type.spec["tableRole"] !== "table") return;
75
+ const reached = Array.from({ length: table.childCount }, () => 0);
76
+ let omits = false;
77
+ table.forEach((row, _offset, rowIndex) => {
78
+ row.forEach((cell) => {
79
+ if (omittedSlotOf(cell)) {
80
+ omits = true;
81
+ return;
82
+ }
83
+ const colspan = Number(cell.attrs["colspan"]) || 1;
84
+ const rowspan = Number(cell.attrs["rowspan"]) || 1;
85
+ for (let at = rowIndex; at < rowIndex + rowspan; at++) if (at < reached.length) reached[at] = (reached[at] ?? 0) + colspan;
86
+ });
87
+ });
88
+ if (!omits) return;
89
+ const width = Math.max(...reached);
90
+ const previousMap = TableMap.get(previousTable);
91
+ const rowPositions = [];
92
+ table.forEach((_row, offset) => rowPositions.push(tablePosition + 1 + offset));
93
+ for (let rowIndex = table.childCount - 1; rowIndex >= 0; rowIndex--) {
94
+ const row = table.child(rowIndex);
95
+ let excess = -(width - (reached[rowIndex] ?? 0));
96
+ row.forEach((cell) => {
97
+ if (omittedSlotOf(cell)) excess += Number(cell.attrs["colspan"]) || 1;
98
+ });
99
+ if (excess <= 0) continue;
100
+ const atPlace = previousMap.map[rowIndex * previousMap.width + removedColumn];
101
+ const placeKind = atPlace === void 0 ? void 0 : omittedSlotOf(previousTable.nodeAt(atPlace));
102
+ const slots = [];
103
+ row.forEach((cell, offset) => {
104
+ if (omittedSlotOf(cell)) slots.push({
105
+ node: cell,
106
+ position: (rowPositions[rowIndex] ?? 0) + 1 + offset
107
+ });
108
+ });
109
+ const order = slots.toSorted((left, right) => Number(omittedSlotOf(right.node) === placeKind) - Number(omittedSlotOf(left.node) === placeKind) || right.position - left.position);
110
+ const changes = /* @__PURE__ */ new Map();
111
+ for (const { node, position } of order) {
112
+ if (excess <= 0) break;
113
+ const colspan = Number(node.attrs["colspan"]) || 1;
114
+ const taken = Math.min(colspan, excess);
115
+ changes.set(position, colspan - taken);
116
+ excess -= taken;
117
+ }
118
+ for (const { node, position } of slots.toReversed()) {
119
+ const next = changes.get(position);
120
+ if (next === void 0) continue;
121
+ if (next === 0) tr.delete(position, position + node.nodeSize);
122
+ else tr.setNodeAttribute(position, "colspan", next);
123
+ }
124
+ }
125
+ removeRowsWithoutCells(tr, tablePosition, previousTable);
126
+ };
47
127
  const ROW_CLEANUP_PENDING = "pending";
48
128
  /** A transient row attribute follows node moves; conversion never serializes it. */
49
129
  const markRowEmptiedInBatch = ({ tr, rowPosition, emptied }) => {
@@ -57,7 +137,7 @@ const markRowsEmptiedInBatch = ({ tr, tablePosition, previousTable, emptied }) =
57
137
  const table = tr.doc.nodeAt(tablePosition);
58
138
  if (!table || table.type.spec["tableRole"] !== "table") return;
59
139
  table.forEach((row, offset, index) => {
60
- if (row.childCount === 0 && previousTable.child(index).childCount > 0) markRowEmptiedInBatch({
140
+ if (rowHoldsNoCells(row) && !rowHoldsNoCells(previousTable.child(index))) markRowEmptiedInBatch({
61
141
  tr,
62
142
  rowPosition: tablePosition + 1 + offset,
63
143
  emptied
@@ -70,7 +150,7 @@ const removeEmptyRows = ({ tr, tablePosition, shouldRemove }) => {
70
150
  if (!table || table.type.spec["tableRole"] !== "table" || table.childCount < 2) return;
71
151
  let emptyRow = -1;
72
152
  table.forEach((row, _offset, index) => {
73
- if (emptyRow === -1 && row.childCount === 0 && shouldRemove(row)) emptyRow = index;
153
+ if (emptyRow === -1 && rowHoldsNoCells(row) && shouldRemove(row)) emptyRow = index;
74
154
  });
75
155
  if (emptyRow === -1) return;
76
156
  removeTableRow(tr, {
@@ -110,13 +190,27 @@ const removeRowsWithoutCellsInRange = ({ tr, from, to }) => {
110
190
  });
111
191
  for (const position of tables.toReversed()) removeBatchRows(tr, position);
112
192
  };
113
- /** Close all cell-less rows after an immediate structural edit. */
114
- const removeRowsWithoutCells = (tr, tablePosition) => {
115
- removeEmptyRows({
116
- tr,
117
- tablePosition,
118
- shouldRemove: () => true
193
+ /**
194
+ * Close the rows an immediate structural edit left without cells. A row written
195
+ * with none is no row this edit emptied, and it stays.
196
+ */
197
+ const removeRowsWithoutCells = (tr, tablePosition, previousTable) => {
198
+ const table = tr.doc.nodeAt(tablePosition);
199
+ if (!table || table.type.spec["tableRole"] !== "table") return;
200
+ const emptied = [];
201
+ table.forEach((row, _offset, index) => {
202
+ const before = previousTable.maybeChild(index);
203
+ if (rowHoldsNoCells(row) && before && !rowHoldsNoCells(before)) emptied.push(index);
119
204
  });
205
+ for (const rowIndex of emptied.toReversed()) {
206
+ const current = tr.doc.nodeAt(tablePosition);
207
+ if (!current || current.childCount < 2) return;
208
+ removeTableRow(tr, {
209
+ map: TableMap.get(current),
210
+ table: current,
211
+ tableStart: tablePosition + 1
212
+ }, rowIndex);
213
+ }
120
214
  };
121
215
  /**
122
216
  * Keep the editable table grid aligned with a physical column removal.
@@ -134,7 +228,7 @@ const reconcileTableGridAfterColumnRemoval = ({ tr, tablePosition, previousTable
134
228
  if (columnCount >= previousColumnCount) return;
135
229
  const removedColumnCount = previousColumnCount - columnCount;
136
230
  const previousWidths = expectTableAttrs(previousTable).columnWidths;
137
- const columnWidths = previousWidths?.length === previousColumnCount ? previousWidths.toSpliced(removedColumn, removedColumnCount) : void 0;
231
+ const columnWidths = previousWidths !== void 0 && previousWidths.length >= previousColumnCount ? previousWidths.toSpliced(removedColumn, removedColumnCount) : void 0;
138
232
  setTableGrid({
139
233
  tr,
140
234
  tablePosition,
@@ -159,7 +253,7 @@ const reconcileTableGridAfterColumnInsertion = ({ tr, tablePosition, previousTab
159
253
  const insertedColumnCount = columnCount - previousColumnCount;
160
254
  const previousWidths = expectTableAttrs(previousTable).columnWidths;
161
255
  const neighbourWidth = insertedColumnWidth(previousTable, insertedColumn);
162
- const columnWidths = previousWidths?.length === previousColumnCount && neighbourWidth !== void 0 ? previousWidths.toSpliced(insertedColumn, 0, ...Array.from({ length: insertedColumnCount }, () => neighbourWidth)) : void 0;
256
+ const columnWidths = previousWidths !== void 0 && previousWidths.length >= previousColumnCount && neighbourWidth !== void 0 ? previousWidths.toSpliced(insertedColumn, 0, ...Array.from({ length: insertedColumnCount }, () => neighbourWidth)) : void 0;
163
257
  setTableGrid({
164
258
  tr,
165
259
  tablePosition,
@@ -172,7 +266,7 @@ const reconcileTableGridAfterColumnInsertion = ({ tr, tablePosition, previousTab
172
266
  const insertedColumnWidth = (table, insertedColumn) => {
173
267
  const columnCount = TableMap.get(table).width;
174
268
  const widths = expectTableAttrs(table).columnWidths;
175
- if (widths?.length !== columnCount) return;
269
+ if (widths === void 0 || widths.length < columnCount) return;
176
270
  return widths[Math.max(0, Math.min(insertedColumn, columnCount) - 1)] ?? widths[0];
177
271
  };
178
272
  /**
@@ -196,7 +290,7 @@ const setTableGrid = ({ tr, tablePosition, table, columnWidths, columnCount }) =
196
290
  const originalFormatting = formatting ? { ...formatting } : void 0;
197
291
  if (originalFormatting) delete originalFormatting.gridSourceXml;
198
292
  tr.setNodeMarkup(tablePosition, void 0, mergeTableAttrs(table, {
199
- columnWidths: columnWidths?.length === columnCount ? columnWidths : void 0,
293
+ columnWidths: columnWidths !== void 0 && columnWidths.length >= columnCount ? columnWidths : void 0,
200
294
  _originalFormatting: originalFormatting
201
295
  }));
202
296
  };
@@ -216,6 +310,12 @@ const insertTableColumn = ({ tr, tablePosition, column, templateColumn, createCe
216
310
  for (let row = 0; row < map.height; row++) {
217
311
  const index = row * map.width + column;
218
312
  const position = map.map[index];
313
+ const omitted = omittedSlotTakingColumn(map, table, row, column);
314
+ if (omitted !== null) {
315
+ const slot = table.nodeAt(omitted);
316
+ tr.setNodeAttribute(tr.mapping.slice(mapFrom).map(tableStart + omitted), "colspan", (Number(slot?.attrs["colspan"]) || 1) + 1);
317
+ continue;
318
+ }
219
319
  const straddling = column > 0 && column < map.width && position !== void 0 && map.map[index - 1] === position ? table.nodeAt(position) : null;
220
320
  if (straddling && position !== void 0) {
221
321
  const offset = column - map.colCount(position);
@@ -231,7 +331,8 @@ const insertTableColumn = ({ tr, tablePosition, column, templateColumn, createCe
231
331
  continue;
232
332
  }
233
333
  const templatePosition = map.map[row * map.width + templateColumn];
234
- const template = templatePosition === void 0 ? null : table.nodeAt(templatePosition);
334
+ const templateCell = templatePosition === void 0 ? null : table.nodeAt(templatePosition);
335
+ const template = omittedSlotOf(templateCell) ? null : templateCell;
235
336
  tr.insert(tr.mapping.slice(mapFrom).map(tableStart + map.positionAt(row, column, table)), createCell(template));
236
337
  }
237
338
  reconcileTableGridAfterColumnInsertion({
@@ -247,6 +348,8 @@ const insertTableColumn = ({ tr, tablePosition, column, templateColumn, createCe
247
348
  * and a row left without a cell of its own goes too.
248
349
  */
249
350
  const removeTableColumns = (tr, tablePosition, left, right) => {
351
+ const previousTable = tr.doc.nodeAt(tablePosition);
352
+ if (!previousTable) return;
250
353
  for (let column = right - 1; column >= left; column--) {
251
354
  const table = tr.doc.nodeAt(tablePosition);
252
355
  if (!table || table.type.spec["tableRole"] !== "table") return;
@@ -277,6 +380,6 @@ const removeTableColumns = (tr, tablePosition, left, right) => {
277
380
  removedColumn: column
278
381
  });
279
382
  }
280
- removeRowsWithoutCells(tr, tablePosition);
383
+ removeRowsWithoutCells(tr, tablePosition, previousTable);
281
384
  };
282
- export { insertTableColumn, markRowEmptiedInBatch, markRowsEmptiedInBatch, reconcileTableGridAfterColumnInsertion, reconcileTableGridAfterColumnRemoval, removeRowsWithoutCells, removeRowsWithoutCellsAfterBatch, removeRowsWithoutCellsInRange, removeTableColumns, removeTableRow };
385
+ export { insertTableColumn, markRowEmptiedInBatch, markRowsEmptiedInBatch, omittedSlotTakingColumn, reconcileOmittedGridSlots, reconcileTableGridAfterColumnInsertion, reconcileTableGridAfterColumnRemoval, removeRowsWithoutCells, removeRowsWithoutCellsAfterBatch, removeRowsWithoutCellsInRange, removeTableColumns, removeTableRow, rowHoldsNoCells };
@@ -0,0 +1,2 @@
1
+ import { Plugin } from "prosemirror-state";
2
+ export declare const tablePositionedBookmarksPlugin: () => Plugin;
@@ -0,0 +1,80 @@
1
+ import { Mapping } from "prosemirror-transform";
2
+ import { Plugin, PluginKey } from "prosemirror-state";
3
+ // src/prosemirror/tablePositionedBookmarks.ts
4
+ const positionedBookmarksOf = (node) => {
5
+ const role = node.type.spec["tableRole"];
6
+ if (role !== "table" && role !== "row") return null;
7
+ const bookmarks = node.attrs["_bookmarks"];
8
+ return Array.isArray(bookmarks) && bookmarks.length > 0 ? bookmarks : null;
9
+ };
10
+ /** Where a boundary between the source's children falls among the new ones. */
11
+ const childIndexAt = (node, nodePosition, at) => {
12
+ let index = 0;
13
+ let end = nodePosition + 1;
14
+ while (index < node.childCount) {
15
+ end += node.child(index).nodeSize;
16
+ if (end > at) break;
17
+ index += 1;
18
+ }
19
+ return index;
20
+ };
21
+ const followingIndex = ({ source, sourcePosition, node, position, index, mapping }) => {
22
+ if (!source || source.type !== node.type || index > source.childCount) return Math.min(index, node.childCount);
23
+ if (index === source.childCount) return node.childCount;
24
+ let boundary = sourcePosition + 1;
25
+ for (let child = 0; child < index; child += 1) boundary += source.child(child).nodeSize;
26
+ return childIndexAt(node, position, mapping.map(boundary, -1));
27
+ };
28
+ const repairChanged = ({ before, after, offset, mapping, back, sourceDoc, tr }) => {
29
+ after.forEach((child, childOffset, index) => {
30
+ if (child === before.maybeChild(index) || child.isTextblock) return;
31
+ const position = offset + childOffset;
32
+ const bookmarks = positionedBookmarksOf(child);
33
+ if (bookmarks) {
34
+ const sourcePosition = back.map(position, 1);
35
+ const source = sourceDoc.nodeAt(sourcePosition);
36
+ const repaired = bookmarks.map((bookmark) => ({
37
+ ...bookmark,
38
+ index: followingIndex({
39
+ source,
40
+ sourcePosition,
41
+ node: child,
42
+ position,
43
+ index: bookmark.index,
44
+ mapping
45
+ })
46
+ }));
47
+ if (repaired.some(({ index: at }, i) => at !== bookmarks[i]?.index)) tr.setNodeAttribute(position, "_bookmarks", repaired);
48
+ }
49
+ repairChanged({
50
+ before: before.maybeChild(index) ?? child.type.create(),
51
+ after: child,
52
+ offset: position + 1,
53
+ mapping,
54
+ back,
55
+ sourceDoc,
56
+ tr
57
+ });
58
+ });
59
+ };
60
+ const tablePositionedBookmarksPlugin = () => new Plugin({
61
+ key: new PluginKey("tablePositionedBookmarks"),
62
+ appendTransaction(transactions, oldState, newState) {
63
+ if (!transactions.some(({ docChanged }) => docChanged)) return null;
64
+ const mapping = new Mapping();
65
+ for (const { mapping: each } of transactions) mapping.appendMapping(each);
66
+ const tr = newState.tr;
67
+ repairChanged({
68
+ before: oldState.doc,
69
+ after: newState.doc,
70
+ offset: 0,
71
+ mapping,
72
+ back: mapping.invert(),
73
+ sourceDoc: oldState.doc,
74
+ tr
75
+ });
76
+ if (!tr.docChanged) return null;
77
+ return tr.setMeta("addToHistory", false);
78
+ }
79
+ });
80
+ export { tablePositionedBookmarksPlugin };
@@ -24,7 +24,7 @@ const COMPLEX_FIELD_RESULT_MARK_NAMES = /* @__PURE__ */ new Set([
24
24
  const hasUnsupportedComplexFieldResultContent = (node) => node.content.content.some((child) => {
25
25
  if (child.type.name === "bookmarkBoundary") return false;
26
26
  const preservedXmlAttrs = child.type.name === "preservedXml" ? readPreservedXmlAttrs(child) : void 0;
27
- return preservedXmlAttrs?.ok && preservedXmlAttrs.value.level === PRESERVED_XML_LEVELS.inline || !isRunContentInlineNodeName(child.type.name) || child.marks.some((mark) => !COMPLEX_FIELD_RESULT_MARK_NAMES.has(mark.type.name));
27
+ return preservedXmlAttrs?.ok && preservedXmlAttrs.value.level === PRESERVED_XML_LEVELS.inline || !isRunContentInlineNodeName(child.type.name) || child.marks.some((mark) => !COMPLEX_FIELD_RESULT_MARK_NAMES.has(mark.type.name) && !mark.isInSet(node.marks));
28
28
  });
29
29
  var ProseMirrorDocumentValidationError = class extends Error {
30
30
  issues;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-core",
3
- "version": "0.66.2",
3
+ "version": "0.67.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,7 +173,7 @@
173
173
  "perf": "bun scripts/profile-editor.ts"
174
174
  },
175
175
  "dependencies": {
176
- "@stll/docx-core": "^0.42.0",
176
+ "@stll/docx-core": "^0.42.1",
177
177
  "@stll/docx-utils": "^0.2.0",
178
178
  "@stll/template-conditions": "^0.6.2",
179
179
  "@stll/utf8-boundaries": "0.2.0",