@superdoc-dev/mcp 0.12.0-next.16 → 0.12.0-next.17
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.
- package/dist/index.js +2002 -566
- package/package.json +1 -1
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-
|
|
52175
|
+
// ../../packages/superdoc/dist/chunks/SuperConverter-CUxtXQFf.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
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
90856
|
-
|
|
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],
|
|
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,
|
|
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
|
-
},
|
|
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
|
|
118741
|
+
var init_SuperConverter_CUxtXQFf_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
|
|
@@ -156854,6 +157421,14 @@ var init_SuperConverter_DBlOjc68_es = __esm(() => {
|
|
|
156854
157421
|
"center",
|
|
156855
157422
|
"bottom"
|
|
156856
157423
|
]);
|
|
157424
|
+
TEXTBOX_CONTAINER_TYPES = new Set([
|
|
157425
|
+
"run",
|
|
157426
|
+
"link",
|
|
157427
|
+
"hyperlink",
|
|
157428
|
+
"structuredContent",
|
|
157429
|
+
"fieldAnnotation",
|
|
157430
|
+
"smartTag"
|
|
157431
|
+
]);
|
|
156857
157432
|
WRAP_TYPES$1 = new Set([
|
|
156858
157433
|
"None",
|
|
156859
157434
|
"Square",
|
|
@@ -158356,7 +158931,7 @@ var init_SuperConverter_DBlOjc68_es = __esm(() => {
|
|
|
158356
158931
|
};
|
|
158357
158932
|
});
|
|
158358
158933
|
|
|
158359
|
-
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-
|
|
158934
|
+
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-DutCjfp2.es.js
|
|
158360
158935
|
function parseSizeUnit(val = "0") {
|
|
158361
158936
|
const length = val.toString() || "0";
|
|
158362
158937
|
const value = Number.parseFloat(length);
|
|
@@ -168751,8 +169326,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
|
|
|
168751
169326
|
}
|
|
168752
169327
|
};
|
|
168753
169328
|
};
|
|
168754
|
-
var
|
|
168755
|
-
|
|
169329
|
+
var init_create_headless_toolbar_DutCjfp2_es = __esm(() => {
|
|
169330
|
+
init_SuperConverter_CUxtXQFf_es();
|
|
168756
169331
|
init_uuid_B2wVPhPi_es();
|
|
168757
169332
|
init_constants_D9qj59G2_es();
|
|
168758
169333
|
init_dist_B8HfvhaK_es();
|
|
@@ -223442,7 +224017,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
|
|
|
223442
224017
|
init_remark_gfm_BhnWr3yf_es();
|
|
223443
224018
|
});
|
|
223444
224019
|
|
|
223445
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
224020
|
+
// ../../packages/superdoc/dist/chunks/src-BBtIMpLJ.es.js
|
|
223446
224021
|
function deleteProps(obj, propOrProps) {
|
|
223447
224022
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
223448
224023
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -264424,7 +264999,7 @@ function hasPageContextTokenInBlock(block) {
|
|
|
264424
264999
|
return true;
|
|
264425
265000
|
} else if (block.kind === "drawing") {
|
|
264426
265001
|
const drawing = block;
|
|
264427
|
-
if (drawing.drawingKind === "vectorShape")
|
|
265002
|
+
if (drawing.drawingKind === "vectorShape" || drawing.drawingKind === "textboxShape")
|
|
264428
265003
|
return hasPageContextTokenInShapeText(drawing.textContent);
|
|
264429
265004
|
if (drawing.drawingKind === "shapeGroup")
|
|
264430
265005
|
return hasPageContextTokenInShapeGroup(drawing.shapes);
|
|
@@ -266081,6 +266656,18 @@ function computeParagraphLayoutStartY(input2) {
|
|
|
266081
266656
|
const effectiveSpacingBefore = input2.suppressSpacingBefore ? 0 : input2.spacingBefore;
|
|
266082
266657
|
return computeParagraphContentStartY(y$1, effectiveSpacingBefore, effectiveSpacingBefore === 0, trailingForCollapse);
|
|
266083
266658
|
}
|
|
266659
|
+
function layoutTextboxContent(block, remeasureParagraph$1) {
|
|
266660
|
+
if (!Array.isArray(block.contentBlocks) || block.contentBlocks.length === 0)
|
|
266661
|
+
return [];
|
|
266662
|
+
const insets = block.textInsets ?? {
|
|
266663
|
+
top: 0,
|
|
266664
|
+
right: 0,
|
|
266665
|
+
bottom: 0,
|
|
266666
|
+
left: 0
|
|
266667
|
+
};
|
|
266668
|
+
const contentWidth = Math.max(1, block.geometry.width - insets.left - insets.right);
|
|
266669
|
+
return block.contentBlocks.map((paragraphBlock) => remeasureParagraph$1(paragraphBlock, contentWidth));
|
|
266670
|
+
}
|
|
266084
266671
|
function describeCellRenderBlocks(cellMeasure, cellBlock, cellPadding) {
|
|
266085
266672
|
const measuredBlocks = cellMeasure.blocks;
|
|
266086
266673
|
const blockDataArray = cellBlock?.blocks;
|
|
@@ -267545,6 +268132,7 @@ function layoutParagraphBlock(ctx$1, anchors) {
|
|
|
267545
268132
|
fragment.pmEnd = pmRange.pmEnd;
|
|
267546
268133
|
state.page.fragments.push(fragment);
|
|
267547
268134
|
} else if (entry.block.kind === "drawing" && entry.measure.kind === "drawing") {
|
|
268135
|
+
const contentMeasures = entry.block.drawingKind === "textboxShape" && typeof remeasureParagraph$1 === "function" ? layoutTextboxContent(entry.block, remeasureParagraph$1) : undefined;
|
|
267548
268136
|
const fragment = {
|
|
267549
268137
|
kind: "drawing",
|
|
267550
268138
|
blockId: entry.block.id,
|
|
@@ -267561,6 +268149,8 @@ function layoutParagraphBlock(ctx$1, anchors) {
|
|
|
267561
268149
|
drawingContentId: entry.block.drawingContentId,
|
|
267562
268150
|
sourceAnchor: entry.block.sourceAnchor
|
|
267563
268151
|
};
|
|
268152
|
+
if (contentMeasures)
|
|
268153
|
+
fragment.contentMeasures = contentMeasures;
|
|
267564
268154
|
if (pmRange.pmStart != null)
|
|
267565
268155
|
fragment.pmStart = pmRange.pmStart;
|
|
267566
268156
|
if (pmRange.pmEnd != null)
|
|
@@ -267969,7 +268559,7 @@ function layoutImageBlock({ block, measure, columns, ensurePage, advanceColumn,
|
|
|
267969
268559
|
state.cursorY += requiredHeight;
|
|
267970
268560
|
state.maxCursorY = Math.max(state.maxCursorY, state.cursorY);
|
|
267971
268561
|
}
|
|
267972
|
-
function layoutDrawingBlock({ block, measure, columns, ensurePage, advanceColumn, columnX }) {
|
|
268562
|
+
function layoutDrawingBlock({ block, measure, columns, ensurePage, advanceColumn, columnX, textboxContentMeasures }) {
|
|
267973
268563
|
if (block.anchor?.isAnchored)
|
|
267974
268564
|
return;
|
|
267975
268565
|
const marginTop = Math.max(0, block.margin?.top ?? 0);
|
|
@@ -268026,6 +268616,8 @@ function layoutDrawingBlock({ block, measure, columns, ensurePage, advanceColumn
|
|
|
268026
268616
|
pmEnd: pmRange.pmEnd,
|
|
268027
268617
|
sourceAnchor: block.sourceAnchor
|
|
268028
268618
|
};
|
|
268619
|
+
if (textboxContentMeasures)
|
|
268620
|
+
fragment.contentMeasures = textboxContentMeasures;
|
|
268029
268621
|
state.page.fragments.push(fragment);
|
|
268030
268622
|
state.cursorY += requiredHeight;
|
|
268031
268623
|
state.maxCursorY = Math.max(state.maxCursorY, state.cursorY);
|
|
@@ -270459,6 +271051,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
270459
271051
|
const state = paginator.ensurePage();
|
|
270460
271052
|
const drawBlock = block;
|
|
270461
271053
|
const drawMeasure = measure;
|
|
271054
|
+
const contentMeasures = drawBlock.drawingKind === "textboxShape" && typeof options.remeasureParagraph === "function" ? layoutTextboxContent(drawBlock, options.remeasureParagraph) : undefined;
|
|
270462
271055
|
const fragment = {
|
|
270463
271056
|
kind: "drawing",
|
|
270464
271057
|
blockId: drawBlock.id,
|
|
@@ -270475,6 +271068,8 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
270475
271068
|
drawingContentId: drawBlock.drawingContentId,
|
|
270476
271069
|
sourceAnchor: drawBlock.sourceAnchor
|
|
270477
271070
|
};
|
|
271071
|
+
if (contentMeasures)
|
|
271072
|
+
fragment.contentMeasures = contentMeasures;
|
|
270478
271073
|
const attrs = drawBlock.attrs;
|
|
270479
271074
|
if (attrs?.pmStart != null)
|
|
270480
271075
|
fragment.pmStart = attrs.pmStart;
|
|
@@ -270490,7 +271085,8 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
270490
271085
|
columns: getCurrentColumns(),
|
|
270491
271086
|
ensurePage: paginator.ensurePage,
|
|
270492
271087
|
advanceColumn: paginator.advanceColumn,
|
|
270493
|
-
columnX
|
|
271088
|
+
columnX,
|
|
271089
|
+
textboxContentMeasures: block.drawingKind === "textboxShape" && typeof options.remeasureParagraph === "function" ? layoutTextboxContent(block, options.remeasureParagraph) : undefined
|
|
270494
271090
|
});
|
|
270495
271091
|
continue;
|
|
270496
271092
|
}
|
|
@@ -270766,7 +271362,7 @@ function shouldExcludeFromMeasurement(fragment, block, fragmentBottom, canvasHei
|
|
|
270766
271362
|
return true;
|
|
270767
271363
|
return false;
|
|
270768
271364
|
}
|
|
270769
|
-
function layoutHeaderFooter(blocks2, measures, constraints, kind) {
|
|
271365
|
+
function layoutHeaderFooter(blocks2, measures, constraints, kind, remeasureParagraph$1) {
|
|
270770
271366
|
if (blocks2.length !== measures.length)
|
|
270771
271367
|
throw new Error(`layoutHeaderFooter expected measures for every block (blocks=${blocks2.length}, measures=${measures.length})`);
|
|
270772
271368
|
const width = Number(constraints?.width);
|
|
@@ -270790,7 +271386,8 @@ function layoutHeaderFooter(blocks2, measures, constraints, kind) {
|
|
|
270790
271386
|
left: 0
|
|
270791
271387
|
},
|
|
270792
271388
|
allowParagraphlessAnchoredTableFallback: false,
|
|
270793
|
-
allowSectionBreakOnlyPageFallback: false
|
|
271389
|
+
allowSectionBreakOnlyPageFallback: false,
|
|
271390
|
+
remeasureParagraph: remeasureParagraph$1
|
|
270794
271391
|
});
|
|
270795
271392
|
if (kind === "footer" && constraints.pageHeight != null)
|
|
270796
271393
|
normalizeFragmentsForRegion(layout.pages, blocks2, measures, kind, constraints);
|
|
@@ -271569,7 +272166,7 @@ function hasPageNumberTokensRequiringPerPageLayout(blocks2) {
|
|
|
271569
272166
|
}
|
|
271570
272167
|
return false;
|
|
271571
272168
|
}
|
|
271572
|
-
async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1, cache$2 = sharedHeaderFooterCache, totalPages, pageResolver, kind, fontSignature = "") {
|
|
272169
|
+
async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1, cache$2 = sharedHeaderFooterCache, totalPages, pageResolver, kind, fontSignature = "", remeasureParagraph$1) {
|
|
271573
272170
|
const result = {};
|
|
271574
272171
|
if (!pageResolver) {
|
|
271575
272172
|
const numPages = totalPages ?? 1;
|
|
@@ -271582,7 +272179,7 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
|
|
|
271582
272179
|
result[type] = {
|
|
271583
272180
|
blocks: clonedBlocks,
|
|
271584
272181
|
measures,
|
|
271585
|
-
layout: layoutHeaderFooter(clonedBlocks, measures, constraints, kind)
|
|
272182
|
+
layout: layoutHeaderFooter(clonedBlocks, measures, constraints, kind, remeasureParagraph$1)
|
|
271586
272183
|
};
|
|
271587
272184
|
}
|
|
271588
272185
|
return result;
|
|
@@ -271599,7 +272196,7 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
|
|
|
271599
272196
|
result[type] = {
|
|
271600
272197
|
blocks: blocks2,
|
|
271601
272198
|
measures,
|
|
271602
|
-
layout: layoutHeaderFooter(blocks2, measures, constraints, kind)
|
|
272199
|
+
layout: layoutHeaderFooter(blocks2, measures, constraints, kind, remeasureParagraph$1)
|
|
271603
272200
|
};
|
|
271604
272201
|
continue;
|
|
271605
272202
|
}
|
|
@@ -271621,7 +272218,7 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
|
|
|
271621
272218
|
const { displayText, displayNumber, totalPages: totalPagesForPage, sectionPageCount, pageFormat, chapterNumberText, chapterSeparator } = pageResolver(pageNum);
|
|
271622
272219
|
resolveHeaderFooterTokens(clonedBlocks, pageNum, totalPagesForPage, displayText, displayNumber, sectionPageCount, pageFormat, chapterNumberText, chapterSeparator);
|
|
271623
272220
|
const measures = await cache$2.measureBlocks(clonedBlocks, constraints, measureBlock$1, fontSignature);
|
|
271624
|
-
const pageLayout = layoutHeaderFooter(clonedBlocks, measures, constraints, kind);
|
|
272221
|
+
const pageLayout = layoutHeaderFooter(clonedBlocks, measures, constraints, kind, remeasureParagraph$1);
|
|
271625
272222
|
const measuresById = /* @__PURE__ */ new Map;
|
|
271626
272223
|
for (let i4 = 0;i4 < clonedBlocks.length; i4 += 1)
|
|
271627
272224
|
measuresById.set(clonedBlocks[i4].id, measures[i4]);
|
|
@@ -272484,7 +273081,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
272484
273081
|
const blocks2 = blocksByRId.get(group.rId);
|
|
272485
273082
|
if (!blocks2 || blocks2.length === 0)
|
|
272486
273083
|
continue;
|
|
272487
|
-
const layout$1 = (await layoutHeaderFooterWithCache({ default: blocks2 }, group.sectionConstraints, measureFn, headerMeasureCache, 1, pageResolver, kind)).default?.layout;
|
|
273084
|
+
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
273085
|
if (!layout$1 || !(layout$1.height > 0))
|
|
272489
273086
|
continue;
|
|
272490
273087
|
const nextHeight = Math.max(0, layout$1.height);
|
|
@@ -272501,7 +273098,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
272501
273098
|
for (const [rId, blocks2] of blocksByRId) {
|
|
272502
273099
|
if (!blocks2 || blocks2.length === 0)
|
|
272503
273100
|
continue;
|
|
272504
|
-
const layout$1 = (await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, measureFn, headerMeasureCache, 1, pageResolver, kind)).default?.layout;
|
|
273101
|
+
const layout$1 = (await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, measureFn, headerMeasureCache, 1, pageResolver, kind, undefined, (block, maxWidth, firstLineIndent) => remeasureParagraph(block, maxWidth, firstLineIndent))).default?.layout;
|
|
272505
273102
|
if (layout$1 && layout$1.height > 0)
|
|
272506
273103
|
heightsByRId.set(rId, layout$1.height);
|
|
272507
273104
|
}
|
|
@@ -272523,7 +273120,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
272523
273120
|
};
|
|
272524
273121
|
headerContentHeights = {};
|
|
272525
273122
|
if (hasHeaderBlocks && headerFooter.headerBlocks) {
|
|
272526
|
-
const preHeaderLayouts = await layoutHeaderFooterWithCache(headerFooter.headerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "header", fontSignature);
|
|
273123
|
+
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
273124
|
for (const [type, value] of Object.entries(preHeaderLayouts)) {
|
|
272528
273125
|
if (!isValidHeaderType(type))
|
|
272529
273126
|
continue;
|
|
@@ -272564,7 +273161,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
272564
273161
|
footerContentHeights = {};
|
|
272565
273162
|
try {
|
|
272566
273163
|
if (hasFooterBlocks && headerFooter.footerBlocks) {
|
|
272567
|
-
const preFooterLayouts = await layoutHeaderFooterWithCache(headerFooter.footerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "footer", fontSignature);
|
|
273164
|
+
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
273165
|
for (const [type, value] of Object.entries(preFooterLayouts)) {
|
|
272569
273166
|
if (!isValidFooterType(type))
|
|
272570
273167
|
continue;
|
|
@@ -272653,6 +273250,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
272653
273250
|
console.warn(`[incrementalLayout] Page token resolution did not converge after ${maxIterations} iterations - stopping`);
|
|
272654
273251
|
}
|
|
272655
273252
|
}
|
|
273253
|
+
hydrateTableTextboxMeasures(currentBlocks, (block, maxWidth) => remeasureParagraph(block, maxWidth));
|
|
272656
273254
|
const totalTokenTime = performance.now() - pageTokenStart;
|
|
272657
273255
|
if (iteration > 0) {
|
|
272658
273256
|
perfLog$1(`[Perf] 4.3 Total page token resolution time: ${totalTokenTime.toFixed(2)}ms`);
|
|
@@ -273664,10 +274262,17 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
273664
274262
|
chapterSeparator: displayInfo?.chapterSeparator
|
|
273665
274263
|
};
|
|
273666
274264
|
} : undefined;
|
|
273667
|
-
|
|
273668
|
-
|
|
273669
|
-
|
|
273670
|
-
|
|
274265
|
+
const hfRemeasure = (block, maxWidth) => remeasureParagraph(block, maxWidth);
|
|
274266
|
+
if (headerFooter.headerBlocks) {
|
|
274267
|
+
for (const blocks2 of Object.values(headerFooter.headerBlocks))
|
|
274268
|
+
hydrateTableTextboxMeasures(blocks2, hfRemeasure);
|
|
274269
|
+
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)));
|
|
274270
|
+
}
|
|
274271
|
+
if (headerFooter.footerBlocks) {
|
|
274272
|
+
for (const blocks2 of Object.values(headerFooter.footerBlocks))
|
|
274273
|
+
hydrateTableTextboxMeasures(blocks2, hfRemeasure);
|
|
274274
|
+
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)));
|
|
274275
|
+
}
|
|
273671
274276
|
perfLog$1(`[Perf] 4.4 Header/footer layout: ${(performance.now() - hfStart).toFixed(2)}ms`);
|
|
273672
274277
|
const cacheStats = headerMeasureCache.getStats();
|
|
273673
274278
|
globalMetrics.recordHeaderFooterCacheMetrics(cacheStats);
|
|
@@ -273683,6 +274288,19 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
273683
274288
|
extraMeasures
|
|
273684
274289
|
};
|
|
273685
274290
|
}
|
|
274291
|
+
function hydrateTableTextboxMeasures(blocks2, remeasure) {
|
|
274292
|
+
for (const block of blocks2) {
|
|
274293
|
+
if (block.kind !== "table")
|
|
274294
|
+
continue;
|
|
274295
|
+
for (const row2 of block.rows ?? [])
|
|
274296
|
+
for (const cell2 of row2.cells ?? [])
|
|
274297
|
+
for (const cellBlock of cell2.blocks ?? [])
|
|
274298
|
+
if (cellBlock.kind === "drawing" && cellBlock.drawingKind === "textboxShape")
|
|
274299
|
+
cellBlock.contentMeasures = layoutTextboxContent(cellBlock, remeasure);
|
|
274300
|
+
else if (cellBlock.kind === "table")
|
|
274301
|
+
hydrateTableTextboxMeasures([cellBlock], remeasure);
|
|
274302
|
+
}
|
|
274303
|
+
}
|
|
273686
274304
|
function rewriteSectionBreaksForSemanticFlow(blocks2, options) {
|
|
273687
274305
|
const semanticPageSize = options.pageSize;
|
|
273688
274306
|
const semanticMargins = options.margins;
|
|
@@ -273961,41 +274579,6 @@ async function remeasureAffectedBlocks(blocks2, measures, affectedBlockIds, perB
|
|
|
273961
274579
|
}
|
|
273962
274580
|
return updatedMeasures;
|
|
273963
274581
|
}
|
|
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
274582
|
function resolveColumnsForHit(layout, page, fragmentY) {
|
|
274000
274583
|
if (page === undefined)
|
|
274001
274584
|
return layout.columns;
|
|
@@ -274291,6 +274874,54 @@ function clickToPositionGeometry(layout, blocks2, measures, containerPoint, opti
|
|
|
274291
274874
|
lineIndex
|
|
274292
274875
|
};
|
|
274293
274876
|
}
|
|
274877
|
+
if (fragment.kind === "drawing" && fragment.drawingKind === "textboxShape" && block.kind === "drawing" && block.drawingKind === "textboxShape") {
|
|
274878
|
+
const textboxHit = resolveTextboxContentHit(fragment, block, measure, pageIndex, pageRelativePoint);
|
|
274879
|
+
if (textboxHit) {
|
|
274880
|
+
const { contentBlock, contentMeasure, localX, localY, pageIndex: pageIndex$1, paragraphIndex } = textboxHit;
|
|
274881
|
+
const lineIndex = findLineIndexAtY(contentMeasure.lines, localY, 0, contentMeasure.lines.length);
|
|
274882
|
+
if (lineIndex != null) {
|
|
274883
|
+
const line = contentMeasure.lines[lineIndex];
|
|
274884
|
+
const isRTL = isRtlBlock(contentBlock);
|
|
274885
|
+
const indentLeft = typeof contentBlock.attrs?.indent?.left === "number" ? contentBlock.attrs.indent.left : 0;
|
|
274886
|
+
const indentRight = typeof contentBlock.attrs?.indent?.right === "number" ? contentBlock.attrs.indent.right : 0;
|
|
274887
|
+
const totalIndent = (Number.isFinite(indentLeft) ? indentLeft : 0) + (Number.isFinite(indentRight) ? indentRight : 0);
|
|
274888
|
+
const insets = textboxHit.block.textInsets ?? {
|
|
274889
|
+
top: 0,
|
|
274890
|
+
right: 0,
|
|
274891
|
+
bottom: 0,
|
|
274892
|
+
left: 0
|
|
274893
|
+
};
|
|
274894
|
+
let availableWidth = Math.max(0, textboxHit.fragment.width - insets.left - insets.right - totalIndent);
|
|
274895
|
+
if (totalIndent > textboxHit.fragment.width)
|
|
274896
|
+
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.`);
|
|
274897
|
+
if (lineIndex === 0) {
|
|
274898
|
+
const suppressFLI = contentBlock.attrs?.suppressFirstLineIndent === true;
|
|
274899
|
+
const firstLineOffset = getFirstLineIndentOffset(contentBlock.attrs?.indent, suppressFLI);
|
|
274900
|
+
availableWidth = adjustAvailableWidthForTextIndent(availableWidth, firstLineOffset, line.maxWidth);
|
|
274901
|
+
}
|
|
274902
|
+
const pos = mapPointToPm(contentBlock, line, localX, isRTL, availableWidth);
|
|
274903
|
+
if (pos != null)
|
|
274904
|
+
return {
|
|
274905
|
+
pos,
|
|
274906
|
+
layoutEpoch,
|
|
274907
|
+
blockId: textboxHit.fragment.blockId,
|
|
274908
|
+
pageIndex: pageIndex$1,
|
|
274909
|
+
column: determineColumn(layout, textboxHit.fragment.x, layout.pages[pageIndex$1], textboxHit.fragment.y),
|
|
274910
|
+
lineIndex
|
|
274911
|
+
};
|
|
274912
|
+
}
|
|
274913
|
+
const firstRun = contentBlock.runs?.[0];
|
|
274914
|
+
if (firstRun && firstRun.pmStart != null)
|
|
274915
|
+
return {
|
|
274916
|
+
pos: firstRun.pmStart,
|
|
274917
|
+
layoutEpoch,
|
|
274918
|
+
blockId: textboxHit.fragment.blockId,
|
|
274919
|
+
pageIndex: pageIndex$1,
|
|
274920
|
+
column: determineColumn(layout, textboxHit.fragment.x, layout.pages[pageIndex$1], textboxHit.fragment.y),
|
|
274921
|
+
lineIndex: 0
|
|
274922
|
+
};
|
|
274923
|
+
}
|
|
274924
|
+
}
|
|
274294
274925
|
if (isAtomicFragment(fragment)) {
|
|
274295
274926
|
const pmRange = getAtomicPmRange(fragment, block);
|
|
274296
274927
|
const pos = pmRange.pmStart ?? pmRange.pmEnd ?? null;
|
|
@@ -274368,6 +274999,41 @@ function clickToPositionGeometry(layout, blocks2, measures, containerPoint, opti
|
|
|
274368
274999
|
}
|
|
274369
275000
|
return null;
|
|
274370
275001
|
}
|
|
275002
|
+
function calculateSummary(samples) {
|
|
275003
|
+
if (samples.length === 0)
|
|
275004
|
+
return {
|
|
275005
|
+
count: 0,
|
|
275006
|
+
min: 0,
|
|
275007
|
+
max: 0,
|
|
275008
|
+
avg: 0,
|
|
275009
|
+
p50: 0,
|
|
275010
|
+
p95: 0,
|
|
275011
|
+
p99: 0
|
|
275012
|
+
};
|
|
275013
|
+
const values = samples.map((s2) => s2.value).sort((a2, b$1) => a2 - b$1);
|
|
275014
|
+
const count = values.length;
|
|
275015
|
+
const sum = values.reduce((acc, v) => acc + v, 0);
|
|
275016
|
+
return {
|
|
275017
|
+
count,
|
|
275018
|
+
min: values[0],
|
|
275019
|
+
max: values[count - 1],
|
|
275020
|
+
avg: sum / count,
|
|
275021
|
+
p50: percentile(values, 0.5),
|
|
275022
|
+
p95: percentile(values, 0.95),
|
|
275023
|
+
p99: percentile(values, 0.99)
|
|
275024
|
+
};
|
|
275025
|
+
}
|
|
275026
|
+
function percentile(sortedValues, p$12) {
|
|
275027
|
+
if (sortedValues.length === 0)
|
|
275028
|
+
return 0;
|
|
275029
|
+
if (sortedValues.length === 1)
|
|
275030
|
+
return sortedValues[0];
|
|
275031
|
+
const index2 = (sortedValues.length - 1) * p$12;
|
|
275032
|
+
const lower = Math.floor(index2);
|
|
275033
|
+
const upper = Math.ceil(index2);
|
|
275034
|
+
const weight = index2 - lower;
|
|
275035
|
+
return sortedValues[lower] * (1 - weight) + sortedValues[upper] * weight;
|
|
275036
|
+
}
|
|
274371
275037
|
function selectionToRects(layout, blocks2, measures, from$1, to, geometryHelper) {
|
|
274372
275038
|
if (from$1 === to)
|
|
274373
275039
|
return [];
|
|
@@ -277536,6 +278202,73 @@ function computeTableCaretLayoutRectFromDom({ viewportHost, visibleHost, zoom },
|
|
|
277536
278202
|
}
|
|
277537
278203
|
return null;
|
|
277538
278204
|
}
|
|
278205
|
+
function findTextboxFragmentElement(viewportHost, blockId, pageIndex) {
|
|
278206
|
+
const pageEl = viewportHost.querySelector(`[data-page-index="${pageIndex}"]`) ?? viewportHost;
|
|
278207
|
+
return Array.from(pageEl.querySelectorAll("[data-block-id]")).find((el) => el.dataset.blockId === blockId) ?? null;
|
|
278208
|
+
}
|
|
278209
|
+
function computeTextboxCaretLayoutRectFromDom({ viewportHost, visibleHost, zoom }, pos, fragment, _block, pageIndex) {
|
|
278210
|
+
const fragmentEl = findTextboxFragmentElement(viewportHost, fragment.blockId, pageIndex);
|
|
278211
|
+
if (!fragmentEl)
|
|
278212
|
+
return null;
|
|
278213
|
+
const lineEls = Array.from(fragmentEl.querySelectorAll(".superdoc-line[data-pm-start][data-pm-end]"));
|
|
278214
|
+
if (lineEls.length === 0)
|
|
278215
|
+
return null;
|
|
278216
|
+
for (let lineIdx = 0;lineIdx < lineEls.length; lineIdx++) {
|
|
278217
|
+
const lineEl = lineEls[lineIdx];
|
|
278218
|
+
const pmStart = Number(lineEl.dataset.pmStart ?? "NaN");
|
|
278219
|
+
const pmEnd = Number(lineEl.dataset.pmEnd ?? "NaN");
|
|
278220
|
+
if (!Number.isFinite(pmStart) || !Number.isFinite(pmEnd))
|
|
278221
|
+
continue;
|
|
278222
|
+
const isLastLine = lineIdx === lineEls.length - 1;
|
|
278223
|
+
if (pos < pmStart || (isLastLine ? pos > pmEnd : pos >= pmEnd))
|
|
278224
|
+
continue;
|
|
278225
|
+
const spanEls = Array.from(lineEl.querySelectorAll("span[data-pm-start][data-pm-end]"));
|
|
278226
|
+
for (let spanIdx = 0;spanIdx < spanEls.length; spanIdx++) {
|
|
278227
|
+
const spanEl = spanEls[spanIdx];
|
|
278228
|
+
const spanStart = Number(spanEl.dataset.pmStart ?? "NaN");
|
|
278229
|
+
const spanEnd = Number(spanEl.dataset.pmEnd ?? "NaN");
|
|
278230
|
+
if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd))
|
|
278231
|
+
continue;
|
|
278232
|
+
const isLastSpan = spanIdx === spanEls.length - 1;
|
|
278233
|
+
if (pos < spanStart || (isLastSpan ? pos > spanEnd : pos >= spanEnd))
|
|
278234
|
+
continue;
|
|
278235
|
+
const textNode = spanEl.firstChild;
|
|
278236
|
+
if (!textNode || textNode.nodeType !== Node.TEXT_NODE) {
|
|
278237
|
+
const spanRect = spanEl.getBoundingClientRect();
|
|
278238
|
+
const viewportRect$2 = viewportHost.getBoundingClientRect();
|
|
278239
|
+
return {
|
|
278240
|
+
pageIndex,
|
|
278241
|
+
x: (spanRect.left - viewportRect$2.left + visibleHost.scrollLeft) / zoom,
|
|
278242
|
+
y: (spanRect.top - viewportRect$2.top + visibleHost.scrollTop) / zoom,
|
|
278243
|
+
height: spanRect.height / zoom
|
|
278244
|
+
};
|
|
278245
|
+
}
|
|
278246
|
+
const text5 = textNode.textContent ?? "";
|
|
278247
|
+
const charOffset = Math.max(0, Math.min(text5.length, pos - spanStart));
|
|
278248
|
+
const range = document.createRange();
|
|
278249
|
+
range.setStart(textNode, charOffset);
|
|
278250
|
+
range.setEnd(textNode, charOffset);
|
|
278251
|
+
const rangeRect = range.getBoundingClientRect();
|
|
278252
|
+
const viewportRect$1 = viewportHost.getBoundingClientRect();
|
|
278253
|
+
const lineRect$1 = lineEl.getBoundingClientRect();
|
|
278254
|
+
return {
|
|
278255
|
+
pageIndex,
|
|
278256
|
+
x: (rangeRect.left - viewportRect$1.left + visibleHost.scrollLeft) / zoom,
|
|
278257
|
+
y: (lineRect$1.top - viewportRect$1.top + visibleHost.scrollTop) / zoom,
|
|
278258
|
+
height: lineRect$1.height / zoom
|
|
278259
|
+
};
|
|
278260
|
+
}
|
|
278261
|
+
const lineRect = lineEl.getBoundingClientRect();
|
|
278262
|
+
const viewportRect = viewportHost.getBoundingClientRect();
|
|
278263
|
+
return {
|
|
278264
|
+
pageIndex,
|
|
278265
|
+
x: (lineRect.left - viewportRect.left + visibleHost.scrollLeft) / zoom,
|
|
278266
|
+
y: (lineRect.top - viewportRect.top + visibleHost.scrollTop) / zoom,
|
|
278267
|
+
height: lineRect.height / zoom
|
|
278268
|
+
};
|
|
278269
|
+
}
|
|
278270
|
+
return null;
|
|
278271
|
+
}
|
|
277539
278272
|
function findLineContainingPos(block, measure, fromLine, toLine, pos) {
|
|
277540
278273
|
if (measure.kind !== "paragraph" || block.kind !== "paragraph")
|
|
277541
278274
|
return null;
|
|
@@ -277592,6 +278325,12 @@ function computeCaretLayoutRectGeometry({ layout, blocks: blocks2, measures, pai
|
|
|
277592
278325
|
visibleHost,
|
|
277593
278326
|
zoom
|
|
277594
278327
|
}, effectivePos, hit.fragment, block, measure, hit.pageIndex);
|
|
278328
|
+
if (hit.fragment.kind === "drawing" && block?.kind === "drawing" && block.drawingKind === "textboxShape" && measure?.kind === "drawing")
|
|
278329
|
+
return computeTextboxCaretLayoutRectFromDom({
|
|
278330
|
+
viewportHost,
|
|
278331
|
+
visibleHost,
|
|
278332
|
+
zoom
|
|
278333
|
+
}, effectivePos, hit.fragment, block, hit.pageIndex);
|
|
277595
278334
|
if (!block || block.kind !== "paragraph" || measure?.kind !== "paragraph")
|
|
277596
278335
|
return null;
|
|
277597
278336
|
if (hit.fragment.kind !== "para")
|
|
@@ -282213,7 +282952,7 @@ async function layoutBlocksByRId(kind, blocksByRId, referencedRIds, constraints,
|
|
|
282213
282952
|
if (!blocks2 || blocks2.length === 0)
|
|
282214
282953
|
continue;
|
|
282215
282954
|
try {
|
|
282216
|
-
const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, (block, c) => measureBlock(block, c, fontMeasureContext), undefined, undefined, pageResolver, kind, fontSignature);
|
|
282955
|
+
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
282956
|
if (batchResult.default)
|
|
282218
282957
|
layoutsByRId.set(rId, {
|
|
282219
282958
|
kind,
|
|
@@ -282273,7 +283012,7 @@ async function layoutWithPerSectionConstraints(kind, blocksByRId, sectionMetadat
|
|
|
282273
283012
|
if (!blocks2 || blocks2.length === 0)
|
|
282274
283013
|
continue;
|
|
282275
283014
|
try {
|
|
282276
|
-
const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, group.sectionConstraints, (block, c) => measureBlock(block, c, fontMeasureContext), undefined, undefined, pageResolver, kind, fontSignature);
|
|
283015
|
+
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
283016
|
if (batchResult.default)
|
|
282278
283017
|
for (const sectionIndex of group.sectionIndices) {
|
|
282279
283018
|
const contentWidth = buildSectionContentWidth(sectionMetadata.find((s2) => s2.sectionIndex === sectionIndex), fallbackConstraints);
|
|
@@ -306265,6 +307004,7 @@ menclose::after {
|
|
|
306265
307004
|
drawingWrapper.style.flexShrink = "0";
|
|
306266
307005
|
drawingWrapper.style.maxWidth = "100%";
|
|
306267
307006
|
drawingWrapper.style.boxSizing = "border-box";
|
|
307007
|
+
drawingWrapper.dataset.blockId = block.id;
|
|
306268
307008
|
applySdtDataset$1(drawingWrapper, block.attrs);
|
|
306269
307009
|
const drawingInner = doc$12.createElement("div");
|
|
306270
307010
|
drawingInner.classList.add("superdoc-table-drawing");
|
|
@@ -306434,6 +307174,7 @@ menclose::after {
|
|
|
306434
307174
|
drawingWrapper.style.maxWidth = "100%";
|
|
306435
307175
|
drawingWrapper.style.boxSizing = "border-box";
|
|
306436
307176
|
drawingWrapper.style.zIndex = String(zIndex);
|
|
307177
|
+
drawingWrapper.dataset.blockId = anchoredBlock.id;
|
|
306437
307178
|
applySdtDataset$1(drawingWrapper, anchoredBlock.attrs);
|
|
306438
307179
|
const drawingInner = doc$12.createElement("div");
|
|
306439
307180
|
drawingInner.classList.add("superdoc-table-drawing");
|
|
@@ -310473,17 +311214,19 @@ menclose::after {
|
|
|
310473
311214
|
throw new Error("DomPainter: document is not available");
|
|
310474
311215
|
if (block.drawingKind === "image")
|
|
310475
311216
|
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);
|
|
311217
|
+
if (block.drawingKind === "vectorShape" || block.drawingKind === "textboxShape")
|
|
311218
|
+
return this.createVectorShapeElement(block, fragment.geometry, false, 1, 1, context, fragment);
|
|
310478
311219
|
if (block.drawingKind === "shapeGroup")
|
|
310479
311220
|
return this.createShapeGroupElement(block, context);
|
|
310480
311221
|
if (block.drawingKind === "chart")
|
|
310481
311222
|
return this.createChartElement(block);
|
|
310482
311223
|
return this.createDrawingPlaceholder();
|
|
310483
311224
|
}
|
|
310484
|
-
createVectorShapeElement(block, geometry, applyTransforms = false, groupScaleX = 1, groupScaleY = 1, context) {
|
|
311225
|
+
createVectorShapeElement(block, geometry, applyTransforms = false, groupScaleX = 1, groupScaleY = 1, context, fragment) {
|
|
310485
311226
|
const container = this.doc.createElement("div");
|
|
310486
311227
|
container.classList.add("superdoc-vector-shape");
|
|
311228
|
+
if (block.drawingKind === "textboxShape")
|
|
311229
|
+
container.classList.add("superdoc-textbox-shape");
|
|
310487
311230
|
container.style.width = "100%";
|
|
310488
311231
|
container.style.height = "100%";
|
|
310489
311232
|
container.style.position = "relative";
|
|
@@ -310514,8 +311257,8 @@ menclose::after {
|
|
|
310514
311257
|
}
|
|
310515
311258
|
this.applyLineEnds(svgElement, block);
|
|
310516
311259
|
contentContainer.appendChild(svgElement);
|
|
310517
|
-
if (this.hasShapeTextContent(block.textContent)) {
|
|
310518
|
-
const textElement = this.createShapeTextElement(block, innerWidth, innerHeight2, groupScaleX, groupScaleY, context);
|
|
311260
|
+
if (block.drawingKind === "textboxShape" || this.hasShapeTextContent(block.textContent)) {
|
|
311261
|
+
const textElement = block.drawingKind === "textboxShape" ? this.createTextboxContentElement(block, fragment, innerWidth, innerHeight2, context) : this.createShapeTextElement(block, innerWidth, innerHeight2, groupScaleX, groupScaleY, context);
|
|
310519
311262
|
contentContainer.appendChild(textElement);
|
|
310520
311263
|
}
|
|
310521
311264
|
container.appendChild(contentContainer);
|
|
@@ -310523,8 +311266,8 @@ menclose::after {
|
|
|
310523
311266
|
}
|
|
310524
311267
|
}
|
|
310525
311268
|
this.applyFallbackShapeStyle(contentContainer, block);
|
|
310526
|
-
if (this.hasShapeTextContent(block.textContent)) {
|
|
310527
|
-
const textElement = this.createShapeTextElement(block, innerWidth, innerHeight2, groupScaleX, groupScaleY, context);
|
|
311269
|
+
if (block.drawingKind === "textboxShape" || this.hasShapeTextContent(block.textContent)) {
|
|
311270
|
+
const textElement = block.drawingKind === "textboxShape" ? this.createTextboxContentElement(block, fragment, innerWidth, innerHeight2, context) : this.createShapeTextElement(block, innerWidth, innerHeight2, groupScaleX, groupScaleY, context);
|
|
310528
311271
|
contentContainer.appendChild(textElement);
|
|
310529
311272
|
}
|
|
310530
311273
|
container.appendChild(contentContainer);
|
|
@@ -310564,6 +311307,47 @@ menclose::after {
|
|
|
310564
311307
|
return this.createWordArtTextElement(textContent$1, block.textAlign ?? "center", block.textInsets, width, height, context);
|
|
310565
311308
|
return this.createFallbackTextElement(textContent$1, block.textAlign ?? "center", block.textVerticalAlign, block.textInsets, groupScaleX, groupScaleY, context);
|
|
310566
311309
|
}
|
|
311310
|
+
createTextboxContentElement(block, fragment, width, height, context) {
|
|
311311
|
+
const contentMeasures = fragment?.contentMeasures ?? block.contentMeasures;
|
|
311312
|
+
if (!Array.isArray(contentMeasures) || contentMeasures.length === 0)
|
|
311313
|
+
return this.hasShapeTextContent(block.textContent) ? this.createShapeTextElement(block, width, height, 1, 1, context) : this.doc.createElement("div");
|
|
311314
|
+
const contentRoot = this.doc.createElement("div");
|
|
311315
|
+
contentRoot.style.position = "absolute";
|
|
311316
|
+
contentRoot.style.top = "0";
|
|
311317
|
+
contentRoot.style.left = "0";
|
|
311318
|
+
contentRoot.style.width = "100%";
|
|
311319
|
+
contentRoot.style.height = "100%";
|
|
311320
|
+
contentRoot.style.display = "flex";
|
|
311321
|
+
contentRoot.style.flexDirection = "column";
|
|
311322
|
+
contentRoot.style.boxSizing = "border-box";
|
|
311323
|
+
contentRoot.style.overflow = "hidden";
|
|
311324
|
+
const insets = block.textInsets ?? {
|
|
311325
|
+
top: 0,
|
|
311326
|
+
right: 0,
|
|
311327
|
+
bottom: 0,
|
|
311328
|
+
left: 0
|
|
311329
|
+
};
|
|
311330
|
+
contentRoot.style.padding = `${insets.top}px ${insets.right}px ${insets.bottom}px ${insets.left}px`;
|
|
311331
|
+
const verticalAlign = block.textVerticalAlign ?? "top";
|
|
311332
|
+
contentRoot.style.justifyContent = verticalAlign === "bottom" ? "flex-end" : verticalAlign === "center" ? "center" : "flex-start";
|
|
311333
|
+
const linesHost = this.doc.createElement("div");
|
|
311334
|
+
linesHost.style.display = "flex";
|
|
311335
|
+
linesHost.style.flexDirection = "column";
|
|
311336
|
+
linesHost.style.minWidth = "0";
|
|
311337
|
+
linesHost.style.width = "100%";
|
|
311338
|
+
const renderContext = context ?? this.defaultFragmentRenderContext();
|
|
311339
|
+
const availableWidth = Math.max(1, width - insets.left - insets.right);
|
|
311340
|
+
block.contentBlocks.forEach((paragraphBlock, paragraphIndex) => {
|
|
311341
|
+
const measure = contentMeasures[paragraphIndex];
|
|
311342
|
+
if (!measure?.lines)
|
|
311343
|
+
return;
|
|
311344
|
+
measure.lines.forEach((line, lineIndex) => {
|
|
311345
|
+
linesHost.appendChild(this.renderLine(paragraphBlock, line, renderContext, availableWidth, lineIndex));
|
|
311346
|
+
});
|
|
311347
|
+
});
|
|
311348
|
+
contentRoot.appendChild(linesHost);
|
|
311349
|
+
return contentRoot;
|
|
311350
|
+
}
|
|
310567
311351
|
shouldUseWordArtTextRenderer(block) {
|
|
310568
311352
|
return block.attrs?.isWordArt === true && this.hasShapeTextContent(block.textContent);
|
|
310569
311353
|
}
|
|
@@ -311116,7 +311900,7 @@ menclose::after {
|
|
|
311116
311900
|
return createDrawingImageElement(this.doc, block, this.buildImageHyperlinkAnchor.bind(this));
|
|
311117
311901
|
if (block.drawingKind === "shapeGroup")
|
|
311118
311902
|
return this.createShapeGroupElement(block, context);
|
|
311119
|
-
if (block.drawingKind === "vectorShape")
|
|
311903
|
+
if (block.drawingKind === "vectorShape" || block.drawingKind === "textboxShape")
|
|
311120
311904
|
return this.createVectorShapeElement(block, block.geometry, false, 1, 1, context);
|
|
311121
311905
|
if (block.drawingKind === "chart")
|
|
311122
311906
|
return this.createChartElement(block);
|
|
@@ -311201,6 +311985,13 @@ menclose::after {
|
|
|
311201
311985
|
};
|
|
311202
311986
|
return runContext;
|
|
311203
311987
|
}
|
|
311988
|
+
defaultFragmentRenderContext() {
|
|
311989
|
+
return {
|
|
311990
|
+
pageNumber: 1,
|
|
311991
|
+
totalPages: 1,
|
|
311992
|
+
section: "body"
|
|
311993
|
+
};
|
|
311994
|
+
}
|
|
311204
311995
|
updateFragmentElement(el, fragment, section, resolvedItem) {
|
|
311205
311996
|
const fragmentItem = resolvedItem?.kind === "fragment" ? resolvedItem : undefined;
|
|
311206
311997
|
const story = resolveSectionStory(section);
|
|
@@ -311697,6 +312488,15 @@ menclose::after {
|
|
|
311697
312488
|
if (!lum)
|
|
311698
312489
|
return "";
|
|
311699
312490
|
return [lum.bright ?? "", lum.contrast ?? ""].join(":");
|
|
312491
|
+
}, drawingTextVersion = (block) => {
|
|
312492
|
+
const textboxContentBlocks = "contentBlocks" in block && Array.isArray(block.contentBlocks) ? block.contentBlocks.map((contentBlock) => deriveBlockVersion(contentBlock)).join(";") : "";
|
|
312493
|
+
return JSON.stringify([
|
|
312494
|
+
block.textAlign ?? "",
|
|
312495
|
+
block.textVerticalAlign ?? "",
|
|
312496
|
+
block.textInsets ?? null,
|
|
312497
|
+
block.textContent ?? null,
|
|
312498
|
+
textboxContentBlocks
|
|
312499
|
+
]);
|
|
311700
312500
|
}, renderedBlockImageVersion = (image2) => [
|
|
311701
312501
|
image2.src ?? "",
|
|
311702
312502
|
image2.width ?? "",
|
|
@@ -311904,10 +312704,10 @@ menclose::after {
|
|
|
311904
312704
|
if (block.kind === "drawing") {
|
|
311905
312705
|
if (block.drawingKind === "image")
|
|
311906
312706
|
return ["drawing:image", renderedBlockImageVersion(block)].join("|");
|
|
311907
|
-
if (block.drawingKind === "vectorShape") {
|
|
312707
|
+
if (block.drawingKind === "vectorShape" || block.drawingKind === "textboxShape") {
|
|
311908
312708
|
const vector = block;
|
|
311909
312709
|
return [
|
|
311910
|
-
"drawing:vector",
|
|
312710
|
+
block.drawingKind === "textboxShape" ? "drawing:textbox" : "drawing:vector",
|
|
311911
312711
|
vector.shapeKind ?? "",
|
|
311912
312712
|
vector.fillColor ?? "",
|
|
311913
312713
|
vector.strokeColor ?? "",
|
|
@@ -311916,7 +312716,8 @@ menclose::after {
|
|
|
311916
312716
|
vector.geometry.height,
|
|
311917
312717
|
vector.geometry.rotation ?? 0,
|
|
311918
312718
|
vector.geometry.flipH ? 1 : 0,
|
|
311919
|
-
vector.geometry.flipV ? 1 : 0
|
|
312719
|
+
vector.geometry.flipV ? 1 : 0,
|
|
312720
|
+
drawingTextVersion(vector)
|
|
311920
312721
|
].join("|");
|
|
311921
312722
|
}
|
|
311922
312723
|
if (block.drawingKind === "shapeGroup") {
|
|
@@ -312612,6 +313413,23 @@ menclose::after {
|
|
|
312612
313413
|
block.textVerticalAlign ?? "",
|
|
312613
313414
|
JSON.stringify(block.textInsets ?? null)
|
|
312614
313415
|
].join(":");
|
|
313416
|
+
if (block.drawingKind === "textboxShape")
|
|
313417
|
+
return [
|
|
313418
|
+
"drawing:textbox",
|
|
313419
|
+
hashDrawingGeometry(block.geometry),
|
|
313420
|
+
block.shapeKind ?? "",
|
|
313421
|
+
JSON.stringify(block.fillColor ?? null),
|
|
313422
|
+
JSON.stringify(block.strokeColor ?? null),
|
|
313423
|
+
block.strokeWidth ?? "",
|
|
313424
|
+
JSON.stringify(block.customGeometry ?? null),
|
|
313425
|
+
JSON.stringify(block.lineEnds ?? null),
|
|
313426
|
+
JSON.stringify(block.effectExtent ?? null),
|
|
313427
|
+
JSON.stringify(block.textContent ?? null),
|
|
313428
|
+
block.textAlign ?? "",
|
|
313429
|
+
block.textVerticalAlign ?? "",
|
|
313430
|
+
JSON.stringify(block.textInsets ?? null),
|
|
313431
|
+
block.contentBlocks.map((contentBlock) => `${contentBlock.id}:${hashRuns(contentBlock)}`).join("|")
|
|
313432
|
+
].join(":");
|
|
312615
313433
|
if (block.drawingKind === "shapeGroup")
|
|
312616
313434
|
return [
|
|
312617
313435
|
"drawing:shapeGroup",
|
|
@@ -313646,8 +314464,10 @@ menclose::after {
|
|
|
313646
314464
|
return false;
|
|
313647
314465
|
if (a2.drawingKind === "image" && b$1.drawingKind === "image")
|
|
313648
314466
|
return imageBlocksEqual(a2, b$1);
|
|
313649
|
-
if (a2.drawingKind === "vectorShape" && b$1.drawingKind === "vectorShape")
|
|
313650
|
-
|
|
314467
|
+
if ((a2.drawingKind === "vectorShape" || a2.drawingKind === "textboxShape") && (b$1.drawingKind === "vectorShape" || b$1.drawingKind === "textboxShape")) {
|
|
314468
|
+
const textboxContentEqual = a2.drawingKind !== "textboxShape" || b$1.drawingKind !== "textboxShape" || jsonEqual(a2.contentBlocks, b$1.contentBlocks);
|
|
314469
|
+
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;
|
|
314470
|
+
}
|
|
313651
314471
|
if (a2.drawingKind === "shapeGroup" && b$1.drawingKind === "shapeGroup")
|
|
313652
314472
|
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
314473
|
if (a2.drawingKind === "chart" && b$1.drawingKind === "chart")
|
|
@@ -314471,7 +315291,329 @@ menclose::after {
|
|
|
314471
315291
|
});
|
|
314472
315292
|
});
|
|
314473
315293
|
return results;
|
|
314474
|
-
}, PRELAYOUT_CHAPTER_MARKER_SEPARATOR_RE, PRELAYOUT_MIN_PAGE_COMPONENT = 10,
|
|
315294
|
+
}, PRELAYOUT_CHAPTER_MARKER_SEPARATOR_RE, PRELAYOUT_MIN_PAGE_COMPONENT = 10, isAtomicFragment = (fragment) => {
|
|
315295
|
+
return fragment.kind === "drawing" || fragment.kind === "image";
|
|
315296
|
+
}, blockPmRangeFromAttrs = (block) => {
|
|
315297
|
+
const attrs = block?.attrs;
|
|
315298
|
+
const pmStart = typeof attrs?.pmStart === "number" ? attrs.pmStart : undefined;
|
|
315299
|
+
return {
|
|
315300
|
+
pmStart,
|
|
315301
|
+
pmEnd: typeof attrs?.pmEnd === "number" ? attrs.pmEnd : pmStart != null ? pmStart + 1 : undefined
|
|
315302
|
+
};
|
|
315303
|
+
}, getAtomicPmRange = (fragment, block) => {
|
|
315304
|
+
return {
|
|
315305
|
+
pmStart: typeof fragment.pmStart === "number" ? fragment.pmStart : blockPmRangeFromAttrs(block).pmStart,
|
|
315306
|
+
pmEnd: typeof fragment.pmEnd === "number" ? fragment.pmEnd : blockPmRangeFromAttrs(block).pmEnd
|
|
315307
|
+
};
|
|
315308
|
+
}, isRtlBlock = (block) => {
|
|
315309
|
+
if (block.kind !== "paragraph")
|
|
315310
|
+
return false;
|
|
315311
|
+
return getParagraphInlineDirection(block.attrs) === "rtl";
|
|
315312
|
+
}, determineColumn = (layout, fragmentX, page, fragmentY) => {
|
|
315313
|
+
const columns = resolveColumnsForHit(layout, page, fragmentY);
|
|
315314
|
+
if (!columns || columns.count <= 1)
|
|
315315
|
+
return 0;
|
|
315316
|
+
const pageWidth = page?.size?.w ?? layout.pageSize.w;
|
|
315317
|
+
const margins = page?.margins ?? layout.pages[0]?.margins;
|
|
315318
|
+
const marginLeft = Math.max(0, margins?.left ?? 0);
|
|
315319
|
+
const marginRight = Math.max(0, margins?.right ?? 0);
|
|
315320
|
+
return getColumnAtX(getColumnGeometry(normalizeColumnLayout(columns, Math.max(1, pageWidth - (marginLeft + marginRight)))), fragmentX, marginLeft);
|
|
315321
|
+
}, determineTableColumn = (layout, fragment, page) => {
|
|
315322
|
+
if (typeof fragment.columnIndex === "number") {
|
|
315323
|
+
const count = resolveColumnsForHit(layout, page, fragment.y)?.count ?? 1;
|
|
315324
|
+
return Math.max(0, Math.min(Math.max(0, count - 1), fragment.columnIndex));
|
|
315325
|
+
}
|
|
315326
|
+
return determineColumn(layout, fragment.x, page, fragment.y);
|
|
315327
|
+
}, findLineIndexAtY = (lines, offsetY, fromLine, toLine) => {
|
|
315328
|
+
if (!lines || lines.length === 0)
|
|
315329
|
+
return null;
|
|
315330
|
+
const lineCount = lines.length;
|
|
315331
|
+
if (fromLine < 0 || toLine > lineCount || fromLine >= toLine)
|
|
315332
|
+
return null;
|
|
315333
|
+
let cursor = 0;
|
|
315334
|
+
for (let i4 = fromLine;i4 < toLine; i4 += 1) {
|
|
315335
|
+
const line = lines[i4];
|
|
315336
|
+
if (!line)
|
|
315337
|
+
return null;
|
|
315338
|
+
const next2 = cursor + line.lineHeight;
|
|
315339
|
+
if (offsetY >= cursor && offsetY < next2)
|
|
315340
|
+
return i4;
|
|
315341
|
+
cursor = next2;
|
|
315342
|
+
}
|
|
315343
|
+
return toLine - 1;
|
|
315344
|
+
}, mapPointToPm = (block, line, x, isRTL, availableWidthOverride, alignmentOverride) => {
|
|
315345
|
+
if (block.kind !== "paragraph")
|
|
315346
|
+
return null;
|
|
315347
|
+
const range = computeLinePmRange(block, line);
|
|
315348
|
+
if (range.pmStart == null || range.pmEnd == null)
|
|
315349
|
+
return null;
|
|
315350
|
+
const result = findCharacterAtX(block, line, x, range.pmStart, availableWidthOverride, alignmentOverride);
|
|
315351
|
+
let pmPosition = result.pmPosition;
|
|
315352
|
+
if (isRTL) {
|
|
315353
|
+
const charOffset = result.charOffset;
|
|
315354
|
+
const charsInLine = Math.max(1, line.toChar - line.fromChar);
|
|
315355
|
+
pmPosition = charOffsetToPm(block, line, Math.max(0, Math.min(charsInLine, charsInLine - charOffset)), range.pmStart);
|
|
315356
|
+
}
|
|
315357
|
+
return pmPosition;
|
|
315358
|
+
}, calculatePageTopFallback = (layout, pageIndex) => {
|
|
315359
|
+
const pageGap = layout.pageGap ?? 0;
|
|
315360
|
+
let y$1 = 0;
|
|
315361
|
+
for (let i4 = 0;i4 < pageIndex; i4++) {
|
|
315362
|
+
const pageHeight = layout.pages[i4]?.size?.h ?? layout.pageSize.h;
|
|
315363
|
+
y$1 += pageHeight + pageGap;
|
|
315364
|
+
}
|
|
315365
|
+
return y$1;
|
|
315366
|
+
}, hitTestAtomicFragment = (pageHit, blocks2, measures, point5) => {
|
|
315367
|
+
for (const fragment of pageHit.page.fragments) {
|
|
315368
|
+
if (!isAtomicFragment(fragment))
|
|
315369
|
+
continue;
|
|
315370
|
+
const withinX = point5.x >= fragment.x && point5.x <= fragment.x + fragment.width;
|
|
315371
|
+
const withinY = point5.y >= fragment.y && point5.y <= fragment.y + fragment.height;
|
|
315372
|
+
if (!withinX || !withinY)
|
|
315373
|
+
continue;
|
|
315374
|
+
const blockIndex = findBlockIndexByFragmentId(blocks2, fragment.blockId);
|
|
315375
|
+
if (blockIndex === -1)
|
|
315376
|
+
continue;
|
|
315377
|
+
const block = blocks2[blockIndex];
|
|
315378
|
+
const measure = measures[blockIndex];
|
|
315379
|
+
if (!block || !measure)
|
|
315380
|
+
continue;
|
|
315381
|
+
return {
|
|
315382
|
+
fragment,
|
|
315383
|
+
block,
|
|
315384
|
+
measure,
|
|
315385
|
+
pageIndex: pageHit.pageIndex,
|
|
315386
|
+
pageY: 0
|
|
315387
|
+
};
|
|
315388
|
+
}
|
|
315389
|
+
return null;
|
|
315390
|
+
}, hitTestTableFragment = (pageHit, blocks2, measures, point5) => {
|
|
315391
|
+
for (const fragment of pageHit.page.fragments) {
|
|
315392
|
+
if (fragment.kind !== "table")
|
|
315393
|
+
continue;
|
|
315394
|
+
const tableFragment = fragment;
|
|
315395
|
+
const withinX = point5.x >= tableFragment.x && point5.x <= tableFragment.x + tableFragment.width;
|
|
315396
|
+
const withinY = point5.y >= tableFragment.y && point5.y <= tableFragment.y + tableFragment.height;
|
|
315397
|
+
if (!withinX || !withinY)
|
|
315398
|
+
continue;
|
|
315399
|
+
const blockIndex = blocks2.findIndex((block$1) => block$1.id === tableFragment.blockId);
|
|
315400
|
+
if (blockIndex === -1)
|
|
315401
|
+
continue;
|
|
315402
|
+
const block = blocks2[blockIndex];
|
|
315403
|
+
const measure = measures[blockIndex];
|
|
315404
|
+
if (!block || block.kind !== "table" || !measure || measure.kind !== "table")
|
|
315405
|
+
continue;
|
|
315406
|
+
const tableBlock = block;
|
|
315407
|
+
const tableMeasure = measure;
|
|
315408
|
+
const localX = point5.x - tableFragment.x;
|
|
315409
|
+
const localY = point5.y - tableFragment.y;
|
|
315410
|
+
let rowY = 0;
|
|
315411
|
+
let rowIndex = -1;
|
|
315412
|
+
if (tableMeasure.rows.length === 0 || tableBlock.rows.length === 0)
|
|
315413
|
+
continue;
|
|
315414
|
+
for (let r$1 = tableFragment.fromRow;r$1 < tableFragment.toRow && r$1 < tableMeasure.rows.length; r$1++) {
|
|
315415
|
+
const rowMeasure$1 = tableMeasure.rows[r$1];
|
|
315416
|
+
if (localY >= rowY && localY < rowY + rowMeasure$1.height) {
|
|
315417
|
+
rowIndex = r$1;
|
|
315418
|
+
break;
|
|
315419
|
+
}
|
|
315420
|
+
rowY += rowMeasure$1.height;
|
|
315421
|
+
}
|
|
315422
|
+
if (rowIndex === -1) {
|
|
315423
|
+
rowIndex = Math.min(tableFragment.toRow - 1, tableMeasure.rows.length - 1);
|
|
315424
|
+
if (rowIndex < tableFragment.fromRow)
|
|
315425
|
+
continue;
|
|
315426
|
+
}
|
|
315427
|
+
const rowMeasure = tableMeasure.rows[rowIndex];
|
|
315428
|
+
const row2 = tableBlock.rows[rowIndex];
|
|
315429
|
+
if (!rowMeasure || !row2)
|
|
315430
|
+
continue;
|
|
315431
|
+
const firstCellGridStart = rowMeasure.cells[0]?.gridColumnStart ?? 0;
|
|
315432
|
+
let colX = 0;
|
|
315433
|
+
if (firstCellGridStart > 0 && tableMeasure.columnWidths)
|
|
315434
|
+
for (let col = 0;col < firstCellGridStart && col < tableMeasure.columnWidths.length; col++)
|
|
315435
|
+
colX += tableMeasure.columnWidths[col];
|
|
315436
|
+
const initialColX = colX;
|
|
315437
|
+
let colIndex = -1;
|
|
315438
|
+
if (rowMeasure.cells.length === 0 || row2.cells.length === 0)
|
|
315439
|
+
continue;
|
|
315440
|
+
for (let c = 0;c < rowMeasure.cells.length; c++) {
|
|
315441
|
+
const cellMeasure$1 = rowMeasure.cells[c];
|
|
315442
|
+
if (localX >= colX && localX < colX + cellMeasure$1.width) {
|
|
315443
|
+
colIndex = c;
|
|
315444
|
+
break;
|
|
315445
|
+
}
|
|
315446
|
+
colX += cellMeasure$1.width;
|
|
315447
|
+
}
|
|
315448
|
+
if (colIndex === -1) {
|
|
315449
|
+
if (localX < initialColX)
|
|
315450
|
+
colIndex = 0;
|
|
315451
|
+
else
|
|
315452
|
+
colIndex = rowMeasure.cells.length - 1;
|
|
315453
|
+
if (colIndex < 0)
|
|
315454
|
+
continue;
|
|
315455
|
+
}
|
|
315456
|
+
const cellMeasure = rowMeasure.cells[colIndex];
|
|
315457
|
+
const cell2 = row2.cells[colIndex];
|
|
315458
|
+
if (!cellMeasure || !cell2)
|
|
315459
|
+
continue;
|
|
315460
|
+
const cellBlocks = cell2.blocks ?? (cell2.paragraph ? [cell2.paragraph] : []);
|
|
315461
|
+
const rawMeasures = cellMeasure.blocks ?? (cellMeasure.paragraph ? [cellMeasure.paragraph] : []);
|
|
315462
|
+
const cellBlockMeasures = (Array.isArray(rawMeasures) ? rawMeasures : []).filter((m$1) => m$1 != null && typeof m$1 === "object" && ("kind" in m$1));
|
|
315463
|
+
let blockStartY = 0;
|
|
315464
|
+
let blockStartGlobalLines = 0;
|
|
315465
|
+
const getBlockHeight = (m$1) => {
|
|
315466
|
+
if (!m$1)
|
|
315467
|
+
return 0;
|
|
315468
|
+
if ("totalHeight" in m$1 && typeof m$1.totalHeight === "number")
|
|
315469
|
+
return m$1.totalHeight;
|
|
315470
|
+
if ("height" in m$1 && typeof m$1.height === "number")
|
|
315471
|
+
return m$1.height;
|
|
315472
|
+
return 0;
|
|
315473
|
+
};
|
|
315474
|
+
let nearestParagraphHit = null;
|
|
315475
|
+
for (let i4 = 0;i4 < cellBlocks.length && i4 < cellBlockMeasures.length; i4++) {
|
|
315476
|
+
const cellBlock = cellBlocks[i4];
|
|
315477
|
+
const cellBlockMeasure = cellBlockMeasures[i4];
|
|
315478
|
+
if (cellBlock?.kind !== "paragraph" || cellBlockMeasure?.kind !== "paragraph") {
|
|
315479
|
+
blockStartY += getBlockHeight(cellBlockMeasure);
|
|
315480
|
+
continue;
|
|
315481
|
+
}
|
|
315482
|
+
const blockHeight = getBlockHeight(cellBlockMeasure);
|
|
315483
|
+
const blockEndY = blockStartY + blockHeight;
|
|
315484
|
+
const padding = cell2.attrs?.padding ?? {
|
|
315485
|
+
top: 0,
|
|
315486
|
+
left: 4,
|
|
315487
|
+
right: 4,
|
|
315488
|
+
bottom: 0
|
|
315489
|
+
};
|
|
315490
|
+
const cellLocalX = localX - colX - (padding.left ?? 4);
|
|
315491
|
+
const cellLocalY = localY - rowY - (padding.top ?? 0);
|
|
315492
|
+
const paragraphBlock = cellBlock;
|
|
315493
|
+
const paragraphMeasure = cellBlockMeasure;
|
|
315494
|
+
if (cellLocalY >= blockStartY && cellLocalY < blockEndY) {
|
|
315495
|
+
const unclampedLocalY = cellLocalY - blockStartY;
|
|
315496
|
+
const localYWithinBlock = Math.max(0, Math.min(unclampedLocalY, Math.max(blockHeight, 0)));
|
|
315497
|
+
return {
|
|
315498
|
+
fragment: tableFragment,
|
|
315499
|
+
block: tableBlock,
|
|
315500
|
+
measure: tableMeasure,
|
|
315501
|
+
pageIndex: pageHit.pageIndex,
|
|
315502
|
+
cellRowIndex: rowIndex,
|
|
315503
|
+
cellColIndex: colIndex,
|
|
315504
|
+
cellBlock: paragraphBlock,
|
|
315505
|
+
cellMeasure: paragraphMeasure,
|
|
315506
|
+
localX: Math.max(0, cellLocalX),
|
|
315507
|
+
localY: Math.max(0, localYWithinBlock),
|
|
315508
|
+
blockStartGlobal: blockStartGlobalLines
|
|
315509
|
+
};
|
|
315510
|
+
}
|
|
315511
|
+
const distanceToBlock = cellLocalY < blockStartY ? blockStartY - cellLocalY : Math.max(0, cellLocalY - blockEndY);
|
|
315512
|
+
if (!nearestParagraphHit || distanceToBlock < nearestParagraphHit.distance) {
|
|
315513
|
+
const unclampedLocalY = cellLocalY - blockStartY;
|
|
315514
|
+
nearestParagraphHit = {
|
|
315515
|
+
cellBlock: paragraphBlock,
|
|
315516
|
+
cellMeasure: paragraphMeasure,
|
|
315517
|
+
localX: Math.max(0, cellLocalX),
|
|
315518
|
+
localY: Math.max(0, Math.min(unclampedLocalY, Math.max(blockHeight, 0))),
|
|
315519
|
+
blockStartGlobal: blockStartGlobalLines,
|
|
315520
|
+
distance: distanceToBlock
|
|
315521
|
+
};
|
|
315522
|
+
}
|
|
315523
|
+
blockStartY = blockEndY;
|
|
315524
|
+
blockStartGlobalLines += paragraphMeasure.lines.length;
|
|
315525
|
+
}
|
|
315526
|
+
if (nearestParagraphHit)
|
|
315527
|
+
return {
|
|
315528
|
+
fragment: tableFragment,
|
|
315529
|
+
block: tableBlock,
|
|
315530
|
+
measure: tableMeasure,
|
|
315531
|
+
pageIndex: pageHit.pageIndex,
|
|
315532
|
+
cellRowIndex: rowIndex,
|
|
315533
|
+
cellColIndex: colIndex,
|
|
315534
|
+
cellBlock: nearestParagraphHit.cellBlock,
|
|
315535
|
+
cellMeasure: nearestParagraphHit.cellMeasure,
|
|
315536
|
+
localX: nearestParagraphHit.localX,
|
|
315537
|
+
localY: nearestParagraphHit.localY,
|
|
315538
|
+
blockStartGlobal: nearestParagraphHit.blockStartGlobal
|
|
315539
|
+
};
|
|
315540
|
+
}
|
|
315541
|
+
return null;
|
|
315542
|
+
}, resolveTextboxContentHit = (fragment, block, measure, pageIndex, point5) => {
|
|
315543
|
+
const fragmentWithContent = fragment;
|
|
315544
|
+
const contentMeasures = Array.isArray(fragmentWithContent.contentMeasures) ? fragmentWithContent.contentMeasures : Array.isArray(block.contentMeasures) ? block.contentMeasures : [];
|
|
315545
|
+
const contentBlocks = Array.isArray(block.contentBlocks) ? block.contentBlocks : [];
|
|
315546
|
+
if (contentMeasures.length === 0 || contentBlocks.length === 0)
|
|
315547
|
+
return null;
|
|
315548
|
+
const insets = block.textInsets ?? {
|
|
315549
|
+
top: 0,
|
|
315550
|
+
right: 0,
|
|
315551
|
+
bottom: 0,
|
|
315552
|
+
left: 0
|
|
315553
|
+
};
|
|
315554
|
+
const localX = Math.max(0, point5.x - fragment.x - insets.left);
|
|
315555
|
+
const rawLocalY = point5.y - fragment.y - insets.top;
|
|
315556
|
+
const totalContentHeight = contentMeasures.reduce((sum, m$1) => sum + (m$1?.kind === "paragraph" ? m$1.totalHeight ?? 0 : 0), 0);
|
|
315557
|
+
const availableHeight = Math.max(0, fragment.height - insets.top - insets.bottom);
|
|
315558
|
+
const verticalAlign = block.textVerticalAlign ?? "top";
|
|
315559
|
+
let contentOffset = 0;
|
|
315560
|
+
if (verticalAlign === "center")
|
|
315561
|
+
contentOffset = Math.max(0, (availableHeight - totalContentHeight) / 2);
|
|
315562
|
+
else if (verticalAlign === "bottom")
|
|
315563
|
+
contentOffset = Math.max(0, availableHeight - totalContentHeight);
|
|
315564
|
+
const localY = rawLocalY - contentOffset;
|
|
315565
|
+
let paragraphStartY = 0;
|
|
315566
|
+
let blockStartGlobal = 0;
|
|
315567
|
+
let nearestParagraphHit = null;
|
|
315568
|
+
for (let i4 = 0;i4 < contentBlocks.length && i4 < contentMeasures.length; i4 += 1) {
|
|
315569
|
+
const contentBlock = contentBlocks[i4];
|
|
315570
|
+
const contentMeasure = contentMeasures[i4];
|
|
315571
|
+
if (contentBlock?.kind !== "paragraph" || contentMeasure?.kind !== "paragraph")
|
|
315572
|
+
continue;
|
|
315573
|
+
const paragraphHeight = contentMeasure.totalHeight;
|
|
315574
|
+
const paragraphEndY = paragraphStartY + paragraphHeight;
|
|
315575
|
+
if (localY >= paragraphStartY && localY < paragraphEndY)
|
|
315576
|
+
return {
|
|
315577
|
+
fragment,
|
|
315578
|
+
block,
|
|
315579
|
+
measure,
|
|
315580
|
+
pageIndex,
|
|
315581
|
+
contentBlock,
|
|
315582
|
+
contentMeasure,
|
|
315583
|
+
paragraphIndex: i4,
|
|
315584
|
+
localX,
|
|
315585
|
+
localY: Math.max(0, Math.min(localY - paragraphStartY, Math.max(paragraphHeight, 0))),
|
|
315586
|
+
blockStartGlobal
|
|
315587
|
+
};
|
|
315588
|
+
const distanceToParagraph = localY < paragraphStartY ? paragraphStartY - localY : Math.max(0, localY - paragraphEndY);
|
|
315589
|
+
if (!nearestParagraphHit || distanceToParagraph < nearestParagraphHit.distance)
|
|
315590
|
+
nearestParagraphHit = {
|
|
315591
|
+
contentBlock,
|
|
315592
|
+
contentMeasure,
|
|
315593
|
+
paragraphIndex: i4,
|
|
315594
|
+
localX,
|
|
315595
|
+
localY: Math.max(0, Math.min(localY - paragraphStartY, Math.max(paragraphHeight, 0))),
|
|
315596
|
+
blockStartGlobal,
|
|
315597
|
+
distance: distanceToParagraph
|
|
315598
|
+
};
|
|
315599
|
+
paragraphStartY = paragraphEndY;
|
|
315600
|
+
blockStartGlobal += contentMeasure.lines.length;
|
|
315601
|
+
}
|
|
315602
|
+
if (nearestParagraphHit)
|
|
315603
|
+
return {
|
|
315604
|
+
fragment,
|
|
315605
|
+
block,
|
|
315606
|
+
measure,
|
|
315607
|
+
pageIndex,
|
|
315608
|
+
contentBlock: nearestParagraphHit.contentBlock,
|
|
315609
|
+
contentMeasure: nearestParagraphHit.contentMeasure,
|
|
315610
|
+
paragraphIndex: nearestParagraphHit.paragraphIndex,
|
|
315611
|
+
localX: nearestParagraphHit.localX,
|
|
315612
|
+
localY: nearestParagraphHit.localY,
|
|
315613
|
+
blockStartGlobal: nearestParagraphHit.blockStartGlobal
|
|
315614
|
+
};
|
|
315615
|
+
return null;
|
|
315616
|
+
}, PageGeometryHelper = class {
|
|
314475
315617
|
constructor(config3) {
|
|
314476
315618
|
this.cache = null;
|
|
314477
315619
|
this.config = config3;
|
|
@@ -314686,254 +315828,6 @@ menclose::after {
|
|
|
314686
315828
|
for (const metric of Object.keys(this.metrics))
|
|
314687
315829
|
this.metrics[metric] = [];
|
|
314688
315830
|
}
|
|
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
315831
|
}, logSelectionMapDebug = (payload) => {}, rangesOverlap2 = (startA, endA, startB, endB) => {
|
|
314938
315832
|
if (startA == null)
|
|
314939
315833
|
return false;
|
|
@@ -316851,10 +317745,15 @@ menclose::after {
|
|
|
316851
317745
|
this.#focusEditorAtFirstPosition();
|
|
316852
317746
|
}
|
|
316853
317747
|
#handleClickInHeaderFooterMode(event, x, y$1, pageIndex, pageLocalY) {
|
|
316854
|
-
const
|
|
317748
|
+
const session = this.#deps?.getHeaderFooterSession();
|
|
317749
|
+
const activeSurfaceSelector = session?.session?.mode === "footer" ? ".superdoc-page-footer" : ".superdoc-page-header";
|
|
316855
317750
|
const visiblePointerSurface = resolveVisibleSurfaceAtPointer(event.target, event.clientX, event.clientY);
|
|
316856
317751
|
const clickedInsideVisibleActiveSurface = visiblePointerSurface?.kind === "headerFooter" && visiblePointerSurface.surface.closest(activeSurfaceSelector) != null;
|
|
316857
317752
|
if (visiblePointerSurface?.kind === "bodyContent") {
|
|
317753
|
+
const behindDocSection = (event.target instanceof Element ? event.target.closest("[data-behind-doc-section]") : null)?.dataset.behindDocSection;
|
|
317754
|
+
const sessionMode = session?.session?.mode;
|
|
317755
|
+
if (behindDocSection && behindDocSection === sessionMode)
|
|
317756
|
+
return false;
|
|
316858
317757
|
this.#callbacks.exitHeaderFooterMode?.();
|
|
316859
317758
|
return false;
|
|
316860
317759
|
}
|
|
@@ -316950,6 +317849,8 @@ menclose::after {
|
|
|
316950
317849
|
return false;
|
|
316951
317850
|
if (fragmentHit.fragment.kind !== "image" && fragmentHit.fragment.kind !== "drawing")
|
|
316952
317851
|
return false;
|
|
317852
|
+
if (fragmentHit.fragment.kind === "drawing" && fragmentHit.fragment.drawingKind === "textboxShape")
|
|
317853
|
+
return false;
|
|
316953
317854
|
const editor = this.#deps?.getEditor();
|
|
316954
317855
|
try {
|
|
316955
317856
|
const tr = editor.state.tr.setSelection(NodeSelection.create(doc$12, hit.pos));
|
|
@@ -319803,7 +320704,8 @@ menclose::after {
|
|
|
319803
320704
|
const surfaceElement = pageElement.querySelector(surfaceSelector);
|
|
319804
320705
|
if (!surfaceElement)
|
|
319805
320706
|
return null;
|
|
319806
|
-
const
|
|
320707
|
+
const behindDocFragments = Array.from(pageElement.querySelectorAll(`[data-behind-doc-section="${this.#session.mode}"]`));
|
|
320708
|
+
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
320709
|
if (!entry)
|
|
319808
320710
|
return null;
|
|
319809
320711
|
const pageRect = pageElement.getBoundingClientRect();
|
|
@@ -320967,13 +321869,13 @@ menclose::after {
|
|
|
320967
321869
|
return;
|
|
320968
321870
|
console.log(...args$1);
|
|
320969
321871
|
}, 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
|
|
321872
|
+
var init_src_BBtIMpLJ_es = __esm(() => {
|
|
320971
321873
|
init_rolldown_runtime_Bg48TavK_es();
|
|
320972
|
-
|
|
321874
|
+
init_SuperConverter_CUxtXQFf_es();
|
|
320973
321875
|
init_jszip_C49i9kUs_es();
|
|
320974
321876
|
init_xml_js_CqGKpaft_es();
|
|
320975
321877
|
init_uuid_B2wVPhPi_es();
|
|
320976
|
-
|
|
321878
|
+
init_create_headless_toolbar_DutCjfp2_es();
|
|
320977
321879
|
init_constants_D9qj59G2_es();
|
|
320978
321880
|
init_dist_B8HfvhaK_es();
|
|
320979
321881
|
init_unified_Dsuw2be5_es();
|
|
@@ -328224,7 +329126,89 @@ ${err.toString()}`);
|
|
|
328224
329126
|
return { style: attrs.style };
|
|
328225
329127
|
} },
|
|
328226
329128
|
wrapAttributes: { rendered: false },
|
|
328227
|
-
|
|
329129
|
+
anchorData: { rendered: false },
|
|
329130
|
+
marginOffset: { rendered: false },
|
|
329131
|
+
attributes: { rendered: false },
|
|
329132
|
+
kind: {
|
|
329133
|
+
default: null,
|
|
329134
|
+
rendered: false
|
|
329135
|
+
},
|
|
329136
|
+
width: {
|
|
329137
|
+
default: null,
|
|
329138
|
+
renderDOM: (attrs) => {
|
|
329139
|
+
if (attrs.width == null)
|
|
329140
|
+
return {};
|
|
329141
|
+
return { "data-width": attrs.width };
|
|
329142
|
+
}
|
|
329143
|
+
},
|
|
329144
|
+
height: {
|
|
329145
|
+
default: null,
|
|
329146
|
+
renderDOM: (attrs) => {
|
|
329147
|
+
if (attrs.height == null)
|
|
329148
|
+
return {};
|
|
329149
|
+
return { "data-height": attrs.height };
|
|
329150
|
+
}
|
|
329151
|
+
},
|
|
329152
|
+
fillColor: {
|
|
329153
|
+
default: null,
|
|
329154
|
+
rendered: false
|
|
329155
|
+
},
|
|
329156
|
+
strokeColor: {
|
|
329157
|
+
default: null,
|
|
329158
|
+
rendered: false
|
|
329159
|
+
},
|
|
329160
|
+
strokeWidth: {
|
|
329161
|
+
default: null,
|
|
329162
|
+
rendered: false
|
|
329163
|
+
},
|
|
329164
|
+
rotation: {
|
|
329165
|
+
default: 0,
|
|
329166
|
+
rendered: false
|
|
329167
|
+
},
|
|
329168
|
+
flipH: {
|
|
329169
|
+
default: false,
|
|
329170
|
+
rendered: false
|
|
329171
|
+
},
|
|
329172
|
+
flipV: {
|
|
329173
|
+
default: false,
|
|
329174
|
+
rendered: false
|
|
329175
|
+
},
|
|
329176
|
+
wrap: {
|
|
329177
|
+
default: null,
|
|
329178
|
+
rendered: false
|
|
329179
|
+
},
|
|
329180
|
+
isAnchor: {
|
|
329181
|
+
default: false,
|
|
329182
|
+
rendered: false
|
|
329183
|
+
},
|
|
329184
|
+
drawingContent: {
|
|
329185
|
+
default: null,
|
|
329186
|
+
rendered: false
|
|
329187
|
+
},
|
|
329188
|
+
originalAttributes: {
|
|
329189
|
+
default: null,
|
|
329190
|
+
rendered: false
|
|
329191
|
+
},
|
|
329192
|
+
effectExtent: {
|
|
329193
|
+
default: null,
|
|
329194
|
+
rendered: false
|
|
329195
|
+
},
|
|
329196
|
+
lineEnds: {
|
|
329197
|
+
default: null,
|
|
329198
|
+
rendered: false
|
|
329199
|
+
},
|
|
329200
|
+
hidden: {
|
|
329201
|
+
default: false,
|
|
329202
|
+
rendered: false
|
|
329203
|
+
},
|
|
329204
|
+
isTextBox: {
|
|
329205
|
+
default: false,
|
|
329206
|
+
rendered: false
|
|
329207
|
+
},
|
|
329208
|
+
isWordArt: {
|
|
329209
|
+
default: false,
|
|
329210
|
+
rendered: false
|
|
329211
|
+
}
|
|
328228
329212
|
};
|
|
328229
329213
|
},
|
|
328230
329214
|
parseDOM() {
|
|
@@ -328259,7 +329243,15 @@ ${err.toString()}`);
|
|
|
328259
329243
|
return attrs.sdBlockId ? { "data-sd-block-id": attrs.sdBlockId } : {};
|
|
328260
329244
|
}
|
|
328261
329245
|
},
|
|
328262
|
-
attributes: { rendered: false }
|
|
329246
|
+
attributes: { rendered: false },
|
|
329247
|
+
textInsets: {
|
|
329248
|
+
default: null,
|
|
329249
|
+
rendered: false
|
|
329250
|
+
},
|
|
329251
|
+
textVerticalAlign: {
|
|
329252
|
+
default: null,
|
|
329253
|
+
rendered: false
|
|
329254
|
+
}
|
|
328263
329255
|
};
|
|
328264
329256
|
},
|
|
328265
329257
|
parseDOM() {
|
|
@@ -351666,14 +352658,21 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
351666
352658
|
return null;
|
|
351667
352659
|
const localX = normalized.x - context.region.localX;
|
|
351668
352660
|
const localY = (normalized.pageLocalY ?? normalized.y - context.region.pageIndex * (bodyPageHeight + pageGap)) - context.region.localY;
|
|
352661
|
+
const domHit = this.#resolveHeaderFooterDomHit(context, clientX, clientY);
|
|
352662
|
+
if (domHit) {
|
|
352663
|
+
const doc$3 = this.getActiveEditor().state?.doc;
|
|
352664
|
+
return {
|
|
352665
|
+
...domHit,
|
|
352666
|
+
pos: doc$3 ? Math.max(0, Math.min(domHit.pos, doc$3.content.size)) : domHit.pos
|
|
352667
|
+
};
|
|
352668
|
+
}
|
|
351669
352669
|
if (localX < 0 || localY < 0 || localX > context.region.width || localY > context.region.height)
|
|
351670
352670
|
return null;
|
|
351671
352671
|
const headerPoint = {
|
|
351672
352672
|
x: localX,
|
|
351673
352673
|
y: localY
|
|
351674
352674
|
};
|
|
351675
|
-
const
|
|
351676
|
-
const hit = this.#resolveHeaderFooterDomHit(context, clientX, clientY) ?? geometryHit;
|
|
352675
|
+
const hit = clickToPositionGeometry(context.layout, context.blocks, context.measures, headerPoint) ?? null;
|
|
351677
352676
|
if (!hit)
|
|
351678
352677
|
return null;
|
|
351679
352678
|
const doc$2 = this.getActiveEditor().state?.doc;
|
|
@@ -356644,11 +357643,11 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
356644
357643
|
]);
|
|
356645
357644
|
});
|
|
356646
357645
|
|
|
356647
|
-
// ../../packages/superdoc/dist/chunks/create-super-doc-ui-
|
|
357646
|
+
// ../../packages/superdoc/dist/chunks/create-super-doc-ui-e_ogmxkt.es.js
|
|
356648
357647
|
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
|
|
356650
|
-
|
|
356651
|
-
|
|
357648
|
+
var init_create_super_doc_ui_e_ogmxkt_es = __esm(() => {
|
|
357649
|
+
init_SuperConverter_CUxtXQFf_es();
|
|
357650
|
+
init_create_headless_toolbar_DutCjfp2_es();
|
|
356652
357651
|
DEFAULT_TEXT_ALIGN_OPTIONS = [
|
|
356653
357652
|
{
|
|
356654
357653
|
label: "Left",
|
|
@@ -356939,16 +357938,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
|
|
|
356939
357938
|
|
|
356940
357939
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
356941
357940
|
var init_super_editor_es = __esm(() => {
|
|
356942
|
-
|
|
356943
|
-
|
|
357941
|
+
init_src_BBtIMpLJ_es();
|
|
357942
|
+
init_SuperConverter_CUxtXQFf_es();
|
|
356944
357943
|
init_jszip_C49i9kUs_es();
|
|
356945
357944
|
init_xml_js_CqGKpaft_es();
|
|
356946
|
-
|
|
357945
|
+
init_create_headless_toolbar_DutCjfp2_es();
|
|
356947
357946
|
init_constants_D9qj59G2_es();
|
|
356948
357947
|
init_dist_B8HfvhaK_es();
|
|
356949
357948
|
init_unified_Dsuw2be5_es();
|
|
356950
357949
|
init_DocxZipper_FUsfThjV_es();
|
|
356951
|
-
|
|
357950
|
+
init_create_super_doc_ui_e_ogmxkt_es();
|
|
356952
357951
|
init_ui_C5PAS9hY_es();
|
|
356953
357952
|
init_eventemitter3_BnGqBE_Q_es();
|
|
356954
357953
|
init_errors_CNaD6vcg_es();
|
|
@@ -388467,7 +389466,43 @@ var lineBreakNodeToBreakBlock2 = (node3, { nextBlockId }) => {
|
|
|
388467
389466
|
};
|
|
388468
389467
|
|
|
388469
389468
|
// ../../packages/super-editor/src/editors/v1/core/layout-adapter/converters/shapes.ts
|
|
388470
|
-
|
|
389469
|
+
function hydrateTextboxDrawingContent2(node3, drawingBlock, context) {
|
|
389470
|
+
if (drawingBlock.drawingKind !== "textboxShape") {
|
|
389471
|
+
return drawingBlock;
|
|
389472
|
+
}
|
|
389473
|
+
return {
|
|
389474
|
+
...drawingBlock,
|
|
389475
|
+
contentBlocks: toTextboxParagraphBlocks2(node3, context)
|
|
389476
|
+
};
|
|
389477
|
+
}
|
|
389478
|
+
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) => {
|
|
389479
|
+
const shapeTextboxNode = node3.type === "shapeTextbox" ? node3 : resolveNestedShapeTextboxNode2(node3);
|
|
389480
|
+
const paragraphToFlowBlocks2 = context.converters?.paragraphToFlowBlocks;
|
|
389481
|
+
if (!shapeTextboxNode || !paragraphToFlowBlocks2 || !Array.isArray(shapeTextboxNode.content)) {
|
|
389482
|
+
return [];
|
|
389483
|
+
}
|
|
389484
|
+
const textboxBlocks = [];
|
|
389485
|
+
for (const child of shapeTextboxNode.content) {
|
|
389486
|
+
if (!isParagraphNode2(child))
|
|
389487
|
+
continue;
|
|
389488
|
+
const convertedBlocks = paragraphToFlowBlocks2({
|
|
389489
|
+
para: child,
|
|
389490
|
+
nextBlockId: context.nextBlockId,
|
|
389491
|
+
positions: context.positions,
|
|
389492
|
+
storyKey: context.storyKey,
|
|
389493
|
+
trackedChangesConfig: context.trackedChangesConfig,
|
|
389494
|
+
bookmarks: context.bookmarks,
|
|
389495
|
+
hyperlinkConfig: context.hyperlinkConfig,
|
|
389496
|
+
themeColors: context.themeColors,
|
|
389497
|
+
converters: context.converters,
|
|
389498
|
+
converterContext: context.converterContext,
|
|
389499
|
+
enableComments: context.enableComments,
|
|
389500
|
+
previousParagraphFont: getLastParagraphFont2(textboxBlocks)
|
|
389501
|
+
});
|
|
389502
|
+
textboxBlocks.push(...convertedBlocks);
|
|
389503
|
+
}
|
|
389504
|
+
return textboxBlocks.filter((block) => block.kind === "paragraph");
|
|
389505
|
+
}, resolveNestedShapeTextboxNode2 = (node3) => Array.isArray(node3.content) ? node3.content.find((child) => child?.type === "shapeTextbox") : undefined, normalizeWrapType2 = (value) => {
|
|
388471
389506
|
if (typeof value !== "string")
|
|
388472
389507
|
return;
|
|
388473
389508
|
return WRAP_TYPES2.has(value) ? value : undefined;
|
|
@@ -388609,12 +389644,21 @@ var WRAP_TYPES2, WRAP_TEXT_VALUES2, H_RELATIVE_VALUES2, V_RELATIVE_VALUES2, H_AL
|
|
|
388609
389644
|
};
|
|
388610
389645
|
var init_shapes = __esm(() => {
|
|
388611
389646
|
init_utilities();
|
|
389647
|
+
init_paragraph2();
|
|
388612
389648
|
WRAP_TYPES2 = new Set(["None", "Square", "Tight", "Through", "TopAndBottom", "Inline"]);
|
|
388613
389649
|
WRAP_TEXT_VALUES2 = new Set(["bothSides", "left", "right", "largest"]);
|
|
388614
389650
|
H_RELATIVE_VALUES2 = new Set(["column", "page", "margin"]);
|
|
388615
389651
|
V_RELATIVE_VALUES2 = new Set(["paragraph", "page", "margin"]);
|
|
388616
389652
|
H_ALIGN_VALUES2 = new Set(["left", "center", "right"]);
|
|
388617
389653
|
V_ALIGN_VALUES2 = new Set(["top", "center", "bottom"]);
|
|
389654
|
+
TEXTBOX_CONTAINER_TYPES2 = new Set([
|
|
389655
|
+
"run",
|
|
389656
|
+
"link",
|
|
389657
|
+
"hyperlink",
|
|
389658
|
+
"structuredContent",
|
|
389659
|
+
"fieldAnnotation",
|
|
389660
|
+
"smartTag"
|
|
389661
|
+
]);
|
|
388618
389662
|
});
|
|
388619
389663
|
|
|
388620
389664
|
// ../../packages/super-editor/src/editors/v1/core/layout-adapter/converters/content-block.ts
|
|
@@ -389657,14 +390701,14 @@ var isTableRowNode2 = (node3) => node3.type === "tableRow" || node3.type === "ta
|
|
|
389657
390701
|
if (childNode.type === "shapeContainer" && context.converters?.shapeContainerNodeToDrawingBlock) {
|
|
389658
390702
|
const drawingBlock = context.converters.shapeContainerNodeToDrawingBlock(childNode, context.nextBlockId, context.positions);
|
|
389659
390703
|
if (drawingBlock && drawingBlock.kind === "drawing") {
|
|
389660
|
-
blocks2.push(drawingBlock);
|
|
390704
|
+
blocks2.push(hydrateTextboxDrawingContent2(childNode, drawingBlock, context));
|
|
389661
390705
|
}
|
|
389662
390706
|
continue;
|
|
389663
390707
|
}
|
|
389664
390708
|
if (childNode.type === "shapeTextbox" && context.converters?.shapeTextboxNodeToDrawingBlock) {
|
|
389665
390709
|
const drawingBlock = context.converters.shapeTextboxNodeToDrawingBlock(childNode, context.nextBlockId, context.positions);
|
|
389666
390710
|
if (drawingBlock && drawingBlock.kind === "drawing") {
|
|
389667
|
-
blocks2.push(drawingBlock);
|
|
390711
|
+
blocks2.push(hydrateTextboxDrawingContent2(childNode, drawingBlock, context));
|
|
389668
390712
|
}
|
|
389669
390713
|
continue;
|
|
389670
390714
|
}
|
|
@@ -389821,9 +390865,31 @@ var init_table = __esm(() => {
|
|
|
389821
390865
|
init_sdt();
|
|
389822
390866
|
init_ooxml();
|
|
389823
390867
|
init_direction();
|
|
390868
|
+
init_shapes();
|
|
389824
390869
|
});
|
|
389825
390870
|
|
|
389826
390871
|
// ../../packages/super-editor/src/editors/v1/core/layout-adapter/converters/paragraph.ts
|
|
390872
|
+
function getLastParagraphFont2(blocks2) {
|
|
390873
|
+
for (let i4 = blocks2.length - 1;i4 >= 0; i4--) {
|
|
390874
|
+
const block = blocks2[i4];
|
|
390875
|
+
if (block.kind === "paragraph") {
|
|
390876
|
+
const para = block;
|
|
390877
|
+
const firstRun = para.runs?.[0];
|
|
390878
|
+
if (!firstRun)
|
|
390879
|
+
continue;
|
|
390880
|
+
const run2 = firstRun;
|
|
390881
|
+
if (typeof run2.text === "string" && run2.text.length === 0) {
|
|
390882
|
+
continue;
|
|
390883
|
+
}
|
|
390884
|
+
const fontFamily = typeof run2.fontFamily === "string" ? run2.fontFamily.trim() : "";
|
|
390885
|
+
const fontSize = typeof run2.fontSize === "number" && Number.isFinite(run2.fontSize) ? run2.fontSize : NaN;
|
|
390886
|
+
if (fontFamily.length > 0 && fontSize > 0) {
|
|
390887
|
+
return { fontFamily, fontSize };
|
|
390888
|
+
}
|
|
390889
|
+
}
|
|
390890
|
+
}
|
|
390891
|
+
return;
|
|
390892
|
+
}
|
|
389827
390893
|
var INLINE_CONVERTERS_REGISTRY2;
|
|
389828
390894
|
var init_paragraph2 = __esm(() => {
|
|
389829
390895
|
init_src2();
|
|
@@ -426853,7 +427919,7 @@ var init_run_properties_export = __esm(() => {
|
|
|
426853
427919
|
});
|
|
426854
427920
|
|
|
426855
427921
|
// ../../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) => {
|
|
427922
|
+
var XML_NODE_NAME13 = "w:r", SD_KEY_NAME2 = "run", REFERENCE_RUN_STYLE_BY_XML_NAME2, BLOCK_HOIST_TYPES2, hasXmlNodeNamed2 = (node4, targetName) => {
|
|
426857
427923
|
if (!node4 || typeof node4 !== "object")
|
|
426858
427924
|
return false;
|
|
426859
427925
|
if (node4.name === targetName)
|
|
@@ -426976,6 +428042,12 @@ var XML_NODE_NAME13 = "w:r", SD_KEY_NAME2 = "run", REFERENCE_RUN_STYLE_BY_XML_NA
|
|
|
426976
428042
|
const contentElements = rPrNode ? elements.filter((el) => el !== rPrNode) : elements;
|
|
426977
428043
|
const childParams = { ...params3, nodes: contentElements };
|
|
426978
428044
|
const content4 = nodeListHandler?.handler(childParams) || [];
|
|
428045
|
+
if (Array.isArray(content4) && content4.length > 0 && content4.every((child) => BLOCK_HOIST_TYPES2.has(child?.type))) {
|
|
428046
|
+
return content4.filter(Boolean).map((child) => ({
|
|
428047
|
+
...child,
|
|
428048
|
+
marks: Array.isArray(child?.marks) ? child.marks : []
|
|
428049
|
+
}));
|
|
428050
|
+
}
|
|
426979
428051
|
const contentWithRunMarks = (Array.isArray(content4) ? content4 : []).map((child) => {
|
|
426980
428052
|
if (!child || typeof child !== "object")
|
|
426981
428053
|
return child;
|
|
@@ -427198,6 +428270,7 @@ var init_r_translator = __esm(() => {
|
|
|
427198
428270
|
"w:footnoteReference": "FootnoteReference",
|
|
427199
428271
|
"w:endnoteReference": "EndnoteReference"
|
|
427200
428272
|
};
|
|
428273
|
+
BLOCK_HOIST_TYPES2 = new Set(["shapeContainer"]);
|
|
427201
428274
|
COMPLEX_SCRIPT_CODEPOINT_RANGES2 = [
|
|
427202
428275
|
[1424, 2303],
|
|
427203
428276
|
[2304, 4255],
|
|
@@ -445193,6 +446266,162 @@ var init_chart_helpers = __esm(() => {
|
|
|
445193
446266
|
CHART_TYPE_NAMES2 = new Set(Object.keys(CHART_TYPE_MAP2));
|
|
445194
446267
|
});
|
|
445195
446268
|
|
|
446269
|
+
// ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/p/index.js
|
|
446270
|
+
var init_p = __esm(() => {
|
|
446271
|
+
init_p_translator();
|
|
446272
|
+
});
|
|
446273
|
+
|
|
446274
|
+
// ../../packages/super-editor/src/editors/v1/core/super-converter/v2/importer/paragraphNodeImporter.js
|
|
446275
|
+
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) => {
|
|
446276
|
+
const elements = (paragraphProperties.elements || []).filter((element3) => element3?.name !== "w:sectPr").map((element3) => carbonCopy2(element3));
|
|
446277
|
+
if (elements.length === 0)
|
|
446278
|
+
return null;
|
|
446279
|
+
return {
|
|
446280
|
+
...carbonCopy2(paragraphProperties),
|
|
446281
|
+
elements
|
|
446282
|
+
};
|
|
446283
|
+
}, inheritWrapperParagraphProperties2 = (blockFieldElement, paragraphProperties) => {
|
|
446284
|
+
if (!paragraphProperties)
|
|
446285
|
+
return blockFieldElement;
|
|
446286
|
+
const fieldElements = Array.isArray(blockFieldElement?.elements) ? blockFieldElement.elements : [];
|
|
446287
|
+
const firstParagraphIndex = fieldElements.findIndex((element3) => element3?.name === "w:p");
|
|
446288
|
+
if (firstParagraphIndex < 0)
|
|
446289
|
+
return blockFieldElement;
|
|
446290
|
+
const firstParagraph = fieldElements[firstParagraphIndex];
|
|
446291
|
+
const firstParagraphElements = Array.isArray(firstParagraph.elements) ? firstParagraph.elements : [];
|
|
446292
|
+
if (hasParagraphProperties2(firstParagraphElements))
|
|
446293
|
+
return blockFieldElement;
|
|
446294
|
+
const renderedParagraphProperties = cloneParagraphPropertiesForRenderedResult2(paragraphProperties);
|
|
446295
|
+
const inheritedFirstParagraph = {
|
|
446296
|
+
...firstParagraph,
|
|
446297
|
+
elements: renderedParagraphProperties ? [renderedParagraphProperties, ...firstParagraphElements] : firstParagraphElements
|
|
446298
|
+
};
|
|
446299
|
+
return {
|
|
446300
|
+
...blockFieldElement,
|
|
446301
|
+
attributes: {
|
|
446302
|
+
...blockFieldElement.attributes || {},
|
|
446303
|
+
wrapperParagraphProperties: carbonCopy2(paragraphProperties)
|
|
446304
|
+
},
|
|
446305
|
+
elements: fieldElements.map((element3, index3) => index3 === firstParagraphIndex ? inheritedFirstParagraph : element3)
|
|
446306
|
+
};
|
|
446307
|
+
}, hoistBlockFieldNodes2 = (params3, paragraphNode) => {
|
|
446308
|
+
const paragraphElements = Array.isArray(paragraphNode?.elements) ? paragraphNode.elements : [];
|
|
446309
|
+
const blockFieldElements = paragraphElements.filter((element3) => BLOCK_FIELD_XML_NAMES2.has(element3?.name));
|
|
446310
|
+
if (blockFieldElements.length === 0)
|
|
446311
|
+
return null;
|
|
446312
|
+
const nodes = [];
|
|
446313
|
+
const remainingElements = paragraphElements.filter((element3) => !BLOCK_FIELD_XML_NAMES2.has(element3?.name));
|
|
446314
|
+
const wrapperParagraphProperties = findParagraphProperties2(remainingElements);
|
|
446315
|
+
const shouldTransferWrapperProperties = !hasMeaningfulParagraphContent3(remainingElements);
|
|
446316
|
+
if (hasMeaningfulParagraphContent3(remainingElements)) {
|
|
446317
|
+
const paragraph4 = translator121.encode({
|
|
446318
|
+
...params3,
|
|
446319
|
+
nodes: [
|
|
446320
|
+
{
|
|
446321
|
+
...paragraphNode,
|
|
446322
|
+
elements: remainingElements
|
|
446323
|
+
}
|
|
446324
|
+
]
|
|
446325
|
+
});
|
|
446326
|
+
if (paragraph4) {
|
|
446327
|
+
nodes.push(paragraph4);
|
|
446328
|
+
}
|
|
446329
|
+
}
|
|
446330
|
+
blockFieldElements.forEach((blockFieldElement) => {
|
|
446331
|
+
const fieldElement = shouldTransferWrapperProperties ? inheritWrapperParagraphProperties2(blockFieldElement, wrapperParagraphProperties) : blockFieldElement;
|
|
446332
|
+
nodes.push(...params3.nodeListHandler.handler({
|
|
446333
|
+
...params3,
|
|
446334
|
+
nodes: [fieldElement],
|
|
446335
|
+
path: [...params3.path || [], paragraphNode]
|
|
446336
|
+
}));
|
|
446337
|
+
});
|
|
446338
|
+
return nodes;
|
|
446339
|
+
}, handleParagraphNode4 = (params3) => {
|
|
446340
|
+
const { nodes } = params3;
|
|
446341
|
+
if (nodes.length === 0 || nodes[0].name !== "w:p") {
|
|
446342
|
+
return { nodes: [], consumed: 0 };
|
|
446343
|
+
}
|
|
446344
|
+
const hoistedNodes = hoistBlockFieldNodes2(params3, nodes[0]);
|
|
446345
|
+
if (hoistedNodes) {
|
|
446346
|
+
return { nodes: hoistedNodes, consumed: 1 };
|
|
446347
|
+
}
|
|
446348
|
+
const schemaNode = translator121.encode(params3);
|
|
446349
|
+
const newNodes = Array.isArray(schemaNode) ? schemaNode : schemaNode ? [schemaNode] : [];
|
|
446350
|
+
return { nodes: newNodes, consumed: 1 };
|
|
446351
|
+
}, paragraphNodeHandlerEntity2;
|
|
446352
|
+
var init_paragraphNodeImporter = __esm(() => {
|
|
446353
|
+
init_p();
|
|
446354
|
+
init_block_field_xml_names();
|
|
446355
|
+
paragraphNodeHandlerEntity2 = {
|
|
446356
|
+
handlerName: "paragraphNodeHandler",
|
|
446357
|
+
handler: handleParagraphNode4
|
|
446358
|
+
};
|
|
446359
|
+
});
|
|
446360
|
+
|
|
446361
|
+
// ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/wp/helpers/import-drawingml-textbox.js
|
|
446362
|
+
function stripRunNodeMarks2(nodes) {
|
|
446363
|
+
if (!Array.isArray(nodes))
|
|
446364
|
+
return nodes;
|
|
446365
|
+
return nodes.map((node4) => {
|
|
446366
|
+
if (!node4 || typeof node4 !== "object")
|
|
446367
|
+
return node4;
|
|
446368
|
+
const stripped = node4.type === "run" && Array.isArray(node4.marks) && node4.marks.length > 0 ? { ...node4, marks: [] } : node4;
|
|
446369
|
+
if (Array.isArray(stripped.content)) {
|
|
446370
|
+
return { ...stripped, content: stripRunNodeMarks2(stripped.content) };
|
|
446371
|
+
}
|
|
446372
|
+
return stripped;
|
|
446373
|
+
});
|
|
446374
|
+
}
|
|
446375
|
+
function importDrawingMLTextbox2({
|
|
446376
|
+
params: params3,
|
|
446377
|
+
drawingNode,
|
|
446378
|
+
textBoxContent,
|
|
446379
|
+
bodyPr,
|
|
446380
|
+
baseAttrs = {},
|
|
446381
|
+
paragraphImporter
|
|
446382
|
+
}) {
|
|
446383
|
+
if (!textBoxContent) {
|
|
446384
|
+
return null;
|
|
446385
|
+
}
|
|
446386
|
+
const processedContent = preProcessTextBoxContent2(textBoxContent, params3);
|
|
446387
|
+
const textboxParagraphs = collectTextBoxParagraphs2(processedContent?.elements || []);
|
|
446388
|
+
const importParagraph = typeof paragraphImporter === "function" ? paragraphImporter : (paragraph4) => {
|
|
446389
|
+
const imported = handleParagraphNode4({
|
|
446390
|
+
...params3,
|
|
446391
|
+
nodes: [paragraph4]
|
|
446392
|
+
});
|
|
446393
|
+
return imported?.nodes || [];
|
|
446394
|
+
};
|
|
446395
|
+
const rawNodes = textboxParagraphs.flatMap((paragraph4) => {
|
|
446396
|
+
const imported = importParagraph(paragraph4);
|
|
446397
|
+
return Array.isArray(imported) ? imported : imported ? [imported] : [];
|
|
446398
|
+
});
|
|
446399
|
+
const contentNodes = stripRunNodeMarks2(rawNodes);
|
|
446400
|
+
const { verticalAlign, insets } = extractBodyPrProperties2(bodyPr);
|
|
446401
|
+
return {
|
|
446402
|
+
type: "shapeContainer",
|
|
446403
|
+
attrs: {
|
|
446404
|
+
...baseAttrs,
|
|
446405
|
+
drawingContent: drawingNode
|
|
446406
|
+
},
|
|
446407
|
+
content: [
|
|
446408
|
+
{
|
|
446409
|
+
type: "shapeTextbox",
|
|
446410
|
+
attrs: {
|
|
446411
|
+
textInsets: { top: insets.top, right: insets.right, bottom: insets.bottom, left: insets.left },
|
|
446412
|
+
textVerticalAlign: verticalAlign,
|
|
446413
|
+
attributes: {}
|
|
446414
|
+
},
|
|
446415
|
+
content: contentNodes
|
|
446416
|
+
}
|
|
446417
|
+
]
|
|
446418
|
+
};
|
|
446419
|
+
}
|
|
446420
|
+
var init_import_drawingml_textbox = __esm(() => {
|
|
446421
|
+
init_textbox_content_helpers();
|
|
446422
|
+
init_paragraphNodeImporter();
|
|
446423
|
+
});
|
|
446424
|
+
|
|
445196
446425
|
// ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.js
|
|
445197
446426
|
function handleImageNode3(node4, params3, isAnchor) {
|
|
445198
446427
|
if (!node4)
|
|
@@ -445679,6 +446908,94 @@ function extractTextFromTextBox2(textBoxContent, bodyPr, params3 = {}) {
|
|
|
445679
446908
|
wrap: wrap6
|
|
445680
446909
|
};
|
|
445681
446910
|
}
|
|
446911
|
+
function extractFieldInlineNodes2(node4) {
|
|
446912
|
+
if (node4?.name === "sd:autoPageNumber") {
|
|
446913
|
+
return [{ type: "page-number", attrs: { marksAsAttrs: [], instruction: "PAGE" } }];
|
|
446914
|
+
}
|
|
446915
|
+
if (node4?.name === "sd:totalPageNumber") {
|
|
446916
|
+
return [{ type: "total-page-number", attrs: { marksAsAttrs: [], instruction: "NUMPAGES" } }];
|
|
446917
|
+
}
|
|
446918
|
+
if (node4?.name === "sd:sectionPageCount") {
|
|
446919
|
+
const cachedText = node4?.attributes?.resolvedText ?? node4?.attributes?.importedCachedText ?? "";
|
|
446920
|
+
if (!cachedText)
|
|
446921
|
+
return [];
|
|
446922
|
+
return [{ type: "text", text: cachedText }];
|
|
446923
|
+
}
|
|
446924
|
+
return [];
|
|
446925
|
+
}
|
|
446926
|
+
function extractInlineNodesFromRun2(run2, params3) {
|
|
446927
|
+
if (!run2?.elements)
|
|
446928
|
+
return [];
|
|
446929
|
+
const nodes = [];
|
|
446930
|
+
run2.elements.forEach((el) => {
|
|
446931
|
+
if (el.name === "w:t" || el.name === "w:delText") {
|
|
446932
|
+
const textNode = el.elements?.find((n) => n.type === "text");
|
|
446933
|
+
if (!textNode || typeof textNode.text !== "string")
|
|
446934
|
+
return;
|
|
446935
|
+
const cleanedText = textNode.text.replace(/\[\[sdspace\]\]/g, " ");
|
|
446936
|
+
if (cleanedText.length > 0) {
|
|
446937
|
+
nodes.push({ type: "text", text: cleanedText });
|
|
446938
|
+
}
|
|
446939
|
+
} else if (el.name === "w:tab") {
|
|
446940
|
+
nodes.push({ type: "text", text: "\t" });
|
|
446941
|
+
} else if (el.name === "w:br") {
|
|
446942
|
+
nodes.push({ type: "lineBreak", attrs: {} });
|
|
446943
|
+
} else if (el.name === "sd:autoPageNumber" || el.name === "sd:totalPageNumber" || el.name === "sd:sectionPageCount") {
|
|
446944
|
+
nodes.push(...extractFieldInlineNodes2(el));
|
|
446945
|
+
} else if (el.name === "w:drawing") {
|
|
446946
|
+
const inline = el.elements?.find((child) => child?.name === "wp:inline");
|
|
446947
|
+
if (!inline)
|
|
446948
|
+
return;
|
|
446949
|
+
const imagePm = handleImageNode3(inline, { ...params3, nodes: [el] }, false);
|
|
446950
|
+
if (imagePm?.type === "image" && imagePm.attrs?.hidden !== true) {
|
|
446951
|
+
nodes.push(imagePm);
|
|
446952
|
+
}
|
|
446953
|
+
}
|
|
446954
|
+
});
|
|
446955
|
+
return nodes;
|
|
446956
|
+
}
|
|
446957
|
+
function paragraphToPmParagraph2(paragraph4, params3) {
|
|
446958
|
+
const paragraphNode = collectTextBoxParagraphs2([paragraph4])[0];
|
|
446959
|
+
if (!paragraphNode)
|
|
446960
|
+
return null;
|
|
446961
|
+
const paragraphProperties = resolveParagraphPropertiesForTextBox2(paragraphNode, params3);
|
|
446962
|
+
const alignment = extractParagraphAlignment2(paragraphNode) || "left";
|
|
446963
|
+
const content4 = [];
|
|
446964
|
+
let pendingRunContent = [];
|
|
446965
|
+
const flushPendingRun = () => {
|
|
446966
|
+
if (pendingRunContent.length === 0)
|
|
446967
|
+
return;
|
|
446968
|
+
content4.push({ type: "run", attrs: {}, content: pendingRunContent });
|
|
446969
|
+
pendingRunContent = [];
|
|
446970
|
+
};
|
|
446971
|
+
(paragraphNode.elements || []).forEach((element3) => {
|
|
446972
|
+
if (element3?.name === "w:r") {
|
|
446973
|
+
const inlineParts = extractInlineNodesFromRun2(element3, params3);
|
|
446974
|
+
inlineParts.forEach((part) => {
|
|
446975
|
+
if (part?.type === "image") {
|
|
446976
|
+
flushPendingRun();
|
|
446977
|
+
content4.push(part);
|
|
446978
|
+
return;
|
|
446979
|
+
}
|
|
446980
|
+
pendingRunContent.push(part);
|
|
446981
|
+
});
|
|
446982
|
+
return;
|
|
446983
|
+
}
|
|
446984
|
+
if (element3?.name?.startsWith("sd:")) {
|
|
446985
|
+
const runContent = extractFieldInlineNodes2(element3);
|
|
446986
|
+
if (runContent.length > 0) {
|
|
446987
|
+
pendingRunContent.push(...runContent);
|
|
446988
|
+
}
|
|
446989
|
+
}
|
|
446990
|
+
});
|
|
446991
|
+
flushPendingRun();
|
|
446992
|
+
return {
|
|
446993
|
+
type: "paragraph",
|
|
446994
|
+
attrs: { paragraphProperties, textAlign: alignment },
|
|
446995
|
+
content: content4,
|
|
446996
|
+
marks: []
|
|
446997
|
+
};
|
|
446998
|
+
}
|
|
445682
446999
|
function getVectorShape2({
|
|
445683
447000
|
params: params3,
|
|
445684
447001
|
node: node4,
|
|
@@ -445730,14 +447047,46 @@ function getVectorShape2({
|
|
|
445730
447047
|
const textBoxContent = textBox?.elements?.find((el) => el.name === "w:txbxContent");
|
|
445731
447048
|
const bodyPr = wsp.elements?.find((el) => el.name === "wps:bodyPr");
|
|
445732
447049
|
const nonVisualShapeProps = wsp.elements?.find((el) => el.name === "wps:cNvSpPr");
|
|
447050
|
+
const isWordArt = bodyPr?.attributes?.["fromWordArt"] === "1";
|
|
447051
|
+
const isTextBox = nonVisualShapeProps?.attributes?.["txBox"] === "1";
|
|
447052
|
+
if (isTextBox && textBoxContent) {
|
|
447053
|
+
return importDrawingMLTextbox2({
|
|
447054
|
+
params: params3,
|
|
447055
|
+
drawingNode: drawingNode?.name === "w:drawing" ? drawingNode : null,
|
|
447056
|
+
textBoxContent,
|
|
447057
|
+
bodyPr,
|
|
447058
|
+
baseAttrs: {
|
|
447059
|
+
...schemaAttrs,
|
|
447060
|
+
width,
|
|
447061
|
+
height,
|
|
447062
|
+
rotation,
|
|
447063
|
+
flipH,
|
|
447064
|
+
flipV,
|
|
447065
|
+
fillColor,
|
|
447066
|
+
strokeColor,
|
|
447067
|
+
strokeWidth,
|
|
447068
|
+
lineEnds,
|
|
447069
|
+
effectExtent,
|
|
447070
|
+
marginOffset,
|
|
447071
|
+
anchorData,
|
|
447072
|
+
wrap: wrap6,
|
|
447073
|
+
isAnchor,
|
|
447074
|
+
isWordArt,
|
|
447075
|
+
isTextBox,
|
|
447076
|
+
originalAttributes: node4?.attributes
|
|
447077
|
+
},
|
|
447078
|
+
paragraphImporter: params3?.nodeListHandler != null ? undefined : (paragraph4) => {
|
|
447079
|
+
const imported = paragraphToPmParagraph2(paragraph4, params3);
|
|
447080
|
+
return Array.isArray(imported) ? imported : imported ? [imported] : [];
|
|
447081
|
+
}
|
|
447082
|
+
});
|
|
447083
|
+
}
|
|
445733
447084
|
let textContent2 = null;
|
|
445734
447085
|
let textAlign = "left";
|
|
445735
447086
|
if (textBoxContent) {
|
|
445736
447087
|
textContent2 = extractTextFromTextBox2(textBoxContent, bodyPr, params3);
|
|
445737
447088
|
textAlign = textContent2?.horizontalAlign || "left";
|
|
445738
447089
|
}
|
|
445739
|
-
const isWordArt = bodyPr?.attributes?.["fromWordArt"] === "1";
|
|
445740
|
-
const isTextBox = nonVisualShapeProps?.attributes?.["txBox"] === "1";
|
|
445741
447090
|
return {
|
|
445742
447091
|
type: "vectorShape",
|
|
445743
447092
|
attrs: {
|
|
@@ -445876,6 +447225,38 @@ var DRAWING_XML_TAG2 = "w:drawing", SHAPE_URI2 = "http://schemas.microsoft.com/o
|
|
|
445876
447225
|
if (result)
|
|
445877
447226
|
return result;
|
|
445878
447227
|
}
|
|
447228
|
+
const nonVisualShapeProps = wsp.elements?.find((el) => el.name === "wps:cNvSpPr");
|
|
447229
|
+
const isTextBox = nonVisualShapeProps?.attributes?.["txBox"] === "1";
|
|
447230
|
+
if (isTextBox && textBoxContent) {
|
|
447231
|
+
const bodyPr = wsp.elements?.find((el) => el.name === "wps:bodyPr");
|
|
447232
|
+
const drawingNode = params3.nodes?.[0];
|
|
447233
|
+
const result = importDrawingMLTextbox2({
|
|
447234
|
+
params: params3,
|
|
447235
|
+
drawingNode: drawingNode?.name === "w:drawing" ? drawingNode : null,
|
|
447236
|
+
textBoxContent,
|
|
447237
|
+
bodyPr,
|
|
447238
|
+
baseAttrs: {
|
|
447239
|
+
width: size3?.width,
|
|
447240
|
+
height: size3?.height,
|
|
447241
|
+
marginOffset,
|
|
447242
|
+
anchorData,
|
|
447243
|
+
wrap: wrap6,
|
|
447244
|
+
isAnchor,
|
|
447245
|
+
isTextBox: true,
|
|
447246
|
+
originalAttributes: node4?.attributes,
|
|
447247
|
+
...params3.nodes?.[0]?.name === "w:drawing" ? { drawingContent: params3.nodes[0] } : {}
|
|
447248
|
+
},
|
|
447249
|
+
paragraphImporter: params3?.nodeListHandler != null ? undefined : (paragraph4) => {
|
|
447250
|
+
const imported = paragraphToPmParagraph2(paragraph4, params3);
|
|
447251
|
+
return Array.isArray(imported) ? imported : imported ? [imported] : [];
|
|
447252
|
+
}
|
|
447253
|
+
});
|
|
447254
|
+
if (result?.attrs && isHidden) {
|
|
447255
|
+
result.attrs.hidden = true;
|
|
447256
|
+
}
|
|
447257
|
+
if (result)
|
|
447258
|
+
return result;
|
|
447259
|
+
}
|
|
445879
447260
|
const fallbackType = textBoxContent ? "textbox" : "drawing";
|
|
445880
447261
|
const placeholder = buildShapePlaceholder2(node4, size3, padding, marginOffset, fallbackType);
|
|
445881
447262
|
if (placeholder?.attrs && isHidden) {
|
|
@@ -446172,6 +447553,7 @@ var init_encode_image_node_helpers = __esm(() => {
|
|
|
446172
447553
|
init_tiff_converter();
|
|
446173
447554
|
init_textbox_content_helpers();
|
|
446174
447555
|
init_chart_helpers();
|
|
447556
|
+
init_import_drawingml_textbox();
|
|
446175
447557
|
});
|
|
446176
447558
|
|
|
446177
447559
|
// ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/wp/anchor/helpers/handle-anchor-node.js
|
|
@@ -448511,11 +449893,6 @@ var init_translate_document_section = __esm(() => {
|
|
|
448511
449893
|
init_translateChildNodes();
|
|
448512
449894
|
});
|
|
448513
449895
|
|
|
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
449896
|
// ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/sdt/helpers/translate-document-part-obj.js
|
|
448520
449897
|
function translateDocumentPartObj2(params3) {
|
|
448521
449898
|
const { node: node4 } = params3;
|
|
@@ -452215,93 +453592,6 @@ var init_textNodeImporter = __esm(() => {
|
|
|
452215
453592
|
};
|
|
452216
453593
|
});
|
|
452217
453594
|
|
|
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
453595
|
// ../../packages/super-editor/src/editors/v1/core/super-converter/v2/importer/sdtNodeImporter.js
|
|
452306
453596
|
var handleSdtNode2 = (params3) => {
|
|
452307
453597
|
const { nodes } = params3;
|
|
@@ -456386,9 +457676,16 @@ function handleShapeTextboxImport2({ params: params3, pict }) {
|
|
|
456386
457676
|
}
|
|
456387
457677
|
const parsedStyle = parseInlineStyles2(shapeAttrs.style);
|
|
456388
457678
|
const shapeStyle = buildStyles2(parsedStyle);
|
|
457679
|
+
const positionData = extractPositionData2(parsedStyle);
|
|
456389
457680
|
if (shapeStyle) {
|
|
456390
457681
|
schemaAttrs.style = shapeStyle;
|
|
456391
457682
|
}
|
|
457683
|
+
if (positionData.anchorData) {
|
|
457684
|
+
schemaAttrs.anchorData = positionData.anchorData;
|
|
457685
|
+
}
|
|
457686
|
+
if (positionData.marginOffset) {
|
|
457687
|
+
schemaAttrs.marginOffset = positionData.marginOffset;
|
|
457688
|
+
}
|
|
456392
457689
|
const textbox = shape.elements?.find((el) => el.name === "v:textbox");
|
|
456393
457690
|
const wrap6 = shape.elements?.find((el) => el.name === "w10:wrap");
|
|
456394
457691
|
if (wrap6?.attributes) {
|
|
@@ -456431,6 +457728,44 @@ function buildStyles2(styleObject) {
|
|
|
456431
457728
|
}
|
|
456432
457729
|
return style2;
|
|
456433
457730
|
}
|
|
457731
|
+
function extractPositionData2(styleObject) {
|
|
457732
|
+
const anchorData = {};
|
|
457733
|
+
const marginOffset = {};
|
|
457734
|
+
if (styleObject["mso-position-horizontal"]) {
|
|
457735
|
+
anchorData.alignH = styleObject["mso-position-horizontal"];
|
|
457736
|
+
}
|
|
457737
|
+
if (styleObject["mso-position-horizontal-relative"]) {
|
|
457738
|
+
anchorData.hRelativeFrom = styleObject["mso-position-horizontal-relative"];
|
|
457739
|
+
}
|
|
457740
|
+
if (styleObject["mso-position-vertical"]) {
|
|
457741
|
+
anchorData.alignV = styleObject["mso-position-vertical"];
|
|
457742
|
+
}
|
|
457743
|
+
if (styleObject["mso-position-vertical-relative"]) {
|
|
457744
|
+
anchorData.vRelativeFrom = styleObject["mso-position-vertical-relative"];
|
|
457745
|
+
}
|
|
457746
|
+
if (styleObject["margin-left"] != null) {
|
|
457747
|
+
marginOffset.horizontal = convertToPixels2(styleObject["margin-left"]);
|
|
457748
|
+
}
|
|
457749
|
+
if (styleObject["margin-top"] != null) {
|
|
457750
|
+
marginOffset.top = convertToPixels2(styleObject["margin-top"]);
|
|
457751
|
+
}
|
|
457752
|
+
return {
|
|
457753
|
+
...Object.keys(anchorData).length > 0 ? { anchorData } : {},
|
|
457754
|
+
...Object.keys(marginOffset).length > 0 ? { marginOffset } : {}
|
|
457755
|
+
};
|
|
457756
|
+
}
|
|
457757
|
+
function convertToPixels2(value) {
|
|
457758
|
+
const num = parseFloat(value);
|
|
457759
|
+
if (Number.isNaN(num))
|
|
457760
|
+
return 0;
|
|
457761
|
+
if (value.endsWith("pt"))
|
|
457762
|
+
return num * 96 / 72;
|
|
457763
|
+
if (value.endsWith("in"))
|
|
457764
|
+
return num * 96;
|
|
457765
|
+
if (value.endsWith("px"))
|
|
457766
|
+
return num;
|
|
457767
|
+
return num;
|
|
457768
|
+
}
|
|
456434
457769
|
var init_handle_shape_textbox_import = __esm(() => {
|
|
456435
457770
|
init_docxImporter();
|
|
456436
457771
|
init_paragraphNodeImporter();
|
|
@@ -456512,12 +457847,12 @@ function handleShapeImageWatermarkImport2({ params: params3, pict }) {
|
|
|
456512
457847
|
alignV: vPosition
|
|
456513
457848
|
},
|
|
456514
457849
|
size: {
|
|
456515
|
-
width:
|
|
456516
|
-
height:
|
|
457850
|
+
width: convertToPixels3(width),
|
|
457851
|
+
height: convertToPixels3(height)
|
|
456517
457852
|
},
|
|
456518
457853
|
marginOffset: {
|
|
456519
|
-
horizontal:
|
|
456520
|
-
top:
|
|
457854
|
+
horizontal: convertToPixels3(position5.marginLeft),
|
|
457855
|
+
top: convertToPixels3(position5.marginTop)
|
|
456521
457856
|
},
|
|
456522
457857
|
...gain && { gain },
|
|
456523
457858
|
...blacklevel && { blacklevel }
|
|
@@ -456551,7 +457886,7 @@ function parseVmlStyle2(style2) {
|
|
|
456551
457886
|
}
|
|
456552
457887
|
return result;
|
|
456553
457888
|
}
|
|
456554
|
-
function
|
|
457889
|
+
function convertToPixels3(value) {
|
|
456555
457890
|
if (typeof value === "number")
|
|
456556
457891
|
return value;
|
|
456557
457892
|
if (!value || typeof value !== "string")
|
|
@@ -456643,8 +457978,8 @@ function handleShapeTextWatermarkImport2({ pict }) {
|
|
|
456643
457978
|
const wrap6 = shape.elements?.find((el) => el.name === "w10:wrap");
|
|
456644
457979
|
const wrapAttrs = wrap6?.attributes || {};
|
|
456645
457980
|
const wrapType = wrapAttrs.type || "none";
|
|
456646
|
-
const widthPx =
|
|
456647
|
-
const heightPx =
|
|
457981
|
+
const widthPx = convertToPixels4(width);
|
|
457982
|
+
const heightPx = convertToPixels4(height);
|
|
456648
457983
|
const sanitizedOpacity = sanitizeNumeric2(parseVmlOpacity2(opacity), DEFAULT_VML_TEXT_WATERMARK_OPACITY2, 0, 1);
|
|
456649
457984
|
const sanitizedRotation = sanitizeNumeric2(rotation, 0, -360, 360);
|
|
456650
457985
|
const svgResult = generateTextWatermarkSVG2({
|
|
@@ -456676,8 +458011,8 @@ function handleShapeTextWatermarkImport2({ pict }) {
|
|
|
456676
458011
|
vPosition,
|
|
456677
458012
|
hRelativeTo,
|
|
456678
458013
|
vRelativeTo,
|
|
456679
|
-
marginLeft:
|
|
456680
|
-
marginTop:
|
|
458014
|
+
marginLeft: convertToPixels4(position5.marginLeft),
|
|
458015
|
+
marginTop: convertToPixels4(position5.marginTop),
|
|
456681
458016
|
width: widthPx,
|
|
456682
458017
|
height: heightPx,
|
|
456683
458018
|
svgWidth: svgResult.svgWidth,
|
|
@@ -456942,7 +458277,7 @@ function parseVmlStyle3(style2) {
|
|
|
456942
458277
|
}
|
|
456943
458278
|
return result;
|
|
456944
458279
|
}
|
|
456945
|
-
function
|
|
458280
|
+
function convertToPixels4(value) {
|
|
456946
458281
|
if (typeof value === "number")
|
|
456947
458282
|
return value;
|
|
456948
458283
|
if (!value || typeof value !== "string")
|
|
@@ -457009,16 +458344,83 @@ var init_pict_node_type_strategy = __esm(() => {
|
|
|
457009
458344
|
init_handle_shape_text_watermark_import();
|
|
457010
458345
|
});
|
|
457011
458346
|
|
|
458347
|
+
// ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/wp/helpers/translate-drawingml-textbox.js
|
|
458348
|
+
function translateDrawingMLTextbox2(params3) {
|
|
458349
|
+
const { node: node4 } = params3;
|
|
458350
|
+
const drawingContent = node4?.attrs?.drawingContent;
|
|
458351
|
+
const shapeTextbox = node4?.content?.find((child) => child?.type === "shapeTextbox");
|
|
458352
|
+
if (!drawingContent || !shapeTextbox) {
|
|
458353
|
+
return null;
|
|
458354
|
+
}
|
|
458355
|
+
const drawing = carbonCopy2(drawingContent);
|
|
458356
|
+
const liveParagraphs = translateChildNodes2({
|
|
458357
|
+
...params3,
|
|
458358
|
+
node: shapeTextbox
|
|
458359
|
+
});
|
|
458360
|
+
const txbxContent = findTextboxContentNode2(drawing);
|
|
458361
|
+
if (!txbxContent) {
|
|
458362
|
+
return null;
|
|
458363
|
+
}
|
|
458364
|
+
txbxContent.elements = liveParagraphs;
|
|
458365
|
+
const alternateContent = {
|
|
458366
|
+
name: "mc:AlternateContent",
|
|
458367
|
+
elements: [
|
|
458368
|
+
{
|
|
458369
|
+
name: "mc:Choice",
|
|
458370
|
+
attributes: { Requires: "wps" },
|
|
458371
|
+
elements: [drawing]
|
|
458372
|
+
}
|
|
458373
|
+
]
|
|
458374
|
+
};
|
|
458375
|
+
return wrapTextInRun2(alternateContent);
|
|
458376
|
+
}
|
|
458377
|
+
function findTextboxContentNode2(node4) {
|
|
458378
|
+
if (!node4 || typeof node4 !== "object")
|
|
458379
|
+
return null;
|
|
458380
|
+
if (node4.name === "w:txbxContent")
|
|
458381
|
+
return node4;
|
|
458382
|
+
if (!Array.isArray(node4.elements))
|
|
458383
|
+
return null;
|
|
458384
|
+
for (const child of node4.elements) {
|
|
458385
|
+
const found3 = findTextboxContentNode2(child);
|
|
458386
|
+
if (found3)
|
|
458387
|
+
return found3;
|
|
458388
|
+
}
|
|
458389
|
+
return null;
|
|
458390
|
+
}
|
|
458391
|
+
var init_translate_drawingml_textbox = __esm(() => {
|
|
458392
|
+
init_translateChildNodes();
|
|
458393
|
+
init_exporter();
|
|
458394
|
+
});
|
|
458395
|
+
|
|
457012
458396
|
// ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/pict/helpers/translate-shape-container.js
|
|
457013
458397
|
function translateShapeContainer2(params3) {
|
|
457014
458398
|
const { node: node4 } = params3;
|
|
458399
|
+
if (node4?.attrs?.drawingContent) {
|
|
458400
|
+
const run2 = translateDrawingMLTextbox2(params3);
|
|
458401
|
+
if (run2) {
|
|
458402
|
+
return {
|
|
458403
|
+
name: "w:p",
|
|
458404
|
+
elements: [run2]
|
|
458405
|
+
};
|
|
458406
|
+
}
|
|
458407
|
+
return {
|
|
458408
|
+
name: "w:p",
|
|
458409
|
+
elements: [wrapTextInRun2(node4.attrs.drawingContent)]
|
|
458410
|
+
};
|
|
458411
|
+
}
|
|
457015
458412
|
const elements = translateChildNodes2(params3);
|
|
458413
|
+
const shapeAttributes = {
|
|
458414
|
+
...node4.attrs.attributes,
|
|
458415
|
+
fillcolor: node4.attrs.fillcolor
|
|
458416
|
+
};
|
|
458417
|
+
const style2 = buildShapeStyle2(node4.attrs);
|
|
458418
|
+
if (style2) {
|
|
458419
|
+
shapeAttributes.style = style2;
|
|
458420
|
+
}
|
|
457016
458421
|
const shape = {
|
|
457017
458422
|
name: "v:shape",
|
|
457018
|
-
attributes:
|
|
457019
|
-
...node4.attrs.attributes,
|
|
457020
|
-
fillcolor: node4.attrs.fillcolor
|
|
457021
|
-
},
|
|
458423
|
+
attributes: shapeAttributes,
|
|
457022
458424
|
elements: [
|
|
457023
458425
|
...elements,
|
|
457024
458426
|
...node4.attrs.wrapAttributes ? [
|
|
@@ -457041,9 +458443,43 @@ function translateShapeContainer2(params3) {
|
|
|
457041
458443
|
elements: [wrapTextInRun2(pict)]
|
|
457042
458444
|
};
|
|
457043
458445
|
}
|
|
458446
|
+
function buildShapeStyle2(attrs) {
|
|
458447
|
+
const originalStyle = parseInlineStyles2(attrs.attributes?.style);
|
|
458448
|
+
const managedStyle = parseInlineStyles2(attrs.style);
|
|
458449
|
+
const style2 = {
|
|
458450
|
+
...originalStyle,
|
|
458451
|
+
...managedStyle
|
|
458452
|
+
};
|
|
458453
|
+
if (attrs.marginOffset?.horizontal !== undefined) {
|
|
458454
|
+
style2["margin-left"] = `${convertToPt2(attrs.marginOffset.horizontal)}pt`;
|
|
458455
|
+
}
|
|
458456
|
+
if (attrs.marginOffset?.top !== undefined) {
|
|
458457
|
+
style2["margin-top"] = `${convertToPt2(attrs.marginOffset.top)}pt`;
|
|
458458
|
+
}
|
|
458459
|
+
if (attrs.anchorData?.alignH) {
|
|
458460
|
+
style2["mso-position-horizontal"] = attrs.anchorData.alignH;
|
|
458461
|
+
}
|
|
458462
|
+
if (attrs.anchorData?.hRelativeFrom) {
|
|
458463
|
+
style2["mso-position-horizontal-relative"] = attrs.anchorData.hRelativeFrom;
|
|
458464
|
+
}
|
|
458465
|
+
if (attrs.anchorData?.alignV) {
|
|
458466
|
+
style2["mso-position-vertical"] = attrs.anchorData.alignV;
|
|
458467
|
+
}
|
|
458468
|
+
if (attrs.anchorData?.vRelativeFrom) {
|
|
458469
|
+
style2["mso-position-vertical-relative"] = attrs.anchorData.vRelativeFrom;
|
|
458470
|
+
}
|
|
458471
|
+
const entries = Object.entries(style2);
|
|
458472
|
+
if (entries.length === 0)
|
|
458473
|
+
return;
|
|
458474
|
+
return entries.map(([prop, value]) => `${prop}:${value}`).join(";");
|
|
458475
|
+
}
|
|
458476
|
+
function convertToPt2(pixels) {
|
|
458477
|
+
return pixels * 72 / 96;
|
|
458478
|
+
}
|
|
457044
458479
|
var init_translate_shape_container = __esm(() => {
|
|
457045
458480
|
init_translateChildNodes();
|
|
457046
458481
|
init_exporter();
|
|
458482
|
+
init_translate_drawingml_textbox();
|
|
457047
458483
|
});
|
|
457048
458484
|
|
|
457049
458485
|
// ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/pict/helpers/translate-shape-textbox.js
|
|
@@ -457268,18 +458704,18 @@ function buildVmlStyle2(attrs) {
|
|
|
457268
458704
|
styles.push("position:absolute");
|
|
457269
458705
|
if (attrs.size) {
|
|
457270
458706
|
if (attrs.size.width) {
|
|
457271
|
-
styles.push(`width:${
|
|
458707
|
+
styles.push(`width:${convertToPt3(attrs.size.width)}pt`);
|
|
457272
458708
|
}
|
|
457273
458709
|
if (attrs.size.height) {
|
|
457274
|
-
styles.push(`height:${
|
|
458710
|
+
styles.push(`height:${convertToPt3(attrs.size.height)}pt`);
|
|
457275
458711
|
}
|
|
457276
458712
|
}
|
|
457277
458713
|
if (attrs.marginOffset) {
|
|
457278
458714
|
if (attrs.marginOffset.horizontal !== undefined) {
|
|
457279
|
-
styles.push(`margin-left:${
|
|
458715
|
+
styles.push(`margin-left:${convertToPt3(attrs.marginOffset.horizontal)}pt`);
|
|
457280
458716
|
}
|
|
457281
458717
|
if (attrs.marginOffset.top !== undefined) {
|
|
457282
|
-
styles.push(`margin-top:${
|
|
458718
|
+
styles.push(`margin-top:${convertToPt3(attrs.marginOffset.top)}pt`);
|
|
457283
458719
|
}
|
|
457284
458720
|
}
|
|
457285
458721
|
if (attrs.wrap?.attrs?.behindDoc) {
|
|
@@ -457303,7 +458739,7 @@ function buildVmlStyle2(attrs) {
|
|
|
457303
458739
|
styles.push("mso-height-percent:0");
|
|
457304
458740
|
return styles.join(";");
|
|
457305
458741
|
}
|
|
457306
|
-
function
|
|
458742
|
+
function convertToPt3(pixels) {
|
|
457307
458743
|
return pixels * 72 / 96;
|
|
457308
458744
|
}
|
|
457309
458745
|
var init_translate_image_watermark = () => {};
|
|
@@ -457443,10 +458879,10 @@ function buildVmlStyle3(attrs, wmData) {
|
|
|
457443
458879
|
styles.push("position:absolute");
|
|
457444
458880
|
if (attrs.marginOffset) {
|
|
457445
458881
|
if (attrs.marginOffset.horizontal !== undefined) {
|
|
457446
|
-
styles.push(`margin-left:${
|
|
458882
|
+
styles.push(`margin-left:${convertToPt4(attrs.marginOffset.horizontal)}pt`);
|
|
457447
458883
|
}
|
|
457448
458884
|
if (attrs.marginOffset.top !== undefined) {
|
|
457449
|
-
styles.push(`margin-top:${
|
|
458885
|
+
styles.push(`margin-top:${convertToPt4(attrs.marginOffset.top)}pt`);
|
|
457450
458886
|
}
|
|
457451
458887
|
} else {
|
|
457452
458888
|
styles.push("margin-left:0.05pt");
|
|
@@ -457454,10 +458890,10 @@ function buildVmlStyle3(attrs, wmData) {
|
|
|
457454
458890
|
}
|
|
457455
458891
|
if (attrs.size) {
|
|
457456
458892
|
if (attrs.size.width) {
|
|
457457
|
-
styles.push(`width:${
|
|
458893
|
+
styles.push(`width:${convertToPt4(attrs.size.width)}pt`);
|
|
457458
458894
|
}
|
|
457459
458895
|
if (attrs.size.height) {
|
|
457460
|
-
styles.push(`height:${
|
|
458896
|
+
styles.push(`height:${convertToPt4(attrs.size.height)}pt`);
|
|
457461
458897
|
}
|
|
457462
458898
|
}
|
|
457463
458899
|
const wrapType = attrs.wrap?.type;
|
|
@@ -457507,7 +458943,7 @@ function buildTextpathStyle2(wmData) {
|
|
|
457507
458943
|
}
|
|
457508
458944
|
return styles.join(";");
|
|
457509
458945
|
}
|
|
457510
|
-
function
|
|
458946
|
+
function convertToPt4(pixels) {
|
|
457511
458947
|
if (typeof pixels === "number") {
|
|
457512
458948
|
return pixels * 72 / 96;
|
|
457513
458949
|
}
|