@beyondwork/docx-react-component 1.0.121 → 1.0.123

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 +318 -32
  2. package/dist/api/public-types.d.cts +2 -2
  3. package/dist/api/public-types.d.ts +2 -2
  4. package/dist/api/public-types.js +3 -3
  5. package/dist/api/v3.cjs +349 -62
  6. package/dist/api/v3.d.cts +3 -3
  7. package/dist/api/v3.d.ts +3 -3
  8. package/dist/api/v3.js +10 -10
  9. package/dist/{canonical-document-ByIqTd4s.d.cts → canonical-document-CG2TgAzj.d.cts} +1 -1
  10. package/dist/{canonical-document-ByIqTd4s.d.ts → canonical-document-CG2TgAzj.d.ts} +1 -1
  11. package/dist/{chunk-B4YHWFE3.js → chunk-32ZAOQ54.js} +1 -1
  12. package/dist/{chunk-QNGJRZ2D.js → chunk-4IPEZYQX.js} +1 -1
  13. package/dist/{chunk-3OFSP2IX.js → chunk-BOHHIVQ2.js} +3 -3
  14. package/dist/{chunk-EMDH4IQN.js → chunk-E5IBDE5E.js} +4 -3
  15. package/dist/{chunk-TFSXOIAI.js → chunk-FNWKE74J.js} +43 -3
  16. package/dist/{chunk-IT2DK3A7.js → chunk-H2YQKA55.js} +9 -7
  17. package/dist/{chunk-3TUQCHYT.js → chunk-H6IL5ABU.js} +47 -7
  18. package/dist/{chunk-GON2DNTE.js → chunk-HXHQA4BU.js} +1 -1
  19. package/dist/{chunk-3OHVK2D6.js → chunk-IR7QV2BX.js} +17 -1
  20. package/dist/{chunk-ZKSDVHGH.js → chunk-KOHQFZMM.js} +1 -1
  21. package/dist/{chunk-XVFENXLK.js → chunk-LGWNN3L2.js} +2 -2
  22. package/dist/{chunk-TMU7JMXX.js → chunk-MB7RJBSN.js} +9 -21
  23. package/dist/{chunk-UWDWGQH5.js → chunk-ML4A4WUN.js} +1 -1
  24. package/dist/{chunk-GZW2ERUO.js → chunk-N4VIXI2Z.js} +3 -3
  25. package/dist/{chunk-S4ANOS2M.js → chunk-NNPVA5VL.js} +2 -2
  26. package/dist/{chunk-QFU7ZOAD.js → chunk-PFYUJU3Q.js} +176 -36
  27. package/dist/{chunk-37SEJQ3G.js → chunk-RSYN6FTS.js} +2 -2
  28. package/dist/{chunk-OBCP6VTG.js → chunk-RWERZWHR.js} +1 -1
  29. package/dist/{chunk-UHQOUTAX.js → chunk-SGSJ4DQA.js} +377 -50
  30. package/dist/{chunk-PCXTMEGY.js → chunk-UHJLCPLU.js} +24 -14
  31. package/dist/{chunk-G3B2OBCZ.js → chunk-ZRHLLPSJ.js} +271 -26
  32. package/dist/compare.d.cts +1 -1
  33. package/dist/compare.d.ts +1 -1
  34. package/dist/core/commands/formatting-commands.d.cts +2 -2
  35. package/dist/core/commands/formatting-commands.d.ts +2 -2
  36. package/dist/core/commands/image-commands.cjs +50 -9
  37. package/dist/core/commands/image-commands.d.cts +2 -2
  38. package/dist/core/commands/image-commands.d.ts +2 -2
  39. package/dist/core/commands/image-commands.js +5 -5
  40. package/dist/core/commands/section-layout-commands.d.cts +2 -2
  41. package/dist/core/commands/section-layout-commands.d.ts +2 -2
  42. package/dist/core/commands/style-commands.d.cts +2 -2
  43. package/dist/core/commands/style-commands.d.ts +2 -2
  44. package/dist/core/commands/table-structure-commands.cjs +50 -9
  45. package/dist/core/commands/table-structure-commands.d.cts +2 -2
  46. package/dist/core/commands/table-structure-commands.d.ts +2 -2
  47. package/dist/core/commands/table-structure-commands.js +4 -4
  48. package/dist/core/commands/text-commands.cjs +66 -9
  49. package/dist/core/commands/text-commands.d.cts +3 -2
  50. package/dist/core/commands/text-commands.d.ts +3 -2
  51. package/dist/core/commands/text-commands.js +5 -5
  52. package/dist/core/selection/mapping.d.cts +2 -2
  53. package/dist/core/selection/mapping.d.ts +2 -2
  54. package/dist/core/state/editor-state.d.cts +2 -2
  55. package/dist/core/state/editor-state.d.ts +2 -2
  56. package/dist/index.cjs +1196 -197
  57. package/dist/index.d.cts +5 -5
  58. package/dist/index.d.ts +5 -5
  59. package/dist/index.js +278 -85
  60. package/dist/io/docx-session.cjs +10 -21
  61. package/dist/io/docx-session.d.cts +4 -4
  62. package/dist/io/docx-session.d.ts +4 -4
  63. package/dist/io/docx-session.js +4 -4
  64. package/dist/legal.cjs +8 -20
  65. package/dist/legal.d.cts +1 -1
  66. package/dist/legal.d.ts +1 -1
  67. package/dist/legal.js +3 -3
  68. package/dist/{loader-BF8ju_LK.d.ts → loader-D9KCtj4m.d.cts} +4 -22
  69. package/dist/{loader-g54WRvj1.d.cts → loader-D9y4ZRjj.d.ts} +4 -22
  70. package/dist/{public-types-Dl1jiWjk.d.ts → public-types-CNnMHZM9.d.ts} +263 -213
  71. package/dist/{public-types-D_y4Ptcj.d.cts → public-types-DajNGKV4.d.cts} +263 -213
  72. package/dist/public-types.cjs +318 -32
  73. package/dist/public-types.d.cts +2 -2
  74. package/dist/public-types.d.ts +2 -2
  75. package/dist/public-types.js +3 -3
  76. package/dist/runtime/collab.d.cts +3 -3
  77. package/dist/runtime/collab.d.ts +3 -3
  78. package/dist/runtime/document-runtime.cjs +752 -77
  79. package/dist/runtime/document-runtime.d.cts +2 -2
  80. package/dist/runtime/document-runtime.d.ts +2 -2
  81. package/dist/runtime/document-runtime.js +14 -14
  82. package/dist/{session-C1EPAkcI.d.ts → session-DEmaOEjA.d.ts} +3 -3
  83. package/dist/{session-D15QOO0Q.d.cts → session-DyQGlryH.d.cts} +3 -3
  84. package/dist/session.cjs +12 -618
  85. package/dist/session.d.cts +5 -5
  86. package/dist/session.d.ts +5 -5
  87. package/dist/session.js +7 -9
  88. package/dist/tailwind.cjs +489 -63
  89. package/dist/tailwind.d.cts +2 -2
  90. package/dist/tailwind.d.ts +2 -2
  91. package/dist/tailwind.js +7 -7
  92. package/dist/{types-BoSRp2Vg.d.cts → types-CxE1aZiv.d.cts} +2 -2
  93. package/dist/{types-DEvRwq9C.d.ts → types-DjJNaE9c.d.ts} +2 -2
  94. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +3 -3
  95. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +3 -3
  96. package/dist/ui-tailwind/editor-surface/search-plugin.js +4 -4
  97. package/dist/ui-tailwind/theme/tokens.css +387 -0
  98. package/dist/ui-tailwind.cjs +489 -63
  99. package/dist/ui-tailwind.d.cts +3 -3
  100. package/dist/ui-tailwind.d.ts +3 -3
  101. package/dist/ui-tailwind.js +7 -7
  102. package/package.json +7 -3
