@superdoc-dev/mcp 0.11.0-next.14 → 0.11.0-next.15

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 (2) hide show
  1. package/dist/index.js +319 -132
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -52211,7 +52211,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
52211
52211
  emptyOptions2 = {};
52212
52212
  });
52213
52213
 
52214
- // ../../packages/superdoc/dist/chunks/SuperConverter-BVWG4qnQ.es.js
52214
+ // ../../packages/superdoc/dist/chunks/SuperConverter-DOoAJ6Zk.es.js
52215
52215
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
52216
52216
  const fieldValue = extension$1.config[field];
52217
52217
  if (typeof fieldValue === "function")
@@ -92420,6 +92420,9 @@ function writeSectPrPageNumbering(sectPr, numbering) {
92420
92420
  if (numbering.chapterSeparator !== undefined)
92421
92421
  setStringAttr(pgNumType, "w:chapSep", numbering.chapterSeparator);
92422
92422
  }
92423
+ function readSectPrTitlePage(sectPr) {
92424
+ return Boolean(findChild(sectPr, "w:titlePg"));
92425
+ }
92423
92426
  function writeSectPrTitlePage(sectPr, enabled) {
92424
92427
  if (enabled) {
92425
92428
  ensureChild(sectPr, "w:titlePg");
@@ -95101,6 +95104,13 @@ function getTextAdapter(editor, input) {
95101
95104
  `, `
95102
95105
  `, { textModel: "visible" });
95103
95106
  }
95107
+ function projectInternalTrackChangeType(type, structural) {
95108
+ if (type !== "structural")
95109
+ return type;
95110
+ if (structural?.subtype === "table-delete" || structural?.side === "deletion")
95111
+ return "delete";
95112
+ return "insert";
95113
+ }
95104
95114
  function rangesOverlap(a, b) {
95105
95115
  return a[0] < b[1] && b[0] < a[1];
95106
95116
  }
@@ -95204,17 +95214,18 @@ function buildPublicTrackedChangeIdMap(grouped, replacements) {
95204
95214
  return publicIdByChange;
95205
95215
  }
95206
95216
  function layerFromChange(change, relationship) {
95217
+ const type = resolveTrackedChangeType(change);
95207
95218
  return {
95208
95219
  id: change.id,
95209
95220
  rawId: change.rawId,
95210
95221
  commandRawId: change.commandRawId,
95211
- type: resolveTrackedChangeType(change),
95222
+ type: projectInternalTrackChangeType(type, change.structural),
95212
95223
  relationship
95213
95224
  };
95214
95225
  }
95215
95226
  function compareOverlapChildren(a, b) {
95216
- const aType = resolveTrackedChangeType(a);
95217
- const bType = resolveTrackedChangeType(b);
95227
+ const aType = projectInternalTrackChangeType(resolveTrackedChangeType(a), a.structural);
95228
+ const bType = projectInternalTrackChangeType(resolveTrackedChangeType(b), b.structural);
95218
95229
  if (aType !== bType) {
95219
95230
  if (aType === "delete")
95220
95231
  return -1;
@@ -117871,7 +117882,7 @@ var isRegExp = (value) => {
117871
117882
  state.kern = kernNode.attributes["w:val"];
117872
117883
  }
117873
117884
  }, SuperConverter;
117874
- var init_SuperConverter_BVWG4qnQ_es = __esm(() => {
117885
+ var init_SuperConverter_DOoAJ6Zk_es = __esm(() => {
117875
117886
  init_rolldown_runtime_Bg48TavK_es();
117876
117887
  init_jszip_C49i9kUs_es();
117877
117888
  init_xml_js_CqGKpaft_es();
@@ -122887,7 +122898,7 @@ var init_SuperConverter_BVWG4qnQ_es = __esm(() => {
122887
122898
  "trackChanges.list": {
122888
122899
  memberPath: "trackChanges.list",
122889
122900
  description: "List all tracked changes in the document.",
122890
- expectedResult: "Returns a TrackChangesListResult with tracked change entries (`insert`, `delete`, `replacement`, `format`, `structural`), total count, and raw imported Word OOXML revision IDs (`w:id`) when available. Structural changes (whole-table insert/delete) carry a `subtype` of `table-insert` or `table-delete`.",
122901
+ expectedResult: "Returns a TrackChangesListResult with tracked change entries (`insert`, `delete`, `replacement`, `format`), total count, and raw imported Word OOXML revision IDs (`w:id`) when available. Whole-table tracked insertions and deletions are surfaced through the legacy `insert` / `delete` types.",
122891
122902
  requiresDocumentContext: true,
122892
122903
  metadata: readOperation({
122893
122904
  idempotency: "idempotent",
@@ -122901,7 +122912,7 @@ var init_SuperConverter_BVWG4qnQ_es = __esm(() => {
122901
122912
  "trackChanges.get": {
122902
122913
  memberPath: "trackChanges.get",
122903
122914
  description: "Retrieve a single tracked change by ID.",
122904
- expectedResult: "Returns a TrackChangeInfo object with the change type (`insert`, `delete`, `replacement`, `format`, `structural`), author, date, affected content, and raw imported Word OOXML revision IDs (`w:id`) when available. Structural changes (whole-table insert/delete) carry a `subtype` of `table-insert` or `table-delete`.",
122915
+ expectedResult: "Returns a TrackChangeInfo object with the change type (`insert`, `delete`, `replacement`, `format`), author, date, affected content, and raw imported Word OOXML revision IDs (`w:id`) when available. Whole-table tracked insertions and deletions are surfaced through the legacy `insert` / `delete` types.",
122905
122916
  requiresDocumentContext: true,
122906
122917
  metadata: readOperation({
122907
122918
  idempotency: "idempotent",
@@ -122921,6 +122932,7 @@ var init_SuperConverter_BVWG4qnQ_es = __esm(() => {
122921
122932
  supportsTrackedMode: false,
122922
122933
  possibleFailureCodes: [
122923
122934
  "NO_OP",
122935
+ "INVALID_INPUT",
122924
122936
  "INVALID_TARGET",
122925
122937
  "TARGET_NOT_FOUND",
122926
122938
  "CAPABILITY_UNAVAILABLE",
@@ -127400,8 +127412,7 @@ var init_SuperConverter_BVWG4qnQ_es = __esm(() => {
127400
127412
  "insert",
127401
127413
  "delete",
127402
127414
  "replacement",
127403
- "format",
127404
- "structural"
127415
+ "format"
127405
127416
  ];
127406
127417
  nodeTypeValues = NODE_TYPES;
127407
127418
  blockNodeTypeValues = BLOCK_NODE_TYPES;
@@ -128431,10 +128442,6 @@ var init_SuperConverter_BVWG4qnQ_es = __esm(() => {
128431
128442
  address: trackedChangeAddressSchema,
128432
128443
  id: { type: "string" },
128433
128444
  type: { enum: [...trackChangeTypeValues] },
128434
- subtype: {
128435
- enum: ["table-insert", "table-delete"],
128436
- description: "Finer classification for structural changes (type === 'structural')."
128437
- },
128438
128445
  grouping: { enum: [
128439
128446
  "standalone",
128440
128447
  "replacement-pair",
@@ -128457,10 +128464,6 @@ var init_SuperConverter_BVWG4qnQ_es = __esm(() => {
128457
128464
  discoveryResultSchema(discoveryItemSchema({
128458
128465
  address: trackedChangeAddressSchema,
128459
128466
  type: { enum: [...trackChangeTypeValues] },
128460
- subtype: {
128461
- enum: ["table-insert", "table-delete"],
128462
- description: "Finer classification for structural changes (type === 'structural')."
128463
- },
128464
128467
  grouping: { enum: [
128465
128468
  "standalone",
128466
128469
  "replacement-pair",
@@ -130955,7 +130958,7 @@ var init_SuperConverter_BVWG4qnQ_es = __esm(() => {
130955
130958
  },
130956
130959
  type: {
130957
130960
  enum: [...trackChangeTypeValues],
130958
- description: "Filter by change type: 'insert', 'delete', 'replacement', 'format', or 'structural'."
130961
+ description: "Filter by change type: 'insert', 'delete', 'replacement', or 'format'."
130959
130962
  },
130960
130963
  in: {
130961
130964
  oneOf: [storyLocatorSchema, { const: "all" }],
@@ -157216,7 +157219,7 @@ var init_SuperConverter_BVWG4qnQ_es = __esm(() => {
157216
157219
  };
157217
157220
  });
157218
157221
 
157219
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-JvWvpCga.es.js
157222
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DUhzXJ4D.es.js
157220
157223
  function parseSizeUnit(val = "0") {
157221
157224
  const length = val.toString() || "0";
157222
157225
  const value = Number.parseFloat(length);
@@ -167549,8 +167552,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
167549
167552
  }
167550
167553
  };
167551
167554
  };
167552
- var init_create_headless_toolbar_JvWvpCga_es = __esm(() => {
167553
- init_SuperConverter_BVWG4qnQ_es();
167555
+ var init_create_headless_toolbar_DUhzXJ4D_es = __esm(() => {
167556
+ init_SuperConverter_DOoAJ6Zk_es();
167554
167557
  init_uuid_qzgm05fK_es();
167555
167558
  init_constants_D9qj59G2_es();
167556
167559
  init_dist_B8HfvhaK_es();
@@ -222234,7 +222237,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
222234
222237
  init_remark_gfm_BhnWr3yf_es();
222235
222238
  });
222236
222239
 
222237
- // ../../packages/superdoc/dist/chunks/src-x_i3LADL.es.js
222240
+ // ../../packages/superdoc/dist/chunks/src-DEnygTyz.es.js
222238
222241
  function deleteProps(obj, propOrProps) {
222239
222242
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
222240
222243
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -238893,7 +238896,7 @@ function buildChangedTextFields(type, excerpt) {
238893
238896
  }
238894
238897
  function buildProjectedInfo(snapshot2, options = {}) {
238895
238898
  const id2 = options.id ?? snapshot2.address.entityId;
238896
- const type = options.type ?? snapshot2.type;
238899
+ const type = options.type ?? projectInternalTrackChangeType(snapshot2.type, { subtype: snapshot2.subtype });
238897
238900
  return {
238898
238901
  info: {
238899
238902
  address: {
@@ -238902,7 +238905,6 @@ function buildProjectedInfo(snapshot2, options = {}) {
238902
238905
  },
238903
238906
  id: id2,
238904
238907
  type,
238905
- ...type === "structural" && snapshot2.subtype ? { subtype: snapshot2.subtype } : {},
238906
238908
  grouping: options.grouping,
238907
238909
  pairedWithChangeId: options.pairedWithChangeId ?? undefined,
238908
238910
  wordRevisionIds: normalizeWordRevisionIds(snapshot2.wordRevisionIds),
@@ -238933,7 +238935,7 @@ function replacementPairKey2(snapshot2) {
238933
238935
  return null;
238934
238936
  }
238935
238937
  function projectedSnapshotType(snapshot2) {
238936
- return isCombinedReplacementSnapshot(snapshot2) ? "replacement" : snapshot2.type;
238938
+ return isCombinedReplacementSnapshot(snapshot2) ? "replacement" : projectInternalTrackChangeType(snapshot2.type, { subtype: snapshot2.subtype });
238937
238939
  }
238938
238940
  function snapshotGrouping(snapshot2) {
238939
238941
  return isCombinedReplacementSnapshot(snapshot2) ? "replacement-pair" : "standalone";
@@ -239158,11 +239160,10 @@ function trackChangesListWrapper(editor, input2) {
239158
239160
  const items = paged.items.map((row2) => {
239159
239161
  const info = row2.info;
239160
239162
  const handle3 = buildResolvedHandle(row2.handleKey, "stable", "trackedChange");
239161
- const { address, type, subtype, grouping, pairedWithChangeId, wordRevisionIds, overlap, author, authorEmail, authorImage, date: date6, excerpt, insertedText, deletedText, origin, imported } = info;
239163
+ const { address, type, grouping, pairedWithChangeId, wordRevisionIds, overlap, author, authorEmail, authorImage, date: date6, excerpt, insertedText, deletedText, origin, imported } = info;
239162
239164
  return buildDiscoveryItem(info.id, handle3, {
239163
239165
  address,
239164
239166
  type,
239165
- ...subtype ? { subtype } : {},
239166
239167
  grouping,
239167
239168
  pairedWithChangeId,
239168
239169
  wordRevisionIds,
@@ -239213,7 +239214,7 @@ function trackChangesGetWrapper(editor, input2) {
239213
239214
  const snapshot2 = snapshots.find((item) => item.anchorKey === anchorKey || item.address.entityId === baseId);
239214
239215
  if (snapshot2)
239215
239216
  return snapshotToInfo(snapshot2);
239216
- const type = resolveTrackedChangeType(resolved.change);
239217
+ const type = projectInternalTrackChangeType(resolveTrackedChangeType(resolved.change), resolved.change.structural);
239217
239218
  const excerpt = (resolved.change.excerpt !== undefined ? resolved.change.excerpt : undefined) ?? normalizeExcerpt(resolved.editor.state.doc.textBetween(resolved.change.from, resolved.change.to, " ", ""));
239218
239219
  const grouping = resolved.change.hasInsert && resolved.change.hasDelete && !resolved.change.hasFormat ? "replacement-pair" : undefined;
239219
239220
  return {
@@ -239225,7 +239226,6 @@ function trackChangesGetWrapper(editor, input2) {
239225
239226
  },
239226
239227
  id: resolved.change.id,
239227
239228
  type,
239228
- ...type === "structural" && resolved.change.structural ? { subtype: resolved.change.structural.subtype } : {},
239229
239229
  grouping,
239230
239230
  wordRevisionIds: normalizeWordRevisionIds(resolved.change.wordRevisionIds),
239231
239231
  overlap: resolved.change.overlap,
@@ -239464,12 +239464,20 @@ function isTrackedChangeCommentTargetShape(target) {
239464
239464
  return false;
239465
239465
  return typeof value.trackedChangeId === "string" && value.trackedChangeId.length > 0;
239466
239466
  }
239467
+ function trackedChangeDisplayType(snapshot2) {
239468
+ if (snapshot2.type !== "structural")
239469
+ return null;
239470
+ return snapshot2.subtype === "table-delete" ? "tableDelete" : "tableInsert";
239471
+ }
239472
+ function publicTrackedChangeType(snapshot2) {
239473
+ return projectInternalTrackChangeType(snapshot2.type, { subtype: snapshot2.subtype });
239474
+ }
239467
239475
  function buildTrackedChangeLink(snapshot2) {
239468
239476
  const { trackedChangeText, deletedText } = trackedChangeTextFields(snapshot2);
239469
239477
  return {
239470
239478
  trackedChange: true,
239471
- trackedChangeType: snapshot2.type,
239472
- trackedChangeDisplayType: null,
239479
+ trackedChangeType: publicTrackedChangeType(snapshot2),
239480
+ trackedChangeDisplayType: trackedChangeDisplayType(snapshot2),
239473
239481
  trackedChangeStory: snapshot2.story,
239474
239482
  trackedChangeAnchorKey: snapshot2.anchorKey,
239475
239483
  trackedChangeText,
@@ -239513,7 +239521,7 @@ function choosePreferredTrackedChangeSnapshot(snapshots, preferredId) {
239513
239521
  const rightLength = Math.max(0, right$1.range.to - right$1.range.from);
239514
239522
  if (leftLength !== rightLength)
239515
239523
  return leftLength - rightLength;
239516
- const typeDelta = trackedChangeTypePriority(left$1.type) - trackedChangeTypePriority(right$1.type);
239524
+ const typeDelta = trackedChangeTypePriority(publicTrackedChangeType(left$1)) - trackedChangeTypePriority(publicTrackedChangeType(right$1));
239517
239525
  if (typeDelta !== 0)
239518
239526
  return typeDelta;
239519
239527
  if (left$1.range.from !== right$1.range.from)
@@ -239730,7 +239738,7 @@ function parseCreatedTime(value) {
239730
239738
  }
239731
239739
  function trackedChangeTextFields(snapshot2) {
239732
239740
  const excerpt = snapshot2.excerpt ?? "";
239733
- if (snapshot2.type === "delete")
239741
+ if (publicTrackedChangeType(snapshot2) === "delete")
239734
239742
  return {
239735
239743
  trackedChangeText: "",
239736
239744
  deletedText: excerpt
@@ -239757,7 +239765,8 @@ function toTrackedChangeCommentInfo(snapshot2) {
239757
239765
  anchoredText: snapshot2.excerpt,
239758
239766
  story: snapshot2.story,
239759
239767
  trackedChange: true,
239760
- trackedChangeType: snapshot2.type,
239768
+ trackedChangeType: publicTrackedChangeType(snapshot2),
239769
+ trackedChangeDisplayType: trackedChangeDisplayType(snapshot2),
239761
239770
  trackedChangeStory: snapshot2.story,
239762
239771
  trackedChangeAnchorKey: snapshot2.anchorKey,
239763
239772
  trackedChangeText,
@@ -240624,7 +240633,7 @@ function listCommentsHandler(editor, query) {
240624
240633
  const paged = paginate(filtered, query?.offset, query?.limit);
240625
240634
  const items = paged.items.map((comment2) => {
240626
240635
  const handle3 = buildResolvedHandle(`comment:${comment2.commentId}`, "stable", "comment");
240627
- const { importedId, parentCommentId, text: text5, isInternal, status, target, anchoredText, createdTime, creatorName, creatorEmail, address, story, trackedChange, trackedChangeType, trackedChangeDisplayType, trackedChangeStory, trackedChangeAnchorKey, trackedChangeText, deletedText, trackedChangeLink } = comment2;
240636
+ const { importedId, parentCommentId, text: text5, isInternal, status, target, anchoredText, createdTime, creatorName, creatorEmail, address, story, trackedChange, trackedChangeType, trackedChangeDisplayType: trackedChangeDisplayType$1, trackedChangeStory, trackedChangeAnchorKey, trackedChangeText, deletedText, trackedChangeLink } = comment2;
240628
240637
  return buildDiscoveryItem(comment2.commentId, handle3, {
240629
240638
  address,
240630
240639
  importedId,
@@ -240640,7 +240649,7 @@ function listCommentsHandler(editor, query) {
240640
240649
  story,
240641
240650
  trackedChange,
240642
240651
  trackedChangeType,
240643
- trackedChangeDisplayType,
240652
+ trackedChangeDisplayType: trackedChangeDisplayType$1,
240644
240653
  trackedChangeStory,
240645
240654
  trackedChangeAnchorKey,
240646
240655
  trackedChangeText,
@@ -241577,6 +241586,27 @@ function rewriteImportedStyleNumbering(importedStyleEls, numRemap) {
241577
241586
  function numAttr(el, attr) {
241578
241587
  return el.attributes?.[attr];
241579
241588
  }
241589
+ function reorderNumberingChildren(numberingEl) {
241590
+ if (!numberingEl.elements)
241591
+ return;
241592
+ const other = [];
241593
+ const abstracts = [];
241594
+ const nums = [];
241595
+ for (const el of numberingEl.elements) {
241596
+ const ln = localName$1(el);
241597
+ if (ln === "abstractNum")
241598
+ abstracts.push(el);
241599
+ else if (ln === "num")
241600
+ nums.push(el);
241601
+ else
241602
+ other.push(el);
241603
+ }
241604
+ numberingEl.elements = [
241605
+ ...other,
241606
+ ...abstracts,
241607
+ ...nums
241608
+ ];
241609
+ }
241580
241610
  function mergeNumberingGraph(currentRoot, sourceRoot) {
241581
241611
  const result = {
241582
241612
  numRemap: /* @__PURE__ */ new Map,
@@ -241660,6 +241690,7 @@ function mergeNumberingGraph(currentRoot, sourceRoot) {
241660
241690
  usedNum.add(id2);
241661
241691
  cur.elements.push(next2);
241662
241692
  }
241693
+ reorderNumberingChildren(cur);
241663
241694
  return result;
241664
241695
  }
241665
241696
  function reconcileSettings(currentRoot, sourceRoot) {
@@ -241849,18 +241880,21 @@ function importHeaderFooterAssets(editor, converter, byName, dryRun) {
241849
241880
  usedMedia.add(allocated);
241850
241881
  return allocated;
241851
241882
  };
241852
- const sourceRelByTarget = /* @__PURE__ */ new Map;
241883
+ const sourceRelIdsByTarget = /* @__PURE__ */ new Map;
241853
241884
  for (const rel of srcRelEls) {
241854
241885
  const type = rel.attributes?.Type;
241855
241886
  const target = rel.attributes?.Target;
241856
241887
  const id2 = rel.attributes?.Id;
241857
241888
  if (!type || !target || !id2)
241858
241889
  continue;
241859
- if (type === HEADER_REL_TYPE2 || type === FOOTER_REL_TYPE2)
241860
- sourceRelByTarget.set(relTargetToWordPath(target).replace(/^word\//, ""), {
241861
- id: id2,
241862
- type
241863
- });
241890
+ if (type === HEADER_REL_TYPE2 || type === FOOTER_REL_TYPE2) {
241891
+ const sourceTarget = relTargetToWordPath(target).replace(/^word\//, "");
241892
+ const existing = sourceRelIdsByTarget.get(sourceTarget);
241893
+ if (existing)
241894
+ existing.push(id2);
241895
+ else
241896
+ sourceRelIdsByTarget.set(sourceTarget, [id2]);
241897
+ }
241864
241898
  }
241865
241899
  const setHeaderIdsArray = (idsHolder, relId) => {
241866
241900
  if (!Array.isArray(idsHolder.ids))
@@ -241951,12 +241985,12 @@ function importHeaderFooterAssets(editor, converter, byName, dryRun) {
241951
241985
  }
241952
241986
  });
241953
241987
  docRelsChanged = true;
241954
- const srcRel = sourceRelByTarget.get(sourceTarget);
241955
- if (srcRel) {
241956
- result.relIdRemap.set(srcRel.id, relId);
241988
+ const sourceRelIds = sourceRelIdsByTarget.get(sourceTarget) ?? [];
241989
+ for (const sourceRelId of sourceRelIds) {
241990
+ result.relIdRemap.set(sourceRelId, relId);
241957
241991
  result.mappings.push({
241958
241992
  kind: "relationship",
241959
- from: srcRel.id,
241993
+ from: sourceRelId,
241960
241994
  to: relId
241961
241995
  });
241962
241996
  }
@@ -242006,6 +242040,29 @@ function ensureContentTypeOverride$1(converter, partPath, contentType) {
242006
242040
  });
242007
242041
  return true;
242008
242042
  }
242043
+ function toSectionXmlElement(node2) {
242044
+ if (!node2.name)
242045
+ throw new Error("Expected named XML element.");
242046
+ return {
242047
+ type: node2.type,
242048
+ name: node2.name,
242049
+ attributes: node2.attributes ? { ...node2.attributes } : undefined,
242050
+ elements: node2.elements?.filter((child) => typeof child.name === "string").map((child) => toSectionXmlElement(child))
242051
+ };
242052
+ }
242053
+ function mergePageOneHeaderFooterModel(targetSectPr, sourceSectPr) {
242054
+ const mergedSectPr = ensureSectPrElement(targetSectPr);
242055
+ for (const kind of HEADER_FOOTER_KINDS2)
242056
+ for (const variant of HEADER_FOOTER_VARIANTS$2) {
242057
+ const sourceRef = getSectPrHeaderFooterRef(sourceSectPr, kind, variant);
242058
+ if (sourceRef)
242059
+ setSectPrHeaderFooterRef(mergedSectPr, kind, variant, sourceRef);
242060
+ else
242061
+ clearSectPrHeaderFooterRef(mergedSectPr, kind, variant);
242062
+ }
242063
+ writeSectPrTitlePage(mergedSectPr, readSectPrTitlePage(sourceSectPr));
242064
+ return mergedSectPr;
242065
+ }
242009
242066
  function applyPageOneSectionDefaults(editor, sourceDocumentXml, relIdRemap, parseXml2, dryRun) {
242010
242067
  const result = {
242011
242068
  detected: false,
@@ -242024,8 +242081,18 @@ function applyPageOneSectionDefaults(editor, sourceDocumentXml, relIdRemap, pars
242024
242081
  if (!sourceSectPr)
242025
242082
  return result;
242026
242083
  result.detected = true;
242027
- const sectPr = clone2(sourceSectPr);
242028
- rewriteSectPrRefs(sectPr, relIdRemap);
242084
+ let sectPr;
242085
+ try {
242086
+ const rewrittenSectPr = clone2(sourceSectPr);
242087
+ rewriteSectPrRefs(rewrittenSectPr, relIdRemap);
242088
+ sectPr = toSectionXmlElement(rewrittenSectPr);
242089
+ } catch {
242090
+ result.warnings.push({
242091
+ code: "SECTION_DEFAULTS_UNAVAILABLE",
242092
+ message: "Could not normalize the source page-1 sectPr."
242093
+ });
242094
+ return result;
242095
+ }
242029
242096
  let projections;
242030
242097
  try {
242031
242098
  projections = resolveSectionProjections(editor);
@@ -242036,26 +242103,43 @@ function applyPageOneSectionDefaults(editor, sourceDocumentXml, relIdRemap, pars
242036
242103
  });
242037
242104
  return result;
242038
242105
  }
242039
- const bodyProjection = [...projections].reverse().find((p$12) => p$12.target.kind === "body") ?? projections[projections.length - 1];
242040
- if (!bodyProjection) {
242106
+ if (projections.length === 0) {
242041
242107
  result.warnings.push({
242042
242108
  code: "SECTION_DEFAULTS_UNAVAILABLE",
242043
- message: "No body section projection found for page-1 sectPr adoption."
242109
+ message: "No section projections found for page-1 sectPr adoption."
242044
242110
  });
242045
242111
  return result;
242046
242112
  }
242047
- if (xmlDeepEqual(readTargetSectPr(editor, bodyProjection), sectPr))
242113
+ const bodyProjection = [...projections].reverse().find((projection) => projection.target.kind === "body") ?? projections[projections.length - 1];
242114
+ const sectionUpdates = projections.map((projection) => {
242115
+ const currentSectPr = readTargetSectPr(editor, projection);
242116
+ const nextSectPr = projection.sectionId === bodyProjection.sectionId ? clone2(sectPr) : mergePageOneHeaderFooterModel(currentSectPr, sectPr);
242117
+ if (xmlDeepEqual(currentSectPr, nextSectPr))
242118
+ return null;
242119
+ return {
242120
+ sectionId: projection.sectionId,
242121
+ nextSectPr
242122
+ };
242123
+ }).filter((update) => Boolean(update));
242124
+ if (sectionUpdates.length === 0)
242048
242125
  return result;
242049
242126
  result.changed = true;
242050
242127
  result.changedParts.push({
242051
242128
  part: "word/document.xml",
242052
242129
  scope: "sectionDefaults",
242053
- change: "replaced"
242130
+ change: sectionUpdates.some((update) => update.sectionId !== bodyProjection.sectionId) ? "merged" : "replaced"
242054
242131
  });
242055
242132
  if (dryRun)
242056
242133
  return result;
242057
242134
  try {
242058
- applySectPrToProjection(editor, bodyProjection, sectPr);
242135
+ for (let index2 = 0;index2 < sectionUpdates.length; index2 += 1) {
242136
+ const update = sectionUpdates[index2];
242137
+ const liveProjection = resolveSectionProjections(editor).find((projection) => projection.sectionId === update.sectionId);
242138
+ if (!liveProjection)
242139
+ throw new Error(`Section ${update.sectionId} disappeared during page-1 sectPr adoption.`);
242140
+ applySectPrToProjection(editor, liveProjection, clone2(update.nextSectPr), { addToHistory: index2 === sectionUpdates.length - 1 });
242141
+ }
242142
+ clearIndexCache(editor);
242059
242143
  result.applied = true;
242060
242144
  } catch (err) {
242061
242145
  result.changed = false;
@@ -242523,7 +242607,7 @@ async function applyTemplateAsync(editor, converter, input2, options) {
242523
242607
  });
242524
242608
  } else if (sec.detected) {
242525
242609
  warnings.push(...sec.warnings);
242526
- pushNoChangeSkip(skippedScopes, "sectionDefaults", "word/document.xml", sec.warnings.length > 0 ? "Source page-1 section defaults could not be applied." : "Source page-1 section defaults already match the active section defaults.");
242610
+ pushNoChangeSkip(skippedScopes, "sectionDefaults", "word/document.xml", sec.warnings.length > 0 ? "Source page-1 section defaults could not be applied." : "Source page-1 section defaults already match the current document's active section defaults and section header/footer visibility model.");
242527
242611
  }
242528
242612
  }
242529
242613
  if (styleMappings.length > 0)
@@ -285790,7 +285874,7 @@ var Node$13 = class Node$14 {
285790
285874
  }, getTrackedChangeText = ({ nodes, mark: mark2, trackedChangeType, isReplacement }) => {
285791
285875
  let trackedChangeText = "";
285792
285876
  let deletionText = "";
285793
- let trackedChangeDisplayType = null;
285877
+ let trackedChangeDisplayType$1 = null;
285794
285878
  if (trackedChangeType === "trackDelete" || isReplacement)
285795
285879
  deletionText = nodes.reduce((acc, node2) => {
285796
285880
  if (!node2.marks.find((nodeMark) => nodeMark.type.name === "trackDelete"))
@@ -285815,14 +285899,14 @@ var Node$13 = class Node$14 {
285815
285899
  });
285816
285900
  if (trackedFormatDisplay) {
285817
285901
  trackedChangeText = trackedFormatDisplay.trackedChangeText;
285818
- trackedChangeDisplayType = trackedFormatDisplay.trackedChangeDisplayType;
285902
+ trackedChangeDisplayType$1 = trackedFormatDisplay.trackedChangeDisplayType;
285819
285903
  } else
285820
285904
  trackedChangeText = translateFormatChangesToEnglish(normalizedFormatAttrs);
285821
285905
  }
285822
285906
  return {
285823
285907
  deletionText,
285824
285908
  trackedChangeText,
285825
- trackedChangeDisplayType
285909
+ trackedChangeDisplayType: trackedChangeDisplayType$1
285826
285910
  };
285827
285911
  }, createOrUpdateTrackedChangeComment = ({ event, marks, deletionNodes, nodes, newEditorState, documentId, trackedChangesForId }) => {
285828
285912
  const node2 = nodes[0];
@@ -285866,7 +285950,7 @@ var Node$13 = class Node$14 {
285866
285950
  nodesToUse = nodesWithMark.length ? nodesWithMark : node2 ? [node2] : [];
285867
285951
  if (!nodesToUse.length)
285868
285952
  return;
285869
- const { deletionText, trackedChangeText, trackedChangeDisplayType } = getTrackedChangeText({
285953
+ const { deletionText, trackedChangeText, trackedChangeDisplayType: trackedChangeDisplayType$1 } = getTrackedChangeText({
285870
285954
  nodes: nodesToUse,
285871
285955
  mark: trackedMark,
285872
285956
  trackedChangeType,
@@ -285882,7 +285966,7 @@ var Node$13 = class Node$14 {
285882
285966
  changeId: id2,
285883
285967
  trackedChangeType: isReplacement ? "both" : trackedChangeType,
285884
285968
  trackedChangeText,
285885
- trackedChangeDisplayType,
285969
+ trackedChangeDisplayType: trackedChangeDisplayType$1,
285886
285970
  deletedText: isReplacement || marks.deletionMark ? deletionText : null,
285887
285971
  author,
285888
285972
  ...authorId && { authorId },
@@ -299569,7 +299653,7 @@ var Node$13 = class Node$14 {
299569
299653
  listener(snapshot2);
299570
299654
  } catch {}
299571
299655
  }
299572
- }, projectedTrackedChangeCache, TRACK_MARK_TYPE_BY_NAME, EMITTABLE_BLOCK_TYPES, SDT_BLOCK_NODE_NAMES, REQUIRED_COMMANDS, VALID_CAPABILITY_REASON_CODES, REQUIRED_HELPERS, SCHEMA_NODE_GATES, schemaGatedIds, SUPPORTED_NON_UNIFORM_STRATEGIES, SUPPORTED_SET_MARKS, REGEX_MAX_PATTERN_LENGTH = 1024, STYLES_PART = "word/styles.xml", PROPERTIES_KEY_BY_CHANNEL, XML_PATH_BY_CHANNEL, UNDERLINE_API_TO_STORAGE, UNDERLINE_STORAGE_TO_API, HEX_SUBKEYS_BY_PROPERTY, import_jszip_min2, LAYOUT_AFFECTING_SETTING_NAMES, HEADER_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", IMAGE_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", HEADER_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml", FOOTER_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml", CONTENT_TYPES_PART$1 = "[Content_Types].xml", DOCUMENT_RELS_PART$1 = "word/_rels/document.xml.rels", SUBSTRATE_SCOPE_ORDER, CONTENT_TYPE_BY_SCOPE, REL_TYPE_BY_PART, CONTENT_TYPES_PART = "[Content_Types].xml", DOCUMENT_RELS_PART = "word/_rels/document.xml.rels", SUPPORTED_DELETE_NODE_TYPES2, REJECTED_DELETE_NODE_TYPES2, TEXT_PREVIEW_MAX_LENGTH = 80, RANGE_DELETE_SAFE_NODE_TYPES, HEADING_PATTERN, OOXML_DEFAULT_FONT_SIZE_PT = 10, INDENT_PER_LEVEL_TWIPS = 720, HANGING_INDENT_TWIPS = 360, SYMBOL_FONT_NAMES, RFONTS_FAMILY_ATTRS, ORDERED_PRESET_CONFIG, BULLET_PRESET_CONFIG, PRESET_TEMPLATES, LevelFormattingHelpers, PRESET_KIND_MAP, NUMBERING_PART = "word/numbering.xml", DEFAULT_PRESET_FOR_KIND, _setValueDelegate, PREVIEW_TEXT_MAX_LENGTH = 2000, BLOCK_PREVIEW_MAX_LENGTH = 200, EDGE_NODE_TYPES$1, COMMENT_MARK_NAME2 = "commentMark", TRACK_CHANGE_MARK_NAMES, POINTS_TO_PIXELS, POINTS_TO_TWIPS = 20, PIXELS_TO_TWIPS, DEFAULT_TABLE_GRID_WIDTH_TWIPS = 1500, SETTINGS_PART$1 = "word/settings.xml", PRESET_GREY = "999999", PRESET_BLACK = "000000", STATIC_PRESETS, IDENTITY_BLOCK_ATTRS, WORD_DEFAULT_TBL_LOOK, FLAG_TO_OOXML_KEY, INVERTED_FLAGS, XML_KEY_TO_STYLE_OPTION, CLEARED_BORDER_OOXML, TABLE_MARGIN_KEY_GROUPS, TABLE_ADAPTER_DISPATCH, ROW_TARGETED_TABLE_OPS, registered = false, STYLES_PART_ID = "word/styles.xml", stylesPartDescriptor, settingsPartDescriptor, RELS_PART_ID2 = "word/_rels/document.xml.rels", HEADER_RELATIONSHIP_TYPE$1 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_RELATIONSHIP_TYPE$1 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", relsPartDescriptor, BatchHistoryAdapter = class {
299656
+ }, projectedTrackedChangeCache, TRACK_MARK_TYPE_BY_NAME, EMITTABLE_BLOCK_TYPES, SDT_BLOCK_NODE_NAMES, REQUIRED_COMMANDS, VALID_CAPABILITY_REASON_CODES, REQUIRED_HELPERS, SCHEMA_NODE_GATES, schemaGatedIds, SUPPORTED_NON_UNIFORM_STRATEGIES, SUPPORTED_SET_MARKS, REGEX_MAX_PATTERN_LENGTH = 1024, STYLES_PART = "word/styles.xml", PROPERTIES_KEY_BY_CHANNEL, XML_PATH_BY_CHANNEL, UNDERLINE_API_TO_STORAGE, UNDERLINE_STORAGE_TO_API, HEX_SUBKEYS_BY_PROPERTY, import_jszip_min2, LAYOUT_AFFECTING_SETTING_NAMES, HEADER_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", IMAGE_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", HEADER_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml", FOOTER_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml", CONTENT_TYPES_PART$1 = "[Content_Types].xml", DOCUMENT_RELS_PART$1 = "word/_rels/document.xml.rels", HEADER_FOOTER_KINDS2, HEADER_FOOTER_VARIANTS$2, SUBSTRATE_SCOPE_ORDER, CONTENT_TYPE_BY_SCOPE, REL_TYPE_BY_PART, CONTENT_TYPES_PART = "[Content_Types].xml", DOCUMENT_RELS_PART = "word/_rels/document.xml.rels", SUPPORTED_DELETE_NODE_TYPES2, REJECTED_DELETE_NODE_TYPES2, TEXT_PREVIEW_MAX_LENGTH = 80, RANGE_DELETE_SAFE_NODE_TYPES, HEADING_PATTERN, OOXML_DEFAULT_FONT_SIZE_PT = 10, INDENT_PER_LEVEL_TWIPS = 720, HANGING_INDENT_TWIPS = 360, SYMBOL_FONT_NAMES, RFONTS_FAMILY_ATTRS, ORDERED_PRESET_CONFIG, BULLET_PRESET_CONFIG, PRESET_TEMPLATES, LevelFormattingHelpers, PRESET_KIND_MAP, NUMBERING_PART = "word/numbering.xml", DEFAULT_PRESET_FOR_KIND, _setValueDelegate, PREVIEW_TEXT_MAX_LENGTH = 2000, BLOCK_PREVIEW_MAX_LENGTH = 200, EDGE_NODE_TYPES$1, COMMENT_MARK_NAME2 = "commentMark", TRACK_CHANGE_MARK_NAMES, POINTS_TO_PIXELS, POINTS_TO_TWIPS = 20, PIXELS_TO_TWIPS, DEFAULT_TABLE_GRID_WIDTH_TWIPS = 1500, SETTINGS_PART$1 = "word/settings.xml", PRESET_GREY = "999999", PRESET_BLACK = "000000", STATIC_PRESETS, IDENTITY_BLOCK_ATTRS, WORD_DEFAULT_TBL_LOOK, FLAG_TO_OOXML_KEY, INVERTED_FLAGS, XML_KEY_TO_STYLE_OPTION, CLEARED_BORDER_OOXML, TABLE_MARGIN_KEY_GROUPS, TABLE_ADAPTER_DISPATCH, ROW_TARGETED_TABLE_OPS, registered = false, STYLES_PART_ID = "word/styles.xml", stylesPartDescriptor, settingsPartDescriptor, RELS_PART_ID2 = "word/_rels/document.xml.rels", HEADER_RELATIONSHIP_TYPE$1 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_RELATIONSHIP_TYPE$1 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", relsPartDescriptor, BatchHistoryAdapter = class {
299573
299657
  #done = [];
299574
299658
  #redone = [];
299575
299659
  #listeners = /* @__PURE__ */ new Set;
@@ -319338,13 +319422,13 @@ menclose::after {
319338
319422
  return;
319339
319423
  console.log(...args$1);
319340
319424
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions, TRACKED_MARK_NAMES;
319341
- var init_src_x_i3LADL_es = __esm(() => {
319425
+ var init_src_DEnygTyz_es = __esm(() => {
319342
319426
  init_rolldown_runtime_Bg48TavK_es();
319343
- init_SuperConverter_BVWG4qnQ_es();
319427
+ init_SuperConverter_DOoAJ6Zk_es();
319344
319428
  init_jszip_C49i9kUs_es();
319345
319429
  init_xml_js_CqGKpaft_es();
319346
319430
  init_uuid_qzgm05fK_es();
319347
- init_create_headless_toolbar_JvWvpCga_es();
319431
+ init_create_headless_toolbar_DUhzXJ4D_es();
319348
319432
  init_constants_D9qj59G2_es();
319349
319433
  init_dist_B8HfvhaK_es();
319350
319434
  init_unified_Dsuw2be5_es();
@@ -343013,6 +343097,12 @@ function print() { __p += __j.call(arguments, '') }
343013
343097
  "noPunctuationKerning",
343014
343098
  "kerning"
343015
343099
  ]);
343100
+ HEADER_FOOTER_KINDS2 = ["header", "footer"];
343101
+ HEADER_FOOTER_VARIANTS$2 = [
343102
+ "default",
343103
+ "first",
343104
+ "even"
343105
+ ];
343016
343106
  SUBSTRATE_SCOPE_ORDER = [
343017
343107
  "styles",
343018
343108
  "numbering",
@@ -354178,11 +354268,11 @@ function print() { __p += __j.call(arguments, '') }
354178
354268
  ]);
354179
354269
  });
354180
354270
 
354181
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-B66Edat2.es.js
354271
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CmcU7hTR.es.js
354182
354272
  var headlessToolbarConstants, MOD_ALIASES, ALT_ALIASES, CTRL_ALIASES, SHIFT_ALIASES, BUILTIN_CONTEXT_MENU_GROUPS, BUILTIN_GROUP_ORDER, RESERVED_PROXY_PROPERTY_NAMES, ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS;
354183
- var init_create_super_doc_ui_B66Edat2_es = __esm(() => {
354184
- init_SuperConverter_BVWG4qnQ_es();
354185
- init_create_headless_toolbar_JvWvpCga_es();
354273
+ var init_create_super_doc_ui_CmcU7hTR_es = __esm(() => {
354274
+ init_SuperConverter_DOoAJ6Zk_es();
354275
+ init_create_headless_toolbar_DUhzXJ4D_es();
354186
354276
  headlessToolbarConstants = {
354187
354277
  DEFAULT_TEXT_ALIGN_OPTIONS: [
354188
354278
  {
@@ -354464,16 +354554,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
354464
354554
 
354465
354555
  // ../../packages/superdoc/dist/super-editor.es.js
354466
354556
  var init_super_editor_es = __esm(() => {
354467
- init_src_x_i3LADL_es();
354468
- init_SuperConverter_BVWG4qnQ_es();
354557
+ init_src_DEnygTyz_es();
354558
+ init_SuperConverter_DOoAJ6Zk_es();
354469
354559
  init_jszip_C49i9kUs_es();
354470
354560
  init_xml_js_CqGKpaft_es();
354471
- init_create_headless_toolbar_JvWvpCga_es();
354561
+ init_create_headless_toolbar_DUhzXJ4D_es();
354472
354562
  init_constants_D9qj59G2_es();
354473
354563
  init_dist_B8HfvhaK_es();
354474
354564
  init_unified_Dsuw2be5_es();
354475
354565
  init_DocxZipper_Bu2Fhqkw_es();
354476
- init_create_super_doc_ui_B66Edat2_es();
354566
+ init_create_super_doc_ui_CmcU7hTR_es();
354477
354567
  init_ui_C5PAS9hY_es();
354478
354568
  init_eventemitter3_BnGqBE_Q_es();
354479
354569
  init_errors_CNaD6vcg_es();
@@ -358085,7 +358175,7 @@ More content with **bold** and *italic*.`
358085
358175
  "trackChanges.list": {
358086
358176
  memberPath: "trackChanges.list",
358087
358177
  description: "List all tracked changes in the document.",
358088
- expectedResult: "Returns a TrackChangesListResult with tracked change entries (`insert`, `delete`, `replacement`, `format`, `structural`), total count, and raw imported Word OOXML revision IDs (`w:id`) when available. Structural changes (whole-table insert/delete) carry a `subtype` of `table-insert` or `table-delete`.",
358178
+ expectedResult: "Returns a TrackChangesListResult with tracked change entries (`insert`, `delete`, `replacement`, `format`), total count, and raw imported Word OOXML revision IDs (`w:id`) when available. Whole-table tracked insertions and deletions are surfaced through the legacy `insert` / `delete` types.",
358089
358179
  requiresDocumentContext: true,
358090
358180
  metadata: readOperation2({
358091
358181
  idempotency: "idempotent",
@@ -358099,7 +358189,7 @@ More content with **bold** and *italic*.`
358099
358189
  "trackChanges.get": {
358100
358190
  memberPath: "trackChanges.get",
358101
358191
  description: "Retrieve a single tracked change by ID.",
358102
- expectedResult: "Returns a TrackChangeInfo object with the change type (`insert`, `delete`, `replacement`, `format`, `structural`), author, date, affected content, and raw imported Word OOXML revision IDs (`w:id`) when available. Structural changes (whole-table insert/delete) carry a `subtype` of `table-insert` or `table-delete`.",
358192
+ expectedResult: "Returns a TrackChangeInfo object with the change type (`insert`, `delete`, `replacement`, `format`), author, date, affected content, and raw imported Word OOXML revision IDs (`w:id`) when available. Whole-table tracked insertions and deletions are surfaced through the legacy `insert` / `delete` types.",
358103
358193
  requiresDocumentContext: true,
358104
358194
  metadata: readOperation2({
358105
358195
  idempotency: "idempotent",
@@ -358119,6 +358209,7 @@ More content with **bold** and *italic*.`
358119
358209
  supportsTrackedMode: false,
358120
358210
  possibleFailureCodes: [
358121
358211
  "NO_OP",
358212
+ "INVALID_INPUT",
358122
358213
  "INVALID_TARGET",
358123
358214
  "TARGET_NOT_FOUND",
358124
358215
  "CAPABILITY_UNAVAILABLE",
@@ -363460,7 +363551,7 @@ var init_schemas4 = __esm(() => {
363460
363551
  init_style_policy_types();
363461
363552
  init_paragraphs();
363462
363553
  init_styles();
363463
- trackChangeTypeValues2 = ["insert", "delete", "replacement", "format", "structural"];
363554
+ trackChangeTypeValues2 = ["insert", "delete", "replacement", "format"];
363464
363555
  nodeTypeValues2 = NODE_TYPES2;
363465
363556
  blockNodeTypeValues2 = BLOCK_NODE_TYPES2;
363466
363557
  deletableBlockNodeTypeValues2 = DELETABLE_BLOCK_NODE_TYPES2;
@@ -364230,10 +364321,6 @@ var init_schemas4 = __esm(() => {
364230
364321
  address: trackedChangeAddressSchema2,
364231
364322
  id: { type: "string" },
364232
364323
  type: { enum: [...trackChangeTypeValues2] },
364233
- subtype: {
364234
- enum: ["table-insert", "table-delete"],
364235
- description: "Finer classification for structural changes (type === 'structural')."
364236
- },
364237
364324
  grouping: { enum: ["standalone", "replacement-pair", "unknown"] },
364238
364325
  pairedWithChangeId: { type: ["string", "null"] },
364239
364326
  wordRevisionIds: trackChangeWordRevisionIdsSchema2,
@@ -364248,10 +364335,6 @@ var init_schemas4 = __esm(() => {
364248
364335
  trackChangeDomainItemSchema = discoveryItemSchema2({
364249
364336
  address: trackedChangeAddressSchema2,
364250
364337
  type: { enum: [...trackChangeTypeValues2] },
364251
- subtype: {
364252
- enum: ["table-insert", "table-delete"],
364253
- description: "Finer classification for structural changes (type === 'structural')."
364254
- },
364255
364338
  grouping: { enum: ["standalone", "replacement-pair", "unknown"] },
364256
364339
  pairedWithChangeId: { type: ["string", "null"] },
364257
364340
  wordRevisionIds: trackChangeWordRevisionIdsSchema2,
@@ -366565,7 +366648,7 @@ var init_schemas4 = __esm(() => {
366565
366648
  offset: { type: "integer", description: "Number of tracked changes to skip for pagination." },
366566
366649
  type: {
366567
366650
  enum: [...trackChangeTypeValues2],
366568
- description: "Filter by change type: 'insert', 'delete', 'replacement', 'format', or 'structural'."
366651
+ description: "Filter by change type: 'insert', 'delete', 'replacement', or 'format'."
366569
366652
  },
366570
366653
  in: {
366571
366654
  oneOf: [storyLocatorSchema2, { const: "all" }],
@@ -372270,7 +372353,7 @@ function assertHeaderFooterSlotTarget2(input2, operationName) {
372270
372353
  throw new DocumentApiValidationError3("INVALID_TARGET", `${operationName}.target must be a headerFooterSlot address.`, { field: `${operationName}.target`, value: target });
372271
372354
  }
372272
372355
  assertSectionAddress2(target.section, `${operationName}.target.section`);
372273
- assertOneOf3(target.headerFooterKind, `${operationName}.target.headerFooterKind`, HEADER_FOOTER_KINDS2);
372356
+ assertOneOf3(target.headerFooterKind, `${operationName}.target.headerFooterKind`, HEADER_FOOTER_KINDS3);
372274
372357
  assertOneOf3(target.variant, `${operationName}.target.variant`, HEADER_FOOTER_VARIANTS3);
372275
372358
  }
372276
372359
  function assertHeaderFooterPartTarget2(input2, operationName) {
@@ -372285,7 +372368,7 @@ function assertHeaderFooterPartTarget2(input2, operationName) {
372285
372368
  }
372286
372369
  function executeHeaderFootersList2(adapter, query2) {
372287
372370
  if (query2?.kind !== undefined) {
372288
- assertOneOf3(query2.kind, "headerFooters.list.kind", HEADER_FOOTER_KINDS2);
372371
+ assertOneOf3(query2.kind, "headerFooters.list.kind", HEADER_FOOTER_KINDS3);
372289
372372
  }
372290
372373
  if (query2?.section !== undefined) {
372291
372374
  assertSectionAddress2(query2.section, "headerFooters.list.section");
@@ -372316,12 +372399,12 @@ function executeHeaderFootersRefsSetLinkedToPrevious2(adapter, input2, options)
372316
372399
  }
372317
372400
  function executeHeaderFootersPartsList2(adapter, query2) {
372318
372401
  if (query2?.kind !== undefined) {
372319
- assertOneOf3(query2.kind, "headerFooters.parts.list.kind", HEADER_FOOTER_KINDS2);
372402
+ assertOneOf3(query2.kind, "headerFooters.parts.list.kind", HEADER_FOOTER_KINDS3);
372320
372403
  }
372321
372404
  return adapter.parts.list(query2);
372322
372405
  }
372323
372406
  function executeHeaderFootersPartsCreate2(adapter, input2, options) {
372324
- assertOneOf3(input2?.kind, "headerFooters.parts.create.kind", HEADER_FOOTER_KINDS2);
372407
+ assertOneOf3(input2?.kind, "headerFooters.parts.create.kind", HEADER_FOOTER_KINDS3);
372325
372408
  if (input2.sourceRefId !== undefined) {
372326
372409
  assertNonEmptyString3(input2.sourceRefId, "headerFooters.parts.create.sourceRefId");
372327
372410
  }
@@ -372331,11 +372414,11 @@ function executeHeaderFootersPartsDelete2(adapter, input2, options) {
372331
372414
  assertHeaderFooterPartTarget2(input2, "headerFooters.parts.delete");
372332
372415
  return adapter.parts.delete(input2, normalizeMutationOptions2(options));
372333
372416
  }
372334
- var HEADER_FOOTER_KINDS2, HEADER_FOOTER_VARIANTS3;
372417
+ var HEADER_FOOTER_KINDS3, HEADER_FOOTER_VARIANTS3;
372335
372418
  var init_header_footers = __esm(() => {
372336
372419
  init_errors5();
372337
372420
  init_validation_primitives();
372338
- HEADER_FOOTER_KINDS2 = ["header", "footer"];
372421
+ HEADER_FOOTER_KINDS3 = ["header", "footer"];
372339
372422
  HEADER_FOOTER_VARIANTS3 = ["default", "first", "even"];
372340
372423
  });
372341
372424
 
@@ -372475,7 +372558,7 @@ function normalizeSectionsListQuery2(query2) {
372475
372558
  return { limit: Number(limit), offset: Number(offset2) };
372476
372559
  }
372477
372560
  function validateHeaderFooterRefParams2(operationName, kind, variant) {
372478
- assertOneOf4(kind, `${operationName}.kind`, HEADER_FOOTER_KINDS3);
372561
+ assertOneOf4(kind, `${operationName}.kind`, HEADER_FOOTER_KINDS4);
372479
372562
  assertOneOf4(variant, `${operationName}.variant`, HEADER_FOOTER_VARIANTS4);
372480
372563
  }
372481
372564
  function executeSectionsList2(adapter, query2) {
@@ -372624,7 +372707,7 @@ function executeSectionsClearPageBorders2(adapter, input2, options) {
372624
372707
  assertSectionTarget2(input2, "sections.clearPageBorders");
372625
372708
  return adapter.clearPageBorders(input2, normalizeMutationOptions2(options));
372626
372709
  }
372627
- var DEFAULT_SECTIONS_LIST_LIMIT2 = 250, SECTION_BREAK_TYPES3, SECTION_ORIENTATIONS2, SECTION_VERTICAL_ALIGNS2, SECTION_DIRECTIONS2, HEADER_FOOTER_KINDS3, HEADER_FOOTER_VARIANTS4, LINE_NUMBER_RESTARTS2, PAGE_NUMBER_FORMATS2, PAGE_NUMBER_CHAPTER_SEPARATORS2, PAGE_BORDER_DISPLAYS2, PAGE_BORDER_OFFSET_FROM_VALUES2, PAGE_BORDER_Z_ORDER_VALUES2;
372710
+ var DEFAULT_SECTIONS_LIST_LIMIT2 = 250, SECTION_BREAK_TYPES3, SECTION_ORIENTATIONS2, SECTION_VERTICAL_ALIGNS2, SECTION_DIRECTIONS2, HEADER_FOOTER_KINDS4, HEADER_FOOTER_VARIANTS4, LINE_NUMBER_RESTARTS2, PAGE_NUMBER_FORMATS2, PAGE_NUMBER_CHAPTER_SEPARATORS2, PAGE_BORDER_DISPLAYS2, PAGE_BORDER_OFFSET_FROM_VALUES2, PAGE_BORDER_Z_ORDER_VALUES2;
372628
372711
  var init_sections = __esm(() => {
372629
372712
  init_errors5();
372630
372713
  init_validation_primitives();
@@ -372632,7 +372715,7 @@ var init_sections = __esm(() => {
372632
372715
  SECTION_ORIENTATIONS2 = ["portrait", "landscape"];
372633
372716
  SECTION_VERTICAL_ALIGNS2 = ["top", "center", "bottom", "both"];
372634
372717
  SECTION_DIRECTIONS2 = ["ltr", "rtl"];
372635
- HEADER_FOOTER_KINDS3 = ["header", "footer"];
372718
+ HEADER_FOOTER_KINDS4 = ["header", "footer"];
372636
372719
  HEADER_FOOTER_VARIANTS4 = ["default", "first", "even"];
372637
372720
  LINE_NUMBER_RESTARTS2 = ["continuous", "newPage", "newSection"];
372638
372721
  PAGE_NUMBER_FORMATS2 = [
@@ -388723,6 +388806,9 @@ function writeSectPrPageNumbering2(sectPr, numbering) {
388723
388806
  if (numbering.chapterSeparator !== undefined)
388724
388807
  setStringAttr2(pgNumType, "w:chapSep", numbering.chapterSeparator);
388725
388808
  }
388809
+ function readSectPrTitlePage2(sectPr) {
388810
+ return Boolean(findChild2(sectPr, "w:titlePg"));
388811
+ }
388726
388812
  function writeSectPrTitlePage2(sectPr, enabled) {
388727
388813
  if (enabled) {
388728
388814
  ensureChild2(sectPr, "w:titlePg");
@@ -451701,7 +451787,7 @@ function importCommentData2({ docx, editor, converter }) {
451701
451787
  const trackedChange = attributes["custom:trackedChange"] === "true";
451702
451788
  const trackedChangeType = attributes["custom:trackedChangeType"];
451703
451789
  const trackedChangeText = attributes["custom:trackedChangeText"] !== "null" ? attributes["custom:trackedChangeText"] : null;
451704
- const trackedChangeDisplayType = attributes["custom:trackedChangeDisplayType"] !== "null" ? attributes["custom:trackedChangeDisplayType"] : null;
451790
+ const trackedChangeDisplayType2 = attributes["custom:trackedChangeDisplayType"] !== "null" ? attributes["custom:trackedChangeDisplayType"] : null;
451705
451791
  const trackedDeletedText = attributes["custom:trackedDeletedText"] !== "null" ? attributes["custom:trackedDeletedText"] : null;
451706
451792
  const date6 = new Date(createdDate);
451707
451793
  const unixTimestampMs = date6.getTime();
@@ -451730,7 +451816,7 @@ function importCommentData2({ docx, editor, converter }) {
451730
451816
  trackedChange,
451731
451817
  trackedChangeText,
451732
451818
  trackedChangeType,
451733
- trackedChangeDisplayType,
451819
+ trackedChangeDisplayType: trackedChangeDisplayType2,
451734
451820
  trackedDeletedText,
451735
451821
  isDone: false,
451736
451822
  origin: converter?.documentOrigin || "word",
@@ -457547,6 +457633,15 @@ var enumerateStructuralRowChanges2 = (state) => {
457547
457633
  });
457548
457634
  }, stringOf2 = (value) => typeof value === "string" ? value : value == null ? "" : String(value);
457549
457635
 
457636
+ // ../../packages/super-editor/src/editors/v1/document-api-adapters/helpers/tracked-change-type-utils.ts
457637
+ function projectInternalTrackChangeType2(type, structural) {
457638
+ if (type !== "structural")
457639
+ return type;
457640
+ if (structural?.subtype === "table-delete" || structural?.side === "deletion")
457641
+ return "delete";
457642
+ return "insert";
457643
+ }
457644
+
457550
457645
  // ../../packages/super-editor/src/editors/v1/document-api-adapters/helpers/tracked-change-resolver.ts
457551
457646
  function rangesOverlap3(a2, b2) {
457552
457647
  return a2[0] < b2[1] && b2[0] < a2[1];
@@ -457655,17 +457750,18 @@ function buildPublicTrackedChangeIdMap2(grouped, replacements) {
457655
457750
  return publicIdByChange;
457656
457751
  }
457657
457752
  function layerFromChange2(change, relationship) {
457753
+ const type = resolveTrackedChangeType2(change);
457658
457754
  return {
457659
457755
  id: change.id,
457660
457756
  rawId: change.rawId,
457661
457757
  commandRawId: change.commandRawId,
457662
- type: resolveTrackedChangeType2(change),
457758
+ type: projectInternalTrackChangeType2(type, change.structural),
457663
457759
  relationship
457664
457760
  };
457665
457761
  }
457666
457762
  function compareOverlapChildren2(a2, b2) {
457667
- const aType = resolveTrackedChangeType2(a2);
457668
- const bType = resolveTrackedChangeType2(b2);
457763
+ const aType = projectInternalTrackChangeType2(resolveTrackedChangeType2(a2), a2.structural);
457764
+ const bType = projectInternalTrackChangeType2(resolveTrackedChangeType2(b2), b2.structural);
457669
457765
  if (aType !== bType) {
457670
457766
  if (aType === "delete")
457671
457767
  return -1;
@@ -472056,7 +472152,7 @@ function buildChangedTextFields2(type, excerpt) {
472056
472152
  }
472057
472153
  function buildProjectedInfo2(snapshot2, options = {}) {
472058
472154
  const id2 = options.id ?? snapshot2.address.entityId;
472059
- const type = options.type ?? snapshot2.type;
472155
+ const type = options.type ?? projectInternalTrackChangeType2(snapshot2.type, { subtype: snapshot2.subtype });
472060
472156
  return {
472061
472157
  info: {
472062
472158
  address: {
@@ -472065,7 +472161,6 @@ function buildProjectedInfo2(snapshot2, options = {}) {
472065
472161
  },
472066
472162
  id: id2,
472067
472163
  type,
472068
- ...type === "structural" && snapshot2.subtype ? { subtype: snapshot2.subtype } : {},
472069
472164
  grouping: options.grouping,
472070
472165
  pairedWithChangeId: options.pairedWithChangeId ?? undefined,
472071
472166
  wordRevisionIds: normalizeWordRevisionIds2(snapshot2.wordRevisionIds),
@@ -472098,7 +472193,7 @@ function replacementPairKey4(snapshot2) {
472098
472193
  return null;
472099
472194
  }
472100
472195
  function projectedSnapshotType2(snapshot2) {
472101
- return isCombinedReplacementSnapshot2(snapshot2) ? "replacement" : snapshot2.type;
472196
+ return isCombinedReplacementSnapshot2(snapshot2) ? "replacement" : projectInternalTrackChangeType2(snapshot2.type, { subtype: snapshot2.subtype });
472102
472197
  }
472103
472198
  function snapshotGrouping2(snapshot2) {
472104
472199
  return isCombinedReplacementSnapshot2(snapshot2) ? "replacement-pair" : "standalone";
@@ -472329,7 +472424,6 @@ function trackChangesListWrapper2(editor, input2) {
472329
472424
  const {
472330
472425
  address: address2,
472331
472426
  type,
472332
- subtype,
472333
472427
  grouping,
472334
472428
  pairedWithChangeId,
472335
472429
  wordRevisionIds,
@@ -472347,7 +472441,6 @@ function trackChangesListWrapper2(editor, input2) {
472347
472441
  return buildDiscoveryItem2(info.id, handle4, {
472348
472442
  address: address2,
472349
472443
  type,
472350
- ...subtype ? { subtype } : {},
472351
472444
  grouping,
472352
472445
  pairedWithChangeId,
472353
472446
  wordRevisionIds,
@@ -472393,7 +472486,8 @@ function trackChangesGetWrapper2(editor, input2) {
472393
472486
  const snapshot2 = snapshots.find((item) => item.anchorKey === anchorKey || item.address.entityId === baseId);
472394
472487
  if (snapshot2)
472395
472488
  return snapshotToInfo2(snapshot2);
472396
- const type = resolveTrackedChangeType2(resolved.change);
472489
+ const internalType = resolveTrackedChangeType2(resolved.change);
472490
+ const type = projectInternalTrackChangeType2(internalType, resolved.change.structural);
472397
472491
  const excerpt = (resolved.change.excerpt !== undefined ? resolved.change.excerpt : undefined) ?? normalizeExcerpt2(resolved.editor.state.doc.textBetween(resolved.change.from, resolved.change.to, " ", ""));
472398
472492
  const grouping = resolved.change.hasInsert && resolved.change.hasDelete && !resolved.change.hasFormat ? "replacement-pair" : undefined;
472399
472493
  return {
@@ -472405,7 +472499,6 @@ function trackChangesGetWrapper2(editor, input2) {
472405
472499
  },
472406
472500
  id: resolved.change.id,
472407
472501
  type,
472408
- ...type === "structural" && resolved.change.structural ? { subtype: resolved.change.structural.subtype } : {},
472409
472502
  grouping,
472410
472503
  wordRevisionIds: normalizeWordRevisionIds2(resolved.change.wordRevisionIds),
472411
472504
  overlap: resolved.change.overlap,
@@ -472668,12 +472761,20 @@ function isTrackedChangeCommentTargetShape2(target) {
472668
472761
  return false;
472669
472762
  return typeof value.trackedChangeId === "string" && value.trackedChangeId.length > 0;
472670
472763
  }
472764
+ function trackedChangeDisplayType2(snapshot2) {
472765
+ if (snapshot2.type !== "structural")
472766
+ return null;
472767
+ return snapshot2.subtype === "table-delete" ? "tableDelete" : "tableInsert";
472768
+ }
472769
+ function publicTrackedChangeType2(snapshot2) {
472770
+ return projectInternalTrackChangeType2(snapshot2.type, { subtype: snapshot2.subtype });
472771
+ }
472671
472772
  function buildTrackedChangeLink2(snapshot2) {
472672
472773
  const { trackedChangeText, deletedText } = trackedChangeTextFields2(snapshot2);
472673
472774
  return {
472674
472775
  trackedChange: true,
472675
- trackedChangeType: snapshot2.type,
472676
- trackedChangeDisplayType: null,
472776
+ trackedChangeType: publicTrackedChangeType2(snapshot2),
472777
+ trackedChangeDisplayType: trackedChangeDisplayType2(snapshot2),
472677
472778
  trackedChangeStory: snapshot2.story,
472678
472779
  trackedChangeAnchorKey: snapshot2.anchorKey,
472679
472780
  trackedChangeText,
@@ -472720,7 +472821,7 @@ function choosePreferredTrackedChangeSnapshot2(snapshots, preferredId) {
472720
472821
  const rightLength = Math.max(0, right2.range.to - right2.range.from);
472721
472822
  if (leftLength !== rightLength)
472722
472823
  return leftLength - rightLength;
472723
- const typeDelta = trackedChangeTypePriority2(left2.type) - trackedChangeTypePriority2(right2.type);
472824
+ const typeDelta = trackedChangeTypePriority2(publicTrackedChangeType2(left2)) - trackedChangeTypePriority2(publicTrackedChangeType2(right2));
472724
472825
  if (typeDelta !== 0)
472725
472826
  return typeDelta;
472726
472827
  if (left2.range.from !== right2.range.from)
@@ -472927,7 +473028,7 @@ function parseCreatedTime2(value) {
472927
473028
  }
472928
473029
  function trackedChangeTextFields2(snapshot2) {
472929
473030
  const excerpt = snapshot2.excerpt ?? "";
472930
- if (snapshot2.type === "delete") {
473031
+ if (publicTrackedChangeType2(snapshot2) === "delete") {
472931
473032
  return { trackedChangeText: "", deletedText: excerpt };
472932
473033
  }
472933
473034
  return { trackedChangeText: excerpt, deletedText: null };
@@ -472949,7 +473050,8 @@ function toTrackedChangeCommentInfo2(snapshot2) {
472949
473050
  anchoredText: snapshot2.excerpt,
472950
473051
  story: snapshot2.story,
472951
473052
  trackedChange: true,
472952
- trackedChangeType: snapshot2.type,
473053
+ trackedChangeType: publicTrackedChangeType2(snapshot2),
473054
+ trackedChangeDisplayType: trackedChangeDisplayType2(snapshot2),
472953
473055
  trackedChangeStory: snapshot2.story,
472954
473056
  trackedChangeAnchorKey: snapshot2.anchorKey,
472955
473057
  trackedChangeText,
@@ -473817,7 +473919,7 @@ function listCommentsHandler2(editor, query2) {
473817
473919
  story,
473818
473920
  trackedChange,
473819
473921
  trackedChangeType,
473820
- trackedChangeDisplayType,
473922
+ trackedChangeDisplayType: trackedChangeDisplayType3,
473821
473923
  trackedChangeStory,
473822
473924
  trackedChangeAnchorKey,
473823
473925
  trackedChangeText,
@@ -473839,7 +473941,7 @@ function listCommentsHandler2(editor, query2) {
473839
473941
  story,
473840
473942
  trackedChange,
473841
473943
  trackedChangeType,
473842
- trackedChangeDisplayType,
473944
+ trackedChangeDisplayType: trackedChangeDisplayType3,
473843
473945
  trackedChangeStory,
473844
473946
  trackedChangeAnchorKey,
473845
473947
  trackedChangeText,
@@ -480186,6 +480288,23 @@ function rewriteImportedStyleNumbering2(importedStyleEls, numRemap) {
480186
480288
  function numAttr2(el, attr) {
480187
480289
  return el.attributes?.[attr];
480188
480290
  }
480291
+ function reorderNumberingChildren2(numberingEl) {
480292
+ if (!numberingEl.elements)
480293
+ return;
480294
+ const other = [];
480295
+ const abstracts = [];
480296
+ const nums = [];
480297
+ for (const el of numberingEl.elements) {
480298
+ const ln = localName2(el);
480299
+ if (ln === "abstractNum")
480300
+ abstracts.push(el);
480301
+ else if (ln === "num")
480302
+ nums.push(el);
480303
+ else
480304
+ other.push(el);
480305
+ }
480306
+ numberingEl.elements = [...other, ...abstracts, ...nums];
480307
+ }
480189
480308
  function mergeNumberingGraph2(currentRoot, sourceRoot) {
480190
480309
  const result = { numRemap: new Map, abstractRemap: new Map, mappings: [] };
480191
480310
  const cur = rootElement2(currentRoot, "numbering");
@@ -480259,6 +480378,7 @@ function mergeNumberingGraph2(currentRoot, sourceRoot) {
480259
480378
  }
480260
480379
  cur.elements.push(next2);
480261
480380
  }
480381
+ reorderNumberingChildren2(cur);
480262
480382
  return result;
480263
480383
  }
480264
480384
  function reconcileSettings2(currentRoot, sourceRoot) {
@@ -480480,7 +480600,7 @@ function importHeaderFooterAssets2(editor, converter, byName, dryRun) {
480480
480600
  usedMedia.add(allocated);
480481
480601
  return allocated;
480482
480602
  };
480483
- const sourceRelByTarget = new Map;
480603
+ const sourceRelIdsByTarget = new Map;
480484
480604
  for (const rel of srcRelEls) {
480485
480605
  const type = rel.attributes?.Type;
480486
480606
  const target = rel.attributes?.Target;
@@ -480488,7 +480608,12 @@ function importHeaderFooterAssets2(editor, converter, byName, dryRun) {
480488
480608
  if (!type || !target || !id2)
480489
480609
  continue;
480490
480610
  if (type === HEADER_REL_TYPE4 || type === FOOTER_REL_TYPE4) {
480491
- sourceRelByTarget.set(relTargetToWordPath2(target).replace(/^word\//, ""), { id: id2, type });
480611
+ const sourceTarget = relTargetToWordPath2(target).replace(/^word\//, "");
480612
+ const existing = sourceRelIdsByTarget.get(sourceTarget);
480613
+ if (existing)
480614
+ existing.push(id2);
480615
+ else
480616
+ sourceRelIdsByTarget.set(sourceTarget, [id2]);
480492
480617
  }
480493
480618
  }
480494
480619
  const setHeaderIdsArray = (idsHolder, relId) => {
@@ -480573,10 +480698,10 @@ function importHeaderFooterAssets2(editor, converter, byName, dryRun) {
480573
480698
  }
480574
480699
  });
480575
480700
  docRelsChanged = true;
480576
- const srcRel = sourceRelByTarget.get(sourceTarget);
480577
- if (srcRel) {
480578
- result.relIdRemap.set(srcRel.id, relId);
480579
- result.mappings.push({ kind: "relationship", from: srcRel.id, to: relId });
480701
+ const sourceRelIds = sourceRelIdsByTarget.get(sourceTarget) ?? [];
480702
+ for (const sourceRelId of sourceRelIds) {
480703
+ result.relIdRemap.set(sourceRelId, relId);
480704
+ result.mappings.push({ kind: "relationship", from: sourceRelId, to: relId });
480580
480705
  }
480581
480706
  if (ensureContentTypeOverride2(converter, targetPartName, kind === "header" ? HEADER_CONTENT_TYPE2 : FOOTER_CONTENT_TYPE2)) {
480582
480707
  contentTypesChanged = true;
@@ -480618,6 +480743,32 @@ function ensureContentTypeOverride2(converter, partPath, contentType) {
480618
480743
  });
480619
480744
  return true;
480620
480745
  }
480746
+ function toSectionXmlElement2(node4) {
480747
+ if (!node4.name) {
480748
+ throw new Error("Expected named XML element.");
480749
+ }
480750
+ return {
480751
+ type: node4.type,
480752
+ name: node4.name,
480753
+ attributes: node4.attributes ? { ...node4.attributes } : undefined,
480754
+ elements: node4.elements?.filter((child) => typeof child.name === "string").map((child) => toSectionXmlElement2(child))
480755
+ };
480756
+ }
480757
+ function mergePageOneHeaderFooterModel2(targetSectPr, sourceSectPr) {
480758
+ const mergedSectPr = ensureSectPrElement2(targetSectPr);
480759
+ for (const kind of HEADER_FOOTER_KINDS5) {
480760
+ for (const variant of HEADER_FOOTER_VARIANTS5) {
480761
+ const sourceRef = getSectPrHeaderFooterRef2(sourceSectPr, kind, variant);
480762
+ if (sourceRef) {
480763
+ setSectPrHeaderFooterRef2(mergedSectPr, kind, variant, sourceRef);
480764
+ } else {
480765
+ clearSectPrHeaderFooterRef2(mergedSectPr, kind, variant);
480766
+ }
480767
+ }
480768
+ }
480769
+ writeSectPrTitlePage2(mergedSectPr, readSectPrTitlePage2(sourceSectPr));
480770
+ return mergedSectPr;
480771
+ }
480621
480772
  function applyPageOneSectionDefaults2(editor, sourceDocumentXml, relIdRemap, parseXml2, dryRun) {
480622
480773
  const result = {
480623
480774
  detected: false,
@@ -480636,8 +480787,18 @@ function applyPageOneSectionDefaults2(editor, sourceDocumentXml, relIdRemap, par
480636
480787
  if (!sourceSectPr)
480637
480788
  return result;
480638
480789
  result.detected = true;
480639
- const sectPr = clone3(sourceSectPr);
480640
- rewriteSectPrRefs2(sectPr, relIdRemap);
480790
+ let sectPr;
480791
+ try {
480792
+ const rewrittenSectPr = clone3(sourceSectPr);
480793
+ rewriteSectPrRefs2(rewrittenSectPr, relIdRemap);
480794
+ sectPr = toSectionXmlElement2(rewrittenSectPr);
480795
+ } catch {
480796
+ result.warnings.push({
480797
+ code: "SECTION_DEFAULTS_UNAVAILABLE",
480798
+ message: "Could not normalize the source page-1 sectPr."
480799
+ });
480800
+ return result;
480801
+ }
480641
480802
  let projections;
480642
480803
  try {
480643
480804
  projections = resolveSectionProjections2(editor);
@@ -480648,24 +480809,47 @@ function applyPageOneSectionDefaults2(editor, sourceDocumentXml, relIdRemap, par
480648
480809
  });
480649
480810
  return result;
480650
480811
  }
480651
- const bodyProjection = [...projections].reverse().find((p3) => p3.target.kind === "body") ?? projections[projections.length - 1];
480652
- if (!bodyProjection) {
480812
+ if (projections.length === 0) {
480653
480813
  result.warnings.push({
480654
480814
  code: "SECTION_DEFAULTS_UNAVAILABLE",
480655
- message: "No body section projection found for page-1 sectPr adoption."
480815
+ message: "No section projections found for page-1 sectPr adoption."
480656
480816
  });
480657
480817
  return result;
480658
480818
  }
480659
- const currentSectPr = readTargetSectPr2(editor, bodyProjection);
480660
- if (xmlDeepEqual2(currentSectPr, sectPr)) {
480819
+ const bodyProjection = [...projections].reverse().find((projection) => projection.target.kind === "body") ?? projections[projections.length - 1];
480820
+ const sectionUpdates = projections.map((projection) => {
480821
+ const currentSectPr = readTargetSectPr2(editor, projection);
480822
+ const nextSectPr = projection.sectionId === bodyProjection.sectionId ? clone3(sectPr) : mergePageOneHeaderFooterModel2(currentSectPr, sectPr);
480823
+ if (xmlDeepEqual2(currentSectPr, nextSectPr))
480824
+ return null;
480825
+ return {
480826
+ sectionId: projection.sectionId,
480827
+ nextSectPr
480828
+ };
480829
+ }).filter((update) => Boolean(update));
480830
+ if (sectionUpdates.length === 0) {
480661
480831
  return result;
480662
480832
  }
480663
480833
  result.changed = true;
480664
- result.changedParts.push({ part: "word/document.xml", scope: "sectionDefaults", change: "replaced" });
480834
+ result.changedParts.push({
480835
+ part: "word/document.xml",
480836
+ scope: "sectionDefaults",
480837
+ change: sectionUpdates.some((update) => update.sectionId !== bodyProjection.sectionId) ? "merged" : "replaced"
480838
+ });
480665
480839
  if (dryRun)
480666
480840
  return result;
480667
480841
  try {
480668
- applySectPrToProjection3(editor, bodyProjection, sectPr);
480842
+ for (let index3 = 0;index3 < sectionUpdates.length; index3 += 1) {
480843
+ const update = sectionUpdates[index3];
480844
+ const liveProjection = resolveSectionProjections2(editor).find((projection) => projection.sectionId === update.sectionId);
480845
+ if (!liveProjection) {
480846
+ throw new Error(`Section ${update.sectionId} disappeared during page-1 sectPr adoption.`);
480847
+ }
480848
+ applySectPrToProjection3(editor, liveProjection, clone3(update.nextSectPr), {
480849
+ addToHistory: index3 === sectionUpdates.length - 1
480850
+ });
480851
+ }
480852
+ clearIndexCache2(editor);
480669
480853
  result.applied = true;
480670
480854
  } catch (err) {
480671
480855
  result.changed = false;
@@ -480677,13 +480861,17 @@ function applyPageOneSectionDefaults2(editor, sourceDocumentXml, relIdRemap, par
480677
480861
  }
480678
480862
  return result;
480679
480863
  }
480680
- var HEADER_REL_TYPE4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_REL_TYPE4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", IMAGE_REL_TYPE4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", HEADER_CONTENT_TYPE2 = "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml", FOOTER_CONTENT_TYPE2 = "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml", CONTENT_TYPES_PART2 = "[Content_Types].xml", DOCUMENT_RELS_PART2 = "word/_rels/document.xml.rels";
480864
+ var HEADER_REL_TYPE4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_REL_TYPE4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", IMAGE_REL_TYPE4 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", HEADER_CONTENT_TYPE2 = "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml", FOOTER_CONTENT_TYPE2 = "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml", CONTENT_TYPES_PART2 = "[Content_Types].xml", DOCUMENT_RELS_PART2 = "word/_rels/document.xml.rels", HEADER_FOOTER_KINDS5, HEADER_FOOTER_VARIANTS5;
480681
480865
  var init_template_assets = __esm(() => {
480682
480866
  init_template_xml();
480683
480867
  init_read_package();
480684
480868
  init_sections_resolver();
480685
480869
  init_section_mutation_wrapper();
480686
480870
  init_section_projection_access();
480871
+ init_index_cache();
480872
+ init_sections_xml();
480873
+ HEADER_FOOTER_KINDS5 = ["header", "footer"];
480874
+ HEADER_FOOTER_VARIANTS5 = ["default", "first", "even"];
480687
480875
  });
480688
480876
 
480689
480877
  // ../../packages/super-editor/src/editors/v1/document-api-adapters/templates/templates-adapter.ts
@@ -481069,7 +481257,7 @@ async function applyTemplateAsync2(editor, converter, input2, options) {
481069
481257
  appliedScopes.push({ scope: "sectionDefaults", part: "word/document.xml" });
481070
481258
  } else if (sec.detected) {
481071
481259
  warnings.push(...sec.warnings);
481072
- pushNoChangeSkip2(skippedScopes, "sectionDefaults", "word/document.xml", sec.warnings.length > 0 ? "Source page-1 section defaults could not be applied." : "Source page-1 section defaults already match the active section defaults.");
481260
+ pushNoChangeSkip2(skippedScopes, "sectionDefaults", "word/document.xml", sec.warnings.length > 0 ? "Source page-1 section defaults could not be applied." : "Source page-1 section defaults already match the current document's active section defaults and section header/footer visibility model.");
481073
481261
  }
481074
481262
  }
481075
481263
  if (styleMappings.length > 0)
@@ -508856,10 +509044,9 @@ EXAMPLES:
508856
509044
  "insert",
508857
509045
  "delete",
508858
509046
  "replacement",
508859
- "format",
508860
- "structural"
509047
+ "format"
508861
509048
  ],
508862
- description: "Filter by change type: 'insert', 'delete', 'replacement', 'format', or 'structural'. Only for action 'list'. Omit for other actions."
509049
+ description: "Filter by change type: 'insert', 'delete', 'replacement', or 'format'. Only for action 'list'. Omit for other actions."
508863
509050
  },
508864
509051
  force: {
508865
509052
  type: "boolean",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/mcp",
3
- "version": "0.11.0-next.14",
3
+ "version": "0.11.0-next.15",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -19,9 +19,9 @@
19
19
  "@types/bun": "^1.3.8",
20
20
  "@types/node": "22.19.2",
21
21
  "typescript": "^5.9.2",
22
- "@superdoc/document-api": "0.0.1",
23
22
  "@superdoc/super-editor": "0.0.1",
24
- "superdoc": "1.38.0"
23
+ "superdoc": "1.38.0",
24
+ "@superdoc/document-api": "0.0.1"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public"