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

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 +88 -35
  2. package/package.json +3 -3
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-CMq87UyB.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 {
@@ -291791,8 +291803,8 @@ menclose::after {
291791
291803
  get manager() {
291792
291804
  return this.#headerFooterManager;
291793
291805
  }
291794
- refreshStructure() {
291795
- this.#headerFooterManager?.refresh();
291806
+ refreshStructure(options) {
291807
+ this.#headerFooterManager?.refresh(options?.purgeCachedEditors ? { purgeCachedEditors: true } : undefined);
291796
291808
  this.#headerFooterAdapter?.invalidateAll();
291797
291809
  }
291798
291810
  invalidateLayoutForRefs(refIds) {
@@ -293385,12 +293397,12 @@ menclose::after {
293385
293397
  return;
293386
293398
  console.log(...args$1);
293387
293399
  }, 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(() => {
293400
+ var init_src_CMq87UyB_es = __esm(() => {
293389
293401
  init_rolldown_runtime_Bg48TavK_es();
293390
- init_SuperConverter_CcvDw1Yc_es();
293402
+ init_SuperConverter_BInxZk0I_es();
293391
293403
  init_jszip_C49i9kUs_es();
293392
293404
  init_uuid_qzgm05fK_es();
293393
- init_create_headless_toolbar_D5yv7LyN_es();
293405
+ init_create_headless_toolbar_rUh3xIsa_es();
293394
293406
  init_constants_DrU4EASo_es();
293395
293407
  init_dist_B8HfvhaK_es();
293396
293408
  init_unified_Dsuw2be5_es();
@@ -319559,6 +319571,7 @@ function print() { __p += __j.call(arguments, '') }
319559
319571
  this.#insertNewFileData();
319560
319572
  if (!this.options.ydoc)
319561
319573
  this.#initComments();
319574
+ this.emit("documentReplaced", { editor: this });
319562
319575
  }
319563
319576
  getInternalXmlFile(name, type = "json") {
319564
319577
  if (!this.converter.convertedXml[name]) {
@@ -324658,7 +324671,9 @@ function print() { __p += __j.call(arguments, '') }
324658
324671
  #hasConverter(editor) {
324659
324672
  return "converter" in editor && editor.converter !== undefined && editor.converter !== null;
324660
324673
  }
324661
- refresh() {
324674
+ refresh(options) {
324675
+ if (options?.purgeCachedEditors)
324676
+ this.#teardownEditors();
324662
324677
  this.#collections = this.#extractCollections();
324663
324678
  const nextDescriptors = this.#collectDescriptors(this.#collections);
324664
324679
  this.#teardownMissingEditors(nextDescriptors);
@@ -327602,6 +327617,7 @@ function print() { __p += __j.call(arguments, '') }
327602
327617
  });
327603
327618
  const handleCollaborationReady = (payload) => {
327604
327619
  this.emit("collaborationReady", payload);
327620
+ this.#refreshHeaderFooterStructureThenRerender();
327605
327621
  if (this.#options.collaborationProvider?.awareness && this.#layoutOptions.presence?.enabled !== false)
327606
327622
  this.#setupCollaborationCursors();
327607
327623
  };
@@ -327610,6 +327626,14 @@ function print() { __p += __j.call(arguments, '') }
327610
327626
  event: "collaborationReady",
327611
327627
  handler: handleCollaborationReady
327612
327628
  });
327629
+ const handleDocumentReplaced = () => {
327630
+ this.#refreshHeaderFooterStructureThenRerender({ purgeCachedEditors: true });
327631
+ };
327632
+ this.#editor.on("documentReplaced", handleDocumentReplaced);
327633
+ this.#editorListeners.push({
327634
+ event: "documentReplaced",
327635
+ handler: handleDocumentReplaced
327636
+ });
327613
327637
  const handleCommentsUpdate = (payload) => {
327614
327638
  if ("activeCommentId" in payload) {
327615
327639
  const activeId = payload.activeCommentId ?? null;
@@ -328470,6 +328494,13 @@ function print() { __p += __j.call(arguments, '') }
328470
328494
  #calculateExtendedSelection(anchor, head, mode) {
328471
328495
  return calculateExtendedSelection(this.#layoutState.blocks, anchor, head, mode);
328472
328496
  }
328497
+ #refreshHeaderFooterStructureThenRerender(options) {
328498
+ this.#headerFooterSession?.refreshStructure(options);
328499
+ this.#flowBlockCache.setHasExternalChanges(true);
328500
+ this.#pendingDocChange = true;
328501
+ this.#selectionSync.onLayoutStart();
328502
+ this.#scheduleRerender();
328503
+ }
328473
328504
  #scheduleRerender() {
328474
328505
  if (this.#renderScheduled)
328475
328506
  return;
@@ -328717,7 +328748,7 @@ function print() { __p += __j.call(arguments, '') }
328717
328748
  }
328718
328749
  this.#sectionMetadata = sectionMetadata;
328719
328750
  const converter = this.#editor.converter;
328720
- const multiSectionId = buildMultiSectionIdentifier(sectionMetadata, converter?.pageStyles, {
328751
+ const multiSectionId = buildMultiSectionIdentifier(sectionMetadata, { alternateHeaders: this.#resolveAlternateHeadersFlag() }, {
328721
328752
  headerIds: converter?.headerIds,
328722
328753
  footerIds: converter?.footerIds
328723
328754
  });
@@ -329382,6 +329413,16 @@ function print() { __p += __j.call(arguments, '') }
329382
329413
  overlay.innerHTML = "";
329383
329414
  overlay.appendChild(fragment);
329384
329415
  }
329416
+ #resolveAlternateHeadersFlag() {
329417
+ const converter = this.#editor?.converter;
329418
+ if (!converter)
329419
+ return false;
329420
+ const settingsPart = converter.convertedXml?.["word/settings.xml"];
329421
+ const fromSettings = resolveEvenAndOddHeadersFromSettingsPart(settingsPart);
329422
+ if (fromSettings !== null)
329423
+ return fromSettings;
329424
+ return converter.pageStyles?.alternateHeaders === true;
329425
+ }
329385
329426
  #resolveLayoutOptions(blocks2, sectionMetadata) {
329386
329427
  const defaults2 = this.#computeDefaultLayoutDefaults();
329387
329428
  const firstSection = blocks2?.find((block) => block.kind === "sectionBreak" && block?.attrs?.isFirstSection);
@@ -329445,7 +329486,7 @@ function print() { __p += __j.call(arguments, '') }
329445
329486
  };
329446
329487
  }
329447
329488
  this.#hiddenHost.style.width = `${pageSize.w}px`;
329448
- const alternateHeaders = Boolean(this.#editor?.converter?.pageStyles?.alternateHeaders);
329489
+ const alternateHeaders = this.#resolveAlternateHeadersFlag();
329449
329490
  return {
329450
329491
  flowMode: "paginated",
329451
329492
  pageSize,
@@ -331371,11 +331412,11 @@ function print() { __p += __j.call(arguments, '') }
331371
331412
  ];
331372
331413
  });
331373
331414
 
331374
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CEK13syX.es.js
331415
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-DzAnOuIL.es.js
331375
331416
  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();
331417
+ var init_create_super_doc_ui_DzAnOuIL_es = __esm(() => {
331418
+ init_SuperConverter_BInxZk0I_es();
331419
+ init_create_headless_toolbar_rUh3xIsa_es();
331379
331420
  MOD_ALIASES = new Set([
331380
331421
  "Mod",
331381
331422
  "Meta",
@@ -331417,16 +331458,16 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
331417
331458
 
331418
331459
  // ../../packages/superdoc/dist/super-editor.es.js
331419
331460
  var init_super_editor_es = __esm(() => {
331420
- init_src_BpYr_7Wm_es();
331421
- init_SuperConverter_CcvDw1Yc_es();
331461
+ init_src_CMq87UyB_es();
331462
+ init_SuperConverter_BInxZk0I_es();
331422
331463
  init_jszip_C49i9kUs_es();
331423
331464
  init_xml_js_CqGKpaft_es();
331424
- init_create_headless_toolbar_D5yv7LyN_es();
331465
+ init_create_headless_toolbar_rUh3xIsa_es();
331425
331466
  init_constants_DrU4EASo_es();
331426
331467
  init_dist_B8HfvhaK_es();
331427
331468
  init_unified_Dsuw2be5_es();
331428
331469
  init_DocxZipper_Dh4RtvcE_es();
331429
- init_create_super_doc_ui_CEK13syX_es();
331470
+ init_create_super_doc_ui_DzAnOuIL_es();
331430
331471
  init_ui_CGB3qmy3_es();
331431
331472
  init_eventemitter3_UwU_CLPU_es();
331432
331473
  init_errors_C_DoKMoN_es();
@@ -422234,13 +422275,23 @@ var detectDocumentOrigin2 = (docx) => {
422234
422275
  if (rawValue == null)
422235
422276
  return true;
422236
422277
  return ST_ON_OFF_TRUE_VALUES2.has(String(rawValue).trim().toLowerCase());
422278
+ }, resolveEvenAndOddHeadersFromSettingsPart2 = (settingsPart) => {
422279
+ if (!settingsPart || typeof settingsPart !== "object")
422280
+ return null;
422281
+ const part = settingsPart;
422282
+ const settingsRoot = part.name === "w:settings" ? part : part.elements?.find((entry) => entry?.name === "w:settings");
422283
+ if (!settingsRoot?.elements?.length)
422284
+ return null;
422285
+ const evenOdd = settingsRoot.elements.find((el) => el?.name === "w:evenAndOddHeaders");
422286
+ if (!evenOdd)
422287
+ return null;
422288
+ return isStOnOffEnabled2(evenOdd);
422237
422289
  }, isAlternatingHeadersOddEven2 = (docx) => {
422238
422290
  const settings = docx["word/settings.xml"];
422239
- if (!settings || !settings.elements?.length)
422291
+ if (!settings)
422240
422292
  return false;
422241
- const { elements = [] } = settings.elements[0];
422242
- const evenOdd = elements.find((el) => el.name === "w:evenAndOddHeaders");
422243
- return isStOnOffEnabled2(evenOdd);
422293
+ const resolved = resolveEvenAndOddHeadersFromSettingsPart2(settings);
422294
+ return resolved ?? false;
422244
422295
  };
422245
422296
  var init_docxImporter = __esm(() => {
422246
422297
  init_docxHelper();
@@ -458937,7 +458988,8 @@ function nodePositionToPosition2(doc6, pos) {
458937
458988
  const node4 = resolved.node(depth);
458938
458989
  const blockId = node4.attrs?.sdBlockId;
458939
458990
  if (blockId) {
458940
- return { blockId, offset: pos - resolved.start(depth) };
458991
+ const blockPos = resolved.start(depth) - 1;
458992
+ return { blockId, offset: pmPositionToTextOffset2(node4, blockPos, pos) };
458941
458993
  }
458942
458994
  }
458943
458995
  return { blockId: "", offset: pos };
@@ -459712,7 +459764,8 @@ function pmPosToPosition2(doc6, pos) {
459712
459764
  const node4 = resolved.node(depth);
459713
459765
  const blockId = node4.attrs?.sdBlockId;
459714
459766
  if (blockId) {
459715
- return { blockId, offset: pos - resolved.start(depth) };
459767
+ const blockPos = resolved.start(depth) - 1;
459768
+ return { blockId, offset: pmPositionToTextOffset2(node4, blockPos, pos) };
459716
459769
  }
459717
459770
  }
459718
459771
  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.75",
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.32.0"
23
+ "superdoc": "1.32.0",
24
+ "@superdoc/document-api": "0.0.1"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public"