package/dist/session.cjs CHANGED
@@ -24,8 +24,7 @@ __export(session_exports, {
24
24
  SessionNotOpenError: () => SessionNotOpenError,
25
25
  SessionNotWiredError: () => SessionNotWiredError,
26
26
  isReopenBarrier: () => isReopenBarrier,
27
- loadDocxSessionAsync: () => loadDocxSessionAsync,
28
- loadDocxSessionSync: () => loadDocxSessionSync
27
+ loadDocxSessionAsync: () => loadDocxSessionAsync
29
28
  });
30
29
  module.exports = __toCommonJS(session_exports);
31
30
 
@@ -14826,7 +14825,6 @@ function resolveContentType(path, contentTypes) {
14826
14825
  // src/io/ooxml/parse-bookmark-references.ts
14827
14826
  var HYPERLINK_ANCHOR_RE = /<(?:\w+:)?hyperlink\b[^>]*\bw:anchor\s*=\s*"([^"]*)"/gi;
14828
14827
  var INSTR_TEXT_RE = /<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gi;
14829
- var SIMPLE_FIELD_INSTR_RE = /<(?:\w+:)?fldSimple\b[^>]*\bw:instr\s*=\s*"([^"]*)"/gi;
14830
14828
  var TOC_FIELD_RE = /\bTOC\b/;
14831
14829
  var REFLIKE_FIELD_RE = /\b(?:HYPERLINK|REF|PAGEREF|NOTEREF)\s+([A-Za-z0-9_:.\-]+)/g;
14832
14830
  var DATA_BINDING_RE = /<(?:\w+:)?dataBinding\b/i;
@@ -14845,14 +14843,12 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
14845
14843
  }
14846
14844
  INSTR_TEXT_RE.lastIndex = 0;
14847
14845
  while ((m = INSTR_TEXT_RE.exec(documentXml)) !== null) {
14848
- if (scanInstructionForRetainedBookmarks(m[1] ?? "", retained)) {
14849
- retainAllToc = true;
14850
- }
14851
- }
14852
- SIMPLE_FIELD_INSTR_RE.lastIndex = 0;
14853
- while ((m = SIMPLE_FIELD_INSTR_RE.exec(documentXml)) !== null) {
14854
- if (scanInstructionForRetainedBookmarks(m[1] ?? "", retained)) {
14855
- retainAllToc = true;
14846
+ const instrText = m[1] ?? "";
14847
+ if (TOC_FIELD_RE.test(instrText)) retainAllToc = true;
14848
+ REFLIKE_FIELD_RE.lastIndex = 0;
14849
+ let r;
14850
+ while ((r = REFLIKE_FIELD_RE.exec(instrText)) !== null) {
14851
+ if (r[1]) retained.add(r[1]);
14856
14852
  }
14857
14853
  }
14858
14854
  retainRevisionBoundedBookmarks(documentXml, retained);
@@ -14862,15 +14858,6 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
14862
14858
  retainAll
14863
14859
  };
14864
14860
  }
