@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
@@ -42391,7 +42391,7 @@ const _SuperConverter = class _SuperConverter2 {
42391
42391
  static getStoredSuperdocVersion(docx) {
42392
42392
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42393
42393
  }
42394
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.82") {
42394
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.84") {
42395
42395
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42396
42396
  }
42397
42397
  /**
@@ -59580,7 +59580,7 @@ const isHeadless = (editor) => {
59580
59580
  const shouldSkipNodeView = (editor) => {
59581
59581
  return isHeadless(editor);
59582
59582
  };
59583
- const summaryVersion = "1.0.0-beta.82";
59583
+ const summaryVersion = "1.0.0-beta.84";
59584
59584
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59585
59585
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59586
59586
  function mapAttributes(attrs) {
@@ -60369,7 +60369,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60369
60369
  { default: remarkStringify },
60370
60370
  { default: remarkGfm }
60371
60371
  ] = await Promise.all([
60372
- Promise.resolve().then(() => require("./index-GF5Urhpn-BNFw-VyP.cjs")),
60372
+ Promise.resolve().then(() => require("./index-ByDo0rez-DTbakkgE.cjs")),
60373
60373
  Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
60374
60374
  Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
60375
60375
  Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
@@ -60574,7 +60574,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60574
60574
  * Process collaboration migrations
60575
60575
  */
