@superdoc-dev/mcp 0.12.0-next.16 → 0.12.0-next.18

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 +2008 -568
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -52172,7 +52172,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
52172
52172
  emptyOptions2 = {};
52173
52173
  });
52174
52174
 
52175
- // ../../packages/superdoc/dist/chunks/SuperConverter-DBlOjc68.es.js
52175
+ // ../../packages/superdoc/dist/chunks/SuperConverter-kDrJISzz.es.js
52176
52176
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
52177
52177
  const fieldValue = extension$1.config[field];
52178
52178
  if (typeof fieldValue === "function")
@@ -68260,6 +68260,61 @@ function parseStyleId(chartSpace) {
68260
68260
  const val = getAttr(findChild$1(chartSpace, "c:style"), "val");
68261
68261
  return val != null ? Number(val) : undefined;
68262
68262
  }
68263
+ function stripRunNodeMarks(nodes) {
68264
+ if (!Array.isArray(nodes))
68265
+ return nodes;
68266
+ return nodes.map((node2) => {
68267
+ if (!node2 || typeof node2 !== "object")
68268
+ return node2;
68269
+ const stripped = node2.type === "run" && Array.isArray(node2.marks) && node2.marks.length > 0 ? {
68270
+ ...node2,
68271
+ marks: []
68272
+ } : node2;
68273
+ if (Array.isArray(stripped.content))
68274
+ return {
68275
+ ...stripped,
68276
+ content: stripRunNodeMarks(stripped.content)
68277
+ };
68278
+ return stripped;
68279
+ });
68280
+ }
68281
+ function importDrawingMLTextbox({ params, drawingNode, textBoxContent, bodyPr, baseAttrs = {}, paragraphImporter }) {
68282
+ if (!textBoxContent)
68283
+ return null;
68284
+ const textboxParagraphs = collectTextBoxParagraphs(preProcessTextBoxContent(textBoxContent, params)?.elements || []);
68285
+ const importParagraph = typeof paragraphImporter === "function" ? paragraphImporter : (paragraph2) => {
68286
+ return handleParagraphNode$1({
68287
+ ...params,
68288
+ nodes: [paragraph2]
68289
+ })?.nodes || [];
68290
+ };
68291
+ const contentNodes = stripRunNodeMarks(textboxParagraphs.flatMap((paragraph2) => {
68292
+ const imported = importParagraph(paragraph2);
68293
+ return Array.isArray(imported) ? imported : imported ? [imported] : [];
68294
+ }));
68295
+ const { verticalAlign, insets } = extractBodyPrProperties(bodyPr);
68296
+ return {
68297
+ type: "shapeContainer",
68298
+ attrs: {
68299
+ ...baseAttrs,
68300
+ drawingContent: drawingNode
68301
+ },
68302
+ content: [{
68303
+ type: "shapeTextbox",
68304
+ attrs: {
68305
+ textInsets: {
68306
+ top: insets.top,
68307
+ right: insets.right,
68308
+ bottom: insets.bottom,
68309
+ left: insets.left
68310
+ },
68311
+ textVerticalAlign: verticalAlign,
68312
+ attributes: {}
68313
+ },
68314
+ content: contentNodes
68315
+ }]
68316
+ };
68317
+ }
68263
68318
  function handleImageNode$1(node2, params, isAnchor) {
68264
68319
  if (!node2)
68265
68320
  return null;
@@ -68731,6 +68786,122 @@ function extractTextFromTextBox(textBoxContent, bodyPr, params = {}) {
68731
68786
  wrap: wrap$1
68732
68787
  };
68733
68788
  }
