@superdoc-dev/cli 0.17.0-next.27 → 0.17.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 +409 -46
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -68327,7 +68327,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
68327
68327
  emptyOptions2 = {};
68328
68328
  });
68329
68329
 
68330
- // ../../packages/superdoc/dist/chunks/SuperConverter-DK5WIHuy.es.js
68330
+ // ../../packages/superdoc/dist/chunks/SuperConverter-DAuqlmYY.es.js
68331
68331
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
68332
68332
  const fieldValue = extension$1.config[field];
68333
68333
  if (typeof fieldValue === "function")
@@ -84110,11 +84110,248 @@ function collectTextBoxParagraphs(nodes, paragraphs = []) {
84110
84110
  paragraphs.push(node3);
84111
84111
  return;
84112
84112
  }
84113
+ if (node3.name === "w:tbl") {
84114
+ paragraphs.push(...flattenTextBoxTableToParagraphs(node3));
84115
+ return;
84116
+ }
84113
84117
  if (Array.isArray(node3.elements))
84114
84118
  collectTextBoxParagraphs(node3.elements, paragraphs);
84115
84119
  });
84116
84120
  return paragraphs;
84117
84121
  }
84122
+ function flattenTextBoxTableToParagraphs(table) {
84123
+ const rows = table.elements?.filter((node3) => node3?.name === "w:tr") || [];
84124
+ if (!rows.length)
84125
+ return [];
84126
+ const gridWidths = extractTableGridWidths(table);
84127
+ const paragraphs = [];
84128
+ rows.forEach((row) => {
84129
+ const cells = row.elements?.filter((node3) => node3?.name === "w:tc") || [];
84130
+ if (!cells.length)
84131
+ return;
84132
+ const columnStarts = buildColumnStarts(cells, gridWidths);
84133
+ const cellLines = cells.map((cell) => collectTextBoxTableCellLines(cell));
84134
+ const maxLineCount = cellLines.reduce((max4, lines) => Math.max(max4, lines.length), 0);
84135
+ for (let lineIndex = 0;lineIndex < maxLineCount; lineIndex += 1) {
84136
+ const lineParts = cellLines.map((lines) => lines[lineIndex] || null);
84137
+ if (!lineParts.some((line) => line && hasRenderableLineContent(line.elements)))
84138
+ continue;
84139
+ paragraphs.push(buildTableVisualLineParagraph(lineParts, columnStarts));
84140
+ }
84141
+ });
84142
+ return paragraphs;
84143
+ }
84144
+ function extractTableGridWidths(table) {
84145
+ return table.elements?.find((node3) => node3?.name === "w:tblGrid")?.elements?.filter((node3) => node3?.name === "w:gridCol").map((node3) => toFiniteNumber$3(node3.attributes?.["w:w"] ?? node3.attributes?.w)).filter((value) => value != null && value > 0) || [];
84146
+ }
84147
+ function buildColumnStarts(cells, gridWidths) {
84148
+ const starts = [];
84149
+ let cursor = 0;
84150
+ let gridIndex = 0;
84151
+ cells.forEach((cell) => {
84152
+ starts.push(cursor);
84153
+ const gridSpan = resolveCellGridSpan(cell);
84154
+ cursor += resolveCellWidth(cell, gridWidths, gridIndex, gridSpan);
84155
+ gridIndex += gridSpan;
84156
+ });
84157
+ return starts;
84158
+ }
84159
+ function resolveCellGridSpan(cell) {
84160
+ const gridSpan = cell.elements?.find((node3) => node3?.name === "w:tcPr")?.elements?.find((node3) => node3?.name === "w:gridSpan");
84161
+ const value = toFiniteNumber$3(gridSpan?.attributes?.["w:val"] ?? gridSpan?.attributes?.val);
84162
+ return value && value > 0 ? Math.max(1, Math.floor(value)) : 1;
84163
+ }
84164
+ function resolveCellWidth(cell, gridWidths, gridIndex, gridSpan) {
84165
+ const gridWidth = sumGridWidths(gridWidths, gridIndex, gridSpan);
84166
+ if (gridWidth > 0)
84167
+ return gridWidth;
84168
+ const tcW = cell.elements?.find((node3) => node3?.name === "w:tcPr")?.elements?.find((node3) => node3?.name === "w:tcW");
84169
+ const width = toFiniteNumber$3(tcW?.attributes?.["w:w"] ?? tcW?.attributes?.w);
84170
+ return width && width > 0 ? width : 0;
84171
+ }
84172
+ function sumGridWidths(gridWidths, gridIndex, gridSpan) {
84173
+ if (!Array.isArray(gridWidths) || gridWidths.length === 0)
84174
+ return 0;
84175
+ let width = 0;
84176
+ for (let offset = 0;offset < gridSpan; offset += 1) {
84177
+ const gridWidth = gridWidths[gridIndex + offset];
84178
+ if (gridWidth != null && gridWidth > 0)
84179
+ width += gridWidth;
84180
+ }
84181
+ return width;
84182
+ }
84183
+ function collectTextBoxTableCellLines(cell) {
84184
+ const paragraphNodes = [];
84185
+ collectTextBoxParagraphsSkippingTables(cell.elements || [], paragraphNodes);
84186
+ return paragraphNodes.flatMap((paragraph2) => splitTextBoxParagraphIntoVisualLines(paragraph2));
84187
+ }
84188
+ function collectTextBoxParagraphsSkippingTables(nodes, paragraphs) {
84189
+ if (!Array.isArray(nodes))
84190
+ return;
84191
+ nodes.forEach((node3) => {
84192
+ if (!node3)
84193
+ return;
84194
+ if (node3.name === "w:p") {
84195
+ paragraphs.push(node3);
84196
+ return;
84197
+ }
84198
+ if (node3.name === "w:tbl")
84199
+ return;
84200
+ if (Array.isArray(node3.elements))
84201
+ collectTextBoxParagraphsSkippingTables(node3.elements, paragraphs);
84202
+ });
84203
+ }
84204
+ function splitTextBoxParagraphIntoVisualLines(paragraph2) {
84205
+ const pPr = paragraph2.elements?.find((node3) => node3?.name === "w:pPr") || null;
84206
+ const lines = [{
84207
+ pPr,
84208
+ elements: []
84209
+ }];
84210
+ const appendToCurrentLine = (element) => {
84211
+ lines[lines.length - 1].elements.push(element);
84212
+ };
84213
+ for (const element of paragraph2.elements || []) {
84214
+ if (!element || element.name === "w:pPr")
84215
+ continue;
84216
+ if (element.name !== "w:r" || !Array.isArray(element.elements)) {
84217
+ appendToCurrentLine(carbonCopy(element));
84218
+ continue;
84219
+ }
84220
+ splitRunAroundBreaks(element, appendToCurrentLine, () => {
84221
+ lines.push({
84222
+ pPr,
84223
+ elements: []
84224
+ });
84225
+ });
84226
+ }
84227
+ while (lines.length > 1 && !hasRenderableLineContent(lines[lines.length - 1].elements))
84228
+ lines.pop();
84229
+ return lines;
84230
+ }
84231
+ function splitRunAroundBreaks(run$1, appendRun, startNewLine) {
84232
+ let runElements = [];
84233
+ const runProperties = run$1.elements?.filter((node3) => node3?.name === "w:rPr").map((node3) => carbonCopy(node3)) || [];
84234
+ const flushRun = () => {
84235
+ if (!runElements.filter((node3) => node3?.name !== "w:rPr").length) {
84236
+ runElements = runProperties.map((node3) => carbonCopy(node3));
84237
+ return;
84238
+ }
84239
+ appendRun({
84240
+ ...carbonCopy(run$1),
84241
+ elements: runElements
84242
+ });
84243
+ runElements = runProperties.map((node3) => carbonCopy(node3));
84244
+ };
84245
+ run$1.elements.forEach((child) => {
84246
+ if (child?.name === "w:br") {
84247
+ flushRun();
84248
+ startNewLine();
84249
+ return;
84250
+ }
84251
+ runElements.push(carbonCopy(child));
84252
+ });
84253
+ flushRun();
84254
+ }
84255
+ function buildTableVisualLineParagraph(lineParts, columnStarts) {
84256
+ const pPr = buildVisualLineParagraphProperties((lineParts.find((line) => line?.pPr) || lineParts.find(Boolean))?.pPr, lineParts, columnStarts);
84257
+ const elements = pPr ? [pPr] : [];
84258
+ lineParts.forEach((line, index2) => {
84259
+ if (!line || !hasRenderableLineContent(line.elements))
84260
+ return;
84261
+ if (index2 > 0)
84262
+ elements.push(createTabRun());
84263
+ elements.push(...line.elements.map((element) => carbonCopy(element)));
84264
+ });
84265
+ return {
84266
+ name: "w:p",
84267
+ elements
84268
+ };
84269
+ }
84270
+ function buildVisualLineParagraphProperties(basePPr, lineParts, columnStarts) {
84271
+ const pPr = basePPr ? carbonCopy(basePPr) : {
84272
+ name: "w:pPr",
84273
+ elements: []
84274
+ };
84275
+ pPr.elements = (pPr.elements || []).filter((node3) => node3?.name !== "w:tabs");
84276
+ const tabStops = [];
84277
+ lineParts.forEach((line, index2) => {
84278
+ const columnStart = columnStarts[index2] || 0;
84279
+ if (index2 > 0 && columnStart > 0 && line && hasRenderableLineContent(line.elements))
84280
+ tabStops.push(createTabStop(columnStart));
84281
+ const sourceTabs = extractTabs(line?.pPr);
84282
+ let positionedSourceTabCount = 0;
84283
+ sourceTabs.forEach((tab) => {
84284
+ const pos = toFiniteNumber$3(tab.attributes?.["w:pos"] ?? tab.attributes?.pos);
84285
+ if (pos == null)
84286
+ return;
84287
+ positionedSourceTabCount += 1;
84288
+ tabStops.push(createTabStop(columnStart + pos, tab.attributes));
84289
+ });
84290
+ const tabRunCount = countTabRuns(line?.elements);
84291
+ for (let tabIndex = positionedSourceTabCount;tabIndex < tabRunCount; tabIndex += 1)
84292
+ tabStops.push(createTabStop(resolveDefaultInternalTabPos(columnStart, tabIndex)));
84293
+ });
84294
+ if (tabStops.length > 0)
84295
+ pPr.elements.push({
84296
+ name: "w:tabs",
84297
+ elements: dedupeTabStops(tabStops)
84298
+ });
84299
+ return pPr.elements.length > 0 ? pPr : null;
84300
+ }
84301
+ function extractTabs(pPr) {
84302
+ return pPr?.elements?.find((node3) => node3?.name === "w:tabs")?.elements?.filter((node3) => node3?.name === "w:tab") || [];
84303
+ }
84304
+ function countTabRuns(elements = []) {
84305
+ return elements.reduce((count2, element) => {
84306
+ if (element?.name === "w:tab")
84307
+ return count2 + 1;
84308
+ if (Array.isArray(element?.elements))
84309
+ return count2 + countTabRuns(element.elements);
84310
+ return count2;
84311
+ }, 0);
84312
+ }
84313
+ function resolveDefaultInternalTabPos(columnStart, tabIndex) {
84314
+ return columnStart + DEFAULT_TAB_INTERVAL_TWIPS$1 * (tabIndex + 1);
84315
+ }
84316
+ function createTabRun() {
84317
+ return {
84318
+ name: "w:r",
84319
+ elements: [{ name: "w:tab" }]
84320
+ };
84321
+ }
84322
+ function createTabStop(pos, sourceAttributes = {}) {
84323
+ return {
84324
+ name: "w:tab",
84325
+ attributes: {
84326
+ ...sourceAttributes,
84327
+ "w:val": sourceAttributes["w:val"] || sourceAttributes.val || "left",
84328
+ "w:pos": String(pos)
84329
+ }
84330
+ };
84331
+ }
84332
+ function dedupeTabStops(tabStops) {
84333
+ const seen = /* @__PURE__ */ new Set;
84334
+ return tabStops.filter((tab) => {
84335
+ const key = `${tab.attributes?.["w:val"] || ""}:${tab.attributes?.["w:pos"] || ""}`;
84336
+ if (seen.has(key))
84337
+ return false;
84338
+ seen.add(key);
84339
+ return true;
84340
+ }).sort((a, b) => Number(a.attributes?.["w:pos"] || 0) - Number(b.attributes?.["w:pos"] || 0));
84341
+ }
84342
+ function hasRenderableLineContent(elements) {
84343
+ return elements.some((element) => {
84344
+ if (element?.name === "w:tab")
84345
+ return true;
84346
+ if (element?.name === "w:t")
84347
+ return true;
84348
+ return Array.isArray(element?.elements) && hasRenderableLineContent(element.elements);
84349
+ });
84350
+ }
84351
+ function toFiniteNumber$3(value) {
84352
+ const number = Number(value);
84353
+ return Number.isFinite(number) ? number : null;
84354
+ }
84118
84355
  function preProcessTextBoxContent(textBoxContent, params3 = {}) {
84119
84356
  if (!textBoxContent?.elements)
84120
84357
  return textBoxContent;
@@ -84530,6 +84767,8 @@ function handleImageNode$1(node3, params3, isAnchor) {
84530
84767
  type: wrapNode?.name.slice(7) || "None",
84531
84768
  attrs: {}
84532
84769
  } : { type: "Inline" };
84770
+ const hasBehindDocAttribute = isAnchor && attributes.behindDoc != null;
84771
+ const isBehindDoc = attributes.behindDoc === "1" || attributes.behindDoc === 1 || attributes.behindDoc === true;
84533
84772
  switch (wrap$1.type) {
84534
84773
  case "Square":
84535
84774
  if (wrapNode?.attributes?.wrapText)
@@ -84570,7 +84809,7 @@ function handleImageNode$1(node3, params3, isAnchor) {
84570
84809
  wrap$1.attrs.distTop = emuToPixels(wrapNode.attributes.distT);
84571
84810
  break;
84572
84811
  case "None":
84573
- wrap$1.attrs.behindDoc = node3.attributes?.behindDoc === "1";
84812
+ wrap$1.attrs.behindDoc = isBehindDoc;
84574
84813
  break;
84575
84814
  case "Inline":
84576
84815
  break;
@@ -84579,6 +84818,8 @@ function handleImageNode$1(node3, params3, isAnchor) {
84579
84818
  }
84580
84819
  if (wrap$1.type === "Square" || wrap$1.type === "Tight" || wrap$1.type === "Through" || wrap$1.type === "TopAndBottom")
84581
84820
  mergeAnchorPaddingIntoWrapDistances(wrap$1, padding);
84821
+ if (hasBehindDocAttribute && wrap$1.attrs)
84822
+ wrap$1.attrs.behindDoc = isBehindDoc;
84582
84823
  const docPr = node3.elements.find((el) => el.name === "wp:docPr");
84583
84824
  const isHidden = isDocPrHidden(docPr);
84584
84825
  let anchorData = null;
@@ -122424,7 +122665,7 @@ var isRegExp = (value) => {
122424
122665
  i$1++;
122425
122666
  }
122426
122667
  return { processedNodes };
122427
- }, HEADER_FOOTER_FILENAME_PATTERN, CHART_TYPE_MAP, CHART_TYPE_NAMES, findChild$1 = (node3, name) => node3?.elements?.find((el) => el.name === name), findChildren$2 = (node3, name) => node3?.elements?.filter((el) => el.name === name) ?? [], getAttr = (node3, attr) => node3?.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) => {
122668
+ }, HEADER_FOOTER_FILENAME_PATTERN, DEFAULT_TAB_INTERVAL_TWIPS$1 = 720, CHART_TYPE_MAP, CHART_TYPE_NAMES, findChild$1 = (node3, name) => node3?.elements?.find((el) => el.name === name), findChildren$2 = (node3, name) => node3?.elements?.filter((el) => el.name === name) ?? [], getAttr = (node3, attr) => node3?.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) => {
122428
122669
  const elements = (paragraphProperties.elements || []).filter((element) => element?.name !== "w:sectPr").map((element) => carbonCopy(element));
122429
122670
  if (elements.length === 0)
122430
122671
  return null;
@@ -134969,7 +135210,7 @@ var isRegExp = (value) => {
134969
135210
  state.kern = kernNode.attributes["w:val"];
134970
135211
  }
134971
135212
  }, SuperConverter;
