@harbour-enterprises/superdoc 1.0.0-beta.82 → 1.0.0-beta.84

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 (27) hide show
  1. package/dist/chunks/{PdfViewer-kLZVOUbz.cjs → PdfViewer-CAaNRs-k.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-gQqtBsXT.es.js → PdfViewer-CN5I0v21.es.js} +1 -1
  3. package/dist/chunks/{index-GF5Urhpn-BNFw-VyP.cjs → index-ByDo0rez-DTbakkgE.cjs} +1 -1
  4. package/dist/chunks/{index-GF5Urhpn-LFkKkWot.es.js → index-ByDo0rez-Dddj1OPE.es.js} +1 -1
  5. package/dist/chunks/{index-cUgy4sJN.cjs → index-CXX12ADx.cjs} +3 -3
  6. package/dist/chunks/{index-CNPZHNDf.es.js → index-D6mF0NAB.es.js} +3 -3
  7. package/dist/chunks/{super-editor.es-DfLaDbHA.es.js → super-editor.es-B-ix_3cI.es.js} +469 -74
  8. package/dist/chunks/{super-editor.es-44RL9-Ca.cjs → super-editor.es-C89GPNG4.cjs} +469 -74
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-Bfu1F5pk.js → converter-CWmKgkFT.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-Cl08Z_S_.js → docx-zipper-CFgPPujz.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-CwTMBaym.js → editor-Dmk80b6P.js} +470 -75
  13. package/dist/super-editor/chunks/{index-GF5Urhpn.js → index-ByDo0rez.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-DZTp7DIF.js → toolbar-Bi5YCv48.js} +2 -2
  15. package/dist/super-editor/converter.es.js +1 -1
  16. package/dist/super-editor/docx-zipper.es.js +2 -2
  17. package/dist/super-editor/editor.es.js +3 -3
  18. package/dist/super-editor/file-zipper.es.js +1 -1
  19. package/dist/super-editor/super-editor.es.js +6 -6
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.cjs +1 -1
  22. package/dist/super-editor.es.js +1 -1
  23. package/dist/superdoc.cjs +2 -2
  24. package/dist/superdoc.es.js +2 -2
  25. package/dist/superdoc.umd.js +471 -76
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -42374,7 +42374,7 @@ const _SuperConverter = class _SuperConverter2 {
42374
42374
  static getStoredSuperdocVersion(docx) {
42375
42375
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42376
42376
  }
42377
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.82") {
42377
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.84") {
42378
42378
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42379
42379
  }
42380
42380
  /**
@@ -59563,7 +59563,7 @@ const isHeadless = (editor) => {
59563
59563
  const shouldSkipNodeView = (editor) => {
59564
59564
  return isHeadless(editor);
59565
59565
  };
59566
- const summaryVersion = "1.0.0-beta.82";
59566
+ const summaryVersion = "1.0.0-beta.84";
59567
59567
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59568
59568
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59569
59569
  function mapAttributes(attrs) {
@@ -60352,7 +60352,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60352
60352
  { default: remarkStringify },
60353
60353
  { default: remarkGfm }
60354
60354
  ] = await Promise.all([
60355
- import("./index-GF5Urhpn-LFkKkWot.es.js"),
60355
+ import("./index-ByDo0rez-Dddj1OPE.es.js"),
60356
60356
  import("./index-DRCvimau-Cw339678.es.js"),
60357
60357
  import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
60358
60358
  import("./index-D_sWOSiG-DE96TaT5.es.js"),
@@ -60557,7 +60557,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60557
60557
  * Process collaboration migrations
60558
60558
  */