14865
- function scanInstructionForRetainedBookmarks(instruction, retained) {
14866
- const hasTocField = TOC_FIELD_RE.test(instruction);
14867
- REFLIKE_FIELD_RE.lastIndex = 0;
14868
- let r;
14869
- while ((r = REFLIKE_FIELD_RE.exec(instruction)) !== null) {
14870
- if (r[1]) retained.add(r[1]);
14871
- }
14872
- return hasTocField;
14873
- }
14874
14861
  function retainRevisionBoundedBookmarks(documentXml, retained) {
14875
14862
  const starts = /* @__PURE__ */ new Map();
14876
14863
  BOOKMARK_START_RE.lastIndex = 0;
@@ -18373,7 +18360,7 @@ var SAFE_TABLE_FIELD_FAMILIES = /* @__PURE__ */ new Set([
18373
18360
  "FORMULA"
18374
18361
  ]);
18375
18362
  var RISKY_TABLE_MARKUP_RE = /<w:(ins|del|moveFrom|moveTo|rPrChange|pPrChange|tblPrChange|trPrChange|tcPrChange|sectPrChange|cellIns|cellDel|cellMerge|smartTag)\b/;
18376
- var SIMPLE_FIELD_INSTR_RE2 = /\bw:instr="([^"]*)"/g;
18363
+ var SIMPLE_FIELD_INSTR_RE = /\bw:instr="([^"]*)"/g;
18377
18364
  var COMPLEX_FIELD_TOKEN_RE = /<(?:\w+:)?fldChar\b[^>]*?(?:\w+:)?fldCharType="(begin|separate|end)"[^>]*?(?:\/>|>[\s\S]*?<\/(?:\w+:)?fldChar>)|<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gu;