60576
60576
  processCollaborationMigrations() {
60577
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.82");
60577
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.84");
60578
60578
  if (!this.options.ydoc) return;
60579
60579
  const metaMap = this.options.ydoc.getMap("meta");
60580
60580
  let docVersion = metaMap.get("version");
@@ -63618,32 +63618,76 @@ function hydrateImageBlocks(blocks, mediaFiles) {
63618
63618
  return hasChanges ? hydratedRuns : runs;
63619
63619
  };
63620
63620
  return blocks.map((block) => {
63621
- if (block.kind === "image") {
63622
- if (!block.src || block.src.startsWith("data:")) {
63623
- return block;
63624
- }
63625
- const attrs = block.attrs ?? {};
63626
- const relId = typeof attrs.rId === "string" ? attrs.rId : void 0;
63627
- const attrSrc = typeof attrs.src === "string" ? attrs.src : void 0;
63628
- const extension = typeof attrs.extension === "string" ? attrs.extension.toLowerCase() : void 0;
63629
- const resolvedSrc = resolveImageSrc(block.src, relId, attrSrc, extension);
63630
- if (resolvedSrc) {
63631
- return { ...block, src: resolvedSrc };
63632
- }
63633
- return block;
63634
- }
63635
- if (block.kind === "paragraph") {
63636
- const paragraphBlock = block;
63637
- if (!paragraphBlock.runs || paragraphBlock.runs.length === 0) {
63638
- return block;
63639
- }
63640
- const hydratedRuns = hydrateRuns(paragraphBlock.runs);
63641
- if (hydratedRuns !== paragraphBlock.runs) {
63642
- return { ...paragraphBlock, runs: hydratedRuns };
63621
+ const hydrateBlock = (blk) => {
63622
+ if (blk.kind === "image") {
63623
+ if (!blk.src || blk.src.startsWith("data:")) {
63624
+ return blk;
63625
+ }
63626
+ const attrs = blk.attrs ?? {};
63627
+ const relId = typeof attrs.rId === "string" ? attrs.rId : void 0;
63628
+ const attrSrc = typeof attrs.src === "string" ? attrs.src : void 0;
63629
+ const extension = typeof attrs.extension === "string" ? attrs.extension.toLowerCase() : void 0;
63630
+ const resolvedSrc = resolveImageSrc(blk.src, relId, attrSrc, extension);
63631
+ if (resolvedSrc) {
63632
+ return { ...blk, src: resolvedSrc };
63633
+ }
63634
+ return blk;
63635
+ }
63636
+ if (blk.kind === "paragraph") {
63637
+ const paragraphBlock = blk;
63638
+ if (!paragraphBlock.runs || paragraphBlock.runs.length === 0) {
63639
+ return blk;
63640
+ }
63641
+ const hydratedRuns = hydrateRuns(paragraphBlock.runs);
63642
+ if (hydratedRuns !== paragraphBlock.runs) {
63643
+ return { ...paragraphBlock, runs: hydratedRuns };
63644
+ }
63645
+ return blk;
63646
+ }
63647
+ if (blk.kind === "table") {
63648
+ let rowsChanged = false;
63649
+ const newRows = blk.rows.map((row) => {
63650
+ let cellsChanged = false;
63651
+ const newCells = row.cells.map((cell) => {
63652
+ let cellChanged = false;
63653
+ const hydratedBlocks = (cell.blocks ?? (cell.paragraph ? [cell.paragraph] : [])).map((cb) => hydrateBlock(cb));
63654
+ if (cell.blocks && hydratedBlocks !== cell.blocks) {
63655
+ cellChanged = true;
63656
+ }
63657
+ let hydratedParagraph = cell.paragraph;
63658
+ if (!cell.blocks && cell.paragraph && cell.paragraph.kind === "paragraph") {
63659
+ const hydratedPara = hydrateBlock(cell.paragraph);
63660
+ if (hydratedPara !== cell.paragraph) {
63661
+ hydratedParagraph = hydratedPara;
63662
+ cellChanged = true;
63663
+ }
63664
+ }
63665
+ if (cellChanged) {
63666
+ return {
63667
+ ...cell,
63668
+ blocks: hydratedBlocks.length > 0 ? hydratedBlocks : cell.blocks,
63669
+ paragraph: hydratedParagraph
63670
+ };
63671
+ }
63672
+ return cell;
63673
+ });
63674
+ if (newCells.some((c2, idx) => c2 !== row.cells[idx])) {
63675
+ cellsChanged = true;
63676
+ }
63677
+ if (cellsChanged) {
63678
+ rowsChanged = true;
63679
+ return { ...row, cells: newCells };
63680
+ }
63681
+ return row;
63682
+ });
63683
+ if (rowsChanged) {
63684
+ return { ...blk, rows: newRows };
63685
+ }
63686
+ return blk;
63643
63687
  }
63644
- return block;
63645
- }
63646
- return block;
63688
+ return blk;
63689
+ };
63690
+ return hydrateBlock(block);
63647
63691
  });
63648
63692
  }
63649
63693
  function isGradientFill(value) {
@@ -65358,7 +65402,7 @@ function buildSdtCacheKey(nodeType, attrs, explicitKey) {
65358
65402
  return void 0;
65359
65403
  }
65360
65404
  const DEFAULT_LIST_HANGING_PX$1 = 18;
65361
- const LIST_MARKER_GAP$2 = 8;
65405
+ const LIST_MARKER_GAP$3 = 8;
65362
65406
  const DEFAULT_BULLET_GLYPH = "•";
65363
65407
  const DEFAULT_DECIMAL_PATTERN = "%1.";
65364
65408
  const ASCII_UPPERCASE_A = 65;
@@ -65769,7 +65813,7 @@ function computeWordParagraphLayout(input) {
65769
65813
  let markerBoxWidthPx;
65770
65814
  let markerX;
65771
65815
  if (hasFirstLineIndent) {
65772
- markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP$2 : DEFAULT_LIST_HANGING_PX$1;
65816
+ markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP$3 : DEFAULT_LIST_HANGING_PX$1;
65773
65817
  markerX = indentLeftPx + (firstLinePx ?? 0);
65774
65818
  layout.textStartPx = markerX + markerBoxWidthPx;
65775
65819
  layout.hangingPx = 0;
@@ -65869,12 +65913,12 @@ const resolveMarkerBoxWidth = (hangingPxRaw, glyphWidthPx) => {
65869
65913
  let markerBox = Math.max(hangingPxRaw || 0, 0);
65870
65914
  if (markerBox <= 0) {
65871
65915
  if (glyphWidthPx != null && glyphWidthPx > 0) {
65872
- markerBox = glyphWidthPx + LIST_MARKER_GAP$2;
65916
+ markerBox = glyphWidthPx + LIST_MARKER_GAP$3;
65873
65917
  } else {
65874
65918
  markerBox = DEFAULT_LIST_HANGING_PX$1;
65875
65919
  }
65876
- } else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP$2 > markerBox) {
65877
- markerBox = glyphWidthPx + LIST_MARKER_GAP$2;
65920
+ } else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP$3 > markerBox) {
65921
+ markerBox = glyphWidthPx + LIST_MARKER_GAP$3;
65878
65922
  }
65879
65923
  return markerBox;
65880
65924
  };
@@ -66496,13 +66540,21 @@ const findNumFmtElement = (lvl) => {
66496
66540
  const resolveNumberingFromContext = (numId, ilvl, numbering) => {
66497
66541
  const definitions = numbering?.definitions;
66498
66542
  const abstracts = numbering?.abstracts;
66499
- if (!definitions || !abstracts) return void 0;
66543
+ if (!definitions || !abstracts) {
66544
+ return void 0;
66545
+ }
66500
66546
  const numDef = asOoxmlElement(definitions[String(numId)]);
66501
- if (!numDef) return void 0;
66547
+ if (!numDef) {
66548
+ return void 0;
66549
+ }
66502
66550
  const abstractId = getAttribute(findChild(numDef, "w:abstractNumId"), "w:val");
66503
- if (abstractId == null) return void 0;
66551
+ if (abstractId == null) {
66552
+ return void 0;
66553
+ }
66504
66554
  const abstract = asOoxmlElement(abstracts[String(abstractId)]);
66505
- if (!abstract) return void 0;
66555
+ if (!abstract) {
66556
+ return void 0;
66557
+ }
66506
66558
  let levelDef = abstract.elements?.find(
66507
66559
  (el) => el?.name === "w:lvl" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
66508
66560
  );
@@ -66514,7 +66566,9 @@ const resolveNumberingFromContext = (numId, ilvl, numbering) => {
66514
66566
  levelDef = overrideLvl;
66515
66567
  }
66516
66568
  const startOverride = parseNumberAttr(getAttribute(findChild(override, "w:startOverride"), "w:val"));
66517
- if (!levelDef) return void 0;
66569
+ if (!levelDef) {
66570
+ return void 0;
66571
+ }
66518
66572
  const numFmtEl = findNumFmtElement(levelDef);
66519
66573
  const lvlText = getAttribute(findChild(levelDef, "w:lvlText"), "w:val");
66520
66574
  const start2 = startOverride ?? parseNumberAttr(getAttribute(findChild(levelDef, "w:start"), "w:val"));
@@ -67160,14 +67214,29 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
67160
67214
  paragraphAttrs.frame = frame;
67161
67215
  }
67162
67216
  }
67217
+ const listRendering = normalizeListRenderingAttrs(attrs.listRendering);
67163
67218
  const numberingSource = attrs.numberingProperties ?? paragraphProps.numberingProperties ?? hydrated?.numberingProperties;
67164
- const rawNumberingProps = toAdapterNumberingProps(numberingSource);
67219
+ let rawNumberingProps = toAdapterNumberingProps(numberingSource);
67220
+ if (!rawNumberingProps && listRendering) {
67221
+ const path = listRendering.path;
67222
+ const counterFromPath = path && path.length ? path[path.length - 1] : void 0;
67223
+ const ilvl = path && path.length > 1 ? path.length - 1 : 0;
67224
+ rawNumberingProps = {
67225
+ numId: -1,
67226
+ ilvl,
67227
+ path,
67228
+ counterValue: Number.isFinite(counterFromPath) ? Number(counterFromPath) : void 0,
67229
+ markerText: listRendering.markerText,
67230
+ format: listRendering.numberingType,
67231
+ lvlJc: listRendering.justification,
67232
+ suffix: listRendering.suffix
67233
+ };
67234
+ }
67165
67235
  const hasValidNumbering = rawNumberingProps && isValidNumberingId(rawNumberingProps.numId);
67166
67236
  if (hasValidNumbering) {
67167
67237
  const numberingProps = rawNumberingProps;
67168
67238
  const numId = numberingProps.numId;
67169
67239
  const ilvl = Number.isFinite(numberingProps.ilvl) ? Math.max(0, Math.floor(Number(numberingProps.ilvl))) : 0;
67170
- const listRendering = normalizeListRenderingAttrs(attrs.listRendering);
67171
67240
  const numericNumId = typeof numId === "number" ? numId : void 0;
67172
67241
  const resolvedLevel = resolveNumberingFromContext(numId, ilvl, converterContext?.numbering);
67173
67242
  if (resolvedLevel) {
@@ -67242,13 +67311,18 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
67242
67311
  }
67243
67312
  }
67244
67313
  paragraphAttrs.wordLayout = wordLayout;
67245
- if (enrichedNumberingProps.resolvedLevelIndent) {
67246
- const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
67247
- const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
67248
- paragraphAttrs.indent = {
67249
- ...baseIndent,
67250
- ...normalizedIndent ?? {}
67251
- };
67314
+ }
67315
+ if (enrichedNumberingProps.resolvedLevelIndent) {
67316
+ const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
67317
+ const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
67318
+ paragraphAttrs.indent = {
67319
+ ...baseIndent,
67320
+ ...normalizedIndent ?? {}
67321
+ };
67322
+ if (normalizedIndent?.firstLine !== void 0) {
67323
+ delete paragraphAttrs.indent.hanging;
67324
+ } else if (normalizedIndent?.hanging !== void 0) {
67325
+ delete paragraphAttrs.indent.firstLine;
67252
67326
  }
67253
67327
  }
67254
67328
  paragraphAttrs.numberingProperties = enrichedNumberingProps;
@@ -69218,29 +69292,129 @@ const parseTableCell = (args) => {
69218
69292
  ...context.converterContext,
69219
69293
  tableStyleParagraphProps
69220
69294
  } : context.converterContext;
69295
+ const paragraphToFlowBlocks2 = context.converters?.paragraphToFlowBlocks ?? context.paragraphToFlowBlocks;
69296
+ const listCounterContext = context.listCounterContext;
69221
69297
  for (const childNode of cellNode.content) {
69222
69298
  if (childNode.type === "paragraph") {
69223
- const paragraphBlocks = context.paragraphToFlowBlocks(
69299
+ if (!paragraphToFlowBlocks2) continue;
69300
+ const paragraphBlocks = paragraphToFlowBlocks2(
69224
69301
  childNode,
69225
69302
  context.nextBlockId,
69226
69303
  context.positions,
69227
69304
  context.defaultFont,
69228
69305
  context.defaultSize,
69229
69306
  context.styleContext,
69230
- void 0,
69231
- // listCounterContext
69307
+ listCounterContext,
69232
69308
  context.trackedChanges,
69233
69309
  context.bookmarks,
69234
69310
  context.hyperlinkConfig,
69235
69311
  context.themeColors,
69236
69312
  cellConverterContext
69237
- // converterContext at position 12
69238
69313
  );
69239
- const paragraph = paragraphBlocks.find((b2) => b2.kind === "paragraph");
69240
- if (paragraph) {
69241
- blocks.push(paragraph);
69314
+ paragraphBlocks.forEach((block) => {
69315
+ if (block.kind === "paragraph" || block.kind === "image" || block.kind === "drawing") {
69316
+ blocks.push(block);
69317
+ }
69318
+ });
69319
+ continue;
69320
+ }
69321
+ if (childNode.type === "image" && context.converters?.imageNodeToBlock) {
69322
+ const mergedMarks = [...childNode.marks ?? []];
69323
+ const trackedMeta = context.trackedChanges ? collectTrackedChangeFromMarks(mergedMarks) : void 0;
69324
+ if (shouldHideTrackedNode(trackedMeta, context.trackedChanges)) {
69325
+ continue;
69326
+ }
69327
+ const imageBlock = context.converters.imageNodeToBlock(
69328
+ childNode,
69329
+ context.nextBlockId,
69330
+ context.positions,
69331
+ trackedMeta,
69332
+ context.trackedChanges
69333
+ );
69334
+ if (imageBlock && imageBlock.kind === "image") {
69335
+ annotateBlockWithTrackedChange(imageBlock, trackedMeta, context.trackedChanges);
69336
+ blocks.push(imageBlock);
69337
+ }
69338
+ continue;
69339
+ }
69340
+ if (childNode.type === "vectorShape" && context.converters?.vectorShapeNodeToDrawingBlock) {
69341
+ const drawingBlock = context.converters.vectorShapeNodeToDrawingBlock(
69342
+ childNode,
69343
+ context.nextBlockId,
69344
+ context.positions
69345
+ );
69346
+ if (drawingBlock) {
69347
+ blocks.push(drawingBlock);
69348
+ }
69349
+ continue;
69350
+ }
69351
+ if (childNode.type === "shapeGroup" && context.converters?.shapeGroupNodeToDrawingBlock) {
69352
+ const drawingBlock = context.converters.shapeGroupNodeToDrawingBlock(
69353
+ childNode,
69354
+ context.nextBlockId,
69355
+ context.positions
69356
+ );
69357
+ if (drawingBlock) {
69358
+ blocks.push(drawingBlock);
69242
69359
  }
69360
+ continue;
69243
69361
  }
69362
+ if (childNode.type === "shapeContainer" && context.converters?.shapeContainerNodeToDrawingBlock) {
69363
+ const drawingBlock = context.converters.shapeContainerNodeToDrawingBlock(
69364
+ childNode,
69365
+ context.nextBlockId,
69366
+ context.positions
69367
+ );
69368
+ if (drawingBlock) {
69369
+ blocks.push(drawingBlock);
69370
+ }
69371
+ continue;
69372
+ }
69373
+ if (childNode.type === "shapeTextbox" && context.converters?.shapeTextboxNodeToDrawingBlock) {
69374
+ const drawingBlock = context.converters.shapeTextboxNodeToDrawingBlock(
69375
+ childNode,
69376
+ context.nextBlockId,
69377
+ context.positions
69378
+ );
69379
+ if (drawingBlock) {
69380
+ blocks.push(drawingBlock);
69381
+ }
69382
+ }
69383
+ }
69384
+ try {
69385
+ const blockSummaries = blocks.map((b2) => {
69386
+ if (b2.kind === "paragraph") {
69387
+ const runs = b2.runs ?? [];
69388
+ const attrs = b2.attrs ?? {};
69389
+ return {
69390
+ kind: "paragraph",
69391
+ runKinds: runs.map((r2) => r2.kind ?? "text"),
69392
+ runCount: runs.length,
69393
+ runPreview: runs.map((r2) => {
69394
+ const kind = r2.kind ?? "text";
69395
+ if (kind === "image") {
69396
+ const img = r2;
69397
+ return { kind, src: img.src, width: img.width, height: img.height };
69398
+ }
69399
+ return { kind };
69400
+ }),
69401
+ hasNumbering: Boolean(attrs.numberingProperties),
69402
+ markerText: attrs.wordLayout?.marker?.markerText
69403
+ };
69404
+ }
69405
+ return { kind: b2.kind };
69406
+ });
69407
+ console.log(
69408
+ "[tableNodeToBlock.parseTableCell] cell contents",
69409
+ JSON.stringify({
69410
+ cellIndex,
69411
+ rowIndex,
69412
+ cellIdPreview: `cell-${rowIndex}-${cellIndex}`,
69413
+ childTypes: cellNode.content.map((c2) => c2?.type),
69414
+ blocks: blockSummaries
69415
+ })
69416
+ );
69417
+ } catch {
69244
69418
  }
69245
69419
  if (blocks.length === 0) {
69246
69420
  return null;
@@ -69380,9 +69554,10 @@ function extractFloatingTableAnchorWrap(node) {
69380
69554
  }
69381
69555
  return { anchor, wrap: wrap2 };
69382
69556
  }
69383
- function tableNodeToBlock$1(node, nextBlockId, positions, defaultFont, defaultSize, _styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, paragraphToFlowBlocks2, converterContext) {
69557
+ function tableNodeToBlock$1(node, nextBlockId, positions, defaultFont, defaultSize, _styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, paragraphToFlowBlocks2, converterContext, options) {
69384
69558
  if (!Array.isArray(node.content) || node.content.length === 0) return null;
69385
- if (!paragraphToFlowBlocks2) return null;
69559
+ const paragraphConverter = paragraphToFlowBlocks2 ?? options?.converters?.paragraphToFlowBlocks;
69560
+ if (!paragraphConverter) return null;
69386
69561
  const parserDeps = {
69387
69562
  nextBlockId,
69388
69563
  positions,
@@ -69393,8 +69568,10 @@ function tableNodeToBlock$1(node, nextBlockId, positions, defaultFont, defaultSi
69393
69568
  bookmarks,
69394
69569
  hyperlinkConfig,
69395
69570
  themeColors,
69396
- paragraphToFlowBlocks: paragraphToFlowBlocks2,
69397
- converterContext
69571
+ listCounterContext: options?.listCounterContext,
69572
+ paragraphToFlowBlocks: paragraphConverter,
69573
+ converterContext,
69574
+ converters: options?.converters
69398
69575
  };
69399
69576
  const hydratedTableStyle = hydrateTableStyleAttrs(node, converterContext);
69400
69577
  const defaultCellPadding = hydratedTableStyle?.cellPadding;
@@ -69514,6 +69691,7 @@ function handleTableNode(node, context) {
69514
69691
  defaultFont,
69515
69692
  defaultSize,
69516
69693
  styleContext,
69694
+ listCounterContext,
69517
69695
  trackedChangesConfig,
69518
69696
  bookmarks,
69519
69697
  hyperlinkConfig,
@@ -69533,7 +69711,8 @@ function handleTableNode(node, context) {
69533
69711
  void 0,
69534
69712
  // themeColors
69535
69713
  converters?.paragraphToFlowBlocks,
69536
- converterContext
69714
+ converterContext,
69715
+ { listCounterContext, converters }
69537
69716
  );
69538
69717
  if (tableBlock) {
69539
69718
  blocks.push(tableBlock);
@@ -69687,7 +69866,7 @@ function toFlowBlocks(pmDoc, options) {
69687
69866
  bookmarks2,
69688
69867
  hyperlinkConfig2,
69689
69868
  themeColorsParam ?? themeColors,
69690
- converterCtx ?? converterContext
69869
+ paragraphConverter
69691
69870
  );
69692
69871
  const handlerContext = {
69693
69872
  blocks,
@@ -69710,7 +69889,11 @@ function toFlowBlocks(pmDoc, options) {
69710
69889
  converters: {
69711
69890
  paragraphToFlowBlocks: paragraphConverter,
69712
69891
  tableNodeToBlock: tableConverter,
69713
- imageNodeToBlock
69892
+ imageNodeToBlock,
69893
+ vectorShapeNodeToDrawingBlock,
69894
+ shapeGroupNodeToDrawingBlock,
69895
+ shapeContainerNodeToDrawingBlock,
69896
+ shapeTextboxNodeToDrawingBlock
69714
69897
  }
69715
69898
  };
69716
69899
  doc2.content.forEach((node) => {
@@ -69795,7 +69978,18 @@ function paragraphToFlowBlocks(para, nextBlockId, positions, defaultFont, defaul
69795
69978
  hyperlinkConfig2,
69796
69979
  themeColors2,
69797
69980
  paragraphToFlowBlocks,
69798
- converterCtx ?? converterContext
69981
+ converterCtx ?? converterContext,
69982
+ {
69983
+ listCounterContext,
69984
+ converters: {
69985
+ paragraphToFlowBlocks: paragraphToFlowBlocks$1,
69986
+ imageNodeToBlock,
69987
+ vectorShapeNodeToDrawingBlock,
69988
+ shapeGroupNodeToDrawingBlock,
69989
+ shapeContainerNodeToDrawingBlock,
69990
+ shapeTextboxNodeToDrawingBlock
69991
+ }
69992
+ }
69799
69993
  )
69800
69994
  },
69801
69995
  converterContext
@@ -69814,7 +70008,17 @@ function tableNodeToBlock(node, nextBlockId, positions, defaultFont, defaultSize
69814
70008
  hyperlinkConfig,
69815
70009
  themeColors,
69816
70010
  paragraphToFlowBlocks,
69817
- converterContext
70011
+ converterContext,
70012
+ {
70013
+ converters: {
70014
+ paragraphToFlowBlocks: paragraphToFlowBlocks$1,
70015
+ imageNodeToBlock,
70016
+ vectorShapeNodeToDrawingBlock,
70017
+ shapeGroupNodeToDrawingBlock,
70018
+ shapeContainerNodeToDrawingBlock,
70019
+ shapeTextboxNodeToDrawingBlock
70020
+ }
70021
+ }
69818
70022
  );
69819
70023
  }
69820
70024
  let measurementCanvas = null;
@@ -72997,6 +73201,43 @@ const resolveTableCellBorders = (tableBorders, rowIndex, colIndex, totalRows, to
72997
73201
  right: borderValueToSpec(isLastCol ? tableBorders?.right : null)
72998
73202
  };
72999
73203
  };
73204
+ const LIST_MARKER_GAP$2 = 8;
73205
+ function renderListMarker(params2) {
73206
+ const { doc: doc2, lineEl, markerLayout, markerMeasure, indentLeftPx } = params2;
73207
+ const markerJustification = markerLayout?.justification ?? "left";
73208
+ const markerBoxWidth = (typeof markerLayout?.markerBoxWidthPx === "number" ? markerLayout.markerBoxWidthPx : void 0) ?? markerMeasure?.markerWidth ?? 0;
73209
+ const gutter = (typeof markerLayout?.gutterWidthPx === "number" ? markerLayout.gutterWidthPx : void 0) ?? markerMeasure?.gutterWidth ?? LIST_MARKER_GAP$2;
73210
+ const markerStartPos = markerJustification === "left" ? indentLeftPx : (typeof markerLayout?.markerX === "number" ? markerLayout.markerX : void 0) ?? indentLeftPx;
73211
+ const markerLeftPos = markerStartPos - markerBoxWidth;
73212
+ const lineContainer = doc2.createElement("div");
73213
+ lineContainer.style.position = "relative";
73214
+ lineContainer.style.width = "100%";
73215
+ const markerEl = doc2.createElement("span");
73216
+ markerEl.classList.add("superdoc-paragraph-marker");
73217
+ markerEl.textContent = markerLayout?.markerText ?? "";
73218
+ markerEl.style.display = "inline-block";
73219
+ markerEl.style.fontFamily = markerLayout?.run?.fontFamily ?? "";
73220
+ if (markerLayout?.run?.fontSize != null) {
73221
+ markerEl.style.fontSize = `${markerLayout.run.fontSize}px`;
73222
+ }
73223
+ markerEl.style.fontWeight = markerLayout?.run?.bold ? "bold" : "";
73224
+ markerEl.style.fontStyle = markerLayout?.run?.italic ? "italic" : "";
73225
+ if (markerLayout?.run?.color) {
73226
+ markerEl.style.color = markerLayout.run.color;
73227
+ }
73228
+ if (markerLayout?.run?.letterSpacing != null) {
73229
+ markerEl.style.letterSpacing = `${markerLayout.run.letterSpacing}px`;
73230
+ }
73231
+ markerEl.style.position = "absolute";
73232
+ markerEl.style.left = `${markerLeftPos}px`;
73233
+ markerEl.style.width = `${markerBoxWidth}px`;
73234
+ markerEl.style.textAlign = markerJustification;
73235
+ markerEl.style.paddingRight = `${gutter}px`;
73236
+ lineEl.style.paddingLeft = `${markerStartPos}px`;
73237
+ lineContainer.appendChild(markerEl);
73238
+ lineContainer.appendChild(lineEl);
73239
+ return lineContainer;
73240
+ }
73000
73241
  const renderTableCell = (deps) => {
73001
73242
  const {
73002
73243
  doc: doc2,
@@ -73038,6 +73279,20 @@ const renderTableCell = (deps) => {
73038
73279
  }
73039
73280
  const cellBlocks = cell?.blocks ?? (cell?.paragraph ? [cell.paragraph] : []);
73040
73281
  const blockMeasures = cellMeasure?.blocks ?? (cellMeasure?.paragraph ? [cellMeasure.paragraph] : []);
73282
+ try {
73283
+ console.log(
73284
+ "[DomPainter.renderTableCell] cell render input",
73285
+ JSON.stringify({
73286
+ cellId: cell?.id,
73287
+ blockKinds: cellBlocks.map((b2) => b2.kind),
73288
+ measureKinds: blockMeasures.map((m2) => m2.kind),
73289
+ width: cellMeasure?.width,
73290
+ height: cellMeasure?.height,
73291
+ rowHeight
73292
+ })
73293
+ );
73294
+ } catch {
73295
+ }
73041
73296
  if (cellBlocks.length > 0 && blockMeasures.length > 0) {
73042
73297
  const content = doc2.createElement("div");
73043
73298
  content.style.position = "relative";
@@ -73069,9 +73324,106 @@ const renderTableCell = (deps) => {
73069
73324
  for (let i = 0; i < Math.min(blockMeasures.length, cellBlocks.length); i++) {
73070
73325
  const blockMeasure = blockMeasures[i];
73071
73326
  const block = cellBlocks[i];
73327
+ if (blockMeasure.kind === "image" && block?.kind === "image") {
73328
+ console.log(
73329
+ "[DomPainter.renderTableCell] rendering image block in cell",
73330
+ JSON.stringify({
73331
+ cellId: cell?.id,
73332
+ blockId: block.id,
73333
+ width: blockMeasure.width,
73334
+ height: blockMeasure.height
73335
+ })
73336
+ );
73337
+ const imageWrapper = doc2.createElement("div");
73338
+ imageWrapper.style.position = "relative";
73339
+ imageWrapper.style.width = `${blockMeasure.width}px`;
73340
+ imageWrapper.style.height = `${blockMeasure.height}px`;
73341
+ imageWrapper.style.maxWidth = "100%";
73342
+ imageWrapper.style.boxSizing = "border-box";
73343
+ applySdtDataset(imageWrapper, block.attrs?.sdt);
73344
+ const imgEl = doc2.createElement("img");
73345
+ imgEl.classList.add("superdoc-table-image");
73346
+ if (block.src) {
73347
+ imgEl.src = block.src;
73348
+ }
73349
+ imgEl.alt = block.alt ?? "";
73350
+ imgEl.style.width = "100%";
73351
+ imgEl.style.height = "100%";
73352
+ imgEl.style.objectFit = block.objectFit ?? "contain";
73353
+ imgEl.style.display = "block";
73354
+ imageWrapper.appendChild(imgEl);
73355
+ content.appendChild(imageWrapper);
73356
+ continue;
73357
+ }
73358
+ if (blockMeasure.kind === "drawing" && block?.kind === "drawing") {
73359
+ console.log(
73360
+ "[DomPainter.renderTableCell] rendering drawing block in cell",
73361
+ JSON.stringify({
73362
+ cellId: cell?.id,
73363
+ blockId: block.id,
73364
+ drawingKind: block.drawingKind,
73365
+ width: blockMeasure.width,
73366
+ height: blockMeasure.height
73367
+ })
73368
+ );
73369
+ const drawingWrapper = doc2.createElement("div");
73370
+ drawingWrapper.style.position = "relative";
73371
+ drawingWrapper.style.width = `${blockMeasure.width}px`;
73372
+ drawingWrapper.style.height = `${blockMeasure.height}px`;
73373
+ drawingWrapper.style.maxWidth = "100%";
73374
+ drawingWrapper.style.boxSizing = "border-box";
73375
+ applySdtDataset(drawingWrapper, block.attrs);
73376
+ const drawingInner = doc2.createElement("div");
73377
+ drawingInner.classList.add("superdoc-table-drawing");
73378
+ drawingInner.style.width = "100%";
73379
+ drawingInner.style.height = "100%";
73380
+ drawingInner.style.display = "flex";
73381
+ drawingInner.style.alignItems = "center";
73382
+ drawingInner.style.justifyContent = "center";
73383
+ drawingInner.style.overflow = "hidden";
73384
+ if (block.drawingKind === "image" && "src" in block && block.src) {
73385
+ const img = doc2.createElement("img");
73386
+ img.classList.add("superdoc-drawing-image");
73387
+ img.src = block.src;
73388
+ img.alt = block.alt ?? "";
73389
+ img.style.width = "100%";
73390
+ img.style.height = "100%";
73391
+ img.style.objectFit = block.objectFit ?? "contain";
73392
+ drawingInner.appendChild(img);
73393
+ } else {
73394
+ const placeholder = doc2.createElement("div");
73395
+ placeholder.style.width = "100%";
73396
+ placeholder.style.height = "100%";
73397
+ 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)";
73398
+ placeholder.style.border = "1px dashed rgba(15, 23, 42, 0.3)";
73399
+ drawingInner.appendChild(placeholder);
73400
+ }
73401
+ drawingWrapper.appendChild(drawingInner);
73402
+ content.appendChild(drawingWrapper);
73403
+ continue;
73404
+ }
73072
73405
  if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
73073
- const lines = blockMeasure.lines;
73406
+ try {
73407
+ const runKinds = (block.runs ?? []).map((r2) => r2.kind ?? "text");
73408
+ const imageRuns = (block.runs ?? []).filter((r2) => r2.kind === "image").map((r2) => ({ src: r2.src }));
73409
+ console.log(
73410
+ "[DomPainter.renderTableCell] rendering paragraph block in cell",
73411
+ JSON.stringify({
73412
+ cellId: cell?.id,
73413
+ blockId: block.id,
73414
+ runKinds,
73415
+ imageRuns
73416
+ })
73417
+ );
73418
+ } catch {
73419
+ }
73420
+ const paragraphMeasure = blockMeasure;
73421
+ const lines = paragraphMeasure.lines;
73074
73422
  const blockLineCount = lines?.length || 0;
73423
+ const wordLayout = block.attrs?.wordLayout ?? null;
73424
+ const markerLayout = wordLayout?.marker;
73425
+ const markerMeasure = paragraphMeasure.marker;
73426
+ const indentLeftPx = markerMeasure?.indentLeft ?? wordLayout?.indentLeftPx ?? (block.attrs?.indent && typeof block.attrs.indent.left === "number" ? block.attrs.indent.left : 0);
73075
73427
  const blockStartGlobal = cumulativeLineCount;
73076
73428
  const blockEndGlobal = cumulativeLineCount + blockLineCount;
73077
73429
  if (blockEndGlobal <= globalFromLine) {
@@ -73093,7 +73445,38 @@ const renderTableCell = (deps) => {
73093
73445
  for (let lineIdx = localStartLine; lineIdx < localEndLine && lineIdx < lines.length; lineIdx++) {
73094
73446
  const line = lines[lineIdx];
73095
73447
  const lineEl = renderLine(block, line, { ...context, section: "body" });
73096
- paraWrapper.appendChild(lineEl);
73448
+ lineEl.style.paddingLeft = "";
73449
+ lineEl.style.paddingRight = "";
73450
+ lineEl.style.textIndent = "";
73451
+ const shouldRenderMarker = markerLayout && markerMeasure && lineIdx === 0 && localStartLine === 0 && markerMeasure.markerWidth > 0;
73452
+ if (shouldRenderMarker) {
73453
+ const lineContainer = renderListMarker({
73454
+ doc: doc2,
73455
+ lineEl,
73456
+ markerLayout,
73457
+ markerMeasure,
73458
+ indentLeftPx
73459
+ });
73460
+ paraWrapper.appendChild(lineContainer);
73461
+ } else {
73462
+ if (markerLayout && indentLeftPx) {
73463
+ lineEl.style.paddingLeft = `${indentLeftPx}px`;
73464
+ } else {
73465
+ const indent = block.attrs?.indent;
73466
+ if (indent) {
73467
+ if (typeof indent.left === "number" && indent.left > 0) {
73468
+ lineEl.style.paddingLeft = `${indent.left}px`;
73469
+ }
73470
+ if (typeof indent.right === "number" && indent.right > 0) {
73471
+ lineEl.style.paddingRight = `${indent.right}px`;
73472
+ }
73473
+ if (lineIdx === 0 && typeof indent.firstLine === "number" && indent.firstLine !== 0) {
73474
+ lineEl.style.textIndent = `${indent.firstLine}px`;
73475
+ }
73476
+ }
73477
+ }
73478
+ paraWrapper.appendChild(lineEl);
73479
+ }
73097
73480
  renderedHeight += line.lineHeight;
73098
73481
  }
73099
73482
  const renderedEntireBlock = localStartLine === 0 && localEndLine >= blockLineCount;
@@ -74903,10 +75286,10 @@ const _DomPainter = class _DomPainter2 {
74903
75286
  let markerStartPos;
74904
75287
  if (isFirstLineIndentMode && wordLayout.marker.markerX !== void 0 && Number.isFinite(wordLayout.marker.markerX)) {
74905
75288
  markerStartPos = wordLayout.marker.markerX;
74906
- } else if (isFirstLineIndentMode) {
74907
- markerStartPos = paraIndentLeft + (paraIndent?.firstLine ?? 0);
74908
75289
  } else {
74909
- markerStartPos = paraIndentLeft - (paraIndent?.hanging ?? 0);
75290
+ const hanging = paraIndent?.hanging ?? 0;
75291
+ const firstLine = paraIndent?.firstLine ?? 0;
75292
+ markerStartPos = paraIndentLeft - hanging + firstLine;
74910
75293
  }
74911
75294
  const validMarkerStartPos = Number.isFinite(markerStartPos) ? markerStartPos : 0;
74912
75295
  lineEl.style.paddingLeft = `${validMarkerStartPos}px`;
@@ -74974,15 +75357,27 @@ const _DomPainter = class _DomPainter2 {
74974
75357
  tabWidth = LIST_MARKER_GAP$1;
74975
75358
  }
74976
75359
  } else {
74977
- const implicitTabStop = paraIndentLeft;
74978
- tabWidth = implicitTabStop - currentPos;
74979
- if (tabWidth < 1) {
75360
+ const firstLine = paraIndent?.firstLine ?? 0;
75361
+ const textStart = paraIndentLeft + firstLine;
75362
+ tabWidth = textStart - currentPos;
75363
+ if (tabWidth <= 0) {
74980
75364
  tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
74981
- if (tabWidth === 0) tabWidth = DEFAULT_TAB_INTERVAL_PX$1;
75365
+ } else if (tabWidth < LIST_MARKER_GAP$1) {
75366
+ tabWidth = LIST_MARKER_GAP$1;
74982
75367
  }
74983
75368
  }
74984
75369
  } else {
74985
- 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;
75370
+ const gutterWidth = fragment.markerGutter ?? wordLayout.marker.gutterWidthPx;
75371
+ if (gutterWidth !== void 0 && Number.isFinite(gutterWidth) && gutterWidth > 0) {
75372
+ tabWidth = gutterWidth;
75373
+ } else {
75374
+ const firstLine = paraIndent?.firstLine ?? 0;
75375
+ const textStart = paraIndentLeft + firstLine;
75376
+ tabWidth = textStart - validMarkerStartPos;
75377
+ }
75378
+ if (tabWidth < LIST_MARKER_GAP$1) {
75379
+ tabWidth = LIST_MARKER_GAP$1;
75380
+ }
74986
75381
  }
74987
75382
  tabEl.style.display = "inline-block";
74988
75383
  tabEl.style.width = `${tabWidth}px`;