oasis-editor 0.0.157 → 0.0.159

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.
@@ -2863,7 +2863,7 @@ function OasisEditorAppLazy(props = {}) {
2863
2863
  onCleanup(() => {
2864
2864
  cancelled = true;
2865
2865
  });
2866
- import("./OasisEditorApp-BfdBu3ui.js").then((m) => {
2866
+ import("./OasisEditorApp-DU_hHfTo.js").then((m) => {
2867
2867
  cancelled = true;
2868
2868
  setProgress(1);
2869
2869
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -38883,6 +38883,283 @@ function parseMathExpression(element) {
38883
38883
  sourceXml: serializer.serializeToString(element)
38884
38884
  };
38885
38885
  }
38886
+ const RECOGNIZED_SDT_PR_CHILDREN = /* @__PURE__ */ new Set([
38887
+ "alias",
38888
+ "tag",
38889
+ "id",
38890
+ "lock",
38891
+ "placeholder",
38892
+ "dataBinding",
38893
+ "temporary",
38894
+ "appearance",
38895
+ "showingPlcHdr",
38896
+ "color",
38897
+ "text",
38898
+ "richText",
38899
+ "picture",
38900
+ "comboBox",
38901
+ "dropDownList",
38902
+ "date",
38903
+ "repeatingSection",
38904
+ "repeatingSectionItem",
38905
+ "group",
38906
+ "equation",
38907
+ "citation",
38908
+ "bibliography"
38909
+ ]);
38910
+ function parseSdtPr(sdtPr) {
38911
+ if (!sdtPr) {
38912
+ return {};
38913
+ }
38914
+ const result = {};
38915
+ const aliasEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "alias");
38916
+ if (aliasEl) {
38917
+ const alias = getAttributeValue(aliasEl, "val");
38918
+ if (alias !== null) {
38919
+ result.alias = alias;
38920
+ }
38921
+ }
38922
+ const tagEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "tag");
38923
+ if (tagEl) {
38924
+ const tag = getAttributeValue(tagEl, "val");
38925
+ if (tag !== null) {
38926
+ result.tag = tag;
38927
+ }
38928
+ }
38929
+ const idEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "id");
38930
+ if (idEl) {
38931
+ const id = getAttributeValue(idEl, "val");
38932
+ if (id !== null) {
38933
+ result.id = id;
38934
+ }
38935
+ }
38936
+ const lockEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "lock");
38937
+ if (lockEl) {
38938
+ const lock = getAttributeValue(lockEl, "val");
38939
+ if (lock !== null) {
38940
+ result.lock = lock;
38941
+ }
38942
+ }
38943
+ const appearanceEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "appearance");
38944
+ if (appearanceEl) {
38945
+ const appearance = getAttributeValue(appearanceEl, "val");
38946
+ if (appearance !== null) {
38947
+ result.appearance = appearance;
38948
+ }
38949
+ }
38950
+ const showingPlcHdrEl = getFirstChildByTagNameNS(
38951
+ sdtPr,
38952
+ WORD_NS$3,
38953
+ "showingPlcHdr"
38954
+ );
38955
+ if (showingPlcHdrEl) {
38956
+ result.showingPlcHdr = isWordTrue(
38957
+ getAttributeValue(showingPlcHdrEl, "val")
38958
+ );
38959
+ }
38960
+ const temporaryEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "temporary");
38961
+ if (temporaryEl) {
38962
+ result.temporary = isWordTrue(getAttributeValue(temporaryEl, "val"));
38963
+ }
38964
+ const colorEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "color");
38965
+ if (colorEl) {
38966
+ const color = getAttributeValue(colorEl, "val");
38967
+ if (color !== null) {
38968
+ result.color = color;
38969
+ }
38970
+ }
38971
+ const placeholderEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "placeholder");
38972
+ if (placeholderEl) {
38973
+ const docPart = getFirstChildByTagNameNS(placeholderEl, WORD_NS$3, "docPart");
38974
+ if (docPart) {
38975
+ const docPartVal = getAttributeValue(docPart, "val");
38976
+ if (docPartVal !== null) {
38977
+ result.placeholderDocPart = docPartVal;
38978
+ }
38979
+ }
38980
+ }
38981
+ const dataBindingEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "dataBinding");
38982
+ if (dataBindingEl) {
38983
+ const dataBinding = parseSdtDataBinding(dataBindingEl);
38984
+ if (dataBinding) {
38985
+ result.dataBinding = dataBinding;
38986
+ }
38987
+ }
38988
+ const subtype = parseSdtSubtype(sdtPr);
38989
+ if (subtype) {
38990
+ result.subtype = subtype;
38991
+ }
38992
+ const unknownXml = serializeUnknownSdtPrChildren(sdtPr);
38993
+ if (unknownXml.length > 0) {
38994
+ result.unknownXml = unknownXml;
38995
+ }
38996
+ return result;
38997
+ }
38998
+ function parseSdtDataBinding(el) {
38999
+ const prefixMappingsEl = getFirstChildByTagNameNS(
39000
+ el,
39001
+ WORD_NS$3,
39002
+ "prefixMappings"
39003
+ );
39004
+ const xpathEl = getFirstChildByTagNameNS(el, WORD_NS$3, "xpath");
39005
+ const storeItemIDEl = getFirstChildByTagNameNS(el, WORD_NS$3, "storeItemID");
39006
+ const dataBinding = {};
39007
+ if (prefixMappingsEl) {
39008
+ const val = getAttributeValue(prefixMappingsEl, "val");
39009
+ if (val !== null) {
39010
+ dataBinding.prefixMappings = val;
39011
+ }
39012
+ }
39013
+ if (xpathEl) {
39014
+ const val = getAttributeValue(xpathEl, "val");
39015
+ if (val !== null) {
39016
+ dataBinding.xpath = val;
39017
+ }
39018
+ }
39019
+ if (storeItemIDEl) {
39020
+ const val = getAttributeValue(storeItemIDEl, "val");
39021
+ if (val !== null) {
39022
+ dataBinding.storeItemID = val;
39023
+ }
39024
+ }
39025
+ if (dataBinding.prefixMappings === void 0 && dataBinding.xpath === void 0 && dataBinding.storeItemID === void 0) {
39026
+ return null;
39027
+ }
39028
+ return dataBinding;
39029
+ }
39030
+ function parseSdtListItems(parent) {
39031
+ const items = getChildrenByTagNameNS(parent, WORD_NS$3, "listItem");
39032
+ if (items.length === 0) {
39033
+ return void 0;
39034
+ }
39035
+ return items.map(
39036
+ (item) => ({
39037
+ displayText: getAttributeValue(item, "displayText") ?? void 0,
39038
+ value: getAttributeValue(item, "value") ?? void 0
39039
+ })
39040
+ );
39041
+ }
39042
+ function parseSdtSubtype(parent) {
39043
+ const comboBoxEl = getFirstChildByTagNameNS(parent, WORD_NS$3, "comboBox");
39044
+ if (comboBoxEl) {
39045
+ const lastSelectedEl = getFirstChildByTagNameNS(
39046
+ comboBoxEl,
39047
+ WORD_NS$3,
39048
+ "lastSelectedValue"
39049
+ );
39050
+ return {
39051
+ kind: "comboBox",
39052
+ listItems: parseSdtListItems(comboBoxEl),
39053
+ ...lastSelectedEl ? {
39054
+ lastSelectedValue: getAttributeValue(lastSelectedEl, "val") ?? void 0
39055
+ } : {}
39056
+ };
39057
+ }
39058
+ const dropDownEl = getFirstChildByTagNameNS(parent, WORD_NS$3, "dropDownList");
39059
+ if (dropDownEl) {
39060
+ const lastSelectedEl = getFirstChildByTagNameNS(
39061
+ dropDownEl,
39062
+ WORD_NS$3,
39063
+ "lastSelectedValue"
39064
+ );
39065
+ return {
39066
+ kind: "dropDownList",
39067
+ listItems: parseSdtListItems(dropDownEl),
39068
+ ...lastSelectedEl ? {
39069
+ lastSelectedValue: getAttributeValue(lastSelectedEl, "val") ?? void 0
39070
+ } : {}
39071
+ };
39072
+ }
39073
+ const dateEl = getFirstChildByTagNameNS(parent, WORD_NS$3, "date");
39074
+ if (dateEl) {
39075
+ const fullDate = getAttributeValue(dateEl, "fullDate") ?? void 0;
39076
+ const dateFormatEl = getFirstChildByTagNameNS(
39077
+ dateEl,
39078
+ WORD_NS$3,
39079
+ "dateFormat"
39080
+ );
39081
+ const lidEl = getFirstChildByTagNameNS(dateEl, WORD_NS$3, "lid");
39082
+ const calendarEl = getFirstChildByTagNameNS(dateEl, WORD_NS$3, "calendar");
39083
+ const storeMappedDataAsEl = getFirstChildByTagNameNS(
39084
+ dateEl,
39085
+ WORD_NS$3,
39086
+ "storeMappedDataAs"
39087
+ );
39088
+ return {
39089
+ kind: "date",
39090
+ fullDate,
39091
+ dateFormat: dateFormatEl ? getAttributeValue(dateFormatEl, "val") ?? void 0 : void 0,
39092
+ lid: lidEl ? getAttributeValue(lidEl, "val") ?? void 0 : void 0,
39093
+ calendar: calendarEl ? getAttributeValue(calendarEl, "val") ?? void 0 : void 0,
39094
+ storeMappedDataAs: storeMappedDataAsEl ? getAttributeValue(storeMappedDataAsEl, "val") ?? void 0 : void 0
39095
+ };
39096
+ }
39097
+ const textEl = getFirstChildByTagNameNS(parent, WORD_NS$3, "text");
39098
+ if (textEl) {
39099
+ return { kind: "text" };
39100
+ }
39101
+ for (const kind of [
39102
+ "richText",
39103
+ "picture",
39104
+ "group",
39105
+ "equation",
39106
+ "citation",
39107
+ "bibliography",
39108
+ "repeatingSection",
39109
+ "repeatingSectionItem"
39110
+ ]) {
39111
+ if (getFirstChildByTagNameNS(parent, WORD_NS$3, kind)) {
39112
+ return { kind };
39113
+ }
39114
+ }
39115
+ const w14CheckboxEl = getFirstW14Child(parent, "checkbox");
39116
+ if (w14CheckboxEl) {
39117
+ const checkedEl = getFirstChildByTagNameNS(
39118
+ w14CheckboxEl,
39119
+ WORD14_NS$1,
39120
+ "checked"
39121
+ );
39122
+ const checkedStateEl = getFirstChildByTagNameNS(
39123
+ w14CheckboxEl,
39124
+ WORD14_NS$1,
39125
+ "checkedState"
39126
+ );
39127
+ const uncheckedStateEl = getFirstChildByTagNameNS(
39128
+ w14CheckboxEl,
39129
+ WORD14_NS$1,
39130
+ "uncheckedState"
39131
+ );
39132
+ const checked = checkedEl ? isWordTrue(getAttributeValue(checkedEl, "val")) : void 0;
39133
+ return {
39134
+ kind: "checkbox",
39135
+ ...checked !== void 0 ? { checked } : {},
39136
+ ...checkedStateEl ? {
39137
+ checkedStateFont: getAttributeValue(checkedStateEl, "font") ?? void 0,
39138
+ checkedStateChar: getAttributeValue(checkedStateEl, "char") ?? void 0
39139
+ } : {},
39140
+ ...uncheckedStateEl ? {
39141
+ uncheckedStateFont: getAttributeValue(uncheckedStateEl, "font") ?? void 0,
39142
+ uncheckedStateChar: getAttributeValue(uncheckedStateEl, "char") ?? void 0
39143
+ } : {}
39144
+ };
39145
+ }
39146
+ return void 0;
39147
+ }
39148
+ function serializeUnknownSdtPrChildren(sdtPr) {
39149
+ let out = "";
39150
+ for (let i = 0; i < sdtPr.childNodes.length; i += 1) {
39151
+ const node = sdtPr.childNodes[i];
39152
+ if ((node == null ? void 0 : node.nodeType) !== node.ELEMENT_NODE) {
39153
+ continue;
39154
+ }
39155
+ const el = node;
39156
+ if (el.localName && el.namespaceURI === WORD_NS$3 && RECOGNIZED_SDT_PR_CHILDREN.has(el.localName)) {
39157
+ continue;
39158
+ }
39159
+ out += new XMLSerializer().serializeToString(el);
39160
+ }
39161
+ return out;
39162
+ }
38886
39163
  const VML_FRACTION_DENOMINATOR = 65536;