68789
+ function extractFieldInlineNodes(node2) {
68790
+ if (node2?.name === "sd:autoPageNumber")
68791
+ return [{
68792
+ type: "page-number",
68793
+ attrs: {
68794
+ marksAsAttrs: [],
68795
+ instruction: "PAGE"
68796
+ }
68797
+ }];
68798
+ if (node2?.name === "sd:totalPageNumber")
68799
+ return [{
68800
+ type: "total-page-number",
68801
+ attrs: {
68802
+ marksAsAttrs: [],
68803
+ instruction: "NUMPAGES"
68804
+ }
68805
+ }];
68806
+ if (node2?.name === "sd:sectionPageCount") {
68807
+ const cachedText = node2?.attributes?.resolvedText ?? node2?.attributes?.importedCachedText ?? "";
68808
+ if (!cachedText)
68809
+ return [];
68810
+ return [{
68811
+ type: "text",
68812
+ text: cachedText
68813
+ }];
68814
+ }
68815
+ return [];
68816
+ }
68817
+ function extractInlineNodesFromRun(run$1, params) {
68818
+ if (!run$1?.elements)
68819
+ return [];
68820
+ const nodes = [];
68821
+ run$1.elements.forEach((el) => {
68822
+ if (el.name === "w:t" || el.name === "w:delText") {
68823
+ const textNode = el.elements?.find((n) => n.type === "text");
68824
+ if (!textNode || typeof textNode.text !== "string")
68825
+ return;
68826
+ const cleanedText = textNode.text.replace(/\[\[sdspace\]\]/g, " ");
68827
+ if (cleanedText.length > 0)
68828
+ nodes.push({
68829
+ type: "text",
68830
+ text: cleanedText
68831
+ });
68832
+ } else if (el.name === "w:tab")
68833
+ nodes.push({
68834
+ type: "text",
68835
+ text: "\t"
68836
+ });
68837
+ else if (el.name === "w:br")
68838
+ nodes.push({
68839
+ type: "lineBreak",
68840
+ attrs: {}
68841
+ });
68842
+ else if (el.name === "sd:autoPageNumber" || el.name === "sd:totalPageNumber" || el.name === "sd:sectionPageCount")
68843
+ nodes.push(...extractFieldInlineNodes(el));
68844
+ else if (el.name === "w:drawing") {
68845
+ const inline = el.elements?.find((child) => child?.name === "wp:inline");
68846
+ if (!inline)
68847
+ return;
68848
+ const imagePm = handleImageNode$1(inline, {
68849
+ ...params,
68850
+ nodes: [el]
68851
+ }, false);
68852
+ if (imagePm?.type === "image" && imagePm.attrs?.hidden !== true)
68853
+ nodes.push(imagePm);
68854
+ }
68855
+ });
68856
+ return nodes;
68857
+ }
68858
+ function paragraphToPmParagraph(paragraph2, params) {
68859
+ const paragraphNode = collectTextBoxParagraphs([paragraph2])[0];
68860
+ if (!paragraphNode)
68861
+ return null;
68862
+ const paragraphProperties = resolveParagraphPropertiesForTextBox(paragraphNode, params);
68863
+ const alignment = extractParagraphAlignment(paragraphNode) || "left";
68864
+ const content$2 = [];
68865
+ let pendingRunContent = [];
68866
+ const flushPendingRun = () => {
68867
+ if (pendingRunContent.length === 0)
68868
+ return;
68869
+ content$2.push({
68870
+ type: "run",
68871
+ attrs: {},
68872
+ content: pendingRunContent
68873
+ });
68874
+ pendingRunContent = [];
68875
+ };
68876
+ (paragraphNode.elements || []).forEach((element) => {
68877
+ if (element?.name === "w:r") {
68878
+ extractInlineNodesFromRun(element, params).forEach((part) => {
68879
+ if (part?.type === "image") {
68880
+ flushPendingRun();
68881
+ content$2.push(part);
68882
+ return;
68883
+ }
68884
+ pendingRunContent.push(part);
68885
+ });
68886
+ return;
68887
+ }
68888
+ if (element?.name?.startsWith("sd:")) {
68889
+ const runContent = extractFieldInlineNodes(element);
68890
+ if (runContent.length > 0)
68891
+ pendingRunContent.push(...runContent);
68892
+ }
68893
+ });
68894
+ flushPendingRun();
68895
+ return {
68896
+ type: "paragraph",
68897
+ attrs: {
68898
+ paragraphProperties,
68899
+ textAlign: alignment
68900
+ },
68901
+ content: content$2,
68902
+ marks: []
68903
+ };
68904
+ }
68734
68905
  function getVectorShape({ params, node: node2, graphicData, size, marginOffset, anchorData, wrap: wrap$1, isAnchor, customGeometry }) {
68735
68906
  const schemaAttrs = {};
68736
68907
  const drawingNode = params.nodes?.[0];
@@ -68766,14 +68937,45 @@ function getVectorShape({ params, node: node2, graphicData, size, marginOffset,
68766
68937
  const textBoxContent = wsp.elements?.find((el) => el.name === "wps:txbx")?.elements?.find((el) => el.name === "w:txbxContent");
68767
68938
  const bodyPr = wsp.elements?.find((el) => el.name === "wps:bodyPr");
68768
68939
  const nonVisualShapeProps = wsp.elements?.find((el) => el.name === "wps:cNvSpPr");
68940
+ const isWordArt = bodyPr?.attributes?.["fromWordArt"] === "1";
68941
+ const isTextBox = nonVisualShapeProps?.attributes?.["txBox"] === "1";
68942
+ if (isTextBox && textBoxContent)
68943
+ return importDrawingMLTextbox({
68944
+ params,
68945
+ drawingNode: drawingNode?.name === "w:drawing" ? drawingNode : null,
68946
+ textBoxContent,
68947
+ bodyPr,
68948
+ baseAttrs: {
68949
+ ...schemaAttrs,
68950
+ width,
68951
+ height,
68952
+ rotation,
68953
+ flipH,
68954
+ flipV,
68955
+ fillColor,
68956
+ strokeColor,
68957
+ strokeWidth,
68958
+ lineEnds,
68959
+ effectExtent,
68960
+ marginOffset,
68961
+ anchorData,
68962
+ wrap: wrap$1,
68963
+ isAnchor,
68964
+ isWordArt,
68965
+ isTextBox,
68966
+ originalAttributes: node2?.attributes
68967
+ },
68968
+ paragraphImporter: params?.nodeListHandler != null ? undefined : (paragraph2) => {
68969
+ const imported = paragraphToPmParagraph(paragraph2, params);
68970
+ return Array.isArray(imported) ? imported : imported ? [imported] : [];
68971
+ }
68972
+ });
68769
68973
  let textContent = null;
68770
68974
  let textAlign = "left";
68771
68975
  if (textBoxContent) {
68772
68976
  textContent = extractTextFromTextBox(textBoxContent, bodyPr, params);
68773
68977
  textAlign = textContent?.horizontalAlign || "left";
68774
68978
  }
68775
- const isWordArt = bodyPr?.attributes?.["fromWordArt"] === "1";
68776
- const isTextBox = nonVisualShapeProps?.attributes?.["txBox"] === "1";
68777
68979
  return {
68778
68980
  type: "vectorShape",
68779
68981
  attrs: {
@@ -84997,9 +85199,15 @@ function handleShapeTextboxImport({ params, pict }) {
84997
85199
  schemaAttrs.attributes = shapeAttrs;
84998
85200
  if (shapeAttrs.fillcolor)
84999
85201
  schemaAttrs.fillcolor = shapeAttrs.fillcolor;
85000
- const shapeStyle = buildStyles(parseInlineStyles(shapeAttrs.style));
85202
+ const parsedStyle = parseInlineStyles(shapeAttrs.style);
85203
+ const shapeStyle = buildStyles(parsedStyle);
85204
+ const positionData = extractPositionData(parsedStyle);
85001
85205
  if (shapeStyle)
85002
85206
  schemaAttrs.style = shapeStyle;
85207
+ if (positionData.anchorData)
85208
+ schemaAttrs.anchorData = positionData.anchorData;
85209
+ if (positionData.marginOffset)
85210
+ schemaAttrs.marginOffset = positionData.marginOffset;
85003
85211
  const textbox = shape.elements?.find((el) => el.name === "v:textbox");
85004
85212
  const wrap$1 = shape.elements?.find((el) => el.name === "w10:wrap");
85005
85213
  if (wrap$1?.attributes)
@@ -85029,6 +85237,38 @@ function buildStyles(styleObject) {
85029
85237
  style += `${prop}: ${value};`;
85030
85238
  return style;
85031
85239
  }
85240
+ function extractPositionData(styleObject) {
85241
+ const anchorData = {};
85242
+ const marginOffset = {};
85243
+ if (styleObject["mso-position-horizontal"])
85244
+ anchorData.alignH = styleObject["mso-position-horizontal"];
85245
+ if (styleObject["mso-position-horizontal-relative"])
85246
+ anchorData.hRelativeFrom = styleObject["mso-position-horizontal-relative"];
85247
+ if (styleObject["mso-position-vertical"])
85248
+ anchorData.alignV = styleObject["mso-position-vertical"];
85249
+ if (styleObject["mso-position-vertical-relative"])
85250
+ anchorData.vRelativeFrom = styleObject["mso-position-vertical-relative"];
85251
+ if (styleObject["margin-left"] != null)
85252
+ marginOffset.horizontal = convertToPixels$2(styleObject["margin-left"]);
85253
+ if (styleObject["margin-top"] != null)
85254
+ marginOffset.top = convertToPixels$2(styleObject["margin-top"]);
85255
+ return {
85256
+ ...Object.keys(anchorData).length > 0 ? { anchorData } : {},
85257
+ ...Object.keys(marginOffset).length > 0 ? { marginOffset } : {}
85258
+ };
85259
+ }
85260
+ function convertToPixels$2(value) {
85261
+ const num = parseFloat(value);
85262
+ if (Number.isNaN(num))
85263
+ return 0;
85264
+ if (value.endsWith("pt"))
85265
+ return num * 96 / 72;
85266
+ if (value.endsWith("in"))
85267
+ return num * 96;
85268
+ if (value.endsWith("px"))
85269
+ return num;
85270
+ return num;
85271
+ }
85032
85272
  function handleShapeImageWatermarkImport({ params, pict }) {
85033
85273
  const shape = pict.elements?.find((el) => el.name === "v:shape");
85034
85274
  if (!shape)
@@ -85549,15 +85789,69 @@ function pictNodeTypeStrategy(node2) {
85549
85789
  handler: null
85550
85790
  };
85551
85791
  }
85792
+ function translateDrawingMLTextbox(params) {
85793
+ const { node: node2 } = params;
85794
+ const drawingContent = node2?.attrs?.drawingContent;
85795
+ const shapeTextbox = node2?.content?.find((child) => child?.type === "shapeTextbox");
85796
+ if (!drawingContent || !shapeTextbox)
85797
+ return null;
85798
+ const drawing = carbonCopy(drawingContent);
85799
+ const liveParagraphs = translateChildNodes({
85800
+ ...params,
85801
+ node: shapeTextbox
85802
+ });
85803
+ const txbxContent = findTextboxContentNode(drawing);
85804
+ if (!txbxContent)
85805
+ return null;
85806
+ txbxContent.elements = liveParagraphs;
85807
+ return wrapTextInRun({
85808
+ name: "mc:AlternateContent",
85809
+ elements: [{
85810
+ name: "mc:Choice",
85811
+ attributes: { Requires: "wps" },
85812
+ elements: [drawing]
85813
+ }]
85814
+ });
85815
+ }
85816
+ function findTextboxContentNode(node2) {
85817
+ if (!node2 || typeof node2 !== "object")
85818
+ return null;
85819
+ if (node2.name === "w:txbxContent")
85820
+ return node2;
85821
+ if (!Array.isArray(node2.elements))
85822
+ return null;
85823
+ for (const child of node2.elements) {
85824
+ const found$1 = findTextboxContentNode(child);
85825
+ if (found$1)
85826
+ return found$1;
85827
+ }
85828
+ return null;
85829
+ }
85552
85830
  function translateShapeContainer(params) {
85553
85831
  const { node: node2 } = params;
85832
+ if (node2?.attrs?.drawingContent) {
85833
+ const run$1 = translateDrawingMLTextbox(params);
85834
+ if (run$1)
85835
+ return {
85836
+ name: "w:p",
85837
+ elements: [run$1]
85838
+ };
85839
+ return {
85840
+ name: "w:p",
85841
+ elements: [wrapTextInRun(node2.attrs.drawingContent)]
85842
+ };
85843
+ }
85554
85844
  const elements = translateChildNodes(params);
85845
+ const shapeAttributes = {
85846
+ ...node2.attrs.attributes,
85847
+ fillcolor: node2.attrs.fillcolor
85848
+ };
85849
+ const style = buildShapeStyle(node2.attrs);
85850
+ if (style)
85851
+ shapeAttributes.style = style;
85555
85852
  const shape = {
85556
85853
  name: "v:shape",
85557
- attributes: {
85558
- ...node2.attrs.attributes,
85559
- fillcolor: node2.attrs.fillcolor
85560
- },
85854
+ attributes: shapeAttributes,
85561
85855
  elements: [...elements, ...node2.attrs.wrapAttributes ? [{
85562
85856
  name: "w10:wrap",
85563
85857
  attributes: { ...node2.attrs.wrapAttributes }
@@ -85572,6 +85866,33 @@ function translateShapeContainer(params) {
85572
85866
  })]
85573
85867
  };
85574
85868
  }
85869
+ function buildShapeStyle(attrs) {
85870
+ const originalStyle = parseInlineStyles(attrs.attributes?.style);
85871
+ const managedStyle = parseInlineStyles(attrs.style);
85872
+ const style = {
85873
+ ...originalStyle,
85874
+ ...managedStyle
85875
+ };
85876
+ if (attrs.marginOffset?.horizontal !== undefined)
85877
+ style["margin-left"] = `${convertToPt$2(attrs.marginOffset.horizontal)}pt`;
85878
+ if (attrs.marginOffset?.top !== undefined)
85879
+ style["margin-top"] = `${convertToPt$2(attrs.marginOffset.top)}pt`;
85880
+ if (attrs.anchorData?.alignH)
85881
+ style["mso-position-horizontal"] = attrs.anchorData.alignH;
85882
+ if (attrs.anchorData?.hRelativeFrom)
85883
+ style["mso-position-horizontal-relative"] = attrs.anchorData.hRelativeFrom;
85884
+ if (attrs.anchorData?.alignV)
85885
+ style["mso-position-vertical"] = attrs.anchorData.alignV;
85886
+ if (attrs.anchorData?.vRelativeFrom)
85887
+ style["mso-position-vertical-relative"] = attrs.anchorData.vRelativeFrom;
85888
+ const entries = Object.entries(style);
85889
+ if (entries.length === 0)
85890
+ return;
85891
+ return entries.map(([prop, value]) => `${prop}:${value}`).join(";");
85892
+ }
85893
+ function convertToPt$2(pixels) {
85894
+ return pixels * 72 / 96;
85895
+ }
85575
85896
  function translateShapeTextbox(params) {
85576
85897
  const { node: node2 } = params;
85577
85898
  const textboxContent = {
@@ -87948,7 +88269,7 @@ function hydrateImageBlocks(blocks, mediaFiles) {
87948
88269
  }
87949
88270
  if (blk.kind === "drawing") {
87950
88271
  const drawingBlock = blk;
87951
- if (drawingBlock.drawingKind === "vectorShape") {
88272
+ if (drawingBlock.drawingKind === "vectorShape" || drawingBlock.drawingKind === "textboxShape") {
87952
88273
  const parts = drawingBlock.textContent?.parts;
87953
88274
  if (!parts || parts.length === 0)
87954
88275
  return blk;
@@ -90003,6 +90324,14 @@ function lineBreakNodeToRun({ node: node2, positions, sdtMetadata }) {
90003
90324
  lineBreakRun.sdt = sdtMetadata;
90004
90325
  return lineBreakRun;
90005
90326
  }
90327
+ function hydrateTextboxDrawingContent(node2, drawingBlock, context) {
90328
+ if (drawingBlock.drawingKind !== "textboxShape")
90329
+ return drawingBlock;
90330
+ return {
90331
+ ...drawingBlock,
90332
+ contentBlocks: toTextboxParagraphBlocks(node2, context)
90333
+ };
90334
+ }
90006
90335
  function vectorShapeNodeToDrawingBlock(node2, nextBlockId, positions) {
90007
90336
  const rawAttrs = getAttrs$2(node2);
90008
90337
  if (isHiddenDrawing$1(rawAttrs))
@@ -90047,25 +90376,43 @@ function shapeContainerNodeToDrawingBlock(node2, nextBlockId, positions) {
90047
90376
  const rawAttrs = getAttrs$2(node2);
90048
90377
  if (isHiddenDrawing$1(rawAttrs))
90049
90378
  return null;
90050
- return buildDrawingBlock(rawAttrs, nextBlockId, positions, node2, {
90379
+ const geometry = {
90051
90380
  width: coercePositiveNumber(rawAttrs.width, 1),
90052
90381
  height: coercePositiveNumber(rawAttrs.height, 1),
90053
90382
  rotation: coerceNumber(rawAttrs.rotation) ?? 0,
90054
90383
  flipH: coerceBoolean(rawAttrs.flipH) ?? false,
90055
90384
  flipV: coerceBoolean(rawAttrs.flipV) ?? false
90056
- }, "vectorShape");
90385
+ };
90386
+ const shapeTextboxNode = resolveNestedShapeTextboxNode(node2);
90387
+ const textboxAttrs = shapeTextboxNode ? getAttrs$2(shapeTextboxNode) : {};
90388
+ const textContent = shapeTextboxNode ? extractTextboxTextContent(shapeTextboxNode) : undefined;
90389
+ return buildDrawingBlock({
90390
+ ...rawAttrs,
90391
+ ...textContent ? { textContent } : {},
90392
+ ...rawAttrs.textAlign == null && textContent?.horizontalAlign ? { textAlign: textContent.horizontalAlign } : {},
90393
+ ...rawAttrs.textInsets == null ? { textInsets: resolveTextboxInsetsFromAttrs(textboxAttrs) } : {},
90394
+ ...rawAttrs.textVerticalAlign == null ? { textVerticalAlign: resolveTextboxVerticalAlignFromAttrs(textboxAttrs) } : {}
90395
+ }, nextBlockId, positions, node2, geometry, "textboxShape", { contentBlocks: [] });
90057
90396
  }
90058
90397
  function shapeTextboxNodeToDrawingBlock(node2, nextBlockId, positions) {
90059
90398
  const rawAttrs = getAttrs$2(node2);
90060
90399
  if (isHiddenDrawing$1(rawAttrs))
90061
90400
  return null;
90062
- return buildDrawingBlock(rawAttrs, nextBlockId, positions, node2, {
90401
+ const geometry = {
90063
90402
  width: coercePositiveNumber(rawAttrs.width, 1),
90064
90403
  height: coercePositiveNumber(rawAttrs.height, 1),
90065
90404
  rotation: coerceNumber(rawAttrs.rotation) ?? 0,
90066
90405
  flipH: coerceBoolean(rawAttrs.flipH) ?? false,
90067
90406
  flipV: coerceBoolean(rawAttrs.flipV) ?? false
90068
- }, "vectorShape");
90407
+ };
90408
+ const textContent = extractTextboxTextContent(node2);
90409
+ return buildDrawingBlock({
90410
+ ...rawAttrs,
90411
+ ...textContent ? { textContent } : {},
90412
+ ...rawAttrs.textAlign == null && textContent?.horizontalAlign ? { textAlign: textContent.horizontalAlign } : {},
90413
+ ...rawAttrs.textInsets == null ? { textInsets: resolveTextboxInsetsFromAttrs(rawAttrs) } : {},
90414
+ ...rawAttrs.textVerticalAlign == null ? { textVerticalAlign: resolveTextboxVerticalAlignFromAttrs(rawAttrs) } : {}
90415
+ }, nextBlockId, positions, node2, geometry, "textboxShape", { contentBlocks: [] });
90069
90416
  }
90070
90417
  function handleVectorShapeNode(node2, context) {
90071
90418
  const { blocks, recordBlockKind, nextBlockId, positions } = context;
@@ -90087,7 +90434,7 @@ function handleShapeContainerNode(node2, context) {
90087
90434
  const { blocks, recordBlockKind, nextBlockId, positions } = context;
90088
90435
  const drawingBlock = shapeContainerNodeToDrawingBlock(node2, nextBlockId, positions);
90089
90436
  if (drawingBlock) {
90090
- blocks.push(drawingBlock);
90437
+ blocks.push(hydrateTextboxDrawingContent(node2, drawingBlock, context));
90091
90438
  recordBlockKind?.(drawingBlock.kind);
90092
90439
  }
90093
90440
  }
@@ -90095,7 +90442,7 @@ function handleShapeTextboxNode(node2, context) {
90095
90442
  const { blocks, recordBlockKind, nextBlockId, positions } = context;
90096
90443
  const drawingBlock = shapeTextboxNodeToDrawingBlock(node2, nextBlockId, positions);
90097
90444
  if (drawingBlock) {
90098
- blocks.push(drawingBlock);
90445
+ blocks.push(hydrateTextboxDrawingContent(node2, drawingBlock, context));
90099
90446
  recordBlockKind?.(drawingBlock.kind);
90100
90447
  }
90101
90448
  }
@@ -90852,8 +91199,14 @@ function paragraphToFlowBlocks({ para, nextBlockId, positions, storyKey, tracked
90852
91199
  const converter = SHAPE_CONVERTERS_REGISTRY[node2.type];
90853
91200
  const drawingBlock = converter(node2, stableNextBlockId, positions);
90854
91201
  if (drawingBlock) {
90855
- attachInlineShapeGroupAlignment(drawingBlock);
90856
- blocks.push(attachAnchorParagraphId(drawingBlock, anchorParagraphId));
91202
+ const hydratedBlock = hydrateTextboxDrawingContent(node2, drawingBlock, {
91203
+ converterContext,
91204
+ converters: converters$1,
91205
+ nextBlockId: stableNextBlockId,
91206
+ positions
91207
+ });
91208
+ attachInlineShapeGroupAlignment(hydratedBlock);
91209
+ blocks.push(attachAnchorParagraphId(hydratedBlock, anchorParagraphId));
90857
91210
  }
90858
91211
  return;
90859
91212
  }
@@ -100011,7 +100364,7 @@ var isRegExp = (value) => {
100011
100364
  return attributes["w:rsidDel"];
100012
100365
  }, decode$52 = (attrs) => {
100013
100366
  return attrs.rsidDel;
100014
- }, attributes_default$4, STYLES_KEY = "word/styles.xml", XML_NODE_NAME$32 = "w:r", SD_KEY_NAME = "run", REFERENCE_RUN_STYLE_BY_XML_NAME, hasXmlNodeNamed = (node2, targetName) => {
100367
+ }, attributes_default$4, STYLES_KEY = "word/styles.xml", XML_NODE_NAME$32 = "w:r", SD_KEY_NAME = "run", REFERENCE_RUN_STYLE_BY_XML_NAME, BLOCK_HOIST_TYPES, hasXmlNodeNamed = (node2, targetName) => {
100015
100368
  if (!node2 || typeof node2 !== "object")
100016
100369
  return false;
100017
100370
  if (node2.name === targetName)
@@ -100144,6 +100497,11 @@ var isRegExp = (value) => {
100144
100497
  nodes: contentElements
100145
100498
  };
100146
100499
  const content$2 = nodeListHandler?.handler(childParams) || [];
100500
+ if (Array.isArray(content$2) && content$2.length > 0 && content$2.every((child) => BLOCK_HOIST_TYPES.has(child?.type)))
100501
+ return content$2.filter(Boolean).map((child) => ({
100502
+ ...child,
100503
+ marks: Array.isArray(child?.marks) ? child.marks : []
100504
+ }));
100147
100505
  const filtered = (Array.isArray(content$2) ? content$2 : []).map((child) => {
100148
100506
  if (!child || typeof child !== "object")
100149
100507
  return child;
@@ -105846,7 +106204,86 @@ var isRegExp = (value) => {
105846
106204
  i$1++;
105847
106205
  }
105848
106206
  return { processedNodes };
105849
- }, HEADER_FOOTER_FILENAME_PATTERN, CHART_TYPE_MAP, CHART_TYPE_NAMES, findChild$1 = (node2, name) => node2?.elements?.find((el) => el.name === name), findChildren$2 = (node2, name) => node2?.elements?.filter((el) => el.name === name) ?? [], getAttr = (node2, attr) => node2?.attributes?.[attr], DRAWING_XML_TAG = "w:drawing", SHAPE_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", GROUP_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", SD_IMAGE_ID_NAMESPACE = "7c9e6679-7425-40de-944b-e07fc1f90ae7", normalizeTargetPath$1 = (targetPath = "") => {
106207
+ }, HEADER_FOOTER_FILENAME_PATTERN, CHART_TYPE_MAP, CHART_TYPE_NAMES, findChild$1 = (node2, name) => node2?.elements?.find((el) => el.name === name), findChildren$2 = (node2, name) => node2?.elements?.filter((el) => el.name === name) ?? [], getAttr = (node2, attr) => node2?.attributes?.[attr], PARAGRAPH_PROPERTIES_XML_NAME = "w:pPr", hasMeaningfulParagraphContent = (elements = []) => elements.some((element) => element?.name && element.name !== PARAGRAPH_PROPERTIES_XML_NAME), findParagraphProperties = (elements = []) => elements.find((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME) ?? null, hasParagraphProperties = (elements = []) => elements.some((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME), cloneParagraphPropertiesForRenderedResult = (paragraphProperties) => {
106208
+ const elements = (paragraphProperties.elements || []).filter((element) => element?.name !== "w:sectPr").map((element) => carbonCopy(element));
106209
+ if (elements.length === 0)
106210
+ return null;
106211
+ return {
106212
+ ...carbonCopy(paragraphProperties),
106213
+ elements
106214
+ };
106215
+ }, inheritWrapperParagraphProperties = (blockFieldElement, paragraphProperties) => {
106216
+ if (!paragraphProperties)
106217
+ return blockFieldElement;
106218
+ const fieldElements = Array.isArray(blockFieldElement?.elements) ? blockFieldElement.elements : [];
106219
+ const firstParagraphIndex = fieldElements.findIndex((element) => element?.name === "w:p");
106220
+ if (firstParagraphIndex < 0)
106221
+ return blockFieldElement;
106222
+ const firstParagraph = fieldElements[firstParagraphIndex];
106223
+ const firstParagraphElements = Array.isArray(firstParagraph.elements) ? firstParagraph.elements : [];
106224
+ if (hasParagraphProperties(firstParagraphElements))
106225
+ return blockFieldElement;
106226
+ const renderedParagraphProperties = cloneParagraphPropertiesForRenderedResult(paragraphProperties);
106227
+ const inheritedFirstParagraph = {
106228
+ ...firstParagraph,
106229
+ elements: renderedParagraphProperties ? [renderedParagraphProperties, ...firstParagraphElements] : firstParagraphElements
106230
+ };
106231
+ return {
106232
+ ...blockFieldElement,
106233
+ attributes: {
106234
+ ...blockFieldElement.attributes || {},
106235
+ wrapperParagraphProperties: carbonCopy(paragraphProperties)
106236
+ },
106237
+ elements: fieldElements.map((element, index2) => index2 === firstParagraphIndex ? inheritedFirstParagraph : element)
106238
+ };
106239
+ }, hoistBlockFieldNodes = (params, paragraphNode) => {
106240
+ const paragraphElements = Array.isArray(paragraphNode?.elements) ? paragraphNode.elements : [];
106241
+ const blockFieldElements = paragraphElements.filter((element) => BLOCK_FIELD_XML_NAMES.has(element?.name));
106242
+ if (blockFieldElements.length === 0)
106243
+ return null;
106244
+ const nodes = [];
106245
+ const remainingElements = paragraphElements.filter((element) => !BLOCK_FIELD_XML_NAMES.has(element?.name));
106246
+ const wrapperParagraphProperties = findParagraphProperties(remainingElements);
106247
+ const shouldTransferWrapperProperties = !hasMeaningfulParagraphContent(remainingElements);
106248
+ if (hasMeaningfulParagraphContent(remainingElements)) {
106249
+ const paragraph2 = translator.encode({
106250
+ ...params,
106251
+ nodes: [{
106252
+ ...paragraphNode,
106253
+ elements: remainingElements
106254
+ }]
106255
+ });
106256
+ if (paragraph2)
106257
+ nodes.push(paragraph2);
106258
+ }
106259
+ blockFieldElements.forEach((blockFieldElement) => {
106260
+ const fieldElement = shouldTransferWrapperProperties ? inheritWrapperParagraphProperties(blockFieldElement, wrapperParagraphProperties) : blockFieldElement;
106261
+ nodes.push(...params.nodeListHandler.handler({
106262
+ ...params,
106263
+ nodes: [fieldElement],
106264
+ path: [...params.path || [], paragraphNode]
106265
+ }));
106266
+ });
106267
+ return nodes;
106268
+ }, handleParagraphNode$1 = (params) => {
106269
+ const { nodes } = params;
106270
+ if (nodes.length === 0 || nodes[0].name !== "w:p")
106271
+ return {
106272
+ nodes: [],
106273
+ consumed: 0
106274
+ };
106275
+ const hoistedNodes = hoistBlockFieldNodes(params, nodes[0]);
106276
+ if (hoistedNodes)
106277
+ return {
106278
+ nodes: hoistedNodes,
106279
+ consumed: 1
106280
+ };
106281
+ const schemaNode = translator.encode(params);
106282
+ return {
106283
+ nodes: Array.isArray(schemaNode) ? schemaNode : schemaNode ? [schemaNode] : [],
106284
+ consumed: 1
106285
+ };
106286
+ }, paragraphNodeHandlerEntity, DRAWING_XML_TAG = "w:drawing", SHAPE_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", GROUP_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", SD_IMAGE_ID_NAMESPACE = "7c9e6679-7425-40de-944b-e07fc1f90ae7", normalizeTargetPath$1 = (targetPath = "") => {
105850
106287
  if (!targetPath)
105851
106288
  return targetPath;
105852
106289
  const trimmed = targetPath.replace(/^\/+/, "");
@@ -105949,6 +106386,35 @@ var isRegExp = (value) => {
105949
106386
  if (result)
105950
106387
  return result;
105951
106388
  }
106389
+ if (wsp.elements?.find((el) => el.name === "wps:cNvSpPr")?.attributes?.["txBox"] === "1" && textBoxContent) {
106390
+ const bodyPr = wsp.elements?.find((el) => el.name === "wps:bodyPr");
106391
+ const drawingNode = params.nodes?.[0];
106392
+ const result = importDrawingMLTextbox({
106393
+ params,
106394
+ drawingNode: drawingNode?.name === "w:drawing" ? drawingNode : null,
106395
+ textBoxContent,
106396
+ bodyPr,
106397
+ baseAttrs: {
106398
+ width: size?.width,
106399
+ height: size?.height,
106400
+ marginOffset,
106401
+ anchorData,
106402
+ wrap: wrap$1,
106403
+ isAnchor,
106404
+ isTextBox: true,
106405
+ originalAttributes: node2?.attributes,
106406
+ ...params.nodes?.[0]?.name === "w:drawing" ? { drawingContent: params.nodes[0] } : {}
106407
+ },
106408
+ paragraphImporter: params?.nodeListHandler != null ? undefined : (paragraph2) => {
106409
+ const imported = paragraphToPmParagraph(paragraph2, params);
106410
+ return Array.isArray(imported) ? imported : imported ? [imported] : [];
106411
+ }
106412
+ });
106413
+ if (result?.attrs && isHidden)
106414
+ result.attrs.hidden = true;
106415
+ if (result)
106416
+ return result;
106417
+ }
105952
106418
  const placeholder = buildShapePlaceholder(node2, size, padding, marginOffset, textBoxContent ? "textbox" : "drawing");
105953
106419
  if (placeholder?.attrs && isHidden)
105954
106420
  placeholder.attrs.hidden = true;
@@ -111942,86 +112408,7 @@ var isRegExp = (value) => {
111942
112408
  nodes: [resultNode],
111943
112409
  consumed: 1
111944
112410
  };
111945
- }, textNodeHandlerEntity, 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) => {
111946
- const elements = (paragraphProperties.elements || []).filter((element) => element?.name !== "w:sectPr").map((element) => carbonCopy(element));
111947
- if (elements.length === 0)
111948
- return null;
111949
- return {
111950
- ...carbonCopy(paragraphProperties),
111951
- elements
111952
- };
111953
- }, inheritWrapperParagraphProperties = (blockFieldElement, paragraphProperties) => {
111954
- if (!paragraphProperties)
111955
- return blockFieldElement;
111956
- const fieldElements = Array.isArray(blockFieldElement?.elements) ? blockFieldElement.elements : [];
111957
- const firstParagraphIndex = fieldElements.findIndex((element) => element?.name === "w:p");
111958
- if (firstParagraphIndex < 0)
111959
- return blockFieldElement;
111960
- const firstParagraph = fieldElements[firstParagraphIndex];
111961
- const firstParagraphElements = Array.isArray(firstParagraph.elements) ? firstParagraph.elements : [];
111962
- if (hasParagraphProperties(firstParagraphElements))
111963
- return blockFieldElement;
111964
- const renderedParagraphProperties = cloneParagraphPropertiesForRenderedResult(paragraphProperties);
111965
- const inheritedFirstParagraph = {
111966
- ...firstParagraph,
111967
- elements: renderedParagraphProperties ? [renderedParagraphProperties, ...firstParagraphElements] : firstParagraphElements
111968
- };
111969
- return {
111970
- ...blockFieldElement,
111971
- attributes: {
111972
- ...blockFieldElement.attributes || {},
111973
- wrapperParagraphProperties: carbonCopy(paragraphProperties)
111974
- },
111975
- elements: fieldElements.map((element, index2) => index2 === firstParagraphIndex ? inheritedFirstParagraph : element)
111976
- };
111977
- }, hoistBlockFieldNodes = (params, paragraphNode) => {
111978
- const paragraphElements = Array.isArray(paragraphNode?.elements) ? paragraphNode.elements : [];
111979
- const blockFieldElements = paragraphElements.filter((element) => BLOCK_FIELD_XML_NAMES.has(element?.name));
111980
- if (blockFieldElements.length === 0)
111981
- return null;
111982
- const nodes = [];
111983
- const remainingElements = paragraphElements.filter((element) => !BLOCK_FIELD_XML_NAMES.has(element?.name));
111984
- const wrapperParagraphProperties = findParagraphProperties(remainingElements);
111985
- const shouldTransferWrapperProperties = !hasMeaningfulParagraphContent(remainingElements);
111986
- if (hasMeaningfulParagraphContent(remainingElements)) {
111987
- const paragraph2 = translator.encode({
111988
- ...params,
111989
- nodes: [{
111990
- ...paragraphNode,
111991
- elements: remainingElements
111992
- }]
111993
- });
111994
- if (paragraph2)
111995
- nodes.push(paragraph2);
111996
- }
111997
- blockFieldElements.forEach((blockFieldElement) => {
111998
- const fieldElement = shouldTransferWrapperProperties ? inheritWrapperParagraphProperties(blockFieldElement, wrapperParagraphProperties) : blockFieldElement;
111999
- nodes.push(...params.nodeListHandler.handler({
112000
- ...params,
112001
- nodes: [fieldElement],
112002
- path: [...params.path || [], paragraphNode]
112003
- }));
112004
- });
112005
- return nodes;
112006
- }, handleParagraphNode$1 = (params) => {
112007
- const { nodes } = params;
112008
- if (nodes.length === 0 || nodes[0].name !== "w:p")
112009
- return {
112010
- nodes: [],
112011
- consumed: 0
112012
- };
112013
- const hoistedNodes = hoistBlockFieldNodes(params, nodes[0]);
112014
- if (hoistedNodes)
112015
- return {
112016
- nodes: hoistedNodes,
112017
- consumed: 1
112018
- };
112019
- const schemaNode = translator.encode(params);
112020
- return {
112021
- nodes: Array.isArray(schemaNode) ? schemaNode : schemaNode ? [schemaNode] : [],
112022
- consumed: 1
112023
- };
112024
- }, paragraphNodeHandlerEntity, handleSdtNode = (params) => {
112411
+ }, textNodeHandlerEntity, handleSdtNode = (params) => {
112025
112412
  const { nodes } = params;
112026
112413
  if (nodes.length === 0 || nodes[0].name !== "w:sdt")
112027
112414
  return {
@@ -116889,7 +117276,186 @@ var isRegExp = (value) => {
116889
117276
  if (toBoolean(attrs.hidden) === true)
116890
117277
  return true;
116891
117278
  return typeof attrs.visibility === "string" && attrs.visibility.toLowerCase() === "hidden";
116892
- }, normalizeWrapType$1 = (value) => {
117279
+ }, TEXTBOX_CONTAINER_TYPES, resolveTextFormattingFromMarks = (marks) => {
117280
+ if (!Array.isArray(marks) || marks.length === 0)
117281
+ return;
117282
+ const formatting = {};
117283
+ marks.forEach((mark) => {
117284
+ if (!mark || typeof mark.type !== "string")
117285
+ return;
117286
+ const attrs = isPlainObject4(mark.attrs) ? mark.attrs : {};
117287
+ if (mark.type === "bold")
117288
+ formatting.bold = true;
117289
+ if (mark.type === "italic")
117290
+ formatting.italic = true;
117291
+ const color2 = typeof attrs.color === "string" ? attrs.color.replace(/^#/, "") : undefined;
117292
+ if (color2)
117293
+ formatting.color = color2;
117294
+ const fontFamily = typeof attrs.fontFamily === "string" ? attrs.fontFamily : undefined;
117295
+ if (fontFamily)
117296
+ formatting.fontFamily = fontFamily;
117297
+ const fontSize = pickNumber(attrs.fontSize);
117298
+ if (fontSize != null)
117299
+ formatting.fontSize = fontSize;
117300
+ });
117301
+ return Object.keys(formatting).length > 0 ? formatting : undefined;
117302
+ }, pushTextPart = (parts, part) => {
117303
+ if (!part.text && !part.fieldType && !part.isLineBreak)
117304
+ return;
117305
+ parts.push(part);
117306
+ }, extractTextPartsFromTextboxInline = (node2, parts) => {
117307
+ if (!node2)
117308
+ return;
117309
+ const formatting = resolveTextFormattingFromMarks(node2.marks);
117310
+ if (typeof node2.text === "string") {
117311
+ pushTextPart(parts, {
117312
+ text: node2.text,
117313
+ ...formatting ? { formatting } : {}
117314
+ });
117315
+ return;
117316
+ }
117317
+ switch (node2.type) {
117318
+ case "text":
117319
+ pushTextPart(parts, {
117320
+ text: "",
117321
+ ...formatting ? { formatting } : {}
117322
+ });
117323
+ return;
117324
+ case "tab":
117325
+ pushTextPart(parts, {
117326
+ text: "\t",
117327
+ ...formatting ? { formatting } : {}
117328
+ });
117329
+ return;
117330
+ case "lineBreak":
117331
+ pushTextPart(parts, {
117332
+ text: `
117333
+ `,
117334
+ isLineBreak: true,
117335
+ ...formatting ? { formatting } : {}
117336
+ });
117337
+ return;
117338
+ case "page-number":
117339
+ pushTextPart(parts, {
117340
+ text: "",
117341
+ fieldType: "PAGE",
117342
+ pageNumberFormat: typeof node2.attrs?.pageNumberFormat === "string" ? node2.attrs.pageNumberFormat : undefined,
117343
+ ...formatting ? { formatting } : {}
117344
+ });
117345
+ return;
117346
+ case "total-page-number":
117347
+ pushTextPart(parts, {
117348
+ text: typeof node2.attrs?.resolvedText === "string" ? node2.attrs.resolvedText : typeof node2.attrs?.importedCachedText === "string" ? node2.attrs.importedCachedText : "",
117349
+ fieldType: "NUMPAGES",
117350
+ pageNumberFormat: typeof node2.attrs?.pageNumberFormat === "string" ? node2.attrs.pageNumberFormat : undefined,
117351
+ ...formatting ? { formatting } : {}
117352
+ });
117353
+ return;
117354
+ default:
117355
+ break;
117356
+ }
117357
+ if (Array.isArray(node2.content) && (TEXTBOX_CONTAINER_TYPES.has(node2.type) || node2.content.length > 0))
117358
+ node2.content.forEach((child) => extractTextPartsFromTextboxInline(child, parts));
117359
+ }, extractTextboxTextContent = (node2) => {
117360
+ if (!Array.isArray(node2.content) || node2.content.length === 0)
117361
+ return;
117362
+ const parts = [];
117363
+ let horizontalAlign;
117364
+ const paragraphs = node2.content.filter((child) => child?.type === "paragraph");
117365
+ const paragraphHasRenderableContent = (paragraph2) => Array.isArray(paragraph2.content) && paragraph2.content.length > 0;
117366
+ paragraphs.forEach((paragraph2, paragraphIndex) => {
117367
+ const justification = paragraph2.attrs?.paragraphProperties;
117368
+ if (!horizontalAlign && isPlainObject4(justification)) {
117369
+ const value = justification.justification;
117370
+ if (value === "left" || value === "center" || value === "right")
117371
+ horizontalAlign = value;
117372
+ }
117373
+ paragraph2.content?.forEach((child) => extractTextPartsFromTextboxInline(child, parts));
117374
+ if (paragraphIndex < paragraphs.length - 1) {
117375
+ const nextParagraph = paragraphs[paragraphIndex + 1];
117376
+ parts.push({
117377
+ text: `
117378
+ `,
117379
+ isLineBreak: true,
117380
+ isEmptyParagraph: !paragraphHasRenderableContent(paragraph2) || !paragraphHasRenderableContent(nextParagraph)
117381
+ });
117382
+ }
117383
+ });
117384
+ return parts.length > 0 ? {
117385
+ parts,
117386
+ ...horizontalAlign ? { horizontalAlign } : {}
117387
+ } : undefined;
117388
+ }, isParagraphNode = (node2) => node2?.type === "paragraph", toTextboxParagraphBlocks = (node2, context) => {
117389
+ const shapeTextboxNode = node2.type === "shapeTextbox" ? node2 : resolveNestedShapeTextboxNode(node2);
117390
+ const paragraphToFlowBlocks$1 = context.converters?.paragraphToFlowBlocks;
117391
+ if (!shapeTextboxNode || !paragraphToFlowBlocks$1 || !Array.isArray(shapeTextboxNode.content))
117392
+ return [];
117393
+ const textboxBlocks = [];
117394
+ for (const child of shapeTextboxNode.content) {
117395
+ if (!isParagraphNode(child))
117396
+ continue;
117397
+ const convertedBlocks = paragraphToFlowBlocks$1({
117398
+ para: child,
117399
+ nextBlockId: context.nextBlockId,
117400
+ positions: context.positions,
117401
+ storyKey: context.storyKey,
117402
+ trackedChangesConfig: context.trackedChangesConfig,
117403
+ bookmarks: context.bookmarks,
117404
+ hyperlinkConfig: context.hyperlinkConfig,
117405
+ themeColors: context.themeColors,
117406
+ converters: context.converters,
117407
+ converterContext: context.converterContext,
117408
+ enableComments: context.enableComments,
117409
+ previousParagraphFont: getLastParagraphFont(textboxBlocks)
117410
+ });
117411
+ textboxBlocks.push(...convertedBlocks);
117412
+ }
117413
+ return textboxBlocks.filter((block) => block.kind === "paragraph");
117414
+ }, parseTextboxInsetValue = (value) => {
117415
+ const trimmed = value.trim();
117416
+ if (!trimmed)
117417
+ return;
117418
+ if (trimmed.endsWith("pt"))
117419
+ return ptToPx(parseFloat(trimmed.slice(0, -2)));
117420
+ if (trimmed.endsWith("px"))
117421
+ return pickNumber(trimmed.slice(0, -2));
117422
+ if (trimmed.endsWith("in")) {
117423
+ const inches = parseFloat(trimmed.slice(0, -2));
117424
+ return Number.isFinite(inches) ? inches * 96 : undefined;
117425
+ }
117426
+ return pickNumber(trimmed);
117427
+ }, resolveTextboxInsetsFromAttrs = (attrs) => {
117428
+ const explicitInsets = normalizeTextInsets(attrs.textInsets);
117429
+ if (explicitInsets)
117430
+ return explicitInsets;
117431
+ const textboxAttrs = isPlainObject4(attrs.attributes) ? attrs.attributes : undefined;
117432
+ const inset = typeof textboxAttrs?.inset === "string" ? textboxAttrs.inset : undefined;
117433
+ if (!inset)
117434
+ return;
117435
+ const values = inset.split(",").map((entry) => parseTextboxInsetValue(entry));
117436
+ if (values.length !== 4 || values.some((entry) => entry == null))
117437
+ return;
117438
+ return {
117439
+ top: values[1],
117440
+ right: values[2],
117441
+ bottom: values[3],
117442
+ left: values[0]
117443
+ };
117444
+ }, resolveTextboxVerticalAlignFromAttrs = (attrs) => {
117445
+ const explicitAlign = normalizeTextVerticalAlign(attrs.textVerticalAlign);
117446
+ if (explicitAlign)
117447
+ return explicitAlign;
117448
+ const textboxAttrs = isPlainObject4(attrs.attributes) ? attrs.attributes : undefined;
117449
+ const style = typeof textboxAttrs?.style === "string" ? textboxAttrs.style : undefined;
117450
+ if (!style)
117451
+ return;
117452
+ const match = style.match(/v-text-anchor\s*:\s*(top|middle|bottom)/i);
117453
+ if (!match)
117454
+ return;
117455
+ if (match[1].toLowerCase() === "middle")
117456
+ return "center";
117457
+ return match[1].toLowerCase();
117458
+ }, resolveNestedShapeTextboxNode = (node2) => Array.isArray(node2.content) ? node2.content.find((child) => child?.type === "shapeTextbox") : undefined, normalizeWrapType$1 = (value) => {
116893
117459
  if (typeof value !== "string")
116894
117460
  return;
116895
117461
  return WRAP_TYPES$2.has(value) ? value : undefined;
@@ -117606,13 +118172,13 @@ var isRegExp = (value) => {
117606
118172
  if (childNode.type === "shapeContainer" && context.converters?.shapeContainerNodeToDrawingBlock) {
117607
118173
  const drawingBlock = context.converters.shapeContainerNodeToDrawingBlock(childNode, context.nextBlockId, context.positions);
117608
118174
  if (drawingBlock && drawingBlock.kind === "drawing")
117609
- blocks.push(drawingBlock);
118175
+ blocks.push(hydrateTextboxDrawingContent(childNode, drawingBlock, context));
117610
118176
  continue;
117611
118177
  }
117612
118178
  if (childNode.type === "shapeTextbox" && context.converters?.shapeTextboxNodeToDrawingBlock) {
117613
118179
  const drawingBlock = context.converters.shapeTextboxNodeToDrawingBlock(childNode, context.nextBlockId, context.positions);
117614
118180
  if (drawingBlock && drawingBlock.kind === "drawing")
117615
- blocks.push(drawingBlock);
118181
+ blocks.push(hydrateTextboxDrawingContent(childNode, drawingBlock, context));
117616
118182
  continue;
117617
118183
  }
117618
118184
  }
@@ -118172,7 +118738,7 @@ var isRegExp = (value) => {
118172
118738
  state.kern = kernNode.attributes["w:val"];
118173
118739
  }
118174
118740
  }, SuperConverter;
118175
- var init_SuperConverter_DBlOjc68_es = __esm(() => {
118741
+ var init_SuperConverter_kDrJISzz_es = __esm(() => {
118176
118742
  init_rolldown_runtime_Bg48TavK_es();
118177
118743
  init_jszip_C49i9kUs_es();
118178
118744
  init_xml_js_CqGKpaft_es();
@@ -134933,6 +135499,7 @@ var init_SuperConverter_DBlOjc68_es = __esm(() => {
134933
135499
  "w:footnoteReference": "FootnoteReference",
134934
135500
  "w:endnoteReference": "EndnoteReference"
134935
135501
  };
135502
+ BLOCK_HOIST_TYPES = new Set(["shapeContainer"]);
134936
135503
  COMPLEX_SCRIPT_CODEPOINT_RANGES = [
134937
135504
  [1424, 2303],
134938
135505
  [2304, 4255],
@@ -147018,6 +147585,10 @@ var init_SuperConverter_DBlOjc68_es = __esm(() => {
147018
147585
  "c:surface3DChart": "surfaceChart"
147019
147586
  };
147020
147587
  CHART_TYPE_NAMES = new Set(Object.keys(CHART_TYPE_MAP));
147588
+ paragraphNodeHandlerEntity = {
147589
+ handlerName: "paragraphNodeHandler",
147590
+ handler: handleParagraphNode$1
147591
+ };
147021
147592
  atomElements = /^(img|br|input|textarea|hr)$/i;
147022
147593
  nav = typeof navigator != "undefined" ? navigator : null;
147023
147594
  doc2 = typeof document != "undefined" ? document : null;
@@ -154754,10 +155325,6 @@ var init_SuperConverter_DBlOjc68_es = __esm(() => {
154754
155325
  handlerName: "textNodeHandler",
154755
155326
  handler: handleTextNode
154756
155327
  };
154757
- paragraphNodeHandlerEntity = {
154758
- handlerName: "paragraphNodeHandler",
154759
- handler: handleParagraphNode$1
154760
- };
154761
155328
  sdtNodeHandlerEntity = {
154762
155329
  handlerName: "sdtNodeHandler",
154763
155330
  handler: handleSdtNode
@@ -156538,7 +157105,8 @@ var init_SuperConverter_DBlOjc68_es = __esm(() => {
156538
157105
  weight: "bold",
156539
157106
  style: "normal",
156540
157107
  file: "PTSansNarrow-Bold.woff2"
156541
- }])
157108
+ }]),
157109
+ family("TeX Gyre Bonum", "TeXGyreBonum", "LicenseRef-GUST-Font-License-1.0")
156542
157110
  ]);
156543
157111
  SUBSTITUTION_EVIDENCE = SUBSTITUTION_EVIDENCE$1;
156544
157112
  bundledFamilies = new Set(BUNDLED_MANIFEST.map((f2) => f2.family));
@@ -156558,6 +157126,7 @@ var init_SuperConverter_DBlOjc68_es = __esm(() => {
156558
157126
  "Arial Black",
156559
157127
  "Arial Narrow",
156560
157128
  "Baskerville Old Face",
157129
+ "Bookman Old Style",
156561
157130
  "Brush Script MT",
156562
157131
  "Century",
156563
157132
  "Cooper Black",
@@ -156854,6 +157423,14 @@ var init_SuperConverter_DBlOjc68_es = __esm(() => {
156854
157423
  "center",
156855
157424
  "bottom"
156856
157425
  ]);
157426
+ TEXTBOX_CONTAINER_TYPES = new Set([
157427
+ "run",
157428
+ "link",
157429
+ "hyperlink",
157430
+ "structuredContent",
157431
+ "fieldAnnotation",
157432
+ "smartTag"
157433
+ ]);
156857
157434
  WRAP_TYPES$1 = new Set([
156858
157435
  "None",
156859
157436
  "Square",
@@ -158356,7 +158933,7 @@ var init_SuperConverter_DBlOjc68_es = __esm(() => {
158356
158933
  };
158357
158934
  });
158358
158935
 
158359
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DWyoHv_L.es.js
158936
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-D1v6sX42.es.js
158360
158937
  function parseSizeUnit(val = "0") {
158361
158938
  const length = val.toString() || "0";
158362
158939
  const value = Number.parseFloat(length);
@@ -168751,8 +169328,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
168751
169328
  }
168752
169329
  };
168753
169330
  };
168754
- var init_create_headless_toolbar_DWyoHv_L_es = __esm(() => {
168755
- init_SuperConverter_DBlOjc68_es();
169331
+ var init_create_headless_toolbar_D1v6sX42_es = __esm(() => {
169332
+ init_SuperConverter_kDrJISzz_es();
168756
169333
  init_uuid_B2wVPhPi_es();
168757
169334
  init_constants_D9qj59G2_es();
168758
169335
  init_dist_B8HfvhaK_es();
@@ -223442,7 +224019,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
223442
224019
  init_remark_gfm_BhnWr3yf_es();
223443
224020
  });
223444
224021
 
223445
- // ../../packages/superdoc/dist/chunks/src-BnMjPHBh.es.js
224022
+ // ../../packages/superdoc/dist/chunks/src-C8MNSOR0.es.js
223446
224023
  function deleteProps(obj, propOrProps) {
223447
224024
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
223448
224025
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -264424,7 +265001,7 @@ function hasPageContextTokenInBlock(block) {
264424
265001
  return true;
264425
265002
  } else if (block.kind === "drawing") {
264426
265003
  const drawing = block;
264427
- if (drawing.drawingKind === "vectorShape")
265004
+ if (drawing.drawingKind === "vectorShape" || drawing.drawingKind === "textboxShape")
264428
265005
  return hasPageContextTokenInShapeText(drawing.textContent);
264429
265006
  if (drawing.drawingKind === "shapeGroup")
264430
265007
  return hasPageContextTokenInShapeGroup(drawing.shapes);
@@ -266081,6 +266658,18 @@ function computeParagraphLayoutStartY(input2) {
266081
266658
  const effectiveSpacingBefore = input2.suppressSpacingBefore ? 0 : input2.spacingBefore;
266082
266659
  return computeParagraphContentStartY(y$1, effectiveSpacingBefore, effectiveSpacingBefore === 0, trailingForCollapse);
266083
266660
  }
266661
+ function layoutTextboxContent(block, remeasureParagraph$1) {
266662
+ if (!Array.isArray(block.contentBlocks) || block.contentBlocks.length === 0)
266663
+ return [];
266664
+ const insets = block.textInsets ?? {
266665
+ top: 0,
266666
+ right: 0,
266667
+ bottom: 0,
266668
+ left: 0
266669
+ };
266670
+ const contentWidth = Math.max(1, block.geometry.width - insets.left - insets.right);
266671
+ return block.contentBlocks.map((paragraphBlock) => remeasureParagraph$1(paragraphBlock, contentWidth));
266672
+ }
266084
266673
  function describeCellRenderBlocks(cellMeasure, cellBlock, cellPadding) {
266085
266674
  const measuredBlocks = cellMeasure.blocks;
266086
266675
  const blockDataArray = cellBlock?.blocks;
@@ -267545,6 +268134,7 @@ function layoutParagraphBlock(ctx$1, anchors) {
267545
268134
  fragment.pmEnd = pmRange.pmEnd;
267546
268135
  state.page.fragments.push(fragment);
267547
268136
  } else if (entry.block.kind === "drawing" && entry.measure.kind === "drawing") {
268137
+ const contentMeasures = entry.block.drawingKind === "textboxShape" && typeof remeasureParagraph$1 === "function" ? layoutTextboxContent(entry.block, remeasureParagraph$1) : undefined;
267548
268138
  const fragment = {
267549
268139
  kind: "drawing",
267550
268140
  blockId: entry.block.id,
@@ -267561,6 +268151,8 @@ function layoutParagraphBlock(ctx$1, anchors) {
267561
268151
  drawingContentId: entry.block.drawingContentId,
267562
268152
  sourceAnchor: entry.block.sourceAnchor
267563
268153
  };
268154
+ if (contentMeasures)
268155
+ fragment.contentMeasures = contentMeasures;
267564
268156
  if (pmRange.pmStart != null)
267565
268157
  fragment.pmStart = pmRange.pmStart;
267566
268158
  if (pmRange.pmEnd != null)
@@ -267969,7 +268561,7 @@ function layoutImageBlock({ block, measure, columns, ensurePage, advanceColumn,
267969
268561
  state.cursorY += requiredHeight;
267970
268562
  state.maxCursorY = Math.max(state.maxCursorY, state.cursorY);
267971
268563
  }
267972
- function layoutDrawingBlock({ block, measure, columns, ensurePage, advanceColumn, columnX }) {
268564
+ function layoutDrawingBlock({ block, measure, columns, ensurePage, advanceColumn, columnX, textboxContentMeasures }) {
267973
268565
  if (block.anchor?.isAnchored)
267974
268566
  return;
267975
268567
  const marginTop = Math.max(0, block.margin?.top ?? 0);
@@ -268026,6 +268618,8 @@ function layoutDrawingBlock({ block, measure, columns, ensurePage, advanceColumn
268026
268618
  pmEnd: pmRange.pmEnd,
268027
268619
  sourceAnchor: block.sourceAnchor
268028
268620
  };
268621
+ if (textboxContentMeasures)
268622
+ fragment.contentMeasures = textboxContentMeasures;
268029
268623
  state.page.fragments.push(fragment);
268030
268624
  state.cursorY += requiredHeight;
268031
268625
  state.maxCursorY = Math.max(state.maxCursorY, state.cursorY);
@@ -270459,6 +271053,7 @@ function layoutDocument(blocks2, measures, options = {}) {
270459
271053
  const state = paginator.ensurePage();
270460
271054
  const drawBlock = block;
270461
271055
  const drawMeasure = measure;
271056
+ const contentMeasures = drawBlock.drawingKind === "textboxShape" && typeof options.remeasureParagraph === "function" ? layoutTextboxContent(drawBlock, options.remeasureParagraph) : undefined;
270462
271057
  const fragment = {
270463
271058
  kind: "drawing",
270464
271059
  blockId: drawBlock.id,
@@ -270475,6 +271070,8 @@ function layoutDocument(blocks2, measures, options = {}) {
270475
271070
  drawingContentId: drawBlock.drawingContentId,
270476
271071
  sourceAnchor: drawBlock.sourceAnchor
270477
271072
  };
271073
+ if (contentMeasures)
271074
+ fragment.contentMeasures = contentMeasures;
270478
271075
  const attrs = drawBlock.attrs;
270479
271076
  if (attrs?.pmStart != null)
270480
271077
  fragment.pmStart = attrs.pmStart;
@@ -270490,7 +271087,8 @@ function layoutDocument(blocks2, measures, options = {}) {
270490
271087
  columns: getCurrentColumns(),
270491
271088
  ensurePage: paginator.ensurePage,
270492
271089
  advanceColumn: paginator.advanceColumn,
270493
- columnX
271090
+ columnX,
271091
+ textboxContentMeasures: block.drawingKind === "textboxShape" && typeof options.remeasureParagraph === "function" ? layoutTextboxContent(block, options.remeasureParagraph) : undefined
270494
271092
  });
270495
271093
  continue;
270496
271094
  }
@@ -270766,7 +271364,7 @@ function shouldExcludeFromMeasurement(fragment, block, fragmentBottom, canvasHei
270766
271364
  return true;
270767
271365
  return false;
270768
271366
  }
270769
- function layoutHeaderFooter(blocks2, measures, constraints, kind) {
271367
+ function layoutHeaderFooter(blocks2, measures, constraints, kind, remeasureParagraph$1) {
270770
271368
  if (blocks2.length !== measures.length)
270771
271369
  throw new Error(`layoutHeaderFooter expected measures for every block (blocks=${blocks2.length}, measures=${measures.length})`);
270772
271370
  const width = Number(constraints?.width);
@@ -270790,7 +271388,8 @@ function layoutHeaderFooter(blocks2, measures, constraints, kind) {
270790
271388
  left: 0
270791
271389
  },
270792
271390
  allowParagraphlessAnchoredTableFallback: false,
270793
- allowSectionBreakOnlyPageFallback: false
271391
+ allowSectionBreakOnlyPageFallback: false,
271392
+ remeasureParagraph: remeasureParagraph$1
270794
271393
  });
270795
271394
  if (kind === "footer" && constraints.pageHeight != null)
270796
271395
  normalizeFragmentsForRegion(layout.pages, blocks2, measures, kind, constraints);
@@ -271569,7 +272168,7 @@ function hasPageNumberTokensRequiringPerPageLayout(blocks2) {
271569
272168
  }
271570
272169
  return false;
271571
272170
  }
271572
- async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1, cache$2 = sharedHeaderFooterCache, totalPages, pageResolver, kind, fontSignature = "") {
272171
+ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1, cache$2 = sharedHeaderFooterCache, totalPages, pageResolver, kind, fontSignature = "", remeasureParagraph$1) {
271573
272172
  const result = {};
271574
272173
  if (!pageResolver) {
271575
272174
  const numPages = totalPages ?? 1;
@@ -271582,7 +272181,7 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
271582
272181
  result[type] = {
271583
272182
  blocks: clonedBlocks,
271584
272183
  measures,
271585
- layout: layoutHeaderFooter(clonedBlocks, measures, constraints, kind)
272184
+ layout: layoutHeaderFooter(clonedBlocks, measures, constraints, kind, remeasureParagraph$1)
271586
272185
  };
271587
272186
  }
271588
272187
  return result;
@@ -271599,7 +272198,7 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
271599
272198
  result[type] = {
271600
272199
  blocks: blocks2,
271601
272200
  measures,
271602
- layout: layoutHeaderFooter(blocks2, measures, constraints, kind)
272201
+ layout: layoutHeaderFooter(blocks2, measures, constraints, kind, remeasureParagraph$1)
271603
272202
  };
271604
272203
  continue;
271605
272204
  }
@@ -271621,7 +272220,7 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
271621
272220
  const { displayText, displayNumber, totalPages: totalPagesForPage, sectionPageCount, pageFormat, chapterNumberText, chapterSeparator } = pageResolver(pageNum);
271622
272221
  resolveHeaderFooterTokens(clonedBlocks, pageNum, totalPagesForPage, displayText, displayNumber, sectionPageCount, pageFormat, chapterNumberText, chapterSeparator);
271623
272222
  const measures = await cache$2.measureBlocks(clonedBlocks, constraints, measureBlock$1, fontSignature);
271624
- const pageLayout = layoutHeaderFooter(clonedBlocks, measures, constraints, kind);
272223
+ const pageLayout = layoutHeaderFooter(clonedBlocks, measures, constraints, kind, remeasureParagraph$1);
271625
272224
  const measuresById = /* @__PURE__ */ new Map;
271626
272225
  for (let i4 = 0;i4 < clonedBlocks.length; i4 += 1)
271627
272226
  measuresById.set(clonedBlocks[i4].id, measures[i4]);
@@ -272484,7 +273083,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
272484
273083
  const blocks2 = blocksByRId.get(group.rId);
272485
273084
  if (!blocks2 || blocks2.length === 0)
272486
273085
  continue;
272487
- const layout$1 = (await layoutHeaderFooterWithCache({ default: blocks2 }, group.sectionConstraints, measureFn, headerMeasureCache, 1, pageResolver, kind)).default?.layout;
273086
+ const layout$1 = (await layoutHeaderFooterWithCache({ default: blocks2 }, group.sectionConstraints, measureFn, headerMeasureCache, 1, pageResolver, kind, undefined, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent))).default?.layout;
272488
273087
  if (!layout$1 || !(layout$1.height > 0))
272489
273088
  continue;
272490
273089
  const nextHeight = Math.max(0, layout$1.height);
@@ -272501,7 +273100,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
272501
273100
  for (const [rId, blocks2] of blocksByRId) {
272502
273101
  if (!blocks2 || blocks2.length === 0)
272503
273102
  continue;
272504
- const layout$1 = (await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, measureFn, headerMeasureCache, 1, pageResolver, kind)).default?.layout;
273103
+ const layout$1 = (await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, measureFn, headerMeasureCache, 1, pageResolver, kind, undefined, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent))).default?.layout;
272505
273104
  if (layout$1 && layout$1.height > 0)
272506
273105
  heightsByRId.set(rId, layout$1.height);
272507
273106
  }
@@ -272523,7 +273122,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
272523
273122
  };
272524
273123
  headerContentHeights = {};
272525
273124
  if (hasHeaderBlocks && headerFooter.headerBlocks) {
272526
- const preHeaderLayouts = await layoutHeaderFooterWithCache(headerFooter.headerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "header", fontSignature);
273125
+ const preHeaderLayouts = await layoutHeaderFooterWithCache(headerFooter.headerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "header", fontSignature, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent));
272527
273126
  for (const [type, value] of Object.entries(preHeaderLayouts)) {
272528
273127
  if (!isValidHeaderType(type))
272529
273128
  continue;
@@ -272564,7 +273163,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
272564
273163
  footerContentHeights = {};
272565
273164
  try {
272566
273165
  if (hasFooterBlocks && headerFooter.footerBlocks) {
272567
- const preFooterLayouts = await layoutHeaderFooterWithCache(headerFooter.footerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "footer", fontSignature);
273166
+ const preFooterLayouts = await layoutHeaderFooterWithCache(headerFooter.footerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "footer", fontSignature, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent));
272568
273167
  for (const [type, value] of Object.entries(preFooterLayouts)) {
272569
273168
  if (!isValidFooterType(type))
272570
273169
  continue;
@@ -272653,6 +273252,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
272653
273252
  console.warn(`[incrementalLayout] Page token resolution did not converge after ${maxIterations} iterations - stopping`);
272654
273253
  }
272655
273254
  }
273255
+ hydrateTableTextboxMeasures(currentBlocks, (block, maxWidth) => remeasureParagraph(block, maxWidth));
272656
273256
  const totalTokenTime = performance.now() - pageTokenStart;
272657
273257
  if (iteration > 0) {
272658
273258
  perfLog$1(`[Perf] 4.3 Total page token resolution time: ${totalTokenTime.toFixed(2)}ms`);
@@ -273664,10 +274264,17 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
273664
274264
  chapterSeparator: displayInfo?.chapterSeparator
273665
274265
  };
273666
274266
  } : undefined;
273667
- if (headerFooter.headerBlocks)
273668
- headers = serializeHeaderFooterResults("header", await layoutHeaderFooterWithCache(headerFooter.headerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FeatureFlags.HEADER_FOOTER_PAGE_TOKENS ? undefined : numberingCtx.totalPages, pageResolver, "header", fontSignature));
273669
- if (headerFooter.footerBlocks)
273670
- footers = serializeHeaderFooterResults("footer", await layoutHeaderFooterWithCache(headerFooter.footerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FeatureFlags.HEADER_FOOTER_PAGE_TOKENS ? undefined : numberingCtx.totalPages, pageResolver, "footer", fontSignature));
274267
+ const hfRemeasure = (block, maxWidth) => remeasureParagraph(block, maxWidth);
274268
+ if (headerFooter.headerBlocks) {
274269
+ for (const blocks2 of Object.values(headerFooter.headerBlocks))
274270
+ hydrateTableTextboxMeasures(blocks2, hfRemeasure);
274271
+ headers = serializeHeaderFooterResults("header", await layoutHeaderFooterWithCache(headerFooter.headerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FeatureFlags.HEADER_FOOTER_PAGE_TOKENS ? undefined : numberingCtx.totalPages, pageResolver, "header", fontSignature, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent)));
274272
+ }
274273
+ if (headerFooter.footerBlocks) {
274274
+ for (const blocks2 of Object.values(headerFooter.footerBlocks))
274275
+ hydrateTableTextboxMeasures(blocks2, hfRemeasure);
274276
+ footers = serializeHeaderFooterResults("footer", await layoutHeaderFooterWithCache(headerFooter.footerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FeatureFlags.HEADER_FOOTER_PAGE_TOKENS ? undefined : numberingCtx.totalPages, pageResolver, "footer", fontSignature, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent)));
274277
+ }
273671
274278
  perfLog$1(`[Perf] 4.4 Header/footer layout: ${(performance.now() - hfStart).toFixed(2)}ms`);
273672
274279
  const cacheStats = headerMeasureCache.getStats();
273673
274280
  globalMetrics.recordHeaderFooterCacheMetrics(cacheStats);
@@ -273683,6 +274290,19 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
273683
274290
  extraMeasures
273684
274291
  };
273685
274292
  }
274293
+ function hydrateTableTextboxMeasures(blocks2, remeasure) {
274294
+ for (const block of blocks2) {
274295
+ if (block.kind !== "table")
274296
+ continue;
274297
+ for (const row2 of block.rows ?? [])
274298
+ for (const cell2 of row2.cells ?? [])
274299
+ for (const cellBlock of cell2.blocks ?? [])
274300
+ if (cellBlock.kind === "drawing" && cellBlock.drawingKind === "textboxShape")
274301
+ cellBlock.contentMeasures = layoutTextboxContent(cellBlock, remeasure);
274302
+ else if (cellBlock.kind === "table")
274303
+ hydrateTableTextboxMeasures([cellBlock], remeasure);
274304
+ }
274305
+ }
273686
274306
  function rewriteSectionBreaksForSemanticFlow(blocks2, options) {
273687
274307
  const semanticPageSize = options.pageSize;
273688
274308
  const semanticMargins = options.margins;
@@ -273961,41 +274581,6 @@ async function remeasureAffectedBlocks(blocks2, measures, affectedBlockIds, perB
273961
274581
  }
273962
274582
  return updatedMeasures;
273963
274583
  }
273964
- function calculateSummary(samples) {
273965
- if (samples.length === 0)
273966
- return {
273967
- count: 0,
273968
- min: 0,
273969
- max: 0,
273970
- avg: 0,
273971
- p50: 0,
273972
- p95: 0,
273973
- p99: 0
273974
- };
273975
- const values = samples.map((s2) => s2.value).sort((a2, b$1) => a2 - b$1);
273976
- const count = values.length;
273977
- const sum = values.reduce((acc, v) => acc + v, 0);
273978
- return {
273979
- count,
273980
- min: values[0],
273981
- max: values[count - 1],
273982
- avg: sum / count,
273983
- p50: percentile(values, 0.5),
273984
- p95: percentile(values, 0.95),
273985
- p99: percentile(values, 0.99)
273986
- };
273987
- }
273988
- function percentile(sortedValues, p$12) {
273989
- if (sortedValues.length === 0)
273990
- return 0;
273991
- if (sortedValues.length === 1)
273992
- return sortedValues[0];
273993
- const index2 = (sortedValues.length - 1) * p$12;
273994
- const lower = Math.floor(index2);
273995
- const upper = Math.ceil(index2);
273996
- const weight = index2 - lower;
273997
- return sortedValues[lower] * (1 - weight) + sortedValues[upper] * weight;
273998
- }
273999
274584
  function resolveColumnsForHit(layout, page, fragmentY) {
274000
274585
  if (page === undefined)
274001
274586
  return layout.columns;
@@ -274291,6 +274876,54 @@ function clickToPositionGeometry(layout, blocks2, measures, containerPoint, opti
274291
274876
  lineIndex
274292
274877
  };
274293
274878
  }
274879
+ if (fragment.kind === "drawing" && fragment.drawingKind === "textboxShape" && block.kind === "drawing" && block.drawingKind === "textboxShape") {
274880
+ const textboxHit = resolveTextboxContentHit(fragment, block, measure, pageIndex, pageRelativePoint);
274881
+ if (textboxHit) {
274882
+ const { contentBlock, contentMeasure, localX, localY, pageIndex: pageIndex$1, paragraphIndex } = textboxHit;
274883
+ const lineIndex = findLineIndexAtY(contentMeasure.lines, localY, 0, contentMeasure.lines.length);
274884
+ if (lineIndex != null) {
274885
+ const line = contentMeasure.lines[lineIndex];
274886
+ const isRTL = isRtlBlock(contentBlock);
274887
+ const indentLeft = typeof contentBlock.attrs?.indent?.left === "number" ? contentBlock.attrs.indent.left : 0;
274888
+ const indentRight = typeof contentBlock.attrs?.indent?.right === "number" ? contentBlock.attrs.indent.right : 0;
274889
+ const totalIndent = (Number.isFinite(indentLeft) ? indentLeft : 0) + (Number.isFinite(indentRight) ? indentRight : 0);
274890
+ const insets = textboxHit.block.textInsets ?? {
274891
+ top: 0,
274892
+ right: 0,
274893
+ bottom: 0,
274894
+ left: 0
274895
+ };
274896
+ let availableWidth = Math.max(0, textboxHit.fragment.width - insets.left - insets.right - totalIndent);
274897
+ if (totalIndent > textboxHit.fragment.width)
274898
+ console.warn(`[clickToPosition:textbox] Paragraph indents (${totalIndent}px) exceed fragment width (${textboxHit.fragment.width}px) for block ${textboxHit.fragment.blockId}. This may indicate a layout miscalculation. Available width clamped to 0.`);
274899
+ if (lineIndex === 0) {
274900
+ const suppressFLI = contentBlock.attrs?.suppressFirstLineIndent === true;
274901
+ const firstLineOffset = getFirstLineIndentOffset(contentBlock.attrs?.indent, suppressFLI);
274902
+ availableWidth = adjustAvailableWidthForTextIndent(availableWidth, firstLineOffset, line.maxWidth);
274903
+ }
274904
+ const pos = mapPointToPm(contentBlock, line, localX, isRTL, availableWidth);
274905
+ if (pos != null)
274906
+ return {
274907
+ pos,
274908
+ layoutEpoch,
274909
+ blockId: textboxHit.fragment.blockId,
274910
+ pageIndex: pageIndex$1,
274911
+ column: determineColumn(layout, textboxHit.fragment.x, layout.pages[pageIndex$1], textboxHit.fragment.y),
274912
+ lineIndex
274913
+ };
274914
+ }
274915
+ const firstRun = contentBlock.runs?.[0];
274916
+ if (firstRun && firstRun.pmStart != null)
274917
+ return {
274918
+ pos: firstRun.pmStart,
274919
+ layoutEpoch,
274920
+ blockId: textboxHit.fragment.blockId,
274921
+ pageIndex: pageIndex$1,
274922
+ column: determineColumn(layout, textboxHit.fragment.x, layout.pages[pageIndex$1], textboxHit.fragment.y),
274923
+ lineIndex: 0
274924
+ };
274925
+ }
274926
+ }
274294
274927
  if (isAtomicFragment(fragment)) {
274295
274928
  const pmRange = getAtomicPmRange(fragment, block);
274296
274929
  const pos = pmRange.pmStart ?? pmRange.pmEnd ?? null;
@@ -274368,6 +275001,41 @@ function clickToPositionGeometry(layout, blocks2, measures, containerPoint, opti
274368
275001
  }
274369
275002
  return null;
274370
275003
  }
275004
+ function calculateSummary(samples) {
275005
+ if (samples.length === 0)
275006
+ return {
275007
+ count: 0,
275008
+ min: 0,
275009
+ max: 0,
275010
+ avg: 0,
275011
+ p50: 0,
275012
+ p95: 0,
275013
+ p99: 0
275014
+ };
275015
+ const values = samples.map((s2) => s2.value).sort((a2, b$1) => a2 - b$1);
275016
+ const count = values.length;
275017
+ const sum = values.reduce((acc, v) => acc + v, 0);
275018
+ return {
275019
+ count,
275020
+ min: values[0],
275021
+ max: values[count - 1],
275022
+ avg: sum / count,
275023
+ p50: percentile(values, 0.5),
275024
+ p95: percentile(values, 0.95),
275025
+ p99: percentile(values, 0.99)
275026
+ };
275027
+ }
275028
+ function percentile(sortedValues, p$12) {
275029
+ if (sortedValues.length === 0)
275030
+ return 0;
275031
+ if (sortedValues.length === 1)
275032
+ return sortedValues[0];
275033
+ const index2 = (sortedValues.length - 1) * p$12;
275034
+ const lower = Math.floor(index2);
275035
+ const upper = Math.ceil(index2);
275036
+ const weight = index2 - lower;
275037
+ return sortedValues[lower] * (1 - weight) + sortedValues[upper] * weight;
275038
+ }
274371
275039
  function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper) {
274372
275040
  if (from$1 === to)
274373
275041
  return [];
@@ -277536,6 +278204,73 @@ function computeTableCaretLayoutRectFromDom({ viewportHost, visibleHost, zoom },
277536
278204
  }
277537
278205
  return null;
277538
278206
  }
278207
+ function findTextboxFragmentElement(viewportHost, blockId, pageIndex) {
278208
+ const pageEl = viewportHost.querySelector(`[data-page-index="${pageIndex}"]`) ?? viewportHost;
278209
+ return Array.from(pageEl.querySelectorAll("[data-block-id]")).find((el) => el.dataset.blockId === blockId) ?? null;
278210
+ }
278211
+ function computeTextboxCaretLayoutRectFromDom({ viewportHost, visibleHost, zoom }, pos, fragment, _block, pageIndex) {
278212
+ const fragmentEl = findTextboxFragmentElement(viewportHost, fragment.blockId, pageIndex);
278213
+ if (!fragmentEl)
278214
+ return null;
278215
+ const lineEls = Array.from(fragmentEl.querySelectorAll(".superdoc-line[data-pm-start][data-pm-end]"));
278216
+ if (lineEls.length === 0)
278217
+ return null;
278218
+ for (let lineIdx = 0;lineIdx < lineEls.length; lineIdx++) {
278219
+ const lineEl = lineEls[lineIdx];
278220
+ const pmStart = Number(lineEl.dataset.pmStart ?? "NaN");
278221
+ const pmEnd = Number(lineEl.dataset.pmEnd ?? "NaN");
278222
+ if (!Number.isFinite(pmStart) || !Number.isFinite(pmEnd))
278223
+ continue;
278224
+ const isLastLine = lineIdx === lineEls.length - 1;
278225
+ if (pos < pmStart || (isLastLine ? pos > pmEnd : pos >= pmEnd))
278226
+ continue;
278227
+ const spanEls = Array.from(lineEl.querySelectorAll("span[data-pm-start][data-pm-end]"));
278228
+ for (let spanIdx = 0;spanIdx < spanEls.length; spanIdx++) {
278229
+ const spanEl = spanEls[spanIdx];
278230
+ const spanStart = Number(spanEl.dataset.pmStart ?? "NaN");
278231
+ const spanEnd = Number(spanEl.dataset.pmEnd ?? "NaN");
278232
+ if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd))
278233
+ continue;
278234
+ const isLastSpan = spanIdx === spanEls.length - 1;
278235
+ if (pos < spanStart || (isLastSpan ? pos > spanEnd : pos >= spanEnd))
278236
+ continue;
278237
+ const textNode = spanEl.firstChild;
278238
+ if (!textNode || textNode.nodeType !== Node.TEXT_NODE) {
278239
+ const spanRect = spanEl.getBoundingClientRect();
278240
+ const viewportRect$2 = viewportHost.getBoundingClientRect();
278241
+ return {
278242
+ pageIndex,
278243
+ x: (spanRect.left - viewportRect$2.left + visibleHost.scrollLeft) / zoom,
278244
+ y: (spanRect.top - viewportRect$2.top + visibleHost.scrollTop) / zoom,
278245
+ height: spanRect.height / zoom
278246
+ };
278247
+ }
278248
+ const text5 = textNode.textContent ?? "";
278249
+ const charOffset = Math.max(0, Math.min(text5.length, pos - spanStart));
278250
+ const range = document.createRange();
278251
+ range.setStart(textNode, charOffset);
278252
+ range.setEnd(textNode, charOffset);
278253
+ const rangeRect = range.getBoundingClientRect();
278254
+ const viewportRect$1 = viewportHost.getBoundingClientRect();
278255
+ const lineRect$1 = lineEl.getBoundingClientRect();
278256
+ return {
278257
+ pageIndex,
278258
+ x: (rangeRect.left - viewportRect$1.left + visibleHost.scrollLeft) / zoom,
278259
+ y: (lineRect$1.top - viewportRect$1.top + visibleHost.scrollTop) / zoom,
278260
+ height: lineRect$1.height / zoom
278261
+ };
278262
+ }
278263
+ const lineRect = lineEl.getBoundingClientRect();
278264
+ const viewportRect = viewportHost.getBoundingClientRect();
278265
+ return {
278266
+ pageIndex,
278267
+ x: (lineRect.left - viewportRect.left + visibleHost.scrollLeft) / zoom,
278268
+ y: (lineRect.top - viewportRect.top + visibleHost.scrollTop) / zoom,
278269
+ height: lineRect.height / zoom
278270
+ };
278271
+ }
278272
+ return null;
278273
+ }
277539
278274
  function findLineContainingPos(block, measure, fromLine, toLine, pos) {
277540
278275
  if (measure.kind !== "paragraph" || block.kind !== "paragraph")
277541
278276
  return null;
@@ -277592,6 +278327,12 @@ function computeCaretLayoutRectGeometry({ layout, blocks: blocks2, measures, pai
277592
278327
  visibleHost,
277593
278328
  zoom
277594
278329
  }, effectivePos, hit.fragment, block, measure, hit.pageIndex);
278330
+ if (hit.fragment.kind === "drawing" && block?.kind === "drawing" && block.drawingKind === "textboxShape" && measure?.kind === "drawing")
278331
+ return computeTextboxCaretLayoutRectFromDom({
278332
+ viewportHost,
278333
+ visibleHost,
278334
+ zoom
278335
+ }, effectivePos, hit.fragment, block, hit.pageIndex);
277595
278336
  if (!block || block.kind !== "paragraph" || measure?.kind !== "paragraph")
277596
278337
  return null;
277597
278338
  if (hit.fragment.kind !== "para")
@@ -282213,7 +282954,7 @@ async function layoutBlocksByRId(kind, blocksByRId, referencedRIds, constraints,
282213
282954
  if (!blocks2 || blocks2.length === 0)
282214
282955
  continue;
282215
282956
  try {
282216
- const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, (block, c) => measureBlock(block, c, fontMeasureContext), undefined, undefined, pageResolver, kind, fontSignature);
282957
+ const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, (block, c) => measureBlock(block, c, fontMeasureContext), undefined, undefined, pageResolver, kind, fontSignature, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent));
282217
282958
  if (batchResult.default)
282218
282959
  layoutsByRId.set(rId, {
282219
282960
  kind,
@@ -282273,7 +283014,7 @@ async function layoutWithPerSectionConstraints(kind, blocksByRId, sectionMetadat
282273
283014
  if (!blocks2 || blocks2.length === 0)
282274
283015
  continue;
282275
283016
  try {
282276
- const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, group.sectionConstraints, (block, c) => measureBlock(block, c, fontMeasureContext), undefined, undefined, pageResolver, kind, fontSignature);
283017
+ const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, group.sectionConstraints, (block, c) => measureBlock(block, c, fontMeasureContext), undefined, undefined, pageResolver, kind, fontSignature, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent));
282277
283018
  if (batchResult.default)
282278
283019
  for (const sectionIndex of group.sectionIndices) {
282279
283020
  const contentWidth = buildSectionContentWidth(sectionMetadata.find((s2) => s2.sectionIndex === sectionIndex), fallbackConstraints);
@@ -306265,6 +307006,7 @@ menclose::after {
306265
307006
  drawingWrapper.style.flexShrink = "0";
306266
307007
  drawingWrapper.style.maxWidth = "100%";
306267
307008
  drawingWrapper.style.boxSizing = "border-box";
307009
+ drawingWrapper.dataset.blockId = block.id;
306268
307010
  applySdtDataset$1(drawingWrapper, block.attrs);
306269
307011
  const drawingInner = doc$12.createElement("div");
306270
307012
  drawingInner.classList.add("superdoc-table-drawing");
@@ -306434,6 +307176,7 @@ menclose::after {
306434
307176
  drawingWrapper.style.maxWidth = "100%";
306435
307177
  drawingWrapper.style.boxSizing = "border-box";
306436
307178
  drawingWrapper.style.zIndex = String(zIndex);
307179
+ drawingWrapper.dataset.blockId = anchoredBlock.id;
306437
307180
  applySdtDataset$1(drawingWrapper, anchoredBlock.attrs);
306438
307181
  const drawingInner = doc$12.createElement("div");
306439
307182
  drawingInner.classList.add("superdoc-table-drawing");
@@ -310473,17 +311216,19 @@ menclose::after {
310473
311216
  throw new Error("DomPainter: document is not available");
310474
311217
  if (block.drawingKind === "image")
310475
311218
  return createDrawingImageElement(this.doc, block, this.buildImageHyperlinkAnchor.bind(this));
310476
- if (block.drawingKind === "vectorShape")
310477
- return this.createVectorShapeElement(block, fragment.geometry, false, 1, 1, context);
311219
+ if (block.drawingKind === "vectorShape" || block.drawingKind === "textboxShape")
311220
+ return this.createVectorShapeElement(block, fragment.geometry, false, 1, 1, context, fragment);
310478
311221
  if (block.drawingKind === "shapeGroup")
310479
311222
  return this.createShapeGroupElement(block, context);
310480
311223
  if (block.drawingKind === "chart")
310481
311224
  return this.createChartElement(block);
310482
311225
  return this.createDrawingPlaceholder();
310483
311226
  }
310484
- createVectorShapeElement(block, geometry, applyTransforms = false, groupScaleX = 1, groupScaleY = 1, context) {
311227
+ createVectorShapeElement(block, geometry, applyTransforms = false, groupScaleX = 1, groupScaleY = 1, context, fragment) {
310485
311228
  const container = this.doc.createElement("div");
310486
311229
  container.classList.add("superdoc-vector-shape");
311230
+ if (block.drawingKind === "textboxShape")
311231
+ container.classList.add("superdoc-textbox-shape");
310487
311232
  container.style.width = "100%";
310488
311233
  container.style.height = "100%";
310489
311234
  container.style.position = "relative";
@@ -310514,8 +311259,8 @@ menclose::after {
310514
311259
  }
310515
311260
  this.applyLineEnds(svgElement, block);
310516
311261
  contentContainer.appendChild(svgElement);
310517
- if (this.hasShapeTextContent(block.textContent)) {
310518
- const textElement = this.createShapeTextElement(block, innerWidth, innerHeight2, groupScaleX, groupScaleY, context);
311262
+ if (block.drawingKind === "textboxShape" || this.hasShapeTextContent(block.textContent)) {
311263
+ const textElement = block.drawingKind === "textboxShape" ? this.createTextboxContentElement(block, fragment, innerWidth, innerHeight2, context) : this.createShapeTextElement(block, innerWidth, innerHeight2, groupScaleX, groupScaleY, context);
310519
311264
  contentContainer.appendChild(textElement);
310520
311265
  }
310521
311266
  container.appendChild(contentContainer);
@@ -310523,8 +311268,8 @@ menclose::after {
310523
311268
  }
310524
311269
  }
310525
311270
  this.applyFallbackShapeStyle(contentContainer, block);
310526
- if (this.hasShapeTextContent(block.textContent)) {
310527
- const textElement = this.createShapeTextElement(block, innerWidth, innerHeight2, groupScaleX, groupScaleY, context);
311271
+ if (block.drawingKind === "textboxShape" || this.hasShapeTextContent(block.textContent)) {
311272
+ const textElement = block.drawingKind === "textboxShape" ? this.createTextboxContentElement(block, fragment, innerWidth, innerHeight2, context) : this.createShapeTextElement(block, innerWidth, innerHeight2, groupScaleX, groupScaleY, context);
310528
311273
  contentContainer.appendChild(textElement);
310529
311274
  }
310530
311275
  container.appendChild(contentContainer);
@@ -310564,6 +311309,47 @@ menclose::after {
310564
311309
  return this.createWordArtTextElement(textContent$1, block.textAlign ?? "center", block.textInsets, width, height, context);
310565
311310
  return this.createFallbackTextElement(textContent$1, block.textAlign ?? "center", block.textVerticalAlign, block.textInsets, groupScaleX, groupScaleY, context);
310566
311311
  }
311312
+ createTextboxContentElement(block, fragment, width, height, context) {
311313
+ const contentMeasures = fragment?.contentMeasures ?? block.contentMeasures;
311314
+ if (!Array.isArray(contentMeasures) || contentMeasures.length === 0)
311315
+ return this.hasShapeTextContent(block.textContent) ? this.createShapeTextElement(block, width, height, 1, 1, context) : this.doc.createElement("div");
311316
+ const contentRoot = this.doc.createElement("div");
311317
+ contentRoot.style.position = "absolute";
311318
+ contentRoot.style.top = "0";
311319
+ contentRoot.style.left = "0";
311320
+ contentRoot.style.width = "100%";
311321
+ contentRoot.style.height = "100%";
311322
+ contentRoot.style.display = "flex";
311323
+ contentRoot.style.flexDirection = "column";
311324
+ contentRoot.style.boxSizing = "border-box";
311325
+ contentRoot.style.overflow = "hidden";
311326
+ const insets = block.textInsets ?? {
311327
+ top: 0,
311328
+ right: 0,
311329
+ bottom: 0,
311330
+ left: 0
311331
+ };
311332
+ contentRoot.style.padding = `${insets.top}px ${insets.right}px ${insets.bottom}px ${insets.left}px`;
311333
+ const verticalAlign = block.textVerticalAlign ?? "top";
311334
+ contentRoot.style.justifyContent = verticalAlign === "bottom" ? "flex-end" : verticalAlign === "center" ? "center" : "flex-start";
311335
+ const linesHost = this.doc.createElement("div");
311336
+ linesHost.style.display = "flex";
311337
+ linesHost.style.flexDirection = "column";
311338
+ linesHost.style.minWidth = "0";
311339
+ linesHost.style.width = "100%";
311340
+ const renderContext = context ?? this.defaultFragmentRenderContext();
311341
+ const availableWidth = Math.max(1, width - insets.left - insets.right);
311342
+ block.contentBlocks.forEach((paragraphBlock, paragraphIndex) => {
311343
+ const measure = contentMeasures[paragraphIndex];
311344
+ if (!measure?.lines)
311345
+ return;
311346
+ measure.lines.forEach((line, lineIndex) => {
311347
+ linesHost.appendChild(this.renderLine(paragraphBlock, line, renderContext, availableWidth, lineIndex));
311348
+ });
311349
+ });
311350
+ contentRoot.appendChild(linesHost);
311351
+ return contentRoot;
311352
+ }
310567
311353
  shouldUseWordArtTextRenderer(block) {
310568
311354
  return block.attrs?.isWordArt === true && this.hasShapeTextContent(block.textContent);
310569
311355
  }
@@ -311116,7 +311902,7 @@ menclose::after {
311116
311902
  return createDrawingImageElement(this.doc, block, this.buildImageHyperlinkAnchor.bind(this));
311117
311903
  if (block.drawingKind === "shapeGroup")
311118
311904
  return this.createShapeGroupElement(block, context);
311119
- if (block.drawingKind === "vectorShape")
311905
+ if (block.drawingKind === "vectorShape" || block.drawingKind === "textboxShape")
311120
311906
  return this.createVectorShapeElement(block, block.geometry, false, 1, 1, context);
311121
311907
  if (block.drawingKind === "chart")
311122
311908
  return this.createChartElement(block);
@@ -311201,6 +311987,13 @@ menclose::after {
311201
311987
  };
311202
311988
  return runContext;
311203
311989
  }
311990
+ defaultFragmentRenderContext() {
311991
+ return {
311992
+ pageNumber: 1,
311993
+ totalPages: 1,
311994
+ section: "body"
311995
+ };
311996
+ }
311204
311997
  updateFragmentElement(el, fragment, section, resolvedItem) {
311205
311998
  const fragmentItem = resolvedItem?.kind === "fragment" ? resolvedItem : undefined;
311206
311999
  const story = resolveSectionStory(section);
@@ -311697,6 +312490,15 @@ menclose::after {
311697
312490
  if (!lum)
311698
312491
  return "";
311699
312492
  return [lum.bright ?? "", lum.contrast ?? ""].join(":");
312493
+ }, drawingTextVersion = (block) => {
312494
+ const textboxContentBlocks = "contentBlocks" in block && Array.isArray(block.contentBlocks) ? block.contentBlocks.map((contentBlock) => deriveBlockVersion(contentBlock)).join(";") : "";
312495
+ return JSON.stringify([
312496
+ block.textAlign ?? "",
312497
+ block.textVerticalAlign ?? "",
312498
+ block.textInsets ?? null,
312499
+ block.textContent ?? null,
312500
+ textboxContentBlocks
312501
+ ]);
311700
312502
  }, renderedBlockImageVersion = (image2) => [
311701
312503
  image2.src ?? "",
311702
312504
  image2.width ?? "",
@@ -311904,10 +312706,10 @@ menclose::after {
311904
312706
  if (block.kind === "drawing") {
311905
312707
  if (block.drawingKind === "image")
311906
312708
  return ["drawing:image", renderedBlockImageVersion(block)].join("|");
311907
- if (block.drawingKind === "vectorShape") {
312709
+ if (block.drawingKind === "vectorShape" || block.drawingKind === "textboxShape") {
311908
312710
  const vector = block;
311909
312711
  return [
311910
- "drawing:vector",
312712
+ block.drawingKind === "textboxShape" ? "drawing:textbox" : "drawing:vector",
311911
312713
  vector.shapeKind ?? "",
311912
312714
  vector.fillColor ?? "",
311913
312715
  vector.strokeColor ?? "",
@@ -311916,7 +312718,8 @@ menclose::after {
311916
312718
  vector.geometry.height,
311917
312719
  vector.geometry.rotation ?? 0,
311918
312720
  vector.geometry.flipH ? 1 : 0,
311919
- vector.geometry.flipV ? 1 : 0
312721
+ vector.geometry.flipV ? 1 : 0,
312722
+ drawingTextVersion(vector)
311920
312723
  ].join("|");
311921
312724
  }
311922
312725
  if (block.drawingKind === "shapeGroup") {
@@ -312612,6 +313415,23 @@ menclose::after {
312612
313415
  block.textVerticalAlign ?? "",
312613
313416
  JSON.stringify(block.textInsets ?? null)
312614
313417
  ].join(":");
313418
+ if (block.drawingKind === "textboxShape")
313419
+ return [
313420
+ "drawing:textbox",
313421
+ hashDrawingGeometry(block.geometry),
313422
+ block.shapeKind ?? "",
313423
+ JSON.stringify(block.fillColor ?? null),
313424
+ JSON.stringify(block.strokeColor ?? null),
313425
+ block.strokeWidth ?? "",
313426
+ JSON.stringify(block.customGeometry ?? null),
313427
+ JSON.stringify(block.lineEnds ?? null),
313428
+ JSON.stringify(block.effectExtent ?? null),
313429
+ JSON.stringify(block.textContent ?? null),
313430
+ block.textAlign ?? "",
313431
+ block.textVerticalAlign ?? "",
313432
+ JSON.stringify(block.textInsets ?? null),
313433
+ block.contentBlocks.map((contentBlock) => `${contentBlock.id}:${hashRuns(contentBlock)}`).join("|")
313434
+ ].join(":");
312615
313435
  if (block.drawingKind === "shapeGroup")
312616
313436
  return [
312617
313437
  "drawing:shapeGroup",
@@ -313646,8 +314466,10 @@ menclose::after {
313646
314466
  return false;
313647
314467
  if (a2.drawingKind === "image" && b$1.drawingKind === "image")
313648
314468
  return imageBlocksEqual(a2, b$1);
313649
- if (a2.drawingKind === "vectorShape" && b$1.drawingKind === "vectorShape")
313650
- return drawingGeometryEqual(a2.geometry, b$1.geometry) && a2.shapeKind === b$1.shapeKind && a2.fillColor === b$1.fillColor && a2.strokeColor === b$1.strokeColor && a2.strokeWidth === b$1.strokeWidth;
314469
+ if ((a2.drawingKind === "vectorShape" || a2.drawingKind === "textboxShape") && (b$1.drawingKind === "vectorShape" || b$1.drawingKind === "textboxShape")) {
314470
+ const textboxContentEqual = a2.drawingKind !== "textboxShape" || b$1.drawingKind !== "textboxShape" || jsonEqual(a2.contentBlocks, b$1.contentBlocks);
314471
+ return drawingGeometryEqual(a2.geometry, b$1.geometry) && a2.shapeKind === b$1.shapeKind && a2.fillColor === b$1.fillColor && a2.strokeColor === b$1.strokeColor && a2.strokeWidth === b$1.strokeWidth && a2.textAlign === b$1.textAlign && a2.textVerticalAlign === b$1.textVerticalAlign && jsonEqual(a2.textInsets, b$1.textInsets) && jsonEqual(a2.textContent, b$1.textContent) && jsonEqual(a2.customGeometry, b$1.customGeometry) && jsonEqual(a2.lineEnds, b$1.lineEnds) && jsonEqual(a2.effectExtent, b$1.effectExtent) && textboxContentEqual;
314472
+ }
313651
314473
  if (a2.drawingKind === "shapeGroup" && b$1.drawingKind === "shapeGroup")
313652
314474
  return drawingGeometryEqual(a2.geometry, b$1.geometry) && shapeGroupTransformEqual(a2.groupTransform, b$1.groupTransform) && shapeGroupSizeEqual(a2.size, b$1.size) && shapeGroupChildrenEqual(a2.shapes, b$1.shapes);
313653
314475
  if (a2.drawingKind === "chart" && b$1.drawingKind === "chart")
@@ -314471,7 +315293,329 @@ menclose::after {
314471
315293
  });
314472
315294
  });
314473
315295
  return results;
314474
- }, PRELAYOUT_CHAPTER_MARKER_SEPARATOR_RE, PRELAYOUT_MIN_PAGE_COMPONENT = 10, PageGeometryHelper = class {
315296
+ }, PRELAYOUT_CHAPTER_MARKER_SEPARATOR_RE, PRELAYOUT_MIN_PAGE_COMPONENT = 10, isAtomicFragment = (fragment) => {
315297
+ return fragment.kind === "drawing" || fragment.kind === "image";
315298
+ }, blockPmRangeFromAttrs = (block) => {
315299
+ const attrs = block?.attrs;
315300
+ const pmStart = typeof attrs?.pmStart === "number" ? attrs.pmStart : undefined;
315301
+ return {
315302
+ pmStart,
315303
+ pmEnd: typeof attrs?.pmEnd === "number" ? attrs.pmEnd : pmStart != null ? pmStart + 1 : undefined
315304
+ };
315305
+ }, getAtomicPmRange = (fragment, block) => {
315306
+ return {
315307
+ pmStart: typeof fragment.pmStart === "number" ? fragment.pmStart : blockPmRangeFromAttrs(block).pmStart,
315308
+ pmEnd: typeof fragment.pmEnd === "number" ? fragment.pmEnd : blockPmRangeFromAttrs(block).pmEnd
315309
+ };
315310
+ }, isRtlBlock = (block) => {
315311
+ if (block.kind !== "paragraph")
315312
+ return false;
315313
+ return getParagraphInlineDirection(block.attrs) === "rtl";
315314
+ }, determineColumn = (layout, fragmentX, page, fragmentY) => {
315315
+ const columns = resolveColumnsForHit(layout, page, fragmentY);
315316
+ if (!columns || columns.count <= 1)
315317
+ return 0;
315318
+ const pageWidth = page?.size?.w ?? layout.pageSize.w;
315319
+ const margins = page?.margins ?? layout.pages[0]?.margins;
315320
+ const marginLeft = Math.max(0, margins?.left ?? 0);
315321
+ const marginRight = Math.max(0, margins?.right ?? 0);
315322
+ return getColumnAtX(getColumnGeometry(normalizeColumnLayout(columns, Math.max(1, pageWidth - (marginLeft + marginRight)))), fragmentX, marginLeft);
315323
+ }, determineTableColumn = (layout, fragment, page) => {
315324
+ if (typeof fragment.columnIndex === "number") {
315325
+ const count = resolveColumnsForHit(layout, page, fragment.y)?.count ?? 1;
315326
+ return Math.max(0, Math.min(Math.max(0, count - 1), fragment.columnIndex));
315327
+ }
315328
+ return determineColumn(layout, fragment.x, page, fragment.y);
315329
+ }, findLineIndexAtY = (lines, offsetY, fromLine, toLine) => {
315330
+ if (!lines || lines.length === 0)
315331
+ return null;
315332
+ const lineCount = lines.length;
315333
+ if (fromLine < 0 || toLine > lineCount || fromLine >= toLine)
315334
+ return null;
315335
+ let cursor = 0;
315336
+ for (let i4 = fromLine;i4 < toLine; i4 += 1) {
315337
+ const line = lines[i4];
315338
+ if (!line)
315339
+ return null;
315340
+ const next2 = cursor + line.lineHeight;
315341
+ if (offsetY >= cursor && offsetY < next2)
315342
+ return i4;
315343
+ cursor = next2;
315344
+ }
315345
+ return toLine - 1;
315346
+ }, mapPointToPm = (block, line, x, isRTL, availableWidthOverride, alignmentOverride) => {
315347
+ if (block.kind !== "paragraph")
315348
+ return null;
315349
+ const range = computeLinePmRange(block, line);
315350
+ if (range.pmStart == null || range.pmEnd == null)
315351
+ return null;
315352
+ const result = findCharacterAtX(block, line, x, range.pmStart, availableWidthOverride, alignmentOverride);
315353
+ let pmPosition = result.pmPosition;
315354
+ if (isRTL) {
315355
+ const charOffset = result.charOffset;
315356
+ const charsInLine = Math.max(1, line.toChar - line.fromChar);
315357
+ pmPosition = charOffsetToPm(block, line, Math.max(0, Math.min(charsInLine, charsInLine - charOffset)), range.pmStart);
315358
+ }
315359
+ return pmPosition;
315360
+ }, calculatePageTopFallback = (layout, pageIndex) => {
315361
+ const pageGap = layout.pageGap ?? 0;
315362
+ let y$1 = 0;
315363
+ for (let i4 = 0;i4 < pageIndex; i4++) {
315364
+ const pageHeight = layout.pages[i4]?.size?.h ?? layout.pageSize.h;
315365
+ y$1 += pageHeight + pageGap;
315366
+ }
315367
+ return y$1;
315368
+ }, hitTestAtomicFragment = (pageHit, blocks2, measures, point5) => {
315369
+ for (const fragment of pageHit.page.fragments) {
315370
+ if (!isAtomicFragment(fragment))
315371
+ continue;
315372
+ const withinX = point5.x >= fragment.x && point5.x <= fragment.x + fragment.width;
315373
+ const withinY = point5.y >= fragment.y && point5.y <= fragment.y + fragment.height;
315374
+ if (!withinX || !withinY)
315375
+ continue;
315376
+ const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId);
315377
+ if (blockIndex === -1)
315378
+ continue;
315379
+ const block = blocks2[blockIndex];
315380
+ const measure = measures[blockIndex];
315381
+ if (!block || !measure)
315382
+ continue;
315383
+ return {
315384
+ fragment,
315385
+ block,
315386
+ measure,
315387
+ pageIndex: pageHit.pageIndex,
315388
+ pageY: 0
315389
+ };
315390
+ }
315391
+ return null;
315392
+ }, hitTestTableFragment = (pageHit, blocks2, measures, point5) => {
315393
+ for (const fragment of pageHit.page.fragments) {
315394
+ if (fragment.kind !== "table")
315395
+ continue;
315396
+ const tableFragment = fragment;
315397
+ const withinX = point5.x >= tableFragment.x && point5.x <= tableFragment.x + tableFragment.width;
315398
+ const withinY = point5.y >= tableFragment.y && point5.y <= tableFragment.y + tableFragment.height;
315399
+ if (!withinX || !withinY)
315400
+ continue;
315401
+ const blockIndex = blocks2.findIndex((block$1) => block$1.id === tableFragment.blockId);
315402
+ if (blockIndex === -1)
315403
+ continue;
315404
+ const block = blocks2[blockIndex];
315405
+ const measure = measures[blockIndex];
315406
+ if (!block || block.kind !== "table" || !measure || measure.kind !== "table")
315407
+ continue;
315408
+ const tableBlock = block;
315409
+ const tableMeasure = measure;
315410
+ const localX = point5.x - tableFragment.x;
315411
+ const localY = point5.y - tableFragment.y;
315412
+ let rowY = 0;
315413
+ let rowIndex = -1;
315414
+ if (tableMeasure.rows.length === 0 || tableBlock.rows.length === 0)
315415
+ continue;
315416
+ for (let r$1 = tableFragment.fromRow;r$1 < tableFragment.toRow && r$1 < tableMeasure.rows.length; r$1++) {
315417
+ const rowMeasure$1 = tableMeasure.rows[r$1];
315418
+ if (localY >= rowY && localY < rowY + rowMeasure$1.height) {
315419
+ rowIndex = r$1;
315420
+ break;
315421
+ }
315422
+ rowY += rowMeasure$1.height;
315423
+ }
315424
+ if (rowIndex === -1) {
315425
+ rowIndex = Math.min(tableFragment.toRow - 1, tableMeasure.rows.length - 1);
315426
+ if (rowIndex < tableFragment.fromRow)
315427
+ continue;
315428
+ }
315429
+ const rowMeasure = tableMeasure.rows[rowIndex];
315430
+ const row2 = tableBlock.rows[rowIndex];
315431
+ if (!rowMeasure || !row2)
315432
+ continue;
315433
+ const firstCellGridStart = rowMeasure.cells[0]?.gridColumnStart ?? 0;
315434
+ let colX = 0;
315435
+ if (firstCellGridStart > 0 && tableMeasure.columnWidths)
315436
+ for (let col = 0;col < firstCellGridStart && col < tableMeasure.columnWidths.length; col++)
315437
+ colX += tableMeasure.columnWidths[col];
315438
+ const initialColX = colX;
315439
+ let colIndex = -1;
315440
+ if (rowMeasure.cells.length === 0 || row2.cells.length === 0)
315441
+ continue;
315442
+ for (let c = 0;c < rowMeasure.cells.length; c++) {
315443
+ const cellMeasure$1 = rowMeasure.cells[c];
315444
+ if (localX >= colX && localX < colX + cellMeasure$1.width) {
315445
+ colIndex = c;
315446
+ break;
315447
+ }
315448
+ colX += cellMeasure$1.width;
315449
+ }
315450
+ if (colIndex === -1) {
315451
+ if (localX < initialColX)
315452
+ colIndex = 0;
315453
+ else
315454
+ colIndex = rowMeasure.cells.length - 1;
315455
+ if (colIndex < 0)
315456
+ continue;
315457
+ }
315458
+ const cellMeasure = rowMeasure.cells[colIndex];
315459
+ const cell2 = row2.cells[colIndex];
315460
+ if (!cellMeasure || !cell2)
315461
+ continue;
315462
+ const cellBlocks = cell2.blocks ?? (cell2.paragraph ? [cell2.paragraph] : []);
315463
+ const rawMeasures = cellMeasure.blocks ?? (cellMeasure.paragraph ? [cellMeasure.paragraph] : []);
315464
+ const cellBlockMeasures = (Array.isArray(rawMeasures) ? rawMeasures : []).filter((m$1) => m$1 != null && typeof m$1 === "object" && ("kind" in m$1));
315465
+ let blockStartY = 0;
315466
+ let blockStartGlobalLines = 0;
315467
+ const getBlockHeight = (m$1) => {
315468
+ if (!m$1)
315469
+ return 0;
315470
+ if ("totalHeight" in m$1 && typeof m$1.totalHeight === "number")
315471
+ return m$1.totalHeight;
315472
+ if ("height" in m$1 && typeof m$1.height === "number")
315473
+ return m$1.height;
315474
+ return 0;
315475
+ };
315476
+ let nearestParagraphHit = null;
315477
+ for (let i4 = 0;i4 < cellBlocks.length && i4 < cellBlockMeasures.length; i4++) {
315478
+ const cellBlock = cellBlocks[i4];
315479
+ const cellBlockMeasure = cellBlockMeasures[i4];
315480
+ if (cellBlock?.kind !== "paragraph" || cellBlockMeasure?.kind !== "paragraph") {
315481
+ blockStartY += getBlockHeight(cellBlockMeasure);
315482
+ continue;
315483
+ }
315484
+ const blockHeight = getBlockHeight(cellBlockMeasure);
315485
+ const blockEndY = blockStartY + blockHeight;
315486
+ const padding = cell2.attrs?.padding ?? {
315487
+ top: 0,
315488
+ left: 4,
315489
+ right: 4,
315490
+ bottom: 0
315491
+ };
315492
+ const cellLocalX = localX - colX - (padding.left ?? 4);
315493
+ const cellLocalY = localY - rowY - (padding.top ?? 0);
315494
+ const paragraphBlock = cellBlock;
315495
+ const paragraphMeasure = cellBlockMeasure;
315496
+ if (cellLocalY >= blockStartY && cellLocalY < blockEndY) {
315497
+ const unclampedLocalY = cellLocalY - blockStartY;
315498
+ const localYWithinBlock = Math.max(0, Math.min(unclampedLocalY, Math.max(blockHeight, 0)));
315499
+ return {
315500
+ fragment: tableFragment,
315501
+ block: tableBlock,
315502
+ measure: tableMeasure,
315503
+ pageIndex: pageHit.pageIndex,
315504
+ cellRowIndex: rowIndex,
315505
+ cellColIndex: colIndex,
315506
+ cellBlock: paragraphBlock,
315507
+ cellMeasure: paragraphMeasure,
315508
+ localX: Math.max(0, cellLocalX),
315509
+ localY: Math.max(0, localYWithinBlock),
315510
+ blockStartGlobal: blockStartGlobalLines
315511
+ };
315512
+ }
315513
+ const distanceToBlock = cellLocalY < blockStartY ? blockStartY - cellLocalY : Math.max(0, cellLocalY - blockEndY);
315514
+ if (!nearestParagraphHit || distanceToBlock < nearestParagraphHit.distance) {
315515
+ const unclampedLocalY = cellLocalY - blockStartY;
315516
+ nearestParagraphHit = {
315517
+ cellBlock: paragraphBlock,
315518
+ cellMeasure: paragraphMeasure,
315519
+ localX: Math.max(0, cellLocalX),
315520
+ localY: Math.max(0, Math.min(unclampedLocalY, Math.max(blockHeight, 0))),
315521
+ blockStartGlobal: blockStartGlobalLines,
315522
+ distance: distanceToBlock
315523
+ };
315524
+ }
315525
+ blockStartY = blockEndY;
315526
+ blockStartGlobalLines += paragraphMeasure.lines.length;
315527
+ }
315528
+ if (nearestParagraphHit)
315529
+ return {
315530
+ fragment: tableFragment,
315531
+ block: tableBlock,
315532
+ measure: tableMeasure,
315533
+ pageIndex: pageHit.pageIndex,
315534
+ cellRowIndex: rowIndex,
315535
+ cellColIndex: colIndex,
315536
+ cellBlock: nearestParagraphHit.cellBlock,
315537
+ cellMeasure: nearestParagraphHit.cellMeasure,
315538
+ localX: nearestParagraphHit.localX,
315539
+ localY: nearestParagraphHit.localY,
315540
+ blockStartGlobal: nearestParagraphHit.blockStartGlobal
315541
+ };
315542
+ }
315543
+ return null;
315544
+ }, resolveTextboxContentHit = (fragment, block, measure, pageIndex, point5) => {
315545
+ const fragmentWithContent = fragment;
315546
+ const contentMeasures = Array.isArray(fragmentWithContent.contentMeasures) ? fragmentWithContent.contentMeasures : Array.isArray(block.contentMeasures) ? block.contentMeasures : [];
315547
+ const contentBlocks = Array.isArray(block.contentBlocks) ? block.contentBlocks : [];
315548
+ if (contentMeasures.length === 0 || contentBlocks.length === 0)
315549
+ return null;
315550
+ const insets = block.textInsets ?? {
315551
+ top: 0,
315552
+ right: 0,
315553
+ bottom: 0,
315554
+ left: 0
315555
+ };
315556
+ const localX = Math.max(0, point5.x - fragment.x - insets.left);
315557
+ const rawLocalY = point5.y - fragment.y - insets.top;
315558
+ const totalContentHeight = contentMeasures.reduce((sum, m$1) => sum + (m$1?.kind === "paragraph" ? m$1.totalHeight ?? 0 : 0), 0);
315559
+ const availableHeight = Math.max(0, fragment.height - insets.top - insets.bottom);
315560
+ const verticalAlign = block.textVerticalAlign ?? "top";
315561
+ let contentOffset = 0;
315562
+ if (verticalAlign === "center")
315563
+ contentOffset = Math.max(0, (availableHeight - totalContentHeight) / 2);
315564
+ else if (verticalAlign === "bottom")
315565
+ contentOffset = Math.max(0, availableHeight - totalContentHeight);
315566
+ const localY = rawLocalY - contentOffset;
315567
+ let paragraphStartY = 0;
315568
+ let blockStartGlobal = 0;
315569
+ let nearestParagraphHit = null;
315570
+ for (let i4 = 0;i4 < contentBlocks.length && i4 < contentMeasures.length; i4 += 1) {
315571
+ const contentBlock = contentBlocks[i4];
315572
+ const contentMeasure = contentMeasures[i4];
315573
+ if (contentBlock?.kind !== "paragraph" || contentMeasure?.kind !== "paragraph")
315574
+ continue;
315575
+ const paragraphHeight = contentMeasure.totalHeight;
315576
+ const paragraphEndY = paragraphStartY + paragraphHeight;
315577
+ if (localY >= paragraphStartY && localY < paragraphEndY)
315578
+ return {
315579
+ fragment,
315580
+ block,
315581
+ measure,
315582
+ pageIndex,
315583
+ contentBlock,
315584
+ contentMeasure,
315585
+ paragraphIndex: i4,
315586
+ localX,
315587
+ localY: Math.max(0, Math.min(localY - paragraphStartY, Math.max(paragraphHeight, 0))),
315588
+ blockStartGlobal
315589
+ };
315590
+ const distanceToParagraph = localY < paragraphStartY ? paragraphStartY - localY : Math.max(0, localY - paragraphEndY);
315591
+ if (!nearestParagraphHit || distanceToParagraph < nearestParagraphHit.distance)
315592
+ nearestParagraphHit = {
315593
+ contentBlock,
315594
+ contentMeasure,
315595
+ paragraphIndex: i4,
315596
+ localX,
315597
+ localY: Math.max(0, Math.min(localY - paragraphStartY, Math.max(paragraphHeight, 0))),
315598
+ blockStartGlobal,
315599
+ distance: distanceToParagraph
315600
+ };
315601
+ paragraphStartY = paragraphEndY;
315602
+ blockStartGlobal += contentMeasure.lines.length;
315603
+ }
315604
+ if (nearestParagraphHit)
315605
+ return {
315606
+ fragment,
315607
+ block,
315608
+ measure,
315609
+ pageIndex,
315610
+ contentBlock: nearestParagraphHit.contentBlock,
315611
+ contentMeasure: nearestParagraphHit.contentMeasure,
315612
+ paragraphIndex: nearestParagraphHit.paragraphIndex,
315613
+ localX: nearestParagraphHit.localX,
315614
+ localY: nearestParagraphHit.localY,
315615
+ blockStartGlobal: nearestParagraphHit.blockStartGlobal
315616
+ };
315617
+ return null;
315618
+ }, PageGeometryHelper = class {
314475
315619
  constructor(config3) {
314476
315620
  this.cache = null;
314477
315621
  this.config = config3;
@@ -314686,254 +315830,6 @@ menclose::after {
314686
315830
  for (const metric of Object.keys(this.metrics))
314687
315831
  this.metrics[metric] = [];
314688
315832
  }
314689
- }, isAtomicFragment = (fragment) => {
314690
- return fragment.kind === "drawing" || fragment.kind === "image";
314691
- }, blockPmRangeFromAttrs = (block) => {
314692
- const attrs = block?.attrs;
314693
- const pmStart = typeof attrs?.pmStart === "number" ? attrs.pmStart : undefined;
314694
- return {
314695
- pmStart,
314696
- pmEnd: typeof attrs?.pmEnd === "number" ? attrs.pmEnd : pmStart != null ? pmStart + 1 : undefined
314697
- };
314698
- }, getAtomicPmRange = (fragment, block) => {
314699
- return {
314700
- pmStart: typeof fragment.pmStart === "number" ? fragment.pmStart : blockPmRangeFromAttrs(block).pmStart,
314701
- pmEnd: typeof fragment.pmEnd === "number" ? fragment.pmEnd : blockPmRangeFromAttrs(block).pmEnd
314702
- };
314703
- }, isRtlBlock = (block) => {
314704
- if (block.kind !== "paragraph")
314705
- return false;
314706
- return getParagraphInlineDirection(block.attrs) === "rtl";
314707
- }, determineColumn = (layout, fragmentX, page, fragmentY) => {
314708
- const columns = resolveColumnsForHit(layout, page, fragmentY);
314709
- if (!columns || columns.count <= 1)
314710
- return 0;
314711
- const pageWidth = page?.size?.w ?? layout.pageSize.w;
314712
- const margins = page?.margins ?? layout.pages[0]?.margins;
314713
- const marginLeft = Math.max(0, margins?.left ?? 0);
314714
- const marginRight = Math.max(0, margins?.right ?? 0);
314715
- return getColumnAtX(getColumnGeometry(normalizeColumnLayout(columns, Math.max(1, pageWidth - (marginLeft + marginRight)))), fragmentX, marginLeft);
314716
- }, determineTableColumn = (layout, fragment, page) => {
314717
- if (typeof fragment.columnIndex === "number") {
314718
- const count = resolveColumnsForHit(layout, page, fragment.y)?.count ?? 1;
314719
- return Math.max(0, Math.min(Math.max(0, count - 1), fragment.columnIndex));
314720
- }
314721
- return determineColumn(layout, fragment.x, page, fragment.y);
314722
- }, findLineIndexAtY = (lines, offsetY, fromLine, toLine) => {
314723
- if (!lines || lines.length === 0)
314724
- return null;
314725
- const lineCount = lines.length;
314726
- if (fromLine < 0 || toLine > lineCount || fromLine >= toLine)
314727
- return null;
314728
- let cursor = 0;
314729
- for (let i4 = fromLine;i4 < toLine; i4 += 1) {
314730
- const line = lines[i4];
314731
- if (!line)
314732
- return null;
314733
- const next2 = cursor + line.lineHeight;
314734
- if (offsetY >= cursor && offsetY < next2)
314735
- return i4;
314736
- cursor = next2;
314737
- }
314738
- return toLine - 1;
314739
- }, mapPointToPm = (block, line, x, isRTL, availableWidthOverride, alignmentOverride) => {
314740
- if (block.kind !== "paragraph")
314741
- return null;
314742
- const range = computeLinePmRange(block, line);
314743
- if (range.pmStart == null || range.pmEnd == null)
314744
- return null;
314745
- const result = findCharacterAtX(block, line, x, range.pmStart, availableWidthOverride, alignmentOverride);
314746
- let pmPosition = result.pmPosition;
314747
- if (isRTL) {
314748
- const charOffset = result.charOffset;
314749
- const charsInLine = Math.max(1, line.toChar - line.fromChar);
314750
- pmPosition = charOffsetToPm(block, line, Math.max(0, Math.min(charsInLine, charsInLine - charOffset)), range.pmStart);
314751
- }
314752
- return pmPosition;
314753
- }, calculatePageTopFallback = (layout, pageIndex) => {
314754
- const pageGap = layout.pageGap ?? 0;
314755
- let y$1 = 0;
314756
- for (let i4 = 0;i4 < pageIndex; i4++) {
314757
- const pageHeight = layout.pages[i4]?.size?.h ?? layout.pageSize.h;
314758
- y$1 += pageHeight + pageGap;
314759
- }
314760
- return y$1;
314761
- }, hitTestAtomicFragment = (pageHit, blocks2, measures, point5) => {
314762
- for (const fragment of pageHit.page.fragments) {
314763
- if (!isAtomicFragment(fragment))
314764
- continue;
314765
- const withinX = point5.x >= fragment.x && point5.x <= fragment.x + fragment.width;
314766
- const withinY = point5.y >= fragment.y && point5.y <= fragment.y + fragment.height;
314767
- if (!withinX || !withinY)
314768
- continue;
314769
- const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId);
314770
- if (blockIndex === -1)
314771
- continue;
314772
- const block = blocks2[blockIndex];
314773
- const measure = measures[blockIndex];
314774
- if (!block || !measure)
314775
- continue;
314776
- return {
314777
- fragment,
314778
- block,
314779
- measure,
314780
- pageIndex: pageHit.pageIndex,
314781
- pageY: 0
314782
- };
314783
- }
314784
- return null;
314785
- }, hitTestTableFragment = (pageHit, blocks2, measures, point5) => {
314786
- for (const fragment of pageHit.page.fragments) {
314787
- if (fragment.kind !== "table")
314788
- continue;
314789
- const tableFragment = fragment;
314790
- const withinX = point5.x >= tableFragment.x && point5.x <= tableFragment.x + tableFragment.width;
314791
- const withinY = point5.y >= tableFragment.y && point5.y <= tableFragment.y + tableFragment.height;
314792
- if (!withinX || !withinY)
314793
- continue;
314794
- const blockIndex = blocks2.findIndex((block$1) => block$1.id === tableFragment.blockId);
314795
- if (blockIndex === -1)
314796
- continue;
314797
- const block = blocks2[blockIndex];
314798
- const measure = measures[blockIndex];
314799
- if (!block || block.kind !== "table" || !measure || measure.kind !== "table")
314800
- continue;
314801
- const tableBlock = block;
314802
- const tableMeasure = measure;
314803
- const localX = point5.x - tableFragment.x;
314804
- const localY = point5.y - tableFragment.y;
314805
- let rowY = 0;
314806
- let rowIndex = -1;
314807
- if (tableMeasure.rows.length === 0 || tableBlock.rows.length === 0)
314808
- continue;
314809
- for (let r$1 = tableFragment.fromRow;r$1 < tableFragment.toRow && r$1 < tableMeasure.rows.length; r$1++) {
314810
- const rowMeasure$1 = tableMeasure.rows[r$1];
314811
- if (localY >= rowY && localY < rowY + rowMeasure$1.height) {
314812
- rowIndex = r$1;
314813
- break;
314814
- }
314815
- rowY += rowMeasure$1.height;
314816
- }
314817
- if (rowIndex === -1) {
314818
- rowIndex = Math.min(tableFragment.toRow - 1, tableMeasure.rows.length - 1);
314819
- if (rowIndex < tableFragment.fromRow)
314820
- continue;
314821
- }
314822
- const rowMeasure = tableMeasure.rows[rowIndex];
314823
- const row2 = tableBlock.rows[rowIndex];
314824
- if (!rowMeasure || !row2)
314825
- continue;
314826
- const firstCellGridStart = rowMeasure.cells[0]?.gridColumnStart ?? 0;
314827
- let colX = 0;
314828
- if (firstCellGridStart > 0 && tableMeasure.columnWidths)
314829
- for (let col = 0;col < firstCellGridStart && col < tableMeasure.columnWidths.length; col++)
314830
- colX += tableMeasure.columnWidths[col];
314831
- const initialColX = colX;
314832
- let colIndex = -1;
314833
- if (rowMeasure.cells.length === 0 || row2.cells.length === 0)
314834
- continue;
314835
- for (let c = 0;c < rowMeasure.cells.length; c++) {
314836
- const cellMeasure$1 = rowMeasure.cells[c];
314837
- if (localX >= colX && localX < colX + cellMeasure$1.width) {
314838
- colIndex = c;
314839
- break;
314840
- }
314841
- colX += cellMeasure$1.width;
314842
- }
314843
- if (colIndex === -1) {
314844
- if (localX < initialColX)
314845
- colIndex = 0;
314846
- else
314847
- colIndex = rowMeasure.cells.length - 1;
314848
- if (colIndex < 0)
314849
- continue;
314850
- }
314851
- const cellMeasure = rowMeasure.cells[colIndex];
314852
- const cell2 = row2.cells[colIndex];
314853
- if (!cellMeasure || !cell2)
314854
- continue;
314855
- const cellBlocks = cell2.blocks ?? (cell2.paragraph ? [cell2.paragraph] : []);
314856
- const rawMeasures = cellMeasure.blocks ?? (cellMeasure.paragraph ? [cellMeasure.paragraph] : []);
314857
- const cellBlockMeasures = (Array.isArray(rawMeasures) ? rawMeasures : []).filter((m$1) => m$1 != null && typeof m$1 === "object" && ("kind" in m$1));
314858
- let blockStartY = 0;
314859
- let blockStartGlobalLines = 0;
314860
- const getBlockHeight = (m$1) => {
314861
- if (!m$1)
314862
- return 0;
314863
- if ("totalHeight" in m$1 && typeof m$1.totalHeight === "number")
314864
- return m$1.totalHeight;
314865
- if ("height" in m$1 && typeof m$1.height === "number")
314866
- return m$1.height;
314867
- return 0;
314868
- };
314869
- let nearestParagraphHit = null;
314870
- for (let i4 = 0;i4 < cellBlocks.length && i4 < cellBlockMeasures.length; i4++) {
314871
- const cellBlock = cellBlocks[i4];
314872
- const cellBlockMeasure = cellBlockMeasures[i4];
314873
- if (cellBlock?.kind !== "paragraph" || cellBlockMeasure?.kind !== "paragraph") {
314874
- blockStartY += getBlockHeight(cellBlockMeasure);
314875
- continue;
314876
- }
314877
- const blockHeight = getBlockHeight(cellBlockMeasure);
314878
- const blockEndY = blockStartY + blockHeight;
314879
- const padding = cell2.attrs?.padding ?? {
314880
- top: 0,
314881
- left: 4,
314882
- right: 4,
314883
- bottom: 0
314884
- };
314885
- const cellLocalX = localX - colX - (padding.left ?? 4);
314886
- const cellLocalY = localY - rowY - (padding.top ?? 0);
314887
- const paragraphBlock = cellBlock;
314888
- const paragraphMeasure = cellBlockMeasure;
314889
- if (cellLocalY >= blockStartY && cellLocalY < blockEndY) {
314890
- const unclampedLocalY = cellLocalY - blockStartY;
314891
- const localYWithinBlock = Math.max(0, Math.min(unclampedLocalY, Math.max(blockHeight, 0)));
314892
- return {
314893
- fragment: tableFragment,
314894
- block: tableBlock,
314895
- measure: tableMeasure,
314896
- pageIndex: pageHit.pageIndex,
314897
- cellRowIndex: rowIndex,
314898
- cellColIndex: colIndex,
314899
- cellBlock: paragraphBlock,
314900
- cellMeasure: paragraphMeasure,
314901
- localX: Math.max(0, cellLocalX),
314902
- localY: Math.max(0, localYWithinBlock),
314903
- blockStartGlobal: blockStartGlobalLines
314904
- };
314905
- }
314906
- const distanceToBlock = cellLocalY < blockStartY ? blockStartY - cellLocalY : Math.max(0, cellLocalY - blockEndY);
314907
- if (!nearestParagraphHit || distanceToBlock < nearestParagraphHit.distance) {
314908
- const unclampedLocalY = cellLocalY - blockStartY;
314909
- nearestParagraphHit = {
314910
- cellBlock: paragraphBlock,
314911
- cellMeasure: paragraphMeasure,
314912
- localX: Math.max(0, cellLocalX),
314913
- localY: Math.max(0, Math.min(unclampedLocalY, Math.max(blockHeight, 0))),
314914
- blockStartGlobal: blockStartGlobalLines,
314915
- distance: distanceToBlock
314916
- };
314917
- }
314918
- blockStartY = blockEndY;
314919
- blockStartGlobalLines += paragraphMeasure.lines.length;
314920
- }
314921
- if (nearestParagraphHit)
314922
- return {
314923
- fragment: tableFragment,
314924
- block: tableBlock,
314925
- measure: tableMeasure,
314926
- pageIndex: pageHit.pageIndex,
314927
- cellRowIndex: rowIndex,
314928
- cellColIndex: colIndex,
314929
- cellBlock: nearestParagraphHit.cellBlock,
314930
- cellMeasure: nearestParagraphHit.cellMeasure,
314931
- localX: nearestParagraphHit.localX,
314932
- localY: nearestParagraphHit.localY,
314933
- blockStartGlobal: nearestParagraphHit.blockStartGlobal
314934
- };
314935
- }
314936
- return null;
314937
315833
  }, logSelectionMapDebug = (payload) => {}, rangesOverlap2 = (startA, endA, startB, endB) => {
314938
315834
  if (startA == null)
314939
315835
  return false;
@@ -316851,10 +317747,15 @@ menclose::after {
316851
317747
  this.#focusEditorAtFirstPosition();
316852
317748
  }
316853
317749
  #handleClickInHeaderFooterMode(event, x, y$1, pageIndex, pageLocalY) {
316854
- const activeSurfaceSelector = this.#deps?.getHeaderFooterSession()?.session?.mode === "footer" ? ".superdoc-page-footer" : ".superdoc-page-header";
317750
+ const session = this.#deps?.getHeaderFooterSession();
317751
+ const activeSurfaceSelector = session?.session?.mode === "footer" ? ".superdoc-page-footer" : ".superdoc-page-header";
316855
317752
  const visiblePointerSurface = resolveVisibleSurfaceAtPointer(event.target, event.clientX, event.clientY);
316856
317753
  const clickedInsideVisibleActiveSurface = visiblePointerSurface?.kind === "headerFooter" && visiblePointerSurface.surface.closest(activeSurfaceSelector) != null;
316857
317754
  if (visiblePointerSurface?.kind === "bodyContent") {
317755
+ const behindDocSection = (event.target instanceof Element ? event.target.closest("[data-behind-doc-section]") : null)?.dataset.behindDocSection;
317756
+ const sessionMode = session?.session?.mode;
317757
+ if (behindDocSection && behindDocSection === sessionMode)
317758
+ return false;
316858
317759
  this.#callbacks.exitHeaderFooterMode?.();
316859
317760
  return false;
316860
317761
  }
@@ -316950,6 +317851,8 @@ menclose::after {
316950
317851
  return false;
316951
317852
  if (fragmentHit.fragment.kind !== "image" && fragmentHit.fragment.kind !== "drawing")
316952
317853
  return false;
317854
+ if (fragmentHit.fragment.kind === "drawing" && fragmentHit.fragment.drawingKind === "textboxShape")
317855
+ return false;
316953
317856
  const editor = this.#deps?.getEditor();
316954
317857
  try {
316955
317858
  const tr = editor.state.tr.setSelection(NodeSelection.create(doc$12, hit.pos));
@@ -319803,7 +320706,8 @@ menclose::after {
319803
320706
  const surfaceElement = pageElement.querySelector(surfaceSelector);
319804
320707
  if (!surfaceElement)
319805
320708
  return null;
319806
- const entry = findSurfaceEntryAtPos(buildSurfacePmEntries(surfaceElement), pos);
320709
+ const behindDocFragments = Array.from(pageElement.querySelectorAll(`[data-behind-doc-section="${this.#session.mode}"]`));
320710
+ const entry = findSurfaceEntryAtPos([...buildSurfacePmEntries(surfaceElement), ...behindDocFragments.flatMap((frag) => buildSurfacePmEntries(frag))].sort((a2, b$1) => a2.pmStart - b$1.pmStart || a2.pmEnd - b$1.pmEnd), pos);
319807
320711
  if (!entry)
319808
320712
  return null;
319809
320713
  const pageRect = pageElement.getBoundingClientRect();
@@ -320967,13 +321871,13 @@ menclose::after {
320967
321871
  return;
320968
321872
  console.log(...args$1);
320969
321873
  }, 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;
320970
- var init_src_BnMjPHBh_es = __esm(() => {
321874
+ var init_src_C8MNSOR0_es = __esm(() => {
320971
321875
  init_rolldown_runtime_Bg48TavK_es();
320972
- init_SuperConverter_DBlOjc68_es();
321876
+ init_SuperConverter_kDrJISzz_es();
320973
321877
  init_jszip_C49i9kUs_es();
320974
321878
  init_xml_js_CqGKpaft_es();
320975
321879
  init_uuid_B2wVPhPi_es();
320976
- init_create_headless_toolbar_DWyoHv_L_es();
321880
+ init_create_headless_toolbar_D1v6sX42_es();
320977
321881
  init_constants_D9qj59G2_es();
320978
321882
  init_dist_B8HfvhaK_es();
320979
321883
  init_unified_Dsuw2be5_es();
@@ -328224,7 +329128,89 @@ ${err.toString()}`);
328224
329128
  return { style: attrs.style };
328225
329129
  } },
328226
329130
  wrapAttributes: { rendered: false },
328227
- attributes: { rendered: false }
329131
+ anchorData: { rendered: false },
329132
+ marginOffset: { rendered: false },
329133
+ attributes: { rendered: false },
329134
+ kind: {
329135
+ default: null,
329136
+ rendered: false
329137
+ },
329138
+ width: {
329139
+ default: null,
329140
+ renderDOM: (attrs) => {
329141
+ if (attrs.width == null)
329142
+ return {};
329143
+ return { "data-width": attrs.width };
329144
+ }
329145
+ },
329146
+ height: {
329147
+ default: null,
329148
+ renderDOM: (attrs) => {
329149
+ if (attrs.height == null)
329150
+ return {};
329151
+ return { "data-height": attrs.height };
329152
+ }
329153
+ },
329154
+ fillColor: {
329155
+ default: null,
329156
+ rendered: false
329157
+ },
329158
+ strokeColor: {
329159
+ default: null,
329160
+ rendered: false
329161
+ },
329162
+ strokeWidth: {
329163
+ default: null,
329164
+ rendered: false
329165
+ },
329166
+ rotation: {
329167
+ default: 0,
329168
+ rendered: false
329169
+ },
329170
+ flipH: {
329171
+ default: false,
329172
+ rendered: false
329173
+ },
329174
+ flipV: {
329175
+ default: false,
329176
+ rendered: false
329177
+ },
329178
+ wrap: {
329179
+ default: null,
329180
+ rendered: false
329181
+ },
329182
+ isAnchor: {
329183
+ default: false,
329184
+ rendered: false
329185
+ },
329186
+ drawingContent: {
329187
+ default: null,
329188
+ rendered: false
329189
+ },
329190
+ originalAttributes: {
329191
+ default: null,
329192
+ rendered: false
329193
+ },
329194
+ effectExtent: {
329195
+ default: null,
329196
+ rendered: false
329197
+ },
329198
+ lineEnds: {
329199
+ default: null,
329200
+ rendered: false
329201
+ },
329202
+ hidden: {
329203
+ default: false,
329204
+ rendered: false
329205
+ },
329206
+ isTextBox: {
329207
+ default: false,
329208
+ rendered: false
329209
+ },
329210
+ isWordArt: {
329211
+ default: false,
329212
+ rendered: false
329213
+ }
328228
329214
  };
328229
329215
  },
328230
329216
  parseDOM() {
@@ -328259,7 +329245,15 @@ ${err.toString()}`);
328259
329245
  return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
328260
329246
  }
328261
329247
  },
328262
- attributes: { rendered: false }
329248
+ attributes: { rendered: false },
329249
+ textInsets: {
329250
+ default: null,
329251
+ rendered: false
329252
+ },
329253
+ textVerticalAlign: {
329254
+ default: null,
329255
+ rendered: false
329256
+ }
328263
329257
  };
328264
329258
  },
328265
329259
  parseDOM() {
@@ -351666,14 +352660,21 @@ function print() { __p += __j.call(arguments, '') }
351666
352660
  return null;
351667
352661
  const localX = normalized.x - context.region.localX;
351668
352662
  const localY = (normalized.pageLocalY ?? normalized.y - context.region.pageIndex * (bodyPageHeight + pageGap)) - context.region.localY;
352663
+ const domHit = this.#resolveHeaderFooterDomHit(context, clientX, clientY);
352664
+ if (domHit) {
352665
+ const doc$3 = this.getActiveEditor().state?.doc;
352666
+ return {
352667
+ ...domHit,
352668
+ pos: doc$3 ? Math.max(0, Math.min(domHit.pos, doc$3.content.size)) : domHit.pos
352669
+ };
352670
+ }
351669
352671
  if (localX < 0 || localY < 0 || localX > context.region.width || localY > context.region.height)
351670
352672
  return null;
351671
352673
  const headerPoint = {
351672
352674
  x: localX,
351673
352675
  y: localY
351674
352676
  };
351675
- const geometryHit = clickToPositionGeometry(context.layout, context.blocks, context.measures, headerPoint) ?? null;
351676
- const hit = this.#resolveHeaderFooterDomHit(context, clientX, clientY) ?? geometryHit;
352677
+ const hit = clickToPositionGeometry(context.layout, context.blocks, context.measures, headerPoint) ?? null;
351677
352678
  if (!hit)
351678
352679
  return null;
351679
352680
  const doc$2 = this.getActiveEditor().state?.doc;
@@ -356644,11 +357645,11 @@ function print() { __p += __j.call(arguments, '') }
356644
357645
  ]);
356645
357646
  });
356646
357647
 
356647
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-Bw8pGh5l.es.js
357648
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-G-_4_UF5.es.js
356648
357649
  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;
356649
- var init_create_super_doc_ui_Bw8pGh5l_es = __esm(() => {
356650
- init_SuperConverter_DBlOjc68_es();
356651
- init_create_headless_toolbar_DWyoHv_L_es();
357650
+ var init_create_super_doc_ui_G__4_UF5_es = __esm(() => {
357651
+ init_SuperConverter_kDrJISzz_es();
357652
+ init_create_headless_toolbar_D1v6sX42_es();
356652
357653
  DEFAULT_TEXT_ALIGN_OPTIONS = [
356653
357654
  {
356654
357655
  label: "Left",
@@ -356939,16 +357940,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
356939
357940
 
356940
357941
  // ../../packages/superdoc/dist/super-editor.es.js
356941
357942
  var init_super_editor_es = __esm(() => {
356942
- init_src_BnMjPHBh_es();
356943
- init_SuperConverter_DBlOjc68_es();
357943
+ init_src_C8MNSOR0_es();
357944
+ init_SuperConverter_kDrJISzz_es();
356944
357945
  init_jszip_C49i9kUs_es();
356945
357946
  init_xml_js_CqGKpaft_es();
356946
- init_create_headless_toolbar_DWyoHv_L_es();
357947
+ init_create_headless_toolbar_D1v6sX42_es();
356947
357948
  init_constants_D9qj59G2_es();
356948
357949
  init_dist_B8HfvhaK_es();
356949
357950
  init_unified_Dsuw2be5_es();
356950
357951
  init_DocxZipper_FUsfThjV_es();
356951
- init_create_super_doc_ui_Bw8pGh5l_es();
357952
+ init_create_super_doc_ui_G__4_UF5_es();
356952
357953
  init_ui_C5PAS9hY_es();
356953
357954
  init_eventemitter3_BnGqBE_Q_es();
356954
357955
  init_errors_CNaD6vcg_es();
@@ -388467,7 +389468,43 @@ var lineBreakNodeToBreakBlock2 = (node3, { nextBlockId }) => {
388467
389468
  };
388468
389469
 
388469
389470
  // ../../packages/super-editor/src/editors/v1/core/layout-adapter/converters/shapes.ts
388470
- var WRAP_TYPES2, WRAP_TEXT_VALUES2, H_RELATIVE_VALUES2, V_RELATIVE_VALUES2, H_ALIGN_VALUES2, V_ALIGN_VALUES2, normalizeWrapType2 = (value) => {
389471
+ function hydrateTextboxDrawingContent2(node3, drawingBlock, context) {
389472
+ if (drawingBlock.drawingKind !== "textboxShape") {
389473
+ return drawingBlock;
389474
+ }
389475
+ return {
389476
+ ...drawingBlock,
389477
+ contentBlocks: toTextboxParagraphBlocks2(node3, context)
389478
+ };
389479
+ }
389480
+ var WRAP_TYPES2, WRAP_TEXT_VALUES2, H_RELATIVE_VALUES2, V_RELATIVE_VALUES2, H_ALIGN_VALUES2, V_ALIGN_VALUES2, TEXTBOX_CONTAINER_TYPES2, isParagraphNode2 = (node3) => node3?.type === "paragraph", toTextboxParagraphBlocks2 = (node3, context) => {
389481
+ const shapeTextboxNode = node3.type === "shapeTextbox" ? node3 : resolveNestedShapeTextboxNode2(node3);
389482
+ const paragraphToFlowBlocks2 = context.converters?.paragraphToFlowBlocks;
389483
+ if (!shapeTextboxNode || !paragraphToFlowBlocks2 || !Array.isArray(shapeTextboxNode.content)) {
389484
+ return [];
389485
+ }
389486
+ const textboxBlocks = [];
389487
+ for (const child of shapeTextboxNode.content) {
389488
+ if (!isParagraphNode2(child))
389489
+ continue;
389490
+ const convertedBlocks = paragraphToFlowBlocks2({
389491
+ para: child,
389492
+ nextBlockId: context.nextBlockId,
389493
+ positions: context.positions,
389494
+ storyKey: context.storyKey,
389495
+ trackedChangesConfig: context.trackedChangesConfig,
389496
+ bookmarks: context.bookmarks,
389497
+ hyperlinkConfig: context.hyperlinkConfig,
389498
+ themeColors: context.themeColors,
389499
+ converters: context.converters,
389500
+ converterContext: context.converterContext,
389501
+ enableComments: context.enableComments,
389502
+ previousParagraphFont: getLastParagraphFont2(textboxBlocks)
389503
+ });
389504
+ textboxBlocks.push(...convertedBlocks);
389505
+ }
389506
+ return textboxBlocks.filter((block) => block.kind === "paragraph");
389507
+ }, resolveNestedShapeTextboxNode2 = (node3) => Array.isArray(node3.content) ? node3.content.find((child) => child?.type === "shapeTextbox") : undefined, normalizeWrapType2 = (value) => {
388471
389508
  if (typeof value !== "string")
388472
389509
  return;
388473
389510
  return WRAP_TYPES2.has(value) ? value : undefined;
@@ -388609,12 +389646,21 @@ var WRAP_TYPES2, WRAP_TEXT_VALUES2, H_RELATIVE_VALUES2, V_RELATIVE_VALUES2, H_AL
388609
389646
  };
388610
389647
  var init_shapes = __esm(() => {
388611
389648
  init_utilities();
389649
+ init_paragraph2();
388612
389650
  WRAP_TYPES2 = new Set(["None", "Square", "Tight", "Through", "TopAndBottom", "Inline"]);
388613
389651
  WRAP_TEXT_VALUES2 = new Set(["bothSides", "left", "right", "largest"]);
388614
389652
  H_RELATIVE_VALUES2 = new Set(["column", "page", "margin"]);
388615
389653
  V_RELATIVE_VALUES2 = new Set(["paragraph", "page", "margin"]);
388616
389654
  H_ALIGN_VALUES2 = new Set(["left", "center", "right"]);
388617
389655
  V_ALIGN_VALUES2 = new Set(["top", "center", "bottom"]);
389656
+ TEXTBOX_CONTAINER_TYPES2 = new Set([
389657
+ "run",
389658
+ "link",
389659
+ "hyperlink",
389660
+ "structuredContent",
389661
+ "fieldAnnotation",
389662
+ "smartTag"
389663
+ ]);
388618
389664
  });
388619
389665
 
388620
389666
  // ../../packages/super-editor/src/editors/v1/core/layout-adapter/converters/content-block.ts
@@ -389657,14 +390703,14 @@ var isTableRowNode2 = (node3) => node3.type === "tableRow" || node3.type === "ta
389657
390703
  if (childNode.type === "shapeContainer" && context.converters?.shapeContainerNodeToDrawingBlock) {
389658
390704
  const drawingBlock = context.converters.shapeContainerNodeToDrawingBlock(childNode, context.nextBlockId, context.positions);
389659
390705
  if (drawingBlock && drawingBlock.kind === "drawing") {
389660
- blocks2.push(drawingBlock);
390706
+ blocks2.push(hydrateTextboxDrawingContent2(childNode, drawingBlock, context));
389661
390707
  }
389662
390708
  continue;
389663
390709
  }
389664
390710
  if (childNode.type === "shapeTextbox" && context.converters?.shapeTextboxNodeToDrawingBlock) {
389665
390711
  const drawingBlock = context.converters.shapeTextboxNodeToDrawingBlock(childNode, context.nextBlockId, context.positions);
389666
390712
  if (drawingBlock && drawingBlock.kind === "drawing") {
389667
- blocks2.push(drawingBlock);
390713
+ blocks2.push(hydrateTextboxDrawingContent2(childNode, drawingBlock, context));
389668
390714
  }
389669
390715
  continue;
389670
390716
  }
@@ -389821,9 +390867,31 @@ var init_table = __esm(() => {
389821
390867
  init_sdt();
389822
390868
  init_ooxml();
389823
390869
  init_direction();
390870
+ init_shapes();
389824
390871
  });
389825
390872
 
389826
390873
  // ../../packages/super-editor/src/editors/v1/core/layout-adapter/converters/paragraph.ts
390874
+ function getLastParagraphFont2(blocks2) {
390875
+ for (let i4 = blocks2.length - 1;i4 >= 0; i4--) {
390876
+ const block = blocks2[i4];
390877
+ if (block.kind === "paragraph") {
390878
+ const para = block;
390879
+ const firstRun = para.runs?.[0];
390880
+ if (!firstRun)
390881
+ continue;
390882
+ const run2 = firstRun;
390883
+ if (typeof run2.text === "string" && run2.text.length === 0) {
390884
+ continue;
390885
+ }
390886
+ const fontFamily = typeof run2.fontFamily === "string" ? run2.fontFamily.trim() : "";
390887
+ const fontSize = typeof run2.fontSize === "number" && Number.isFinite(run2.fontSize) ? run2.fontSize : NaN;
390888
+ if (fontFamily.length > 0 && fontSize > 0) {
390889
+ return { fontFamily, fontSize };
390890
+ }
390891
+ }
390892
+ }
390893
+ return;
390894
+ }
389827
390895
  var INLINE_CONVERTERS_REGISTRY2;
389828
390896
  var init_paragraph2 = __esm(() => {
389829
390897
  init_src2();
@@ -426853,7 +427921,7 @@ var init_run_properties_export = __esm(() => {
426853
427921
  });
426854
427922
 
426855
427923
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/r/r-translator.js
426856
- var XML_NODE_NAME13 = "w:r", SD_KEY_NAME2 = "run", REFERENCE_RUN_STYLE_BY_XML_NAME2, hasXmlNodeNamed2 = (node4, targetName) => {
427924
+ var XML_NODE_NAME13 = "w:r", SD_KEY_NAME2 = "run", REFERENCE_RUN_STYLE_BY_XML_NAME2, BLOCK_HOIST_TYPES2, hasXmlNodeNamed2 = (node4, targetName) => {
426857
427925
  if (!node4 || typeof node4 !== "object")
426858
427926
  return false;
426859
427927
  if (node4.name === targetName)
@@ -426976,6 +428044,12 @@ var XML_NODE_NAME13 = "w:r", SD_KEY_NAME2 = "run", REFERENCE_RUN_STYLE_BY_XML_NA
426976
428044
  const contentElements = rPrNode ? elements.filter((el) => el !== rPrNode) : elements;
426977
428045
  const childParams = { ...params3, nodes: contentElements };
426978
428046
  const content4 = nodeListHandler?.handler(childParams) || [];
428047
+ if (Array.isArray(content4) && content4.length > 0 && content4.every((child) => BLOCK_HOIST_TYPES2.has(child?.type))) {
428048
+ return content4.filter(Boolean).map((child) => ({
428049
+ ...child,
428050
+ marks: Array.isArray(child?.marks) ? child.marks : []
428051
+ }));
428052
+ }
426979
428053
  const contentWithRunMarks = (Array.isArray(content4) ? content4 : []).map((child) => {
426980
428054
  if (!child || typeof child !== "object")
426981
428055
  return child;
@@ -427198,6 +428272,7 @@ var init_r_translator = __esm(() => {
427198
428272
  "w:footnoteReference": "FootnoteReference",
427199
428273
  "w:endnoteReference": "EndnoteReference"
427200
428274
  };
428275
+ BLOCK_HOIST_TYPES2 = new Set(["shapeContainer"]);
427201
428276
  COMPLEX_SCRIPT_CODEPOINT_RANGES2 = [
427202
428277
  [1424, 2303],
427203
428278
  [2304, 4255],
@@ -445193,6 +446268,162 @@ var init_chart_helpers = __esm(() => {
445193
446268
  CHART_TYPE_NAMES2 = new Set(Object.keys(CHART_TYPE_MAP2));
445194
446269
  });
445195
446270
 
446271
+ // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/p/index.js
446272
+ var init_p = __esm(() => {
446273
+ init_p_translator();
446274
+ });
446275
+
446276
+ // ../../packages/super-editor/src/editors/v1/core/super-converter/v2/importer/paragraphNodeImporter.js
446277
+ var PARAGRAPH_PROPERTIES_XML_NAME3 = "w:pPr", hasMeaningfulParagraphContent3 = (elements = []) => elements.some((element3) => element3?.name && element3.name !== PARAGRAPH_PROPERTIES_XML_NAME3), findParagraphProperties2 = (elements = []) => elements.find((element3) => element3?.name === PARAGRAPH_PROPERTIES_XML_NAME3) ?? null, hasParagraphProperties2 = (elements = []) => elements.some((element3) => element3?.name === PARAGRAPH_PROPERTIES_XML_NAME3), cloneParagraphPropertiesForRenderedResult2 = (paragraphProperties) => {
446278
+ const elements = (paragraphProperties.elements || []).filter((element3) => element3?.name !== "w:sectPr").map((element3) => carbonCopy2(element3));
446279
+ if (elements.length === 0)
446280
+ return null;
446281
+ return {
446282
+ ...carbonCopy2(paragraphProperties),
446283
+ elements
446284
+ };
446285
+ }, inheritWrapperParagraphProperties2 = (blockFieldElement, paragraphProperties) => {
446286
+ if (!paragraphProperties)
446287
+ return blockFieldElement;
446288
+ const fieldElements = Array.isArray(blockFieldElement?.elements) ? blockFieldElement.elements : [];
446289
+ const firstParagraphIndex = fieldElements.findIndex((element3) => element3?.name === "w:p");
446290
+ if (firstParagraphIndex < 0)
446291
+ return blockFieldElement;
446292
+ const firstParagraph = fieldElements[firstParagraphIndex];
446293
+ const firstParagraphElements = Array.isArray(firstParagraph.elements) ? firstParagraph.elements : [];
446294
+ if (hasParagraphProperties2(firstParagraphElements))
446295
+ return blockFieldElement;
446296
+ const renderedParagraphProperties = cloneParagraphPropertiesForRenderedResult2(paragraphProperties);
446297
+ const inheritedFirstParagraph = {
446298
+ ...firstParagraph,
446299
+ elements: renderedParagraphProperties ? [renderedParagraphProperties, ...firstParagraphElements] : firstParagraphElements
446300
+ };
446301
+ return {
446302
+ ...blockFieldElement,
446303
+ attributes: {
446304
+ ...blockFieldElement.attributes || {},
446305
+ wrapperParagraphProperties: carbonCopy2(paragraphProperties)
446306
+ },
446307
+ elements: fieldElements.map((element3, index3) => index3 === firstParagraphIndex ? inheritedFirstParagraph : element3)
446308
+ };
446309
+ }, hoistBlockFieldNodes2 = (params3, paragraphNode) => {
446310
+ const paragraphElements = Array.isArray(paragraphNode?.elements) ? paragraphNode.elements : [];
446311
+ const blockFieldElements = paragraphElements.filter((element3) => BLOCK_FIELD_XML_NAMES2.has(element3?.name));
446312
+ if (blockFieldElements.length === 0)
446313
+ return null;
446314
+ const nodes = [];
446315
+ const remainingElements = paragraphElements.filter((element3) => !BLOCK_FIELD_XML_NAMES2.has(element3?.name));
446316
+ const wrapperParagraphProperties = findParagraphProperties2(remainingElements);
446317
+ const shouldTransferWrapperProperties = !hasMeaningfulParagraphContent3(remainingElements);
446318
+ if (hasMeaningfulParagraphContent3(remainingElements)) {
446319
+ const paragraph4 = translator121.encode({
446320
+ ...params3,
446321
+ nodes: [
446322
+ {
446323
+ ...paragraphNode,
446324
+ elements: remainingElements
446325
+ }
446326
+ ]
446327
+ });
446328
+ if (paragraph4) {
446329
+ nodes.push(paragraph4);
446330
+ }
446331
+ }
446332
+ blockFieldElements.forEach((blockFieldElement) => {
446333
+ const fieldElement = shouldTransferWrapperProperties ? inheritWrapperParagraphProperties2(blockFieldElement, wrapperParagraphProperties) : blockFieldElement;
446334
+ nodes.push(...params3.nodeListHandler.handler({
446335
+ ...params3,
446336
+ nodes: [fieldElement],
446337
+ path: [...params3.path || [], paragraphNode]
446338
+ }));
446339
+ });
446340
+ return nodes;
446341
+ }, handleParagraphNode4 = (params3) => {
446342
+ const { nodes } = params3;
446343
+ if (nodes.length === 0 || nodes[0].name !== "w:p") {
446344
+ return { nodes: [], consumed: 0 };
446345
+ }
446346
+ const hoistedNodes = hoistBlockFieldNodes2(params3, nodes[0]);
446347
+ if (hoistedNodes) {
446348
+ return { nodes: hoistedNodes, consumed: 1 };
446349
+ }
446350
+ const schemaNode = translator121.encode(params3);
446351
+ const newNodes = Array.isArray(schemaNode) ? schemaNode : schemaNode ? [schemaNode] : [];
446352
+ return { nodes: newNodes, consumed: 1 };
446353
+ }, paragraphNodeHandlerEntity2;
446354
+ var init_paragraphNodeImporter = __esm(() => {
446355
+ init_p();
446356
+ init_block_field_xml_names();
446357
+ paragraphNodeHandlerEntity2 = {
446358
+ handlerName: "paragraphNodeHandler",
446359
+ handler: handleParagraphNode4
446360
+ };
446361
+ });
446362
+
446363
+ // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/wp/helpers/import-drawingml-textbox.js
446364
+ function stripRunNodeMarks2(nodes) {
446365
+ if (!Array.isArray(nodes))
446366
+ return nodes;
446367
+ return nodes.map((node4) => {
446368
+ if (!node4 || typeof node4 !== "object")
446369
+ return node4;
446370
+ const stripped = node4.type === "run" && Array.isArray(node4.marks) && node4.marks.length > 0 ? { ...node4, marks: [] } : node4;
446371
+ if (Array.isArray(stripped.content)) {
446372
+ return { ...stripped, content: stripRunNodeMarks2(stripped.content) };
446373
+ }
446374
+ return stripped;
446375
+ });
446376
+ }
446377
+ function importDrawingMLTextbox2({
446378
+ params: params3,
446379
+ drawingNode,
446380
+ textBoxContent,
446381
+ bodyPr,
446382
+ baseAttrs = {},
446383
+ paragraphImporter
446384
+ }) {
446385
+ if (!textBoxContent) {
446386
+ return null;
446387
+ }
446388
+ const processedContent = preProcessTextBoxContent2(textBoxContent, params3);
446389
+ const textboxParagraphs = collectTextBoxParagraphs2(processedContent?.elements || []);
446390
+ const importParagraph = typeof paragraphImporter === "function" ? paragraphImporter : (paragraph4) => {
446391
+ const imported = handleParagraphNode4({
446392
+ ...params3,
446393
+ nodes: [paragraph4]
446394
+ });
446395
+ return imported?.nodes || [];
446396
+ };
446397
+ const rawNodes = textboxParagraphs.flatMap((paragraph4) => {
446398
+ const imported = importParagraph(paragraph4);
446399
+ return Array.isArray(imported) ? imported : imported ? [imported] : [];
446400
+ });
446401
+ const contentNodes = stripRunNodeMarks2(rawNodes);
446402
+ const { verticalAlign, insets } = extractBodyPrProperties2(bodyPr);
446403
+ return {
446404
+ type: "shapeContainer",
446405
+ attrs: {
446406
+ ...baseAttrs,
446407
+ drawingContent: drawingNode
446408
+ },
446409
+ content: [
446410
+ {
446411
+ type: "shapeTextbox",
446412
+ attrs: {
446413
+ textInsets: { top: insets.top, right: insets.right, bottom: insets.bottom, left: insets.left },
446414
+ textVerticalAlign: verticalAlign,
446415
+ attributes: {}
446416
+ },
446417
+ content: contentNodes
446418
+ }
446419
+ ]
446420
+ };
446421
+ }
446422
+ var init_import_drawingml_textbox = __esm(() => {
446423
+ init_textbox_content_helpers();
446424
+ init_paragraphNodeImporter();
446425
+ });
446426
+
445196
446427
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.js
445197
446428
  function handleImageNode3(node4, params3, isAnchor) {
445198
446429
  if (!node4)
@@ -445679,6 +446910,94 @@ function extractTextFromTextBox2(textBoxContent, bodyPr, params3 = {}) {
445679
446910
  wrap: wrap6
445680
446911
  };
445681
446912
  }
446913
+ function extractFieldInlineNodes2(node4) {
446914
+ if (node4?.name === "sd:autoPageNumber") {
446915
+ return [{ type: "page-number", attrs: { marksAsAttrs: [], instruction: "PAGE" } }];
446916
+ }
446917
+ if (node4?.name === "sd:totalPageNumber") {
446918
+ return [{ type: "total-page-number", attrs: { marksAsAttrs: [], instruction: "NUMPAGES" } }];
446919
+ }
446920
+ if (node4?.name === "sd:sectionPageCount") {
446921
+ const cachedText = node4?.attributes?.resolvedText ?? node4?.attributes?.importedCachedText ?? "";
446922
+ if (!cachedText)
446923
+ return [];
446924
+ return [{ type: "text", text: cachedText }];
446925
+ }
446926
+ return [];
446927
+ }
446928
+ function extractInlineNodesFromRun2(run2, params3) {
446929
+ if (!run2?.elements)
446930
+ return [];
446931
+ const nodes = [];
446932
+ run2.elements.forEach((el) => {
446933
+ if (el.name === "w:t" || el.name === "w:delText") {
446934
+ const textNode = el.elements?.find((n) => n.type === "text");
446935
+ if (!textNode || typeof textNode.text !== "string")
446936
+ return;
446937
+ const cleanedText = textNode.text.replace(/\[\[sdspace\]\]/g, " ");
446938
+ if (cleanedText.length > 0) {
446939
+ nodes.push({ type: "text", text: cleanedText });
446940
+ }
446941
+ } else if (el.name === "w:tab") {
446942
+ nodes.push({ type: "text", text: "\t" });
446943
+ } else if (el.name === "w:br") {
446944
+ nodes.push({ type: "lineBreak", attrs: {} });
446945
+ } else if (el.name === "sd:autoPageNumber" || el.name === "sd:totalPageNumber" || el.name === "sd:sectionPageCount") {
446946
+ nodes.push(...extractFieldInlineNodes2(el));
446947
+ } else if (el.name === "w:drawing") {
446948
+ const inline = el.elements?.find((child) => child?.name === "wp:inline");
446949
+ if (!inline)
446950
+ return;
446951
+ const imagePm = handleImageNode3(inline, { ...params3, nodes: [el] }, false);
446952
+ if (imagePm?.type === "image" && imagePm.attrs?.hidden !== true) {
446953
+ nodes.push(imagePm);
446954
+ }
446955
+ }
446956
+ });
446957
+ return nodes;
446958
+ }
446959
+ function paragraphToPmParagraph2(paragraph4, params3) {
446960
+ const paragraphNode = collectTextBoxParagraphs2([paragraph4])[0];
446961
+ if (!paragraphNode)
446962
+ return null;
446963
+ const paragraphProperties = resolveParagraphPropertiesForTextBox2(paragraphNode, params3);
446964
+ const alignment = extractParagraphAlignment2(paragraphNode) || "left";
446965
+ const content4 = [];
446966
+ let pendingRunContent = [];
446967
+ const flushPendingRun = () => {
446968
+ if (pendingRunContent.length === 0)
446969
+ return;
446970
+ content4.push({ type: "run", attrs: {}, content: pendingRunContent });
446971
+ pendingRunContent = [];
446972
+ };
446973
+ (paragraphNode.elements || []).forEach((element3) => {
446974
+ if (element3?.name === "w:r") {
446975
+ const inlineParts = extractInlineNodesFromRun2(element3, params3);
446976
+ inlineParts.forEach((part) => {
446977
+ if (part?.type === "image") {
446978
+ flushPendingRun();
446979
+ content4.push(part);
446980
+ return;
446981
+ }
446982
+ pendingRunContent.push(part);
446983
+ });
446984
+ return;
446985
+ }
446986
+ if (element3?.name?.startsWith("sd:")) {
446987
+ const runContent = extractFieldInlineNodes2(element3);
446988
+ if (runContent.length > 0) {
446989
+ pendingRunContent.push(...runContent);
446990
+ }
446991
+ }
446992
+ });
446993
+ flushPendingRun();
446994
+ return {
446995
+ type: "paragraph",
446996
+ attrs: { paragraphProperties, textAlign: alignment },
446997
+ content: content4,
446998
+ marks: []
446999
+ };
447000
+ }
445682
447001
  function getVectorShape2({
445683
447002
  params: params3,
445684
447003
  node: node4,
@@ -445730,14 +447049,46 @@ function getVectorShape2({
445730
447049
  const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
445731
447050
  const bodyPr = wsp.elements?.find((el) => el.name === "wps:bodyPr");
445732
447051
  const nonVisualShapeProps = wsp.elements?.find((el) => el.name === "wps:cNvSpPr");
447052
+ const isWordArt = bodyPr?.attributes?.["fromWordArt"] === "1";
447053
+ const isTextBox = nonVisualShapeProps?.attributes?.["txBox"] === "1";
447054
+ if (isTextBox && textBoxContent) {
447055
+ return importDrawingMLTextbox2({
447056
+ params: params3,
447057
+ drawingNode: drawingNode?.name === "w:drawing" ? drawingNode : null,
447058
+ textBoxContent,
447059
+ bodyPr,
447060
+ baseAttrs: {
447061
+ ...schemaAttrs,
447062
+ width,
447063
+ height,
447064
+ rotation,
447065
+ flipH,
447066
+ flipV,
447067
+ fillColor,
447068
+ strokeColor,
447069
+ strokeWidth,
447070
+ lineEnds,
447071
+ effectExtent,
447072
+ marginOffset,
447073
+ anchorData,
447074
+ wrap: wrap6,
447075
+ isAnchor,
447076
+ isWordArt,
447077
+ isTextBox,
447078
+ originalAttributes: node4?.attributes
447079
+ },
447080
+ paragraphImporter: params3?.nodeListHandler != null ? undefined : (paragraph4) => {
447081
+ const imported = paragraphToPmParagraph2(paragraph4, params3);
447082
+ return Array.isArray(imported) ? imported : imported ? [imported] : [];
447083
+ }
447084
+ });
447085
+ }
445733
447086
  let textContent2 = null;
445734
447087
  let textAlign = "left";
445735
447088
  if (textBoxContent) {
445736
447089
  textContent2 = extractTextFromTextBox2(textBoxContent, bodyPr, params3);
445737
447090
  textAlign = textContent2?.horizontalAlign || "left";
445738
447091
  }
445739
- const isWordArt = bodyPr?.attributes?.["fromWordArt"] === "1";
445740
- const isTextBox = nonVisualShapeProps?.attributes?.["txBox"] === "1";
445741
447092
  return {
445742
447093
  type: "vectorShape",
445743
447094
  attrs: {
@@ -445876,6 +447227,38 @@ var DRAWING_XML_TAG2 = "w:drawing", SHAPE_URI2 = "http://schemas.microsoft.com/o
445876
447227
  if (result)
445877
447228
  return result;
445878
447229
  }
447230
+ const nonVisualShapeProps = wsp.elements?.find((el) => el.name === "wps:cNvSpPr");
447231
+ const isTextBox = nonVisualShapeProps?.attributes?.["txBox"] === "1";
447232
+ if (isTextBox && textBoxContent) {
447233
+ const bodyPr = wsp.elements?.find((el) => el.name === "wps:bodyPr");
447234
+ const drawingNode = params3.nodes?.[0];
447235
+ const result = importDrawingMLTextbox2({
447236
+ params: params3,
447237
+ drawingNode: drawingNode?.name === "w:drawing" ? drawingNode : null,
447238
+ textBoxContent,
447239
+ bodyPr,
447240
+ baseAttrs: {
447241
+ width: size3?.width,
447242
+ height: size3?.height,
447243
+ marginOffset,
447244
+ anchorData,
447245
+ wrap: wrap6,
447246
+ isAnchor,
447247
+ isTextBox: true,
447248
+ originalAttributes: node4?.attributes,
447249
+ ...params3.nodes?.[0]?.name === "w:drawing" ? { drawingContent: params3.nodes[0] } : {}
447250
+ },
447251
+ paragraphImporter: params3?.nodeListHandler != null ? undefined : (paragraph4) => {
447252
+ const imported = paragraphToPmParagraph2(paragraph4, params3);
447253
+ return Array.isArray(imported) ? imported : imported ? [imported] : [];
447254
+ }
447255
+ });
447256
+ if (result?.attrs && isHidden) {
447257
+ result.attrs.hidden = true;
447258
+ }
447259
+ if (result)
447260
+ return result;
447261
+ }
445879
447262
  const fallbackType = textBoxContent ? "textbox" : "drawing";
445880
447263
  const placeholder = buildShapePlaceholder2(node4, size3, padding, marginOffset, fallbackType);
445881
447264
  if (placeholder?.attrs && isHidden) {
@@ -446172,6 +447555,7 @@ var init_encode_image_node_helpers = __esm(() => {
446172
447555
  init_tiff_converter();
446173
447556
  init_textbox_content_helpers();
446174
447557
  init_chart_helpers();
447558
+ init_import_drawingml_textbox();
446175
447559
  });
446176
447560
 
446177
447561
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/wp/anchor/helpers/handle-anchor-node.js
@@ -448511,11 +449895,6 @@ var init_translate_document_section = __esm(() => {
448511
449895
  init_translateChildNodes();
448512
449896
  });
448513
449897
 
448514
- // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/p/index.js
448515
- var init_p = __esm(() => {
448516
- init_p_translator();
448517
- });
448518
-
448519
449898
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/sdt/helpers/translate-document-part-obj.js
448520
449899
  function translateDocumentPartObj2(params3) {
448521
449900
  const { node: node4 } = params3;
@@ -452215,93 +453594,6 @@ var init_textNodeImporter = __esm(() => {
452215
453594
  };
452216
453595
  });
452217
453596
 
452218
- // ../../packages/super-editor/src/editors/v1/core/super-converter/v2/importer/paragraphNodeImporter.js
452219
- var PARAGRAPH_PROPERTIES_XML_NAME3 = "w:pPr", hasMeaningfulParagraphContent3 = (elements = []) => elements.some((element3) => element3?.name && element3.name !== PARAGRAPH_PROPERTIES_XML_NAME3), findParagraphProperties2 = (elements = []) => elements.find((element3) => element3?.name === PARAGRAPH_PROPERTIES_XML_NAME3) ?? null, hasParagraphProperties2 = (elements = []) => elements.some((element3) => element3?.name === PARAGRAPH_PROPERTIES_XML_NAME3), cloneParagraphPropertiesForRenderedResult2 = (paragraphProperties) => {
452220
- const elements = (paragraphProperties.elements || []).filter((element3) => element3?.name !== "w:sectPr").map((element3) => carbonCopy2(element3));
452221
- if (elements.length === 0)
452222
- return null;
452223
- return {
452224
- ...carbonCopy2(paragraphProperties),
452225
- elements
452226
- };
452227
- }, inheritWrapperParagraphProperties2 = (blockFieldElement, paragraphProperties) => {
452228
- if (!paragraphProperties)
452229
- return blockFieldElement;
452230
- const fieldElements = Array.isArray(blockFieldElement?.elements) ? blockFieldElement.elements : [];
452231
- const firstParagraphIndex = fieldElements.findIndex((element3) => element3?.name === "w:p");
452232
- if (firstParagraphIndex < 0)
452233
- return blockFieldElement;
452234
- const firstParagraph = fieldElements[firstParagraphIndex];
452235
- const firstParagraphElements = Array.isArray(firstParagraph.elements) ? firstParagraph.elements : [];
452236
- if (hasParagraphProperties2(firstParagraphElements))
452237
- return blockFieldElement;
452238
- const renderedParagraphProperties = cloneParagraphPropertiesForRenderedResult2(paragraphProperties);
452239
- const inheritedFirstParagraph = {
452240
- ...firstParagraph,
452241
- elements: renderedParagraphProperties ? [renderedParagraphProperties, ...firstParagraphElements] : firstParagraphElements
452242
- };
452243
- return {
452244
- ...blockFieldElement,
452245
- attributes: {
452246
- ...blockFieldElement.attributes || {},
452247
- wrapperParagraphProperties: carbonCopy2(paragraphProperties)
452248
- },
452249
- elements: fieldElements.map((element3, index3) => index3 === firstParagraphIndex ? inheritedFirstParagraph : element3)
452250
- };
452251
- }, hoistBlockFieldNodes2 = (params3, paragraphNode) => {
452252
- const paragraphElements = Array.isArray(paragraphNode?.elements) ? paragraphNode.elements : [];
452253
- const blockFieldElements = paragraphElements.filter((element3) => BLOCK_FIELD_XML_NAMES2.has(element3?.name));
452254
- if (blockFieldElements.length === 0)
452255
- return null;
452256
- const nodes = [];
452257
- const remainingElements = paragraphElements.filter((element3) => !BLOCK_FIELD_XML_NAMES2.has(element3?.name));
452258
- const wrapperParagraphProperties = findParagraphProperties2(remainingElements);
452259
- const shouldTransferWrapperProperties = !hasMeaningfulParagraphContent3(remainingElements);
452260
- if (hasMeaningfulParagraphContent3(remainingElements)) {
452261
- const paragraph4 = translator121.encode({
452262
- ...params3,
452263
- nodes: [
452264
- {
452265
- ...paragraphNode,
452266
- elements: remainingElements
452267
- }
452268
- ]
452269
- });
452270
- if (paragraph4) {
452271
- nodes.push(paragraph4);
452272
- }
452273
- }
452274
- blockFieldElements.forEach((blockFieldElement) => {
452275
- const fieldElement = shouldTransferWrapperProperties ? inheritWrapperParagraphProperties2(blockFieldElement, wrapperParagraphProperties) : blockFieldElement;
452276
- nodes.push(...params3.nodeListHandler.handler({
452277
- ...params3,
452278
- nodes: [fieldElement],
452279
- path: [...params3.path || [], paragraphNode]
452280
- }));
452281
- });
452282
- return nodes;
452283
- }, handleParagraphNode4 = (params3) => {
452284
- const { nodes } = params3;
452285
- if (nodes.length === 0 || nodes[0].name !== "w:p") {
452286
- return { nodes: [], consumed: 0 };
452287
- }
452288
- const hoistedNodes = hoistBlockFieldNodes2(params3, nodes[0]);
452289
- if (hoistedNodes) {
452290
- return { nodes: hoistedNodes, consumed: 1 };
452291
- }
452292
- const schemaNode = translator121.encode(params3);
452293
- const newNodes = Array.isArray(schemaNode) ? schemaNode : schemaNode ? [schemaNode] : [];
452294
- return { nodes: newNodes, consumed: 1 };
452295
- }, paragraphNodeHandlerEntity2;
452296
- var init_paragraphNodeImporter = __esm(() => {
452297
- init_p();
452298
- init_block_field_xml_names();
452299
- paragraphNodeHandlerEntity2 = {
452300
- handlerName: "paragraphNodeHandler",
452301
- handler: handleParagraphNode4
452302
- };
452303
- });
452304
-
452305
453597
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v2/importer/sdtNodeImporter.js
452306
453598
  var handleSdtNode2 = (params3) => {
452307
453599
  const { nodes } = params3;
@@ -456386,9 +457678,16 @@ function handleShapeTextboxImport2({ params: params3, pict }) {
456386
457678
  }
456387
457679
  const parsedStyle = parseInlineStyles2(shapeAttrs.style);
456388
457680
  const shapeStyle = buildStyles2(parsedStyle);
457681
+ const positionData = extractPositionData2(parsedStyle);
456389
457682
  if (shapeStyle) {
456390
457683
  schemaAttrs.style = shapeStyle;
456391
457684
  }
457685
+ if (positionData.anchorData) {
457686
+ schemaAttrs.anchorData = positionData.anchorData;
457687
+ }
457688
+ if (positionData.marginOffset) {
457689
+ schemaAttrs.marginOffset = positionData.marginOffset;
457690
+ }
456392
457691
  const textbox = shape.elements?.find((el) => el.name === "v:textbox");
456393
457692
  const wrap6 = shape.elements?.find((el) => el.name === "w10:wrap");
456394
457693
  if (wrap6?.attributes) {
@@ -456431,6 +457730,44 @@ function buildStyles2(styleObject) {
456431
457730
  }
456432
457731
  return style2;
456433
457732
  }
457733
+ function extractPositionData2(styleObject) {
457734
+ const anchorData = {};
457735
+ const marginOffset = {};
457736
+ if (styleObject["mso-position-horizontal"]) {
457737
+ anchorData.alignH = styleObject["mso-position-horizontal"];
457738
+ }
457739
+ if (styleObject["mso-position-horizontal-relative"]) {
457740
+ anchorData.hRelativeFrom = styleObject["mso-position-horizontal-relative"];
457741
+ }
457742
+ if (styleObject["mso-position-vertical"]) {
457743
+ anchorData.alignV = styleObject["mso-position-vertical"];
457744
+ }
457745
+ if (styleObject["mso-position-vertical-relative"]) {
457746
+ anchorData.vRelativeFrom = styleObject["mso-position-vertical-relative"];
457747
+ }
457748
+ if (styleObject["margin-left"] != null) {
457749
+ marginOffset.horizontal = convertToPixels2(styleObject["margin-left"]);
457750
+ }
457751
+ if (styleObject["margin-top"] != null) {
457752
+ marginOffset.top = convertToPixels2(styleObject["margin-top"]);
457753
+ }
457754
+ return {
457755
+ ...Object.keys(anchorData).length > 0 ? { anchorData } : {},
457756
+ ...Object.keys(marginOffset).length > 0 ? { marginOffset } : {}
457757
+ };
457758
+ }
457759
+ function convertToPixels2(value) {
457760
+ const num = parseFloat(value);
457761
+ if (Number.isNaN(num))
457762
+ return 0;
457763
+ if (value.endsWith("pt"))
457764
+ return num * 96 / 72;
457765
+ if (value.endsWith("in"))
457766
+ return num * 96;
457767
+ if (value.endsWith("px"))
457768
+ return num;
457769
+ return num;
457770
+ }
456434
457771
  var init_handle_shape_textbox_import = __esm(() => {
456435
457772
  init_docxImporter();
456436
457773
  init_paragraphNodeImporter();
@@ -456512,12 +457849,12 @@ function handleShapeImageWatermarkImport2({ params: params3, pict }) {
456512
457849
  alignV: vPosition
456513
457850
  },
456514
457851
  size: {
456515
- width: convertToPixels2(width),
456516
- height: convertToPixels2(height)
457852
+ width: convertToPixels3(width),
457853
+ height: convertToPixels3(height)
456517
457854
  },
456518
457855
  marginOffset: {
456519
- horizontal: convertToPixels2(position5.marginLeft),
456520
- top: convertToPixels2(position5.marginTop)
457856
+ horizontal: convertToPixels3(position5.marginLeft),
457857
+ top: convertToPixels3(position5.marginTop)
456521
457858
  },
456522
457859
  ...gain && { gain },
456523
457860
  ...blacklevel && { blacklevel }
@@ -456551,7 +457888,7 @@ function parseVmlStyle2(style2) {
456551
457888
  }
456552
457889
  return result;
456553
457890
  }
456554
- function convertToPixels2(value) {
457891
+ function convertToPixels3(value) {
456555
457892
  if (typeof value === "number")
456556
457893
  return value;
456557
457894
  if (!value || typeof value !== "string")
@@ -456643,8 +457980,8 @@ function handleShapeTextWatermarkImport2({ pict }) {
456643
457980
  const wrap6 = shape.elements?.find((el) => el.name === "w10:wrap");
456644
457981
  const wrapAttrs = wrap6?.attributes || {};
456645
457982
  const wrapType = wrapAttrs.type || "none";
456646
- const widthPx = convertToPixels3(width);
456647
- const heightPx = convertToPixels3(height);
457983
+ const widthPx = convertToPixels4(width);
457984
+ const heightPx = convertToPixels4(height);
456648
457985
  const sanitizedOpacity = sanitizeNumeric2(parseVmlOpacity2(opacity), DEFAULT_VML_TEXT_WATERMARK_OPACITY2, 0, 1);
456649
457986
  const sanitizedRotation = sanitizeNumeric2(rotation, 0, -360, 360);
456650
457987
  const svgResult = generateTextWatermarkSVG2({
@@ -456676,8 +458013,8 @@ function handleShapeTextWatermarkImport2({ pict }) {
456676
458013
  vPosition,
456677
458014
  hRelativeTo,
456678
458015
  vRelativeTo,
456679
- marginLeft: convertToPixels3(position5.marginLeft),
456680
- marginTop: convertToPixels3(position5.marginTop),
458016
+ marginLeft: convertToPixels4(position5.marginLeft),
458017
+ marginTop: convertToPixels4(position5.marginTop),
456681
458018
  width: widthPx,
456682
458019
  height: heightPx,
456683
458020
  svgWidth: svgResult.svgWidth,
@@ -456942,7 +458279,7 @@ function parseVmlStyle3(style2) {
456942
458279
  }
456943
458280
  return result;
456944
458281
  }
456945
- function convertToPixels3(value) {
458282
+ function convertToPixels4(value) {
456946
458283
  if (typeof value === "number")
456947
458284
  return value;
456948
458285
  if (!value || typeof value !== "string")
@@ -457009,16 +458346,83 @@ var init_pict_node_type_strategy = __esm(() => {
457009
458346
  init_handle_shape_text_watermark_import();
457010
458347
  });
457011
458348
 
458349
+ // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/wp/helpers/translate-drawingml-textbox.js
458350
+ function translateDrawingMLTextbox2(params3) {
458351
+ const { node: node4 } = params3;
458352
+ const drawingContent = node4?.attrs?.drawingContent;
458353
+ const shapeTextbox = node4?.content?.find((child) => child?.type === "shapeTextbox");
458354
+ if (!drawingContent || !shapeTextbox) {
458355
+ return null;
458356
+ }
458357
+ const drawing = carbonCopy2(drawingContent);
458358
+ const liveParagraphs = translateChildNodes2({
458359
+ ...params3,
458360
+ node: shapeTextbox
458361
+ });
458362
+ const txbxContent = findTextboxContentNode2(drawing);
458363
+ if (!txbxContent) {
458364
+ return null;
458365
+ }
458366
+ txbxContent.elements = liveParagraphs;
458367
+ const alternateContent = {
458368
+ name: "mc:AlternateContent",
458369
+ elements: [
458370
+ {
458371
+ name: "mc:Choice",
458372
+ attributes: { Requires: "wps" },
458373
+ elements: [drawing]
458374
+ }
458375
+ ]
458376
+ };
458377
+ return wrapTextInRun2(alternateContent);
458378
+ }
458379
+ function findTextboxContentNode2(node4) {
458380
+ if (!node4 || typeof node4 !== "object")
458381
+ return null;
458382
+ if (node4.name === "w:txbxContent")
458383
+ return node4;
458384
+ if (!Array.isArray(node4.elements))
458385
+ return null;
458386
+ for (const child of node4.elements) {
458387
+ const found3 = findTextboxContentNode2(child);
458388
+ if (found3)
458389
+ return found3;
458390
+ }
458391
+ return null;
458392
+ }
458393
+ var init_translate_drawingml_textbox = __esm(() => {
458394
+ init_translateChildNodes();
458395
+ init_exporter();
458396
+ });
458397
+
457012
458398
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/pict/helpers/translate-shape-container.js
457013
458399
  function translateShapeContainer2(params3) {
457014
458400
  const { node: node4 } = params3;
458401
+ if (node4?.attrs?.drawingContent) {
458402
+ const run2 = translateDrawingMLTextbox2(params3);
458403
+ if (run2) {
458404
+ return {
458405
+ name: "w:p",
458406
+ elements: [run2]
458407
+ };
458408
+ }
458409
+ return {
458410
+ name: "w:p",
458411
+ elements: [wrapTextInRun2(node4.attrs.drawingContent)]
458412
+ };
458413
+ }
457015
458414
  const elements = translateChildNodes2(params3);
458415
+ const shapeAttributes = {
458416
+ ...node4.attrs.attributes,
458417
+ fillcolor: node4.attrs.fillcolor
458418
+ };
458419
+ const style2 = buildShapeStyle2(node4.attrs);
458420
+ if (style2) {
458421
+ shapeAttributes.style = style2;
458422
+ }
457016
458423
  const shape = {
457017
458424
  name: "v:shape",
457018
- attributes: {
457019
- ...node4.attrs.attributes,
457020
- fillcolor: node4.attrs.fillcolor
457021
- },
458425
+ attributes: shapeAttributes,
457022
458426
  elements: [
457023
458427
  ...elements,
457024
458428
  ...node4.attrs.wrapAttributes ? [
@@ -457041,9 +458445,43 @@ function translateShapeContainer2(params3) {
457041
458445
  elements: [wrapTextInRun2(pict)]
457042
458446
  };
457043
458447
  }
458448
+ function buildShapeStyle2(attrs) {
458449
+ const originalStyle = parseInlineStyles2(attrs.attributes?.style);
458450
+ const managedStyle = parseInlineStyles2(attrs.style);
458451
+ const style2 = {
458452
+ ...originalStyle,
458453
+ ...managedStyle
458454
+ };
458455
+ if (attrs.marginOffset?.horizontal !== undefined) {
458456
+ style2["margin-left"] = `${convertToPt2(attrs.marginOffset.horizontal)}pt`;
458457
+ }
458458
+ if (attrs.marginOffset?.top !== undefined) {
458459
+ style2["margin-top"] = `${convertToPt2(attrs.marginOffset.top)}pt`;
458460
+ }
458461
+ if (attrs.anchorData?.alignH) {
458462
+ style2["mso-position-horizontal"] = attrs.anchorData.alignH;
458463
+ }
458464
+ if (attrs.anchorData?.hRelativeFrom) {
458465
+ style2["mso-position-horizontal-relative"] = attrs.anchorData.hRelativeFrom;
458466
+ }
458467
+ if (attrs.anchorData?.alignV) {
458468
+ style2["mso-position-vertical"] = attrs.anchorData.alignV;
458469
+ }
458470
+ if (attrs.anchorData?.vRelativeFrom) {
458471
+ style2["mso-position-vertical-relative"] = attrs.anchorData.vRelativeFrom;
458472
+ }
458473
+ const entries = Object.entries(style2);
458474
+ if (entries.length === 0)
458475
+ return;
458476
+ return entries.map(([prop, value]) => `${prop}:${value}`).join(";");
458477
+ }
458478
+ function convertToPt2(pixels) {
458479
+ return pixels * 72 / 96;
458480
+ }
457044
458481
  var init_translate_shape_container = __esm(() => {
457045
458482
  init_translateChildNodes();
457046
458483
  init_exporter();
458484
+ init_translate_drawingml_textbox();
457047
458485
  });
457048
458486
 
457049
458487
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/pict/helpers/translate-shape-textbox.js
@@ -457268,18 +458706,18 @@ function buildVmlStyle2(attrs) {
457268
458706
  styles.push("position:absolute");
457269
458707
  if (attrs.size) {
457270
458708
  if (attrs.size.width) {
457271
- styles.push(`width:${convertToPt2(attrs.size.width)}pt`);
458709
+ styles.push(`width:${convertToPt3(attrs.size.width)}pt`);
457272
458710
  }
457273
458711
  if (attrs.size.height) {
457274
- styles.push(`height:${convertToPt2(attrs.size.height)}pt`);
458712
+ styles.push(`height:${convertToPt3(attrs.size.height)}pt`);
457275
458713
  }
457276
458714
  }
457277
458715
  if (attrs.marginOffset) {
457278
458716
  if (attrs.marginOffset.horizontal !== undefined) {
457279
- styles.push(`margin-left:${convertToPt2(attrs.marginOffset.horizontal)}pt`);
458717
+ styles.push(`margin-left:${convertToPt3(attrs.marginOffset.horizontal)}pt`);
457280
458718
  }
457281
458719
  if (attrs.marginOffset.top !== undefined) {
457282
- styles.push(`margin-top:${convertToPt2(attrs.marginOffset.top)}pt`);
458720
+ styles.push(`margin-top:${convertToPt3(attrs.marginOffset.top)}pt`);
457283
458721
  }
457284
458722
  }
457285
458723
  if (attrs.wrap?.attrs?.behindDoc) {
@@ -457303,7 +458741,7 @@ function buildVmlStyle2(attrs) {
457303
458741
  styles.push("mso-height-percent:0");
457304
458742
  return styles.join(";");
457305
458743
  }
457306
- function convertToPt2(pixels) {
458744
+ function convertToPt3(pixels) {
457307
458745
  return pixels * 72 / 96;
457308
458746
  }
457309
458747
  var init_translate_image_watermark = () => {};
@@ -457443,10 +458881,10 @@ function buildVmlStyle3(attrs, wmData) {
457443
458881
  styles.push("position:absolute");
457444
458882
  if (attrs.marginOffset) {
457445
458883
  if (attrs.marginOffset.horizontal !== undefined) {
457446
- styles.push(`margin-left:${convertToPt3(attrs.marginOffset.horizontal)}pt`);
458884
+ styles.push(`margin-left:${convertToPt4(attrs.marginOffset.horizontal)}pt`);
457447
458885
  }
457448
458886
  if (attrs.marginOffset.top !== undefined) {
457449
- styles.push(`margin-top:${convertToPt3(attrs.marginOffset.top)}pt`);
458887
+ styles.push(`margin-top:${convertToPt4(attrs.marginOffset.top)}pt`);
457450
458888
  }
457451
458889
  } else {
457452
458890
  styles.push("margin-left:0.05pt");
@@ -457454,10 +458892,10 @@ function buildVmlStyle3(attrs, wmData) {
457454
458892
  }
457455
458893
  if (attrs.size) {
457456
458894
  if (attrs.size.width) {
457457
- styles.push(`width:${convertToPt3(attrs.size.width)}pt`);
458895
+ styles.push(`width:${convertToPt4(attrs.size.width)}pt`);
457458
458896
  }
457459
458897
  if (attrs.size.height) {
457460
- styles.push(`height:${convertToPt3(attrs.size.height)}pt`);
458898
+ styles.push(`height:${convertToPt4(attrs.size.height)}pt`);
457461
458899
  }
457462
458900
  }
457463
458901
  const wrapType = attrs.wrap?.type;
@@ -457507,7 +458945,7 @@ function buildTextpathStyle2(wmData) {
457507
458945
  }
457508
458946
  return styles.join(";");
457509
458947
  }
457510
- function convertToPt3(pixels) {
458948
+ function convertToPt4(pixels) {
457511
458949
  if (typeof pixels === "number") {
457512
458950
  return pixels * 72 / 96;
457513
458951
  }
@@ -459360,7 +460798,8 @@ var init_bundled_manifest = __esm(() => {
459360
460798
  familyWithFaces2("PT Sans Narrow", "OFL-1.1", [
459361
460799
  { weight: "normal", style: "normal", file: "PTSansNarrow-Regular.woff2" },
459362
460800
  { weight: "bold", style: "normal", file: "PTSansNarrow-Bold.woff2" }
459363
- ])
460801
+ ]),
460802
+ family2("TeX Gyre Bonum", "TeXGyreBonum", "LicenseRef-GUST-Font-License-1.0")
459364
460803
  ]);
459365
460804
  });
459366
460805
 
@@ -460056,6 +461495,7 @@ var init_font_offerings = __esm(() => {
460056
461495
  "Arial Black",
460057
461496
  "Arial Narrow",
460058
461497
  "Baskerville Old Face",
461498
+ "Bookman Old Style",
460059
461499
  "Brush Script MT",
460060
461500
  "Century",
460061
461501
  "Cooper Black",