@beyondwork/docx-react-component 1.0.129 → 1.0.131

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 (102) hide show
  1. package/dist/api/public-types.cjs +595 -18
  2. package/dist/api/public-types.d.cts +1 -1
  3. package/dist/api/public-types.d.ts +1 -1
  4. package/dist/api/public-types.js +4 -4
  5. package/dist/api/v3.cjs +1164 -332
  6. package/dist/api/v3.d.cts +2 -2
  7. package/dist/api/v3.d.ts +2 -2
  8. package/dist/api/v3.js +13 -13
  9. package/dist/{chunk-OTQIW2TC.js → chunk-35RHOE6I.js} +105 -4
  10. package/dist/{chunk-PGKUJZXV.js → chunk-3YCQM2RV.js} +6 -6
  11. package/dist/{chunk-JJGVE5J7.js → chunk-4YCWECLZ.js} +1 -1
  12. package/dist/{chunk-EZKJXIPH.js → chunk-6TBLDBCL.js} +1 -1
  13. package/dist/{chunk-SKPTKQHF.js → chunk-7G5GR3VV.js} +122 -23
  14. package/dist/{chunk-HUIHBBAQ.js → chunk-A3GSNB4G.js} +17 -6
  15. package/dist/{chunk-5DGKFNQT.js → chunk-A66ZVUAT.js} +150 -1
  16. package/dist/{chunk-YIYM4ZAP.js → chunk-CI2TD3T4.js} +1 -1
  17. package/dist/{chunk-63FYIGCT.js → chunk-DGA7M77X.js} +2 -2
  18. package/dist/{chunk-EB6M3GE6.js → chunk-FM4K4XFJ.js} +100 -97
  19. package/dist/{chunk-VNLDQJ47.js → chunk-HYHCRMR7.js} +1 -1
  20. package/dist/{chunk-DJU2W4E4.js → chunk-KNHMXKC6.js} +2 -2
  21. package/dist/{chunk-Q3QYGKFE.js → chunk-M7YRJX6V.js} +10 -21
  22. package/dist/{chunk-KFCQYZXR.js → chunk-OVLZQ6FZ.js} +61 -0
  23. package/dist/{chunk-W34X3KBR.js → chunk-PHMWH23E.js} +1 -1
  24. package/dist/{chunk-DDN2AIGE.js → chunk-Q7Y57KOK.js} +2 -2
  25. package/dist/{chunk-LJH64PV3.js → chunk-QXKQPUOM.js} +3 -3
  26. package/dist/{chunk-CX42VC67.js → chunk-SYQWQ6FE.js} +1 -1
  27. package/dist/{chunk-5DSHUYSY.js → chunk-T5YYFDZB.js} +1 -1
  28. package/dist/{chunk-RMRTQGW3.js → chunk-THVM6EP5.js} +371 -13
  29. package/dist/{chunk-XMHSGPLN.js → chunk-VRKK2CSZ.js} +111 -90
  30. package/dist/{chunk-OL2UEHRP.js → chunk-WUDSNHWF.js} +1 -1
  31. package/dist/{chunk-XQCAMKIQ.js → chunk-WZDKNF37.js} +250 -106
  32. package/dist/{chunk-PRAZBHNF.js → chunk-YLL7MF5C.js} +15 -15
  33. package/dist/{chunk-YZDZ4FGR.js → chunk-ZVC23LKV.js} +1 -1
  34. package/dist/compare.cjs +100 -97
  35. package/dist/compare.js +3 -3
  36. package/dist/core/commands/formatting-commands.d.cts +1 -1
  37. package/dist/core/commands/formatting-commands.d.ts +1 -1
  38. package/dist/core/commands/image-commands.cjs +16 -5
  39. package/dist/core/commands/image-commands.d.cts +1 -1
  40. package/dist/core/commands/image-commands.d.ts +1 -1
  41. package/dist/core/commands/image-commands.js +5 -5
  42. package/dist/core/commands/section-layout-commands.d.cts +1 -1
  43. package/dist/core/commands/section-layout-commands.d.ts +1 -1
  44. package/dist/core/commands/style-commands.d.cts +1 -1
  45. package/dist/core/commands/style-commands.d.ts +1 -1
  46. package/dist/core/commands/table-structure-commands.cjs +16 -5
  47. package/dist/core/commands/table-structure-commands.d.cts +1 -1
  48. package/dist/core/commands/table-structure-commands.d.ts +1 -1
  49. package/dist/core/commands/table-structure-commands.js +4 -4
  50. package/dist/core/commands/text-commands.cjs +16 -5
  51. package/dist/core/commands/text-commands.d.cts +1 -1
  52. package/dist/core/commands/text-commands.d.ts +1 -1
  53. package/dist/core/commands/text-commands.js +5 -5
  54. package/dist/core/selection/mapping.d.cts +1 -1
  55. package/dist/core/selection/mapping.d.ts +1 -1
  56. package/dist/core/state/editor-state.d.cts +1 -1
  57. package/dist/core/state/editor-state.d.ts +1 -1
  58. package/dist/index.cjs +1280 -347
  59. package/dist/index.d.cts +4 -4
  60. package/dist/index.d.ts +4 -4
  61. package/dist/index.js +24 -24
  62. package/dist/io/docx-session.cjs +216 -203
  63. package/dist/io/docx-session.d.cts +3 -3
  64. package/dist/io/docx-session.d.ts +3 -3
  65. package/dist/io/docx-session.js +6 -6
  66. package/dist/legal.cjs +9 -20
  67. package/dist/legal.js +3 -3
  68. package/dist/{loader-4qsw4eIU.d.ts → loader-B-aL5HGD.d.ts} +2 -2
  69. package/dist/{loader-B8TKhmQi.d.cts → loader-DiY_ZgKl.d.cts} +2 -2
  70. package/dist/{measurement-backend-canvas-Q3MJMEYX.js → measurement-backend-canvas-F7ZYDACK.js} +1 -1
  71. package/dist/{public-types-p9b8rfy8.d.ts → public-types-DyqnxxO9.d.ts} +124 -1
  72. package/dist/{public-types-B5CRoR6f.d.cts → public-types-gvubspUI.d.cts} +124 -1
  73. package/dist/public-types.cjs +595 -18
  74. package/dist/public-types.d.cts +1 -1
  75. package/dist/public-types.d.ts +1 -1
  76. package/dist/public-types.js +4 -4
  77. package/dist/runtime/collab.d.cts +2 -2
  78. package/dist/runtime/collab.d.ts +2 -2
  79. package/dist/runtime/document-runtime.cjs +908 -129
  80. package/dist/runtime/document-runtime.d.cts +1 -1
  81. package/dist/runtime/document-runtime.d.ts +1 -1
  82. package/dist/runtime/document-runtime.js +17 -17
  83. package/dist/{session-BnGIjaex.d.cts → session-BUN6B-Vj.d.cts} +2 -2
  84. package/dist/{session-vEYKf-w3.d.ts → session-CDB0hohT.d.ts} +2 -2
  85. package/dist/session.cjs +216 -203
  86. package/dist/session.d.cts +4 -4
  87. package/dist/session.d.ts +4 -4
  88. package/dist/session.js +7 -7
  89. package/dist/tailwind.cjs +595 -18
  90. package/dist/tailwind.d.cts +1 -1
  91. package/dist/tailwind.d.ts +1 -1
  92. package/dist/tailwind.js +8 -8
  93. package/dist/{types-BLuvZ6cQ.d.cts → types-C4bz3kDU.d.cts} +1 -1
  94. package/dist/{types-Dutlyj0T.d.ts → types-VWH6CRvG.d.ts} +1 -1
  95. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +2 -2
  96. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +2 -2
  97. package/dist/ui-tailwind/editor-surface/search-plugin.js +5 -5
  98. package/dist/ui-tailwind.cjs +595 -18
  99. package/dist/ui-tailwind.d.cts +2 -2
  100. package/dist/ui-tailwind.d.ts +2 -2
  101. package/dist/ui-tailwind.js +8 -8
  102. package/package.json +4 -1