60559
60559
  processCollaborationMigrations() {
60560
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.82");
60560
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.84");
60561
60561
  if (!this.options.ydoc) return;
60562
60562
  const metaMap = this.options.ydoc.getMap("meta");
60563
60563
  let docVersion = metaMap.get("version");
@@ -63601,32 +63601,76 @@ function hydrateImageBlocks(blocks, mediaFiles) {
63601
63601
  return hasChanges ? hydratedRuns : runs;
63602
63602
  };
63603
63603
  return blocks.map((block) => {
63604
- if (block.kind === "image") {
63605
- if (!block.src || block.src.startsWith("data:")) {
63606
- return block;
63607
- }
63608
- const attrs = block.attrs ?? {};
63609
- const relId = typeof attrs.rId === "string" ? attrs.rId : void 0;
63610
- const attrSrc = typeof attrs.src === "string" ? attrs.src : void 0;
63611
- const extension = typeof attrs.extension === "string" ? attrs.extension.toLowerCase() : void 0;
63612
- const resolvedSrc = resolveImageSrc(block.src, relId, attrSrc, extension);
63613
- if (resolvedSrc) {
63614
- return { ...block, src: resolvedSrc };
63615
- }
63616
- return block;
63617
- }
63618
- if (block.kind === "paragraph") {
63619
- const paragraphBlock = block;
63620
- if (!paragraphBlock.runs || paragraphBlock.runs.length === 0) {
63621
- return block;
63622
- }
63623
- const hydratedRuns = hydrateRuns(paragraphBlock.runs);
63624
- if (hydratedRuns !== paragraphBlock.runs) {
63625
- return { ...paragraphBlock, runs: hydratedRuns };
63604
+ const hydrateBlock = (blk) => {
63605
+ if (blk.kind === "image") {
63606
+ if (!blk.src || blk.src.startsWith("data:")) {
63607
+ return blk;
63608
+ }
63609
+ const attrs = blk.attrs ?? {};
63610
+ const relId = typeof attrs.rId === "string" ? attrs.rId : void 0;
63611
+ const attrSrc = typeof attrs.src === "string" ? attrs.src : void 0;
63612
+ const extension = typeof attrs.extension === "string" ? attrs.extension.toLowerCase() : void 0;
63613
+ const resolvedSrc = resolveImageSrc(blk.src, relId, attrSrc, extension);
63614
+ if (resolvedSrc) {
63615
+ return { ...blk, src: resolvedSrc };
63616
+ }
63617
+ return blk;
63618
+ }
63619
+ if (blk.kind === "paragraph") {
63620
+ const paragraphBlock = blk;
63621
+ if (!paragraphBlock.runs || paragraphBlock.runs.length === 0) {
63622
+ return blk;
63623
+ }
63624
+ const hydratedRuns = hydrateRuns(paragraphBlock.runs);
63625
+ if (hydratedRuns !== paragraphBlock.runs) {
63626
+ return { ...paragraphBlock, runs: hydratedRuns };
63627
+ }
63628
+ return blk;
63629
+ }
63630
+ if (blk.kind === "table") {
63631
+ let rowsChanged = false;
63632
+ const newRows = blk.rows.map((row) => {
63633
+ let cellsChanged = false;
63634
+ const newCells = row.cells.map((cell) => {
63635
+ let cellChanged = false;
63636
+ const hydratedBlocks = (cell.blocks ?? (cell.paragraph ? [cell.paragraph] : [])).map((cb) => hydrateBlock(cb));
63637
+ if (cell.blocks && hydratedBlocks !== cell.blocks) {
63638
+ cellChanged = true;
63639
+ }
63640
+ let hydratedParagraph = cell.paragraph;
63641
+ if (!cell.blocks && cell.paragraph && cell.paragraph.kind === "paragraph") {
63642
+ const hydratedPara = hydrateBlock(cell.paragraph);
63643
+ if (hydratedPara !== cell.paragraph) {
63644
+ hydratedParagraph = hydratedPara;
63645
+ cellChanged = true;
63646
+ }
63647
+ }
63648
+ if (cellChanged) {
63649
+ return {
63650
+ ...cell,
63651
+ blocks: hydratedBlocks.length > 0 ? hydratedBlocks : cell.blocks,
63652
+ paragraph: hydratedParagraph
63653
+ };
63654
+ }
63655
+ return cell;
63656
+ });
63657
+ if (newCells.some((c2, idx) => c2 !== row.cells[idx])) {
63658
+ cellsChanged = true;
63659
+ }
63660
+ if (cellsChanged) {
63661
+ rowsChanged = true;
63662
+ return { ...row, cells: newCells };
63663
+ }
63664
+ return row;
63665
+ });
63666
+ if (rowsChanged) {
63667
+ return { ...blk, rows: newRows };
63668
+ }
63669
+ return blk;
63626
63670
  }
63627
- return block;
63628
- }
63629
- return block;
63671
+ return blk;
63672
+ };
63673
+ return hydrateBlock(block);
63630
63674
  });
63631
63675
  }
63632
63676
  function isGradientFill(value) {
@@ -65341,7 +65385,7 @@ function buildSdtCacheKey(nodeType, attrs, explicitKey) {
65341
65385
  return void 0;
65342
65386
  }
65343
65387
  const DEFAULT_LIST_HANGING_PX$1 = 18;
65344
- const LIST_MARKER_GAP$2 = 8;
65388
+ const LIST_MARKER_GAP$3 = 8;
65345
65389
  const DEFAULT_BULLET_GLYPH = "•";
65346
65390
  const DEFAULT_DECIMAL_PATTERN = "%1.";
65347
65391
  const ASCII_UPPERCASE_A = 65;
@@ -65752,7 +65796,7 @@ function computeWordParagraphLayout(input) {
65752
65796
  let markerBoxWidthPx;
65753
65797
  let markerX;
65754
65798
  if (hasFirstLineIndent) {
65755
- markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP$2 : DEFAULT_LIST_HANGING_PX$1;
65799
+ markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP$3 : DEFAULT_LIST_HANGING_PX$1;
65756
65800
  markerX = indentLeftPx + (firstLinePx ?? 0);
65757
65801
  layout.textStartPx = markerX + markerBoxWidthPx;
65758
65802
  layout.hangingPx = 0;
@@ -65852,12 +65896,12 @@ const resolveMarkerBoxWidth = (hangingPxRaw, glyphWidthPx) => {
65852
65896
  let markerBox = Math.max(hangingPxRaw || 0, 0);
65853
65897
  if (markerBox <= 0) {
65854
65898
  if (glyphWidthPx != null && glyphWidthPx > 0) {
65855
- markerBox = glyphWidthPx + LIST_MARKER_GAP$2;
65899
+ markerBox = glyphWidthPx + LIST_MARKER_GAP$3;
65856
65900
  } else {
65857
65901
  markerBox = DEFAULT_LIST_HANGING_PX$1;
65858
65902
  }
65859
- } else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP$2 > markerBox) {
65860
- markerBox = glyphWidthPx + LIST_MARKER_GAP$2;
65903
+ } else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP$3 > markerBox) {
65904
+ markerBox = glyphWidthPx + LIST_MARKER_GAP$3;
65861
65905
  }
65862
65906
  return markerBox;
65863
65907
  };
@@ -66479,13 +66523,21 @@ const findNumFmtElement = (lvl) => {
66479
66523
  const resolveNumberingFromContext = (numId, ilvl, numbering) => {
66480
66524
  const definitions = numbering?.definitions;
66481
66525
  const abstracts = numbering?.abstracts;
66482
- if (!definitions || !abstracts) return void 0;
66526
+ if (!definitions || !abstracts) {
66527
+ return void 0;
66528
+ }
66483
66529
  const numDef = asOoxmlElement(definitions[String(numId)]);
66484
- if (!numDef) return void 0;
66530
+ if (!numDef) {
66531
+ return void 0;
66532
+ }
66485
66533
  const abstractId = getAttribute(findChild(numDef, "w:abstractNumId"), "w:val");
66486
- if (abstractId == null) return void 0;
66534
+ if (abstractId == null) {
66535
+ return void 0;
66536
+ }
66487
66537
  const abstract = asOoxmlElement(abstracts[String(abstractId)]);
66488
- if (!abstract) return void 0;
66538
+ if (!abstract) {
66539
+ return void 0;
66540
+ }
66489
66541
  let levelDef = abstract.elements?.find(
66490
66542
  (el) => el?.name === "w:lvl" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
66491
66543
  );
@@ -66497,7 +66549,9 @@ const resolveNumberingFromContext = (numId, ilvl, numbering) => {
66497
66549
  levelDef = overrideLvl;
66498
66550
  }
66499
66551
  const startOverride = parseNumberAttr(getAttribute(findChild(override, "w:startOverride"), "w:val"));
66500
- if (!levelDef) return void 0;
66552
+ if (!levelDef) {
66553
+ return void 0;
66554
+ }
66501
66555
  const numFmtEl = findNumFmtElement(levelDef);
66502
66556
  const lvlText = getAttribute(findChild(levelDef, "w:lvlText"), "w:val");
66503
66557
  const start2 = startOverride ?? parseNumberAttr(getAttribute(findChild(levelDef, "w:start"), "w:val"));
@@ -67143,14 +67197,29 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
67143
67197
  paragraphAttrs.frame = frame;
67144
67198
  }
67145
67199
  }
67200
+ const listRendering = normalizeListRenderingAttrs(attrs.listRendering);
67146
67201
  const numberingSource = attrs.numberingProperties ?? paragraphProps.numberingProperties ?? hydrated?.numberingProperties;
67147
- const rawNumberingProps = toAdapterNumberingProps(numberingSource);
67202
+ let rawNumberingProps = toAdapterNumberingProps(numberingSource);
67203
+ if (!rawNumberingProps && listRendering) {
67204
+ const path = listRendering.path;
67205
+ const counterFromPath = path && path.length ? path[path.length - 1] : void 0;
67206
+ const ilvl = path && path.length > 1 ? path.length - 1 : 0;
67207
+ rawNumberingProps = {
67208
+ numId: -1,
67209
+ ilvl,
67210
+ path,
67211
+ counterValue: Number.isFinite(counterFromPath) ? Number(counterFromPath) : void 0,
67212
+ markerText: listRendering.markerText,
67213
+ format: listRendering.numberingType,
67214
+ lvlJc: listRendering.justification,
67215
+ suffix: listRendering.suffix
67216
+ };
67217
+ }
67148
67218
  const hasValidNumbering = rawNumberingProps && isValidNumberingId(rawNumberingProps.numId);
67149
67219
  if (hasValidNumbering) {
67150
67220
  const numberingProps = rawNumberingProps;
67151
67221
  const numId = numberingProps.numId;
67152
67222
  const ilvl = Number.isFinite(numberingProps.ilvl) ? Math.max(0, Math.floor(Number(numberingProps.ilvl))) : 0;
67153
- const listRendering = normalizeListRenderingAttrs(attrs.listRendering);
67154
67223
  const numericNumId = typeof numId === "number" ? numId : void 0;
67155
67224
  const resolvedLevel = resolveNumberingFromContext(numId, ilvl, converterContext?.numbering);
67156
67225
  if (resolvedLevel) {
@@ -67225,13 +67294,18 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
67225
67294
  }
67226
67295
  }
67227
67296
  paragraphAttrs.wordLayout = wordLayout;
67228
- if (enrichedNumberingProps.resolvedLevelIndent) {
67229
- const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
67230
- const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
67231
- paragraphAttrs.indent = {
67232
- ...baseIndent,
67233
- ...normalizedIndent ?? {}
67234
- };
67297
+ }
67298
+ if (enrichedNumberingProps.resolvedLevelIndent) {
67299
+ const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
67300
+ const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
67301
+ paragraphAttrs.indent = {
67302
+ ...baseIndent,
67303
+ ...normalizedIndent ?? {}
67304
+ };
67305
+ if (normalizedIndent?.firstLine !== void 0) {
67306
+ delete paragraphAttrs.indent.hanging;
67307
+ } else if (normalizedIndent?.hanging !== void 0) {
67308
+ delete paragraphAttrs.indent.firstLine;
67235
67309
  }
67236
67310
  }
67237
67311
  paragraphAttrs.numberingProperties = enrichedNumberingProps;
@@ -69201,29 +69275,129 @@ const parseTableCell = (args) => {
69201
69275
  ...context.converterContext,
69202
69276
  tableStyleParagraphProps
69203
69277
  } : context.converterContext;
69278
+ const paragraphToFlowBlocks2 = context.converters?.paragraphToFlowBlocks ?? context.paragraphToFlowBlocks;
69279
+ const listCounterContext = context.listCounterContext;
69204
69280
  for (const childNode of cellNode.content) {
69205
69281
  if (childNode.type === "paragraph") {
69206
- const paragraphBlocks = context.paragraphToFlowBlocks(
69282
+ if (!paragraphToFlowBlocks2) continue;
69283
+ const paragraphBlocks = paragraphToFlowBlocks2(
69207
69284
  childNode,
69208
69285
  context.nextBlockId,
69209
69286
  context.positions,
69210
69287
  context.defaultFont,
69211
69288
  context.defaultSize,
69212
69289
  context.styleContext,
69213
- void 0,
69214
- // listCounterContext
69290
+ listCounterContext,
69215
69291
  context.trackedChanges,
69216
69292
  context.bookmarks,
69217
69293
  context.hyperlinkConfig,
69218
69294
  context.themeColors,
69219
69295
  cellConverterContext
69220
- // converterContext at position 12
69221
69296
  );
69222
- const paragraph = paragraphBlocks.find((b2) => b2.kind === "paragraph");
69223
- if (paragraph) {
69224
- blocks.push(paragraph);
69297
+ paragraphBlocks.forEach((block) => {
69298
+ if (block.kind === "paragraph" || block.kind === "image" || block.kind === "drawing") {
69299
+ blocks.push(block);
69300
+ }
69301
+ });
69302
+ continue;
69303
+ }
69304
+ if (childNode.type === "image" && context.converters?.imageNodeToBlock) {
69305
+ const mergedMarks = [...childNode.marks ?? []];
69306
+ const trackedMeta = context.trackedChanges ? collectTrackedChangeFromMarks(mergedMarks) : void 0;
69307
+ if (shouldHideTrackedNode(trackedMeta, context.trackedChanges)) {
69308
+ continue;
69309
+ }
69310
+ const imageBlock = context.converters.imageNodeToBlock(
69311
+ childNode,
69312
+ context.nextBlockId,
69313
+ context.positions,
69314
+ trackedMeta,
69315
+ context.trackedChanges
69316
+ );
69317
+ if (imageBlock && imageBlock.kind === "image") {
69318
+ annotateBlockWithTrackedChange(imageBlock, trackedMeta, context.trackedChanges);
69319
+ blocks.push(imageBlock);
69320
+ }
69321
+ continue;
69322
+ }
69323
+ if (childNode.type === "vectorShape" && context.converters?.vectorShapeNodeToDrawingBlock) {
69324
+ const drawingBlock = context.converters.vectorShapeNodeToDrawingBlock(
69325
+ childNode,
69326
+ context.nextBlockId,
69327
+ context.positions
69328
+ );
69329
+ if (drawingBlock) {
69330
+ blocks.push(drawingBlock);
69331
+ }
69332
+ continue;
69333
+ }
69334
+ if (childNode.type === "shapeGroup" && context.converters?.shapeGroupNodeToDrawingBlock) {
69335
+ const drawingBlock = context.converters.shapeGroupNodeToDrawingBlock(
69336
+ childNode,
69337
+ context.nextBlockId,
69338
+ context.positions
69339
+ );
69340
+ if (drawingBlock) {
69341
+ blocks.push(drawingBlock);
69225
69342
  }
69343
+ continue;
69226
69344
  }
69345
+ if (childNode.type === "shapeContainer" && context.converters?.shapeContainerNodeToDrawingBlock) {
69346
+ const drawingBlock = context.converters.shapeContainerNodeToDrawingBlock(
69347
+ childNode,
69348
+ context.nextBlockId,
69349
+ context.positions
69350
+ );
69351
+ if (drawingBlock) {
69352
+ blocks.push(drawingBlock);
69353
+ }
69354
+ continue;
69355
+ }
69356
+ if (childNode.type === "shapeTextbox" && context.converters?.shapeTextboxNodeToDrawingBlock) {
69357
+ const drawingBlock = context.converters.shapeTextboxNodeToDrawingBlock(
69358
+ childNode,
69359
+ context.nextBlockId,
69360
+ context.positions
69361
+ );
69362
+ if (drawingBlock) {
69363
+ blocks.push(drawingBlock);
69364
+ }
69365
+ }
69366
+ }
69367
+ try {
69368
+ const blockSummaries = blocks.map((b2) => {
69369
+ if (b2.kind === "paragraph") {
69370
+ const runs = b2.runs ?? [];
69371
+ const attrs = b2.attrs ?? {};
69372
+ return {
69373
+ kind: "paragraph",
69374
+ runKinds: runs.map((r2) => r2.kind ?? "text"),
69375
+ runCount: runs.length,
69376
+ runPreview: runs.map((r2) => {
69377
+ const kind = r2.kind ?? "text";
69378
+ if (kind === "image") {
69379
+ const img = r2;
69380
+ return { kind, src: img.src, width: img.width, height: img.height };
69381
+ }
69382
+ return { kind };
69383
+ }),
69384
+ hasNumbering: Boolean(attrs.numberingProperties),
69385
+ markerText: attrs.wordLayout?.marker?.markerText
69386
+ };
69387
+ }
69388
+ return { kind: b2.kind };
69389
+ });
69390
+ console.log(
69391
+ "[tableNodeToBlock.parseTableCell] cell contents",
69392
+ JSON.stringify({
69393
+ cellIndex,
69394
+ rowIndex,
69395
+ cellIdPreview: `cell-${rowIndex}-${cellIndex}`,
69396
+ childTypes: cellNode.content.map((c2) => c2?.type),
69397
+ blocks: blockSummaries
69398
+ })
69399
+ );
69400
+ } catch {
69227
69401
  }
69228
69402
  if (blocks.length === 0) {
69229
69403
  return null;
@@ -69363,9 +69537,10 @@ function extractFloatingTableAnchorWrap(node) {
69363
69537
  }
69364
69538
  return { anchor, wrap: wrap2 };
69365
69539
  }
69366
- function tableNodeToBlock$1(node, nextBlockId, positions, defaultFont, defaultSize, _styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, paragraphToFlowBlocks2, converterContext) {
69540
+ function tableNodeToBlock$1(node, nextBlockId, positions, defaultFont, defaultSize, _styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, paragraphToFlowBlocks2, converterContext, options) {
69367
69541
  if (!Array.isArray(node.content) || node.content.length === 0) return null;
69368
- if (!paragraphToFlowBlocks2) return null;
69542
+ const paragraphConverter = paragraphToFlowBlocks2 ?? options?.converters?.paragraphToFlowBlocks;
69543
+ if (!paragraphConverter) return null;
69369
69544
  const parserDeps = {
69370
69545
  nextBlockId,
69371
69546
  positions,
@@ -69376,8 +69551,10 @@ function tableNodeToBlock$1(node, nextBlockId, positions, defaultFont, defaultSi
69376
69551
  bookmarks,
69377
69552
  hyperlinkConfig,
69378
69553
  themeColors,
69379
- paragraphToFlowBlocks: paragraphToFlowBlocks2,
69380
- converterContext
69554
+ listCounterContext: options?.listCounterContext,
69555
+ paragraphToFlowBlocks: paragraphConverter,
69556
+ converterContext,
69557
+ converters: options?.converters
69381
69558
  };
69382
69559
  const hydratedTableStyle = hydrateTableStyleAttrs(node, converterContext);
69383
69560
  const defaultCellPadding = hydratedTableStyle?.cellPadding;
@@ -69497,6 +69674,7 @@ function handleTableNode(node, context) {
69497
69674
  defaultFont,
69498
69675
  defaultSize,
69499
69676
  styleContext,
69677
+ listCounterContext,
69500
69678
  trackedChangesConfig,
69501
69679
  bookmarks,
69502
69680
  hyperlinkConfig,
@@ -69516,7 +69694,8 @@ function handleTableNode(node, context) {
69516
69694
  void 0,
69517
69695
  // themeColors
69518
69696
  converters?.paragraphToFlowBlocks,
69519
- converterContext
69697
+ converterContext,
69698
+ { listCounterContext, converters }
69520
69699
  );
69521
69700
  if (tableBlock) {
69522
69701
  blocks.push(tableBlock);
@@ -69670,7 +69849,7 @@ function toFlowBlocks(pmDoc, options) {
69670
69849
  bookmarks2,
69671
69850
  hyperlinkConfig2,
69672
69851
  themeColorsParam ?? themeColors,
69673
- converterCtx ?? converterContext
69852
+ paragraphConverter
69674
69853
  );
69675
69854
  const handlerContext = {
69676
69855
  blocks,
@@ -69693,7 +69872,11 @@ function toFlowBlocks(pmDoc, options) {
69693
69872
  converters: {
69694
69873
  paragraphToFlowBlocks: paragraphConverter,
69695
69874
  tableNodeToBlock: tableConverter,
69696
- imageNodeToBlock
69875
+ imageNodeToBlock,
69876
+ vectorShapeNodeToDrawingBlock,
69877
+ shapeGroupNodeToDrawingBlock,
69878
+ shapeContainerNodeToDrawingBlock,
69879
+ shapeTextboxNodeToDrawingBlock
69697
69880
  }
69698
69881
  };
69699
69882
  doc2.content.forEach((node) => {
@@ -69778,7 +69961,18 @@ function paragraphToFlowBlocks(para, nextBlockId, positions, defaultFont, defaul
69778
69961
  hyperlinkConfig2,
69779
69962
  themeColors2,
69780
69963
  paragraphToFlowBlocks,
69781
- converterCtx ?? converterContext
69964
+ converterCtx ?? converterContext,
69965
+ {
69966
+ listCounterContext,
69967
+ converters: {
69968
+ paragraphToFlowBlocks: paragraphToFlowBlocks$1,
69969
+ imageNodeToBlock,
69970
+ vectorShapeNodeToDrawingBlock,
69971
+ shapeGroupNodeToDrawingBlock,
69972
+ shapeContainerNodeToDrawingBlock,
69973
+ shapeTextboxNodeToDrawingBlock
69974
+ }
69975
+ }
69782
69976
  )
69783
69977
  },
69784
69978
  converterContext
@@ -69797,7 +69991,17 @@ function tableNodeToBlock(node, nextBlockId, positions, defaultFont, defaultSize
69797
69991
  hyperlinkConfig,
69798
69992
  themeColors,
69799
69993
  paragraphToFlowBlocks,
69800
- converterContext
69994
+ converterContext,
69995
+ {
69996
+ converters: {
69997
+ paragraphToFlowBlocks: paragraphToFlowBlocks$1,
69998
+ imageNodeToBlock,
69999
+ vectorShapeNodeToDrawingBlock,
70000
+ shapeGroupNodeToDrawingBlock,
70001
+ shapeContainerNodeToDrawingBlock,
70002
+ shapeTextboxNodeToDrawingBlock
70003
+ }
70004
+ }
69801
70005
  );
69802
70006
  }
69803
70007
  let measurementCanvas = null;
@@ -72980,6 +73184,43 @@ const resolveTableCellBorders = (tableBorders, rowIndex, colIndex, totalRows, to
72980
73184
  right: borderValueToSpec(isLastCol ? tableBorders?.right : null)
72981
73185
  };
72982
73186
  };
73187
+ const LIST_MARKER_GAP$2 = 8;
73188
+ function renderListMarker(params2) {
73189
+ const { doc: doc2, lineEl, markerLayout, markerMeasure, indentLeftPx } = params2;
73190
+ const markerJustification = markerLayout?.justification ?? "left";
73191
+ const markerBoxWidth = (typeof markerLayout?.markerBoxWidthPx === "number" ? markerLayout.markerBoxWidthPx : void 0) ?? markerMeasure?.markerWidth ?? 0;
73192
+ const gutter = (typeof markerLayout?.gutterWidthPx === "number" ? markerLayout.gutterWidthPx : void 0) ?? markerMeasure?.gutterWidth ?? LIST_MARKER_GAP$2;
73193
+ const markerStartPos = markerJustification === "left" ? indentLeftPx : (typeof markerLayout?.markerX === "number" ? markerLayout.markerX : void 0) ?? indentLeftPx;
73194
+ const markerLeftPos = markerStartPos - markerBoxWidth;
73195
+ const lineContainer = doc2.createElement("div");
73196
+ lineContainer.style.position = "relative";
73197
+ lineContainer.style.width = "100%";
73198
+ const markerEl = doc2.createElement("span");
73199
+ markerEl.classList.add("superdoc-paragraph-marker");
73200
+ markerEl.textContent = markerLayout?.markerText ?? "";
73201
+ markerEl.style.display = "inline-block";
73202
+ markerEl.style.fontFamily = markerLayout?.run?.fontFamily ?? "";
73203
+ if (markerLayout?.run?.fontSize != null) {
73204
+ markerEl.style.fontSize = `${markerLayout.run.fontSize}px`;
73205
+ }
73206
+ markerEl.style.fontWeight = markerLayout?.run?.bold ? "bold" : "";
73207
+ markerEl.style.fontStyle = markerLayout?.run?.italic ? "italic" : "";
73208
+ if (markerLayout?.run?.color) {
73209
+ markerEl.style.color = markerLayout.run.color;
73210
+ }
73211
+ if (markerLayout?.run?.letterSpacing != null) {
73212
+ markerEl.style.letterSpacing = `${markerLayout.run.letterSpacing}px`;
73213
+ }
73214
+ markerEl.style.position = "absolute";
73215
+ markerEl.style.left = `${markerLeftPos}px`;
73216
+ markerEl.style.width = `${markerBoxWidth}px`;
73217
+ markerEl.style.textAlign = markerJustification;
73218
+ markerEl.style.paddingRight = `${gutter}px`;
73219
+ lineEl.style.paddingLeft = `${markerStartPos}px`;
73220
+ lineContainer.appendChild(markerEl);
73221
+ lineContainer.appendChild(lineEl);
73222
+ return lineContainer;
73223
+ }
72983
73224
  const renderTableCell = (deps) => {
72984
73225
  const {
72985
73226
  doc: doc2,
@@ -73021,6 +73262,20 @@ const renderTableCell = (deps) => {
73021
73262
  }
73022
73263
  const cellBlocks = cell?.blocks ?? (cell?.paragraph ? [cell.paragraph] : []);
73023
73264
  const blockMeasures = cellMeasure?.blocks ?? (cellMeasure?.paragraph ? [cellMeasure.paragraph] : []);
73265
+ try {
73266
+ console.log(
73267
+ "[DomPainter.renderTableCell] cell render input",
73268
+ JSON.stringify({
73269
+ cellId: cell?.id,
73270
+ blockKinds: cellBlocks.map((b2) => b2.kind),
73271
+ measureKinds: blockMeasures.map((m2) => m2.kind),
73272
+ width: cellMeasure?.width,
73273
+ height: cellMeasure?.height,
73274
+ rowHeight
73275
+ })
73276
+ );
73277
+ } catch {
73278
+ }
73024
73279
  if (cellBlocks.length > 0 && blockMeasures.length > 0) {
73025
73280
  const content = doc2.createElement("div");
73026
73281
  content.style.position = "relative";
@@ -73052,9 +73307,106 @@ const renderTableCell = (deps) => {
73052
73307
  for (let i = 0; i < Math.min(blockMeasures.length, cellBlocks.length); i++) {
73053
73308
  const blockMeasure = blockMeasures[i];
73054
73309
  const block = cellBlocks[i];
73310
+ if (blockMeasure.kind === "image" && block?.kind === "image") {
73311
+ console.log(
73312
+ "[DomPainter.renderTableCell] rendering image block in cell",
73313
+ JSON.stringify({
73314
+ cellId: cell?.id,
73315
+ blockId: block.id,
73316
+ width: blockMeasure.width,
73317
+ height: blockMeasure.height
73318
+ })
73319
+ );
73320
+ const imageWrapper = doc2.createElement("div");
73321
+ imageWrapper.style.position = "relative";
73322
+ imageWrapper.style.width = `${blockMeasure.width}px`;
73323
+ imageWrapper.style.height = `${blockMeasure.height}px`;
73324
+ imageWrapper.style.maxWidth = "100%";
73325
+ imageWrapper.style.boxSizing = "border-box";
73326
+ applySdtDataset(imageWrapper, block.attrs?.sdt);
73327
+ const imgEl = doc2.createElement("img");
73328
+ imgEl.classList.add("superdoc-table-image");
73329
+ if (block.src) {
73330
+ imgEl.src = block.src;
73331
+ }
73332
+ imgEl.alt = block.alt ?? "";
73333
+ imgEl.style.width = "100%";
73334
+ imgEl.style.height = "100%";
73335
+ imgEl.style.objectFit = block.objectFit ?? "contain";
73336
+ imgEl.style.display = "block";
73337
+ imageWrapper.appendChild(imgEl);
73338
+ content.appendChild(imageWrapper);
73339
+ continue;
73340
+ }
73341
+ if (blockMeasure.kind === "drawing" && block?.kind === "drawing") {
73342
+ console.log(
73343
+ "[DomPainter.renderTableCell] rendering drawing block in cell",
73344
+ JSON.stringify({
73345
+ cellId: cell?.id,
73346
+ blockId: block.id,
73347
+ drawingKind: block.drawingKind,
73348
+ width: blockMeasure.width,
73349
+ height: blockMeasure.height
73350
+ })
73351
+ );
73352
+ const drawingWrapper = doc2.createElement("div");
73353
+ drawingWrapper.style.position = "relative";
73354
+ drawingWrapper.style.width = `${blockMeasure.width}px`;
73355
+ drawingWrapper.style.height = `${blockMeasure.height}px`;
73356
+ drawingWrapper.style.maxWidth = "100%";
73357
+ drawingWrapper.style.boxSizing = "border-box";
73358
+ applySdtDataset(drawingWrapper, block.attrs);
73359
+ const drawingInner = doc2.createElement("div");
73360
+ drawingInner.classList.add("superdoc-table-drawing");
73361
+ drawingInner.style.width = "100%";
73362
+ drawingInner.style.height = "100%";
73363
+ drawingInner.style.display = "flex";
73364
+ drawingInner.style.alignItems = "center";
73365
+ drawingInner.style.justifyContent = "center";
73366
+ drawingInner.style.overflow = "hidden";
73367
+ if (block.drawingKind === "image" && "src" in block && block.src) {
73368
+ const img = doc2.createElement("img");
73369
+ img.classList.add("superdoc-drawing-image");
73370
+ img.src = block.src;
73371
+ img.alt = block.alt ?? "";
73372
+ img.style.width = "100%";
73373
+ img.style.height = "100%";
73374
+ img.style.objectFit = block.objectFit ?? "contain";
73375
+ drawingInner.appendChild(img);
73376
+ } else {
73377
+ const placeholder = doc2.createElement("div");
73378
+ placeholder.style.width = "100%";
73379
+ placeholder.style.height = "100%";
73380
+ placeholder.style.background = "repeating-linear-gradient(45deg, rgba(15,23,42,0.1), rgba(15,23,42,0.1) 6px, rgba(15,23,42,0.2) 6px, rgba(15,23,42,0.2) 12px)";
73381
+ placeholder.style.border = "1px dashed rgba(15, 23, 42, 0.3)";
73382
+ drawingInner.appendChild(placeholder);
73383
+ }
73384
+ drawingWrapper.appendChild(drawingInner);
73385
+ content.appendChild(drawingWrapper);
73386
+ continue;
73387
+ }
73055
73388
  if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
73056
- const lines = blockMeasure.lines;
73389
+ try {
73390
+ const runKinds = (block.runs ?? []).map((r2) => r2.kind ?? "text");
73391
+ const imageRuns = (block.runs ?? []).filter((r2) => r2.kind === "image").map((r2) => ({ src: r2.src }));
73392
+ console.log(
73393
+ "[DomPainter.renderTableCell] rendering paragraph block in cell",
73394
+ JSON.stringify({
73395
+ cellId: cell?.id,
73396
+ blockId: block.id,
73397
+ runKinds,
73398
+ imageRuns
73399
+ })
73400
+ );
73401
+ } catch {
73402
+ }
73403
+ const paragraphMeasure = blockMeasure;
73404
+ const lines = paragraphMeasure.lines;
73057
73405
  const blockLineCount = lines?.length || 0;
73406
+ const wordLayout = block.attrs?.wordLayout ?? null;
73407
+ const markerLayout = wordLayout?.marker;
73408
+ const markerMeasure = paragraphMeasure.marker;
73409
+ const indentLeftPx = markerMeasure?.indentLeft ?? wordLayout?.indentLeftPx ?? (block.attrs?.indent && typeof block.attrs.indent.left === "number" ? block.attrs.indent.left : 0);
73058
73410
  const blockStartGlobal = cumulativeLineCount;
73059
73411
  const blockEndGlobal = cumulativeLineCount + blockLineCount;
73060
73412
  if (blockEndGlobal <= globalFromLine) {
@@ -73076,7 +73428,38 @@ const renderTableCell = (deps) => {
73076
73428
  for (let lineIdx = localStartLine; lineIdx < localEndLine && lineIdx < lines.length; lineIdx++) {
73077
73429
  const line = lines[lineIdx];
73078
73430
  const lineEl = renderLine(block, line, { ...context, section: "body" });
73079
- paraWrapper.appendChild(lineEl);
73431
+ lineEl.style.paddingLeft = "";
73432
+ lineEl.style.paddingRight = "";
73433
+ lineEl.style.textIndent = "";
73434
+ const shouldRenderMarker = markerLayout && markerMeasure && lineIdx === 0 && localStartLine === 0 && markerMeasure.markerWidth > 0;
73435
+ if (shouldRenderMarker) {
73436
+ const lineContainer = renderListMarker({
73437
+ doc: doc2,
73438
+ lineEl,
73439
+ markerLayout,
73440
+ markerMeasure,
73441
+ indentLeftPx
73442
+ });
73443
+ paraWrapper.appendChild(lineContainer);
73444
+ } else {
73445
+ if (markerLayout && indentLeftPx) {
73446
+ lineEl.style.paddingLeft = `${indentLeftPx}px`;
73447
+ } else {
73448
+ const indent = block.attrs?.indent;
73449
+ if (indent) {
73450
+ if (typeof indent.left === "number" && indent.left > 0) {
73451
+ lineEl.style.paddingLeft = `${indent.left}px`;
73452
+ }
73453
+ if (typeof indent.right === "number" && indent.right > 0) {
73454
+ lineEl.style.paddingRight = `${indent.right}px`;
73455
+ }
73456
+ if (lineIdx === 0 && typeof indent.firstLine === "number" && indent.firstLine !== 0) {
73457
+ lineEl.style.textIndent = `${indent.firstLine}px`;
73458
+ }
73459
+ }
73460
+ }
73461
+ paraWrapper.appendChild(lineEl);
73462
+ }
73080
73463
  renderedHeight += line.lineHeight;
73081
73464
  }
73082
73465
  const renderedEntireBlock = localStartLine === 0 && localEndLine >= blockLineCount;
@@ -74886,10 +75269,10 @@ const _DomPainter = class _DomPainter2 {
74886
75269
  let markerStartPos;
74887
75270
  if (isFirstLineIndentMode && wordLayout.marker.markerX !== void 0 && Number.isFinite(wordLayout.marker.markerX)) {
74888
75271
  markerStartPos = wordLayout.marker.markerX;
74889
- } else if (isFirstLineIndentMode) {
74890
- markerStartPos = paraIndentLeft + (paraIndent?.firstLine ?? 0);
74891
75272
  } else {
74892
- markerStartPos = paraIndentLeft - (paraIndent?.hanging ?? 0);
75273
+ const hanging = paraIndent?.hanging ?? 0;
75274
+ const firstLine = paraIndent?.firstLine ?? 0;
75275
+ markerStartPos = paraIndentLeft - hanging + firstLine;
74893
75276
  }
74894
75277
  const validMarkerStartPos = Number.isFinite(markerStartPos) ? markerStartPos : 0;
74895
75278
  lineEl.style.paddingLeft = `${validMarkerStartPos}px`;
@@ -74957,15 +75340,27 @@ const _DomPainter = class _DomPainter2 {
74957
75340
  tabWidth = LIST_MARKER_GAP$1;
74958
75341
  }
74959
75342
  } else {
74960
- const implicitTabStop = paraIndentLeft;
74961
- tabWidth = implicitTabStop - currentPos;
74962
- if (tabWidth < 1) {
75343
+ const firstLine = paraIndent?.firstLine ?? 0;
75344
+ const textStart = paraIndentLeft + firstLine;
75345
+ tabWidth = textStart - currentPos;
75346
+ if (tabWidth <= 0) {
74963
75347
  tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
74964
- if (tabWidth === 0) tabWidth = DEFAULT_TAB_INTERVAL_PX$1;
75348
+ } else if (tabWidth < LIST_MARKER_GAP$1) {
75349
+ tabWidth = LIST_MARKER_GAP$1;
74965
75350
  }
74966
75351
  }
74967
75352
  } else {
74968
- tabWidth = fragment.markerGutter != null && isFinite(fragment.markerGutter) ? fragment.markerGutter : typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx > 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP$1;
75353
+ const gutterWidth = fragment.markerGutter ?? wordLayout.marker.gutterWidthPx;
75354
+ if (gutterWidth !== void 0 && Number.isFinite(gutterWidth) && gutterWidth > 0) {
75355
+ tabWidth = gutterWidth;
75356
+ } else {
75357
+ const firstLine = paraIndent?.firstLine ?? 0;
75358
+ const textStart = paraIndentLeft + firstLine;
75359
+ tabWidth = textStart - validMarkerStartPos;
75360
+ }
75361
+ if (tabWidth < LIST_MARKER_GAP$1) {
75362
+ tabWidth = LIST_MARKER_GAP$1;
75363
+ }
74969
75364
  }
74970
75365
  tabEl.style.display = "inline-block";
74971
75366
  tabEl.style.width = `${tabWidth}px`;