134972
- var init_SuperConverter_DK5WIHuy_es = __esm(() => {
135213
+ var init_SuperConverter_DAuqlmYY_es = __esm(() => {
134973
135214
  init_rolldown_runtime_Bg48TavK_es();
134974
135215
  init_jszip_C49i9kUs_es();
134975
135216
  init_xml_js_CqGKpaft_es();
@@ -175713,7 +175954,7 @@ var init_SuperConverter_DK5WIHuy_es = __esm(() => {
175713
175954
  };
175714
175955
  });
175715
175956
 
175716
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BLN1v7eO.es.js
175957
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BT0XKtIW.es.js
175717
175958
  function parseSizeUnit(val = "0") {
175718
175959
  const length3 = val.toString() || "0";
175719
175960
  const value = Number.parseFloat(length3);
@@ -186362,8 +186603,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
186362
186603
  }
186363
186604
  };
186364
186605
  };
186365
- var init_create_headless_toolbar_BLN1v7eO_es = __esm(() => {
186366
- init_SuperConverter_DK5WIHuy_es();
186606
+ var init_create_headless_toolbar_BT0XKtIW_es = __esm(() => {
186607
+ init_SuperConverter_DAuqlmYY_es();
186367
186608
  init_uuid_B2wVPhPi_es();
186368
186609
  init_constants_D9qj59G2_es();
186369
186610
  init_dist_B8HfvhaK_es();
@@ -235532,7 +235773,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
235532
235773
  init_remark_gfm_BhnWr3yf_es();
235533
235774
  });
235534
235775
 
235535
- // ../../packages/superdoc/dist/chunks/src-PJVnllcq.es.js
235776
+ // ../../packages/superdoc/dist/chunks/src-DHPdEVg9.es.js
235536
235777
  function deleteProps(obj, propOrProps) {
235537
235778
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
235538
235779
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -274042,6 +274283,23 @@ function resolveImageLabel(root3) {
274042
274283
  function resolveImageKind(root3) {
274043
274284
  return root3.classList.contains(DOM_CLASS_NAMES.IMAGE_FRAGMENT) ? "block" : "inline";
274044
274285
  }
274286
+ function getBehindDocSection(root3) {
274287
+ return root3.closest("[data-behind-doc-section]")?.dataset.behindDocSection ?? null;
274288
+ }
274289
+ function canInteractWithRoot(root3, activeHeaderFooterMode) {
274290
+ const section = getBehindDocSection(root3);
274291
+ if (!section)
274292
+ return true;
274293
+ return section === activeHeaderFooterMode;
274294
+ }
274295
+ function clearImageRoot(root3) {
274296
+ root3.removeAttribute("draggable");
274297
+ delete root3.dataset.dragSourceKind;
274298
+ delete root3.dataset.imageKind;
274299
+ delete root3.dataset.nodeType;
274300
+ delete root3.dataset.displayLabel;
274301
+ delete root3.dataset[INTERACTION_EPOCH_KEY$1];
274302
+ }
274045
274303
  function cssClassForKind(kind) {
274046
274304
  switch (kind) {
274047
274305
  case "spelling":
@@ -280323,7 +280581,8 @@ function collectPreRegisteredAnchors(blocks2, measures) {
280323
280581
  return result;
280324
280582
  }
280325
280583
  function collectAnchoredDrawings(blocks2, measures) {
280326
- const map$12 = /* @__PURE__ */ new Map;
280584
+ const byParagraph = /* @__PURE__ */ new Map;
280585
+ const withoutParagraph = [];
280327
280586
  const len3 = Math.min(blocks2.length, measures.length);
280328
280587
  const paragraphIndexById = buildParagraphIndexById(blocks2, len3);
280329
280588
  for (let i4 = 0;i4 < len3; i4 += 1) {
@@ -280340,17 +280599,28 @@ function collectAnchoredDrawings(blocks2, measures) {
280340
280599
  if (isPageRelativeAnchor(drawingBlock))
280341
280600
  continue;
280342
280601
  const anchorParagraphId = typeof drawingBlock.attrs === "object" && drawingBlock.attrs ? drawingBlock.attrs.anchorParagraphId : undefined;
280343
- const anchorParaIndex = resolveAnchorParagraphIndex(blocks2, len3, paragraphIndexById, i4, anchorParagraphId);
280344
- if (anchorParaIndex == null)
280345
- continue;
280346
- const list5 = map$12.get(anchorParaIndex) ?? [];
280347
- list5.push({
280602
+ const anchoredDrawing = {
280348
280603
  block: drawingBlock,
280349
280604
  measure: drawingMeasure
280350
- });
280351
- map$12.set(anchorParaIndex, list5);
280605
+ };
280606
+ const anchorParaIndex = resolveAnchorParagraphIndex(blocks2, len3, paragraphIndexById, i4, anchorParagraphId);
280607
+ if (anchorParaIndex == null) {
280608
+ withoutParagraph.push(anchoredDrawing);
280609
+ continue;
280610
+ }
280611
+ const list5 = byParagraph.get(anchorParaIndex) ?? [];
280612
+ list5.push(anchoredDrawing);
280613
+ byParagraph.set(anchorParaIndex, list5);
280352
280614
  }
280353
- return map$12;
280615
+ return {
280616
+ byParagraph,
280617
+ withoutParagraph,
280618
+ get size() {
280619
+ return byParagraph.size;
280620
+ },
280621
+ has: (index2) => byParagraph.has(index2),
280622
+ get: (index2) => byParagraph.get(index2)
280623
+ };
280354
280624
  }
280355
280625
  function collectAnchoredTables(blocks2, measures) {
280356
280626
  const len3 = Math.min(blocks2.length, measures.length);
@@ -281553,6 +281823,7 @@ function layoutDocument(blocks2, measures, options = {}) {
281553
281823
  let activeColumns = cloneColumnLayout(options.columns);
281554
281824
  let pendingColumns = null;
281555
281825
  const allowParagraphlessAnchoredTableFallback = options.allowParagraphlessAnchoredTableFallback !== false;
281826
+ const allowParagraphlessAnchoredDrawingFallback = options.allowParagraphlessAnchoredDrawingFallback !== false;
281556
281827
  const allowSectionBreakOnlyPageFallback = options.allowSectionBreakOnlyPageFallback !== false;
281557
281828
  let activeOrientation = null;
281558
281829
  let pendingOrientation = null;
@@ -282243,7 +282514,9 @@ function layoutDocument(blocks2, measures, options = {}) {
282243
282514
  if (block.kind === "paragraph" && blockWithAttrs.attrs?.keepLines === true)
282244
282515
  keepLinesBlockIds.add(block.id);
282245
282516
  });
282246
- const anchoredByParagraph = collectAnchoredDrawings(blocks2, measures);
282517
+ const anchoredDrawings = collectAnchoredDrawings(blocks2, measures);
282518
+ const anchoredByParagraph = anchoredDrawings.byParagraph;
282519
+ const paragraphlessAnchoredDrawings = anchoredDrawings.withoutParagraph;
282247
282520
  const anchoredTables = collectAnchoredTables(blocks2, measures);
282248
282521
  const anchoredTablesByParagraph = anchoredTables.byParagraph;
282249
282522
  const paragraphlessAnchoredTables = anchoredTables.withoutParagraph;
@@ -282263,6 +282536,18 @@ function layoutDocument(blocks2, measures, options = {}) {
282263
282536
  preRegisteredFallbackToContentTop: true
282264
282537
  });
282265
282538
  };
282539
+ const resolveParagraphlessAnchoredDrawingY = (block, measure, state) => resolveAnchoredGraphicY({
282540
+ anchor: block.anchor,
282541
+ objectHeight: measure.height ?? 0,
282542
+ contentTop: state.topMargin,
282543
+ contentBottom: state.contentBottom,
282544
+ pageBottomMargin: state.page.margins?.bottom ?? activeBottomMargin,
282545
+ preRegisteredFallbackToContentTop: true
282546
+ });
282547
+ const resolveParagraphlessAnchoredDrawingX = (block, measure, state) => block.anchor ? computeAnchorX(block.anchor, state.columnIndex, normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)), measure.width, {
282548
+ left: activeLeftMargin,
282549
+ right: activeRightMargin
282550
+ }, activePageSize.w) : columnX(state);
282266
282551
  for (const entry of preRegisteredAnchors) {
282267
282552
  const state = paginator.ensurePage();
282268
282553
  const contentTop = state.topMargin;
@@ -282779,9 +283064,82 @@ function layoutDocument(blocks2, measures, options = {}) {
282779
283064
  activePageCounter = activeSectionPageCounterStart;
282780
283065
  sectionFirstPageNumbers.clear();
282781
283066
  };
282782
- if (pages.length === 0 && (allowParagraphlessAnchoredTableFallback && paragraphlessAnchoredTables.length > 0 || allowSectionBreakOnlyPageFallback && hasOnlySectionBreakBlocks(blocks2)))
283067
+ const shouldUseBlankPageFallback = pages.length === 0;
283068
+ if (shouldUseBlankPageFallback && (allowParagraphlessAnchoredTableFallback && paragraphlessAnchoredTables.length > 0 || allowParagraphlessAnchoredDrawingFallback && paragraphlessAnchoredDrawings.length > 0 || allowSectionBreakOnlyPageFallback && hasOnlySectionBreakBlocks(blocks2)))
282783
283069
  resetPaginationStateForBlankPageFallback();
282784
- if (allowParagraphlessAnchoredTableFallback && pages.length === 0 && paragraphlessAnchoredTables.length > 0) {
283070
+ if (allowParagraphlessAnchoredDrawingFallback && shouldUseBlankPageFallback && paragraphlessAnchoredDrawings.length > 0) {
283071
+ const state = paginator.ensurePage();
283072
+ for (const { block, measure } of paragraphlessAnchoredDrawings) {
283073
+ if (placedAnchoredIds.has(block.id))
283074
+ continue;
283075
+ const anchorX = resolveParagraphlessAnchoredDrawingX(block, measure, state);
283076
+ const anchorY = resolveParagraphlessAnchoredDrawingY(block, measure, state);
283077
+ if (block.kind === "image" && measure.kind === "image") {
283078
+ const pageContentHeight = Math.max(0, state.contentBottom - state.topMargin);
283079
+ const aspectRatio = measure.width > 0 && measure.height > 0 ? measure.width / measure.height : 1;
283080
+ const minWidth = 20;
283081
+ const minHeight = minWidth / aspectRatio;
283082
+ const fragment2 = {
283083
+ kind: "image",
283084
+ blockId: block.id,
283085
+ x: anchorX,
283086
+ y: anchorY,
283087
+ width: measure.width,
283088
+ height: measure.height,
283089
+ isAnchored: true,
283090
+ behindDoc: block.anchor?.behindDoc === true,
283091
+ zIndex: getFragmentZIndex(block),
283092
+ metadata: {
283093
+ originalWidth: measure.width,
283094
+ originalHeight: measure.height,
283095
+ maxWidth: activePageSize.w - (activeLeftMargin + activeRightMargin),
283096
+ maxHeight: pageContentHeight,
283097
+ aspectRatio,
283098
+ minWidth,
283099
+ minHeight
283100
+ },
283101
+ sourceAnchor: block.sourceAnchor
283102
+ };
283103
+ const attrs = block.attrs;
283104
+ if (attrs?.pmStart != null)
283105
+ fragment2.pmStart = attrs.pmStart;
283106
+ if (attrs?.pmEnd != null)
283107
+ fragment2.pmEnd = attrs.pmEnd;
283108
+ state.page.fragments.push(fragment2);
283109
+ placedAnchoredIds.add(block.id);
283110
+ continue;
283111
+ }
283112
+ if (block.kind === "drawing" && measure.kind === "drawing") {
283113
+ const contentMeasures = block.drawingKind === "textboxShape" && typeof options.remeasureParagraph === "function" ? layoutTextboxContent(block, options.remeasureParagraph) : undefined;
283114
+ const fragment2 = {
283115
+ kind: "drawing",
283116
+ blockId: block.id,
283117
+ drawingKind: block.drawingKind,
283118
+ x: anchorX,
283119
+ y: anchorY,
283120
+ width: measure.width,
283121
+ height: measure.height,
283122
+ geometry: measure.geometry,
283123
+ scale: measure.scale,
283124
+ isAnchored: true,
283125
+ behindDoc: block.anchor?.behindDoc === true,
283126
+ zIndex: getFragmentZIndex(block),
283127
+ drawingContentId: block.drawingContentId,
283128
+ sourceAnchor: block.sourceAnchor
283129
+ };
283130
+ if (contentMeasures)
283131
+ fragment2.contentMeasures = contentMeasures;
283132
+ const attrs = block.attrs;
283133
+ if (attrs?.pmStart != null)
283134
+ fragment2.pmStart = attrs.pmStart;
283135
+ if (attrs?.pmEnd != null)
283136
+ fragment2.pmEnd = attrs.pmEnd;
283137
+ state.page.fragments.push(fragment2);
283138
+ placedAnchoredIds.add(block.id);
283139
+ }
283140
+ }
283141
+ }
283142
+ if (allowParagraphlessAnchoredTableFallback && shouldUseBlankPageFallback && paragraphlessAnchoredTables.length > 0) {
282785
283143
  const state = paginator.ensurePage();
282786
283144
  for (const { block: tableBlock, measure: tableMeasure } of paragraphlessAnchoredTables) {
282787
283145
  const columnWidthForTable = getCurrentColumnWidth();
@@ -282794,7 +283152,7 @@ function layoutDocument(blocks2, measures, options = {}) {
282794
283152
  state.page.fragments.push(createAnchoredTableFragment(tableBlock, tableMeasure, anchorX, anchorY));
282795
283153
  }
282796
283154
  }
282797
- if (allowSectionBreakOnlyPageFallback && pages.length === 0 && hasOnlySectionBreakBlocks(blocks2))
283155
+ if (allowSectionBreakOnlyPageFallback && shouldUseBlankPageFallback && hasOnlySectionBreakBlocks(blocks2))
282798
283156
  paginator.ensurePage();
282799
283157
  for (const page of pages) {
282800
283158
  if (!page.vAlign || page.vAlign === "top")
@@ -315115,11 +315473,15 @@ var Node$13 = class Node$14 {
315115
315473
  setContainer(container) {
315116
315474
  this.#container = container;
315117
315475
  }
315118
- apply(layoutEpoch) {
315476
+ apply(layoutEpoch, options = {}) {
315119
315477
  if (!this.#container)
315120
315478
  return;
315121
315479
  const epochStr = String(layoutEpoch);
315122
315480
  for (const root3 of collectImageRoots(this.#container)) {
315481
+ if (!canInteractWithRoot(root3, options.activeHeaderFooterMode ?? "body")) {
315482
+ clearImageRoot(root3);
315483
+ continue;
315484
+ }
315123
315485
  if (root3.dataset[INTERACTION_EPOCH_KEY$1] === epochStr)
315124
315486
  continue;
315125
315487
  const pmStart = parsePmNumber(root3.dataset.pmStart);
@@ -315139,14 +315501,8 @@ var Node$13 = class Node$14 {
315139
315501
  clear() {
315140
315502
  if (!this.#container)
315141
315503
  return;
315142
- for (const root3 of collectImageRoots(this.#container)) {
315143
- root3.removeAttribute("draggable");
315144
- delete root3.dataset.dragSourceKind;
315145
- delete root3.dataset.imageKind;
315146
- delete root3.dataset.nodeType;
315147
- delete root3.dataset.displayLabel;
315148
- delete root3.dataset[INTERACTION_EPOCH_KEY$1];
315149
- }
315504
+ for (const root3 of collectImageRoots(this.#container))
315505
+ clearImageRoot(root3);
315150
315506
  }
315151
315507
  }, BLOCK_LABEL_SELECTOR = ".superdoc-structured-content__label", INLINE_LABEL_SELECTOR, INTERACTION_EPOCH_KEY = "structuredContentInteractionEpoch", StructuredContentInteractionLayer = class {
315152
315508
  #container = null;
@@ -315276,7 +315632,7 @@ var Node$13 = class Node$14 {
315276
315632
  refreshAfterPaint(options) {
315277
315633
  this.#fieldAnnotationLayer.apply(options.layoutEpoch);
315278
315634
  options.rebuildDomPositionIndex();
315279
- this.#imageLayer.apply(options.layoutEpoch);
315635
+ this.#imageLayer.apply(options.layoutEpoch, { activeHeaderFooterMode: options.activeHeaderFooterMode });
315280
315636
  this.#structuredContentLayer.apply(options.layoutEpoch);
315281
315637
  this.syncInlineStyleLayers(options.editorState, options.domPositionIndex);
315282
315638
  this.applyProofingAnnotations(options.proofingAnnotations, options.rebuildDomPositionIndex);
@@ -321459,11 +321815,16 @@ menclose::after {
321459
321815
  geoSdtWrapper.style.left = `${elemLeftPx}px`;
321460
321816
  geoSdtWrapper.style.top = "0px";
321461
321817
  geoSdtWrapper.style.height = `${line.lineHeight}px`;
321818
+ geoSdtWrapper.style.padding = "0px";
321819
+ geoSdtWrapper.style.borderWidth = "0px";
321820
+ geoSdtWrapper.style.lineHeight = `${line.lineHeight}px`;
321462
321821
  }
321463
321822
  if (isImageRun$1(runForSdt))
321464
321823
  geoSdtWrapper.dataset.containsInlineImage = "true";
321465
321824
  runContext.syncInlineSdtWrapperTypography(geoSdtWrapper, runForSdt);
321825
+ geoSdtWrapper.style.lineHeight = `${line.lineHeight}px`;
321466
321826
  elem.style.left = `${elemLeftPx - geoSdtWrapperLeft}px`;
321827
+ elem.style.top = "0px";
321467
321828
  geoSdtMaxRight = Math.max(geoSdtMaxRight, elemLeftPx + elemWidthPx);
321468
321829
  runContext.expandSdtWrapperPmRange(geoSdtWrapper, runForSdt.pmStart, runForSdt.pmEnd);
321469
321830
  geoSdtWrapper.appendChild(elem);
@@ -322684,7 +323045,7 @@ menclose::after {
322684
323045
  else
322685
323046
  pageY = effectiveOffset + fragment2.y + (kind === "footer" ? footerYOffset : 0);
322686
323047
  fragEl.style.top = `${pageY}px`;
322687
- fragEl.style.left = `${marginLeft + fragment2.x}px`;
323048
+ fragEl.style.left = `${isPageRelative ? fragment2.x : marginLeft + fragment2.x}px`;
322688
323049
  fragEl.style.zIndex = "0";
322689
323050
  fragEl.dataset.behindDocSection = kind;
322690
323051
  pageEl.insertBefore(fragEl, pageEl.firstChild);
@@ -325754,7 +326115,7 @@ menclose::after {
325754
326115
  if (transform === "capitalize")
325755
326116
  return capitalizeText$2(text5, fullText, startOffset);
325756
326117
  return text5;
325757
- }, 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) => {
326118
+ }, 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) => {
325758
326119
  const width = run2.width;
325759
326120
  return typeof width === "number" ? width : 0;
325760
326121
  }, isLineBreakRun$1 = (run2) => run2.kind === "lineBreak" || run2.kind === "break" && run2.breakType === "line", markerFontString = (run2) => {
@@ -325776,7 +326137,7 @@ menclose::after {
325776
326137
  };
325777
326138
  return computeTabStops({
325778
326139
  explicitStops: tabs ?? [],
325779
- defaultTabInterval: tabIntervalTwips ?? DEFAULT_TAB_INTERVAL_TWIPS$1,
326140
+ defaultTabInterval: tabIntervalTwips ?? DEFAULT_TAB_INTERVAL_TWIPS$12,
325780
326141
  paragraphIndent: paragraphIndentTwips,
325781
326142
  rawParagraphIndent: rawParagraphIndentTwips
325782
326143
  }).map((stop) => ({
@@ -325796,7 +326157,7 @@ menclose::after {
325796
326157
  stop: tabStops[index2]
325797
326158
  };
325798
326159
  return {
325799
- target: currentX + twipsToPx$1(DEFAULT_TAB_INTERVAL_TWIPS$1),
326160
+ target: currentX + twipsToPx$1(DEFAULT_TAB_INTERVAL_TWIPS$12),
325800
326161
  nextIndex: index2
325801
326162
  };
325802
326163
  }, scanTabAlignmentGroup = (runs2, startRunIndex, startChar, decimalSeparator) => {
@@ -333775,13 +334136,13 @@ menclose::after {
333775
334136
  return;
333776
334137
  console.log(...args$1);
333777
334138
  }, 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;
333778
- var init_src_PJVnllcq_es = __esm(() => {
334139
+ var init_src_DHPdEVg9_es = __esm(() => {
333779
334140
  init_rolldown_runtime_Bg48TavK_es();
333780
- init_SuperConverter_DK5WIHuy_es();
334141
+ init_SuperConverter_DAuqlmYY_es();
333781
334142
  init_jszip_C49i9kUs_es();
333782
334143
  init_xml_js_CqGKpaft_es();
333783
334144
  init_uuid_B2wVPhPi_es();
333784
- init_create_headless_toolbar_BLN1v7eO_es();
334145
+ init_create_headless_toolbar_BT0XKtIW_es();
333785
334146
  init_constants_D9qj59G2_es();
333786
334147
  init_dist_B8HfvhaK_es();
333787
334148
  init_unified_Dsuw2be5_es();
@@ -365922,6 +366283,7 @@ function print() { __p += __j.call(arguments, '') }
365922
366283
  pageIndex: session.pageIndex,
365923
366284
  pageNumber: session.pageNumber
365924
366285
  });
366286
+ this.#refreshEditorDomAugmentations();
365925
366287
  this.#updateAwarenessSession();
365926
366288
  },
365927
366289
  onEditingContext: (data) => {
@@ -367170,6 +367532,7 @@ function print() { __p += __j.call(arguments, '') }
367170
367532
  #refreshEditorDomAugmentations() {
367171
367533
  this.#postPaintPipeline.refreshAfterPaint({
367172
367534
  layoutEpoch: this.#layoutEpoch,
367535
+ activeHeaderFooterMode: this.#headerFooterSession?.session?.mode ?? "body",
367173
367536
  editorState: this.#editor?.view?.state,
367174
367537
  domPositionIndex: this.#domPositionIndex,
367175
367538
  proofingAnnotations: this.#buildProofingAnnotations(),
@@ -369566,11 +369929,11 @@ function print() { __p += __j.call(arguments, '') }
369566
369929
  ]);
369567
369930
  });
369568
369931
 
369569
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CrjXK3s_.es.js
369932
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-Zmv88GYo.es.js
369570
369933
  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;
369571
- var init_create_super_doc_ui_CrjXK3s__es = __esm(() => {
369572
- init_SuperConverter_DK5WIHuy_es();
369573
- init_create_headless_toolbar_BLN1v7eO_es();
369934
+ var init_create_super_doc_ui_Zmv88GYo_es = __esm(() => {
369935
+ init_SuperConverter_DAuqlmYY_es();
369936
+ init_create_headless_toolbar_BT0XKtIW_es();
369574
369937
  DEFAULT_TEXT_ALIGN_OPTIONS = [
369575
369938
  {
369576
369939
  label: "Left",
@@ -369861,16 +370224,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
369861
370224
 
369862
370225
  // ../../packages/superdoc/dist/super-editor.es.js
369863
370226
  var init_super_editor_es = __esm(() => {
369864
- init_src_PJVnllcq_es();
369865
- init_SuperConverter_DK5WIHuy_es();
370227
+ init_src_DHPdEVg9_es();
370228
+ init_SuperConverter_DAuqlmYY_es();
369866
370229
  init_jszip_C49i9kUs_es();
369867
370230
  init_xml_js_CqGKpaft_es();
369868
- init_create_headless_toolbar_BLN1v7eO_es();
370231
+ init_create_headless_toolbar_BT0XKtIW_es();
369869
370232
  init_constants_D9qj59G2_es();
369870
370233
  init_dist_B8HfvhaK_es();
369871
370234
  init_unified_Dsuw2be5_es();
369872
370235
  init_DocxZipper_FUsfThjV_es();
369873
- init_create_super_doc_ui_CrjXK3s__es();
370236
+ init_create_super_doc_ui_Zmv88GYo_es();
369874
370237
  init_ui_C5PAS9hY_es();
369875
370238
  init_eventemitter3_BnGqBE_Q_es();
369876
370239
  init_errors_CNaD6vcg_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.17.0-next.27",
3
+ "version": "0.17.0-next.29",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -24,20 +24,20 @@
24
24
  "@types/node": "22.19.2",
25
25
  "@types/ws": "^8.5.13",
26
26
  "typescript": "^5.9.2",
27
+ "superdoc": "1.39.0",
27
28
  "@superdoc/document-api": "0.0.1",
28
- "@superdoc/super-editor": "0.0.1",
29
- "superdoc": "1.39.0"
29
+ "@superdoc/super-editor": "0.0.1"
30
30
  },
31
31
  "module": "src/index.ts",
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
35
  "optionalDependencies": {
36
- "@superdoc-dev/cli-darwin-arm64": "0.17.0-next.27",
37
- "@superdoc-dev/cli-darwin-x64": "0.17.0-next.27",
38
- "@superdoc-dev/cli-linux-x64": "0.17.0-next.27",
39
- "@superdoc-dev/cli-linux-arm64": "0.17.0-next.27",
40
- "@superdoc-dev/cli-windows-x64": "0.17.0-next.27"
36
+ "@superdoc-dev/cli-darwin-x64": "0.17.0-next.29",
37
+ "@superdoc-dev/cli-darwin-arm64": "0.17.0-next.29",
38
+ "@superdoc-dev/cli-linux-x64": "0.17.0-next.29",
39
+ "@superdoc-dev/cli-linux-arm64": "0.17.0-next.29",
40
+ "@superdoc-dev/cli-windows-x64": "0.17.0-next.29"
41
41
  },
42
42
  "scripts": {
43
43
  "predev": "node scripts/ensure-superdoc-build.js",