@superdoc-dev/mcp 0.3.0-next.74 → 0.3.0-next.76

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 +141 -53
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -51891,7 +51891,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
51891
51891
  emptyOptions2 = {};
51892
51892
  });
51893
51893
 
51894
- // ../../packages/superdoc/dist/chunks/SuperConverter-CcvDw1Yc.es.js
51894
+ // ../../packages/superdoc/dist/chunks/SuperConverter-BInxZk0I.es.js
51895
51895
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
51896
51896
  const fieldValue = extension$1.config[field];
51897
51897
  if (typeof fieldValue === "function")
@@ -104209,12 +104209,22 @@ var isRegExp = (value) => {
104209
104209
  if (rawValue == null)
104210
104210
  return true;
104211
104211
  return ST_ON_OFF_TRUE_VALUES.has(String(rawValue).trim().toLowerCase());
104212
+ }, resolveEvenAndOddHeadersFromSettingsPart = (settingsPart) => {
104213
+ if (!settingsPart || typeof settingsPart !== "object")
104214
+ return null;
104215
+ const part = settingsPart;
104216
+ const settingsRoot = part.name === "w:settings" ? part : part.elements?.find((entry) => entry?.name === "w:settings");
104217
+ if (!settingsRoot?.elements?.length)
104218
+ return null;
104219
+ const evenOdd = settingsRoot.elements.find((el) => el?.name === "w:evenAndOddHeaders");
104220
+ if (!evenOdd)
104221
+ return null;
104222
+ return isStOnOffEnabled(evenOdd);
104212
104223
  }, isAlternatingHeadersOddEven = (docx) => {
104213
104224
  const settings = docx["word/settings.xml"];
104214
- if (!settings || !settings.elements?.length)
104225
+ if (!settings)
104215
104226
  return false;
104216
- const { elements = [] } = settings.elements[0];
104217
- return isStOnOffEnabled(elements.find((el) => el.name === "w:evenAndOddHeaders"));
104227
+ return resolveEvenAndOddHeadersFromSettingsPart(settings) ?? false;
104218
104228
  }, FULL_WIDTH_PT = "468pt", FULL_WIDTH_PT_VALUE = 468, PX_PER_PT = 1.33, XML_NODE_NAME = "w:pict", SD_NODE_NAME, validXmlAttributes, config2, translator$29, DEFAULT_SECTION_PROPS_TWIPS, ensureSectionLayoutDefaults = (sectPr, converter) => {
104219
104229
  if (!sectPr)
104220
104230
  return {
@@ -105076,7 +105086,7 @@ var isRegExp = (value) => {
105076
105086
  state.kern = kernNode.attributes["w:val"];
105077
105087
  }
105078
105088
  }, SuperConverter;
105079
- var init_SuperConverter_CcvDw1Yc_es = __esm(() => {
105089
+ var init_SuperConverter_BInxZk0I_es = __esm(() => {
105080
105090
  init_rolldown_runtime_Bg48TavK_es();
105081
105091
  init_jszip_C49i9kUs_es();
105082
105092
  init_xml_js_CqGKpaft_es();
@@ -142945,7 +142955,7 @@ var init_SuperConverter_CcvDw1Yc_es = __esm(() => {
142945
142955
  };
142946
142956
  });
142947
142957
 
142948
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-D5yv7LyN.es.js
142958
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-rUh3xIsa.es.js
142949
142959
  function parseSizeUnit(val = "0") {
142950
142960
  const length = val.toString() || "0";
142951
142961
  const value = Number.parseFloat(length);
@@ -145612,8 +145622,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
145612
145622
  }
145613
145623
  };
145614
145624
  };
145615
- var init_create_headless_toolbar_D5yv7LyN_es = __esm(() => {
145616
- init_SuperConverter_CcvDw1Yc_es();
145625
+ var init_create_headless_toolbar_rUh3xIsa_es = __esm(() => {
145626
+ init_SuperConverter_BInxZk0I_es();
145617
145627
  init_constants_DrU4EASo_es();
145618
145628
  init_dist_B8HfvhaK_es();
145619
145629
  CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
@@ -199832,7 +199842,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
199832
199842
  init_remark_gfm_BhnWr3yf_es();
199833
199843
  });
199834
199844
 
199835
- // ../../packages/superdoc/dist/chunks/src-BpYr_7Wm.es.js
199845
+ // ../../packages/superdoc/dist/chunks/src-BdpJXQ5F.es.js
199836
199846
  function deleteProps(obj, propOrProps) {
199837
199847
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
199838
199848
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -237048,11 +237058,12 @@ function resolveBookmarkTarget(doc$12, target) {
237048
237058
  function nodePositionToPosition(doc$12, pos) {
237049
237059
  const resolved = doc$12.resolve(pos);
237050
237060
  for (let depth = resolved.depth;depth >= 0; depth--) {
237051
- const blockId = resolved.node(depth).attrs?.sdBlockId;
237061
+ const node2 = resolved.node(depth);
237062
+ const blockId = node2.attrs?.sdBlockId;
237052
237063
  if (blockId)
237053
237064
  return {
237054
237065
  blockId,
237055
- offset: pos - resolved.start(depth)
237066
+ offset: pmPositionToTextOffset(node2, resolved.start(depth) - 1, pos)
237056
237067
  };
237057
237068
  }
237058
237069
  return {
@@ -237504,11 +237515,12 @@ function protectionClearEditingRestrictionAdapter(editor, _input, options) {
237504
237515
  function pmPosToPosition(doc$12, pos) {
237505
237516
  const resolved = doc$12.resolve(pos);
237506
237517
  for (let depth = resolved.depth;depth >= 0; depth--) {
237507
- const blockId = resolved.node(depth).attrs?.sdBlockId;
237518
+ const node2 = resolved.node(depth);
237519
+ const blockId = node2.attrs?.sdBlockId;
237508
237520
  if (blockId)
237509
237521
  return {
237510
237522
  blockId,
237511
- offset: pos - resolved.start(depth)
237523
+ offset: pmPositionToTextOffset(node2, resolved.start(depth) - 1, pos)
237512
237524
  };
237513
237525
  }
237514
237526
  return {
@@ -254658,7 +254670,7 @@ function extractCellPadding(cellAttrs) {
254658
254670
  return;
254659
254671
  return normalizeCellPaddingTopBottom(padding);
254660
254672
  }
254661
- function textNodeToRun({ node: node2, positions, storyKey, defaultFont, defaultSize, inheritedMarks = [], sdtMetadata, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors, enableComments, runProperties, converterContext }) {
254673
+ function textNodeToRun({ node: node2, positions, storyKey, defaultFont, defaultSize, inheritedMarks = [], sdtMetadata, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors, enableComments, runProperties, inlineRunProperties, converterContext }) {
254662
254674
  let run2 = {
254663
254675
  text: node2.text || "",
254664
254676
  fontFamily: defaultFont,
@@ -254672,7 +254684,7 @@ function textNodeToRun({ node: node2, positions, storyKey, defaultFont, defaultS
254672
254684
  applyMarksToRun(run2, [...node2.marks ?? [], ...inheritedMarks ?? []], hyperlinkConfig, themeColors, converterContext?.backgroundColor, enableComments, storyKey);
254673
254685
  if (sdtMetadata)
254674
254686
  run2.sdt = sdtMetadata;
254675
- run2 = applyInlineRunProperties(run2, runProperties, converterContext);
254687
+ run2 = applyInlineRunProperties(run2, runProperties, converterContext, inlineRunProperties);
254676
254688
  return run2;
254677
254689
  }
254678
254690
  function buildReferenceMarkerRun(displayText, params$1) {
@@ -254705,7 +254717,7 @@ function runNodeChildrenToRuns({ node: node2, inheritedMarks, sdtMetadata, conve
254705
254717
  if (runProperties.vanish)
254706
254718
  throw new HiddenByVanishError;
254707
254719
  const resolvedRunProperties = resolveRunProperties(converterContext, runProperties, paragraphProperties, converterContext.tableInfo, false, false);
254708
- node2.content?.forEach((child) => visitNode(child, mergedMarks, sdtMetadata, resolvedRunProperties, false));
254720
+ node2.content?.forEach((child) => visitNode(child, mergedMarks, sdtMetadata, resolvedRunProperties, false, runProperties));
254709
254721
  }
254710
254722
  function resolveSdtMetadata(input2) {
254711
254723
  if (!input2)
@@ -255478,12 +255490,12 @@ function handleTableOfAuthoritiesNode(node2, context) {
255478
255490
  sectionState.currentParagraphIndex++;
255479
255491
  });
255480
255492
  }
255481
- function structuredContentNodeToBlocks({ node: node2, inheritedMarks, sdtMetadata, visitNode, runProperties }) {
255493
+ function structuredContentNodeToBlocks({ node: node2, inheritedMarks, sdtMetadata, visitNode, runProperties, inlineRunProperties }) {
255482
255494
  const nextSdt = resolveNodeSdtMetadata(node2, "structuredContent") ?? sdtMetadata;
255483
- node2.content?.forEach((child) => visitNode(child, inheritedMarks, nextSdt, runProperties, false));
255495
+ node2.content?.forEach((child) => visitNode(child, inheritedMarks, nextSdt, runProperties, false, inlineRunProperties));
255484
255496
  }
255485
255497
  function pageReferenceNodeToBlock(params$1) {
255486
- const { node: node2, inheritedMarks, visitNode, sdtMetadata, positions, converterContext, paragraphProperties } = params$1;
255498
+ const { node: node2, inheritedMarks, visitNode, sdtMetadata, positions, converterContext, paragraphProperties, inlineRunProperties: parentInlineRunProperties } = params$1;
255487
255499
  const instruction = getNodeInstruction(node2) || "";
255488
255500
  const nodeAttrs = typeof node2.attrs === "object" && node2.attrs !== null ? node2.attrs : {};
255489
255501
  const mergedMarks = [...Array.isArray(nodeAttrs.marksAsAttrs) ? nodeAttrs.marksAsAttrs : [], ...inheritedMarks ?? []];
@@ -255513,7 +255525,8 @@ function pageReferenceNodeToBlock(params$1) {
255513
255525
  text: fallbackText
255514
255526
  },
255515
255527
  inheritedMarks: mergedMarks,
255516
- runProperties: resolvedRunProperties
255528
+ runProperties: resolvedRunProperties,
255529
+ inlineRunProperties: runProperties
255517
255530
  });
255518
255531
  if (pageRefPos) {
255519
255532
  tokenRun.pmStart = pageRefPos.start;
@@ -255537,7 +255550,7 @@ function pageReferenceNodeToBlock(params$1) {
255537
255550
  tokenRun.sdt = sdtMetadata;
255538
255551
  return tokenRun;
255539
255552
  } else if (Array.isArray(node2.content))
255540
- node2.content.forEach((child) => visitNode(child, mergedMarks, sdtMetadata, runProperties));
255553
+ node2.content.forEach((child) => visitNode(child, mergedMarks, sdtMetadata, runProperties, false, parentInlineRunProperties));
255541
255554
  }
255542
255555
  function fieldAnnotationNodeToRun({ node: node2, positions }) {
255543
255556
  const fieldMetadata = resolveNodeSdtMetadata(node2, "fieldAnnotation");
@@ -255640,7 +255653,7 @@ function fieldAnnotationNodeToRun({ node: node2, positions }) {
255640
255653
  return run2;
255641
255654
  }
255642
255655
  function bookmarkStartNodeToBlocks(params$1) {
255643
- const { node: node2, positions, bookmarks, visitNode, inheritedMarks, sdtMetadata, runProperties, converterContext } = params$1;
255656
+ const { node: node2, positions, bookmarks, visitNode, inheritedMarks, sdtMetadata, runProperties, inlineRunProperties, converterContext } = params$1;
255644
255657
  const nodeAttrs = typeof node2.attrs === "object" && node2.attrs !== null ? node2.attrs : {};
255645
255658
  const bookmarkName = typeof nodeAttrs.name === "string" ? nodeAttrs.name : undefined;
255646
255659
  if (bookmarkName && bookmarks) {
@@ -255670,7 +255683,7 @@ function bookmarkStartNodeToBlocks(params$1) {
255670
255683
  converterContext.renderedBookmarkIds.add(bookmarkId);
255671
255684
  }
255672
255685
  if (Array.isArray(node2.content))
255673
- node2.content.forEach((child) => visitNode(child, inheritedMarks, sdtMetadata, runProperties));
255686
+ node2.content.forEach((child) => visitNode(child, inheritedMarks, sdtMetadata, runProperties, false, inlineRunProperties));
255674
255687
  return run2;
255675
255688
  }
255676
255689
  function bookmarkEndNodeToRun(params$1) {
@@ -255720,7 +255733,7 @@ function tabNodeToRun({ node: node2, positions, storyKey, tabOrdinal, paragraphA
255720
255733
  applyMarksToRun(run2, marks, undefined, undefined, undefined, true, storyKey);
255721
255734
  return run2;
255722
255735
  }
255723
- function noBreakHyphenNodeToRun({ node: node2, positions, storyKey, defaultFont, defaultSize, inheritedMarks = [], sdtMetadata, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors, enableComments, runProperties, converterContext }) {
255736
+ function noBreakHyphenNodeToRun({ node: node2, positions, storyKey, defaultFont, defaultSize, inheritedMarks = [], sdtMetadata, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors, enableComments, runProperties, inlineRunProperties, converterContext }) {
255724
255737
  let run2 = {
255725
255738
  text: NON_BREAKING_HYPHEN,
255726
255739
  fontFamily: defaultFont,
@@ -255734,14 +255747,14 @@ function noBreakHyphenNodeToRun({ node: node2, positions, storyKey, defaultFont,
255734
255747
  applyMarksToRun(run2, [...node2.marks ?? [], ...inheritedMarks ?? []], hyperlinkConfig, themeColors, converterContext?.backgroundColor, enableComments, storyKey);
255735
255748
  if (sdtMetadata)
255736
255749
  run2.sdt = sdtMetadata;
255737
- run2 = applyInlineRunProperties(run2, runProperties, converterContext);
255750
+ run2 = applyInlineRunProperties(run2, runProperties, converterContext, inlineRunProperties);
255738
255751
  return run2;
255739
255752
  }
255740
- function tokenNodeToRun({ node: node2, positions, storyKey, defaultFont, defaultSize, inheritedMarks, hyperlinkConfig, themeColors, sdtMetadata, runProperties, converterContext }) {
255753
+ function tokenNodeToRun({ node: node2, positions, storyKey, defaultFont, defaultSize, inheritedMarks, hyperlinkConfig, themeColors, sdtMetadata, runProperties, inlineRunProperties, converterContext }) {
255741
255754
  const token$1 = TOKEN_INLINE_TYPES.get(node2.type);
255742
255755
  if (!token$1)
255743
255756
  return null;
255744
- const run2 = {
255757
+ let run2 = {
255745
255758
  text: "0",
255746
255759
  token: token$1,
255747
255760
  fontFamily: defaultFont,
@@ -255754,8 +255767,9 @@ function tokenNodeToRun({ node: node2, positions, storyKey, defaultFont, default
255754
255767
  }
255755
255768
  const nodeMarks = node2.marks ?? [];
255756
255769
  const marksAsAttrs = Array.isArray(node2.attrs?.marksAsAttrs) ? node2.attrs.marksAsAttrs : [];
255757
- applyMarksToRun(run2, [...nodeMarks.length > 0 ? nodeMarks : marksAsAttrs, ...inheritedMarks ?? []], hyperlinkConfig, themeColors, undefined, true, storyKey);
255758
- applyInlineRunProperties(run2, runProperties, converterContext);
255770
+ const marks = [...nodeMarks.length > 0 ? nodeMarks : marksAsAttrs, ...inheritedMarks ?? []];
255771
+ applyMarksToRun(run2, marks, hyperlinkConfig, themeColors, undefined, true, storyKey);
255772
+ run2 = applyInlineRunProperties(run2, runProperties, converterContext, inlineRunProperties);
255759
255773
  if (marksAsAttrs.length > 0)
255760
255774
  run2._explicitFont = true;
255761
255775
  if (sdtMetadata)
@@ -256746,7 +256760,7 @@ function paragraphToFlowBlocks({ para, nextBlockId, positions, storyKey, tracked
256746
256760
  });
256747
256761
  partIndex += 1;
256748
256762
  };
256749
- const visitNode = (node2, inheritedMarks = [], activeSdt, activeRunProperties, activeHidden = false) => {
256763
+ const visitNode = (node2, inheritedMarks = [], activeSdt, activeRunProperties, activeHidden = false, activeInlineRunProperties) => {
256750
256764
  if (activeHidden && node2.type !== "run") {
256751
256765
  suppressedByVanish = true;
256752
256766
  return;
@@ -256765,6 +256779,7 @@ function paragraphToFlowBlocks({ para, nextBlockId, positions, storyKey, tracked
256765
256779
  themeColors,
256766
256780
  enableComments,
256767
256781
  runProperties: activeRunProperties,
256782
+ inlineRunProperties: activeInlineRunProperties,
256768
256783
  paragraphProperties: resolvedParagraphProperties,
256769
256784
  converterContext,
256770
256785
  visitNode,
@@ -287363,7 +287378,31 @@ menclose::after {
287363
287378
  if (!normalizedExisting || isAutoColorValue || isDefaultBlack)
287364
287379
  run2.color = resolveAutoColor(backgroundColor);
287365
287380
  }
287366
- }, HiddenByVanishError, NotInlineNodeError, applyInlineRunProperties = (run2, runProperties, converterContext) => {
287381
+ }, HiddenByVanishError, NotInlineNodeError, buildBidiContext = (runProperties) => {
287382
+ if (runProperties.rtl == null)
287383
+ return;
287384
+ return { rtl: runProperties.rtl === true };
287385
+ }, buildScriptContext = (runProperties) => {
287386
+ const cs = runProperties.cs;
287387
+ const lang = runProperties.lang;
287388
+ const hasLang = lang != null && (lang.val != null || lang.bidi != null || lang.eastAsia != null);
287389
+ if (cs == null && !hasLang)
287390
+ return;
287391
+ const ctx$1 = {};
287392
+ if (cs != null)
287393
+ ctx$1.complexScript = cs === true;
287394
+ if (hasLang) {
287395
+ const language = {};
287396
+ if (lang.val != null)
287397
+ language.default = lang.val;
287398
+ if (lang.bidi != null)
287399
+ language.complexScript = lang.bidi;
287400
+ if (lang.eastAsia != null)
287401
+ language.eastAsian = lang.eastAsia;
287402
+ ctx$1.language = language;
287403
+ }
287404
+ return ctx$1;
287405
+ }, applyInlineRunProperties = (run2, runProperties, converterContext, inlineRunProperties) => {
287367
287406
  if (!runProperties)
287368
287407
  return run2;
287369
287408
  const runAttrs = computeRunAttrs(runProperties, converterContext);
@@ -287371,6 +287410,14 @@ menclose::after {
287371
287410
  for (const key2 of Object.keys(runAttrs))
287372
287411
  if (runAttrs[key2] !== undefined)
287373
287412
  merged[key2] = runAttrs[key2];
287413
+ if (inlineRunProperties) {
287414
+ const bidi = buildBidiContext(inlineRunProperties);
287415
+ if (bidi)
287416
+ merged.bidi = bidi;
287417
+ const script = buildScriptContext(inlineRunProperties);
287418
+ if (script)
287419
+ merged.script = script;
287420
+ }
287374
287421
  return merged;
287375
287422
  }, buildSyntheticTextNode = (displayText, marks) => ({
287376
287423
  type: "text",
@@ -291791,8 +291838,8 @@ menclose::after {
291791
291838
  get manager() {
291792
291839
  return this.#headerFooterManager;
291793
291840
  }
291794
- refreshStructure() {
291795
- this.#headerFooterManager?.refresh();
291841
+ refreshStructure(options) {
291842
+ this.#headerFooterManager?.refresh(options?.purgeCachedEditors ? { purgeCachedEditors: true } : undefined);
291796
291843
  this.#headerFooterAdapter?.invalidateAll();
291797
291844
  }
291798
291845
  invalidateLayoutForRefs(refIds) {
@@ -293385,12 +293432,12 @@ menclose::after {
293385
293432
  return;
293386
293433
  console.log(...args$1);
293387
293434
  }, 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;
293388
- var init_src_BpYr_7Wm_es = __esm(() => {
293435
+ var init_src_BdpJXQ5F_es = __esm(() => {
293389
293436
  init_rolldown_runtime_Bg48TavK_es();
293390
- init_SuperConverter_CcvDw1Yc_es();
293437
+ init_SuperConverter_BInxZk0I_es();
293391
293438
  init_jszip_C49i9kUs_es();
293392
293439
  init_uuid_qzgm05fK_es();
293393
- init_create_headless_toolbar_D5yv7LyN_es();
293440
+ init_create_headless_toolbar_rUh3xIsa_es();
293394
293441
  init_constants_DrU4EASo_es();
293395
293442
  init_dist_B8HfvhaK_es();
293396
293443
  init_unified_Dsuw2be5_es();
@@ -319559,6 +319606,7 @@ function print() { __p += __j.call(arguments, '') }
319559
319606
  this.#insertNewFileData();
319560
319607
  if (!this.options.ydoc)
319561
319608
  this.#initComments();
319609
+ this.emit("documentReplaced", { editor: this });
319562
319610
  }
319563
319611
  getInternalXmlFile(name, type = "json") {
319564
319612
  if (!this.converter.convertedXml[name]) {
@@ -324658,7 +324706,9 @@ function print() { __p += __j.call(arguments, '') }
324658
324706
  #hasConverter(editor) {
324659
324707
  return "converter" in editor && editor.converter !== undefined && editor.converter !== null;
324660
324708
  }
324661
- refresh() {
324709
+ refresh(options) {
324710
+ if (options?.purgeCachedEditors)
324711
+ this.#teardownEditors();
324662
324712
  this.#collections = this.#extractCollections();
324663
324713
  const nextDescriptors = this.#collectDescriptors(this.#collections);
324664
324714
  this.#teardownMissingEditors(nextDescriptors);
@@ -327602,6 +327652,7 @@ function print() { __p += __j.call(arguments, '') }
327602
327652
  });
327603
327653
  const handleCollaborationReady = (payload) => {
327604
327654
  this.emit("collaborationReady", payload);
327655
+ this.#refreshHeaderFooterStructureThenRerender();
327605
327656
  if (this.#options.collaborationProvider?.awareness && this.#layoutOptions.presence?.enabled !== false)
327606
327657
  this.#setupCollaborationCursors();
327607
327658
  };
@@ -327610,6 +327661,14 @@ function print() { __p += __j.call(arguments, '') }
327610
327661
  event: "collaborationReady",
327611
327662
  handler: handleCollaborationReady
327612
327663
  });
327664
+ const handleDocumentReplaced = () => {
327665
+ this.#refreshHeaderFooterStructureThenRerender({ purgeCachedEditors: true });
327666
+ };
327667
+ this.#editor.on("documentReplaced", handleDocumentReplaced);
327668
+ this.#editorListeners.push({
327669
+ event: "documentReplaced",
327670
+ handler: handleDocumentReplaced
327671
+ });
327613
327672
  const handleCommentsUpdate = (payload) => {
327614
327673
  if ("activeCommentId" in payload) {
327615
327674
  const activeId = payload.activeCommentId ?? null;
@@ -328470,6 +328529,13 @@ function print() { __p += __j.call(arguments, '') }
328470
328529
  #calculateExtendedSelection(anchor, head, mode) {
328471
328530
  return calculateExtendedSelection(this.#layoutState.blocks, anchor, head, mode);
328472
328531
  }
328532
+ #refreshHeaderFooterStructureThenRerender(options) {
328533
+ this.#headerFooterSession?.refreshStructure(options);
328534
+ this.#flowBlockCache.setHasExternalChanges(true);
328535
+ this.#pendingDocChange = true;
328536
+ this.#selectionSync.onLayoutStart();
328537
+ this.#scheduleRerender();
328538
+ }
328473
328539
  #scheduleRerender() {
328474
328540
  if (this.#renderScheduled)
328475
328541
  return;
@@ -328717,7 +328783,7 @@ function print() { __p += __j.call(arguments, '') }
328717
328783
  }
328718
328784
  this.#sectionMetadata = sectionMetadata;
328719
328785
  const converter = this.#editor.converter;
328720
- const multiSectionId = buildMultiSectionIdentifier(sectionMetadata, converter?.pageStyles, {
328786
+ const multiSectionId = buildMultiSectionIdentifier(sectionMetadata, { alternateHeaders: this.#resolveAlternateHeadersFlag() }, {
328721
328787
  headerIds: converter?.headerIds,
328722
328788
  footerIds: converter?.footerIds
328723
328789
  });
@@ -329382,6 +329448,16 @@ function print() { __p += __j.call(arguments, '') }
329382
329448
  overlay.innerHTML = "";
329383
329449
  overlay.appendChild(fragment);
329384
329450
  }
329451
+ #resolveAlternateHeadersFlag() {
329452
+ const converter = this.#editor?.converter;
329453
+ if (!converter)
329454
+ return false;
329455
+ const settingsPart = converter.convertedXml?.["word/settings.xml"];
329456
+ const fromSettings = resolveEvenAndOddHeadersFromSettingsPart(settingsPart);
329457
+ if (fromSettings !== null)
329458
+ return fromSettings;
329459
+ return converter.pageStyles?.alternateHeaders === true;
329460
+ }
329385
329461
  #resolveLayoutOptions(blocks2, sectionMetadata) {
329386
329462
  const defaults2 = this.#computeDefaultLayoutDefaults();
329387
329463
  const firstSection = blocks2?.find((block) => block.kind === "sectionBreak" && block?.attrs?.isFirstSection);
@@ -329445,7 +329521,7 @@ function print() { __p += __j.call(arguments, '') }
329445
329521
  };
329446
329522
  }
329447
329523
  this.#hiddenHost.style.width = `${pageSize.w}px`;
329448
- const alternateHeaders = Boolean(this.#editor?.converter?.pageStyles?.alternateHeaders);
329524
+ const alternateHeaders = this.#resolveAlternateHeadersFlag();
329449
329525
  return {
329450
329526
  flowMode: "paginated",
329451
329527
  pageSize,
@@ -331371,11 +331447,11 @@ function print() { __p += __j.call(arguments, '') }
331371
331447
  ];
331372
331448
  });
331373
331449
 
331374
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CEK13syX.es.js
331450
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-DzAnOuIL.es.js
331375
331451
  var 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;
331376
- var init_create_super_doc_ui_CEK13syX_es = __esm(() => {
331377
- init_SuperConverter_CcvDw1Yc_es();
331378
- init_create_headless_toolbar_D5yv7LyN_es();
331452
+ var init_create_super_doc_ui_DzAnOuIL_es = __esm(() => {
331453
+ init_SuperConverter_BInxZk0I_es();
331454
+ init_create_headless_toolbar_rUh3xIsa_es();
331379
331455
  MOD_ALIASES = new Set([
331380
331456
  "Mod",
331381
331457
  "Meta",
@@ -331417,16 +331493,16 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
331417
331493
 
331418
331494
  // ../../packages/superdoc/dist/super-editor.es.js
331419
331495
  var init_super_editor_es = __esm(() => {
331420
- init_src_BpYr_7Wm_es();
331421
- init_SuperConverter_CcvDw1Yc_es();
331496
+ init_src_BdpJXQ5F_es();
331497
+ init_SuperConverter_BInxZk0I_es();
331422
331498
  init_jszip_C49i9kUs_es();
331423
331499
  init_xml_js_CqGKpaft_es();
331424
- init_create_headless_toolbar_D5yv7LyN_es();
331500
+ init_create_headless_toolbar_rUh3xIsa_es();
331425
331501
  init_constants_DrU4EASo_es();
331426
331502
  init_dist_B8HfvhaK_es();
331427
331503
  init_unified_Dsuw2be5_es();
331428
331504
  init_DocxZipper_Dh4RtvcE_es();
331429
- init_create_super_doc_ui_CEK13syX_es();
331505
+ init_create_super_doc_ui_DzAnOuIL_es();
331430
331506
  init_ui_CGB3qmy3_es();
331431
331507
  init_eventemitter3_UwU_CLPU_es();
331432
331508
  init_errors_C_DoKMoN_es();
@@ -422234,13 +422310,23 @@ var detectDocumentOrigin2 = (docx) => {
422234
422310
  if (rawValue == null)
422235
422311
  return true;
422236
422312
  return ST_ON_OFF_TRUE_VALUES2.has(String(rawValue).trim().toLowerCase());
422313
+ }, resolveEvenAndOddHeadersFromSettingsPart2 = (settingsPart) => {
422314
+ if (!settingsPart || typeof settingsPart !== "object")
422315
+ return null;
422316
+ const part = settingsPart;
422317
+ const settingsRoot = part.name === "w:settings" ? part : part.elements?.find((entry) => entry?.name === "w:settings");
422318
+ if (!settingsRoot?.elements?.length)
422319
+ return null;
422320
+ const evenOdd = settingsRoot.elements.find((el) => el?.name === "w:evenAndOddHeaders");
422321
+ if (!evenOdd)
422322
+ return null;
422323
+ return isStOnOffEnabled2(evenOdd);
422237
422324
  }, isAlternatingHeadersOddEven2 = (docx) => {
422238
422325
  const settings = docx["word/settings.xml"];
422239
- if (!settings || !settings.elements?.length)
422326
+ if (!settings)
422240
422327
  return false;
422241
- const { elements = [] } = settings.elements[0];
422242
- const evenOdd = elements.find((el) => el.name === "w:evenAndOddHeaders");
422243
- return isStOnOffEnabled2(evenOdd);
422328
+ const resolved = resolveEvenAndOddHeadersFromSettingsPart2(settings);
422329
+ return resolved ?? false;
422244
422330
  };
422245
422331
  var init_docxImporter = __esm(() => {
422246
422332
  init_docxHelper();
@@ -458937,7 +459023,8 @@ function nodePositionToPosition2(doc6, pos) {
458937
459023
  const node4 = resolved.node(depth);
458938
459024
  const blockId = node4.attrs?.sdBlockId;
458939
459025
  if (blockId) {
458940
- return { blockId, offset: pos - resolved.start(depth) };
459026
+ const blockPos = resolved.start(depth) - 1;
459027
+ return { blockId, offset: pmPositionToTextOffset2(node4, blockPos, pos) };
458941
459028
  }
458942
459029
  }
458943
459030
  return { blockId: "", offset: pos };
@@ -459712,7 +459799,8 @@ function pmPosToPosition2(doc6, pos) {
459712
459799
  const node4 = resolved.node(depth);
459713
459800
  const blockId = node4.attrs?.sdBlockId;
459714
459801
  if (blockId) {
459715
- return { blockId, offset: pos - resolved.start(depth) };
459802
+ const blockPos = resolved.start(depth) - 1;
459803
+ return { blockId, offset: pmPositionToTextOffset2(node4, blockPos, pos) };
459716
459804
  }
459717
459805
  }
459718
459806
  return { blockId: "", offset: pos };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/mcp",
3
- "version": "0.3.0-next.74",
3
+ "version": "0.3.0-next.76",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"