@superdoc-dev/mcp 0.12.0-next.27 → 0.12.0-next.29

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 +647 -48
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -52172,7 +52172,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
52172
52172
  emptyOptions2 = {};
52173
52173
  });
52174
52174
 
52175
- // ../../packages/superdoc/dist/chunks/SuperConverter-DK5WIHuy.es.js
52175
+ // ../../packages/superdoc/dist/chunks/SuperConverter-DAuqlmYY.es.js
52176
52176
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
52177
52177
  const fieldValue = extension$1.config[field];
52178
52178
  if (typeof fieldValue === "function")
@@ -67955,11 +67955,248 @@ function collectTextBoxParagraphs(nodes, paragraphs = []) {
67955
67955
  paragraphs.push(node2);
67956
67956
  return;
67957
67957
  }
67958
+ if (node2.name === "w:tbl") {
67959
+ paragraphs.push(...flattenTextBoxTableToParagraphs(node2));
67960
+ return;
67961
+ }
67958
67962
  if (Array.isArray(node2.elements))
67959
67963
  collectTextBoxParagraphs(node2.elements, paragraphs);
67960
67964
  });
67961
67965
  return paragraphs;
67962
67966
  }
67967
+ function flattenTextBoxTableToParagraphs(table) {
67968
+ const rows = table.elements?.filter((node2) => node2?.name === "w:tr") || [];
67969
+ if (!rows.length)
67970
+ return [];
67971
+ const gridWidths = extractTableGridWidths(table);
67972
+ const paragraphs = [];
67973
+ rows.forEach((row) => {
67974
+ const cells = row.elements?.filter((node2) => node2?.name === "w:tc") || [];
67975
+ if (!cells.length)
67976
+ return;
67977
+ const columnStarts = buildColumnStarts(cells, gridWidths);
67978
+ const cellLines = cells.map((cell) => collectTextBoxTableCellLines(cell));
67979
+ const maxLineCount = cellLines.reduce((max, lines) => Math.max(max, lines.length), 0);
67980
+ for (let lineIndex = 0;lineIndex < maxLineCount; lineIndex += 1) {
67981
+ const lineParts = cellLines.map((lines) => lines[lineIndex] || null);
67982
+ if (!lineParts.some((line) => line && hasRenderableLineContent(line.elements)))
67983
+ continue;
67984
+ paragraphs.push(buildTableVisualLineParagraph(lineParts, columnStarts));
67985
+ }
67986
+ });
67987
+ return paragraphs;
67988
+ }
67989
+ function extractTableGridWidths(table) {
67990
+ return table.elements?.find((node2) => node2?.name === "w:tblGrid")?.elements?.filter((node2) => node2?.name === "w:gridCol").map((node2) => toFiniteNumber$3(node2.attributes?.["w:w"] ?? node2.attributes?.w)).filter((value) => value != null && value > 0) || [];
67991
+ }
67992
+ function buildColumnStarts(cells, gridWidths) {
67993
+ const starts = [];
67994
+ let cursor = 0;
67995
+ let gridIndex = 0;
67996
+ cells.forEach((cell) => {
67997
+ starts.push(cursor);
67998
+ const gridSpan = resolveCellGridSpan(cell);
67999
+ cursor += resolveCellWidth(cell, gridWidths, gridIndex, gridSpan);
68000
+ gridIndex += gridSpan;
68001
+ });
68002
+ return starts;
68003
+ }
68004
+ function resolveCellGridSpan(cell) {
68005
+ const gridSpan = cell.elements?.find((node2) => node2?.name === "w:tcPr")?.elements?.find((node2) => node2?.name === "w:gridSpan");
68006
+ const value = toFiniteNumber$3(gridSpan?.attributes?.["w:val"] ?? gridSpan?.attributes?.val);
68007
+ return value && value > 0 ? Math.max(1, Math.floor(value)) : 1;
68008
+ }
68009
+ function resolveCellWidth(cell, gridWidths, gridIndex, gridSpan) {
68010
+ const gridWidth = sumGridWidths(gridWidths, gridIndex, gridSpan);
68011
+ if (gridWidth > 0)
68012
+ return gridWidth;
68013
+ const tcW = cell.elements?.find((node2) => node2?.name === "w:tcPr")?.elements?.find((node2) => node2?.name === "w:tcW");
68014
+ const width = toFiniteNumber$3(tcW?.attributes?.["w:w"] ?? tcW?.attributes?.w);
68015
+ return width && width > 0 ? width : 0;
68016
+ }
68017
+ function sumGridWidths(gridWidths, gridIndex, gridSpan) {
68018
+ if (!Array.isArray(gridWidths) || gridWidths.length === 0)
68019
+ return 0;
68020
+ let width = 0;
68021
+ for (let offset = 0;offset < gridSpan; offset += 1) {
68022
+ const gridWidth = gridWidths[gridIndex + offset];
68023
+ if (gridWidth != null && gridWidth > 0)
68024
+ width += gridWidth;
68025
+ }
68026
+ return width;
68027
+ }
68028
+ function collectTextBoxTableCellLines(cell) {
68029
+ const paragraphNodes = [];
68030
+ collectTextBoxParagraphsSkippingTables(cell.elements || [], paragraphNodes);
68031
+ return paragraphNodes.flatMap((paragraph2) => splitTextBoxParagraphIntoVisualLines(paragraph2));
68032
+ }
68033
+ function collectTextBoxParagraphsSkippingTables(nodes, paragraphs) {
68034
+ if (!Array.isArray(nodes))
68035
+ return;
68036
+ nodes.forEach((node2) => {
68037
+ if (!node2)
68038
+ return;
68039
+ if (node2.name === "w:p") {
68040
+ paragraphs.push(node2);
68041
+ return;
68042
+ }
68043
+ if (node2.name === "w:tbl")
68044
+ return;
68045
+ if (Array.isArray(node2.elements))
68046
+ collectTextBoxParagraphsSkippingTables(node2.elements, paragraphs);
68047
+ });
68048
+ }
68049
+ function splitTextBoxParagraphIntoVisualLines(paragraph2) {
68050
+ const pPr = paragraph2.elements?.find((node2) => node2?.name === "w:pPr") || null;
68051
+ const lines = [{
68052
+ pPr,
68053
+ elements: []
68054
+ }];
68055
+ const appendToCurrentLine = (element) => {
68056
+ lines[lines.length - 1].elements.push(element);
68057
+ };
68058
+ for (const element of paragraph2.elements || []) {
68059
+ if (!element || element.name === "w:pPr")
68060
+ continue;
68061
+ if (element.name !== "w:r" || !Array.isArray(element.elements)) {
68062
+ appendToCurrentLine(carbonCopy(element));
68063
+ continue;
68064
+ }
68065
+ splitRunAroundBreaks(element, appendToCurrentLine, () => {
68066
+ lines.push({
68067
+ pPr,
68068
+ elements: []
68069
+ });
68070
+ });
68071
+ }
68072
+ while (lines.length > 1 && !hasRenderableLineContent(lines[lines.length - 1].elements))
68073
+ lines.pop();
68074
+ return lines;
68075
+ }
68076
+ function splitRunAroundBreaks(run$1, appendRun, startNewLine) {
68077
+ let runElements = [];
68078
+ const runProperties = run$1.elements?.filter((node2) => node2?.name === "w:rPr").map((node2) => carbonCopy(node2)) || [];
68079
+ const flushRun = () => {
68080
+ if (!runElements.filter((node2) => node2?.name !== "w:rPr").length) {
68081
+ runElements = runProperties.map((node2) => carbonCopy(node2));
68082
+ return;
68083
+ }
68084
+ appendRun({
68085
+ ...carbonCopy(run$1),
68086
+ elements: runElements
68087
+ });
68088
+ runElements = runProperties.map((node2) => carbonCopy(node2));
68089
+ };
68090
+ run$1.elements.forEach((child) => {
68091
+ if (child?.name === "w:br") {
68092
+ flushRun();
68093
+ startNewLine();
68094
+ return;
68095
+ }
68096
+ runElements.push(carbonCopy(child));
68097
+ });
68098
+ flushRun();
68099
+ }
68100
+ function buildTableVisualLineParagraph(lineParts, columnStarts) {
68101
+ const pPr = buildVisualLineParagraphProperties((lineParts.find((line) => line?.pPr) || lineParts.find(Boolean))?.pPr, lineParts, columnStarts);
68102
+ const elements = pPr ? [pPr] : [];
68103
+ lineParts.forEach((line, index2) => {
68104
+ if (!line || !hasRenderableLineContent(line.elements))
68105
+ return;
68106
+ if (index2 > 0)
68107
+ elements.push(createTabRun());
68108
+ elements.push(...line.elements.map((element) => carbonCopy(element)));
68109
+ });
68110
+ return {
68111
+ name: "w:p",
68112
+ elements
68113
+ };
68114
+ }
68115
+ function buildVisualLineParagraphProperties(basePPr, lineParts, columnStarts) {
68116
+ const pPr = basePPr ? carbonCopy(basePPr) : {
68117
+ name: "w:pPr",
68118
+ elements: []
68119
+ };
68120
+ pPr.elements = (pPr.elements || []).filter((node2) => node2?.name !== "w:tabs");
68121
+ const tabStops = [];
68122
+ lineParts.forEach((line, index2) => {
68123
+ const columnStart = columnStarts[index2] || 0;
68124
+ if (index2 > 0 && columnStart > 0 && line && hasRenderableLineContent(line.elements))
68125
+ tabStops.push(createTabStop(columnStart));
68126
+ const sourceTabs = extractTabs(line?.pPr);
68127
+ let positionedSourceTabCount = 0;
68128
+ sourceTabs.forEach((tab) => {
68129
+ const pos = toFiniteNumber$3(tab.attributes?.["w:pos"] ?? tab.attributes?.pos);
68130
+ if (pos == null)
68131
+ return;
68132
+ positionedSourceTabCount += 1;
68133
+ tabStops.push(createTabStop(columnStart + pos, tab.attributes));
68134
+ });
68135
+ const tabRunCount = countTabRuns(line?.elements);
68136
+ for (let tabIndex = positionedSourceTabCount;tabIndex < tabRunCount; tabIndex += 1)
68137
+ tabStops.push(createTabStop(resolveDefaultInternalTabPos(columnStart, tabIndex)));
68138
+ });
68139
+ if (tabStops.length > 0)
68140
+ pPr.elements.push({
68141
+ name: "w:tabs",
68142
+ elements: dedupeTabStops(tabStops)
68143
+ });
68144
+ return pPr.elements.length > 0 ? pPr : null;
68145
+ }
68146
+ function extractTabs(pPr) {
68147
+ return pPr?.elements?.find((node2) => node2?.name === "w:tabs")?.elements?.filter((node2) => node2?.name === "w:tab") || [];
68148
+ }
68149
+ function countTabRuns(elements = []) {
68150
+ return elements.reduce((count, element) => {
68151
+ if (element?.name === "w:tab")
68152
+ return count + 1;
68153
+ if (Array.isArray(element?.elements))
68154
+ return count + countTabRuns(element.elements);
68155
+ return count;
68156
+ }, 0);
68157
+ }
68158
+ function resolveDefaultInternalTabPos(columnStart, tabIndex) {
68159
+ return columnStart + DEFAULT_TAB_INTERVAL_TWIPS$1 * (tabIndex + 1);
68160
+ }
68161
+ function createTabRun() {
68162
+ return {
68163
+ name: "w:r",
68164
+ elements: [{ name: "w:tab" }]
68165
+ };
68166
+ }
68167
+ function createTabStop(pos, sourceAttributes = {}) {
68168
+ return {
68169
+ name: "w:tab",
68170
+ attributes: {
68171
+ ...sourceAttributes,
68172
+ "w:val": sourceAttributes["w:val"] || sourceAttributes.val || "left",
68173
+ "w:pos": String(pos)
68174
+ }
68175
+ };
68176
+ }
68177
+ function dedupeTabStops(tabStops) {
68178
+ const seen = /* @__PURE__ */ new Set;
68179
+ return tabStops.filter((tab) => {
68180
+ const key = `${tab.attributes?.["w:val"] || ""}:${tab.attributes?.["w:pos"] || ""}`;
68181
+ if (seen.has(key))
68182
+ return false;
68183
+ seen.add(key);
68184
+ return true;
68185
+ }).sort((a, b) => Number(a.attributes?.["w:pos"] || 0) - Number(b.attributes?.["w:pos"] || 0));
68186
+ }
68187
+ function hasRenderableLineContent(elements) {
68188
+ return elements.some((element) => {
68189
+ if (element?.name === "w:tab")
68190
+ return true;
68191
+ if (element?.name === "w:t")
68192
+ return true;
68193
+ return Array.isArray(element?.elements) && hasRenderableLineContent(element.elements);
68194
+ });
68195
+ }
68196
+ function toFiniteNumber$3(value) {
68197
+ const number5 = Number(value);
68198
+ return Number.isFinite(number5) ? number5 : null;
68199
+ }
67963
68200
  function preProcessTextBoxContent(textBoxContent, params = {}) {
67964
68201
  if (!textBoxContent?.elements)
67965
68202
  return textBoxContent;
@@ -68375,6 +68612,8 @@ function handleImageNode$1(node2, params, isAnchor) {
68375
68612
  type: wrapNode?.name.slice(7) || "None",
68376
68613
  attrs: {}
68377
68614
  } : { type: "Inline" };
68615
+ const hasBehindDocAttribute = isAnchor && attributes.behindDoc != null;
68616
+ const isBehindDoc = attributes.behindDoc === "1" || attributes.behindDoc === 1 || attributes.behindDoc === true;
68378
68617
  switch (wrap$1.type) {
68379
68618
  case "Square":
68380
68619
  if (wrapNode?.attributes?.wrapText)
@@ -68415,7 +68654,7 @@ function handleImageNode$1(node2, params, isAnchor) {
68415
68654
  wrap$1.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
68416
68655
  break;
68417
68656
  case "None":
68418
- wrap$1.attrs.behindDoc = node2.attributes?.behindDoc === "1";
68657
+ wrap$1.attrs.behindDoc = isBehindDoc;
68419
68658
  break;
68420
68659
  case "Inline":
68421
68660
  break;
@@ -68424,6 +68663,8 @@ function handleImageNode$1(node2, params, isAnchor) {
68424
68663
  }
68425
68664
  if (wrap$1.type === "Square" || wrap$1.type === "Tight" || wrap$1.type === "Through" || wrap$1.type === "TopAndBottom")
68426
68665
  mergeAnchorPaddingIntoWrapDistances(wrap$1, padding);
68666
+ if (hasBehindDocAttribute && wrap$1.attrs)
68667
+ wrap$1.attrs.behindDoc = isBehindDoc;
68427
68668
  const docPr = node2.elements.find((el) => el.name === "wp:docPr");
68428
68669
  const isHidden = isDocPrHidden(docPr);
68429
68670
  let anchorData = null;
@@ -106269,7 +106510,7 @@ var isRegExp = (value) => {
106269
106510
  i$1++;
106270
106511
  }
106271
106512
  return { processedNodes };
106272
- }, HEADER_FOOTER_FILENAME_PATTERN, CHART_TYPE_MAP, CHART_TYPE_NAMES, findChild$1 = (node2, name) => node2?.elements?.find((el) => el.name === name), findChildren$2 = (node2, name) => node2?.elements?.filter((el) => el.name === name) ?? [], getAttr = (node2, attr) => node2?.attributes?.[attr], PARAGRAPH_PROPERTIES_XML_NAME = "w:pPr", hasMeaningfulParagraphContent = (elements = []) => elements.some((element) => element?.name && element.name !== PARAGRAPH_PROPERTIES_XML_NAME), findParagraphProperties = (elements = []) => elements.find((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME) ?? null, hasParagraphProperties = (elements = []) => elements.some((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME), cloneParagraphPropertiesForRenderedResult = (paragraphProperties) => {
106513
+ }, HEADER_FOOTER_FILENAME_PATTERN, DEFAULT_TAB_INTERVAL_TWIPS$1 = 720, CHART_TYPE_MAP, CHART_TYPE_NAMES, findChild$1 = (node2, name) => node2?.elements?.find((el) => el.name === name), findChildren$2 = (node2, name) => node2?.elements?.filter((el) => el.name === name) ?? [], getAttr = (node2, attr) => node2?.attributes?.[attr], PARAGRAPH_PROPERTIES_XML_NAME = "w:pPr", hasMeaningfulParagraphContent = (elements = []) => elements.some((element) => element?.name && element.name !== PARAGRAPH_PROPERTIES_XML_NAME), findParagraphProperties = (elements = []) => elements.find((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME) ?? null, hasParagraphProperties = (elements = []) => elements.some((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME), cloneParagraphPropertiesForRenderedResult = (paragraphProperties) => {
106273
106514
  const elements = (paragraphProperties.elements || []).filter((element) => element?.name !== "w:sectPr").map((element) => carbonCopy(element));
106274
106515
  if (elements.length === 0)
106275
106516
  return null;
@@ -118814,7 +119055,7 @@ var isRegExp = (value) => {
118814
119055
  state.kern = kernNode.attributes["w:val"];
118815
119056
  }
118816
119057
  }, SuperConverter;
118817
- var init_SuperConverter_DK5WIHuy_es = __esm(() => {
119058
+ var init_SuperConverter_DAuqlmYY_es = __esm(() => {
118818
119059
  init_rolldown_runtime_Bg48TavK_es();
118819
119060
  init_jszip_C49i9kUs_es();
118820
119061
  init_xml_js_CqGKpaft_es();
@@ -159558,7 +159799,7 @@ var init_SuperConverter_DK5WIHuy_es = __esm(() => {
159558
159799
  };
159559
159800
  });
159560
159801
 
159561
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BLN1v7eO.es.js
159802
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BT0XKtIW.es.js
159562
159803
  function parseSizeUnit(val = "0") {
159563
159804
  const length = val.toString() || "0";
159564
159805
  const value = Number.parseFloat(length);
@@ -170207,8 +170448,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
170207
170448
  }
170208
170449
  };
170209
170450
  };
170210
- var init_create_headless_toolbar_BLN1v7eO_es = __esm(() => {
170211
- init_SuperConverter_DK5WIHuy_es();
170451
+ var init_create_headless_toolbar_BT0XKtIW_es = __esm(() => {
170452
+ init_SuperConverter_DAuqlmYY_es();
170212
170453
  init_uuid_B2wVPhPi_es();
170213
170454
  init_constants_D9qj59G2_es();
170214
170455
  init_dist_B8HfvhaK_es();
@@ -224898,7 +225139,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
224898
225139
  init_remark_gfm_BhnWr3yf_es();
224899
225140
  });
224900
225141
 
224901
- // ../../packages/superdoc/dist/chunks/src-PJVnllcq.es.js
225142
+ // ../../packages/superdoc/dist/chunks/src-DHPdEVg9.es.js
224902
225143
  function deleteProps(obj, propOrProps) {
224903
225144
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
224904
225145
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -263275,6 +263516,23 @@ function resolveImageLabel(root3) {
263275
263516
  function resolveImageKind(root3) {
263276
263517
  return root3.classList.contains(DOM_CLASS_NAMES.IMAGE_FRAGMENT) ? "block" : "inline";
263277
263518
  }
263519
+ function getBehindDocSection(root3) {
263520
+ return root3.closest("[data-behind-doc-section]")?.dataset.behindDocSection ?? null;
263521
+ }
263522
+ function canInteractWithRoot(root3, activeHeaderFooterMode) {
263523
+ const section = getBehindDocSection(root3);
263524
+ if (!section)
263525
+ return true;
263526
+ return section === activeHeaderFooterMode;
263527
+ }
263528
+ function clearImageRoot(root3) {
263529
+ root3.removeAttribute("draggable");
263530
+ delete root3.dataset.dragSourceKind;
263531
+ delete root3.dataset.imageKind;
263532
+ delete root3.dataset.nodeType;
263533
+ delete root3.dataset.displayLabel;
263534
+ delete root3.dataset[INTERACTION_EPOCH_KEY$1];
263535
+ }
263278
263536
  function cssClassForKind(kind) {
263279
263537
  switch (kind) {
263280
263538
  case "spelling":
@@ -269556,7 +269814,8 @@ function collectPreRegisteredAnchors(blocks2, measures) {
269556
269814
  return result;
269557
269815
  }
269558
269816
  function collectAnchoredDrawings(blocks2, measures) {
269559
- const map$12 = /* @__PURE__ */ new Map;
269817
+ const byParagraph = /* @__PURE__ */ new Map;
269818
+ const withoutParagraph = [];
269560
269819
  const len3 = Math.min(blocks2.length, measures.length);
269561
269820
  const paragraphIndexById = buildParagraphIndexById(blocks2, len3);
269562
269821
  for (let i4 = 0;i4 < len3; i4 += 1) {
@@ -269573,17 +269832,28 @@ function collectAnchoredDrawings(blocks2, measures) {
269573
269832
  if (isPageRelativeAnchor(drawingBlock))
269574
269833
  continue;
269575
269834
  const anchorParagraphId = typeof drawingBlock.attrs === "object" && drawingBlock.attrs ? drawingBlock.attrs.anchorParagraphId : undefined;
269576
- const anchorParaIndex = resolveAnchorParagraphIndex(blocks2, len3, paragraphIndexById, i4, anchorParagraphId);
269577
- if (anchorParaIndex == null)
269578
- continue;
269579
- const list5 = map$12.get(anchorParaIndex) ?? [];
269580
- list5.push({
269835
+ const anchoredDrawing = {
269581
269836
  block: drawingBlock,
269582
269837
  measure: drawingMeasure
269583
- });
269584
- map$12.set(anchorParaIndex, list5);
269838
+ };
269839
+ const anchorParaIndex = resolveAnchorParagraphIndex(blocks2, len3, paragraphIndexById, i4, anchorParagraphId);
269840
+ if (anchorParaIndex == null) {
269841
+ withoutParagraph.push(anchoredDrawing);
269842
+ continue;
269843
+ }
269844
+ const list5 = byParagraph.get(anchorParaIndex) ?? [];
269845
+ list5.push(anchoredDrawing);
269846
+ byParagraph.set(anchorParaIndex, list5);
269585
269847
  }
269586
- return map$12;
269848
+ return {
269849
+ byParagraph,
269850
+ withoutParagraph,
269851
+ get size() {
269852
+ return byParagraph.size;
269853
+ },
269854
+ has: (index2) => byParagraph.has(index2),
269855
+ get: (index2) => byParagraph.get(index2)
269856
+ };
269587
269857
  }
269588
269858
  function collectAnchoredTables(blocks2, measures) {
269589
269859
  const len3 = Math.min(blocks2.length, measures.length);
@@ -270786,6 +271056,7 @@ function layoutDocument(blocks2, measures, options = {}) {
270786
271056
  let activeColumns = cloneColumnLayout(options.columns);
270787
271057
  let pendingColumns = null;
270788
271058
  const allowParagraphlessAnchoredTableFallback = options.allowParagraphlessAnchoredTableFallback !== false;
271059
+ const allowParagraphlessAnchoredDrawingFallback = options.allowParagraphlessAnchoredDrawingFallback !== false;
270789
271060
  const allowSectionBreakOnlyPageFallback = options.allowSectionBreakOnlyPageFallback !== false;
270790
271061
  let activeOrientation = null;
270791
271062
  let pendingOrientation = null;
@@ -271476,7 +271747,9 @@ function layoutDocument(blocks2, measures, options = {}) {
271476
271747
  if (block.kind === "paragraph" && blockWithAttrs.attrs?.keepLines === true)
271477
271748
  keepLinesBlockIds.add(block.id);
271478
271749
  });
271479
- const anchoredByParagraph = collectAnchoredDrawings(blocks2, measures);
271750
+ const anchoredDrawings = collectAnchoredDrawings(blocks2, measures);
271751
+ const anchoredByParagraph = anchoredDrawings.byParagraph;
271752
+ const paragraphlessAnchoredDrawings = anchoredDrawings.withoutParagraph;
271480
271753
  const anchoredTables = collectAnchoredTables(blocks2, measures);
271481
271754
  const anchoredTablesByParagraph = anchoredTables.byParagraph;
271482
271755
  const paragraphlessAnchoredTables = anchoredTables.withoutParagraph;
@@ -271496,6 +271769,18 @@ function layoutDocument(blocks2, measures, options = {}) {
271496
271769
  preRegisteredFallbackToContentTop: true
271497
271770
  });
271498
271771
  };
271772
+ const resolveParagraphlessAnchoredDrawingY = (block, measure, state) => resolveAnchoredGraphicY({
271773
+ anchor: block.anchor,
271774
+ objectHeight: measure.height ?? 0,
271775
+ contentTop: state.topMargin,
271776
+ contentBottom: state.contentBottom,
271777
+ pageBottomMargin: state.page.margins?.bottom ?? activeBottomMargin,
271778
+ preRegisteredFallbackToContentTop: true
271779
+ });
271780
+ const resolveParagraphlessAnchoredDrawingX = (block, measure, state) => block.anchor ? computeAnchorX(block.anchor, state.columnIndex, normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)), measure.width, {
271781
+ left: activeLeftMargin,
271782
+ right: activeRightMargin
271783
+ }, activePageSize.w) : columnX(state);
271499
271784
  for (const entry of preRegisteredAnchors) {
271500
271785
  const state = paginator.ensurePage();
271501
271786
  const contentTop = state.topMargin;
@@ -272012,9 +272297,82 @@ function layoutDocument(blocks2, measures, options = {}) {
272012
272297
  activePageCounter = activeSectionPageCounterStart;
272013
272298
  sectionFirstPageNumbers.clear();
272014
272299
  };
272015
- if (pages.length === 0 && (allowParagraphlessAnchoredTableFallback && paragraphlessAnchoredTables.length > 0 || allowSectionBreakOnlyPageFallback && hasOnlySectionBreakBlocks(blocks2)))
272300
+ const shouldUseBlankPageFallback = pages.length === 0;
272301
+ if (shouldUseBlankPageFallback && (allowParagraphlessAnchoredTableFallback && paragraphlessAnchoredTables.length > 0 || allowParagraphlessAnchoredDrawingFallback && paragraphlessAnchoredDrawings.length > 0 || allowSectionBreakOnlyPageFallback && hasOnlySectionBreakBlocks(blocks2)))
272016
272302
  resetPaginationStateForBlankPageFallback();
272017
- if (allowParagraphlessAnchoredTableFallback && pages.length === 0 && paragraphlessAnchoredTables.length > 0) {
272303
+ if (allowParagraphlessAnchoredDrawingFallback && shouldUseBlankPageFallback && paragraphlessAnchoredDrawings.length > 0) {
272304
+ const state = paginator.ensurePage();
272305
+ for (const { block, measure } of paragraphlessAnchoredDrawings) {
272306
+ if (placedAnchoredIds.has(block.id))
272307
+ continue;
272308
+ const anchorX = resolveParagraphlessAnchoredDrawingX(block, measure, state);
272309
+ const anchorY = resolveParagraphlessAnchoredDrawingY(block, measure, state);
272310
+ if (block.kind === "image" && measure.kind === "image") {
272311
+ const pageContentHeight = Math.max(0, state.contentBottom - state.topMargin);
272312
+ const aspectRatio = measure.width > 0 && measure.height > 0 ? measure.width / measure.height : 1;
272313
+ const minWidth = 20;
272314
+ const minHeight = minWidth / aspectRatio;
272315
+ const fragment = {
272316
+ kind: "image",
272317
+ blockId: block.id,
272318
+ x: anchorX,
272319
+ y: anchorY,
272320
+ width: measure.width,
272321
+ height: measure.height,
272322
+ isAnchored: true,
272323
+ behindDoc: block.anchor?.behindDoc === true,
272324
+ zIndex: getFragmentZIndex(block),
272325
+ metadata: {
272326
+ originalWidth: measure.width,
272327
+ originalHeight: measure.height,
272328
+ maxWidth: activePageSize.w - (activeLeftMargin + activeRightMargin),
272329
+ maxHeight: pageContentHeight,
272330
+ aspectRatio,
272331
+ minWidth,
272332
+ minHeight
272333
+ },
272334
+ sourceAnchor: block.sourceAnchor
272335
+ };
272336
+ const attrs = block.attrs;
272337
+ if (attrs?.pmStart != null)
272338
+ fragment.pmStart = attrs.pmStart;
272339
+ if (attrs?.pmEnd != null)
272340
+ fragment.pmEnd = attrs.pmEnd;
272341
+ state.page.fragments.push(fragment);
272342
+ placedAnchoredIds.add(block.id);
272343
+ continue;
272344
+ }
272345
+ if (block.kind === "drawing" && measure.kind === "drawing") {
272346
+ const contentMeasures = block.drawingKind === "textboxShape" && typeof options.remeasureParagraph === "function" ? layoutTextboxContent(block, options.remeasureParagraph) : undefined;
272347
+ const fragment = {
272348
+ kind: "drawing",
272349
+ blockId: block.id,
272350
+ drawingKind: block.drawingKind,
272351
+ x: anchorX,
272352
+ y: anchorY,
272353
+ width: measure.width,
272354
+ height: measure.height,
272355
+ geometry: measure.geometry,
272356
+ scale: measure.scale,
272357
+ isAnchored: true,
272358
+ behindDoc: block.anchor?.behindDoc === true,
272359
+ zIndex: getFragmentZIndex(block),
272360
+ drawingContentId: block.drawingContentId,
272361
+ sourceAnchor: block.sourceAnchor
272362
+ };
272363
+ if (contentMeasures)
272364
+ fragment.contentMeasures = contentMeasures;
272365
+ const attrs = block.attrs;
272366
+ if (attrs?.pmStart != null)
272367
+ fragment.pmStart = attrs.pmStart;
272368
+ if (attrs?.pmEnd != null)
272369
+ fragment.pmEnd = attrs.pmEnd;
272370
+ state.page.fragments.push(fragment);
272371
+ placedAnchoredIds.add(block.id);
272372
+ }
272373
+ }
272374
+ }
272375
+ if (allowParagraphlessAnchoredTableFallback && shouldUseBlankPageFallback && paragraphlessAnchoredTables.length > 0) {
272018
272376
  const state = paginator.ensurePage();
272019
272377
  for (const { block: tableBlock, measure: tableMeasure } of paragraphlessAnchoredTables) {
272020
272378
  const columnWidthForTable = getCurrentColumnWidth();
@@ -272027,7 +272385,7 @@ function layoutDocument(blocks2, measures, options = {}) {
272027
272385
  state.page.fragments.push(createAnchoredTableFragment(tableBlock, tableMeasure, anchorX, anchorY));
272028
272386
  }
272029
272387
  }
272030
- if (allowSectionBreakOnlyPageFallback && pages.length === 0 && hasOnlySectionBreakBlocks(blocks2))
272388
+ if (allowSectionBreakOnlyPageFallback && shouldUseBlankPageFallback && hasOnlySectionBreakBlocks(blocks2))
272031
272389
  paginator.ensurePage();
272032
272390
  for (const page of pages) {
272033
272391
  if (!page.vAlign || page.vAlign === "top")
@@ -304348,11 +304706,15 @@ var Node$13 = class Node$14 {
304348
304706
  setContainer(container) {
304349
304707
  this.#container = container;
304350
304708
  }
304351
- apply(layoutEpoch) {
304709
+ apply(layoutEpoch, options = {}) {
304352
304710
  if (!this.#container)
304353
304711
  return;
304354
304712
  const epochStr = String(layoutEpoch);
304355
304713
  for (const root3 of collectImageRoots(this.#container)) {
304714
+ if (!canInteractWithRoot(root3, options.activeHeaderFooterMode ?? "body")) {
304715
+ clearImageRoot(root3);
304716
+ continue;
304717
+ }
304356
304718
  if (root3.dataset[INTERACTION_EPOCH_KEY$1] === epochStr)
304357
304719
  continue;
304358
304720
  const pmStart = parsePmNumber(root3.dataset.pmStart);
@@ -304372,14 +304734,8 @@ var Node$13 = class Node$14 {
304372
304734
  clear() {
304373
304735
  if (!this.#container)
304374
304736
  return;
304375
- for (const root3 of collectImageRoots(this.#container)) {
304376
- root3.removeAttribute("draggable");
304377
- delete root3.dataset.dragSourceKind;
304378
- delete root3.dataset.imageKind;
304379
- delete root3.dataset.nodeType;
304380
- delete root3.dataset.displayLabel;
304381
- delete root3.dataset[INTERACTION_EPOCH_KEY$1];
304382
- }
304737
+ for (const root3 of collectImageRoots(this.#container))
304738
+ clearImageRoot(root3);
304383
304739
  }
304384
304740
  }, BLOCK_LABEL_SELECTOR = ".superdoc-structured-content__label", INLINE_LABEL_SELECTOR, INTERACTION_EPOCH_KEY = "structuredContentInteractionEpoch", StructuredContentInteractionLayer = class {
304385
304741
  #container = null;
@@ -304509,7 +304865,7 @@ var Node$13 = class Node$14 {
304509
304865
  refreshAfterPaint(options) {
304510
304866
  this.#fieldAnnotationLayer.apply(options.layoutEpoch);
304511
304867
  options.rebuildDomPositionIndex();
304512
- this.#imageLayer.apply(options.layoutEpoch);
304868
+ this.#imageLayer.apply(options.layoutEpoch, { activeHeaderFooterMode: options.activeHeaderFooterMode });
304513
304869
  this.#structuredContentLayer.apply(options.layoutEpoch);
304514
304870
  this.syncInlineStyleLayers(options.editorState, options.domPositionIndex);
304515
304871
  this.applyProofingAnnotations(options.proofingAnnotations, options.rebuildDomPositionIndex);
@@ -310692,11 +311048,16 @@ menclose::after {
310692
311048
  geoSdtWrapper.style.left = `${elemLeftPx}px`;
310693
311049
  geoSdtWrapper.style.top = "0px";
310694
311050
  geoSdtWrapper.style.height = `${line.lineHeight}px`;
311051
+ geoSdtWrapper.style.padding = "0px";
311052
+ geoSdtWrapper.style.borderWidth = "0px";
311053
+ geoSdtWrapper.style.lineHeight = `${line.lineHeight}px`;
310695
311054
  }
310696
311055
  if (isImageRun$1(runForSdt))
310697
311056
  geoSdtWrapper.dataset.containsInlineImage = "true";
310698
311057
  runContext.syncInlineSdtWrapperTypography(geoSdtWrapper, runForSdt);
311058
+ geoSdtWrapper.style.lineHeight = `${line.lineHeight}px`;
310699
311059
  elem.style.left = `${elemLeftPx - geoSdtWrapperLeft}px`;
311060
+ elem.style.top = "0px";
310700
311061
  geoSdtMaxRight = Math.max(geoSdtMaxRight, elemLeftPx + elemWidthPx);
310701
311062
  runContext.expandSdtWrapperPmRange(geoSdtWrapper, runForSdt.pmStart, runForSdt.pmEnd);
310702
311063
  geoSdtWrapper.appendChild(elem);
@@ -311917,7 +312278,7 @@ menclose::after {
311917
312278
  else
311918
312279
  pageY = effectiveOffset + fragment.y + (kind === "footer" ? footerYOffset : 0);
311919
312280
  fragEl.style.top = `${pageY}px`;
311920
- fragEl.style.left = `${marginLeft + fragment.x}px`;
312281
+ fragEl.style.left = `${isPageRelative ? fragment.x : marginLeft + fragment.x}px`;
311921
312282
  fragEl.style.zIndex = "0";
311922
312283
  fragEl.dataset.behindDocSection = kind;
311923
312284
  pageEl.insertBefore(fragEl, pageEl.firstChild);
@@ -314987,7 +315348,7 @@ menclose::after {
314987
315348
  if (transform2 === "capitalize")
314988
315349
  return capitalizeText$2(text5, fullText, startOffset);
314989
315350
  return text5;
314990
- }, DEFAULT_TAB_INTERVAL_TWIPS$1 = 720, TWIPS_PER_PX$2, TAB_EPSILON$1 = 0.1, WIDTH_FUDGE_PX = 0.5, twipsToPx$1 = (twips) => twips / TWIPS_PER_PX$2, pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$2), sanitizeIndent$1 = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0, sanitizeRawIndent = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0, sanitizeDecimalSeparator$1 = (value) => value === "," ? "," : ".", getRunWidth = (run2) => {
315351
+ }, DEFAULT_TAB_INTERVAL_TWIPS$12 = 720, TWIPS_PER_PX$2, TAB_EPSILON$1 = 0.1, WIDTH_FUDGE_PX = 0.5, twipsToPx$1 = (twips) => twips / TWIPS_PER_PX$2, pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$2), sanitizeIndent$1 = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0, sanitizeRawIndent = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0, sanitizeDecimalSeparator$1 = (value) => value === "," ? "," : ".", getRunWidth = (run2) => {
314991
315352
  const width = run2.width;
314992
315353
  return typeof width === "number" ? width : 0;
314993
315354
  }, isLineBreakRun$1 = (run2) => run2.kind === "lineBreak" || run2.kind === "break" && run2.breakType === "line", markerFontString = (run2) => {
@@ -315009,7 +315370,7 @@ menclose::after {
315009
315370
  };
315010
315371
  return computeTabStops({
315011
315372
  explicitStops: tabs ?? [],
315012
- defaultTabInterval: tabIntervalTwips ?? DEFAULT_TAB_INTERVAL_TWIPS$1,
315373
+ defaultTabInterval: tabIntervalTwips ?? DEFAULT_TAB_INTERVAL_TWIPS$12,
315013
315374
  paragraphIndent: paragraphIndentTwips,
315014
315375
  rawParagraphIndent: rawParagraphIndentTwips
315015
315376
  }).map((stop) => ({
@@ -315029,7 +315390,7 @@ menclose::after {
315029
315390
  stop: tabStops[index2]
315030
315391
  };
315031
315392
  return {
315032
- target: currentX + twipsToPx$1(DEFAULT_TAB_INTERVAL_TWIPS$1),
315393
+ target: currentX + twipsToPx$1(DEFAULT_TAB_INTERVAL_TWIPS$12),
315033
315394
  nextIndex: index2
315034
315395
  };
315035
315396
  }, scanTabAlignmentGroup = (runs2, startRunIndex, startChar, decimalSeparator) => {
@@ -323008,13 +323369,13 @@ menclose::after {
323008
323369
  return;
323009
323370
  console.log(...args$1);
323010
323371
  }, 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;
323011
- var init_src_PJVnllcq_es = __esm(() => {
323372
+ var init_src_DHPdEVg9_es = __esm(() => {
323012
323373
  init_rolldown_runtime_Bg48TavK_es();
323013
- init_SuperConverter_DK5WIHuy_es();
323374
+ init_SuperConverter_DAuqlmYY_es();
323014
323375
  init_jszip_C49i9kUs_es();
323015
323376
  init_xml_js_CqGKpaft_es();
323016
323377
  init_uuid_B2wVPhPi_es();
323017
- init_create_headless_toolbar_BLN1v7eO_es();
323378
+ init_create_headless_toolbar_BT0XKtIW_es();
323018
323379
  init_constants_D9qj59G2_es();
323019
323380
  init_dist_B8HfvhaK_es();
323020
323381
  init_unified_Dsuw2be5_es();
@@ -355155,6 +355516,7 @@ function print() { __p += __j.call(arguments, '') }
355155
355516
  pageIndex: session.pageIndex,
355156
355517
  pageNumber: session.pageNumber
355157
355518
  });
355519
+ this.#refreshEditorDomAugmentations();
355158
355520
  this.#updateAwarenessSession();
355159
355521
  },
355160
355522
  onEditingContext: (data) => {
@@ -356403,6 +356765,7 @@ function print() { __p += __j.call(arguments, '') }
356403
356765
  #refreshEditorDomAugmentations() {
356404
356766
  this.#postPaintPipeline.refreshAfterPaint({
356405
356767
  layoutEpoch: this.#layoutEpoch,
356768
+ activeHeaderFooterMode: this.#headerFooterSession?.session?.mode ?? "body",
356406
356769
  editorState: this.#editor?.view?.state,
356407
356770
  domPositionIndex: this.#domPositionIndex,
356408
356771
  proofingAnnotations: this.#buildProofingAnnotations(),
@@ -358799,11 +359162,11 @@ function print() { __p += __j.call(arguments, '') }
358799
359162
  ]);
358800
359163
  });
358801
359164
 
358802
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CrjXK3s_.es.js
359165
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-Zmv88GYo.es.js
358803
359166
  var DEFAULT_TEXT_ALIGN_OPTIONS, DEFAULT_LINE_HEIGHT_OPTIONS, DEFAULT_ZOOM_OPTIONS, DEFAULT_DOCUMENT_MODE_OPTIONS, DEFAULT_FONT_SIZE_OPTIONS, 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, FONT_SIZE_OPTIONS;
358804
- var init_create_super_doc_ui_CrjXK3s__es = __esm(() => {
358805
- init_SuperConverter_DK5WIHuy_es();
358806
- init_create_headless_toolbar_BLN1v7eO_es();
359167
+ var init_create_super_doc_ui_Zmv88GYo_es = __esm(() => {
359168
+ init_SuperConverter_DAuqlmYY_es();
359169
+ init_create_headless_toolbar_BT0XKtIW_es();
358807
359170
  DEFAULT_TEXT_ALIGN_OPTIONS = [
358808
359171
  {
358809
359172
  label: "Left",
@@ -359094,16 +359457,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
359094
359457
 
359095
359458
  // ../../packages/superdoc/dist/super-editor.es.js
359096
359459
  var init_super_editor_es = __esm(() => {
359097
- init_src_PJVnllcq_es();
359098
- init_SuperConverter_DK5WIHuy_es();
359460
+ init_src_DHPdEVg9_es();
359461
+ init_SuperConverter_DAuqlmYY_es();
359099
359462
  init_jszip_C49i9kUs_es();
359100
359463
  init_xml_js_CqGKpaft_es();
359101
- init_create_headless_toolbar_BLN1v7eO_es();
359464
+ init_create_headless_toolbar_BT0XKtIW_es();
359102
359465
  init_constants_D9qj59G2_es();
359103
359466
  init_dist_B8HfvhaK_es();
359104
359467
  init_unified_Dsuw2be5_es();
359105
359468
  init_DocxZipper_FUsfThjV_es();
359106
- init_create_super_doc_ui_CrjXK3s__es();
359469
+ init_create_super_doc_ui_Zmv88GYo_es();
359107
359470
  init_ui_C5PAS9hY_es();
359108
359471
  init_eventemitter3_BnGqBE_Q_es();
359109
359472
  init_errors_CNaD6vcg_es();
@@ -447179,12 +447542,243 @@ function collectTextBoxParagraphs2(nodes, paragraphs = []) {
447179
447542
  paragraphs.push(node4);
447180
447543
  return;
447181
447544
  }
447545
+ if (node4.name === "w:tbl") {
447546
+ paragraphs.push(...flattenTextBoxTableToParagraphs2(node4));
447547
+ return;
447548
+ }
447182
447549
  if (Array.isArray(node4.elements)) {
447183
447550
  collectTextBoxParagraphs2(node4.elements, paragraphs);
447184
447551
  }
447185
447552
  });
447186
447553
  return paragraphs;
447187
447554
  }
447555
+ function flattenTextBoxTableToParagraphs2(table2) {
447556
+ const rows = table2.elements?.filter((node4) => node4?.name === "w:tr") || [];
447557
+ if (!rows.length)
447558
+ return [];
447559
+ const gridWidths = extractTableGridWidths2(table2);
447560
+ const paragraphs = [];
447561
+ rows.forEach((row2) => {
447562
+ const cells = row2.elements?.filter((node4) => node4?.name === "w:tc") || [];
447563
+ if (!cells.length)
447564
+ return;
447565
+ const columnStarts = buildColumnStarts2(cells, gridWidths);
447566
+ const cellLines = cells.map((cell2) => collectTextBoxTableCellLines2(cell2));
447567
+ const maxLineCount = cellLines.reduce((max3, lines) => Math.max(max3, lines.length), 0);
447568
+ for (let lineIndex = 0;lineIndex < maxLineCount; lineIndex += 1) {
447569
+ const lineParts = cellLines.map((lines) => lines[lineIndex] || null);
447570
+ if (!lineParts.some((line) => line && hasRenderableLineContent2(line.elements)))
447571
+ continue;
447572
+ paragraphs.push(buildTableVisualLineParagraph2(lineParts, columnStarts));
447573
+ }
447574
+ });
447575
+ return paragraphs;
447576
+ }
447577
+ function extractTableGridWidths2(table2) {
447578
+ const grid = table2.elements?.find((node4) => node4?.name === "w:tblGrid");
447579
+ return grid?.elements?.filter((node4) => node4?.name === "w:gridCol").map((node4) => toFiniteNumber4(node4.attributes?.["w:w"] ?? node4.attributes?.w)).filter((value) => value != null && value > 0) || [];
447580
+ }
447581
+ function buildColumnStarts2(cells, gridWidths) {
447582
+ const starts = [];
447583
+ let cursor = 0;
447584
+ let gridIndex = 0;
447585
+ cells.forEach((cell2) => {
447586
+ starts.push(cursor);
447587
+ const gridSpan = resolveCellGridSpan2(cell2);
447588
+ cursor += resolveCellWidth2(cell2, gridWidths, gridIndex, gridSpan);
447589
+ gridIndex += gridSpan;
447590
+ });
447591
+ return starts;
447592
+ }
447593
+ function resolveCellGridSpan2(cell2) {
447594
+ const tcPr = cell2.elements?.find((node4) => node4?.name === "w:tcPr");
447595
+ const gridSpan = tcPr?.elements?.find((node4) => node4?.name === "w:gridSpan");
447596
+ const value = toFiniteNumber4(gridSpan?.attributes?.["w:val"] ?? gridSpan?.attributes?.val);
447597
+ return value && value > 0 ? Math.max(1, Math.floor(value)) : 1;
447598
+ }
447599
+ function resolveCellWidth2(cell2, gridWidths, gridIndex, gridSpan) {
447600
+ const gridWidth = sumGridWidths2(gridWidths, gridIndex, gridSpan);
447601
+ if (gridWidth > 0)
447602
+ return gridWidth;
447603
+ const tcPr = cell2.elements?.find((node4) => node4?.name === "w:tcPr");
447604
+ const tcW = tcPr?.elements?.find((node4) => node4?.name === "w:tcW");
447605
+ const width = toFiniteNumber4(tcW?.attributes?.["w:w"] ?? tcW?.attributes?.w);
447606
+ return width && width > 0 ? width : 0;
447607
+ }
447608
+ function sumGridWidths2(gridWidths, gridIndex, gridSpan) {
447609
+ if (!Array.isArray(gridWidths) || gridWidths.length === 0)
447610
+ return 0;
447611
+ let width = 0;
447612
+ for (let offset2 = 0;offset2 < gridSpan; offset2 += 1) {
447613
+ const gridWidth = gridWidths[gridIndex + offset2];
447614
+ if (gridWidth != null && gridWidth > 0) {
447615
+ width += gridWidth;
447616
+ }
447617
+ }
447618
+ return width;
447619
+ }
447620
+ function collectTextBoxTableCellLines2(cell2) {
447621
+ const paragraphNodes = [];
447622
+ collectTextBoxParagraphsSkippingTables2(cell2.elements || [], paragraphNodes);
447623
+ return paragraphNodes.flatMap((paragraph4) => splitTextBoxParagraphIntoVisualLines2(paragraph4));
447624
+ }
447625
+ function collectTextBoxParagraphsSkippingTables2(nodes, paragraphs) {
447626
+ if (!Array.isArray(nodes))
447627
+ return;
447628
+ nodes.forEach((node4) => {
447629
+ if (!node4)
447630
+ return;
447631
+ if (node4.name === "w:p") {
447632
+ paragraphs.push(node4);
447633
+ return;
447634
+ }
447635
+ if (node4.name === "w:tbl")
447636
+ return;
447637
+ if (Array.isArray(node4.elements)) {
447638
+ collectTextBoxParagraphsSkippingTables2(node4.elements, paragraphs);
447639
+ }
447640
+ });
447641
+ }
447642
+ function splitTextBoxParagraphIntoVisualLines2(paragraph4) {
447643
+ const pPr = paragraph4.elements?.find((node4) => node4?.name === "w:pPr") || null;
447644
+ const lines = [{ pPr, elements: [] }];
447645
+ const appendToCurrentLine = (element3) => {
447646
+ lines[lines.length - 1].elements.push(element3);
447647
+ };
447648
+ for (const element3 of paragraph4.elements || []) {
447649
+ if (!element3 || element3.name === "w:pPr")
447650
+ continue;
447651
+ if (element3.name !== "w:r" || !Array.isArray(element3.elements)) {
447652
+ appendToCurrentLine(carbonCopy2(element3));
447653
+ continue;
447654
+ }
447655
+ splitRunAroundBreaks2(element3, appendToCurrentLine, () => {
447656
+ lines.push({ pPr, elements: [] });
447657
+ });
447658
+ }
447659
+ while (lines.length > 1 && !hasRenderableLineContent2(lines[lines.length - 1].elements)) {
447660
+ lines.pop();
447661
+ }
447662
+ return lines;
447663
+ }
447664
+ function splitRunAroundBreaks2(run2, appendRun, startNewLine) {
447665
+ let runElements = [];
447666
+ const runProperties = run2.elements?.filter((node4) => node4?.name === "w:rPr").map((node4) => carbonCopy2(node4)) || [];
447667
+ const flushRun = () => {
447668
+ const meaningfulElements = runElements.filter((node4) => node4?.name !== "w:rPr");
447669
+ if (!meaningfulElements.length) {
447670
+ runElements = runProperties.map((node4) => carbonCopy2(node4));
447671
+ return;
447672
+ }
447673
+ appendRun({
447674
+ ...carbonCopy2(run2),
447675
+ elements: runElements
447676
+ });
447677
+ runElements = runProperties.map((node4) => carbonCopy2(node4));
447678
+ };
447679
+ run2.elements.forEach((child) => {
447680
+ if (child?.name === "w:br") {
447681
+ flushRun();
447682
+ startNewLine();
447683
+ return;
447684
+ }
447685
+ runElements.push(carbonCopy2(child));
447686
+ });
447687
+ flushRun();
447688
+ }
447689
+ function buildTableVisualLineParagraph2(lineParts, columnStarts) {
447690
+ const baseLine = lineParts.find((line) => line?.pPr) || lineParts.find(Boolean);
447691
+ const pPr = buildVisualLineParagraphProperties2(baseLine?.pPr, lineParts, columnStarts);
447692
+ const elements = pPr ? [pPr] : [];
447693
+ lineParts.forEach((line, index3) => {
447694
+ if (!line || !hasRenderableLineContent2(line.elements))
447695
+ return;
447696
+ if (index3 > 0)
447697
+ elements.push(createTabRun2());
447698
+ elements.push(...line.elements.map((element3) => carbonCopy2(element3)));
447699
+ });
447700
+ return { name: "w:p", elements };
447701
+ }
447702
+ function buildVisualLineParagraphProperties2(basePPr, lineParts, columnStarts) {
447703
+ const pPr = basePPr ? carbonCopy2(basePPr) : { name: "w:pPr", elements: [] };
447704
+ pPr.elements = (pPr.elements || []).filter((node4) => node4?.name !== "w:tabs");
447705
+ const tabStops = [];
447706
+ lineParts.forEach((line, index3) => {
447707
+ const columnStart = columnStarts[index3] || 0;
447708
+ if (index3 > 0 && columnStart > 0 && line && hasRenderableLineContent2(line.elements)) {
447709
+ tabStops.push(createTabStop2(columnStart));
447710
+ }
447711
+ const sourceTabs = extractTabs2(line?.pPr);
447712
+ let positionedSourceTabCount = 0;
447713
+ sourceTabs.forEach((tab) => {
447714
+ const pos = toFiniteNumber4(tab.attributes?.["w:pos"] ?? tab.attributes?.pos);
447715
+ if (pos == null)
447716
+ return;
447717
+ positionedSourceTabCount += 1;
447718
+ tabStops.push(createTabStop2(columnStart + pos, tab.attributes));
447719
+ });
447720
+ const tabRunCount = countTabRuns2(line?.elements);
447721
+ for (let tabIndex = positionedSourceTabCount;tabIndex < tabRunCount; tabIndex += 1) {
447722
+ tabStops.push(createTabStop2(resolveDefaultInternalTabPos2(columnStart, tabIndex)));
447723
+ }
447724
+ });
447725
+ if (tabStops.length > 0) {
447726
+ pPr.elements.push({ name: "w:tabs", elements: dedupeTabStops2(tabStops) });
447727
+ }
447728
+ return pPr.elements.length > 0 ? pPr : null;
447729
+ }
447730
+ function extractTabs2(pPr) {
447731
+ const tabs2 = pPr?.elements?.find((node4) => node4?.name === "w:tabs");
447732
+ return tabs2?.elements?.filter((node4) => node4?.name === "w:tab") || [];
447733
+ }
447734
+ function countTabRuns2(elements = []) {
447735
+ return elements.reduce((count, element3) => {
447736
+ if (element3?.name === "w:tab")
447737
+ return count + 1;
447738
+ if (Array.isArray(element3?.elements))
447739
+ return count + countTabRuns2(element3.elements);
447740
+ return count;
447741
+ }, 0);
447742
+ }
447743
+ function resolveDefaultInternalTabPos2(columnStart, tabIndex) {
447744
+ return columnStart + DEFAULT_TAB_INTERVAL_TWIPS3 * (tabIndex + 1);
447745
+ }
447746
+ function createTabRun2() {
447747
+ return { name: "w:r", elements: [{ name: "w:tab" }] };
447748
+ }
447749
+ function createTabStop2(pos, sourceAttributes = {}) {
447750
+ return {
447751
+ name: "w:tab",
447752
+ attributes: {
447753
+ ...sourceAttributes,
447754
+ "w:val": sourceAttributes["w:val"] || sourceAttributes.val || "left",
447755
+ "w:pos": String(pos)
447756
+ }
447757
+ };
447758
+ }
447759
+ function dedupeTabStops2(tabStops) {
447760
+ const seen = new Set;
447761
+ return tabStops.filter((tab) => {
447762
+ const key2 = `${tab.attributes?.["w:val"] || ""}:${tab.attributes?.["w:pos"] || ""}`;
447763
+ if (seen.has(key2))
447764
+ return false;
447765
+ seen.add(key2);
447766
+ return true;
447767
+ }).sort((a2, b2) => Number(a2.attributes?.["w:pos"] || 0) - Number(b2.attributes?.["w:pos"] || 0));
447768
+ }
447769
+ function hasRenderableLineContent2(elements) {
447770
+ return elements.some((element3) => {
447771
+ if (element3?.name === "w:tab")
447772
+ return true;
447773
+ if (element3?.name === "w:t")
447774
+ return true;
447775
+ return Array.isArray(element3?.elements) && hasRenderableLineContent2(element3.elements);
447776
+ });
447777
+ }
447778
+ function toFiniteNumber4(value) {
447779
+ const number6 = Number(value);
447780
+ return Number.isFinite(number6) ? number6 : null;
447781
+ }
447188
447782
  function preProcessTextBoxContent2(textBoxContent, params3 = {}) {
447189
447783
  if (!textBoxContent?.elements)
447190
447784
  return textBoxContent;
@@ -447288,7 +447882,7 @@ function extractBodyPrProperties2(bodyPr) {
447288
447882
  const wrap6 = bodyPrAttrs["wrap"] || "square";
447289
447883
  return { verticalAlign, insets, wrap: wrap6 };
447290
447884
  }
447291
- var HEADER_FOOTER_FILENAME_PATTERN2;
447885
+ var HEADER_FOOTER_FILENAME_PATTERN2, DEFAULT_TAB_INTERVAL_TWIPS3 = 720;
447292
447886
  var init_textbox_content_helpers = __esm(() => {
447293
447887
  init_preProcessNodesForFldChar();
447294
447888
  init_preProcessPageFieldsOnly();
@@ -447751,6 +448345,8 @@ function handleImageNode3(node4, params3, isAnchor) {
447751
448345
  const simplePosNode = node4?.elements?.find((el) => el.name === "wp:simplePos");
447752
448346
  const wrapNode = isAnchor ? node4?.elements?.find((el) => ["wp:wrapNone", "wp:wrapSquare", "wp:wrapThrough", "wp:wrapTight", "wp:wrapTopAndBottom"].includes(el.name)) : null;
447753
448347
  const wrap6 = isAnchor ? { type: wrapNode?.name.slice(7) || "None", attrs: {} } : { type: "Inline" };
448348
+ const hasBehindDocAttribute = isAnchor && attributes.behindDoc != null;
448349
+ const isBehindDoc = attributes.behindDoc === "1" || attributes.behindDoc === 1 || attributes.behindDoc === true;
447754
448350
  switch (wrap6.type) {
447755
448351
  case "Square":
447756
448352
  if (wrapNode?.attributes?.wrapText) {
@@ -447804,7 +448400,7 @@ function handleImageNode3(node4, params3, isAnchor) {
447804
448400
  }
447805
448401
  break;
447806
448402
  case "None":
447807
- wrap6.attrs.behindDoc = node4.attributes?.behindDoc === "1";
448403
+ wrap6.attrs.behindDoc = isBehindDoc;
447808
448404
  break;
447809
448405
  case "Inline":
447810
448406
  break;
@@ -447814,6 +448410,9 @@ function handleImageNode3(node4, params3, isAnchor) {
447814
448410
  if (wrap6.type === "Square" || wrap6.type === "Tight" || wrap6.type === "Through" || wrap6.type === "TopAndBottom") {
447815
448411
  mergeAnchorPaddingIntoWrapDistances2(wrap6, padding);
447816
448412
  }
448413
+ if (hasBehindDocAttribute && wrap6.attrs) {
448414
+ wrap6.attrs.behindDoc = isBehindDoc;
448415
+ }
447817
448416
  const docPr = node4.elements.find((el) => el.name === "wp:docPr");
447818
448417
  const isHidden = isDocPrHidden2(docPr);
447819
448418
  let anchorData = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/mcp",
3
- "version": "0.12.0-next.27",
3
+ "version": "0.12.0-next.29",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -19,8 +19,8 @@
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",
23
+ "@superdoc/document-api": "0.0.1",
24
24
  "superdoc": "1.39.0"
25
25
  },
26
26
  "publishConfig": {