@@ -247,6 +247,7 @@ function collectCanonicalLayoutInputs(doc) {
247
247
  const blockContexts = collectStoryBlockContexts(doc);
248
248
  return {
249
249
  stories: collectCanonicalStoryIdentities(doc),
250
+ layoutIdentities: collectLayoutInputIdentities(doc, blockContexts),
250
251
  fieldRegions: collectCanonicalFieldRegionIdentities(doc),
251
252
  numbering: collectCanonicalNumberingLayoutInputs(doc, blockContexts),
252
253
  tables: collectCanonicalTableLayoutInputs(blockContexts),
@@ -255,6 +256,116 @@ function collectCanonicalLayoutInputs(doc) {
255
256
  editableTargets: collectEditableTargetRefs(doc)
256
257
  };
257
258
  }
259
+ function collectLayoutInputIdentities(doc, contexts = collectStoryBlockContexts(doc)) {
260
+ const identities = [];
261
+ const editableTargets = collectEditableTargetRefs(doc);
262
+ const editableByStoryBlock = new Map(
263
+ editableTargets.map((target) => [`${target.storyKey}:${target.blockPath}`, target])
264
+ );
265
+ for (const context of contexts) {
266
+ walkBlocks(context.blocks, context.storyKey, context.basePath, {
267
+ paragraph(paragraph, blockPath) {
268
+ const styleNumbering = paragraph.numbering === void 0 && paragraph.styleId !== void 0 ? resolveParagraphStyleNumbering(doc, paragraph.styleId) : void 0;
269
+ const numbering = paragraph.numbering ?? styleNumbering;
270
+ const editableTargetRef = editableByStoryBlock.get(`${context.storyKey}:${blockPath}`);
271
+ identities.push(
272
+ createLayoutInputIdentity({
273
+ storyKey: context.storyKey,
274
+ blockPath,
275
+ block: paragraph,
276
+ ...editableTargetRef !== void 0 ? { editableTargetRef } : {},
277
+ ...numbering !== void 0 ? {
278
+ list: {
279
+ numberingInstanceId: numbering.numberingInstanceId,
280
+ level: numbering.level ?? 0,
281
+ ...paragraph.numbering?.sourceRef !== void 0 ? { markerSourceRef: paragraph.numbering.sourceRef } : {}
282
+ }
283
+ } : {}
284
+ })
285
+ );
286
+ },
287
+ table(table, blockPath) {
288
+ identities.push(
289
+ createLayoutInputIdentity({
290
+ storyKey: context.storyKey,
291
+ blockPath,
292
+ block: table,
293
+ table: { tableBlockPath: blockPath }
294
+ })
295
+ );
296
+ },
297
+ inline(inline, blockPath, inlinePath) {
298
+ const objectId = objectIdForInline(inline);
299
+ if (!objectId) return;
300
+ const sourceRef = sourceRefForInline(inline);
301
+ identities.push({
302
+ storyKey: context.storyKey,
303
+ blockPath,
304
+ blockId: `${context.storyKey}:${inlinePath}`,
305
+ ...sourceRef !== void 0 ? { sourceRef } : {},
306
+ object: {
307
+ objectId,
308
+ ...sourceRef !== void 0 ? { anchorSourceRef: sourceRef } : {}
309
+ }
310
+ });
311
+ }
312
+ });
313
+ }
314
+ return identities;
315
+ }
316
+ function createLayoutInputIdentity(input) {
317
+ const sourceRef = sourceRefForBlock(input.block);
318
+ const blockId = input.block.type === "paragraph" && input.block.wordExtensionIds?.paraId ? `para:${input.block.wordExtensionIds.paraId}` : sourceRef?.sourceId !== void 0 ? `source:${sourceRef.sourceId}` : `${input.storyKey}:${input.blockPath}`;
319
+ return {
320
+ storyKey: input.storyKey,
321
+ blockPath: input.blockPath,
322
+ blockId,
323
+ ...sourceRef !== void 0 ? { sourceRef } : {},
324
+ ...input.editableTargetRef !== void 0 ? { editableTargetRef: input.editableTargetRef } : {},
325
+ ...input.table !== void 0 ? { table: input.table } : {},
326
+ ...input.list !== void 0 ? { list: input.list } : {}
327
+ };
328
+ }
329
+ function sourceRefForBlock(block) {
330
+ return "sourceRef" in block ? block.sourceRef : void 0;
331
+ }
332
+ function sourceRefForInline(inline) {
333
+ return "sourceRef" in inline ? inline.sourceRef : void 0;
334
+ }
335
+ function objectIdForInline(inline) {
336
+ switch (inline.type) {
337
+ case "image":
338
+ return inline.mediaId;
339
+ case "drawing_frame":
340
+ return objectIdForDrawingContent(inline.content) ?? inline.sourceRef?.sourceId;
341
+ case "shape":
342
+ case "vml_shape":
343
+ case "wordart":
344
+ return inline.preserveOnlyObject?.sourceId ?? `raw:${sha256TextHex(inline.rawXml).slice(0, 16)}`;
345
+ case "chart_preview":
346
+ case "smartart_preview":
347
+ return inline.previewMediaId ?? `raw:${sha256TextHex(inline.rawXml).slice(0, 16)}`;
348
+ case "ole_embed":
349
+ return inline.relationshipId ?? inline.id ?? inline.sourceRef?.sourceId;
350
+ case "opaque_inline":
351
+ return inline.fragmentId;
352
+ default:
353
+ return void 0;
354
+ }
355
+ }
356
+ function objectIdForDrawingContent(content) {
357
+ switch (content.type) {
358
+ case "picture":
359
+ return content.mediaId ?? content.packagePartName ?? content.blipRef;
360
+ case "chart_preview":
361
+ case "smartart_preview":
362
+ return content.previewMediaId ?? `raw:${sha256TextHex(content.rawXml).slice(0, 16)}`;
363
+ case "shape":
364
+ return content.preserveOnlyObject?.sourceId ?? `raw:${sha256TextHex(content.rawXml).slice(0, 16)}`;
365
+ case "opaque":
366
+ return content.preserveOnlyObject?.sourceId ?? `raw:${sha256TextHex(content.rawXml).slice(0, 16)}`;
367
+ }
368
+ }
258
369
  function collectEditableTargetRefs(doc, cache) {
259
370
  const targets = [];
260
371
  for (const context of collectStoryBlockContexts(doc)) {
@@ -2403,6 +2514,16 @@ function collectCanonicalNumberingLayoutInputs(doc, contexts = collectStoryBlock
2403
2514
  const instance = doc.numbering.instances[numbering.numberingInstanceId];
2404
2515
  const abstractDefinition = instance?.abstractNumberingId === void 0 ? void 0 : doc.numbering.abstractDefinitions[instance.abstractNumberingId];
2405
2516
  inputs.push({
2517
+ identity: createLayoutInputIdentity({
2518
+ storyKey: context.storyKey,
2519
+ blockPath,
2520
+ block: paragraph,
2521
+ list: {
2522
+ numberingInstanceId: numbering.numberingInstanceId,
2523
+ level: numbering.level ?? 0,
2524
+ ...paragraph.numbering?.sourceRef !== void 0 ? { markerSourceRef: paragraph.numbering.sourceRef } : {}
2525
+ }
2526
+ }),
2406
2527
  numberingKey: `${context.storyKey}:${blockPath}:numbering`,
2407
2528
  storyKey: context.storyKey,
2408
2529
  blockPath,
@@ -2704,6 +2825,12 @@ function projectTableLayoutInput(table, storyKey, blockPath) {
2704
2825
  (row, rowIndex) => projectTableRowLayoutInput(row, tableKey, rowIndex)
2705
2826
  );
2706
2827
  return {
2828
+ identity: createLayoutInputIdentity({
2829
+ storyKey,
2830
+ blockPath,
2831
+ block: table,
2832
+ table: { tableBlockPath: blockPath }
2833
+ }),
2707
2834
  tableKey,
2708
2835
  storyKey,
2709
2836
  blockPath,
@@ -2791,6 +2918,16 @@ function projectDrawingFrameAnchor(node, storyKey, blockPath, inlinePath) {
2791
2918
  const objectKey = `${storyKey}:${inlinePath}`;
2792
2919
  const textBoxBody = projectTextBoxBodyLayoutInput(content, objectKey, sourceRef, `${inlinePath}/txbx`);
2793
2920
  return {
2921
+ identity: {
2922
+ storyKey,
2923
+ blockPath,
2924
+ blockId: objectKey,
2925
+ ...sourceRef !== void 0 ? { sourceRef } : {},
2926
+ object: {
2927
+ objectId: objectKey,
2928
+ ...sourceRef !== void 0 ? { anchorSourceRef: sourceRef } : {}
2929
+ }
2930
+ },
2794
2931
  objectKey,
2795
2932
  storyKey,
2796
2933
  blockPath,
@@ -2912,8 +3049,19 @@ function projectTextBoxRunLayoutInput(inline, paragraphKey, inlineIndex) {
2912
3049
  }
2913
3050
  function projectLegacyImageAnchor(doc, node, storyKey, blockPath, inlinePath) {
2914
3051
  const media = doc.media.items[node.mediaId];
3052
+ const objectKey = `${storyKey}:${inlinePath}`;
2915
3053
  return {
2916
- objectKey: `${storyKey}:${inlinePath}`,
3054
+ identity: {
3055
+ storyKey,
3056
+ blockPath,
3057
+ blockId: objectKey,
3058
+ ...node.sourceRef !== void 0 ? { sourceRef: node.sourceRef } : {},
3059
+ object: {
3060
+ objectId: objectKey,
3061
+ ...node.sourceRef !== void 0 ? { anchorSourceRef: node.sourceRef } : {}
3062
+ }
3063
+ },
3064
+ objectKey,
2917
3065
  storyKey,
2918
3066
  blockPath,
2919
3067
  inlinePath,
@@ -3099,6 +3247,7 @@ export {
3099
3247
  createHeaderFooterStoryKey,
3100
3248
  createNoteStoryKey,
3101
3249
  collectCanonicalLayoutInputs,
3250
+ collectLayoutInputIdentities,
3102
3251
  collectEditableTargetRefs,
3103
3252
  collectEditableTargetRefsForStoryBlockRanges,
3104
3253
  createEditableTargetBlockCache,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  collectEditableTargetRefs
3
- } from "./chunk-5DGKFNQT.js";
3
+ } from "./chunk-A66ZVUAT.js";
4
4
 
5
5
  // src/api/v3/_ux-response.ts
6
6
  function emitUxResponse(runtime, res) {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  loadDocxSessionAsync
3
- } from "./chunk-XMHSGPLN.js";
3
+ } from "./chunk-VRKK2CSZ.js";
4
4
  import {
5
5
  buildCompatibilityReport,
6
6
  createLoadScheduler
7
- } from "./chunk-JJGVE5J7.js";
7
+ } from "./chunk-4YCWECLZ.js";
8
8
  import {
9
9
  decodePersistedSourcePackageBytes,
10
10
  hasValidPersistedSourcePackageDigest,
@@ -1380,26 +1380,35 @@ function buildParagraphPropertiesXml(paragraph) {
1380
1380
  if (frameXml) children.push(frameXml);
1381
1381
  }
1382
1382
  pushOnOffParagraphProperty(children, "widowControl", paragraph.widowControl);
1383
- if (paragraph.outlineLevel !== void 0) {
1384
- children.push(`<w:outlineLvl w:val="${paragraph.outlineLevel}"/>`);
1385
- }
1386
1383
  if (paragraph.numbering) {
1387
1384
  children.push(serializeParagraphNumberingProperties(paragraph.numbering));
1388
1385
  }
1386
+ pushOnOffParagraphProperty(children, "suppressLineNumbers", paragraph.suppressLineNumbers);
1387
+ if (paragraph.borders) {
1388
+ const bordersXml = serializeParagraphBorders(paragraph.borders);
1389
+ if (bordersXml) children.push(bordersXml);
1390
+ }
1391
+ if (paragraph.shading) {
1392
+ const shadingXml = serializeParagraphShading(paragraph.shading);
1393
+ if (shadingXml) children.push(shadingXml);
1394
+ }
1395
+ if (paragraph.tabStops && paragraph.tabStops.length > 0) {
1396
+ const tabsXml = paragraph.tabStops.map((tab) => {
1397
+ const leaderAttr = tab.leader ? ` w:leader="${escapeXmlAttribute2(tab.leader)}"` : "";
1398
+ return `<w:tab w:val="${escapeXmlAttribute2(tab.align)}" w:pos="${twip(tab.position)}"${leaderAttr}/>`;
1399
+ }).join("");
1400
+ children.push(`<w:tabs>${tabsXml}</w:tabs>`);
1401
+ }
1402
+ pushOnOffParagraphProperty(children, "bidi", paragraph.bidi);
1389
1403
  if (paragraph.spacing) {
1390
1404
  const s = paragraph.spacing;
1391
1405
  const attrs = [];
1392
1406
  if (s.before !== void 0) attrs.push(`w:before="${twip(s.before)}"`);
1393
1407
  if (s.after !== void 0) attrs.push(`w:after="${twip(s.after)}"`);
1394
1408
  if (s.line !== void 0) attrs.push(`w:line="${twip(s.line)}"`);
1395
- if (s.lineRule !== void 0) attrs.push(`w:lineRule="${s.lineRule}"`);
1409
+ if (s.lineRule !== void 0) attrs.push(`w:lineRule="${escapeXmlAttribute2(s.lineRule)}"`);
1396
1410
  if (attrs.length > 0) children.push(`<w:spacing ${attrs.join(" ")}/>`);
1397
1411
  }
1398
- if (paragraph.contextualSpacing === true) {
1399
- children.push("<w:contextualSpacing/>");
1400
- } else if (paragraph.contextualSpacing === false) {
1401
- children.push(`<w:contextualSpacing w:val="false"/>`);
1402
- }
1403
1412
  if (paragraph.indentation) {
1404
1413
  const ind = paragraph.indentation;
1405
1414
  const attrs = [];
@@ -1409,33 +1418,20 @@ function buildParagraphPropertiesXml(paragraph) {
1409
1418
  if (ind.hanging !== void 0) attrs.push(`w:hanging="${twip(ind.hanging)}"`);
1410
1419
  if (attrs.length > 0) children.push(`<w:ind ${attrs.join(" ")}/>`);
1411
1420
  }
1412
- if (paragraph.alignment) {
1413
- children.push(`<w:jc w:val="${paragraph.alignment}"/>`);
1421
+ if (paragraph.contextualSpacing === true) {
1422
+ children.push("<w:contextualSpacing/>");
1423
+ } else if (paragraph.contextualSpacing === false) {
1424
+ children.push(`<w:contextualSpacing w:val="false"/>`);
1414
1425
  }
1415
- if (paragraph.borders) {
1416
- const bordersXml = serializeParagraphBorders(paragraph.borders);
1417
- if (bordersXml) {
1418
- children.push(bordersXml);
1419
- }
1426
+ if (paragraph.alignment) {
1427
+ children.push(`<w:jc w:val="${escapeXmlAttribute2(paragraph.alignment)}"/>`);
1420
1428
  }
1421
- if (paragraph.shading) {
1422
- const shadingXml = serializeParagraphShading(paragraph.shading);
1423
- if (shadingXml) {
1424
- children.push(shadingXml);
1425
- }
1429
+ if (paragraph.outlineLevel !== void 0) {
1430
+ children.push(`<w:outlineLvl w:val="${paragraph.outlineLevel}"/>`);
1426
1431
  }
1427
- pushOnOffParagraphProperty(children, "bidi", paragraph.bidi);
1428
- pushOnOffParagraphProperty(children, "suppressLineNumbers", paragraph.suppressLineNumbers);
1429
1432
  if (paragraph.cnfStyle) {
1430
1433
  children.push(`<w:cnfStyle w:val="${escapeXmlAttribute2(paragraph.cnfStyle)}"/>`);
1431
1434
  }
1432
- if (paragraph.tabStops && paragraph.tabStops.length > 0) {
1433
- const tabsXml = paragraph.tabStops.map((tab) => {
1434
- const leaderAttr = tab.leader ? ` w:leader="${tab.leader}"` : "";
1435
- return `<w:tab w:val="${tab.align}" w:pos="${twip(tab.position)}"${leaderAttr}/>`;
1436
- }).join("");
1437
- children.push(`<w:tabs>${tabsXml}</w:tabs>`);
1438
- }
1439
1435
  if (children.length === 0) return "";
1440
1436
  return `<w:pPr>${children.join("")}</w:pPr>`;
1441
1437
  }
@@ -2000,79 +1996,86 @@ function serializeRunProperties(marks) {
2000
1996
  if (!marks || marks.length === 0) {
2001
1997
  return "";
2002
1998
  }
1999
+ const orderedTypes = [
2000
+ "fontFamily",
2001
+ "bold",
2002
+ "italic",
2003
+ "allCaps",
2004
+ "smallCaps",
2005
+ "strikethrough",
2006
+ "doubleStrikethrough",
2007
+ "shadow",
2008
+ "emboss",
2009
+ "imprint",
2010
+ "vanish",
2011
+ "textColor",
2012
+ "charSpacing",
2013
+ "kerning",
2014
+ "position",
2015
+ "fontSize",
2016
+ "highlight",
2017
+ "underline",
2018
+ "backgroundColor",
2019
+ "lang",
2020
+ "textFill"
2021
+ ];
2003
2022
  const markParts = [];
2004
- for (const mark of marks) {
2005
- switch (mark.type) {
2006
- case "bold":
2007
- markParts.push("<w:b/>");
2008
- break;
2009
- case "italic":
2010
- markParts.push("<w:i/>");
2011
- break;
2012
- case "underline":
2013
- markParts.push(`<w:u w:val="single"/>`);
2014
- break;
2015
- case "strikethrough":
2016
- markParts.push("<w:strike/>");
2017
- break;
2018
- case "doubleStrikethrough":
2019
- markParts.push("<w:dstrike/>");
2020
- break;
2021
- case "vanish":
2022
- markParts.push("<w:vanish/>");
2023
- break;
2024
- case "lang":
2025
- markParts.push(`<w:lang w:val="${escapeXmlAttribute2(mark.val)}"/>`);
2026
- break;
2027
- case "highlight":
2028
- markParts.push(`<w:highlight w:val="${escapeXmlAttribute2(mark.val)}"/>`);
2029
- break;
2030
- case "backgroundColor":
2031
- markParts.push(
2032
- `<w:shd w:val="clear" w:color="auto" w:fill="${escapeXmlAttribute2(mark.color)}"/>`
2033
- );
2034
- break;
2035
- case "charSpacing":
2036
- markParts.push(`<w:spacing w:val="${mark.val}"/>`);
2037
- break;
2038
- case "kerning":
2039
- markParts.push(`<w:kern w:val="${mark.val}"/>`);
2040
- break;
2041
- case "emboss":
2042
- markParts.push("<w:emboss/>");
2043
- break;
2044
- case "imprint":
2045
- markParts.push("<w:imprint/>");
2046
- break;
2047
- case "shadow":
2048
- markParts.push("<w:shadow/>");
2049
- break;
2050
- case "position":
2051
- markParts.push(`<w:position w:val="${mark.val}"/>`);
2052
- break;
2053
- case "textFill":
2054
- markParts.push(mark.xml);
2055
- break;
2056
- case "fontFamily":
2057
- markParts.push(`<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`);
2058
- break;
2059
- case "fontSize":
2060
- markParts.push(`<w:sz w:val="${mark.val}"/>`);
2061
- break;
2062
- case "textColor":
2063
- markParts.push(`<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`);
2064
- break;
2065
- case "smallCaps":
2066
- markParts.push("<w:smallCaps/>");
2067
- break;
2068
- case "allCaps":
2069
- markParts.push("<w:caps/>");
2070
- break;
2023
+ for (const type of orderedTypes) {
2024
+ for (const mark of marks) {
2025
+ if (mark.type !== type) continue;
2026
+ const xml = serializeRunPropertyMark(mark);
2027
+ if (xml) markParts.push(xml);
2071
2028
  }
2072
2029
  }
2073
2030
  const children = markParts.join("");
2074
2031
  return children.length > 0 ? `<w:rPr>${children}</w:rPr>` : "";
2075
2032
  }
2033
+ function serializeRunPropertyMark(mark) {
2034
+ switch (mark.type) {
2035
+ case "bold":
2036
+ return "<w:b/>";
2037
+ case "italic":
2038
+ return "<w:i/>";
2039
+ case "underline":
2040
+ return `<w:u w:val="single"/>`;
2041
+ case "strikethrough":
2042
+ return "<w:strike/>";
2043
+ case "doubleStrikethrough":
2044
+ return "<w:dstrike/>";
2045
+ case "vanish":
2046
+ return "<w:vanish/>";
2047
+ case "lang":
2048
+ return `<w:lang w:val="${escapeXmlAttribute2(mark.val)}"/>`;
2049
+ case "highlight":
2050
+ return `<w:highlight w:val="${escapeXmlAttribute2(mark.val)}"/>`;
2051
+ case "backgroundColor":
2052
+ return `<w:shd w:val="clear" w:color="auto" w:fill="${escapeXmlAttribute2(mark.color)}"/>`;
2053
+ case "charSpacing":
2054
+ return `<w:spacing w:val="${mark.val}"/>`;
2055
+ case "kerning":
2056
+ return `<w:kern w:val="${mark.val}"/>`;
2057
+ case "emboss":
2058
+ return "<w:emboss/>";
2059
+ case "imprint":
2060
+ return "<w:imprint/>";
2061
+ case "shadow":
2062
+ return "<w:shadow/>";
2063
+ case "position":
2064
+ return `<w:position w:val="${mark.val}"/>`;
2065
+ case "textFill":
2066
+ return mark.xml;
2067
+ case "fontFamily":
2068
+ return `<w:rFonts w:ascii="${escapeXmlAttribute2(mark.val)}" w:hAnsi="${escapeXmlAttribute2(mark.val)}"/>`;
2069
+ case "fontSize":
2070
+ return `<w:sz w:val="${mark.val}"/>`;
2071
+ case "textColor":
2072
+ return `<w:color w:val="${escapeXmlAttribute2(mark.color)}"/>`;
2073
+ case "smallCaps":
2074
+ return "<w:smallCaps/>";
2075
+ case "allCaps":
2076
+ return "<w:caps/>";
2077
+ }
2078
+ }
2076
2079
  function requiresPreservedSpace(text) {
2077
2080
  return /^\s/.test(text) || /\s$/.test(text) || text.includes(" ");
2078
2081
  }
@@ -8,7 +8,7 @@ import {
8
8
  getRevisionRangeState,
9
9
  selectionTouchesRange,
10
10
  shouldHideInCleanMode
11
- } from "./chunk-PGKUJZXV.js";
11
+ } from "./chunk-3YCQM2RV.js";
12
12
 
13
13
  // src/ui-tailwind/editor-surface/tw-editor-surface.tsx
14
14
  import { useMemo } from "react";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  TextTransactionError
3
- } from "./chunk-5DSHUYSY.js";
3
+ } from "./chunk-T5YYFDZB.js";
4
4
  import {
5
5
  replaceParagraphScope,
6
6
  resolveParagraphScope
7
- } from "./chunk-W34X3KBR.js";
7
+ } from "./chunk-PHMWH23E.js";
8
8
  import {
9
9
  cloneParagraphProperties,
10
10
  cloneStoryUnit,
@@ -6,7 +6,7 @@ import {
6
6
  createHeaderFooterStoryKey,
7
7
  createNoteStoryKey,
8
8
  sha256TextHex
9
- } from "./chunk-5DGKFNQT.js";
9
+ } from "./chunk-A66ZVUAT.js";
10
10
  import {
11
11
  SCOPE_MARKER_BOOKMARK_PREFIX,
12
12
  buildGrabBagSourceChildFromParsed,
@@ -1537,8 +1537,7 @@ function parseInteger(value) {
1537
1537
  // src/io/ooxml/parse-bookmark-references.ts
1538
1538
  var HYPERLINK_ANCHOR_RE = /<(?:\w+:)?hyperlink\b[^>]*\bw:anchor\s*=\s*"([^"]*)"/gi;
1539
1539
  var INSTR_TEXT_RE = /<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gi;
1540
- var FLD_SIMPLE_INSTR_DOUBLE_RE = /<(?:\w+:)?fldSimple\b[^>]*?\b(?:w:)?instr\s*=\s*"([^"]*)"/gi;
1541
- var FLD_SIMPLE_INSTR_SINGLE_RE = /<(?:\w+:)?fldSimple\b[^>]*?\b(?:w:)?instr\s*=\s*'([^']*)'/gi;
1540
+ var FLD_SIMPLE_INSTR_RE = /<(?:\w+:)?fldSimple\b[^>]*\bw:instr\s*=\s*(["'])([\s\S]*?)\1/gi;
1542
1541
  var TOC_FIELD_RE = /\bTOC\b/;
1543
1542
  var REFLIKE_FIELD_RE = /\b(?:HYPERLINK|REF|PAGEREF|NOTEREF)\s+([A-Za-z0-9_:.\-]+)/g;
1544
1543
  var DATA_BINDING_RE = /<(?:\w+:)?dataBinding\b/i;
@@ -1557,21 +1556,14 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
1557
1556
  }
1558
1557
  INSTR_TEXT_RE.lastIndex = 0;
1559
1558
  while ((m = INSTR_TEXT_RE.exec(documentXml)) !== null) {
1560
- const instrText = m[1] ?? "";
1561
- scanFieldInstruction(instrText, retained, () => {
1562
- retainAllToc = true;
1559
+ retainInstructionReferences(m[1] ?? "", retained, (value) => {
1560
+ retainAllToc = retainAllToc || value;
1563
1561
  });
1564
1562
  }
1565
- FLD_SIMPLE_INSTR_DOUBLE_RE.lastIndex = 0;
1566
- while ((m = FLD_SIMPLE_INSTR_DOUBLE_RE.exec(documentXml)) !== null) {
1567
- scanFieldInstruction(decodeXmlAttribute(m[1] ?? ""), retained, () => {
1568
- retainAllToc = true;
1569
- });
1570
- }
1571
- FLD_SIMPLE_INSTR_SINGLE_RE.lastIndex = 0;
1572
- while ((m = FLD_SIMPLE_INSTR_SINGLE_RE.exec(documentXml)) !== null) {
1573
- scanFieldInstruction(decodeXmlAttribute(m[1] ?? ""), retained, () => {
1574
- retainAllToc = true;
1563
+ FLD_SIMPLE_INSTR_RE.lastIndex = 0;
1564
+ while ((m = FLD_SIMPLE_INSTR_RE.exec(documentXml)) !== null) {
1565
+ retainInstructionReferences(m[2] ?? "", retained, (value) => {
1566
+ retainAllToc = retainAllToc || value;
1575
1567
  });
1576
1568
  }
1577
1569
  retainRevisionBoundedBookmarks(documentXml, retained);
@@ -1581,17 +1573,14 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
1581
1573
  retainAll
1582
1574
  };
1583
1575
  }
1584
- function scanFieldInstruction(instrText, retained, retainToc) {
1585
- if (TOC_FIELD_RE.test(instrText)) retainToc();
1576
+ function retainInstructionReferences(instrText, retained, setRetainAllToc) {
1577
+ if (TOC_FIELD_RE.test(instrText)) setRetainAllToc(true);
1586
1578
  REFLIKE_FIELD_RE.lastIndex = 0;
1587
1579
  let r;
1588
1580
  while ((r = REFLIKE_FIELD_RE.exec(instrText)) !== null) {
1589
1581
  if (r[1]) retained.add(r[1]);
1590
1582
  }
1591
1583
  }
1592
- function decodeXmlAttribute(value) {
1593
- return value.replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
1594
- }
1595
1584
  function retainRevisionBoundedBookmarks(documentXml, retained) {
1596
1585
  const starts = /* @__PURE__ */ new Map();
1597
1586
  BOOKMARK_START_RE.lastIndex = 0;
@@ -24,6 +24,43 @@ var DEFAULT_FONT_AVG_CHAR_WIDTH = 5.5;
24
24
  var DEFAULT_FONT_SIZE_HALF_POINTS = 24;
25
25
  var DEFAULT_LINE_HEIGHT_FACTOR = 1.15;
26
26
  var TWIPS_PER_POINT = 20;
27
+ function createLayoutReadyFormattingSnapshot(formatting, runs = /* @__PURE__ */ new Map()) {
28
+ const snapshot = {
29
+ version: 1,
30
+ paragraph: {
31
+ spacingBefore: formatting.spacingBefore,
32
+ spacingAfter: formatting.spacingAfter,
33
+ lineHeight: formatting.lineHeight,
34
+ lineRule: formatting.lineRule,
35
+ indentLeft: formatting.indentLeft,
36
+ indentRight: formatting.indentRight,
37
+ firstLineIndent: formatting.firstLineIndent,
38
+ hangingIndent: formatting.hangingIndent,
39
+ fontSizeHalfPoints: formatting.fontSizeHalfPoints,
40
+ averageCharWidthTwips: formatting.averageCharWidthTwips,
41
+ tabStops: formatting.tabStops.map((tab) => ({ ...tab })),
42
+ defaultTabInterval: formatting.defaultTabInterval,
43
+ keepNext: formatting.keepNext,
44
+ keepLines: formatting.keepLines,
45
+ pageBreakBefore: formatting.pageBreakBefore,
46
+ widowControl: formatting.widowControl,
47
+ contextualSpacing: formatting.contextualSpacing,
48
+ ...formatting.numberingMarkerBox ? { numberingMarkerBox: { ...formatting.numberingMarkerBox } } : {}
49
+ },
50
+ runs: Array.from(runs.entries()).map(([runId, run]) => ({
51
+ runId,
52
+ ...run.fontFamily ? { fontFamily: run.fontFamily } : {},
53
+ ...typeof run.fontSizeHalfPoints === "number" ? { fontSizeHalfPoints: run.fontSizeHalfPoints } : {},
54
+ bold: Boolean(run.bold),
55
+ italic: Boolean(run.italic),
56
+ verticalAlign: run.verticalAlign ?? "baseline"
57
+ })).sort((a, b) => a.runId.localeCompare(b.runId))
58
+ };
59
+ return {
60
+ ...snapshot,
61
+ hash: hashStable(snapshot)
62
+ };
63
+ }
27
64
  function resolveBlockFormatting(block, defaultTabInterval = 720, themeFonts) {
28
65
  if (block.kind !== "paragraph") {
29
66
  return null;
@@ -266,6 +303,29 @@ function buildRunFormattingMap(block) {
266
303
  }
267
304
  return runs;
268
305
  }
306
+ function hashStable(value) {
307
+ return fnv1a(stableStringify(value)).toString(36);
308
+ }
309
+ function stableStringify(value) {
310
+ if (value === null || typeof value !== "object") return JSON.stringify(value);
311
+ if (Array.isArray(value)) {
312
+ return `[${value.map((item) => stableStringify(item)).join(",")}]`;
313
+ }
314
+ if (value instanceof Map) {
315
+ return stableStringify(Array.from(value.entries()));
316
+ }
317
+ const object = value;
318
+ const keys = Object.keys(object).filter((key) => object[key] !== void 0 && typeof object[key] !== "function").sort();
319
+ return `{${keys.map((key) => `${JSON.stringify(key)}:${stableStringify(object[key])}`).join(",")}}`;
320
+ }
321
+ function fnv1a(input) {
322
+ let hash = 2166136261;
323
+ for (let i = 0; i < input.length; i += 1) {
324
+ hash ^= input.charCodeAt(i);
325
+ hash = Math.imul(hash, 16777619);
326
+ }
327
+ return hash >>> 0;
328
+ }
269
329
 
270
330
  // src/runtime/layout/measurement-backend-empirical.ts
271
331
  var MIN_BLOCK_HEIGHT_TWIPS = 240;
@@ -682,6 +742,7 @@ function createCanvasBackend(fontLoader) {
682
742
  }
683
743
 
684
744
  export {
745
+ createLayoutReadyFormattingSnapshot,
685
746
  resolveBlockFormatting,
686
747
  resolveTextWidth,
687
748
  resolveCharsPerLine,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  NO_EDITABLE_TARGETS_INDEX,
3
3
  createEditorSurfaceSnapshot
4
- } from "./chunk-HUIHBBAQ.js";
4
+ } from "./chunk-A3GSNB4G.js";
5
5
  import {
6
6
  createSelectionSnapshot
7
7
  } from "./chunk-OYGMRRR7.js";
@@ -3,12 +3,12 @@ import {
3
3
  createNoopStructuralMutation,
4
4
  findTableCellParagraphSelection,
5
5
  findTopLevelParagraphSelectionNearBlock
6
- } from "./chunk-W34X3KBR.js";
6
+ } from "./chunk-PHMWH23E.js";
7
7
  import {
8
8
  collectEditableTargetRefs,
9
9
  collectStoryBlockContexts,
10
10
  createHeaderFooterStoryKey
11
- } from "./chunk-5DGKFNQT.js";
11
+ } from "./chunk-A66ZVUAT.js";
12
12
  import {
13
13
  createDetachedAnchor,
14
14
  createNodeAnchor,
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-Y4XZCMCS.js";
4
4
  import {
5
5
  applyTextTransaction
6
- } from "./chunk-5DSHUYSY.js";
6
+ } from "./chunk-T5YYFDZB.js";
7
7
  import {
8
8
  createInsertedTableBlock,
9
9
  createNoopStructuralMutation,
@@ -11,11 +11,11 @@ import {
11
11
  replaceParagraphScope,
12
12
  resolveInsertedTableStyleId,
13
13
  resolveParagraphScope
14
- } from "./chunk-W34X3KBR.js";
14
+ } from "./chunk-PHMWH23E.js";
15
15
  import {
16
16
  NO_EDITABLE_TARGETS_INDEX,
17
17
  createEditorSurfaceSnapshot
18
- } from "./chunk-HUIHBBAQ.js";
18
+ } from "./chunk-A3GSNB4G.js";
19
19
  import {
20
20
  createSelectionSnapshot
21
21
  } from "./chunk-OYGMRRR7.js";