38887
39164
  function emuToPx(value2) {
38888
39165
  const emu = parseOptionalInt(value2);
@@ -39669,6 +39946,36 @@ async function parseRunsContainer(container, numberingMaps, zip, relsMap, assets
39669
39946
  runs.push({ text: "", comment: marker });
39670
39947
  continue;
39671
39948
  }
39949
+ if (element.localName === "sdt") {
39950
+ const sdtContent = getFirstChildByTagNameNS(element, WORD_NS$3, "sdtContent");
39951
+ if (!sdtContent) {
39952
+ continue;
39953
+ }
39954
+ const sdtPr = getFirstChildByTagNameNS(element, WORD_NS$3, "sdtPr");
39955
+ const sdtEndPr = getFirstChildByTagNameNS(element, WORD_NS$3, "sdtEndPr");
39956
+ const wrapper = {
39957
+ groupId: createEditorNodeId("sdt"),
39958
+ sdtPr: parseSdtPr(sdtPr),
39959
+ ...sdtEndPr ? { sdtEndPrXml: new XMLSerializer().serializeToString(sdtEndPr) } : {}
39960
+ };
39961
+ const nestedRuns = await parseRunsContainer(
39962
+ sdtContent,
39963
+ numberingMaps,
39964
+ zip,
39965
+ relsMap,
39966
+ assets,
39967
+ theme,
39968
+ inheritedLink,
39969
+ parseNestedBlocks
39970
+ );
39971
+ for (const nestedRun of nestedRuns) {
39972
+ runs.push({
39973
+ ...nestedRun,
39974
+ sdtWrappers: [wrapper, ...nestedRun.sdtWrappers ?? []]
39975
+ });
39976
+ }
39977
+ continue;
39978
+ }
39672
39979
  if (element.localName === "r") {
39673
39980
  const runStyles = parseRunStyle(
39674
39981
  getFirstChildByTagNameNS(element, WORD_NS$3, "rPr"),
@@ -39917,7 +40224,7 @@ function stableSemanticString(value2) {
39917
40224
  function hasRelationshipReference$4(xml) {
39918
40225
  return /\br:(?:id|embed|link)\s*=/.test(xml);
39919
40226
  }
39920
- function directWordChildren$1(element, localName) {
40227
+ function directWordChildren$2(element, localName) {
39921
40228
  const children2 = [];
39922
40229
  for (let index = 0; index < element.childNodes.length; index += 1) {
39923
40230
  const child2 = element.childNodes[index];
@@ -39928,7 +40235,7 @@ function directWordChildren$1(element, localName) {
39928
40235
  return children2;
39929
40236
  }
39930
40237
  function firstDirectWordChild$1(element, localName) {
39931
- return directWordChildren$1(element, localName)[0];
40238
+ return directWordChildren$2(element, localName)[0];
39932
40239
  }
39933
40240
  function serializeElement$1(element) {
39934
40241
  return element ? new XMLSerializer().serializeToString(element) : void 0;
@@ -40078,7 +40385,7 @@ function captureGranularTableSources(table, tableElement) {
40078
40385
  const tableGridXml = serializeElement$1(
40079
40386
  firstDirectWordChild$1(tableElement, "tblGrid")
40080
40387
  );
40081
- const rowElements = directWordChildren$1(tableElement, "tr");
40388
+ const rowElements = directWordChildren$2(tableElement, "tr");
40082
40389
  if (rowElements.length === table.rows.length) {
40083
40390
  rowElements.forEach((rowElement, rowIndex) => {
40084
40391
  const row = table.rows[rowIndex];
@@ -40090,7 +40397,7 @@ function captureGranularTableSources(table, tableElement) {
40090
40397
  firstDirectWordChild$1(rowElement, "tblPrEx")
40091
40398
  )
40092
40399
  });
40093
- const cellElements = directWordChildren$1(rowElement, "tc");
40400
+ const cellElements = directWordChildren$2(rowElement, "tc");
40094
40401
  if (cellElements.length !== row.cells.length) {
40095
40402
  return;
40096
40403
  }
@@ -40209,6 +40516,7 @@ function captureImportedParagraphSource(paragraphNode, paragraphProperties, impo
40209
40516
  };
40210
40517
  }
40211
40518
  function importedRunToEditorRun(run) {
40519
+ var _a2;
40212
40520
  const base = {
40213
40521
  id: createEditorNodeId("run"),
40214
40522
  text: run.text
@@ -40216,6 +40524,9 @@ function importedRunToEditorRun(run) {
40216
40524
  if (run.styles) {
40217
40525
  base.styles = { ...run.styles };
40218
40526
  }
40527
+ if ((_a2 = run.sdtWrappers) == null ? void 0 : _a2.length) {
40528
+ base.sdtWrappers = [...run.sdtWrappers];
40529
+ }
40219
40530
  let editorRun;
40220
40531
  if (run.fieldChar) {
40221
40532
  editorRun = { ...base, kind: "fieldChar", fieldChar: { ...run.fieldChar } };
@@ -40260,19 +40571,14 @@ function importedRunToEditorRun(run) {
40260
40571
  }
40261
40572
  function createImportedParagraph(runs, paragraphStyle, list, markRunStyle, source) {
40262
40573
  var _a2, _b2;
40263
- const editorRuns = runs.length > 0 ? runs.map(importedRunToEditorRun) : (
40264
- // An empty paragraph still carries the formatting of its paragraph mark
40265
- // (`w:pPr/w:rPr`), which Word uses to render the blank line's font/size.
40266
- // Apply it so empty lines match Word instead of falling back to defaults.
40267
- [
40268
- {
40269
- id: createEditorNodeId("run"),
40270
- text: "",
40271
- kind: "text",
40272
- ...markRunStyle ? { styles: { ...markRunStyle } } : {}
40273
- }
40274
- ]
40275
- );
40574
+ const editorRuns = runs.length > 0 ? runs.map(importedRunToEditorRun) : [
40575
+ {
40576
+ id: createEditorNodeId("run"),
40577
+ text: "",
40578
+ kind: "text",
40579
+ ...markRunStyle ? { styles: { ...markRunStyle } } : {}
40580
+ }
40581
+ ];
40276
40582
  const paragraph = {
40277
40583
  id: createEditorNodeId("paragraph"),
40278
40584
  type: "paragraph",
@@ -40442,6 +40748,45 @@ function parseTableLook(tblPr) {
40442
40748
  noVBand: attr2("noVBand") ?? bit(1024) ?? false
40443
40749
  };
40444
40750
  }
40751
+ function collectSdtWrappedWordChildrenImpl(container, localName, inheritedWrappers, result) {
40752
+ for (const child2 of getMarkupCompatibleChildren(container)) {
40753
+ if (child2.namespaceURI !== WORD_NS$3) {
40754
+ continue;
40755
+ }
40756
+ if (child2.localName === localName) {
40757
+ result.push({
40758
+ element: child2,
40759
+ ...inheritedWrappers.length > 0 ? { sdtWrappers: inheritedWrappers } : {}
40760
+ });
40761
+ continue;
40762
+ }
40763
+ if (child2.localName !== "sdt") {
40764
+ continue;
40765
+ }
40766
+ const content2 = getFirstChildByTagNameNS(child2, WORD_NS$3, "sdtContent");
40767
+ if (!content2) {
40768
+ continue;
40769
+ }
40770
+ const properties = getFirstChildByTagNameNS(child2, WORD_NS$3, "sdtPr");
40771
+ const endProperties = getFirstChildByTagNameNS(child2, WORD_NS$3, "sdtEndPr");
40772
+ const wrapper = {
40773
+ groupId: createEditorNodeId("sdt"),
40774
+ sdtPr: parseSdtPr(properties),
40775
+ ...endProperties ? { sdtEndPrXml: new XMLSerializer().serializeToString(endProperties) } : {}
40776
+ };
40777
+ collectSdtWrappedWordChildrenImpl(
40778
+ content2,
40779
+ localName,
40780
+ [...inheritedWrappers, wrapper],
40781
+ result
40782
+ );
40783
+ }
40784
+ }
40785
+ function collectSdtWrappedWordChildren(container, localName) {
40786
+ const result = [];
40787
+ collectSdtWrappedWordChildrenImpl(container, localName, [], result);
40788
+ return result;
40789
+ }
40445
40790
  function collapseCellAutospacing(paragraphs, flags) {
40446
40791
  var _a2, _b2;
40447
40792
  const styleOf = (paragraph) => paragraph.style ?? (paragraph.style = {});
@@ -40487,6 +40832,7 @@ function applyCellParagraphAutospacing(cellNode, blocks) {
40487
40832
  );
40488
40833
  }
40489
40834
  async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, theme, parseNestedBlocks, _styles) {
40835
+ var _a2, _b2;
40490
40836
  const gridCols = [];
40491
40837
  const tblGrid = getFirstChildByTagNameNS(tableNode, WORD_NS$3, "tblGrid");
40492
40838
  if (tblGrid) {
@@ -40510,16 +40856,18 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
40510
40856
  );
40511
40857
  const directTableStyle = parseTableStyle(tblPr, tableStyleId ?? void 0);
40512
40858
  const look = parseTableLook(tblPr);
40513
- const rowNodes = getChildrenByTagNameNS(tableNode, WORD_NS$3, "tr");
40859
+ const rowEntries = collectSdtWrappedWordChildren(tableNode, "tr");
40514
40860
  const rows = [];
40515
- for (let rowIndex = 0; rowIndex < rowNodes.length; rowIndex += 1) {
40516
- const rowNode = rowNodes[rowIndex];
40861
+ for (let rowIndex = 0; rowIndex < rowEntries.length; rowIndex += 1) {
40862
+ const rowEntry = rowEntries[rowIndex];
40863
+ const rowNode = rowEntry.element;
40517
40864
  const rowProperties = getFirstChildByTagNameNS(rowNode, WORD_NS$3, "trPr");
40518
40865
  const rowConditionalStyle = parseTableConditionalFlags(rowProperties);
40519
- const cellNodes = getChildrenByTagNameNS(rowNode, WORD_NS$3, "tc");
40866
+ const cellEntries = collectSdtWrappedWordChildren(rowNode, "tc");
40520
40867
  const cells = [];
40521
- for (let colIndex = 0; colIndex < cellNodes.length; colIndex += 1) {
40522
- const cellNode = cellNodes[colIndex];
40868
+ for (let colIndex = 0; colIndex < cellEntries.length; colIndex += 1) {
40869
+ const cellEntry = cellEntries[colIndex];
40870
+ const cellNode = cellEntry.element;
40523
40871
  const cellProperties = getFirstChildByTagNameNS(
40524
40872
  cellNode,
40525
40873
  WORD_NS$3,
@@ -40547,6 +40895,9 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
40547
40895
  );
40548
40896
  if (cellStyle) cell.style = cellStyle;
40549
40897
  cell.conditionalStyle = parseTableConditionalFlags(cellProperties);
40898
+ if ((_a2 = cellEntry.sdtWrappers) == null ? void 0 : _a2.length) {
40899
+ cell.sdtWrappers = [...cellEntry.sdtWrappers];
40900
+ }
40550
40901
  const cellExtAttrs = collectExtAttributes(cellNode);
40551
40902
  if (cellExtAttrs) cell.extAttributes = cellExtAttrs;
40552
40903
  if (vMerge === "continue") {
@@ -40563,6 +40914,9 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
40563
40914
  row.style = rowStyle;
40564
40915
  }
40565
40916
  row.conditionalStyle = rowConditionalStyle;
40917
+ if ((_b2 = rowEntry.sdtWrappers) == null ? void 0 : _b2.length) {
40918
+ row.sdtWrappers = [...rowEntry.sdtWrappers];
40919
+ }
40566
40920
  const rowExtAttrs = collectExtAttributes(rowNode);
40567
40921
  if (rowExtAttrs) row.extAttributes = rowExtAttrs;
40568
40922
  const tblPrEx = getFirstChildByTagNameNS(rowNode, WORD_NS$3, "tblPrEx");
@@ -40639,283 +40993,6 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
40639
40993
  );
40640
40994
  return table;
40641
40995
  }
40642
- const RECOGNIZED_SDT_PR_CHILDREN = /* @__PURE__ */ new Set([
40643
- "alias",
40644
- "tag",
40645
- "id",
40646
- "lock",
40647
- "placeholder",
40648
- "dataBinding",
40649
- "temporary",
40650
- "appearance",
40651
- "showingPlcHdr",
40652
- "color",
40653
- "text",
40654
- "richText",
40655
- "picture",
40656
- "comboBox",
40657
- "dropDownList",
40658
- "date",
40659
- "repeatingSection",
40660
- "repeatingSectionItem",
40661
- "group",
40662
- "equation",
40663
- "citation",
40664
- "bibliography"
40665
- ]);
40666
- function parseSdtPr(sdtPr) {
40667
- if (!sdtPr) {
40668
- return {};
40669
- }
40670
- const result = {};
40671
- const aliasEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "alias");
40672
- if (aliasEl) {
40673
- const alias = getAttributeValue(aliasEl, "val");
40674
- if (alias !== null) {
40675
- result.alias = alias;
40676
- }
40677
- }
40678
- const tagEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "tag");
40679
- if (tagEl) {
40680
- const tag = getAttributeValue(tagEl, "val");
40681
- if (tag !== null) {
40682
- result.tag = tag;
40683
- }
40684
- }
40685
- const idEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "id");
40686
- if (idEl) {
40687
- const id = getAttributeValue(idEl, "val");
40688
- if (id !== null) {
40689
- result.id = id;
40690
- }
40691
- }
40692
- const lockEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "lock");
40693
- if (lockEl) {
40694
- const lock = getAttributeValue(lockEl, "val");
40695
- if (lock !== null) {
40696
- result.lock = lock;
40697
- }
40698
- }
40699
- const appearanceEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "appearance");
40700
- if (appearanceEl) {
40701
- const appearance = getAttributeValue(appearanceEl, "val");
40702
- if (appearance !== null) {
40703
- result.appearance = appearance;
40704
- }
40705
- }
40706
- const showingPlcHdrEl = getFirstChildByTagNameNS(
40707
- sdtPr,
40708
- WORD_NS$3,
40709
- "showingPlcHdr"
40710
- );
40711
- if (showingPlcHdrEl) {
40712
- result.showingPlcHdr = isWordTrue(
40713
- getAttributeValue(showingPlcHdrEl, "val")
40714
- );
40715
- }
40716
- const temporaryEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "temporary");
40717
- if (temporaryEl) {
40718
- result.temporary = isWordTrue(getAttributeValue(temporaryEl, "val"));
40719
- }
40720
- const colorEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "color");
40721
- if (colorEl) {
40722
- const color = getAttributeValue(colorEl, "val");
40723
- if (color !== null) {
40724
- result.color = color;
40725
- }
40726
- }
40727
- const placeholderEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "placeholder");
40728
- if (placeholderEl) {
40729
- const docPart = getFirstChildByTagNameNS(placeholderEl, WORD_NS$3, "docPart");
40730
- if (docPart) {
40731
- const docPartVal = getAttributeValue(docPart, "val");
40732
- if (docPartVal !== null) {
40733
- result.placeholderDocPart = docPartVal;
40734
- }
40735
- }
40736
- }
40737
- const dataBindingEl = getFirstChildByTagNameNS(sdtPr, WORD_NS$3, "dataBinding");
40738
- if (dataBindingEl) {
40739
- const dataBinding = parseSdtDataBinding(dataBindingEl);
40740
- if (dataBinding) {
40741
- result.dataBinding = dataBinding;
40742
- }
40743
- }
40744
- const subtype = parseSdtSubtype(sdtPr);
40745
- if (subtype) {
40746
- result.subtype = subtype;
40747
- }
40748
- const unknownXml = serializeUnknownSdtPrChildren(sdtPr);
40749
- if (unknownXml.length > 0) {
40750
- result.unknownXml = unknownXml;
40751
- }
40752
- return result;
40753
- }
40754
- function parseSdtDataBinding(el) {
40755
- const prefixMappingsEl = getFirstChildByTagNameNS(
40756
- el,
40757
- WORD_NS$3,
40758
- "prefixMappings"
40759
- );
40760
- const xpathEl = getFirstChildByTagNameNS(el, WORD_NS$3, "xpath");
40761
- const storeItemIDEl = getFirstChildByTagNameNS(el, WORD_NS$3, "storeItemID");
40762
- const dataBinding = {};
40763
- if (prefixMappingsEl) {
40764
- const val = getAttributeValue(prefixMappingsEl, "val");
40765
- if (val !== null) {
40766
- dataBinding.prefixMappings = val;
40767
- }
40768
- }
40769
- if (xpathEl) {
40770
- const val = getAttributeValue(xpathEl, "val");
40771
- if (val !== null) {
40772
- dataBinding.xpath = val;
40773
- }
40774
- }
40775
- if (storeItemIDEl) {
40776
- const val = getAttributeValue(storeItemIDEl, "val");
40777
- if (val !== null) {
40778
- dataBinding.storeItemID = val;
40779
- }
40780
- }
40781
- if (dataBinding.prefixMappings === void 0 && dataBinding.xpath === void 0 && dataBinding.storeItemID === void 0) {
40782
- return null;
40783
- }
40784
- return dataBinding;
40785
- }
40786
- function parseSdtListItems(parent) {
40787
- const items = getChildrenByTagNameNS(parent, WORD_NS$3, "listItem");
40788
- if (items.length === 0) {
40789
- return void 0;
40790
- }
40791
- return items.map(
40792
- (item) => ({
40793
- displayText: getAttributeValue(item, "displayText") ?? void 0,
40794
- value: getAttributeValue(item, "value") ?? void 0
40795
- })
40796
- );
40797
- }
40798
- function parseSdtSubtype(parent) {
40799
- const comboBoxEl = getFirstChildByTagNameNS(parent, WORD_NS$3, "comboBox");
40800
- if (comboBoxEl) {
40801
- const lastSelectedEl = getFirstChildByTagNameNS(
40802
- comboBoxEl,
40803
- WORD_NS$3,
40804
- "lastSelectedValue"
40805
- );
40806
- return {
40807
- kind: "comboBox",
40808
- listItems: parseSdtListItems(comboBoxEl),
40809
- ...lastSelectedEl ? {
40810
- lastSelectedValue: getAttributeValue(lastSelectedEl, "val") ?? void 0
40811
- } : {}
40812
- };
40813
- }
40814
- const dropDownEl = getFirstChildByTagNameNS(parent, WORD_NS$3, "dropDownList");
40815
- if (dropDownEl) {
40816
- const lastSelectedEl = getFirstChildByTagNameNS(
40817
- dropDownEl,
40818
- WORD_NS$3,
40819
- "lastSelectedValue"
40820
- );
40821
- return {
40822
- kind: "dropDownList",
40823
- listItems: parseSdtListItems(dropDownEl),
40824
- ...lastSelectedEl ? {
40825
- lastSelectedValue: getAttributeValue(lastSelectedEl, "val") ?? void 0
40826
- } : {}
40827
- };
40828
- }
40829
- const dateEl = getFirstChildByTagNameNS(parent, WORD_NS$3, "date");
40830
- if (dateEl) {
40831
- const fullDate = getAttributeValue(dateEl, "fullDate") ?? void 0;
40832
- const dateFormatEl = getFirstChildByTagNameNS(
40833
- dateEl,
40834
- WORD_NS$3,
40835
- "dateFormat"
40836
- );
40837
- const lidEl = getFirstChildByTagNameNS(dateEl, WORD_NS$3, "lid");
40838
- const calendarEl = getFirstChildByTagNameNS(dateEl, WORD_NS$3, "calendar");
40839
- const storeMappedDataAsEl = getFirstChildByTagNameNS(
40840
- dateEl,
40841
- WORD_NS$3,
40842
- "storeMappedDataAs"
40843
- );
40844
- return {
40845
- kind: "date",
40846
- fullDate,
40847
- dateFormat: dateFormatEl ? getAttributeValue(dateFormatEl, "val") ?? void 0 : void 0,
40848
- lid: lidEl ? getAttributeValue(lidEl, "val") ?? void 0 : void 0,
40849
- calendar: calendarEl ? getAttributeValue(calendarEl, "val") ?? void 0 : void 0,
40850
- storeMappedDataAs: storeMappedDataAsEl ? getAttributeValue(storeMappedDataAsEl, "val") ?? void 0 : void 0
40851
- };
40852
- }
40853
- const textEl = getFirstChildByTagNameNS(parent, WORD_NS$3, "text");
40854
- if (textEl) {
40855
- return { kind: "text" };
40856
- }
40857
- for (const kind of [
40858
- "richText",
40859
- "picture",
40860
- "group",
40861
- "equation",
40862
- "citation",
40863
- "bibliography",
40864
- "repeatingSection",
40865
- "repeatingSectionItem"
40866
- ]) {
40867
- if (getFirstChildByTagNameNS(parent, WORD_NS$3, kind)) {
40868
- return { kind };
40869
- }
40870
- }
40871
- const w14CheckboxEl = getFirstW14Child(parent, "checkbox");
40872
- if (w14CheckboxEl) {
40873
- const checkedEl = getFirstChildByTagNameNS(
40874
- w14CheckboxEl,
40875
- WORD14_NS$1,
40876
- "checked"
40877
- );
40878
- const checkedStateEl = getFirstChildByTagNameNS(
40879
- w14CheckboxEl,
40880
- WORD14_NS$1,
40881
- "checkedState"
40882
- );
40883
- const uncheckedStateEl = getFirstChildByTagNameNS(
40884
- w14CheckboxEl,
40885
- WORD14_NS$1,
40886
- "uncheckedState"
40887
- );
40888
- const checked = checkedEl ? isWordTrue(getAttributeValue(checkedEl, "val")) : void 0;
40889
- return {
40890
- kind: "checkbox",
40891
- ...checked !== void 0 ? { checked } : {},
40892
- ...checkedStateEl ? {
40893
- checkedStateFont: getAttributeValue(checkedStateEl, "font") ?? void 0,
40894
- checkedStateChar: getAttributeValue(checkedStateEl, "char") ?? void 0
40895
- } : {},
40896
- ...uncheckedStateEl ? {
40897
- uncheckedStateFont: getAttributeValue(uncheckedStateEl, "font") ?? void 0,
40898
- uncheckedStateChar: getAttributeValue(uncheckedStateEl, "char") ?? void 0
40899
- } : {}
40900
- };
40901
- }
40902
- return void 0;
40903
- }
40904
- function serializeUnknownSdtPrChildren(sdtPr) {
40905
- let out = "";
40906
- for (let i = 0; i < sdtPr.childNodes.length; i += 1) {
40907
- const node = sdtPr.childNodes[i];
40908
- if ((node == null ? void 0 : node.nodeType) !== node.ELEMENT_NODE) {
40909
- continue;
40910
- }
40911
- const el = node;
40912
- if (el.localName && el.namespaceURI === WORD_NS$3 && RECOGNIZED_SDT_PR_CHILDREN.has(el.localName)) {
40913
- continue;
40914
- }
40915
- out += new XMLSerializer().serializeToString(el);
40916
- }
40917
- return out;
40918
- }
40919
40996
  async function parseBlockLevelChild(element, numberingMaps, zip, relsMap, assets, theme, parseNestedBlocks) {
40920
40997
  if (element.namespaceURI !== WORD_NS$3) {
40921
40998
  return [];
@@ -42923,6 +43000,240 @@ function serializeTableXml(table, serializeBlockXml) {
42923
43000
  ).join("")}</w:tblGrid></w:tblGridChange>` : ""}</w:tblGrid>` : "";
42924
43001
  return `<w:tbl>${serializeTableProperties(table)}${gridXml}${rowsXml}</w:tbl>`;
42925
43002
  }
43003
+ function serializeSdtPrXml(sdtPr) {
43004
+ const hasAnyField = sdtPr.alias !== void 0 || sdtPr.tag !== void 0 || sdtPr.id !== void 0 || sdtPr.lock !== void 0 || sdtPr.appearance !== void 0 || sdtPr.showingPlcHdr !== void 0 || sdtPr.temporary !== void 0 || sdtPr.color !== void 0 || sdtPr.placeholderDocPart !== void 0 || sdtPr.dataBinding !== void 0 || sdtPr.subtype !== void 0 || (sdtPr.unknownXml ?? "").length > 0;
43005
+ if (!hasAnyField) {
43006
+ return "<w:sdtPr/>";
43007
+ }
43008
+ let inner = "";
43009
+ if (sdtPr.alias !== void 0) {
43010
+ inner += `<w:alias w:val="${escapeXml(sdtPr.alias)}"/>`;
43011
+ }
43012
+ if (sdtPr.tag !== void 0) {
43013
+ inner += `<w:tag w:val="${escapeXml(sdtPr.tag)}"/>`;
43014
+ }
43015
+ if (sdtPr.id !== void 0) {
43016
+ inner += `<w:id w:val="${escapeXml(sdtPr.id)}"/>`;
43017
+ }
43018
+ if (sdtPr.lock !== void 0) {
43019
+ inner += `<w:lock w:val="${escapeXml(sdtPr.lock)}"/>`;
43020
+ }
43021
+ if (sdtPr.placeholderDocPart !== void 0) {
43022
+ inner += `<w:placeholder><w:docPart w:val="${escapeXml(
43023
+ sdtPr.placeholderDocPart
43024
+ )}"/></w:placeholder>`;
43025
+ }
43026
+ if (sdtPr.dataBinding !== void 0) {
43027
+ inner += serializeSdtDataBindingXml(sdtPr.dataBinding);
43028
+ }
43029
+ if (sdtPr.temporary !== void 0) {
43030
+ inner += `<w:temporary w:val="${sdtPr.temporary ? "true" : "false"}"/>`;
43031
+ }
43032
+ if (sdtPr.subtype !== void 0) {
43033
+ inner += serializeSdtSubtypeXml(sdtPr.subtype);
43034
+ }
43035
+ if (sdtPr.appearance !== void 0) {
43036
+ inner += `<w:appearance w:val="${escapeXml(sdtPr.appearance)}"/>`;
43037
+ }
43038
+ if (sdtPr.showingPlcHdr !== void 0) {
43039
+ inner += `<w:showingPlcHdr w:val="${sdtPr.showingPlcHdr ? "true" : "false"}"/>`;
43040
+ }
43041
+ if (sdtPr.color !== void 0) {
43042
+ inner += `<w:color w:val="${escapeXml(sdtPr.color)}"/>`;
43043
+ }
43044
+ if (sdtPr.unknownXml) {
43045
+ inner += sdtPr.unknownXml;
43046
+ }
43047
+ return `<w:sdtPr>${inner}</w:sdtPr>`;
43048
+ }
43049
+ function serializeSdtDataBindingXml(dataBinding) {
43050
+ let inner = "";
43051
+ if (dataBinding.prefixMappings !== void 0) {
43052
+ inner += `<w:prefixMappings w:val="${escapeXml(
43053
+ dataBinding.prefixMappings
43054
+ )}"/>`;
43055
+ }
43056
+ if (dataBinding.xpath !== void 0) {
43057
+ inner += `<w:xpath w:val="${escapeXml(dataBinding.xpath)}"/>`;
43058
+ }
43059
+ if (dataBinding.storeItemID !== void 0) {
43060
+ inner += `<w:storeItemID w:val="${escapeXml(dataBinding.storeItemID)}"/>`;
43061
+ }
43062
+ return inner ? `<w:dataBinding>${inner}</w:dataBinding>` : "";
43063
+ }
43064
+ function serializeSdtListItemXml(item) {
43065
+ const displayTextAttr = item.displayText !== void 0 ? ` w:displayText="${escapeXml(item.displayText)}"` : "";
43066
+ const valueAttr = item.value !== void 0 ? ` w:value="${escapeXml(item.value)}"` : "";
43067
+ return `<w:listItem${displayTextAttr}${valueAttr}/>`;
43068
+ }
43069
+ function serializeSdtSubtypeXml(subtype) {
43070
+ switch (subtype.kind) {
43071
+ case "text":
43072
+ return "<w:text/>";
43073
+ case "richText":
43074
+ return "<w:richText/>";
43075
+ case "picture":
43076
+ return "<w:picture/>";
43077
+ case "group":
43078
+ return "<w:group/>";
43079
+ case "equation":
43080
+ return "<w:equation/>";
43081
+ case "citation":
43082
+ return "<w:citation/>";
43083
+ case "bibliography":
43084
+ return "<w:bibliography/>";
43085
+ case "repeatingSection":
43086
+ return "<w:repeatingSection/>";
43087
+ case "repeatingSectionItem":
43088
+ return "<w:repeatingSectionItem/>";
43089
+ case "comboBox":
43090
+ case "dropDownList": {
43091
+ const items = (subtype.listItems ?? []).map(serializeSdtListItemXml).join("");
43092
+ const lastSelected = subtype.lastSelectedValue !== void 0 ? `<w:lastSelectedValue w:val="${escapeXml(
43093
+ subtype.lastSelectedValue
43094
+ )}"/>` : "";
43095
+ return `<w:${subtype.kind}>${items}${lastSelected}</w:${subtype.kind}>`;
43096
+ }
43097
+ case "date": {
43098
+ const fullDateAttr = subtype.fullDate !== void 0 ? ` w:fullDate="${escapeXml(subtype.fullDate)}"` : "";
43099
+ let children2 = "";
43100
+ if (subtype.dateFormat !== void 0) {
43101
+ children2 += `<w:dateFormat w:val="${escapeXml(subtype.dateFormat)}"/>`;
43102
+ }
43103
+ if (subtype.lid !== void 0) {
43104
+ children2 += `<w:lid w:val="${escapeXml(subtype.lid)}"/>`;
43105
+ }
43106
+ if (subtype.calendar !== void 0) {
43107
+ children2 += `<w:calendar w:val="${escapeXml(subtype.calendar)}"/>`;
43108
+ }
43109
+ if (subtype.storeMappedDataAs !== void 0) {
43110
+ children2 += `<w:storeMappedDataAs w:val="${escapeXml(
43111
+ subtype.storeMappedDataAs
43112
+ )}"/>`;
43113
+ }
43114
+ return `<w:date${fullDateAttr}>${children2}</w:date>`;
43115
+ }
43116
+ case "checkbox": {
43117
+ let children2 = "";
43118
+ if (subtype.checked !== void 0) {
43119
+ children2 += `<w14:checked w14:val="${subtype.checked ? "1" : "0"}"/>`;
43120
+ }
43121
+ if (subtype.checkedStateFont !== void 0 || subtype.checkedStateChar !== void 0) {
43122
+ const fontAttr = subtype.checkedStateFont !== void 0 ? ` w14:font="${escapeXml(subtype.checkedStateFont)}"` : "";
43123
+ const charAttr = subtype.checkedStateChar !== void 0 ? ` w14:char="${escapeXml(subtype.checkedStateChar)}"` : "";
43124
+ children2 += `<w14:checkedState${fontAttr}${charAttr}/>`;
43125
+ }
43126
+ if (subtype.uncheckedStateFont !== void 0 || subtype.uncheckedStateChar !== void 0) {
43127
+ const fontAttr = subtype.uncheckedStateFont !== void 0 ? ` w14:font="${escapeXml(subtype.uncheckedStateFont)}"` : "";
43128
+ const charAttr = subtype.uncheckedStateChar !== void 0 ? ` w14:char="${escapeXml(subtype.uncheckedStateChar)}"` : "";
43129
+ children2 += `<w14:uncheckedState${fontAttr}${charAttr}/>`;
43130
+ }
43131
+ return `<w14:checkbox>${children2}</w14:checkbox>`;
43132
+ }
43133
+ default: {
43134
+ const _exhaustive = subtype;
43135
+ return _exhaustive;
43136
+ }
43137
+ }
43138
+ }
43139
+ function directWordChildren$1(parent, localName) {
43140
+ const result = [];
43141
+ for (let index = 0; index < parent.childNodes.length; index += 1) {
43142
+ const node = parent.childNodes[index];
43143
+ if ((node == null ? void 0 : node.nodeType) === node.ELEMENT_NODE && node.namespaceURI === WORD_NS$1 && node.localName === localName) {
43144
+ result.push(node);
43145
+ }
43146
+ }
43147
+ return result;
43148
+ }
43149
+ function parseWordFragment$1(xml, expectedLocalName) {
43150
+ const wrapper = new DOMParser$1().parseFromString(
43151
+ `<oasis:root xmlns:oasis="urn:oasis:docx" xmlns:w="${WORD_NS$1}" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml">${xml}</oasis:root>`,
43152
+ "application/xml"
43153
+ ).documentElement;
43154
+ if (!wrapper) return void 0;
43155
+ for (let index = 0; index < wrapper.childNodes.length; index += 1) {
43156
+ const node = wrapper.childNodes[index];
43157
+ if ((node == null ? void 0 : node.nodeType) === node.ELEMENT_NODE && node.namespaceURI === WORD_NS$1 && node.localName === expectedLocalName) {
43158
+ return node;
43159
+ }
43160
+ }
43161
+ return void 0;
43162
+ }
43163
+ function createSdtEnvelope(parent, wrapper) {
43164
+ const document2 = parent.ownerDocument;
43165
+ if (!document2) return null;
43166
+ const sdt = document2.createElementNS(WORD_NS$1, "w:sdt");
43167
+ const properties = parseWordFragment$1(serializeSdtPrXml(wrapper.sdtPr), "sdtPr");
43168
+ if (properties) {
43169
+ sdt.appendChild(properties.cloneNode(true));
43170
+ }
43171
+ if (wrapper.sdtEndPrXml) {
43172
+ const endProperties = parseWordFragment$1(wrapper.sdtEndPrXml, "sdtEndPr");
43173
+ if (endProperties) {
43174
+ sdt.appendChild(endProperties.cloneNode(true));
43175
+ }
43176
+ }
43177
+ const content2 = document2.createElementNS(WORD_NS$1, "w:sdtContent");
43178
+ sdt.appendChild(content2);
43179
+ return { sdt, content: content2 };
43180
+ }
43181
+ function wrapSequence(parent, entries2) {
43182
+ var _a2;
43183
+ let index = 0;
43184
+ while (index < entries2.length) {
43185
+ const wrapper = entries2[index].wrappers[0];
43186
+ if (!wrapper) {
43187
+ index += 1;
43188
+ continue;
43189
+ }
43190
+ let end = index + 1;
43191
+ while (end < entries2.length && ((_a2 = entries2[end].wrappers[0]) == null ? void 0 : _a2.groupId) === wrapper.groupId) {
43192
+ end += 1;
43193
+ }
43194
+ const envelope = createSdtEnvelope(parent, wrapper);
43195
+ if (!envelope) {
43196
+ index = end;
43197
+ continue;
43198
+ }
43199
+ parent.insertBefore(envelope.sdt, entries2[index].element);
43200
+ const nestedEntries = [];
43201
+ for (let cursor = index; cursor < end; cursor += 1) {
43202
+ const entry = entries2[cursor];
43203
+ envelope.content.appendChild(entry.element);
43204
+ nestedEntries.push({
43205
+ element: entry.element,
43206
+ wrappers: entry.wrappers.slice(1)
43207
+ });
43208
+ }
43209
+ wrapSequence(envelope.content, nestedEntries);
43210
+ index = end;
43211
+ }
43212
+ }
43213
+ function wrapTableStructuralSdts(table, tableElement) {
43214
+ const rowElements = directWordChildren$1(tableElement, "tr");
43215
+ if (rowElements.length !== table.rows.length) return;
43216
+ for (let rowIndex = 0; rowIndex < rowElements.length; rowIndex += 1) {
43217
+ const rowElement = rowElements[rowIndex];
43218
+ const row = table.rows[rowIndex];
43219
+ const cellElements = directWordChildren$1(rowElement, "tc");
43220
+ if (cellElements.length !== row.cells.length) continue;
43221
+ wrapSequence(
43222
+ rowElement,
43223
+ cellElements.map((element, cellIndex) => ({
43224
+ element,
43225
+ wrappers: row.cells[cellIndex].sdtWrappers ?? []
43226
+ }))
43227
+ );
43228
+ }
43229
+ wrapSequence(
43230
+ tableElement,
43231
+ rowElements.map((element, rowIndex) => ({
43232
+ element,
43233
+ wrappers: table.rows[rowIndex].sdtWrappers ?? []
43234
+ }))
43235
+ );
43236
+ }
42926
43237
  function elementChildren(node) {
42927
43238
  const children2 = [];
42928
43239
  for (let index = 0; index < node.childNodes.length; index += 1) {
@@ -43292,6 +43603,9 @@ function parseWordFragment(xml, expectedLocalName) {
43292
43603
  `<oasis:root xmlns:oasis="urn:oasis:docx" xmlns:w="${WORD_NS$1}">${xml}</oasis:root>`,
43293
43604
  "application/xml"
43294
43605
  ).documentElement;
43606
+ if (!wrapper) {
43607
+ return void 0;
43608
+ }
43295
43609
  const element = wrapper ? directElementChildren$3(wrapper).find(
43296
43610
  (child2) => child2.namespaceURI === WORD_NS$1 && child2.localName === expectedLocalName
43297
43611
  ) : void 0;
@@ -43505,6 +43819,7 @@ function serializeTableXmlPreservingSource(table, serializeParagraphXml2) {
43505
43819
  overlayTableProperties(table, tableElement);
43506
43820
  overlayRowAndCellProperties(table, tableElement);
43507
43821
  ensureTerminalCellParagraphs(tableElement);
43822
+ wrapTableStructuralSdts(table, tableElement);
43508
43823
  const serialized = new XMLSerializer().serializeToString(tableElement);
43509
43824
  return serialized.replace(`<w:tbl xmlns:w="${WORD_NS$1}"`, "<w:tbl");
43510
43825
  }
@@ -44868,141 +45183,34 @@ function serializeRunWithRelationships(run, context2, paragraphStyleId, styles,
44868
45183
  }
44869
45184
  return wrapRunWithHyperlink(runXml, href, context2);
44870
45185
  }
44871
- function serializeSdtPrXml(sdtPr) {
44872
- const hasAnyField = sdtPr.alias !== void 0 || sdtPr.tag !== void 0 || sdtPr.id !== void 0 || sdtPr.lock !== void 0 || sdtPr.appearance !== void 0 || sdtPr.showingPlcHdr !== void 0 || sdtPr.temporary !== void 0 || sdtPr.color !== void 0 || sdtPr.placeholderDocPart !== void 0 || sdtPr.dataBinding !== void 0 || sdtPr.subtype !== void 0 || (sdtPr.unknownXml ?? "").length > 0;
44873
- if (!hasAnyField) {
44874
- return "<w:sdtPr/>";
44875
- }
44876
- let inner = "";
44877
- if (sdtPr.alias !== void 0) {
44878
- inner += `<w:alias w:val="${escapeXml(sdtPr.alias)}"/>`;
44879
- }
44880
- if (sdtPr.tag !== void 0) {
44881
- inner += `<w:tag w:val="${escapeXml(sdtPr.tag)}"/>`;
44882
- }
44883
- if (sdtPr.id !== void 0) {
44884
- inner += `<w:id w:val="${escapeXml(sdtPr.id)}"/>`;
44885
- }
44886
- if (sdtPr.lock !== void 0) {
44887
- inner += `<w:lock w:val="${escapeXml(sdtPr.lock)}"/>`;
44888
- }
44889
- if (sdtPr.placeholderDocPart !== void 0) {
44890
- inner += `<w:placeholder><w:docPart w:val="${escapeXml(
44891
- sdtPr.placeholderDocPart
44892
- )}"/></w:placeholder>`;
44893
- }
44894
- if (sdtPr.dataBinding !== void 0) {
44895
- inner += serializeSdtDataBindingXml(sdtPr.dataBinding);
44896
- }
44897
- if (sdtPr.temporary !== void 0) {
44898
- inner += `<w:temporary w:val="${sdtPr.temporary ? "true" : "false"}"/>`;
44899
- }
44900
- if (sdtPr.subtype !== void 0) {
44901
- inner += serializeSdtSubtypeXml(sdtPr.subtype);
44902
- }
44903
- if (sdtPr.appearance !== void 0) {
44904
- inner += `<w:appearance w:val="${escapeXml(sdtPr.appearance)}"/>`;
44905
- }
44906
- if (sdtPr.showingPlcHdr !== void 0) {
44907
- inner += `<w:showingPlcHdr w:val="${sdtPr.showingPlcHdr ? "true" : "false"}"/>`;
44908
- }
44909
- if (sdtPr.color !== void 0) {
44910
- inner += `<w:color w:val="${escapeXml(sdtPr.color)}"/>`;
44911
- }
44912
- if (sdtPr.unknownXml) {
44913
- inner += sdtPr.unknownXml;
44914
- }
44915
- return `<w:sdtPr>${inner}</w:sdtPr>`;
44916
- }
44917
- function serializeSdtDataBindingXml(dataBinding) {
44918
- let inner = "";
44919
- if (dataBinding.prefixMappings !== void 0) {
44920
- inner += `<w:prefixMappings w:val="${escapeXml(
44921
- dataBinding.prefixMappings
44922
- )}"/>`;
44923
- }
44924
- if (dataBinding.xpath !== void 0) {
44925
- inner += `<w:xpath w:val="${escapeXml(dataBinding.xpath)}"/>`;
44926
- }
44927
- if (dataBinding.storeItemID !== void 0) {
44928
- inner += `<w:storeItemID w:val="${escapeXml(dataBinding.storeItemID)}"/>`;
44929
- }
44930
- return inner ? `<w:dataBinding>${inner}</w:dataBinding>` : "";
44931
- }
44932
- function serializeSdtListItemXml(item) {
44933
- const displayTextAttr = item.displayText !== void 0 ? ` w:displayText="${escapeXml(item.displayText)}"` : "";
44934
- const valueAttr = item.value !== void 0 ? ` w:value="${escapeXml(item.value)}"` : "";
44935
- return `<w:listItem${displayTextAttr}${valueAttr}/>`;
44936
- }
44937
- function serializeSdtSubtypeXml(subtype) {
44938
- switch (subtype.kind) {
44939
- case "text":
44940
- return "<w:text/>";
44941
- case "richText":
44942
- return "<w:richText/>";
44943
- case "picture":
44944
- return "<w:picture/>";
44945
- case "group":
44946
- return "<w:group/>";
44947
- case "equation":
44948
- return "<w:equation/>";
44949
- case "citation":
44950
- return "<w:citation/>";
44951
- case "bibliography":
44952
- return "<w:bibliography/>";
44953
- case "repeatingSection":
44954
- return "<w:repeatingSection/>";
44955
- case "repeatingSectionItem":
44956
- return "<w:repeatingSectionItem/>";
44957
- case "comboBox":
44958
- case "dropDownList": {
44959
- const items = (subtype.listItems ?? []).map(serializeSdtListItemXml).join("");
44960
- const lastSelected = subtype.lastSelectedValue !== void 0 ? `<w:lastSelectedValue w:val="${escapeXml(
44961
- subtype.lastSelectedValue
44962
- )}"/>` : "";
44963
- return `<w:${subtype.kind}>${items}${lastSelected}</w:${subtype.kind}>`;
44964
- }
44965
- case "date": {
44966
- const fullDateAttr = subtype.fullDate !== void 0 ? ` w:fullDate="${escapeXml(subtype.fullDate)}"` : "";
44967
- let children2 = "";
44968
- if (subtype.dateFormat !== void 0) {
44969
- children2 += `<w:dateFormat w:val="${escapeXml(subtype.dateFormat)}"/>`;
44970
- }
44971
- if (subtype.lid !== void 0) {
44972
- children2 += `<w:lid w:val="${escapeXml(subtype.lid)}"/>`;
44973
- }
44974
- if (subtype.calendar !== void 0) {
44975
- children2 += `<w:calendar w:val="${escapeXml(subtype.calendar)}"/>`;
44976
- }
44977
- if (subtype.storeMappedDataAs !== void 0) {
44978
- children2 += `<w:storeMappedDataAs w:val="${escapeXml(
44979
- subtype.storeMappedDataAs
44980
- )}"/>`;
44981
- }
44982
- return `<w:date${fullDateAttr}>${children2}</w:date>`;
44983
- }
44984
- case "checkbox": {
44985
- let children2 = "";
44986
- if (subtype.checked !== void 0) {
44987
- children2 += `<w14:checked w14:val="${subtype.checked ? "1" : "0"}"/>`;
44988
- }
44989
- if (subtype.checkedStateFont !== void 0 || subtype.checkedStateChar !== void 0) {
44990
- const fontAttr = subtype.checkedStateFont !== void 0 ? ` w14:font="${escapeXml(subtype.checkedStateFont)}"` : "";
44991
- const charAttr = subtype.checkedStateChar !== void 0 ? ` w14:char="${escapeXml(subtype.checkedStateChar)}"` : "";
44992
- children2 += `<w14:checkedState${fontAttr}${charAttr}/>`;
44993
- }
44994
- if (subtype.uncheckedStateFont !== void 0 || subtype.uncheckedStateChar !== void 0) {
44995
- const fontAttr = subtype.uncheckedStateFont !== void 0 ? ` w14:font="${escapeXml(subtype.uncheckedStateFont)}"` : "";
44996
- const charAttr = subtype.uncheckedStateChar !== void 0 ? ` w14:char="${escapeXml(subtype.uncheckedStateChar)}"` : "";
44997
- children2 += `<w14:uncheckedState${fontAttr}${charAttr}/>`;
44998
- }
44999
- return `<w14:checkbox>${children2}</w14:checkbox>`;
45186
+ function serializeRunsWithInlineSdts(runs, serializeRun2) {
45187
+ var _a2, _b2, _c;
45188
+ let out = "";
45189
+ let index = 0;
45190
+ while (index < runs.length) {
45191
+ const run = runs[index];
45192
+ const wrapper = (_a2 = run.sdtWrappers) == null ? void 0 : _a2[0];
45193
+ if (!wrapper) {
45194
+ out += serializeRun2(run);
45195
+ index += 1;
45196
+ continue;
45000
45197
  }
45001
- default: {
45002
- const _exhaustive = subtype;
45003
- return _exhaustive;
45198
+ const group = [];
45199
+ let cursor = index;
45200
+ while (cursor < runs.length && ((_c = (_b2 = runs[cursor].sdtWrappers) == null ? void 0 : _b2[0]) == null ? void 0 : _c.groupId) === wrapper.groupId) {
45201
+ const current = runs[cursor];
45202
+ const rest = current.sdtWrappers.slice(1);
45203
+ group.push({
45204
+ ...current,
45205
+ sdtWrappers: rest.length > 0 ? rest : void 0
45206
+ });
45207
+ cursor += 1;
45004
45208
  }
45209
+ const inner = serializeRunsWithInlineSdts(group, serializeRun2);
45210
+ out += `<w:sdt>${serializeSdtPrXml(wrapper.sdtPr)}${wrapper.sdtEndPrXml ?? ""}<w:sdtContent>${inner}</w:sdtContent></w:sdt>`;
45211
+ index = cursor;
45005
45212
  }
45213
+ return out;
45006
45214
  }
45007
45215
  function serializeDropCapFrameParagraph(dropCap) {
45008
45216
  const runProps = serializeRunProperties(dropCap.style);
@@ -45491,19 +45699,21 @@ function serializeParagraphXml(paragraph, context2, styles, overrides) {
45491
45699
  if (reusableParagraphXml) {
45492
45700
  return reusableParagraphXml;
45493
45701
  }
45494
- const serializedRunXml = boundaryTokens.length === 0 ? runs.map(
45495
- (run) => {
45496
- var _a3;
45497
- return serializeRunWithRelationships(
45498
- run,
45499
- context2,
45500
- (_a3 = paragraph.style) == null ? void 0 : _a3.styleId,
45501
- styles,
45502
- serializeBlocksXml
45503
- );
45504
- }
45505
- ) : void 0;
45506
- const runsXml = serializedRunXml ? serializedRunXml.join("") : serializeRunsWithBoundaries(
45702
+ const serializeCanonicalRun = (run) => {
45703
+ var _a3;
45704
+ return serializeRunWithRelationships(
45705
+ run,
45706
+ context2,
45707
+ (_a3 = paragraph.style) == null ? void 0 : _a3.styleId,
45708
+ styles,
45709
+ serializeBlocksXml
45710
+ );
45711
+ };
45712
+ const serializedRunXml = boundaryTokens.length === 0 ? runs.map(serializeCanonicalRun) : void 0;
45713
+ const runsXml = boundaryTokens.length === 0 ? serializeRunsWithInlineSdts(
45714
+ runs,
45715
+ serializeCanonicalRun
45716
+ ) : serializeRunsWithBoundaries(
45507
45717
  runs,
45508
45718
  boundaryTokens,
45509
45719
  context2,
@@ -46356,7 +46566,8 @@ function cloneRun(run) {
46356
46566
  id: run.id,
46357
46567
  text: run.text,
46358
46568
  styles: cloneStyle(run.styles),
46359
- revision: run.revision ? { ...run.revision } : void 0
46569
+ revision: run.revision ? { ...run.revision } : void 0,
46570
+ sdtWrappers: run.sdtWrappers ? [...run.sdtWrappers] : void 0
46360
46571
  };
46361
46572
  const cloned = visitRun(run, {
46362
46573
  text: () => ({ ...base, kind: "text" }),
@@ -47337,7 +47548,7 @@ async function importDocxInWorker(buffer, options = {}) {
47337
47548
  const worker = new Worker(
47338
47549
  new URL(
47339
47550
  /* @vite-ignore */
47340
- "" + new URL("assets/importDocxWorker-DpJa1l2G.js", import.meta.url).href,
47551
+ "" + new URL("assets/importDocxWorker-BHz7MeiI.js", import.meta.url).href,
47341
47552
  import.meta.url
47342
47553
  ),
47343
47554
  {
@@ -55549,7 +55760,7 @@ export {
55549
55760
  createEffect as ay,
55550
55761
  TextField as az,
55551
55762
  getPageBodyTop as b,
55552
- resolveRenderedTextChar as b$,
55763
+ resolveTextAlignmentBaselineOffset as b$,
55553
55764
  serializeLinearMath as b0,
55554
55765
  parseLinearMath as b1,
55555
55766
  Text$1 as b2,
@@ -55560,33 +55771,33 @@ export {
55560
55771
  use as b7,
55561
55772
  PluginUiHost as b8,
55562
55773
  OasisEditorEditor as b9,
55563
- exportEditorDocumentToDocxBlob as bA,
55564
- exportEditorDocumentToDocx as bB,
55565
- pxToPt as bC,
55566
- resolveFloatingObjectRect as bD,
55567
- getTextBoxFloatingGeometry as bE,
55568
- getPresetPathSegments as bF,
55569
- buildListLabels as bG,
55570
- lineDashPatternPt as bH,
55571
- DEFAULT_FONT_SIZE_PX as bI,
55572
- resolveGradientAxis as bJ,
55573
- isDoubleUnderlineStyle as bK,
55574
- isWavyUnderlineStyle as bL,
55575
- underlineStyleLineWidthPx as bM,
55576
- WAVY_UNDERLINE_WAVELENGTH_PX as bN,
55577
- WAVY_UNDERLINE_AMPLITUDE_PX as bO,
55578
- DOUBLE_UNDERLINE_OFFSET_PX as bP,
55579
- underlineStyleDashArray as bQ,
55580
- resolveEffectiveParagraphStyle as bR,
55581
- EMPHASIS_GLYPH as bS,
55582
- parseHexColorToRgb255 as bT,
55583
- rgb255ToHex as bU,
55584
- getImageFloatingGeometry as bV,
55585
- resolveEffectiveTextStyleForParagraph as bW,
55586
- textStyleToFontSizePt as bX,
55587
- mathDisplayText as bY,
55588
- TEXT_BASELINE_RATIO as bZ,
55589
- resolveTextAlignmentBaselineOffset as b_,
55774
+ getDocumentSectionsCanonical as bA,
55775
+ exportEditorDocumentToDocxBlob as bB,
55776
+ exportEditorDocumentToDocx as bC,
55777
+ pxToPt as bD,
55778
+ resolveFloatingObjectRect as bE,
55779
+ getTextBoxFloatingGeometry as bF,
55780
+ getPresetPathSegments as bG,
55781
+ buildListLabels as bH,
55782
+ lineDashPatternPt as bI,
55783
+ DEFAULT_FONT_SIZE_PX as bJ,
55784
+ resolveGradientAxis as bK,
55785
+ isDoubleUnderlineStyle as bL,
55786
+ isWavyUnderlineStyle as bM,
55787
+ underlineStyleLineWidthPx as bN,
55788
+ WAVY_UNDERLINE_WAVELENGTH_PX as bO,
55789
+ WAVY_UNDERLINE_AMPLITUDE_PX as bP,
55790
+ DOUBLE_UNDERLINE_OFFSET_PX as bQ,
55791
+ underlineStyleDashArray as bR,
55792
+ resolveEffectiveParagraphStyle as bS,
55793
+ EMPHASIS_GLYPH as bT,
55794
+ parseHexColorToRgb255 as bU,
55795
+ rgb255ToHex as bV,
55796
+ getImageFloatingGeometry as bW,
55797
+ resolveEffectiveTextStyleForParagraph as bX,
55798
+ textStyleToFontSizePt as bY,
55799
+ mathDisplayText as bZ,
55800
+ TEXT_BASELINE_RATIO as b_,
55590
55801
  OasisBrandMark as ba,
55591
55802
  setPreciseFontPreference as bb,
55592
55803
  setWelcomeSeen as bc,
@@ -55615,16 +55826,16 @@ export {
55615
55826
  mergeTablePropertiesXmlSource as bz,
55616
55827
  getPageContentWidth as c,
55617
55828
  createSectionBoundaryParagraph as c$,
55618
- resolveOpenTypeFeatureTags as c0,
55619
- isLowercaseSmallCapsChar as c1,
55620
- resolveDecorationLineY as c2,
55621
- DOUBLE_STRIKE_OFFSET_PX as c3,
55622
- resolveListLabel as c4,
55623
- getListLabelInset as c5,
55624
- getAlignedListLabelInset as c6,
55625
- getParagraphBorderInsets as c7,
55626
- buildSegmentTable as c8,
55627
- buildCanvasTableLayout as c9,
55829
+ resolveRenderedTextChar as c0,
55830
+ resolveOpenTypeFeatureTags as c1,
55831
+ isLowercaseSmallCapsChar as c2,
55832
+ resolveDecorationLineY as c3,
55833
+ DOUBLE_STRIKE_OFFSET_PX as c4,
55834
+ resolveListLabel as c5,
55835
+ getListLabelInset as c6,
55836
+ getAlignedListLabelInset as c7,
55837
+ getParagraphBorderInsets as c8,
55838
+ buildSegmentTable as c9,
55628
55839
  updateImageCaptionParagraph as cA,
55629
55840
  createImageCaptionParagraph as cB,
55630
55841
  renumberImageCaptionParagraphs as cC,
@@ -55652,28 +55863,28 @@ export {
55652
55863
  VERTICAL_HIT_WEIGHT as cY,
55653
55864
  getCachedCanvasImage as cZ,
55654
55865
  measureParagraphMinContentWidthPx as c_,
55655
- resolveCanvasTableWidth as ca,
55656
- resolveFloatingTableRect as cb,
55657
- paragraphBetweenBorderMatches as cc,
55658
- normalizeFamily as cd,
55659
- ROBOTO_FONT_FILES as ce,
55660
- loadFontAsset as cf,
55661
- getRemotePdfFontFaces as cg,
55662
- OFFICE_COMPAT_FONT_FAMILIES as ch,
55663
- BinaryReader as ci,
55664
- buildSfnt as cj,
55665
- defaultFontDecoderRegistry as ck,
55666
- SfntFontProgram as cl,
55667
- zlibSync as cm,
55668
- renumberImageCaptionsInDocument as cn,
55669
- collectPdfFontFamilies as co,
55670
- outlineFrom as cp,
55671
- getPageHeaderZoneTop as cq,
55672
- getPageColumnRects as cr,
55673
- findFootnoteReference as cs,
55674
- resolveImporterForFile as ct,
55675
- roundTo as cu,
55676
- getDocumentSectionsCanonical as cv,
55866
+ buildCanvasTableLayout as ca,
55867
+ resolveCanvasTableWidth as cb,
55868
+ resolveFloatingTableRect as cc,
55869
+ paragraphBetweenBorderMatches as cd,
55870
+ normalizeFamily as ce,
55871
+ ROBOTO_FONT_FILES as cf,
55872
+ loadFontAsset as cg,
55873
+ getRemotePdfFontFaces as ch,
55874
+ OFFICE_COMPAT_FONT_FAMILIES as ci,
55875
+ BinaryReader as cj,
55876
+ buildSfnt as ck,
55877
+ defaultFontDecoderRegistry as cl,
55878
+ SfntFontProgram as cm,
55879
+ zlibSync as cn,
55880
+ renumberImageCaptionsInDocument as co,
55881
+ collectPdfFontFamilies as cp,
55882
+ outlineFrom as cq,
55883
+ getPageHeaderZoneTop as cr,
55884
+ getPageColumnRects as cs,
55885
+ findFootnoteReference as ct,
55886
+ resolveImporterForFile as cu,
55887
+ roundTo as cv,
55677
55888
  getDocumentParagraphsCanonical as cw,
55678
55889
  getDocumentParagraphs as cx,
55679
55890
  getImageCaptionText as cy,