@harbour-enterprises/superdoc 0.20.0-next.6 → 0.20.0-next.8
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/chunks/{PdfViewer-CuiUv0d5.es.js → PdfViewer-BoDHZ2nW.es.js} +1 -1
- package/dist/chunks/{PdfViewer--YKlzafo.cjs → PdfViewer-Ch0v9vA6.cjs} +1 -1
- package/dist/chunks/{index-Cl1u_lKk.es.js → index-BWPWqVxp.es.js} +2 -2
- package/dist/chunks/{index-CuHtS7O9.cjs → index-DFOT300M.cjs} +2 -2
- package/dist/chunks/{super-editor.es-BIW7iKAk.cjs → super-editor.es-BQ6kZTNg.cjs} +263 -72
- package/dist/chunks/{super-editor.es-DN4v75aq.es.js → super-editor.es-sBfWb5tn.es.js} +263 -72
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-kutpjDQU.js → converter-C91Sr_5w.js} +182 -63
- package/dist/super-editor/chunks/{docx-zipper-BjcI24VU.js → docx-zipper-Cl7LYpt6.js} +1 -1
- package/dist/super-editor/chunks/{editor-ps-v4FlA.js → editor-a7cQT9Dw.js} +83 -11
- package/dist/super-editor/chunks/{toolbar-Ch271j8X.js → toolbar-DiNFtCKr.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +1 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/tblGrid/tblGrid-helpers.d.ts +5 -0
- package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +9 -1
- package/dist/super-editor/src/extensions/image/imageHelpers/fileNameUtils.d.ts +3 -0
- package/dist/super-editor/src/extensions/image/imageHelpers/index.d.ts +1 -0
- package/dist/super-editor/src/extensions/structured-content/StructuredContentBlockView.d.ts +0 -1
- package/dist/super-editor/src/extensions/structured-content/StructuredContentInlineView.d.ts +0 -1
- package/dist/super-editor/src/extensions/structured-content/StructuredContentViewBase.d.ts +1 -1
- package/dist/super-editor/super-editor.es.js +6 -6
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +263 -72
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -14779,22 +14779,25 @@ async function readFromClipboard(state2) {
|
|
|
14779
14779
|
function inchesToTwips(inches) {
|
|
14780
14780
|
if (inches == null) return;
|
|
14781
14781
|
if (typeof inches === "string") inches = parseFloat(inches);
|
|
14782
|
-
return Math.round(inches * 1440);
|
|
14782
|
+
return Math.round(Number(inches) * 1440);
|
|
14783
14783
|
}
|
|
14784
14784
|
function twipsToInches(twips) {
|
|
14785
14785
|
if (twips == null) return;
|
|
14786
|
-
|
|
14787
|
-
|
|
14786
|
+
const value = Number(twips);
|
|
14787
|
+
if (Number.isNaN(value)) return;
|
|
14788
|
+
return value / 1440;
|
|
14788
14789
|
}
|
|
14789
14790
|
function twipsToPixels(twips) {
|
|
14790
14791
|
if (twips == null) return;
|
|
14791
|
-
|
|
14792
|
-
|
|
14792
|
+
const inches = twipsToInches(twips);
|
|
14793
|
+
if (inches == null) return;
|
|
14794
|
+
const pixels = inches * 96;
|
|
14795
|
+
return Math.round(pixels * 1e3) / 1e3;
|
|
14793
14796
|
}
|
|
14794
14797
|
function pixelsToTwips(pixels) {
|
|
14795
14798
|
if (pixels == null) return;
|
|
14796
|
-
|
|
14797
|
-
return inchesToTwips(
|
|
14799
|
+
const inches = Number(pixels) / 96;
|
|
14800
|
+
return inchesToTwips(inches);
|
|
14798
14801
|
}
|
|
14799
14802
|
function twipsToLines(twips) {
|
|
14800
14803
|
if (twips == null) return;
|
|
@@ -24691,13 +24694,15 @@ const getParagraphIndent = (node, docx, styleId = "") => {
|
|
|
24691
24694
|
}
|
|
24692
24695
|
return indent;
|
|
24693
24696
|
};
|
|
24694
|
-
const getParagraphSpacing = (node, docx, styleId = "", marks = []) => {
|
|
24697
|
+
const getParagraphSpacing = (node, docx, styleId = "", marks = [], options = {}) => {
|
|
24698
|
+
const { insideTable = false } = options;
|
|
24695
24699
|
const spacing = {};
|
|
24696
|
-
const { spacing: pDefaultSpacing = {} } = getDefaultParagraphStyle(docx, styleId);
|
|
24700
|
+
const { spacing: pDefaultSpacing = {}, spacingSource } = getDefaultParagraphStyle(docx, styleId);
|
|
24697
24701
|
let lineSpaceAfter, lineSpaceBefore, line, lineRuleStyle;
|
|
24698
24702
|
const pPr = node.elements?.find((el) => el.name === "w:pPr");
|
|
24699
24703
|
const inLineSpacingTag = pPr?.elements?.find((el) => el.name === "w:spacing");
|
|
24700
24704
|
const inLineSpacing = inLineSpacingTag?.attributes || {};
|
|
24705
|
+
const hasInlineSpacing = !!Object.keys(inLineSpacing).length;
|
|
24701
24706
|
const textStyleMark = marks.find((el) => el.type === "textStyle");
|
|
24702
24707
|
const fontSize = textStyleMark?.attrs?.fontSize;
|
|
24703
24708
|
const lineSpacing = inLineSpacing?.["w:line"] || line || pDefaultSpacing?.["w:line"];
|
|
@@ -24719,6 +24724,12 @@ const getParagraphSpacing = (node, docx, styleId = "", marks = []) => {
|
|
|
24719
24724
|
if (afterAutospacing === "1" && fontSize) {
|
|
24720
24725
|
spacing.lineSpaceAfter += Math.round(parseInt(fontSize) * 0.5 * 96 / 72);
|
|
24721
24726
|
}
|
|
24727
|
+
if (insideTable && !hasInlineSpacing && spacingSource === "docDefault") {
|
|
24728
|
+
const hasExplicitSpacing = Object.keys(inLineSpacing).length > 0;
|
|
24729
|
+
if (!hasExplicitSpacing) {
|
|
24730
|
+
return void 0;
|
|
24731
|
+
}
|
|
24732
|
+
}
|
|
24722
24733
|
return spacing;
|
|
24723
24734
|
};
|
|
24724
24735
|
const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
@@ -24759,9 +24770,20 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
|
24759
24770
|
const { attributes: pPrByIdIndentAttr } = pPrStyleIdIndentTag;
|
|
24760
24771
|
const spacingRest = isNormalAsDefault ? pPrNormalSpacingAttr || pPrDefaultSpacingAttr : pPrDefaultSpacingAttr || pPrNormalSpacingAttr;
|
|
24761
24772
|
const indentRest = isNormalAsDefault ? pPrNormalIndentAttr || pPrDefaultIndentAttr : pPrDefaultIndentAttr || pPrNormalIndentAttr;
|
|
24773
|
+
let spacingToUse = pPrByIdSpacingAttr || spacingRest;
|
|
24774
|
+
let spacingSource = "docDefault";
|
|
24775
|
+
if (pPrByIdSpacingAttr) {
|
|
24776
|
+
spacingSource = "style";
|
|
24777
|
+
} else if (spacingRest === pPrNormalSpacingAttr && pPrNormalSpacingAttr) {
|
|
24778
|
+
spacingSource = isNormalAsDefault ? "docDefault" : "normal";
|
|
24779
|
+
} else if (spacingRest === pPrDefaultSpacingAttr && pPrDefaultSpacingAttr) {
|
|
24780
|
+
spacingSource = "docDefault";
|
|
24781
|
+
}
|
|
24782
|
+
let indentToUse = pPrByIdIndentAttr || indentRest;
|
|
24762
24783
|
return {
|
|
24763
|
-
spacing:
|
|
24764
|
-
|
|
24784
|
+
spacing: spacingToUse,
|
|
24785
|
+
spacingSource,
|
|
24786
|
+
indent: indentToUse,
|
|
24765
24787
|
justify: pPrByIdJcAttr
|
|
24766
24788
|
};
|
|
24767
24789
|
};
|
|
@@ -24936,7 +24958,13 @@ const handleParagraphNode$1 = (params) => {
|
|
|
24936
24958
|
}
|
|
24937
24959
|
if (docx) {
|
|
24938
24960
|
const defaultStyleId = node.attributes?.["w:rsidRDefault"];
|
|
24939
|
-
|
|
24961
|
+
const insideTable = (params.path || []).some((ancestor) => ancestor.name === "w:tc");
|
|
24962
|
+
const spacing = getParagraphSpacing(node, docx, styleId, schemaNode.attrs.marksAttrs, {
|
|
24963
|
+
insideTable
|
|
24964
|
+
});
|
|
24965
|
+
if (spacing) {
|
|
24966
|
+
schemaNode.attrs["spacing"] = spacing;
|
|
24967
|
+
}
|
|
24940
24968
|
schemaNode.attrs["rsidRDefault"] = defaultStyleId;
|
|
24941
24969
|
}
|
|
24942
24970
|
if (docx) {
|
|
@@ -25182,10 +25210,10 @@ function createBorderPropertyHandler(xmlName, sdName = null) {
|
|
|
25182
25210
|
createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
|
|
25183
25211
|
createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
|
|
25184
25212
|
],
|
|
25185
|
-
encode: (
|
|
25213
|
+
encode: (params, encodedAttrs) => {
|
|
25186
25214
|
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25187
25215
|
},
|
|
25188
|
-
decode: function({ node },
|
|
25216
|
+
decode: function({ node }, context) {
|
|
25189
25217
|
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
|
|
25190
25218
|
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25191
25219
|
}
|
|
@@ -25544,10 +25572,10 @@ const translator$B = NodeTranslator.from({
|
|
|
25544
25572
|
"w:themeTint",
|
|
25545
25573
|
"w:val"
|
|
25546
25574
|
].map((attr) => createAttributeHandler(attr)),
|
|
25547
|
-
encode: (
|
|
25575
|
+
encode: (params, encodedAttrs) => {
|
|
25548
25576
|
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25549
25577
|
},
|
|
25550
|
-
decode: function({ node },
|
|
25578
|
+
decode: function({ node }, context) {
|
|
25551
25579
|
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.shading || {} } });
|
|
25552
25580
|
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25553
25581
|
}
|
|
@@ -25560,10 +25588,10 @@ const translator$w = NodeTranslator.from({
|
|
|
25560
25588
|
xmlName: "w:tblLook",
|
|
25561
25589
|
sdNodeOrKeyName: "tblLook",
|
|
25562
25590
|
attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
|
|
25563
|
-
encode: (
|
|
25591
|
+
encode: (params, encodedAttrs) => {
|
|
25564
25592
|
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25565
25593
|
},
|
|
25566
|
-
decode: function({ node },
|
|
25594
|
+
decode: function({ node }, context) {
|
|
25567
25595
|
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.tblLook || {} } });
|
|
25568
25596
|
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25569
25597
|
}
|
|
@@ -25581,10 +25609,10 @@ const translator$q = NodeTranslator.from({
|
|
|
25581
25609
|
xmlName: "w:tblpPr",
|
|
25582
25610
|
sdNodeOrKeyName: "floatingTableProperties",
|
|
25583
25611
|
attributes: ["w:leftFromText", "w:rightFromText", "w:topFromText", "w:bottomFromText", "w:tblpX", "w:tblpY"].map((attr) => createAttributeHandler(attr, null, parseInteger, integerToString)).concat(["w:horzAnchor", "w:vertAnchor", "w:tblpXSpec", "w:tblpYSpec"].map((attr) => createAttributeHandler(attr))),
|
|
25584
|
-
encode: (
|
|
25612
|
+
encode: (params, encodedAttrs) => {
|
|
25585
25613
|
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25586
25614
|
},
|
|
25587
|
-
decode: function({ node },
|
|
25615
|
+
decode: function({ node }, context) {
|
|
25588
25616
|
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.floatingTableProperties || {} } });
|
|
25589
25617
|
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25590
25618
|
}
|
|
@@ -25605,13 +25633,13 @@ const translator$d = NodeTranslator.from(createBorderPropertyHandler("w:top"));
|
|
|
25605
25633
|
const translator$c = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
|
|
25606
25634
|
const XML_NODE_NAME$a = "w:tblBorders";
|
|
25607
25635
|
const SD_ATTR_KEY$3 = "borders";
|
|
25608
|
-
const encode$a = (params
|
|
25636
|
+
const encode$a = (params) => {
|
|
25609
25637
|
const { nodes } = params;
|
|
25610
25638
|
const node = nodes[0];
|
|
25611
25639
|
const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
|
|
25612
25640
|
return Object.keys(attributes).length > 0 ? attributes : void 0;
|
|
25613
25641
|
};
|
|
25614
|
-
const decode$a = (params
|
|
25642
|
+
const decode$a = (params) => {
|
|
25615
25643
|
const { borders = {} } = params.node.attrs || {};
|
|
25616
25644
|
const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
|
|
25617
25645
|
const newNode = {
|
|
@@ -25648,13 +25676,13 @@ const translator$b = NodeTranslator.from({
|
|
|
25648
25676
|
});
|
|
25649
25677
|
const XML_NODE_NAME$9 = "w:tblCellMar";
|
|
25650
25678
|
const SD_ATTR_KEY$2 = "cellMargins";
|
|
25651
|
-
const encode$9 = (params
|
|
25679
|
+
const encode$9 = (params) => {
|
|
25652
25680
|
const { nodes } = params;
|
|
25653
25681
|
const node = nodes[0];
|
|
25654
25682
|
const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
|
|
25655
25683
|
return Object.keys(attributes).length > 0 ? attributes : void 0;
|
|
25656
25684
|
};
|
|
25657
|
-
const decode$9 = (params
|
|
25685
|
+
const decode$9 = (params) => {
|
|
25658
25686
|
const { cellMargins = {} } = params.node.attrs || {};
|
|
25659
25687
|
const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
|
|
25660
25688
|
const newNode = {
|
|
@@ -25745,6 +25773,53 @@ const translator$9 = NodeTranslator.from(config$8);
|
|
|
25745
25773
|
const translator$8 = NodeTranslator.from(
|
|
25746
25774
|
createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
|
|
25747
25775
|
);
|
|
25776
|
+
const DEFAULT_COLUMN_WIDTH_PX = 100;
|
|
25777
|
+
const normalizeTwipWidth = (value) => {
|
|
25778
|
+
if (value == null) return null;
|
|
25779
|
+
const numericValue = typeof value === "string" ? parseInt(value, 10) : value;
|
|
25780
|
+
if (!Number.isFinite(numericValue) || Number.isNaN(numericValue) || numericValue <= 0) {
|
|
25781
|
+
return null;
|
|
25782
|
+
}
|
|
25783
|
+
return numericValue;
|
|
25784
|
+
};
|
|
25785
|
+
const getSchemaDefaultColumnWidthPx = (params) => {
|
|
25786
|
+
const defaultValue = params?.editor?.schema?.nodes?.tableCell?.spec?.attrs?.colwidth?.default;
|
|
25787
|
+
if (Array.isArray(defaultValue)) {
|
|
25788
|
+
const numericWidth = defaultValue.find((width) => typeof width === "number" && Number.isFinite(width) && width > 0);
|
|
25789
|
+
if (numericWidth != null) return numericWidth;
|
|
25790
|
+
} else if (typeof defaultValue === "number" && Number.isFinite(defaultValue) && defaultValue > 0) {
|
|
25791
|
+
return defaultValue;
|
|
25792
|
+
}
|
|
25793
|
+
return DEFAULT_COLUMN_WIDTH_PX;
|
|
25794
|
+
};
|
|
25795
|
+
const getTableWidthPx = (params) => {
|
|
25796
|
+
const explicitWidth = params?.node?.attrs?.tableWidth?.width;
|
|
25797
|
+
if (typeof explicitWidth === "number" && explicitWidth > 0) return explicitWidth;
|
|
25798
|
+
const tableWidth = params?.node?.attrs?.tableProperties?.tableWidth;
|
|
25799
|
+
if (tableWidth?.value != null && typeof tableWidth.value === "number" && tableWidth.value > 0) {
|
|
25800
|
+
const { value, type: type2 } = tableWidth;
|
|
25801
|
+
if (!type2 || type2 === "auto" || type2 === "dxa") {
|
|
25802
|
+
return twipsToPixels(value);
|
|
25803
|
+
}
|
|
25804
|
+
}
|
|
25805
|
+
return null;
|
|
25806
|
+
};
|
|
25807
|
+
const resolveFallbackColumnWidthTwips = (params, totalColumns, cellMinWidthTwips) => {
|
|
25808
|
+
const columnCount = Math.max(totalColumns, 1);
|
|
25809
|
+
const defaultColumnWidthPx = getSchemaDefaultColumnWidthPx(params);
|
|
25810
|
+
const tableWidthPx = getTableWidthPx(params);
|
|
25811
|
+
const safeDefaultPx = Number.isFinite(defaultColumnWidthPx) && defaultColumnWidthPx > 0 ? defaultColumnWidthPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
25812
|
+
let fallbackWidthPx = safeDefaultPx;
|
|
25813
|
+
if (typeof tableWidthPx === "number" && tableWidthPx > 0) {
|
|
25814
|
+
fallbackWidthPx = tableWidthPx / columnCount;
|
|
25815
|
+
}
|
|
25816
|
+
const fallbackWidthTwips = pixelsToTwips(fallbackWidthPx);
|
|
25817
|
+
if (!Number.isFinite(fallbackWidthTwips) || Number.isNaN(fallbackWidthTwips) || fallbackWidthTwips <= 0) {
|
|
25818
|
+
const safeDefault = Math.max(pixelsToTwips(safeDefaultPx), cellMinWidthTwips);
|
|
25819
|
+
return safeDefault;
|
|
25820
|
+
}
|
|
25821
|
+
return Math.max(fallbackWidthTwips, cellMinWidthTwips);
|
|
25822
|
+
};
|
|
25748
25823
|
const XML_NODE_NAME$7 = "w:tblGrid";
|
|
25749
25824
|
const SD_ATTR_KEY = "grid";
|
|
25750
25825
|
const cellMinWidth = pixelsToTwips(10);
|
|
@@ -25759,35 +25834,60 @@ const encode$7 = (params) => {
|
|
|
25759
25834
|
};
|
|
25760
25835
|
};
|
|
25761
25836
|
const decode$7 = (params) => {
|
|
25762
|
-
const { grid
|
|
25837
|
+
const { grid: rawGrid } = params.node.attrs || {};
|
|
25838
|
+
const grid = Array.isArray(rawGrid) ? rawGrid : [];
|
|
25763
25839
|
const { firstRow = {} } = params.extraParams || {};
|
|
25764
25840
|
const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
|
|
25765
|
-
const
|
|
25841
|
+
const columnCountFromCells = cellNodes.reduce((count, cell) => {
|
|
25842
|
+
const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
|
|
25843
|
+
return count + spanCount;
|
|
25844
|
+
}, 0);
|
|
25845
|
+
const totalColumns = Math.max(columnCountFromCells, grid.length);
|
|
25846
|
+
const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params, totalColumns, cellMinWidth);
|
|
25766
25847
|
const elements = [];
|
|
25767
|
-
|
|
25768
|
-
|
|
25848
|
+
let columnIndex = 0;
|
|
25849
|
+
const pushColumn = (widthTwips) => {
|
|
25850
|
+
let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
|
|
25851
|
+
if (numericWidth == null || Number.isNaN(numericWidth) || numericWidth <= 0) {
|
|
25852
|
+
numericWidth = fallbackColumnWidthTwips;
|
|
25853
|
+
}
|
|
25854
|
+
numericWidth = Math.max(numericWidth, cellMinWidth);
|
|
25855
|
+
const decoded = translator$8.decode({
|
|
25856
|
+
node: { type: (
|
|
25857
|
+
/** @type {string} */
|
|
25858
|
+
translator$8.sdNodeOrKeyName
|
|
25859
|
+
), attrs: { col: numericWidth } }
|
|
25860
|
+
});
|
|
25861
|
+
if (decoded) elements.push(decoded);
|
|
25862
|
+
};
|
|
25863
|
+
cellNodes.forEach((cell) => {
|
|
25769
25864
|
const { colspan = 1, colwidth } = cell?.attrs || {};
|
|
25770
|
-
|
|
25771
|
-
|
|
25772
|
-
const
|
|
25773
|
-
const
|
|
25774
|
-
const
|
|
25865
|
+
const spanCount = Math.max(1, colspan);
|
|
25866
|
+
for (let span = 0; span < spanCount; span++) {
|
|
25867
|
+
const cellWidthPixels = Array.isArray(colwidth) ? colwidth[span] : void 0;
|
|
25868
|
+
const colGridAttrs = grid?.[columnIndex] || {};
|
|
25869
|
+
const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
|
|
25870
|
+
const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
|
|
25775
25871
|
let cellWidthTwips;
|
|
25776
|
-
if (
|
|
25872
|
+
if (cellWidthPixels != null) {
|
|
25873
|
+
if (gridWidthTwips != null && gridWidthPixels === cellWidthPixels) {
|
|
25874
|
+
cellWidthTwips = gridWidthTwips;
|
|
25875
|
+
} else {
|
|
25876
|
+
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
25877
|
+
}
|
|
25878
|
+
} else if (gridWidthTwips != null) {
|
|
25777
25879
|
cellWidthTwips = gridWidthTwips;
|
|
25778
|
-
} else
|
|
25779
|
-
cellWidthTwips =
|
|
25780
|
-
}
|
|
25781
|
-
|
|
25782
|
-
|
|
25783
|
-
translator$8.decode({
|
|
25784
|
-
node: { type: (
|
|
25785
|
-
/** @type {string} */
|
|
25786
|
-
translator$8.sdNodeOrKeyName
|
|
25787
|
-
), attrs: { col: widthTwips } }
|
|
25788
|
-
})
|
|
25789
|
-
);
|
|
25880
|
+
} else {
|
|
25881
|
+
cellWidthTwips = fallbackColumnWidthTwips;
|
|
25882
|
+
}
|
|
25883
|
+
pushColumn(cellWidthTwips);
|
|
25884
|
+
columnIndex++;
|
|
25790
25885
|
}
|
|
25886
|
+
});
|
|
25887
|
+
while (columnIndex < grid.length) {
|
|
25888
|
+
const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
|
|
25889
|
+
pushColumn(gridWidthTwips);
|
|
25890
|
+
columnIndex++;
|
|
25791
25891
|
}
|
|
25792
25892
|
const newNode = {
|
|
25793
25893
|
name: XML_NODE_NAME$7,
|
|
@@ -25810,7 +25910,8 @@ const encode$6 = (params, encodedAttrs) => {
|
|
|
25810
25910
|
const node = nodes[0];
|
|
25811
25911
|
const tblPr = node.elements.find((el) => el.name === "w:tblPr");
|
|
25812
25912
|
if (tblPr) {
|
|
25813
|
-
|
|
25913
|
+
const encodedProperties = translator$9.encode({ ...params, nodes: [tblPr] });
|
|
25914
|
+
encodedAttrs["tableProperties"] = encodedProperties?.attributes || {};
|
|
25814
25915
|
}
|
|
25815
25916
|
const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
|
|
25816
25917
|
if (tblGrid) {
|
|
@@ -25832,7 +25933,7 @@ const encode$6 = (params, encodedAttrs) => {
|
|
|
25832
25933
|
key = prop;
|
|
25833
25934
|
transform = (v2) => v2;
|
|
25834
25935
|
}
|
|
25835
|
-
if (encodedAttrs.tableProperties
|
|
25936
|
+
if (encodedAttrs.tableProperties && encodedAttrs.tableProperties[key]) {
|
|
25836
25937
|
encodedAttrs[key] = transform(encodedAttrs.tableProperties[key]);
|
|
25837
25938
|
}
|
|
25838
25939
|
});
|
|
@@ -25841,11 +25942,17 @@ const encode$6 = (params, encodedAttrs) => {
|
|
|
25841
25942
|
}
|
|
25842
25943
|
const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
|
|
25843
25944
|
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params);
|
|
25945
|
+
if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
|
|
25946
|
+
encodedAttrs.tableProperties = {
|
|
25947
|
+
...encodedAttrs.tableProperties || {},
|
|
25948
|
+
cellMargins: referencedStyles.cellMargins
|
|
25949
|
+
};
|
|
25950
|
+
}
|
|
25844
25951
|
const rows = node.elements.filter((el) => el.name === "w:tr");
|
|
25845
25952
|
const borderData = Object.assign({}, referencedStyles?.borders || {}, borders || {});
|
|
25846
25953
|
const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
|
|
25847
25954
|
encodedAttrs["borders"] = borderData;
|
|
25848
|
-
const tblStyleTag = tblPr
|
|
25955
|
+
const tblStyleTag = tblPr?.elements?.find((el) => el.name === "w:tblStyle");
|
|
25849
25956
|
const columnWidths = (encodedAttrs["grid"] ?? []).map((item) => twipsToPixels(item.col));
|
|
25850
25957
|
const content = [];
|
|
25851
25958
|
rows.forEach((row) => {
|
|
@@ -25854,6 +25961,7 @@ const encode$6 = (params, encodedAttrs) => {
|
|
|
25854
25961
|
nodes: [row],
|
|
25855
25962
|
extraParams: {
|
|
25856
25963
|
row,
|
|
25964
|
+
table: node,
|
|
25857
25965
|
rowBorders: borderRowData,
|
|
25858
25966
|
styleTag: tblStyleTag,
|
|
25859
25967
|
columnWidths
|
|
@@ -25955,7 +26063,12 @@ function _getReferencedTableStyles(tableStyleReference, params) {
|
|
|
25955
26063
|
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
25956
26064
|
const cellMargins = {};
|
|
25957
26065
|
Object.entries(tableProperties.cellMargins || {}).forEach(([key, attrs]) => {
|
|
25958
|
-
if (attrs?.value
|
|
26066
|
+
if (attrs?.value != null) {
|
|
26067
|
+
cellMargins[key] = {
|
|
26068
|
+
value: attrs.value,
|
|
26069
|
+
type: attrs.type || "dxa"
|
|
26070
|
+
};
|
|
26071
|
+
}
|
|
25959
26072
|
});
|
|
25960
26073
|
if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
|
|
25961
26074
|
}
|
|
@@ -26208,11 +26321,17 @@ const getTableCellMargins = (marginTag, referencedStyles) => {
|
|
|
26208
26321
|
marginTop: marginTopStyle,
|
|
26209
26322
|
marginBottom: marginBottomStyle
|
|
26210
26323
|
} = cellMargins;
|
|
26324
|
+
const resolveMargin = (inlineValue, styleValue) => {
|
|
26325
|
+
if (inlineValue != null) return inlineValue;
|
|
26326
|
+
if (styleValue == null) return void 0;
|
|
26327
|
+
if (typeof styleValue === "object") return styleValue.value;
|
|
26328
|
+
return styleValue;
|
|
26329
|
+
};
|
|
26211
26330
|
const margins = {
|
|
26212
|
-
left: twipsToPixels(inlineMarginLeftValue
|
|
26213
|
-
right: twipsToPixels(inlineMarginRightValue
|
|
26214
|
-
top: twipsToPixels(inlineMarginTopValue
|
|
26215
|
-
bottom: twipsToPixels(inlineMarginBottomValue
|
|
26331
|
+
left: twipsToPixels(resolveMargin(inlineMarginLeftValue, marginLeftStyle)),
|
|
26332
|
+
right: twipsToPixels(resolveMargin(inlineMarginRightValue, marginRightStyle)),
|
|
26333
|
+
top: twipsToPixels(resolveMargin(inlineMarginTopValue, marginTopStyle)),
|
|
26334
|
+
bottom: twipsToPixels(resolveMargin(inlineMarginBottomValue, marginBottomStyle))
|
|
26216
26335
|
};
|
|
26217
26336
|
return margins;
|
|
26218
26337
|
};
|
|
@@ -26487,7 +26606,7 @@ function parseTagValueJSON(json) {
|
|
|
26487
26606
|
}
|
|
26488
26607
|
try {
|
|
26489
26608
|
return JSON.parse(trimmed);
|
|
26490
|
-
} catch
|
|
26609
|
+
} catch {
|
|
26491
26610
|
return {};
|
|
26492
26611
|
}
|
|
26493
26612
|
}
|
|
@@ -27226,14 +27345,14 @@ function translateAnchorNode(params) {
|
|
|
27226
27345
|
const XML_NODE_NAME$3 = "wp:anchor";
|
|
27227
27346
|
const SD_NODE_NAME$3 = ["image"];
|
|
27228
27347
|
const validXmlAttributes$3 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
27229
|
-
function encode$3(params
|
|
27348
|
+
function encode$3(params) {
|
|
27230
27349
|
const { node } = params.extraParams;
|
|
27231
27350
|
if (!node || !node.type) {
|
|
27232
27351
|
return null;
|
|
27233
27352
|
}
|
|
27234
27353
|
return handleAnchorNode(params);
|
|
27235
27354
|
}
|
|
27236
|
-
function decode$3(params
|
|
27355
|
+
function decode$3(params) {
|
|
27237
27356
|
const { node } = params;
|
|
27238
27357
|
if (!node || !node.type) {
|
|
27239
27358
|
return null;
|
|
@@ -27267,14 +27386,14 @@ function translateInlineNode(params) {
|
|
|
27267
27386
|
const XML_NODE_NAME$2 = "wp:inline";
|
|
27268
27387
|
const SD_NODE_NAME$2 = ["image"];
|
|
27269
27388
|
const validXmlAttributes$2 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
27270
|
-
function encode$2(params
|
|
27389
|
+
function encode$2(params) {
|
|
27271
27390
|
const { node } = params.extraParams;
|
|
27272
27391
|
if (!node || !node.type) {
|
|
27273
27392
|
return null;
|
|
27274
27393
|
}
|
|
27275
27394
|
return handleInlineNode(params);
|
|
27276
27395
|
}
|
|
27277
|
-
function decode$2(params
|
|
27396
|
+
function decode$2(params) {
|
|
27278
27397
|
const { node } = params;
|
|
27279
27398
|
if (!node || !node.type) {
|
|
27280
27399
|
return null;
|
|
@@ -27300,7 +27419,7 @@ const registeredHandlers = Object.freeze({
|
|
|
27300
27419
|
const XML_NODE_NAME$1 = "w:drawing";
|
|
27301
27420
|
const SD_NODE_NAME$1 = [];
|
|
27302
27421
|
const validXmlAttributes$1 = [];
|
|
27303
|
-
function encode$1(params
|
|
27422
|
+
function encode$1(params) {
|
|
27304
27423
|
const nodes = params.nodes;
|
|
27305
27424
|
const node = nodes[0];
|
|
27306
27425
|
const validChildTranslators = ["wp:anchor", "wp:inline"];
|
|
@@ -27311,7 +27430,7 @@ function encode$1(params, encodedAttrs) {
|
|
|
27311
27430
|
return translator2.encode({ ...params, extraParams: { node: child } }) || acc;
|
|
27312
27431
|
}, null);
|
|
27313
27432
|
}
|
|
27314
|
-
function decode$1(params
|
|
27433
|
+
function decode$1(params) {
|
|
27315
27434
|
const { node } = params;
|
|
27316
27435
|
if (!node || !node.type) {
|
|
27317
27436
|
return null;
|
|
@@ -28912,7 +29031,7 @@ function translateStructuredContent(params) {
|
|
|
28912
29031
|
const XML_NODE_NAME = "w:sdt";
|
|
28913
29032
|
const SD_NODE_NAME = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
|
|
28914
29033
|
const validXmlAttributes = [];
|
|
28915
|
-
function encode(params
|
|
29034
|
+
function encode(params) {
|
|
28916
29035
|
const nodes = params.nodes;
|
|
28917
29036
|
const node = nodes[0];
|
|
28918
29037
|
const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
|
|
@@ -28922,7 +29041,7 @@ function encode(params, encodedAttrs) {
|
|
|
28922
29041
|
const result = handler2(params);
|
|
28923
29042
|
return result;
|
|
28924
29043
|
}
|
|
28925
|
-
function decode(params
|
|
29044
|
+
function decode(params) {
|
|
28926
29045
|
const { node } = params;
|
|
28927
29046
|
if (!node || !node.type) {
|
|
28928
29047
|
return null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as process$1, av as commonjsGlobal, B as Buffer, aw as getDefaultExportFromCjs, ax as getContentTypesFromXml, ay as xmljs } from "./converter-
|
|
1
|
+
import { p as process$1, av as commonjsGlobal, B as Buffer, aw as getDefaultExportFromCjs, ax as getContentTypesFromXml, ay as xmljs } from "./converter-C91Sr_5w.js";
|
|
2
2
|
function commonjsRequire(path) {
|
|
3
3
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
4
4
|
}
|
|
@@ -12,9 +12,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
12
12
|
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _DocumentSectionView_instances, init_fn3, addToolTip_fn;
|
|
13
13
|
import * as Y from "yjs";
|
|
14
14
|
import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
|
|
15
|
-
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as StepMap, ao as SelectionRange, ap as Transform, aq as isInTable$1, ar as generateDocxRandomId, as as insertNewRelationship, at as updateDOMAttributes, au as htmlHandler } from "./converter-
|
|
15
|
+
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as StepMap, ao as SelectionRange, ap as Transform, aq as isInTable$1, ar as generateDocxRandomId, as as insertNewRelationship, at as updateDOMAttributes, au as htmlHandler } from "./converter-C91Sr_5w.js";
|
|
16
16
|
import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
|
|
17
|
-
import { D as DocxZipper } from "./docx-zipper-
|
|
17
|
+
import { D as DocxZipper } from "./docx-zipper-Cl7LYpt6.js";
|
|
18
18
|
var GOOD_LEAF_SIZE = 200;
|
|
19
19
|
var RopeSequence = function RopeSequence2() {
|
|
20
20
|
};
|
|
@@ -24308,7 +24308,7 @@ const validateUrlAccessibility = async (url) => {
|
|
|
24308
24308
|
credentials: "omit"
|
|
24309
24309
|
});
|
|
24310
24310
|
return response.ok;
|
|
24311
|
-
} catch
|
|
24311
|
+
} catch {
|
|
24312
24312
|
return false;
|
|
24313
24313
|
}
|
|
24314
24314
|
};
|
|
@@ -24477,6 +24477,57 @@ function multiStepResize(canvas, width, height) {
|
|
|
24477
24477
|
}
|
|
24478
24478
|
resample_high_quality(canvas, width, height);
|
|
24479
24479
|
}
|
|
24480
|
+
const FALLBACK_NAME = "image";
|
|
24481
|
+
const stripDiacritics = (value) => value.normalize("NFKD").replace(/[\u0300-\u036f]/g, "");
|
|
24482
|
+
const sanitizeSegment = (segment, { allowDots = false } = {}) => {
|
|
24483
|
+
if (!segment) return "";
|
|
24484
|
+
const normalized = stripDiacritics(segment).replace(/[\s\u2000-\u206f]+/g, "_").replace(/[\\/]+/g, "_");
|
|
24485
|
+
const allowedPattern = allowDots ? /[^0-9A-Za-z._-]+/g : /[^0-9A-Za-z_-]+/g;
|
|
24486
|
+
let sanitized = normalized.replace(allowedPattern, "_");
|
|
24487
|
+
sanitized = sanitized.replace(/_+/g, "_");
|
|
24488
|
+
sanitized = sanitized.replace(/^[_.-]+/, "");
|
|
24489
|
+
sanitized = sanitized.replace(/[_-]+$/, "");
|
|
24490
|
+
return sanitized;
|
|
24491
|
+
};
|
|
24492
|
+
const splitFileName = (name) => {
|
|
24493
|
+
const trimmed = name?.trim?.() ?? "";
|
|
24494
|
+
const lastDot = trimmed.lastIndexOf(".");
|
|
24495
|
+
if (lastDot <= 0 || lastDot === trimmed.length - 1) {
|
|
24496
|
+
return { base: trimmed, ext: "" };
|
|
24497
|
+
}
|
|
24498
|
+
return {
|
|
24499
|
+
base: trimmed.slice(0, lastDot),
|
|
24500
|
+
ext: trimmed.slice(lastDot + 1)
|
|
24501
|
+
};
|
|
24502
|
+
};
|
|
24503
|
+
const sanitizeImageFileName = (inputName) => {
|
|
24504
|
+
const { base: base2, ext } = splitFileName(inputName || "");
|
|
24505
|
+
const sanitizedBase = sanitizeSegment(base2, { allowDots: true }) || FALLBACK_NAME;
|
|
24506
|
+
const sanitizedExt = sanitizeSegment(ext, { allowDots: false }).toLowerCase();
|
|
24507
|
+
if (!sanitizedExt) return sanitizedBase;
|
|
24508
|
+
return `${sanitizedBase}.${sanitizedExt}`;
|
|
24509
|
+
};
|
|
24510
|
+
const ensureUniqueFileName = (preferredName, existingNames = /* @__PURE__ */ new Set()) => {
|
|
24511
|
+
const sanitized = sanitizeImageFileName(preferredName);
|
|
24512
|
+
if (!existingNames || typeof existingNames.has !== "function") {
|
|
24513
|
+
return sanitized;
|
|
24514
|
+
}
|
|
24515
|
+
const existingSet = /* @__PURE__ */ new Set();
|
|
24516
|
+
existingNames.forEach((name) => existingSet.add(sanitizeImageFileName(name)));
|
|
24517
|
+
if (!existingSet.has(sanitized)) {
|
|
24518
|
+
return sanitized;
|
|
24519
|
+
}
|
|
24520
|
+
const { base: base2, ext } = splitFileName(sanitized);
|
|
24521
|
+
let counter = 1;
|
|
24522
|
+
let candidate = sanitized;
|
|
24523
|
+
const suffix = () => `${base2}-${counter}${ext ? `.${ext}` : ""}`;
|
|
24524
|
+
while (existingSet.has(candidate)) {
|
|
24525
|
+
candidate = suffix();
|
|
24526
|
+
counter += 1;
|
|
24527
|
+
}
|
|
24528
|
+
return candidate;
|
|
24529
|
+
};
|
|
24530
|
+
const buildMediaPath = (fileName) => `word/media/${fileName}`;
|
|
24480
24531
|
const fileTooLarge = (file) => {
|
|
24481
24532
|
let fileSizeMb = Number((file.size / (1024 * 1024)).toFixed(4));
|
|
24482
24533
|
if (fileSizeMb > 5) {
|
|
@@ -24510,16 +24561,37 @@ function replaceSelectionWithImagePlaceholder({ editorOptions, view, id }) {
|
|
|
24510
24561
|
tr = addImagePlaceholder(view.state, tr, id, selection.from);
|
|
24511
24562
|
view.dispatch(tr);
|
|
24512
24563
|
}
|
|
24564
|
+
const generateUniqueDocPrId = (editor) => {
|
|
24565
|
+
const existingIds = /* @__PURE__ */ new Set();
|
|
24566
|
+
editor?.state?.doc?.descendants((node) => {
|
|
24567
|
+
if (node.type.name === "image" && node.attrs.id !== void 0 && node.attrs.id !== null) {
|
|
24568
|
+
existingIds.add(String(node.attrs.id));
|
|
24569
|
+
}
|
|
24570
|
+
});
|
|
24571
|
+
let candidate;
|
|
24572
|
+
do {
|
|
24573
|
+
const hex = generateDocxRandomId();
|
|
24574
|
+
candidate = String(parseInt(hex, 16));
|
|
24575
|
+
} while (!candidate || existingIds.has(candidate));
|
|
24576
|
+
return candidate;
|
|
24577
|
+
};
|
|
24513
24578
|
async function uploadAndInsertImage({ editor, view, file, size, id }) {
|
|
24514
24579
|
const imageUploadHandler = typeof editor.options.handleImageUpload === "function" ? editor.options.handleImageUpload : handleImageUpload;
|
|
24580
|
+
const placeholderId = id;
|
|
24515
24581
|
try {
|
|
24516
|
-
|
|
24517
|
-
|
|
24518
|
-
|
|
24582
|
+
const existingFileNames = new Set(Object.keys(editor.storage.image.media ?? {}).map((key2) => key2.split("/").pop()));
|
|
24583
|
+
const uniqueFileName = ensureUniqueFileName(file.name, existingFileNames);
|
|
24584
|
+
const normalizedFile = uniqueFileName === file.name ? file : new File([file], uniqueFileName, {
|
|
24585
|
+
type: file.type,
|
|
24586
|
+
lastModified: file.lastModified ?? Date.now()
|
|
24587
|
+
});
|
|
24588
|
+
let url = await imageUploadHandler(normalizedFile);
|
|
24589
|
+
let placeholderPos = findPlaceholder(view.state, placeholderId);
|
|
24519
24590
|
if (placeholderPos == null) {
|
|
24520
24591
|
return;
|
|
24521
24592
|
}
|
|
24522
|
-
|
|
24593
|
+
const mediaPath = buildMediaPath(uniqueFileName);
|
|
24594
|
+
const docPrId = generateUniqueDocPrId(editor);
|
|
24523
24595
|
let rId = null;
|
|
24524
24596
|
if (editor.options.mode === "docx") {
|
|
24525
24597
|
const [, path] = mediaPath.split("word/");
|
|
@@ -24529,7 +24601,7 @@ async function uploadAndInsertImage({ editor, view, file, size, id }) {
|
|
|
24529
24601
|
let imageNode = view.state.schema.nodes.image.create({
|
|
24530
24602
|
src: mediaPath,
|
|
24531
24603
|
size,
|
|
24532
|
-
id,
|
|
24604
|
+
id: docPrId,
|
|
24533
24605
|
rId
|
|
24534
24606
|
});
|
|
24535
24607
|
editor.storage.image.media = Object.assign(editor.storage.image.media, { [mediaPath]: url });
|
|
@@ -24538,10 +24610,10 @@ async function uploadAndInsertImage({ editor, view, file, size, id }) {
|
|
|
24538
24610
|
}
|
|
24539
24611
|
let tr = view.state.tr;
|
|
24540
24612
|
tr.replaceWith(placeholderPos, placeholderPos, imageNode);
|
|
24541
|
-
tr = removeImagePlaceholder(view.state, tr,
|
|
24613
|
+
tr = removeImagePlaceholder(view.state, tr, placeholderId);
|
|
24542
24614
|
view.dispatch(tr);
|
|
24543
24615
|
} catch {
|
|
24544
|
-
const tr = removeImagePlaceholder(view.state, view.state.tr,
|
|
24616
|
+
const tr = removeImagePlaceholder(view.state, view.state.tr, placeholderId);
|
|
24545
24617
|
view.dispatch(tr);
|
|
24546
24618
|
}
|
|
24547
24619
|
}
|
|
@@ -25712,7 +25784,7 @@ class StructuredContentViewBase {
|
|
|
25712
25784
|
this.htmlAttributes = props.htmlAttributes;
|
|
25713
25785
|
this.mount(props);
|
|
25714
25786
|
}
|
|
25715
|
-
mount(
|
|
25787
|
+
mount() {
|
|
25716
25788
|
return;
|
|
25717
25789
|
}
|
|
25718
25790
|
get dom() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, createElementBlock, openBlock, createElementVNode, createCommentVNode, normalizeClass, normalizeStyle, ref, withKeys, unref, withModifiers, createBlock, toDisplayString, withDirectives, vModelText, nextTick, getCurrentInstance, createVNode, readonly, watch, onMounted, onBeforeUnmount, reactive, onBeforeMount, inject, onActivated, onDeactivated, createTextVNode, Fragment, Comment, defineComponent, provide, h, Teleport, toRef, renderSlot, isVNode, shallowRef, watchEffect, mergeProps, Transition, vShow, cloneVNode, Text, renderList, withCtx } from "vue";
|
|
2
|
-
import { p as process$1 } from "./converter-
|
|
3
|
-
import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-
|
|
2
|
+
import { p as process$1 } from "./converter-C91Sr_5w.js";
|
|
3
|
+
import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-a7cQT9Dw.js";
|
|
4
4
|
const sanitizeNumber = (value, defaultNumber) => {
|
|
5
5
|
let sanitized = value.replace(/[^0-9.]/g, "");
|
|
6
6
|
sanitized = parseFloat(sanitized);
|