18378
18365
  function decodeXmlEntities5(text) {
18379
18366
  return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
@@ -18414,7 +18401,7 @@ function isSafeTableFieldInstruction(instruction) {
18414
18401
  }
18415
18402
  function tableRequiresOpaquePreservation(rawXml) {
18416
18403
  if (RISKY_TABLE_MARKUP_RE.test(rawXml)) return true;
18417
- const simpleInstructions = [...rawXml.matchAll(SIMPLE_FIELD_INSTR_RE2)].map(
18404
+ const simpleInstructions = [...rawXml.matchAll(SIMPLE_FIELD_INSTR_RE)].map(
18418
18405
  (match) => match[1] ?? ""
18419
18406
  );
18420
18407
  const complexInstructions = extractComplexFieldInstructionsFromRaw(rawXml);
@@ -21776,45 +21763,6 @@ function disposeIdleHandles(store) {
21776
21763
  }
21777
21764
 
21778
21765
  // src/io/normalize/normalize-text.ts
21779
- function normalizeParsedTextDocument(document2, packagePartName = "/word/document.xml") {
21780
- const state = {
21781
- nextFragmentIndex: 1,
21782
- nextWarningIndex: 1,
21783
- nextDiagnosticIndex: 1,
21784
- cursor: 0,
21785
- media: {
21786
- items: {}
21787
- },
21788
- preservation: {
21789
- opaqueFragments: {},
21790
- packageParts: {}
21791
- },
21792
- diagnostics: {
21793
- warnings: [],
21794
- errors: []
21795
- }
21796
- };
21797
- const children = [];
21798
- let previousParagraph = false;
21799
- for (const block of document2.blocks) {
21800
- const normalizedBlocks = normalizeBlocks(block, state, packagePartName);
21801
- for (const normalizedBlock of normalizedBlocks) {
21802
- if (previousParagraph && normalizedBlock.type === "paragraph") {
21803
- state.cursor += 1;
21804
- }
21805
- children.push(normalizedBlock);
21806
- previousParagraph = normalizedBlock.type === "paragraph";
21807
- }
21808
- }
21809
- const content = { type: "doc", children };
21810
- return {
21811
- content,
21812
- media: state.media,
21813
- preservation: state.preservation,
21814
- diagnostics: state.diagnostics,
21815
- ...document2.finalSectionProperties !== void 0 ? { finalSectionProperties: document2.finalSectionProperties } : {}
21816
- };
21817
- }
21818
21766
  var NORMALIZE_YIELD_STRIDE = 256;
21819
21767
  async function normalizeParsedTextDocumentAsync(document2, packagePartName = "/word/document.xml", scheduler) {
21820
21768
  const state = {
@@ -24194,7 +24142,8 @@ function parseCommentDefinitions(commentsXml, extensions, durableIds) {
24194
24142
  const createdAt = normalizeImportedTimestamp2(
24195
24143
  readStringAttr(child, "w:date")
24196
24144
  );
24197
- const initials = readStringAttr(child, "w:initials");
24145
+ const rawInitials = readStringAttr(child, "w:initials");
24146
+ const initials = rawInitials !== void 0 && rawInitials.trim().length > 0 ? rawInitials : void 0;
24198
24147
  const paragraphNodes = child.children.filter(
24199
24148
  (node) => node.type === "element" && localName(node.name) === "p"
24200
24149
  );
@@ -28627,560 +28576,6 @@ async function loadDocxSessionAsync(options) {
28627
28576
  );
28628
28577
  }
28629
28578
  }
28630
- function loadDocxSessionSync(options) {
28631
- const editorBuild = typeof options.editorBuild === "string" && options.editorBuild.length > 0 ? options.editorBuild : "dev";
28632
- const sourceBytes = toUint8Array2(options.bytes);
28633
- const stages = createStageEmitter(options.onLoadStage);
28634
- let sourcePackage;
28635
- try {
28636
- sourcePackage = readOpcPackage(sourceBytes);
28637
- } catch (error) {
28638
- return createDiagnosticsSession(
28639
- options,
28640
- createPackageImportDiagnostics({
28641
- issue: classifyCorruptPackageError(error)
28642
- })
28643
- );
28644
- }
28645
- const packageMetadata = parseDocumentMetadataFromOpcParts(sourcePackage.parts);
28646
- stages.emit("opc");
28647
- const embeddedWorkflowPayload = parseWorkflowPayloadEnvelopeFromPackage(sourcePackage);
28648
- const embeddedWorkflowMetadata = embeddedWorkflowPayload?.workflowMetadata;
28649
- const embeddedWorkflowOverlay = embeddedWorkflowPayload?.workflowOverlay;
28650
- const mainDocumentPath = resolveMainDocumentPartPath(sourcePackage);
28651
- const brokenRelationshipIssues = collectBrokenInternalRelationshipIssues(
28652
- sourcePackage,
28653
- mainDocumentPath
28654
- );
28655
- if (brokenRelationshipIssues.length > 0) {
28656
- return createDiagnosticsSession(
28657
- options,
28658
- createPackageImportDiagnostics({
28659
- issue: {
28660
- ...brokenRelationshipIssues[0],
28661
- message: summarizeBrokenRelationshipIssues(brokenRelationshipIssues),
28662
- details: {
28663
- issueCount: brokenRelationshipIssues.length,
28664
- targets: brokenRelationshipIssues.map((issue) => issue.targetPartPath).filter(Boolean)
28665
- }
28666
- }
28667
- })
28668
- );
28669
- }
28670
- if (!mainDocumentPath) {
28671
- return createDiagnosticsSession(
28672
- options,
28673
- createPackageImportDiagnostics({
28674
- issue: createMissingPartIssue(MAIN_DOCUMENT_PATH)
28675
- })
28676
- );
28677
- }
28678
- const documentPart = sourcePackage.parts.get(mainDocumentPath);
28679
- if (!documentPart) {
28680
- return createDiagnosticsSession(
28681
- options,
28682
- createPackageImportDiagnostics({
28683
- issue: createMissingPartIssue(mainDocumentPath)
28684
- })
28685
- );
28686
- }
28687
- if (documentPart.contentType !== MAIN_DOCUMENT_CONTENT_TYPE) {
28688
- return createDiagnosticsSession(
28689
- options,
28690
- createValidationImportDiagnostics({
28691
- message: `DOCX main document part ${mainDocumentPath} must use content type ${MAIN_DOCUMENT_CONTENT_TYPE}.`
28692
- })
28693
- );
28694
- }
28695
- try {
28696
- const sourceDocumentXml = decodeUtf82(documentPart.bytes);
28697
- const importedRevisions = parseRevisionsFromDocumentXml(sourceDocumentXml);
28698
- const numberingPartPath = resolveDocumentRelatedPartPath(
28699
- sourcePackage,
28700
- mainDocumentPath,
28701
- documentPart.relationships,
28702
- NUMBERING_RELATIONSHIP_TYPE,
28703
- NUMBERING_PART_PATH
28704
- );
28705
- const parsedNumbering = numberingPartPath ? parseNumberingXml(
28706
- decodeUtf82(sourcePackage.parts.get(numberingPartPath)?.bytes ?? new Uint8Array()),
28707
- {
28708
- relationships: sourcePackage.parts.get(numberingPartPath)?.relationships,
28709
- partPath: numberingPartPath
28710
- }
28711
- ) : createEmptyNumberingCatalog();
28712
- const mediaParts = collectInlineMediaParts(sourcePackage);
28713
- const chartPartLookup = createChartPartLookup(
28714
- sourcePackage,
28715
- mainDocumentPath,
28716
- documentPart.relationships
28717
- );
28718
- if (options.telemetryBus) {
28719
- setActiveParseTelemetryBus(options.telemetryBus);
28720
- }
28721
- let parsedDocument;
28722
- try {
28723
- parsedDocument = parseMainDocumentXml(
28724
- sourceDocumentXml,
28725
- documentPart.relationships,
28726
- mediaParts,
28727
- mainDocumentPath,
28728
- chartPartLookup,
28729
- {
28730
- stripCosmeticMarkers: options.stripCosmeticMarkers !== false,
28731
- ...options.retainedBookmarkNames !== void 0 ? { retainedBookmarkNames: options.retainedBookmarkNames } : {}
28732
- }
28733
- );
28734
- } finally {
28735
- if (options.telemetryBus) setActiveParseTelemetryBus(void 0);
28736
- }
28737
- const protectionRanges = extractProtectionRanges(parsedDocument.blocks);
28738
- const normalizedDocument = normalizeParsedTextDocument(
28739
- parsedDocument,
28740
- mainDocumentPath
28741
- );
28742
- stages.emit("body");
28743
- const commentsPartPath = resolveCommentsPartPath(
28744
- sourcePackage,
28745
- mainDocumentPath,
28746
- documentPart.relationships
28747
- );
28748
- const commentsExtendedPartPath = resolveDocumentRelatedPartPath(
28749
- sourcePackage,
28750
- mainDocumentPath,
28751
- documentPart.relationships,
28752
- COMMENTS_EXTENDED_RELATIONSHIP_TYPE,
28753
- COMMENTS_EXTENDED_PART_PATH
28754
- );
28755
- const commentsIdsPartPath = resolveDocumentRelatedPartPath(
28756
- sourcePackage,
28757
- mainDocumentPath,
28758
- documentPart.relationships,
28759
- COMMENTS_IDS_RELATIONSHIP_TYPE,
28760
- COMMENTS_IDS_PART_PATH
28761
- );
28762
- const peoplePartPath = resolveDocumentRelatedPartPath(
28763
- sourcePackage,
28764
- mainDocumentPath,
28765
- documentPart.relationships,
28766
- PEOPLE_RELATIONSHIP_TYPE,
28767
- PEOPLE_PART_PATH
28768
- );
28769
- const parsedComments = commentsPartPath ? parseCommentsFromOoxml(
28770
- sourceDocumentXml,
28771
- {
28772
- commentsXml: decodeUtf82(sourcePackage.parts.get(commentsPartPath)?.bytes ?? new Uint8Array()),
28773
- commentsExtendedXml: decodeUtf82(
28774
- sourcePackage.parts.get(commentsExtendedPartPath ?? "")?.bytes ?? new Uint8Array()
28775
- ),
28776
- commentsIdsXml: decodeUtf82(
28777
- sourcePackage.parts.get(commentsIdsPartPath ?? "")?.bytes ?? new Uint8Array()
28778
- ),
28779
- peopleXml: decodeUtf82(
28780
- sourcePackage.parts.get(peoplePartPath ?? "")?.bytes ?? new Uint8Array()
28781
- )
28782
- }
28783
- ) : {
28784
- threads: [],
28785
- diagnostics: [],
28786
- definitions: [],
28787
- sourceRootTag: void 0,
28788
- sourceExtendedRootTag: void 0,
28789
- sourceIdsRootTag: void 0,
28790
- sourcePeopleRootTag: void 0,
28791
- peopleAuthors: []
28792
- };
28793
- const normalizedRevisions = normalizeImportedRevisionRecords(
28794
- importedRevisions,
28795
- normalizedDocument.content,
28796
- normalizedDocument.preservation.opaqueFragments
28797
- );
28798
- const normalizedComments = normalizeImportedCommentThreads(
28799
- parsedComments,
28800
- normalizedDocument.preservation.opaqueFragments,
28801
- normalizedRevisions.revisions
28802
- );
28803
- stages.emit("styles-numbering-comments");
28804
- const importedStoryRevisions = [];
28805
- const importedStoryRevisionDiagnostics = [];
28806
- const subPartOpaqueState = createSubPartOpaqueImportState(
28807
- normalizedDocument.preservation.opaqueFragments,
28808
- normalizedDocument.diagnostics.warnings
28809
- );
28810
- const headerFooterRefs = parseHeaderFooterReferences(sourceDocumentXml);
28811
- const parsedHeaders = [];
28812
- const parsedFooters = [];
28813
- const sourceHeaderPaths = [];
28814
- const sourceFooterPaths = [];
28815
- const seenSubPartKeys = /* @__PURE__ */ new Set();
28816
- for (const ref of headerFooterRefs) {
28817
- const dedupeKey = `${ref.kind}:${ref.variant}:${ref.relationshipId}`;
28818
- if (seenSubPartKeys.has(dedupeKey)) {
28819
- continue;
28820
- }
28821
- seenSubPartKeys.add(dedupeKey);
28822
- const relationship = documentPart.relationships.find(
28823
- (r) => r.id === ref.relationshipId && r.targetMode === "internal"
28824
- );
28825
- if (!relationship) {
28826
- continue;
28827
- }
28828
- const partPath = resolveRelationshipTarget(mainDocumentPath, relationship);
28829
- const part = sourcePackage.parts.get(partPath);
28830
- const partBytes = part?.bytes;
28831
- if (!partBytes) {
28832
- continue;
28833
- }
28834
- const xml = decodeUtf82(partBytes);
28835
- const subPartRelationships = part?.relationships ?? [];
28836
- const subPartChartPartLookup = createChartPartLookup(
28837
- sourcePackage,
28838
- partPath,
28839
- subPartRelationships
28840
- );
28841
- if (ref.kind === "header") {
28842
- const parsedHeaderRevisions = parseRevisionsFromStoryXml(xml);
28843
- const parsed = parseHeaderXml(xml, {
28844
- relationships: subPartRelationships,
28845
- mediaParts,
28846
- sourcePartPath: partPath,
28847
- chartPartLookup: subPartChartPartLookup
28848
- });
28849
- parsedHeaders.push({
28850
- variant: ref.variant,
28851
- partPath,
28852
- relationshipId: ref.relationshipId,
28853
- ...ref.sectionIndex !== void 0 ? { sectionIndex: ref.sectionIndex } : {},
28854
- blocks: normalizeSubPartOpaqueBlocks(
28855
- parsed.blocks,
28856
- normalizedDocument.preservation.opaqueFragments,
28857
- normalizedDocument.diagnostics.warnings,
28858
- partPath,
28859
- subPartOpaqueState
28860
- )
28861
- });
28862
- importedStoryRevisions.push(
28863
- ...parsedHeaderRevisions.revisions.map((revision) => ({
28864
- ...revision,
28865
- metadata: {
28866
- ...revision.metadata,
28867
- storyTarget: {
28868
- kind: "header",
28869
- relationshipId: ref.relationshipId,
28870
- variant: ref.variant,
28871
- ...ref.sectionIndex !== void 0 ? { sectionIndex: ref.sectionIndex } : {}
28872
- }
28873
- }
28874
- }))
28875
- );
28876
- importedStoryRevisionDiagnostics.push(...parsedHeaderRevisions.diagnostics);
28877
- sourceHeaderPaths.push({ partPath, relationshipId: ref.relationshipId });
28878
- } else {
28879
- const parsedFooterRevisions = parseRevisionsFromStoryXml(xml);
28880
- const parsed = parseFooterXml(xml, {
28881
- relationships: subPartRelationships,
28882
- mediaParts,
28883
- sourcePartPath: partPath,
28884
- chartPartLookup: subPartChartPartLookup
28885
- });
28886
- parsedFooters.push({
28887
- variant: ref.variant,
28888
- partPath,
28889
- relationshipId: ref.relationshipId,
28890
- ...ref.sectionIndex !== void 0 ? { sectionIndex: ref.sectionIndex } : {},
28891
- blocks: normalizeSubPartOpaqueBlocks(
28892
- parsed.blocks,
28893
- normalizedDocument.preservation.opaqueFragments,
28894
- normalizedDocument.diagnostics.warnings,
28895
- partPath,
28896
- subPartOpaqueState
28897
- )
28898
- });
28899
- importedStoryRevisions.push(
28900
- ...parsedFooterRevisions.revisions.map((revision) => ({
28901
- ...revision,
28902
- metadata: {
28903
- ...revision.metadata,
28904
- storyTarget: {
28905
- kind: "footer",
28906
- relationshipId: ref.relationshipId,
28907
- variant: ref.variant,
28908
- ...ref.sectionIndex !== void 0 ? { sectionIndex: ref.sectionIndex } : {}
28909
- }
28910
- }
28911
- }))
28912
- );
28913
- importedStoryRevisionDiagnostics.push(...parsedFooterRevisions.diagnostics);
28914
- sourceFooterPaths.push({ partPath, relationshipId: ref.relationshipId });
28915
- }
28916
- }
28917
- const footnotesPartPath = resolveDocumentRelatedPartPath(
28918
- sourcePackage,
28919
- mainDocumentPath,
28920
- documentPart.relationships,
28921
- FOOTNOTES_RELATIONSHIP_TYPE,
28922
- FOOTNOTES_PART_PATH
28923
- );
28924
- const footnotesRelationshipId = documentPart.relationships.find(
28925
- (r) => r.type === FOOTNOTES_RELATIONSHIP_TYPE && r.targetMode === "internal"
28926
- )?.id;
28927
- const endnotesPartPath = resolveDocumentRelatedPartPath(
28928
- sourcePackage,
28929
- mainDocumentPath,
28930
- documentPart.relationships,
28931
- ENDNOTES_RELATIONSHIP_TYPE,
28932
- ENDNOTES_PART_PATH
28933
- );
28934
- const endnotesRelationshipId = documentPart.relationships.find(
28935
- (r) => r.type === ENDNOTES_RELATIONSHIP_TYPE && r.targetMode === "internal"
28936
- )?.id;
28937
- let footnoteCollection;
28938
- if (footnotesPartPath) {
28939
- footnoteCollection = parseFootnotesXml(
28940
- decodeUtf82(sourcePackage.parts.get(footnotesPartPath)?.bytes ?? new Uint8Array())
28941
- );
28942
- normalizeFootnoteCollectionOpaqueBlocks(
28943
- footnoteCollection,
28944
- "footnote",
28945
- normalizedDocument.preservation.opaqueFragments,
28946
- normalizedDocument.diagnostics.warnings,
28947
- footnotesPartPath,
28948
- subPartOpaqueState
28949
- );
28950
- }
28951
- if (endnotesPartPath) {
28952
- footnoteCollection = parseEndnotesXml(
28953
- decodeUtf82(sourcePackage.parts.get(endnotesPartPath)?.bytes ?? new Uint8Array()),
28954
- footnoteCollection
28955
- );
28956
- normalizeFootnoteCollectionOpaqueBlocks(
28957
- footnoteCollection,
28958
- "endnote",
28959
- normalizedDocument.preservation.opaqueFragments,
28960
- normalizedDocument.diagnostics.warnings,
28961
- endnotesPartPath,
28962
- subPartOpaqueState
28963
- );
28964
- }
28965
- const themeRelationship = documentPart.relationships.find(
28966
- (r) => r.type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" && r.targetMode === "internal"
28967
- );
28968
- const themePartPath = themeRelationship ? resolveRelationshipTarget(mainDocumentPath, themeRelationship) : void 0;
28969
- const parsedTheme = themePartPath && sourcePackage.parts.has(themePartPath) ? parseThemeXml(
28970
- decodeUtf82(sourcePackage.parts.get(themePartPath)?.bytes ?? new Uint8Array())
28971
- ) : void 0;
28972
- const resolvedTheme = parsedTheme ? resolveTheme(parsedTheme) : void 0;
28973
- const settingsPartPath = resolveDocumentRelatedPartPath(
28974
- sourcePackage,
28975
- mainDocumentPath,
28976
- documentPart.relationships,
28977
- SETTINGS_RELATIONSHIP_TYPE,
28978
- SETTINGS_PART_PATH
28979
- );
28980
- const parsedSettings = settingsPartPath && sourcePackage.parts.has(settingsPartPath) ? parseSettingsXml(
28981
- decodeUtf82(sourcePackage.parts.get(settingsPartPath)?.bytes ?? new Uint8Array())
28982
- ) : void 0;
28983
- const canonicalTheme = parsedTheme !== void 0 ? materializeCanonicalTheme(
28984
- parsedTheme,
28985
- parsedSettings?.clrSchemeMapping ?? {}
28986
- ) : void 0;
28987
- const settingsXmlForProtection = settingsPartPath && sourcePackage.parts.has(settingsPartPath) ? decodeUtf82(sourcePackage.parts.get(settingsPartPath)?.bytes ?? new Uint8Array()) : "";
28988
- const documentProtection = extractDocumentProtection(settingsXmlForProtection);
28989
- const importedProtectionSnapshot = buildProtectionSnapshot(documentProtection, protectionRanges);
28990
- const stylesPartPath = resolveDocumentRelatedPartPath(
28991
- sourcePackage,
28992
- mainDocumentPath,
28993
- documentPart.relationships,
28994
- STYLES_RELATIONSHIP_TYPE,
28995
- STYLES_PART_PATH
28996
- );
28997
- const parsedStyles = stylesPartPath && sourcePackage.parts.has(stylesPartPath) ? parseStylesXml(
28998
- decodeUtf82(sourcePackage.parts.get(stylesPartPath)?.bytes ?? new Uint8Array())
28999
- ) : parseStylesXml("");
29000
- const fontTablePartPath = resolveDocumentRelatedPartPath(
29001
- sourcePackage,
29002
- mainDocumentPath,
29003
- documentPart.relationships,
29004
- FONT_TABLE_RELATIONSHIP_TYPE,
29005
- FONT_TABLE_PART_PATH
29006
- );
29007
- const parsedFontTable = fontTablePartPath && sourcePackage.parts.has(fontTablePartPath) ? parseFontTable(
29008
- decodeUtf82(sourcePackage.parts.get(fontTablePartPath)?.bytes ?? new Uint8Array())
29009
- ) : void 0;
29010
- const mergedMedia = mergeSecondaryStoryMediaCatalog(normalizedDocument.media, {
29011
- headers: parsedHeaders,
29012
- footers: parsedFooters,
29013
- footnoteCollection,
29014
- mediaParts
29015
- });
29016
- const subParts = parsedHeaders.length > 0 || parsedFooters.length > 0 || footnoteCollection !== void 0 || parsedTheme !== void 0 || normalizedDocument.finalSectionProperties !== void 0 || resolvedTheme !== void 0 || canonicalTheme !== void 0 || parsedSettings !== void 0 ? {
29017
- headers: parsedHeaders,
29018
- footers: parsedFooters,
29019
- ...footnoteCollection !== void 0 ? { footnoteCollection } : {},
29020
- ...parsedTheme !== void 0 ? { theme: parsedTheme } : {},
29021
- ...normalizedDocument.finalSectionProperties !== void 0 ? { finalSectionProperties: normalizedDocument.finalSectionProperties } : {},
29022
- ...resolvedTheme !== void 0 ? { resolvedTheme } : {},
29023
- ...canonicalTheme !== void 0 ? { canonicalTheme } : {},
29024
- ...parsedSettings !== void 0 ? { settings: parsedSettings } : {}
29025
- } : void 0;
29026
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
29027
- const canonicalTimestamp = deriveCanonicalImportTimestamp(packageMetadata);
29028
- const translatedWorkflowState = translateClmCommentsToWorkflow({
29029
- comments: normalizedComments.threads,
29030
- workflowOverlay: embeddedWorkflowOverlay,
29031
- workflowMetadata: embeddedWorkflowMetadata,
29032
- timestamp
29033
- });
29034
- const rehydratedOffloadSync = hydrateOffloadEntriesFromPayload(
29035
- embeddedWorkflowPayload?.editorState
29036
- );
29037
- const embeddedDocumentManifestsSync = collectEmbeddedDocuments(
29038
- sourcePackage,
29039
- mainDocumentPath
29040
- ).manifests;
29041
- const document2 = createImportedCanonicalDocument({
29042
- documentId: options.documentId,
29043
- timestamp: canonicalTimestamp,
29044
- numbering: parsedNumbering,
29045
- media: mergedMedia,
29046
- content: normalizedDocument.content,
29047
- subParts,
29048
- parsedStyles,
29049
- fontTable: parsedFontTable,
29050
- metadata: packageMetadata,
29051
- preservation: buildImportPreservation(normalizedDocument.preservation, sourcePackage, [
29052
- mainDocumentPath,
29053
- numberingPartPath,
29054
- commentsPartPath,
29055
- commentsExtendedPartPath,
29056
- commentsIdsPartPath,
29057
- peoplePartPath,
29058
- ...rehydratedOffloadSync.ownedPartPaths
29059
- ]),
29060
- diagnostics: {
29061
- warnings: [
29062
- ...createBrokenRelationshipWarnings(sourcePackage, mainDocumentPath),
29063
- ...normalizedDocument.diagnostics.warnings,
29064
- ...mapRevisionDiagnosticsToWarnings(normalizedRevisions.diagnostics),
29065
- ...mapStoryRevisionDiagnosticsToWarnings(importedStoryRevisionDiagnostics),
29066
- ...mapCommentDiagnosticsToWarnings(normalizedComments.diagnostics)
29067
- ],
29068
- errors: []
29069
- },
29070
- review: {
29071
- comments: toRuntimeCommentRecords(translatedWorkflowState.comments),
29072
- revisions: toRuntimeRevisionRecords([
29073
- ...normalizedRevisions.revisions,
29074
- ...importedStoryRevisions
29075
- ])
29076
- }
29077
- });
29078
- const compatibility = buildCompatibilityReport({
29079
- document: document2,
29080
- generatedAt: timestamp
29081
- });
29082
- const snapshot = createImportedSnapshot({
29083
- documentId: options.documentId,
29084
- editorBuild,
29085
- timestamp,
29086
- document: document2,
29087
- compatibility,
29088
- protectionSnapshot: importedProtectionSnapshot,
29089
- sourcePackage: createPersistedSourcePackage(sourceBytes, options.sourceLabel),
29090
- workflowOverlay: translatedWorkflowState.workflowOverlay,
29091
- workflowMetadata: translatedWorkflowState.workflowMetadata,
29092
- visibilityPolicies: embeddedWorkflowPayload?.visibilityPolicies,
29093
- markupModePolicy: embeddedWorkflowPayload?.markupModePolicy ?? void 0
29094
- });
29095
- const snapshotIssues = validatePersistedEditorSnapshot(snapshot);
29096
- if (snapshotIssues.length > 0) {
29097
- const firstIssue = snapshotIssues[0];
29098
- return createDiagnosticsSession(
29099
- options,
29100
- createValidationImportDiagnostics({
29101
- message: `DOCX import produced an invalid editor state during validation${firstIssue ? ` (${firstIssue.path}: ${firstIssue.message})` : "."}`,
29102
- source: "import",
29103
- details: {
29104
- issueCount: snapshotIssues.length,
29105
- firstIssuePath: firstIssue?.path
29106
- }
29107
- })
29108
- );
29109
- }
29110
- const initialSessionState = editorSessionStateFromPersistedSnapshot(snapshot);
29111
- const importedState = {
29112
- sourceBytes: new Uint8Array(sourceBytes),
29113
- sourcePackage,
29114
- sourceDocumentXml,
29115
- sourceDocumentPartPath: mainDocumentPath,
29116
- sourceDocumentRelationships: documentPart.relationships,
29117
- sourceDocumentAttributes: extractDocumentRootAttributes(sourceDocumentXml),
29118
- sourceNumberingPartPath: numberingPartPath,
29119
- sourceNumberingRelationshipId: documentPart.relationships.find(
29120
- (relationship) => relationship.type === NUMBERING_RELATIONSHIP_TYPE && relationship.targetMode === "internal"
29121
- )?.id,
29122
- sourceSettingsPartPath: settingsPartPath,
29123
- sourceSettingsXml: settingsXmlForProtection.length > 0 ? settingsXmlForProtection : void 0,
29124
- sourceCommentsPartPath: commentsPartPath,
29125
- sourceCommentsRelationshipId: documentPart.relationships.find(
29126
- (relationship) => relationship.type === COMMENTS_RELATIONSHIP_TYPE && relationship.targetMode === "internal"
29127
- )?.id,
29128
- sourceCommentsRootTag: normalizedComments.sourceRootTag,
29129
- sourceCommentsExtendedPartPath: commentsExtendedPartPath,
29130
- sourceCommentsExtendedRelationshipId: documentPart.relationships.find(
29131
- (relationship) => relationship.type === COMMENTS_EXTENDED_RELATIONSHIP_TYPE && relationship.targetMode === "internal"
29132
- )?.id,
29133
- sourceCommentsExtendedRootTag: normalizedComments.sourceExtendedRootTag,
29134
- sourceCommentsIdsPartPath: commentsIdsPartPath,
29135
- sourceCommentsIdsRelationshipId: documentPart.relationships.find(
29136
- (relationship) => relationship.type === COMMENTS_IDS_RELATIONSHIP_TYPE && relationship.targetMode === "internal"
29137
- )?.id,
29138
- sourceCommentsIdsRootTag: normalizedComments.sourceIdsRootTag,
29139
- sourcePeoplePartPath: peoplePartPath,
29140
- sourcePeopleRelationshipId: documentPart.relationships.find(
29141
- (relationship) => relationship.type === PEOPLE_RELATIONSHIP_TYPE && relationship.targetMode === "internal"
29142
- )?.id,
29143
- sourcePeopleRootTag: normalizedComments.sourcePeopleRootTag,
29144
- sourcePeopleAuthors: normalizedComments.peopleAuthors,
29145
- protectionSnapshot: buildProtectionSnapshot(documentProtection, protectionRanges),
29146
- preservedCommentDefinitions: normalizedComments.preservedDefinitions,
29147
- blockingCommentDiagnostics: normalizedComments.diagnostics.filter(
29148
- (diagnostic) => BLOCKING_COMMENT_DIAGNOSTIC_CODES.has(diagnostic.code)
29149
- ),
29150
- initialCanonicalSignature: serializeCanonicalDocumentForExport(document2),
29151
- initialNumberingSignature: serializeNumberingCatalogForExport(
29152
- document2.numbering
29153
- ),
29154
- sourceSubPartPaths: {
29155
- headers: sourceHeaderPaths,
29156
- footers: sourceFooterPaths,
29157
- footnotesPartPath,
29158
- footnotesRelationshipId,
29159
- endnotesPartPath,
29160
- endnotesRelationshipId,
29161
- themePartPath,
29162
- themeRelationshipId: themeRelationship?.id
29163
- },
29164
- embeddingOffloadEntries: rehydratedOffloadSync.entries,
29165
- ...options.hostAdapter !== void 0 ? { hostAdapter: options.hostAdapter } : {}
29166
- };
29167
- stages.emit("skeleton-ready");
29168
- return {
29169
- initialSessionState,
29170
- initialSnapshot: snapshot,
29171
- readOnly: false,
29172
- protectionSnapshot: importedProtectionSnapshot,
29173
- exportDocx: async (nextSessionState, exportOptions) => runStatefulExport(importedState, nextSessionState, exportOptions),
29174
- embeddedDocumentManifests: embeddedDocumentManifestsSync,
29175
- ...embeddedWorkflowPayload?.editorState ? { initialEditorStatePayload: embeddedWorkflowPayload.editorState } : {}
29176
- };
29177
- } catch (error) {
29178
- return createDiagnosticsSession(
29179
- options,
29180
- createImportDiagnosticsFromError(error)
29181
- );
29182
- }
29183
- }
29184
28579
  function deriveCanonicalImportTimestamp(metadata) {
29185
28580
  return firstNonEmptyString(metadata.createdUtc, metadata.modifiedUtc) ?? CANONICAL_IMPORT_TIMESTAMP;
29186
28581
  }
@@ -29473,6 +28868,5 @@ function isReopenBarrier(result) {
29473
28868
  SessionNotOpenError,
29474
28869
  SessionNotWiredError,
29475
28870
  isReopenBarrier,
29476
- loadDocxSessionAsync,
29477
- loadDocxSessionSync
28871
+ loadDocxSessionAsync
29478
28872
  });