@harbour-enterprises/superdoc 1.3.0-next.2 → 1.3.0-next.3
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-BEZc2jzN.cjs → PdfViewer-D6XxSIuw.cjs} +2 -2
- package/dist/chunks/{PdfViewer-BpbDm_Oh.es.js → PdfViewer-ltwzoe73.es.js} +2 -2
- package/dist/chunks/{SuperConverter-ClzyObj7.es.js → SuperConverter-CVOKZex3.es.js} +294 -192
- package/dist/chunks/{SuperConverter-DOTz2R8L.cjs → SuperConverter-XGlv5pME.cjs} +261 -159
- package/dist/chunks/{index-C2XLSjq0.cjs → index-D0lYfjMI.cjs} +746 -432
- package/dist/chunks/{index-sykfrKvQ.cjs → index-HQW67fDU.cjs} +4 -4
- package/dist/chunks/{index-D5tN0eME.es.js → index-M8MvGhiF.es.js} +746 -432
- package/dist/chunks/{index-CMxyLpsU.es.js → index-e6096-IC.es.js} +4 -4
- package/dist/super-editor/converter.cjs +1 -1
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor.cjs +2 -2
- package/dist/super-editor.es.js +3 -3
- package/dist/superdoc.cjs +3 -3
- package/dist/superdoc.es.js +3 -3
- package/dist/superdoc.umd.js +1010 -598
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +3 -3
|
@@ -7490,134 +7490,200 @@ const INLINE_OVERRIDE_PROPERTIES = [
|
|
|
7490
7490
|
"italic",
|
|
7491
7491
|
"strike",
|
|
7492
7492
|
"underline",
|
|
7493
|
-
"letterSpacing"
|
|
7494
|
-
"vertAlign",
|
|
7495
|
-
"position"
|
|
7493
|
+
"letterSpacing"
|
|
7496
7494
|
];
|
|
7497
7495
|
const DEFAULT_FONT_SIZE_HALF_POINTS = 20;
|
|
7498
|
-
|
|
7499
|
-
|
|
7496
|
+
function isObject(item) {
|
|
7497
|
+
return item != null && typeof item === "object" && !Array.isArray(item);
|
|
7498
|
+
}
|
|
7499
|
+
function combineProperties$1(propertiesArray, options = {}) {
|
|
7500
|
+
const { fullOverrideProps = [], specialHandling = {} } = options;
|
|
7501
|
+
if (!propertiesArray || propertiesArray.length === 0) {
|
|
7502
|
+
return {};
|
|
7503
|
+
}
|
|
7504
|
+
const merge = (target, source) => {
|
|
7505
|
+
const output = { ...target };
|
|
7506
|
+
if (isObject(target) && isObject(source)) {
|
|
7507
|
+
for (const key in source) {
|
|
7508
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7509
|
+
const handler2 = specialHandling[key];
|
|
7510
|
+
if (handler2 && typeof handler2 === "function") {
|
|
7511
|
+
output[key] = handler2(output, source);
|
|
7512
|
+
} else if (!fullOverrideProps.includes(key) && isObject(source[key])) {
|
|
7513
|
+
if (key in target && isObject(target[key])) {
|
|
7514
|
+
output[key] = merge(target[key], source[key]);
|
|
7515
|
+
} else {
|
|
7516
|
+
output[key] = source[key];
|
|
7517
|
+
}
|
|
7518
|
+
} else {
|
|
7519
|
+
output[key] = source[key];
|
|
7520
|
+
}
|
|
7521
|
+
}
|
|
7522
|
+
}
|
|
7523
|
+
}
|
|
7524
|
+
return output;
|
|
7525
|
+
};
|
|
7526
|
+
return propertiesArray.reduce((acc, current) => merge(acc, current ?? {}), {});
|
|
7527
|
+
}
|
|
7528
|
+
function combineRunProperties$1(propertiesArray) {
|
|
7529
|
+
return combineProperties$1(propertiesArray, {
|
|
7530
|
+
fullOverrideProps: ["fontFamily", "color"]
|
|
7531
|
+
});
|
|
7532
|
+
}
|
|
7533
|
+
function applyInlineOverrides(finalProps, inlineProps, overrideKeys = INLINE_OVERRIDE_PROPERTIES) {
|
|
7534
|
+
if (!inlineProps) return finalProps;
|
|
7535
|
+
for (const prop of overrideKeys) {
|
|
7536
|
+
if (inlineProps[prop] != null) {
|
|
7537
|
+
finalProps[prop] = inlineProps[prop];
|
|
7538
|
+
}
|
|
7539
|
+
}
|
|
7540
|
+
return finalProps;
|
|
7541
|
+
}
|
|
7542
|
+
function isValidFontSize(value) {
|
|
7543
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
7544
|
+
}
|
|
7545
|
+
function resolveFontSizeWithFallback(value, defaultProps, normalProps) {
|
|
7546
|
+
if (isValidFontSize(value)) {
|
|
7547
|
+
return value;
|
|
7548
|
+
}
|
|
7549
|
+
if (defaultProps && isValidFontSize(defaultProps.fontSize)) {
|
|
7550
|
+
return defaultProps.fontSize;
|
|
7551
|
+
}
|
|
7552
|
+
if (normalProps && isValidFontSize(normalProps.fontSize)) {
|
|
7553
|
+
return normalProps.fontSize;
|
|
7554
|
+
}
|
|
7555
|
+
return DEFAULT_FONT_SIZE_HALF_POINTS;
|
|
7556
|
+
}
|
|
7557
|
+
function orderDefaultsAndNormal(defaultProps, normalProps, isNormalDefault) {
|
|
7558
|
+
if (isNormalDefault) {
|
|
7559
|
+
return [defaultProps, normalProps];
|
|
7560
|
+
} else {
|
|
7561
|
+
return [normalProps, defaultProps];
|
|
7562
|
+
}
|
|
7563
|
+
}
|
|
7564
|
+
function createFirstLineIndentHandler() {
|
|
7565
|
+
return (target, source) => {
|
|
7566
|
+
if (target.hanging != null && source.firstLine != null) {
|
|
7567
|
+
delete target.hanging;
|
|
7568
|
+
}
|
|
7569
|
+
return source.firstLine;
|
|
7570
|
+
};
|
|
7571
|
+
}
|
|
7572
|
+
function combineIndentProperties(indentChain) {
|
|
7573
|
+
const indentOnly = indentChain.map((props) => props.indent != null ? { indent: props.indent } : {});
|
|
7574
|
+
return combineProperties$1(indentOnly, {
|
|
7575
|
+
specialHandling: {
|
|
7576
|
+
firstLine: createFirstLineIndentHandler()
|
|
7577
|
+
}
|
|
7578
|
+
});
|
|
7579
|
+
}
|
|
7580
|
+
function createOoxmlResolver(translators) {
|
|
7581
|
+
return {
|
|
7582
|
+
resolveRunProperties: (params, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) => resolveRunProperties$1(translators, params, inlineRpr, resolvedPpr, isListNumber, numberingDefinedInline),
|
|
7583
|
+
resolveParagraphProperties: (params, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) => resolveParagraphProperties$1(translators, params, inlineProps, insideTable, overrideInlineStyleId, tableStyleId),
|
|
7584
|
+
getDefaultProperties,
|
|
7585
|
+
getStyleProperties,
|
|
7586
|
+
resolveStyleChain,
|
|
7587
|
+
getNumberingProperties: (params, ilvl, numId, translator2, tries = 0) => getNumberingProperties(translators, params, ilvl, numId, translator2, tries)
|
|
7588
|
+
};
|
|
7589
|
+
}
|
|
7590
|
+
function resolveRunProperties$1(translators, params, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) {
|
|
7500
7591
|
const paragraphStyleId = resolvedPpr?.styleId;
|
|
7501
|
-
const paragraphStyleProps = resolveStyleChain(params, paragraphStyleId,
|
|
7502
|
-
const defaultProps = getDefaultProperties(params,
|
|
7503
|
-
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params, "Normal",
|
|
7592
|
+
const paragraphStyleProps = resolveStyleChain(params, paragraphStyleId, translators.rPr);
|
|
7593
|
+
const defaultProps = getDefaultProperties(params, translators.rPr);
|
|
7594
|
+
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params, "Normal", translators.rPr);
|
|
7504
7595
|
let runStyleProps = {};
|
|
7505
7596
|
if (!paragraphStyleId?.startsWith("TOC")) {
|
|
7506
|
-
runStyleProps = inlineRpr
|
|
7597
|
+
runStyleProps = inlineRpr?.styleId ? resolveStyleChain(params, inlineRpr.styleId, translators.rPr) : {};
|
|
7507
7598
|
}
|
|
7599
|
+
const defaultsChain = orderDefaultsAndNormal(defaultProps, normalProps, isNormalDefault);
|
|
7600
|
+
const inlineRprSafe = inlineRpr ?? {};
|
|
7508
7601
|
let styleChain;
|
|
7509
|
-
|
|
7510
|
-
styleChain = [defaultProps, normalProps];
|
|
7511
|
-
} else {
|
|
7512
|
-
styleChain = [normalProps, defaultProps];
|
|
7513
|
-
}
|
|
7602
|
+
let inlineOverrideSource = inlineRprSafe;
|
|
7514
7603
|
if (isListNumber) {
|
|
7515
7604
|
let numberingProps = {};
|
|
7516
|
-
const
|
|
7605
|
+
const numberingProperties = resolvedPpr?.numberingProperties;
|
|
7606
|
+
const numId = numberingProperties?.numId;
|
|
7517
7607
|
if (numId != null && numId !== 0 && numId !== "0") {
|
|
7518
7608
|
numberingProps = getNumberingProperties(
|
|
7609
|
+
translators,
|
|
7519
7610
|
params,
|
|
7520
|
-
|
|
7611
|
+
numberingProperties?.ilvl ?? 0,
|
|
7521
7612
|
numId,
|
|
7522
|
-
|
|
7613
|
+
translators.rPr
|
|
7523
7614
|
);
|
|
7524
7615
|
}
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
if (inlineRpr?.underline) {
|
|
7529
|
-
delete inlineRpr.underline;
|
|
7616
|
+
const inlineRprForList = numberingDefinedInline ? inlineRprSafe : {};
|
|
7617
|
+
if (inlineRprForList?.underline) {
|
|
7618
|
+
delete inlineRprForList.underline;
|
|
7530
7619
|
}
|
|
7531
|
-
styleChain = [...
|
|
7620
|
+
styleChain = [...defaultsChain, paragraphStyleProps, runStyleProps, inlineRprForList, numberingProps];
|
|
7621
|
+
inlineOverrideSource = inlineRprForList;
|
|
7532
7622
|
} else {
|
|
7533
|
-
styleChain = [...
|
|
7534
|
-
}
|
|
7535
|
-
const finalProps = combineProperties(styleChain, ["fontFamily", "color"]);
|
|
7536
|
-
for (const prop of INLINE_OVERRIDE_PROPERTIES) {
|
|
7537
|
-
if (inlineRpr?.[prop] != null) {
|
|
7538
|
-
finalProps[prop] = inlineRpr[prop];
|
|
7539
|
-
}
|
|
7540
|
-
}
|
|
7541
|
-
if (finalProps.fontSize == null || typeof finalProps.fontSize !== "number" || !Number.isFinite(finalProps.fontSize) || finalProps.fontSize <= 0) {
|
|
7542
|
-
let defaultFontSize = DEFAULT_FONT_SIZE_HALF_POINTS;
|
|
7543
|
-
if (defaultProps?.fontSize != null && typeof defaultProps.fontSize === "number" && Number.isFinite(defaultProps.fontSize) && defaultProps.fontSize > 0) {
|
|
7544
|
-
defaultFontSize = defaultProps.fontSize;
|
|
7545
|
-
} else if (normalProps?.fontSize != null && typeof normalProps.fontSize === "number" && Number.isFinite(normalProps.fontSize) && normalProps.fontSize > 0) {
|
|
7546
|
-
defaultFontSize = normalProps.fontSize;
|
|
7547
|
-
}
|
|
7548
|
-
finalProps.fontSize = defaultFontSize;
|
|
7623
|
+
styleChain = [...defaultsChain, paragraphStyleProps, runStyleProps, inlineRprSafe];
|
|
7549
7624
|
}
|
|
7625
|
+
const finalProps = combineRunProperties$1(styleChain);
|
|
7626
|
+
applyInlineOverrides(finalProps, inlineOverrideSource);
|
|
7627
|
+
finalProps.fontSize = resolveFontSizeWithFallback(finalProps.fontSize, defaultProps, normalProps);
|
|
7550
7628
|
return finalProps;
|
|
7551
|
-
}
|
|
7552
|
-
function resolveParagraphProperties(params, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
7553
|
-
const defaultProps = getDefaultProperties(params,
|
|
7554
|
-
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params, "Normal",
|
|
7555
|
-
|
|
7556
|
-
let
|
|
7629
|
+
}
|
|
7630
|
+
function resolveParagraphProperties$1(translators, params, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
7631
|
+
const defaultProps = getDefaultProperties(params, translators.pPr);
|
|
7632
|
+
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params, "Normal", translators.pPr);
|
|
7633
|
+
const inlinePropsSafe = inlineProps ?? {};
|
|
7634
|
+
let styleId = inlinePropsSafe?.styleId;
|
|
7635
|
+
let styleProps = inlinePropsSafe?.styleId ? resolveStyleChain(params, inlinePropsSafe.styleId, translators.pPr) : {};
|
|
7557
7636
|
let numberingProps = {};
|
|
7558
|
-
|
|
7559
|
-
let numId =
|
|
7560
|
-
let numberingDefinedInline =
|
|
7561
|
-
const
|
|
7637
|
+
const ilvl = inlinePropsSafe?.numberingProperties?.ilvl ?? styleProps?.numberingProperties?.ilvl;
|
|
7638
|
+
let numId = inlinePropsSafe?.numberingProperties?.numId ?? styleProps?.numberingProperties?.numId;
|
|
7639
|
+
let numberingDefinedInline = inlinePropsSafe?.numberingProperties?.numId != null;
|
|
7640
|
+
const inlineNumId = inlinePropsSafe?.numberingProperties?.numId;
|
|
7641
|
+
const inlineNumIdDisablesNumbering = inlineNumId === 0 || inlineNumId === "0";
|
|
7562
7642
|
if (inlineNumIdDisablesNumbering) {
|
|
7563
7643
|
numId = null;
|
|
7564
7644
|
}
|
|
7565
7645
|
const isList2 = numId != null && numId !== 0 && numId !== "0";
|
|
7566
7646
|
if (isList2) {
|
|
7567
|
-
|
|
7568
|
-
numberingProps = getNumberingProperties(params,
|
|
7647
|
+
const ilvlNum = ilvl != null ? ilvl : 0;
|
|
7648
|
+
numberingProps = getNumberingProperties(translators, params, ilvlNum, numId, translators.pPr);
|
|
7569
7649
|
if (overrideInlineStyleId && numberingProps.styleId) {
|
|
7570
7650
|
styleId = numberingProps.styleId;
|
|
7571
|
-
styleProps = resolveStyleChain(params, styleId,
|
|
7572
|
-
if (
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7651
|
+
styleProps = resolveStyleChain(params, styleId, translators.pPr);
|
|
7652
|
+
if (inlinePropsSafe) {
|
|
7653
|
+
inlinePropsSafe.styleId = styleId;
|
|
7654
|
+
const inlineNumProps = inlinePropsSafe.numberingProperties;
|
|
7655
|
+
if (styleProps.numberingProperties?.ilvl === inlineNumProps?.ilvl && styleProps.numberingProperties?.numId === inlineNumProps?.numId) {
|
|
7656
|
+
delete inlinePropsSafe.numberingProperties;
|
|
7576
7657
|
numberingDefinedInline = false;
|
|
7577
7658
|
}
|
|
7578
7659
|
}
|
|
7579
7660
|
}
|
|
7580
7661
|
}
|
|
7581
|
-
const tableProps = tableStyleId ? resolveStyleChain(params, tableStyleId,
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
defaultsChain = [defaultProps, normalProps];
|
|
7585
|
-
} else {
|
|
7586
|
-
defaultsChain = [normalProps, defaultProps];
|
|
7587
|
-
}
|
|
7588
|
-
const propsChain = [...defaultsChain, tableProps, numberingProps, styleProps, inlineProps];
|
|
7662
|
+
const tableProps = tableStyleId ? resolveStyleChain(params, tableStyleId, translators.pPr) : {};
|
|
7663
|
+
const defaultsChain = orderDefaultsAndNormal(defaultProps, normalProps, isNormalDefault);
|
|
7664
|
+
const propsChain = [...defaultsChain, tableProps, numberingProps, styleProps, inlinePropsSafe];
|
|
7589
7665
|
let indentChain;
|
|
7590
7666
|
if (isList2) {
|
|
7591
7667
|
if (numberingDefinedInline) {
|
|
7592
|
-
indentChain = [...defaultsChain, styleProps, numberingProps,
|
|
7668
|
+
indentChain = [...defaultsChain, styleProps, numberingProps, inlinePropsSafe];
|
|
7593
7669
|
} else {
|
|
7594
|
-
styleProps = resolveStyleChain(params, styleId,
|
|
7595
|
-
indentChain = [...defaultsChain, numberingProps, styleProps,
|
|
7670
|
+
styleProps = resolveStyleChain(params, styleId, translators.pPr, false);
|
|
7671
|
+
indentChain = [...defaultsChain, numberingProps, styleProps, inlinePropsSafe];
|
|
7596
7672
|
}
|
|
7597
7673
|
} else {
|
|
7598
|
-
indentChain = [...defaultsChain, numberingProps, styleProps,
|
|
7674
|
+
indentChain = [...defaultsChain, numberingProps, styleProps, inlinePropsSafe];
|
|
7599
7675
|
}
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
indentChain.map((props) => props.indent != null ? { indent: props.indent } : {}),
|
|
7603
|
-
[],
|
|
7604
|
-
{
|
|
7605
|
-
firstLine: (target, source) => {
|
|
7606
|
-
if (target.hanging != null && source.firstLine != null) {
|
|
7607
|
-
delete target.hanging;
|
|
7608
|
-
}
|
|
7609
|
-
return source.firstLine;
|
|
7610
|
-
}
|
|
7611
|
-
}
|
|
7612
|
-
);
|
|
7676
|
+
const finalProps = combineProperties$1(propsChain);
|
|
7677
|
+
const finalIndent = combineIndentProperties(indentChain);
|
|
7613
7678
|
finalProps.indent = finalIndent.indent;
|
|
7614
|
-
if (insideTable && !
|
|
7679
|
+
if (insideTable && !inlinePropsSafe?.spacing && !styleProps?.spacing) {
|
|
7615
7680
|
finalProps.spacing = void 0;
|
|
7616
7681
|
}
|
|
7617
7682
|
return finalProps;
|
|
7618
7683
|
}
|
|
7619
|
-
|
|
7620
|
-
let styleProps = {}
|
|
7684
|
+
function resolveStyleChain(params, styleId, translator2, followBasedOnChain = true) {
|
|
7685
|
+
let styleProps = {};
|
|
7686
|
+
let basedOn = void 0;
|
|
7621
7687
|
if (styleId && styleId !== "Normal") {
|
|
7622
7688
|
({ properties: styleProps, basedOn } = getStyleProperties(params, styleId, translator2));
|
|
7623
7689
|
}
|
|
@@ -7629,7 +7695,7 @@ const resolveStyleChain = (params, styleId, translator2, followBasedOnChain = tr
|
|
|
7629
7695
|
break;
|
|
7630
7696
|
}
|
|
7631
7697
|
seenStyles.add(basedOn);
|
|
7632
|
-
const result = getStyleProperties(params,
|
|
7698
|
+
const result = getStyleProperties(params, nextBasedOn, translator2);
|
|
7633
7699
|
const basedOnProps = result.properties;
|
|
7634
7700
|
nextBasedOn = result.basedOn;
|
|
7635
7701
|
if (basedOnProps && Object.keys(basedOnProps).length) {
|
|
@@ -7638,120 +7704,151 @@ const resolveStyleChain = (params, styleId, translator2, followBasedOnChain = tr
|
|
|
7638
7704
|
basedOn = nextBasedOn;
|
|
7639
7705
|
}
|
|
7640
7706
|
styleChain = styleChain.reverse();
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
};
|
|
7707
|
+
return combineProperties$1(styleChain);
|
|
7708
|
+
}
|
|
7644
7709
|
function getDefaultProperties(params, translator2) {
|
|
7645
|
-
const
|
|
7646
|
-
const styles = docx["word/styles.xml"];
|
|
7710
|
+
const docx = params?.docx;
|
|
7711
|
+
const styles = docx?.["word/styles.xml"];
|
|
7647
7712
|
const rootElements = styles?.elements?.[0]?.elements;
|
|
7648
7713
|
if (!rootElements?.length) {
|
|
7649
7714
|
return {};
|
|
7650
7715
|
}
|
|
7651
7716
|
const defaults = rootElements.find((el) => el.name === "w:docDefaults");
|
|
7652
7717
|
const xmlName = translator2.xmlName;
|
|
7653
|
-
const
|
|
7654
|
-
const
|
|
7718
|
+
const defaultsElements = defaults?.elements;
|
|
7719
|
+
const elementPrDefault = defaultsElements?.find((el) => el.name === `${xmlName}Default`);
|
|
7720
|
+
const elementPrDefaultElements = elementPrDefault?.elements;
|
|
7721
|
+
const elementPr = elementPrDefaultElements?.find((el) => el.name === xmlName);
|
|
7655
7722
|
if (!elementPr) {
|
|
7656
7723
|
return {};
|
|
7657
7724
|
}
|
|
7658
|
-
|
|
7659
|
-
return result;
|
|
7725
|
+
return translator2.encode({ ...params, nodes: [elementPr] }) || {};
|
|
7660
7726
|
}
|
|
7661
7727
|
function getStyleProperties(params, styleId, translator2) {
|
|
7662
|
-
const {
|
|
7663
|
-
const emptyResult = { properties: {}, isDefault: false, basedOn: null };
|
|
7728
|
+
const emptyResult = { properties: {}, isDefault: false, basedOn: void 0 };
|
|
7664
7729
|
if (!styleId) return emptyResult;
|
|
7665
|
-
const
|
|
7730
|
+
const docx = params?.docx;
|
|
7731
|
+
const styles = docx?.["word/styles.xml"];
|
|
7666
7732
|
const rootElements = styles?.elements?.[0]?.elements;
|
|
7667
7733
|
if (!rootElements?.length) {
|
|
7668
7734
|
return emptyResult;
|
|
7669
7735
|
}
|
|
7670
|
-
const style = rootElements.find(
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
const
|
|
7736
|
+
const style = rootElements.find(
|
|
7737
|
+
(el) => el.name === "w:style" && el.attributes?.["w:styleId"] === styleId
|
|
7738
|
+
);
|
|
7739
|
+
const styleElements = style?.elements;
|
|
7740
|
+
const basedOnElement = styleElements?.find((el) => el.name === "w:basedOn");
|
|
7741
|
+
const basedOn = basedOnElement?.attributes?.["w:val"];
|
|
7742
|
+
const elementPr = styleElements?.find((el) => el.name === translator2.xmlName);
|
|
7676
7743
|
if (!elementPr) {
|
|
7677
7744
|
return { ...emptyResult, basedOn };
|
|
7678
7745
|
}
|
|
7679
7746
|
const result = translator2.encode({ ...params, nodes: [elementPr] }) || {};
|
|
7680
|
-
|
|
7747
|
+
const isDefault = style?.attributes?.["w:default"] === "1";
|
|
7748
|
+
return { properties: result, isDefault, basedOn };
|
|
7681
7749
|
}
|
|
7682
|
-
function getNumberingProperties(params, ilvl, numId, translator2, tries = 0) {
|
|
7683
|
-
const
|
|
7684
|
-
if (!
|
|
7685
|
-
const { definitions, abstracts } =
|
|
7750
|
+
function getNumberingProperties(translators, params, ilvl, numId, translator2, tries = 0) {
|
|
7751
|
+
const numbering = params?.numbering;
|
|
7752
|
+
if (!numbering) return {};
|
|
7753
|
+
const { definitions, abstracts } = numbering;
|
|
7754
|
+
if (!definitions || !abstracts) return {};
|
|
7686
7755
|
const propertiesChain = [];
|
|
7687
7756
|
const numDefinition = definitions[numId];
|
|
7688
7757
|
if (!numDefinition) return {};
|
|
7689
|
-
const
|
|
7690
|
-
|
|
7758
|
+
const numDefElements = numDefinition.elements;
|
|
7759
|
+
const lvlOverride = numDefElements?.find(
|
|
7760
|
+
(element) => element.name === "w:lvlOverride" && element.attributes?.["w:ilvl"] == ilvl
|
|
7691
7761
|
);
|
|
7692
|
-
const
|
|
7762
|
+
const lvlOverrideElements = lvlOverride?.elements;
|
|
7763
|
+
const overridePr = lvlOverrideElements?.find((el) => el.name === translator2.xmlName);
|
|
7693
7764
|
if (overridePr) {
|
|
7694
7765
|
const overrideProps = translator2.encode({ ...params, nodes: [overridePr] }) || {};
|
|
7695
7766
|
propertiesChain.push(overrideProps);
|
|
7696
7767
|
}
|
|
7697
|
-
const
|
|
7768
|
+
const abstractNumIdElement = numDefElements?.find((item) => item.name === "w:abstractNumId");
|
|
7769
|
+
const abstractNumId = abstractNumIdElement?.attributes?.["w:val"];
|
|
7698
7770
|
const listDefinitionForThisNumId = abstracts[abstractNumId];
|
|
7699
7771
|
if (!listDefinitionForThisNumId) return {};
|
|
7700
|
-
const
|
|
7772
|
+
const listDefElements = listDefinitionForThisNumId.elements;
|
|
7773
|
+
const numStyleLink = listDefElements?.find((item) => item.name === "w:numStyleLink");
|
|
7701
7774
|
const styleId = numStyleLink?.attributes?.["w:val"];
|
|
7702
7775
|
if (styleId && tries < 1) {
|
|
7703
|
-
const { properties: styleProps } = getStyleProperties(params, styleId,
|
|
7704
|
-
|
|
7705
|
-
|
|
7776
|
+
const { properties: styleProps } = getStyleProperties(params, styleId, translators.pPr);
|
|
7777
|
+
const numIdFromStyle = styleProps?.numberingProperties?.numId;
|
|
7778
|
+
if (numIdFromStyle) {
|
|
7779
|
+
return getNumberingProperties(
|
|
7780
|
+
translators,
|
|
7781
|
+
params,
|
|
7782
|
+
ilvl,
|
|
7783
|
+
numIdFromStyle,
|
|
7784
|
+
translator2,
|
|
7785
|
+
tries + 1
|
|
7786
|
+
);
|
|
7706
7787
|
}
|
|
7707
7788
|
}
|
|
7708
|
-
const levelDefinition =
|
|
7709
|
-
(element) => element.name === "w:lvl" && element.attributes["w:ilvl"] == ilvl
|
|
7789
|
+
const levelDefinition = listDefElements?.find(
|
|
7790
|
+
(element) => element.name === "w:lvl" && element.attributes?.["w:ilvl"] == ilvl
|
|
7710
7791
|
);
|
|
7711
7792
|
if (!levelDefinition) return {};
|
|
7712
|
-
const
|
|
7793
|
+
const levelDefElements = levelDefinition.elements;
|
|
7794
|
+
const abstractElementPr = levelDefElements?.find((el) => el.name === translator2.xmlName);
|
|
7713
7795
|
if (!abstractElementPr) return {};
|
|
7714
7796
|
const abstractProps = translator2.encode({ ...params, nodes: [abstractElementPr] }) || {};
|
|
7715
|
-
const pStyleElement =
|
|
7797
|
+
const pStyleElement = levelDefElements?.find((el) => el.name === "w:pStyle");
|
|
7716
7798
|
if (pStyleElement) {
|
|
7717
|
-
const pStyleId = pStyleElement
|
|
7799
|
+
const pStyleId = pStyleElement.attributes?.["w:val"];
|
|
7718
7800
|
abstractProps.styleId = pStyleId;
|
|
7719
7801
|
}
|
|
7720
7802
|
propertiesChain.push(abstractProps);
|
|
7721
7803
|
propertiesChain.reverse();
|
|
7722
|
-
|
|
7723
|
-
return result;
|
|
7804
|
+
return combineProperties$1(propertiesChain);
|
|
7724
7805
|
}
|
|
7725
|
-
|
|
7726
|
-
if (!
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
const
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
output[key] = source[key];
|
|
7747
|
-
}
|
|
7748
|
-
}
|
|
7749
|
-
}
|
|
7750
|
-
}
|
|
7806
|
+
function resolveDocxFontFamily(attributes, docx, toCssFontFamily) {
|
|
7807
|
+
if (!attributes || typeof attributes !== "object") return null;
|
|
7808
|
+
const ascii = attributes["w:ascii"] ?? attributes["ascii"];
|
|
7809
|
+
const themeAscii = attributes["w:asciiTheme"] ?? attributes["asciiTheme"];
|
|
7810
|
+
let resolved = ascii;
|
|
7811
|
+
if (docx && themeAscii) {
|
|
7812
|
+
const theme = docx["word/theme/theme1.xml"];
|
|
7813
|
+
const themeElements = theme?.elements;
|
|
7814
|
+
if (themeElements?.length) {
|
|
7815
|
+
const topElement = themeElements[0];
|
|
7816
|
+
const topElementElements = topElement?.elements;
|
|
7817
|
+
const themeElementsNode = topElementElements?.find((el) => el.name === "a:themeElements");
|
|
7818
|
+
const themeElementsElements = themeElementsNode?.elements;
|
|
7819
|
+
const fontScheme = themeElementsElements?.find((el) => el.name === "a:fontScheme");
|
|
7820
|
+
const fontSchemeElements = fontScheme?.elements;
|
|
7821
|
+
const prefix = themeAscii.startsWith("minor") ? "minor" : "major";
|
|
7822
|
+
const font = fontSchemeElements?.find((el) => el.name === `a:${prefix}Font`);
|
|
7823
|
+
const fontElements = font?.elements;
|
|
7824
|
+
const latin = fontElements?.find((el) => el.name === "a:latin");
|
|
7825
|
+
const typeface = latin?.attributes?.typeface;
|
|
7826
|
+
resolved = typeface || resolved;
|
|
7751
7827
|
}
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7828
|
+
}
|
|
7829
|
+
if (!resolved) return null;
|
|
7830
|
+
if (toCssFontFamily) {
|
|
7831
|
+
return toCssFontFamily(resolved, docx ?? void 0);
|
|
7832
|
+
}
|
|
7833
|
+
return resolved;
|
|
7834
|
+
}
|
|
7835
|
+
const ooxmlResolver = createOoxmlResolver({ pPr: translator$14, rPr: translator$1O });
|
|
7836
|
+
const getToCssFontFamily = () => {
|
|
7837
|
+
return SuperConverter.toCssFontFamily;
|
|
7838
|
+
};
|
|
7839
|
+
const SUBSCRIPT_SUPERSCRIPT_SCALE = 0.65;
|
|
7840
|
+
const resolveRunProperties = (params, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) => ooxmlResolver.resolveRunProperties(params, inlineRpr, resolvedPpr, isListNumber, numberingDefinedInline);
|
|
7841
|
+
function resolveParagraphProperties(params, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
7842
|
+
return ooxmlResolver.resolveParagraphProperties(
|
|
7843
|
+
params,
|
|
7844
|
+
inlineProps,
|
|
7845
|
+
insideTable,
|
|
7846
|
+
overrideInlineStyleId,
|
|
7847
|
+
tableStyleId
|
|
7848
|
+
);
|
|
7849
|
+
}
|
|
7850
|
+
const combineProperties = (propertiesArray, fullOverrideProps = [], specialHandling = {}) => {
|
|
7851
|
+
return combineProperties$1(propertiesArray, { fullOverrideProps, specialHandling });
|
|
7755
7852
|
};
|
|
7756
7853
|
const combineRunProperties = (propertiesArray) => {
|
|
7757
7854
|
return combineProperties(propertiesArray, ["fontFamily", "color"]);
|
|
@@ -7810,9 +7907,9 @@ function encodeMarksFromRPr(runProperties, docx) {
|
|
|
7810
7907
|
textStyleAttrs[key] = `${spacing}pt`;
|
|
7811
7908
|
break;
|
|
7812
7909
|
case "fontFamily":
|
|
7813
|
-
const fontFamily =
|
|
7910
|
+
const fontFamily = resolveDocxFontFamily(value, docx, getToCssFontFamily());
|
|
7814
7911
|
textStyleAttrs[key] = fontFamily;
|
|
7815
|
-
const eastAsiaFamily = value["eastAsia"];
|
|
7912
|
+
const eastAsiaFamily = typeof value === "object" && value !== null ? value["eastAsia"] : void 0;
|
|
7816
7913
|
if (eastAsiaFamily) {
|
|
7817
7914
|
const eastAsiaCss = getFontFamilyValue$1({ "w:ascii": eastAsiaFamily }, docx);
|
|
7818
7915
|
if (!fontFamily || eastAsiaCss !== textStyleAttrs.fontFamily) {
|
|
@@ -8067,11 +8164,11 @@ function encodeCSSFromRPr(runProperties, docx) {
|
|
|
8067
8164
|
}
|
|
8068
8165
|
case "fontFamily": {
|
|
8069
8166
|
if (!value) break;
|
|
8070
|
-
const fontFamily =
|
|
8167
|
+
const fontFamily = resolveDocxFontFamily(value, docx, getToCssFontFamily());
|
|
8071
8168
|
if (fontFamily) {
|
|
8072
8169
|
css["font-family"] = fontFamily;
|
|
8073
8170
|
}
|
|
8074
|
-
const eastAsiaFamily = value["eastAsia"];
|
|
8171
|
+
const eastAsiaFamily = typeof value === "object" && value !== null ? value["eastAsia"] : void 0;
|
|
8075
8172
|
if (eastAsiaFamily) {
|
|
8076
8173
|
const eastAsiaCss = getFontFamilyValue$1({ "w:ascii": eastAsiaFamily }, docx);
|
|
8077
8174
|
if (eastAsiaCss && (!fontFamily || eastAsiaCss !== fontFamily)) {
|
|
@@ -27295,7 +27392,8 @@ const encode$1 = (params, encodedAttrs = {}) => {
|
|
|
27295
27392
|
text = text.replace(/^[ \t\n\r]+/, "").replace(/[ \t\n\r]+$/, "");
|
|
27296
27393
|
}
|
|
27297
27394
|
text = text.replace(/\[\[sdspace\]\]/g, "");
|
|
27298
|
-
|
|
27395
|
+
const isWhitespaceOnly = /^[ \t\n\r]*$/.test(text);
|
|
27396
|
+
if (xmlSpace !== "preserve" && isWhitespaceOnly) {
|
|
27299
27397
|
return null;
|
|
27300
27398
|
}
|
|
27301
27399
|
} else if (!elements.length && encodedAttrs.xmlSpace === "preserve") {
|
|
@@ -30840,7 +30938,7 @@ class SuperConverter {
|
|
|
30840
30938
|
static getStoredSuperdocVersion(docx) {
|
|
30841
30939
|
return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
30842
30940
|
}
|
|
30843
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.
|
|
30941
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.3") {
|
|
30844
30942
|
return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
|
|
30845
30943
|
}
|
|
30846
30944
|
/**
|
|
@@ -31521,11 +31619,13 @@ exports.changeListLevel = changeListLevel;
|
|
|
31521
31619
|
exports.convertMarkdownToHTML = convertMarkdownToHTML;
|
|
31522
31620
|
exports.createDocFromHTML = createDocFromHTML;
|
|
31523
31621
|
exports.createDocFromMarkdown = createDocFromMarkdown;
|
|
31622
|
+
exports.createOoxmlResolver = createOoxmlResolver;
|
|
31524
31623
|
exports.decodeRPrFromMarks = decodeRPrFromMarks;
|
|
31525
31624
|
exports.docxNumberingHelpers = docxNumberingHelpers;
|
|
31526
31625
|
exports.dropPoint = dropPoint;
|
|
31527
31626
|
exports.encodeCSSFromPPr = encodeCSSFromPPr;
|
|
31528
31627
|
exports.encodeCSSFromRPr = encodeCSSFromRPr;
|
|
31628
|
+
exports.encodeMarksFromRPr = encodeMarksFromRPr;
|
|
31529
31629
|
exports.findParentNode = findParentNode;
|
|
31530
31630
|
exports.findParentNodeClosestToPos = findParentNodeClosestToPos;
|
|
31531
31631
|
exports.generateDocxRandomId = generateDocxRandomId;
|
|
@@ -31544,8 +31644,10 @@ exports.liftTarget = liftTarget;
|
|
|
31544
31644
|
exports.objectIncludes = objectIncludes;
|
|
31545
31645
|
exports.registeredHandlers = registeredHandlers;
|
|
31546
31646
|
exports.replaceStep = replaceStep;
|
|
31547
|
-
exports.
|
|
31647
|
+
exports.resolveDocxFontFamily = resolveDocxFontFamily;
|
|
31548
31648
|
exports.resolveRunProperties = resolveRunProperties;
|
|
31649
|
+
exports.translator = translator$14;
|
|
31650
|
+
exports.translator$1 = translator$1O;
|
|
31549
31651
|
exports.unflattenListsInHtml = unflattenListsInHtml;
|
|
31550
31652
|
exports.updateNumberingProperties = updateNumberingProperties;
|
|
31551
31653
|
exports.wrapTextsInRuns = wrapTextsInRuns;
|