@harbour-enterprises/superdoc 0.20.0-next.7 → 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-BYyZViQt.es.js → PdfViewer-BoDHZ2nW.es.js} +1 -1
- package/dist/chunks/{PdfViewer-DXtnxGoU.cjs → PdfViewer-Ch0v9vA6.cjs} +1 -1
- package/dist/chunks/{index-CqLcgYHG.es.js → index-BWPWqVxp.es.js} +2 -2
- package/dist/chunks/{index-CMBPzhIR.cjs → index-DFOT300M.cjs} +2 -2
- package/dist/chunks/{super-editor.es-5O71lyiI.cjs → super-editor.es-BQ6kZTNg.cjs} +184 -65
- package/dist/chunks/{super-editor.es-BTalhwn-.es.js → super-editor.es-sBfWb5tn.es.js} +184 -65
- 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-CQMKOaY4.js → editor-a7cQT9Dw.js} +4 -4
- package/dist/super-editor/chunks/{toolbar-Cp6gL4i5.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/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 +184 -65
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as defineComponent, B as h, O as Transition, $ as process$1, I as watchEffect, d as computed, r as ref, j as onMounted, W as onUnmounted, c as createElementBlock, o as openBlock, a as createBaseVNode, f as createCommentVNode, v as createVNode, x as unref } from "./vue-CXxsqYcP.es.js";
|
|
2
|
-
import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-
|
|
2
|
+
import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-BWPWqVxp.es.js";
|
|
3
3
|
function self(vars) {
|
|
4
4
|
const {
|
|
5
5
|
opacityDisabled,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const vue = require("./vue-DWle4Cai.cjs");
|
|
4
|
-
const superdoc = require("./index-
|
|
4
|
+
const superdoc = require("./index-DFOT300M.cjs");
|
|
5
5
|
function self(vars) {
|
|
6
6
|
const {
|
|
7
7
|
opacityDisabled,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-
|
|
1
|
+
import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-sBfWb5tn.es.js";
|
|
2
2
|
import { a0 as effectScope, r as ref, _ as markRaw, $ as process$1, a1 as toRaw, d as computed, a2 as isRef, a3 as isReactive, C as toRef, i as inject, p as getCurrentInstance, l as watch, x as unref, a4 as hasInjectionContext, M as reactive, s as nextTick, a5 as getCurrentScope, a6 as onScopeDispose, a7 as toRefs, g as global$1, J as shallowRef, N as readonly, j as onMounted, k as onBeforeUnmount, h as onBeforeMount, S as onActivated, q as onDeactivated, z as createTextVNode, F as Fragment, Q as Comment, m as defineComponent, D as provide, H as withDirectives, B as h, U as Teleport, R as renderSlot, V as isVNode, I as watchEffect, O as Transition, a8 as TransitionGroup, E as mergeProps, P as vShow, G as cloneVNode, T as Text, c as createElementBlock, o as openBlock, t as toDisplayString, v as createVNode, y as withCtx, a as createBaseVNode, A as normalizeStyle, f as createCommentVNode, u as createBlock, w as withModifiers, n as normalizeClass, a9 as resolveDirective, e as renderList, b as createApp, X as resolveDynamicComponent, aa as defineAsyncComponent } from "./vue-CXxsqYcP.es.js";
|
|
3
3
|
import { B as Buffer$2 } from "./jszip-B8KIZSNe.es.js";
|
|
4
4
|
import { B as BlankDOCX } from "./blank-docx-iwdyG9RH.es.js";
|
|
@@ -17369,7 +17369,7 @@ const _sfc_main = {
|
|
|
17369
17369
|
__name: "SuperDoc",
|
|
17370
17370
|
emits: ["selection-update"],
|
|
17371
17371
|
setup(__props, { emit: __emit }) {
|
|
17372
|
-
const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-
|
|
17372
|
+
const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-BoDHZ2nW.es.js"));
|
|
17373
17373
|
const superdocStore = useSuperdocStore();
|
|
17374
17374
|
const commentsStore = useCommentsStore();
|
|
17375
17375
|
const {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const superEditor_es = require("./super-editor.es-
|
|
2
|
+
const superEditor_es = require("./super-editor.es-BQ6kZTNg.cjs");
|
|
3
3
|
const vue = require("./vue-DWle4Cai.cjs");
|
|
4
4
|
const jszip = require("./jszip-b7l8QkfH.cjs");
|
|
5
5
|
const blankDocx = require("./blank-docx-CPqX9RF5.cjs");
|
|
@@ -17386,7 +17386,7 @@ const _sfc_main = {
|
|
|
17386
17386
|
__name: "SuperDoc",
|
|
17387
17387
|
emits: ["selection-update"],
|
|
17388
17388
|
setup(__props, { emit: __emit }) {
|
|
17389
|
-
const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-
|
|
17389
|
+
const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-Ch0v9vA6.cjs")));
|
|
17390
17390
|
const superdocStore = useSuperdocStore();
|
|
17391
17391
|
const commentsStore = useCommentsStore();
|
|
17392
17392
|
const {
|
|
@@ -14798,22 +14798,25 @@ async function readFromClipboard(state2) {
|
|
|
14798
14798
|
function inchesToTwips(inches) {
|
|
14799
14799
|
if (inches == null) return;
|
|
14800
14800
|
if (typeof inches === "string") inches = parseFloat(inches);
|
|
14801
|
-
return Math.round(inches * 1440);
|
|
14801
|
+
return Math.round(Number(inches) * 1440);
|
|
14802
14802
|
}
|
|
14803
14803
|
function twipsToInches(twips) {
|
|
14804
14804
|
if (twips == null) return;
|
|
14805
|
-
|
|
14806
|
-
|
|
14805
|
+
const value = Number(twips);
|
|
14806
|
+
if (Number.isNaN(value)) return;
|
|
14807
|
+
return value / 1440;
|
|
14807
14808
|
}
|
|
14808
14809
|
function twipsToPixels(twips) {
|
|
14809
14810
|
if (twips == null) return;
|
|
14810
|
-
|
|
14811
|
-
|
|
14811
|
+
const inches = twipsToInches(twips);
|
|
14812
|
+
if (inches == null) return;
|
|
14813
|
+
const pixels = inches * 96;
|
|
14814
|
+
return Math.round(pixels * 1e3) / 1e3;
|
|
14812
14815
|
}
|
|
14813
14816
|
function pixelsToTwips(pixels) {
|
|
14814
14817
|
if (pixels == null) return;
|
|
14815
|
-
|
|
14816
|
-
return inchesToTwips(
|
|
14818
|
+
const inches = Number(pixels) / 96;
|
|
14819
|
+
return inchesToTwips(inches);
|
|
14817
14820
|
}
|
|
14818
14821
|
function twipsToLines(twips) {
|
|
14819
14822
|
if (twips == null) return;
|
|
@@ -24701,13 +24704,15 @@ const getParagraphIndent = (node, docx, styleId = "") => {
|
|
|
24701
24704
|
}
|
|
24702
24705
|
return indent;
|
|
24703
24706
|
};
|
|
24704
|
-
const getParagraphSpacing = (node, docx, styleId = "", marks = []) => {
|
|
24707
|
+
const getParagraphSpacing = (node, docx, styleId = "", marks = [], options = {}) => {
|
|
24708
|
+
const { insideTable = false } = options;
|
|
24705
24709
|
const spacing = {};
|
|
24706
|
-
const { spacing: pDefaultSpacing = {} } = getDefaultParagraphStyle(docx, styleId);
|
|
24710
|
+
const { spacing: pDefaultSpacing = {}, spacingSource } = getDefaultParagraphStyle(docx, styleId);
|
|
24707
24711
|
let lineSpaceAfter, lineSpaceBefore, line, lineRuleStyle;
|
|
24708
24712
|
const pPr = node.elements?.find((el) => el.name === "w:pPr");
|
|
24709
24713
|
const inLineSpacingTag = pPr?.elements?.find((el) => el.name === "w:spacing");
|
|
24710
24714
|
const inLineSpacing = inLineSpacingTag?.attributes || {};
|
|
24715
|
+
const hasInlineSpacing = !!Object.keys(inLineSpacing).length;
|
|
24711
24716
|
const textStyleMark = marks.find((el) => el.type === "textStyle");
|
|
24712
24717
|
const fontSize2 = textStyleMark?.attrs?.fontSize;
|
|
24713
24718
|
const lineSpacing = inLineSpacing?.["w:line"] || line || pDefaultSpacing?.["w:line"];
|
|
@@ -24729,6 +24734,12 @@ const getParagraphSpacing = (node, docx, styleId = "", marks = []) => {
|
|
|
24729
24734
|
if (afterAutospacing === "1" && fontSize2) {
|
|
24730
24735
|
spacing.lineSpaceAfter += Math.round(parseInt(fontSize2) * 0.5 * 96 / 72);
|
|
24731
24736
|
}
|
|
24737
|
+
if (insideTable && !hasInlineSpacing && spacingSource === "docDefault") {
|
|
24738
|
+
const hasExplicitSpacing = Object.keys(inLineSpacing).length > 0;
|
|
24739
|
+
if (!hasExplicitSpacing) {
|
|
24740
|
+
return void 0;
|
|
24741
|
+
}
|
|
24742
|
+
}
|
|
24732
24743
|
return spacing;
|
|
24733
24744
|
};
|
|
24734
24745
|
const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
@@ -24769,9 +24780,20 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
|
24769
24780
|
const { attributes: pPrByIdIndentAttr } = pPrStyleIdIndentTag;
|
|
24770
24781
|
const spacingRest = isNormalAsDefault ? pPrNormalSpacingAttr || pPrDefaultSpacingAttr : pPrDefaultSpacingAttr || pPrNormalSpacingAttr;
|
|
24771
24782
|
const indentRest = isNormalAsDefault ? pPrNormalIndentAttr || pPrDefaultIndentAttr : pPrDefaultIndentAttr || pPrNormalIndentAttr;
|
|
24783
|
+
let spacingToUse = pPrByIdSpacingAttr || spacingRest;
|
|
24784
|
+
let spacingSource = "docDefault";
|
|
24785
|
+
if (pPrByIdSpacingAttr) {
|
|
24786
|
+
spacingSource = "style";
|
|
24787
|
+
} else if (spacingRest === pPrNormalSpacingAttr && pPrNormalSpacingAttr) {
|
|
24788
|
+
spacingSource = isNormalAsDefault ? "docDefault" : "normal";
|
|
24789
|
+
} else if (spacingRest === pPrDefaultSpacingAttr && pPrDefaultSpacingAttr) {
|
|
24790
|
+
spacingSource = "docDefault";
|
|
24791
|
+
}
|
|
24792
|
+
let indentToUse = pPrByIdIndentAttr || indentRest;
|
|
24772
24793
|
return {
|
|
24773
|
-
spacing:
|
|
24774
|
-
|
|
24794
|
+
spacing: spacingToUse,
|
|
24795
|
+
spacingSource,
|
|
24796
|
+
indent: indentToUse,
|
|
24775
24797
|
justify: pPrByIdJcAttr
|
|
24776
24798
|
};
|
|
24777
24799
|
};
|
|
@@ -24946,7 +24968,13 @@ const handleParagraphNode$1 = (params2) => {
|
|
|
24946
24968
|
}
|
|
24947
24969
|
if (docx) {
|
|
24948
24970
|
const defaultStyleId = node.attributes?.["w:rsidRDefault"];
|
|
24949
|
-
|
|
24971
|
+
const insideTable = (params2.path || []).some((ancestor) => ancestor.name === "w:tc");
|
|
24972
|
+
const spacing = getParagraphSpacing(node, docx, styleId, schemaNode.attrs.marksAttrs, {
|
|
24973
|
+
insideTable
|
|
24974
|
+
});
|
|
24975
|
+
if (spacing) {
|
|
24976
|
+
schemaNode.attrs["spacing"] = spacing;
|
|
24977
|
+
}
|
|
24950
24978
|
schemaNode.attrs["rsidRDefault"] = defaultStyleId;
|
|
24951
24979
|
}
|
|
24952
24980
|
if (docx) {
|
|
@@ -25192,10 +25220,10 @@ function createBorderPropertyHandler(xmlName, sdName = null) {
|
|
|
25192
25220
|
createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
|
|
25193
25221
|
createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
|
|
25194
25222
|
],
|
|
25195
|
-
encode: (
|
|
25223
|
+
encode: (params2, encodedAttrs) => {
|
|
25196
25224
|
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25197
25225
|
},
|
|
25198
|
-
decode: function({ node },
|
|
25226
|
+
decode: function({ node }, context) {
|
|
25199
25227
|
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs[sdName] || {} } });
|
|
25200
25228
|
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25201
25229
|
}
|
|
@@ -25554,10 +25582,10 @@ const translator$B = NodeTranslator.from({
|
|
|
25554
25582
|
"w:themeTint",
|
|
25555
25583
|
"w:val"
|
|
25556
25584
|
].map((attr) => createAttributeHandler(attr)),
|
|
25557
|
-
encode: (
|
|
25585
|
+
encode: (params2, encodedAttrs) => {
|
|
25558
25586
|
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25559
25587
|
},
|
|
25560
|
-
decode: function({ node },
|
|
25588
|
+
decode: function({ node }, context) {
|
|
25561
25589
|
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.shading || {} } });
|
|
25562
25590
|
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25563
25591
|
}
|
|
@@ -25570,10 +25598,10 @@ const translator$w = NodeTranslator.from({
|
|
|
25570
25598
|
xmlName: "w:tblLook",
|
|
25571
25599
|
sdNodeOrKeyName: "tblLook",
|
|
25572
25600
|
attributes: ["w:firstColumn", "w:firstRow", "w:lastColumn", "w:lastRow", "w:noHBand", "w:noVBand"].map((attr) => createAttributeHandler(attr, null, parseBoolean, booleanToString)).concat([createAttributeHandler("w:val")]),
|
|
25573
|
-
encode: (
|
|
25601
|
+
encode: (params2, encodedAttrs) => {
|
|
25574
25602
|
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25575
25603
|
},
|
|
25576
|
-
decode: function({ node },
|
|
25604
|
+
decode: function({ node }, context) {
|
|
25577
25605
|
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.tblLook || {} } });
|
|
25578
25606
|
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25579
25607
|
}
|
|
@@ -25591,10 +25619,10 @@ const translator$q = NodeTranslator.from({
|
|
|
25591
25619
|
xmlName: "w:tblpPr",
|
|
25592
25620
|
sdNodeOrKeyName: "floatingTableProperties",
|
|
25593
25621
|
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))),
|
|
25594
|
-
encode: (
|
|
25622
|
+
encode: (params2, encodedAttrs) => {
|
|
25595
25623
|
return Object.keys(encodedAttrs).length > 0 ? encodedAttrs : void 0;
|
|
25596
25624
|
},
|
|
25597
|
-
decode: function({ node },
|
|
25625
|
+
decode: function({ node }, context) {
|
|
25598
25626
|
const decodedAttrs = this.decodeAttributes({ node: { ...node, attrs: node.attrs.floatingTableProperties || {} } });
|
|
25599
25627
|
return Object.keys(decodedAttrs).length > 0 ? { attributes: decodedAttrs } : void 0;
|
|
25600
25628
|
}
|
|
@@ -25615,13 +25643,13 @@ const translator$d = NodeTranslator.from(createBorderPropertyHandler("w:top"));
|
|
|
25615
25643
|
const translator$c = NodeTranslator.from(createMeasurementPropertyHandler("w:top", "marginTop"));
|
|
25616
25644
|
const XML_NODE_NAME$a = "w:tblBorders";
|
|
25617
25645
|
const SD_ATTR_KEY$3 = "borders";
|
|
25618
|
-
const encode$a = (params2
|
|
25646
|
+
const encode$a = (params2) => {
|
|
25619
25647
|
const { nodes } = params2;
|
|
25620
25648
|
const node = nodes[0];
|
|
25621
25649
|
const attributes = encodeProperties(node, tblBordersTranslatorsByXmlName);
|
|
25622
25650
|
return Object.keys(attributes).length > 0 ? attributes : void 0;
|
|
25623
25651
|
};
|
|
25624
|
-
const decode$a = (params2
|
|
25652
|
+
const decode$a = (params2) => {
|
|
25625
25653
|
const { borders = {} } = params2.node.attrs || {};
|
|
25626
25654
|
const elements = decodeProperties(tblBordersTranslatorsBySdName, borders);
|
|
25627
25655
|
const newNode = {
|
|
@@ -25658,13 +25686,13 @@ const translator$b = NodeTranslator.from({
|
|
|
25658
25686
|
});
|
|
25659
25687
|
const XML_NODE_NAME$9 = "w:tblCellMar";
|
|
25660
25688
|
const SD_ATTR_KEY$2 = "cellMargins";
|
|
25661
|
-
const encode$9 = (params2
|
|
25689
|
+
const encode$9 = (params2) => {
|
|
25662
25690
|
const { nodes } = params2;
|
|
25663
25691
|
const node = nodes[0];
|
|
25664
25692
|
const attributes = encodeProperties(node, propertyTranslatorsByXmlName$1);
|
|
25665
25693
|
return Object.keys(attributes).length > 0 ? attributes : void 0;
|
|
25666
25694
|
};
|
|
25667
|
-
const decode$9 = (params2
|
|
25695
|
+
const decode$9 = (params2) => {
|
|
25668
25696
|
const { cellMargins = {} } = params2.node.attrs || {};
|
|
25669
25697
|
const elements = decodeProperties(propertyTranslatorsBySdName$1, cellMargins);
|
|
25670
25698
|
const newNode = {
|
|
@@ -25755,6 +25783,53 @@ const translator$9 = NodeTranslator.from(config$8);
|
|
|
25755
25783
|
const translator$8 = NodeTranslator.from(
|
|
25756
25784
|
createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString)
|
|
25757
25785
|
);
|
|
25786
|
+
const DEFAULT_COLUMN_WIDTH_PX = 100;
|
|
25787
|
+
const normalizeTwipWidth = (value) => {
|
|
25788
|
+
if (value == null) return null;
|
|
25789
|
+
const numericValue = typeof value === "string" ? parseInt(value, 10) : value;
|
|
25790
|
+
if (!Number.isFinite(numericValue) || Number.isNaN(numericValue) || numericValue <= 0) {
|
|
25791
|
+
return null;
|
|
25792
|
+
}
|
|
25793
|
+
return numericValue;
|
|
25794
|
+
};
|
|
25795
|
+
const getSchemaDefaultColumnWidthPx = (params2) => {
|
|
25796
|
+
const defaultValue = params2?.editor?.schema?.nodes?.tableCell?.spec?.attrs?.colwidth?.default;
|
|
25797
|
+
if (Array.isArray(defaultValue)) {
|
|
25798
|
+
const numericWidth = defaultValue.find((width) => typeof width === "number" && Number.isFinite(width) && width > 0);
|
|
25799
|
+
if (numericWidth != null) return numericWidth;
|
|
25800
|
+
} else if (typeof defaultValue === "number" && Number.isFinite(defaultValue) && defaultValue > 0) {
|
|
25801
|
+
return defaultValue;
|
|
25802
|
+
}
|
|
25803
|
+
return DEFAULT_COLUMN_WIDTH_PX;
|
|
25804
|
+
};
|
|
25805
|
+
const getTableWidthPx = (params2) => {
|
|
25806
|
+
const explicitWidth = params2?.node?.attrs?.tableWidth?.width;
|
|
25807
|
+
if (typeof explicitWidth === "number" && explicitWidth > 0) return explicitWidth;
|
|
25808
|
+
const tableWidth = params2?.node?.attrs?.tableProperties?.tableWidth;
|
|
25809
|
+
if (tableWidth?.value != null && typeof tableWidth.value === "number" && tableWidth.value > 0) {
|
|
25810
|
+
const { value, type: type2 } = tableWidth;
|
|
25811
|
+
if (!type2 || type2 === "auto" || type2 === "dxa") {
|
|
25812
|
+
return twipsToPixels(value);
|
|
25813
|
+
}
|
|
25814
|
+
}
|
|
25815
|
+
return null;
|
|
25816
|
+
};
|
|
25817
|
+
const resolveFallbackColumnWidthTwips = (params2, totalColumns, cellMinWidthTwips) => {
|
|
25818
|
+
const columnCount = Math.max(totalColumns, 1);
|
|
25819
|
+
const defaultColumnWidthPx = getSchemaDefaultColumnWidthPx(params2);
|
|
25820
|
+
const tableWidthPx = getTableWidthPx(params2);
|
|
25821
|
+
const safeDefaultPx = Number.isFinite(defaultColumnWidthPx) && defaultColumnWidthPx > 0 ? defaultColumnWidthPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
25822
|
+
let fallbackWidthPx = safeDefaultPx;
|
|
25823
|
+
if (typeof tableWidthPx === "number" && tableWidthPx > 0) {
|
|
25824
|
+
fallbackWidthPx = tableWidthPx / columnCount;
|
|
25825
|
+
}
|
|
25826
|
+
const fallbackWidthTwips = pixelsToTwips(fallbackWidthPx);
|
|
25827
|
+
if (!Number.isFinite(fallbackWidthTwips) || Number.isNaN(fallbackWidthTwips) || fallbackWidthTwips <= 0) {
|
|
25828
|
+
const safeDefault = Math.max(pixelsToTwips(safeDefaultPx), cellMinWidthTwips);
|
|
25829
|
+
return safeDefault;
|
|
25830
|
+
}
|
|
25831
|
+
return Math.max(fallbackWidthTwips, cellMinWidthTwips);
|
|
25832
|
+
};
|
|
25758
25833
|
const XML_NODE_NAME$7 = "w:tblGrid";
|
|
25759
25834
|
const SD_ATTR_KEY = "grid";
|
|
25760
25835
|
const cellMinWidth = pixelsToTwips(10);
|
|
@@ -25769,35 +25844,60 @@ const encode$7 = (params2) => {
|
|
|
25769
25844
|
};
|
|
25770
25845
|
};
|
|
25771
25846
|
const decode$7 = (params2) => {
|
|
25772
|
-
const { grid
|
|
25847
|
+
const { grid: rawGrid } = params2.node.attrs || {};
|
|
25848
|
+
const grid = Array.isArray(rawGrid) ? rawGrid : [];
|
|
25773
25849
|
const { firstRow = {} } = params2.extraParams || {};
|
|
25774
25850
|
const cellNodes = firstRow.content?.filter((n) => n.type === "tableCell") ?? [];
|
|
25775
|
-
const
|
|
25851
|
+
const columnCountFromCells = cellNodes.reduce((count, cell) => {
|
|
25852
|
+
const spanCount = Math.max(1, cell?.attrs?.colspan ?? 1);
|
|
25853
|
+
return count + spanCount;
|
|
25854
|
+
}, 0);
|
|
25855
|
+
const totalColumns = Math.max(columnCountFromCells, grid.length);
|
|
25856
|
+
const fallbackColumnWidthTwips = resolveFallbackColumnWidthTwips(params2, totalColumns, cellMinWidth);
|
|
25776
25857
|
const elements = [];
|
|
25777
|
-
|
|
25778
|
-
|
|
25858
|
+
let columnIndex = 0;
|
|
25859
|
+
const pushColumn = (widthTwips) => {
|
|
25860
|
+
let numericWidth = typeof widthTwips === "string" ? parseInt(widthTwips, 10) : widthTwips;
|
|
25861
|
+
if (numericWidth == null || Number.isNaN(numericWidth) || numericWidth <= 0) {
|
|
25862
|
+
numericWidth = fallbackColumnWidthTwips;
|
|
25863
|
+
}
|
|
25864
|
+
numericWidth = Math.max(numericWidth, cellMinWidth);
|
|
25865
|
+
const decoded = translator$8.decode({
|
|
25866
|
+
node: { type: (
|
|
25867
|
+
/** @type {string} */
|
|
25868
|
+
translator$8.sdNodeOrKeyName
|
|
25869
|
+
), attrs: { col: numericWidth } }
|
|
25870
|
+
});
|
|
25871
|
+
if (decoded) elements.push(decoded);
|
|
25872
|
+
};
|
|
25873
|
+
cellNodes.forEach((cell) => {
|
|
25779
25874
|
const { colspan = 1, colwidth } = cell?.attrs || {};
|
|
25780
|
-
|
|
25781
|
-
|
|
25782
|
-
const
|
|
25783
|
-
const
|
|
25784
|
-
const
|
|
25875
|
+
const spanCount = Math.max(1, colspan);
|
|
25876
|
+
for (let span = 0; span < spanCount; span++) {
|
|
25877
|
+
const cellWidthPixels = Array.isArray(colwidth) ? colwidth[span] : void 0;
|
|
25878
|
+
const colGridAttrs = grid?.[columnIndex] || {};
|
|
25879
|
+
const gridWidthTwips = normalizeTwipWidth(colGridAttrs.col);
|
|
25880
|
+
const gridWidthPixels = gridWidthTwips != null ? twipsToPixels(gridWidthTwips) : null;
|
|
25785
25881
|
let cellWidthTwips;
|
|
25786
|
-
if (
|
|
25882
|
+
if (cellWidthPixels != null) {
|
|
25883
|
+
if (gridWidthTwips != null && gridWidthPixels === cellWidthPixels) {
|
|
25884
|
+
cellWidthTwips = gridWidthTwips;
|
|
25885
|
+
} else {
|
|
25886
|
+
cellWidthTwips = pixelsToTwips(cellWidthPixels);
|
|
25887
|
+
}
|
|
25888
|
+
} else if (gridWidthTwips != null) {
|
|
25787
25889
|
cellWidthTwips = gridWidthTwips;
|
|
25788
|
-
} else
|
|
25789
|
-
cellWidthTwips =
|
|
25790
|
-
}
|
|
25791
|
-
|
|
25792
|
-
|
|
25793
|
-
translator$8.decode({
|
|
25794
|
-
node: { type: (
|
|
25795
|
-
/** @type {string} */
|
|
25796
|
-
translator$8.sdNodeOrKeyName
|
|
25797
|
-
), attrs: { col: widthTwips } }
|
|
25798
|
-
})
|
|
25799
|
-
);
|
|
25890
|
+
} else {
|
|
25891
|
+
cellWidthTwips = fallbackColumnWidthTwips;
|
|
25892
|
+
}
|
|
25893
|
+
pushColumn(cellWidthTwips);
|
|
25894
|
+
columnIndex++;
|
|
25800
25895
|
}
|
|
25896
|
+
});
|
|
25897
|
+
while (columnIndex < grid.length) {
|
|
25898
|
+
const gridWidthTwips = normalizeTwipWidth(grid[columnIndex]?.col);
|
|
25899
|
+
pushColumn(gridWidthTwips);
|
|
25900
|
+
columnIndex++;
|
|
25801
25901
|
}
|
|
25802
25902
|
const newNode = {
|
|
25803
25903
|
name: XML_NODE_NAME$7,
|
|
@@ -25820,7 +25920,8 @@ const encode$6 = (params2, encodedAttrs) => {
|
|
|
25820
25920
|
const node = nodes[0];
|
|
25821
25921
|
const tblPr = node.elements.find((el) => el.name === "w:tblPr");
|
|
25822
25922
|
if (tblPr) {
|
|
25823
|
-
|
|
25923
|
+
const encodedProperties = translator$9.encode({ ...params2, nodes: [tblPr] });
|
|
25924
|
+
encodedAttrs["tableProperties"] = encodedProperties?.attributes || {};
|
|
25824
25925
|
}
|
|
25825
25926
|
const tblGrid = node.elements.find((el) => el.name === "w:tblGrid");
|
|
25826
25927
|
if (tblGrid) {
|
|
@@ -25842,7 +25943,7 @@ const encode$6 = (params2, encodedAttrs) => {
|
|
|
25842
25943
|
key2 = prop;
|
|
25843
25944
|
transform = (v2) => v2;
|
|
25844
25945
|
}
|
|
25845
|
-
if (encodedAttrs.tableProperties
|
|
25946
|
+
if (encodedAttrs.tableProperties && encodedAttrs.tableProperties[key2]) {
|
|
25846
25947
|
encodedAttrs[key2] = transform(encodedAttrs.tableProperties[key2]);
|
|
25847
25948
|
}
|
|
25848
25949
|
});
|
|
@@ -25851,11 +25952,17 @@ const encode$6 = (params2, encodedAttrs) => {
|
|
|
25851
25952
|
}
|
|
25852
25953
|
const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
|
|
25853
25954
|
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
|
|
25955
|
+
if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
|
|
25956
|
+
encodedAttrs.tableProperties = {
|
|
25957
|
+
...encodedAttrs.tableProperties || {},
|
|
25958
|
+
cellMargins: referencedStyles.cellMargins
|
|
25959
|
+
};
|
|
25960
|
+
}
|
|
25854
25961
|
const rows = node.elements.filter((el) => el.name === "w:tr");
|
|
25855
25962
|
const borderData = Object.assign({}, referencedStyles?.borders || {}, borders || {});
|
|
25856
25963
|
const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
|
|
25857
25964
|
encodedAttrs["borders"] = borderData;
|
|
25858
|
-
const tblStyleTag = tblPr
|
|
25965
|
+
const tblStyleTag = tblPr?.elements?.find((el) => el.name === "w:tblStyle");
|
|
25859
25966
|
const columnWidths = (encodedAttrs["grid"] ?? []).map((item) => twipsToPixels(item.col));
|
|
25860
25967
|
const content = [];
|
|
25861
25968
|
rows.forEach((row) => {
|
|
@@ -25864,6 +25971,7 @@ const encode$6 = (params2, encodedAttrs) => {
|
|
|
25864
25971
|
nodes: [row],
|
|
25865
25972
|
extraParams: {
|
|
25866
25973
|
row,
|
|
25974
|
+
table: node,
|
|
25867
25975
|
rowBorders: borderRowData,
|
|
25868
25976
|
styleTag: tblStyleTag,
|
|
25869
25977
|
columnWidths
|
|
@@ -25965,7 +26073,12 @@ function _getReferencedTableStyles(tableStyleReference, params2) {
|
|
|
25965
26073
|
if (rowBorders) stylesToReturn.rowBorders = rowBorders;
|
|
25966
26074
|
const cellMargins = {};
|
|
25967
26075
|
Object.entries(tableProperties.cellMargins || {}).forEach(([key2, attrs]) => {
|
|
25968
|
-
if (attrs?.value
|
|
26076
|
+
if (attrs?.value != null) {
|
|
26077
|
+
cellMargins[key2] = {
|
|
26078
|
+
value: attrs.value,
|
|
26079
|
+
type: attrs.type || "dxa"
|
|
26080
|
+
};
|
|
26081
|
+
}
|
|
25969
26082
|
});
|
|
25970
26083
|
if (Object.keys(cellMargins).length) stylesToReturn.cellMargins = cellMargins;
|
|
25971
26084
|
}
|
|
@@ -26218,11 +26331,17 @@ const getTableCellMargins = (marginTag, referencedStyles) => {
|
|
|
26218
26331
|
marginTop: marginTopStyle,
|
|
26219
26332
|
marginBottom: marginBottomStyle
|
|
26220
26333
|
} = cellMargins;
|
|
26334
|
+
const resolveMargin = (inlineValue, styleValue) => {
|
|
26335
|
+
if (inlineValue != null) return inlineValue;
|
|
26336
|
+
if (styleValue == null) return void 0;
|
|
26337
|
+
if (typeof styleValue === "object") return styleValue.value;
|
|
26338
|
+
return styleValue;
|
|
26339
|
+
};
|
|
26221
26340
|
const margins = {
|
|
26222
|
-
left: twipsToPixels(inlineMarginLeftValue
|
|
26223
|
-
right: twipsToPixels(inlineMarginRightValue
|
|
26224
|
-
top: twipsToPixels(inlineMarginTopValue
|
|
26225
|
-
bottom: twipsToPixels(inlineMarginBottomValue
|
|
26341
|
+
left: twipsToPixels(resolveMargin(inlineMarginLeftValue, marginLeftStyle)),
|
|
26342
|
+
right: twipsToPixels(resolveMargin(inlineMarginRightValue, marginRightStyle)),
|
|
26343
|
+
top: twipsToPixels(resolveMargin(inlineMarginTopValue, marginTopStyle)),
|
|
26344
|
+
bottom: twipsToPixels(resolveMargin(inlineMarginBottomValue, marginBottomStyle))
|
|
26226
26345
|
};
|
|
26227
26346
|
return margins;
|
|
26228
26347
|
};
|
|
@@ -26497,7 +26616,7 @@ function parseTagValueJSON(json) {
|
|
|
26497
26616
|
}
|
|
26498
26617
|
try {
|
|
26499
26618
|
return JSON.parse(trimmed);
|
|
26500
|
-
} catch
|
|
26619
|
+
} catch {
|
|
26501
26620
|
return {};
|
|
26502
26621
|
}
|
|
26503
26622
|
}
|
|
@@ -27236,14 +27355,14 @@ function translateAnchorNode(params2) {
|
|
|
27236
27355
|
const XML_NODE_NAME$3 = "wp:anchor";
|
|
27237
27356
|
const SD_NODE_NAME$3 = ["image"];
|
|
27238
27357
|
const validXmlAttributes$3 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
27239
|
-
function encode$3(params2
|
|
27358
|
+
function encode$3(params2) {
|
|
27240
27359
|
const { node } = params2.extraParams;
|
|
27241
27360
|
if (!node || !node.type) {
|
|
27242
27361
|
return null;
|
|
27243
27362
|
}
|
|
27244
27363
|
return handleAnchorNode(params2);
|
|
27245
27364
|
}
|
|
27246
|
-
function decode$3(params2
|
|
27365
|
+
function decode$3(params2) {
|
|
27247
27366
|
const { node } = params2;
|
|
27248
27367
|
if (!node || !node.type) {
|
|
27249
27368
|
return null;
|
|
@@ -27277,14 +27396,14 @@ function translateInlineNode(params2) {
|
|
|
27277
27396
|
const XML_NODE_NAME$2 = "wp:inline";
|
|
27278
27397
|
const SD_NODE_NAME$2 = ["image"];
|
|
27279
27398
|
const validXmlAttributes$2 = ["distT", "distB", "distL", "distR"].map((xmlName) => createAttributeHandler(xmlName));
|
|
27280
|
-
function encode$2(params2
|
|
27399
|
+
function encode$2(params2) {
|
|
27281
27400
|
const { node } = params2.extraParams;
|
|
27282
27401
|
if (!node || !node.type) {
|
|
27283
27402
|
return null;
|
|
27284
27403
|
}
|
|
27285
27404
|
return handleInlineNode(params2);
|
|
27286
27405
|
}
|
|
27287
|
-
function decode$2(params2
|
|
27406
|
+
function decode$2(params2) {
|
|
27288
27407
|
const { node } = params2;
|
|
27289
27408
|
if (!node || !node.type) {
|
|
27290
27409
|
return null;
|
|
@@ -27310,7 +27429,7 @@ const registeredHandlers = Object.freeze({
|
|
|
27310
27429
|
const XML_NODE_NAME$1 = "w:drawing";
|
|
27311
27430
|
const SD_NODE_NAME$1 = [];
|
|
27312
27431
|
const validXmlAttributes$1 = [];
|
|
27313
|
-
function encode$1(params2
|
|
27432
|
+
function encode$1(params2) {
|
|
27314
27433
|
const nodes = params2.nodes;
|
|
27315
27434
|
const node = nodes[0];
|
|
27316
27435
|
const validChildTranslators = ["wp:anchor", "wp:inline"];
|
|
@@ -27321,7 +27440,7 @@ function encode$1(params2, encodedAttrs) {
|
|
|
27321
27440
|
return translator2.encode({ ...params2, extraParams: { node: child } }) || acc;
|
|
27322
27441
|
}, null);
|
|
27323
27442
|
}
|
|
27324
|
-
function decode$1(params2
|
|
27443
|
+
function decode$1(params2) {
|
|
27325
27444
|
const { node } = params2;
|
|
27326
27445
|
if (!node || !node.type) {
|
|
27327
27446
|
return null;
|
|
@@ -28922,7 +29041,7 @@ function translateStructuredContent(params2) {
|
|
|
28922
29041
|
const XML_NODE_NAME = "w:sdt";
|
|
28923
29042
|
const SD_NODE_NAME = ["fieldAnnotation", "structuredContent", "structuredContentBlock", "documentSection"];
|
|
28924
29043
|
const validXmlAttributes = [];
|
|
28925
|
-
function encode$s(params2
|
|
29044
|
+
function encode$s(params2) {
|
|
28926
29045
|
const nodes = params2.nodes;
|
|
28927
29046
|
const node = nodes[0];
|
|
28928
29047
|
const { type: sdtType, handler: handler2 } = sdtNodeTypeStrategy(node);
|
|
@@ -28932,7 +29051,7 @@ function encode$s(params2, encodedAttrs) {
|
|
|
28932
29051
|
const result = handler2(params2);
|
|
28933
29052
|
return result;
|
|
28934
29053
|
}
|
|
28935
|
-
function decode(params2
|
|
29054
|
+
function decode(params2) {
|
|
28936
29055
|
const { node } = params2;
|
|
28937
29056
|
if (!node || !node.type) {
|
|
28938
29057
|
return null;
|
|
@@ -58667,7 +58786,7 @@ const validateUrlAccessibility = async (url) => {
|
|
|
58667
58786
|
credentials: "omit"
|
|
58668
58787
|
});
|
|
58669
58788
|
return response.ok;
|
|
58670
|
-
} catch
|
|
58789
|
+
} catch {
|
|
58671
58790
|
return false;
|
|
58672
58791
|
}
|
|
58673
58792
|
};
|
|
@@ -60143,7 +60262,7 @@ class StructuredContentViewBase {
|
|
|
60143
60262
|
this.htmlAttributes = props.htmlAttributes;
|
|
60144
60263
|
this.mount(props);
|
|
60145
60264
|
}
|
|
60146
|
-
mount(
|
|
60265
|
+
mount() {
|
|
60147
60266
|
return;
|
|
60148
60267
|
}
|
|
60149
60268
|
get dom() {
|