@harbour-enterprises/superdoc 1.3.0-next.1 → 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-BAoRLNIo.cjs → PdfViewer-D6XxSIuw.cjs} +2 -2
- package/dist/chunks/{PdfViewer-CkOzQzPk.es.js → PdfViewer-ltwzoe73.es.js} +2 -2
- package/dist/chunks/{SuperConverter-BXP6NikG.es.js → SuperConverter-CVOKZex3.es.js} +294 -192
- package/dist/chunks/{SuperConverter-Dy0-KTCc.cjs → SuperConverter-XGlv5pME.cjs} +261 -159
- package/dist/chunks/{index-BNpbdx2a.cjs → index-D0lYfjMI.cjs} +853 -525
- package/dist/chunks/{index-BbvMtiJY.cjs → index-HQW67fDU.cjs} +4 -4
- package/dist/chunks/{index-wwGlJ58Z.es.js → index-M8MvGhiF.es.js} +853 -525
- package/dist/chunks/{index-C31VY_46.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 +1117 -691
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +2 -2
|
@@ -7489,134 +7489,200 @@ const INLINE_OVERRIDE_PROPERTIES = [
|
|
|
7489
7489
|
"italic",
|
|
7490
7490
|
"strike",
|
|
7491
7491
|
"underline",
|
|
7492
|
-
"letterSpacing"
|
|
7493
|
-
"vertAlign",
|
|
7494
|
-
"position"
|
|
7492
|
+
"letterSpacing"
|
|
7495
7493
|
];
|
|
7496
7494
|
const DEFAULT_FONT_SIZE_HALF_POINTS = 20;
|
|
7497
|
-
|
|
7498
|
-
|
|
7495
|
+
function isObject(item) {
|
|
7496
|
+
return item != null && typeof item === "object" && !Array.isArray(item);
|
|
7497
|
+
}
|
|
7498
|
+
function combineProperties$1(propertiesArray, options = {}) {
|
|
7499
|
+
const { fullOverrideProps = [], specialHandling = {} } = options;
|
|
7500
|
+
if (!propertiesArray || propertiesArray.length === 0) {
|
|
7501
|
+
return {};
|
|
7502
|
+
}
|
|
7503
|
+
const merge = (target, source) => {
|
|
7504
|
+
const output = { ...target };
|
|
7505
|
+
if (isObject(target) && isObject(source)) {
|
|
7506
|
+
for (const key in source) {
|
|
7507
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7508
|
+
const handler2 = specialHandling[key];
|
|
7509
|
+
if (handler2 && typeof handler2 === "function") {
|
|
7510
|
+
output[key] = handler2(output, source);
|
|
7511
|
+
} else if (!fullOverrideProps.includes(key) && isObject(source[key])) {
|
|
7512
|
+
if (key in target && isObject(target[key])) {
|
|
7513
|
+
output[key] = merge(target[key], source[key]);
|
|
7514
|
+
} else {
|
|
7515
|
+
output[key] = source[key];
|
|
7516
|
+
}
|
|
7517
|
+
} else {
|
|
7518
|
+
output[key] = source[key];
|
|
7519
|
+
}
|
|
7520
|
+
}
|
|
7521
|
+
}
|
|
7522
|
+
}
|
|
7523
|
+
return output;
|
|
7524
|
+
};
|
|
7525
|
+
return propertiesArray.reduce((acc, current) => merge(acc, current ?? {}), {});
|
|
7526
|
+
}
|
|
7527
|
+
function combineRunProperties$1(propertiesArray) {
|
|
7528
|
+
return combineProperties$1(propertiesArray, {
|
|
7529
|
+
fullOverrideProps: ["fontFamily", "color"]
|
|
7530
|
+
});
|
|
7531
|
+
}
|
|
7532
|
+
function applyInlineOverrides(finalProps, inlineProps, overrideKeys = INLINE_OVERRIDE_PROPERTIES) {
|
|
7533
|
+
if (!inlineProps) return finalProps;
|
|
7534
|
+
for (const prop of overrideKeys) {
|
|
7535
|
+
if (inlineProps[prop] != null) {
|
|
7536
|
+
finalProps[prop] = inlineProps[prop];
|
|
7537
|
+
}
|
|
7538
|
+
}
|
|
7539
|
+
return finalProps;
|
|
7540
|
+
}
|
|
7541
|
+
function isValidFontSize(value) {
|
|
7542
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
7543
|
+
}
|
|
7544
|
+
function resolveFontSizeWithFallback(value, defaultProps, normalProps) {
|
|
7545
|
+
if (isValidFontSize(value)) {
|
|
7546
|
+
return value;
|
|
7547
|
+
}
|
|
7548
|
+
if (defaultProps && isValidFontSize(defaultProps.fontSize)) {
|
|
7549
|
+
return defaultProps.fontSize;
|
|
7550
|
+
}
|
|
7551
|
+
if (normalProps && isValidFontSize(normalProps.fontSize)) {
|
|
7552
|
+
return normalProps.fontSize;
|
|
7553
|
+
}
|
|
7554
|
+
return DEFAULT_FONT_SIZE_HALF_POINTS;
|
|
7555
|
+
}
|
|
7556
|
+
function orderDefaultsAndNormal(defaultProps, normalProps, isNormalDefault) {
|
|
7557
|
+
if (isNormalDefault) {
|
|
7558
|
+
return [defaultProps, normalProps];
|
|
7559
|
+
} else {
|
|
7560
|
+
return [normalProps, defaultProps];
|
|
7561
|
+
}
|
|
7562
|
+
}
|
|
7563
|
+
function createFirstLineIndentHandler() {
|
|
7564
|
+
return (target, source) => {
|
|
7565
|
+
if (target.hanging != null && source.firstLine != null) {
|
|
7566
|
+
delete target.hanging;
|
|
7567
|
+
}
|
|
7568
|
+
return source.firstLine;
|
|
7569
|
+
};
|
|
7570
|
+
}
|
|
7571
|
+
function combineIndentProperties(indentChain) {
|
|
7572
|
+
const indentOnly = indentChain.map((props) => props.indent != null ? { indent: props.indent } : {});
|
|
7573
|
+
return combineProperties$1(indentOnly, {
|
|
7574
|
+
specialHandling: {
|
|
7575
|
+
firstLine: createFirstLineIndentHandler()
|
|
7576
|
+
}
|
|
7577
|
+
});
|
|
7578
|
+
}
|
|
7579
|
+
function createOoxmlResolver(translators) {
|
|
7580
|
+
return {
|
|
7581
|
+
resolveRunProperties: (params, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) => resolveRunProperties$1(translators, params, inlineRpr, resolvedPpr, isListNumber, numberingDefinedInline),
|
|
7582
|
+
resolveParagraphProperties: (params, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) => resolveParagraphProperties$1(translators, params, inlineProps, insideTable, overrideInlineStyleId, tableStyleId),
|
|
7583
|
+
getDefaultProperties,
|
|
7584
|
+
getStyleProperties,
|
|
7585
|
+
resolveStyleChain,
|
|
7586
|
+
getNumberingProperties: (params, ilvl, numId, translator2, tries = 0) => getNumberingProperties(translators, params, ilvl, numId, translator2, tries)
|
|
7587
|
+
};
|
|
7588
|
+
}
|
|
7589
|
+
function resolveRunProperties$1(translators, params, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) {
|
|
7499
7590
|
const paragraphStyleId = resolvedPpr?.styleId;
|
|
7500
|
-
const paragraphStyleProps = resolveStyleChain(params, paragraphStyleId,
|
|
7501
|
-
const defaultProps = getDefaultProperties(params,
|
|
7502
|
-
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params, "Normal",
|
|
7591
|
+
const paragraphStyleProps = resolveStyleChain(params, paragraphStyleId, translators.rPr);
|
|
7592
|
+
const defaultProps = getDefaultProperties(params, translators.rPr);
|
|
7593
|
+
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params, "Normal", translators.rPr);
|
|
7503
7594
|
let runStyleProps = {};
|
|
7504
7595
|
if (!paragraphStyleId?.startsWith("TOC")) {
|
|
7505
|
-
runStyleProps = inlineRpr
|
|
7596
|
+
runStyleProps = inlineRpr?.styleId ? resolveStyleChain(params, inlineRpr.styleId, translators.rPr) : {};
|
|
7506
7597
|
}
|
|
7598
|
+
const defaultsChain = orderDefaultsAndNormal(defaultProps, normalProps, isNormalDefault);
|
|
7599
|
+
const inlineRprSafe = inlineRpr ?? {};
|
|
7507
7600
|
let styleChain;
|
|
7508
|
-
|
|
7509
|
-
styleChain = [defaultProps, normalProps];
|
|
7510
|
-
} else {
|
|
7511
|
-
styleChain = [normalProps, defaultProps];
|
|
7512
|
-
}
|
|
7601
|
+
let inlineOverrideSource = inlineRprSafe;
|
|
7513
7602
|
if (isListNumber) {
|
|
7514
7603
|
let numberingProps = {};
|
|
7515
|
-
const
|
|
7604
|
+
const numberingProperties = resolvedPpr?.numberingProperties;
|
|
7605
|
+
const numId = numberingProperties?.numId;
|
|
7516
7606
|
if (numId != null && numId !== 0 && numId !== "0") {
|
|
7517
7607
|
numberingProps = getNumberingProperties(
|
|
7608
|
+
translators,
|
|
7518
7609
|
params,
|
|
7519
|
-
|
|
7610
|
+
numberingProperties?.ilvl ?? 0,
|
|
7520
7611
|
numId,
|
|
7521
|
-
|
|
7612
|
+
translators.rPr
|
|
7522
7613
|
);
|
|
7523
7614
|
}
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
if (inlineRpr?.underline) {
|
|
7528
|
-
delete inlineRpr.underline;
|
|
7615
|
+
const inlineRprForList = numberingDefinedInline ? inlineRprSafe : {};
|
|
7616
|
+
if (inlineRprForList?.underline) {
|
|
7617
|
+
delete inlineRprForList.underline;
|
|
7529
7618
|
}
|
|
7530
|
-
styleChain = [...
|
|
7619
|
+
styleChain = [...defaultsChain, paragraphStyleProps, runStyleProps, inlineRprForList, numberingProps];
|
|
7620
|
+
inlineOverrideSource = inlineRprForList;
|
|
7531
7621
|
} else {
|
|
7532
|
-
styleChain = [...
|
|
7533
|
-
}
|
|
7534
|
-
const finalProps = combineProperties(styleChain, ["fontFamily", "color"]);
|
|
7535
|
-
for (const prop of INLINE_OVERRIDE_PROPERTIES) {
|
|
7536
|
-
if (inlineRpr?.[prop] != null) {
|
|
7537
|
-
finalProps[prop] = inlineRpr[prop];
|
|
7538
|
-
}
|
|
7539
|
-
}
|
|
7540
|
-
if (finalProps.fontSize == null || typeof finalProps.fontSize !== "number" || !Number.isFinite(finalProps.fontSize) || finalProps.fontSize <= 0) {
|
|
7541
|
-
let defaultFontSize = DEFAULT_FONT_SIZE_HALF_POINTS;
|
|
7542
|
-
if (defaultProps?.fontSize != null && typeof defaultProps.fontSize === "number" && Number.isFinite(defaultProps.fontSize) && defaultProps.fontSize > 0) {
|
|
7543
|
-
defaultFontSize = defaultProps.fontSize;
|
|
7544
|
-
} else if (normalProps?.fontSize != null && typeof normalProps.fontSize === "number" && Number.isFinite(normalProps.fontSize) && normalProps.fontSize > 0) {
|
|
7545
|
-
defaultFontSize = normalProps.fontSize;
|
|
7546
|
-
}
|
|
7547
|
-
finalProps.fontSize = defaultFontSize;
|
|
7622
|
+
styleChain = [...defaultsChain, paragraphStyleProps, runStyleProps, inlineRprSafe];
|
|
7548
7623
|
}
|
|
7624
|
+
const finalProps = combineRunProperties$1(styleChain);
|
|
7625
|
+
applyInlineOverrides(finalProps, inlineOverrideSource);
|
|
7626
|
+
finalProps.fontSize = resolveFontSizeWithFallback(finalProps.fontSize, defaultProps, normalProps);
|
|
7549
7627
|
return finalProps;
|
|
7550
|
-
}
|
|
7551
|
-
function resolveParagraphProperties(params, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
7552
|
-
const defaultProps = getDefaultProperties(params,
|
|
7553
|
-
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params, "Normal",
|
|
7554
|
-
|
|
7555
|
-
let
|
|
7628
|
+
}
|
|
7629
|
+
function resolveParagraphProperties$1(translators, params, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
7630
|
+
const defaultProps = getDefaultProperties(params, translators.pPr);
|
|
7631
|
+
const { properties: normalProps, isDefault: isNormalDefault } = getStyleProperties(params, "Normal", translators.pPr);
|
|
7632
|
+
const inlinePropsSafe = inlineProps ?? {};
|
|
7633
|
+
let styleId = inlinePropsSafe?.styleId;
|
|
7634
|
+
let styleProps = inlinePropsSafe?.styleId ? resolveStyleChain(params, inlinePropsSafe.styleId, translators.pPr) : {};
|
|
7556
7635
|
let numberingProps = {};
|
|
7557
|
-
|
|
7558
|
-
let numId =
|
|
7559
|
-
let numberingDefinedInline =
|
|
7560
|
-
const
|
|
7636
|
+
const ilvl = inlinePropsSafe?.numberingProperties?.ilvl ?? styleProps?.numberingProperties?.ilvl;
|
|
7637
|
+
let numId = inlinePropsSafe?.numberingProperties?.numId ?? styleProps?.numberingProperties?.numId;
|
|
7638
|
+
let numberingDefinedInline = inlinePropsSafe?.numberingProperties?.numId != null;
|
|
7639
|
+
const inlineNumId = inlinePropsSafe?.numberingProperties?.numId;
|
|
7640
|
+
const inlineNumIdDisablesNumbering = inlineNumId === 0 || inlineNumId === "0";
|
|
7561
7641
|
if (inlineNumIdDisablesNumbering) {
|
|
7562
7642
|
numId = null;
|
|
7563
7643
|
}
|
|
7564
7644
|
const isList2 = numId != null && numId !== 0 && numId !== "0";
|
|
7565
7645
|
if (isList2) {
|
|
7566
|
-
|
|
7567
|
-
numberingProps = getNumberingProperties(params,
|
|
7646
|
+
const ilvlNum = ilvl != null ? ilvl : 0;
|
|
7647
|
+
numberingProps = getNumberingProperties(translators, params, ilvlNum, numId, translators.pPr);
|
|
7568
7648
|
if (overrideInlineStyleId && numberingProps.styleId) {
|
|
7569
7649
|
styleId = numberingProps.styleId;
|
|
7570
|
-
styleProps = resolveStyleChain(params, styleId,
|
|
7571
|
-
if (
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7650
|
+
styleProps = resolveStyleChain(params, styleId, translators.pPr);
|
|
7651
|
+
if (inlinePropsSafe) {
|
|
7652
|
+
inlinePropsSafe.styleId = styleId;
|
|
7653
|
+
const inlineNumProps = inlinePropsSafe.numberingProperties;
|
|
7654
|
+
if (styleProps.numberingProperties?.ilvl === inlineNumProps?.ilvl && styleProps.numberingProperties?.numId === inlineNumProps?.numId) {
|
|
7655
|
+
delete inlinePropsSafe.numberingProperties;
|
|
7575
7656
|
numberingDefinedInline = false;
|
|
7576
7657
|
}
|
|
7577
7658
|
}
|
|
7578
7659
|
}
|
|
7579
7660
|
}
|
|
7580
|
-
const tableProps = tableStyleId ? resolveStyleChain(params, tableStyleId,
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
defaultsChain = [defaultProps, normalProps];
|
|
7584
|
-
} else {
|
|
7585
|
-
defaultsChain = [normalProps, defaultProps];
|
|
7586
|
-
}
|
|
7587
|
-
const propsChain = [...defaultsChain, tableProps, numberingProps, styleProps, inlineProps];
|
|
7661
|
+
const tableProps = tableStyleId ? resolveStyleChain(params, tableStyleId, translators.pPr) : {};
|
|
7662
|
+
const defaultsChain = orderDefaultsAndNormal(defaultProps, normalProps, isNormalDefault);
|
|
7663
|
+
const propsChain = [...defaultsChain, tableProps, numberingProps, styleProps, inlinePropsSafe];
|
|
7588
7664
|
let indentChain;
|
|
7589
7665
|
if (isList2) {
|
|
7590
7666
|
if (numberingDefinedInline) {
|
|
7591
|
-
indentChain = [...defaultsChain, styleProps, numberingProps,
|
|
7667
|
+
indentChain = [...defaultsChain, styleProps, numberingProps, inlinePropsSafe];
|
|
7592
7668
|
} else {
|
|
7593
|
-
styleProps = resolveStyleChain(params, styleId,
|
|
7594
|
-
indentChain = [...defaultsChain, numberingProps, styleProps,
|
|
7669
|
+
styleProps = resolveStyleChain(params, styleId, translators.pPr, false);
|
|
7670
|
+
indentChain = [...defaultsChain, numberingProps, styleProps, inlinePropsSafe];
|
|
7595
7671
|
}
|
|
7596
7672
|
} else {
|
|
7597
|
-
indentChain = [...defaultsChain, numberingProps, styleProps,
|
|
7673
|
+
indentChain = [...defaultsChain, numberingProps, styleProps, inlinePropsSafe];
|
|
7598
7674
|
}
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
indentChain.map((props) => props.indent != null ? { indent: props.indent } : {}),
|
|
7602
|
-
[],
|
|
7603
|
-
{
|
|
7604
|
-
firstLine: (target, source) => {
|
|
7605
|
-
if (target.hanging != null && source.firstLine != null) {
|
|
7606
|
-
delete target.hanging;
|
|
7607
|
-
}
|
|
7608
|
-
return source.firstLine;
|
|
7609
|
-
}
|
|
7610
|
-
}
|
|
7611
|
-
);
|
|
7675
|
+
const finalProps = combineProperties$1(propsChain);
|
|
7676
|
+
const finalIndent = combineIndentProperties(indentChain);
|
|
7612
7677
|
finalProps.indent = finalIndent.indent;
|
|
7613
|
-
if (insideTable && !
|
|
7678
|
+
if (insideTable && !inlinePropsSafe?.spacing && !styleProps?.spacing) {
|
|
7614
7679
|
finalProps.spacing = void 0;
|
|
7615
7680
|
}
|
|
7616
7681
|
return finalProps;
|
|
7617
7682
|
}
|
|
7618
|
-
|
|
7619
|
-
let styleProps = {}
|
|
7683
|
+
function resolveStyleChain(params, styleId, translator2, followBasedOnChain = true) {
|
|
7684
|
+
let styleProps = {};
|
|
7685
|
+
let basedOn = void 0;
|
|
7620
7686
|
if (styleId && styleId !== "Normal") {
|
|
7621
7687
|
({ properties: styleProps, basedOn } = getStyleProperties(params, styleId, translator2));
|
|
7622
7688
|
}
|
|
@@ -7628,7 +7694,7 @@ const resolveStyleChain = (params, styleId, translator2, followBasedOnChain = tr
|
|
|
7628
7694
|
break;
|
|
7629
7695
|
}
|
|
7630
7696
|
seenStyles.add(basedOn);
|
|
7631
|
-
const result = getStyleProperties(params,
|
|
7697
|
+
const result = getStyleProperties(params, nextBasedOn, translator2);
|
|
7632
7698
|
const basedOnProps = result.properties;
|
|
7633
7699
|
nextBasedOn = result.basedOn;
|
|
7634
7700
|
if (basedOnProps && Object.keys(basedOnProps).length) {
|
|
@@ -7637,120 +7703,151 @@ const resolveStyleChain = (params, styleId, translator2, followBasedOnChain = tr
|
|
|
7637
7703
|
basedOn = nextBasedOn;
|
|
7638
7704
|
}
|
|
7639
7705
|
styleChain = styleChain.reverse();
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
};
|
|
7706
|
+
return combineProperties$1(styleChain);
|
|
7707
|
+
}
|
|
7643
7708
|
function getDefaultProperties(params, translator2) {
|
|
7644
|
-
const
|
|
7645
|
-
const styles = docx["word/styles.xml"];
|
|
7709
|
+
const docx = params?.docx;
|
|
7710
|
+
const styles = docx?.["word/styles.xml"];
|
|
7646
7711
|
const rootElements = styles?.elements?.[0]?.elements;
|
|
7647
7712
|
if (!rootElements?.length) {
|
|
7648
7713
|
return {};
|
|
7649
7714
|
}
|
|
7650
7715
|
const defaults = rootElements.find((el) => el.name === "w:docDefaults");
|
|
7651
7716
|
const xmlName = translator2.xmlName;
|
|
7652
|
-
const
|
|
7653
|
-
const
|
|
7717
|
+
const defaultsElements = defaults?.elements;
|
|
7718
|
+
const elementPrDefault = defaultsElements?.find((el) => el.name === `${xmlName}Default`);
|
|
7719
|
+
const elementPrDefaultElements = elementPrDefault?.elements;
|
|
7720
|
+
const elementPr = elementPrDefaultElements?.find((el) => el.name === xmlName);
|
|
7654
7721
|
if (!elementPr) {
|
|
7655
7722
|
return {};
|
|
7656
7723
|
}
|
|
7657
|
-
|
|
7658
|
-
return result;
|
|
7724
|
+
return translator2.encode({ ...params, nodes: [elementPr] }) || {};
|
|
7659
7725
|
}
|
|
7660
7726
|
function getStyleProperties(params, styleId, translator2) {
|
|
7661
|
-
const {
|
|
7662
|
-
const emptyResult = { properties: {}, isDefault: false, basedOn: null };
|
|
7727
|
+
const emptyResult = { properties: {}, isDefault: false, basedOn: void 0 };
|
|
7663
7728
|
if (!styleId) return emptyResult;
|
|
7664
|
-
const
|
|
7729
|
+
const docx = params?.docx;
|
|
7730
|
+
const styles = docx?.["word/styles.xml"];
|
|
7665
7731
|
const rootElements = styles?.elements?.[0]?.elements;
|
|
7666
7732
|
if (!rootElements?.length) {
|
|
7667
7733
|
return emptyResult;
|
|
7668
7734
|
}
|
|
7669
|
-
const style = rootElements.find(
|
|
7670
|
-
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
const
|
|
7735
|
+
const style = rootElements.find(
|
|
7736
|
+
(el) => el.name === "w:style" && el.attributes?.["w:styleId"] === styleId
|
|
7737
|
+
);
|
|
7738
|
+
const styleElements = style?.elements;
|
|
7739
|
+
const basedOnElement = styleElements?.find((el) => el.name === "w:basedOn");
|
|
7740
|
+
const basedOn = basedOnElement?.attributes?.["w:val"];
|
|
7741
|
+
const elementPr = styleElements?.find((el) => el.name === translator2.xmlName);
|
|
7675
7742
|
if (!elementPr) {
|
|
7676
7743
|
return { ...emptyResult, basedOn };
|
|
7677
7744
|
}
|
|
7678
7745
|
const result = translator2.encode({ ...params, nodes: [elementPr] }) || {};
|
|
7679
|
-
|
|
7746
|
+
const isDefault = style?.attributes?.["w:default"] === "1";
|
|
7747
|
+
return { properties: result, isDefault, basedOn };
|
|
7680
7748
|
}
|
|
7681
|
-
function getNumberingProperties(params, ilvl, numId, translator2, tries = 0) {
|
|
7682
|
-
const
|
|
7683
|
-
if (!
|
|
7684
|
-
const { definitions, abstracts } =
|
|
7749
|
+
function getNumberingProperties(translators, params, ilvl, numId, translator2, tries = 0) {
|
|
7750
|
+
const numbering = params?.numbering;
|
|
7751
|
+
if (!numbering) return {};
|
|
7752
|
+
const { definitions, abstracts } = numbering;
|
|
7753
|
+
if (!definitions || !abstracts) return {};
|
|
7685
7754
|
const propertiesChain = [];
|
|
7686
7755
|
const numDefinition = definitions[numId];
|
|
7687
7756
|
if (!numDefinition) return {};
|
|
7688
|
-
const
|
|
7689
|
-
|
|
7757
|
+
const numDefElements = numDefinition.elements;
|
|
7758
|
+
const lvlOverride = numDefElements?.find(
|
|
7759
|
+
(element) => element.name === "w:lvlOverride" && element.attributes?.["w:ilvl"] == ilvl
|
|
7690
7760
|
);
|
|
7691
|
-
const
|
|
7761
|
+
const lvlOverrideElements = lvlOverride?.elements;
|
|
7762
|
+
const overridePr = lvlOverrideElements?.find((el) => el.name === translator2.xmlName);
|
|
7692
7763
|
if (overridePr) {
|
|
7693
7764
|
const overrideProps = translator2.encode({ ...params, nodes: [overridePr] }) || {};
|
|
7694
7765
|
propertiesChain.push(overrideProps);
|
|
7695
7766
|
}
|
|
7696
|
-
const
|
|
7767
|
+
const abstractNumIdElement = numDefElements?.find((item) => item.name === "w:abstractNumId");
|
|
7768
|
+
const abstractNumId = abstractNumIdElement?.attributes?.["w:val"];
|
|
7697
7769
|
const listDefinitionForThisNumId = abstracts[abstractNumId];
|
|
7698
7770
|
if (!listDefinitionForThisNumId) return {};
|
|
7699
|
-
const
|
|
7771
|
+
const listDefElements = listDefinitionForThisNumId.elements;
|
|
7772
|
+
const numStyleLink = listDefElements?.find((item) => item.name === "w:numStyleLink");
|
|
7700
7773
|
const styleId = numStyleLink?.attributes?.["w:val"];
|
|
7701
7774
|
if (styleId && tries < 1) {
|
|
7702
|
-
const { properties: styleProps } = getStyleProperties(params, styleId,
|
|
7703
|
-
|
|
7704
|
-
|
|
7775
|
+
const { properties: styleProps } = getStyleProperties(params, styleId, translators.pPr);
|
|
7776
|
+
const numIdFromStyle = styleProps?.numberingProperties?.numId;
|
|
7777
|
+
if (numIdFromStyle) {
|
|
7778
|
+
return getNumberingProperties(
|
|
7779
|
+
translators,
|
|
7780
|
+
params,
|
|
7781
|
+
ilvl,
|
|
7782
|
+
numIdFromStyle,
|
|
7783
|
+
translator2,
|
|
7784
|
+
tries + 1
|
|
7785
|
+
);
|
|
7705
7786
|
}
|
|
7706
7787
|
}
|
|
7707
|
-
const levelDefinition =
|
|
7708
|
-
(element) => element.name === "w:lvl" && element.attributes["w:ilvl"] == ilvl
|
|
7788
|
+
const levelDefinition = listDefElements?.find(
|
|
7789
|
+
(element) => element.name === "w:lvl" && element.attributes?.["w:ilvl"] == ilvl
|
|
7709
7790
|
);
|
|
7710
7791
|
if (!levelDefinition) return {};
|
|
7711
|
-
const
|
|
7792
|
+
const levelDefElements = levelDefinition.elements;
|
|
7793
|
+
const abstractElementPr = levelDefElements?.find((el) => el.name === translator2.xmlName);
|
|
7712
7794
|
if (!abstractElementPr) return {};
|
|
7713
7795
|
const abstractProps = translator2.encode({ ...params, nodes: [abstractElementPr] }) || {};
|
|
7714
|
-
const pStyleElement =
|
|
7796
|
+
const pStyleElement = levelDefElements?.find((el) => el.name === "w:pStyle");
|
|
7715
7797
|
if (pStyleElement) {
|
|
7716
|
-
const pStyleId = pStyleElement
|
|
7798
|
+
const pStyleId = pStyleElement.attributes?.["w:val"];
|
|
7717
7799
|
abstractProps.styleId = pStyleId;
|
|
7718
7800
|
}
|
|
7719
7801
|
propertiesChain.push(abstractProps);
|
|
7720
7802
|
propertiesChain.reverse();
|
|
7721
|
-
|
|
7722
|
-
return result;
|
|
7803
|
+
return combineProperties$1(propertiesChain);
|
|
7723
7804
|
}
|
|
7724
|
-
|
|
7725
|
-
if (!
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
const
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
output[key] = source[key];
|
|
7746
|
-
}
|
|
7747
|
-
}
|
|
7748
|
-
}
|
|
7749
|
-
}
|
|
7805
|
+
function resolveDocxFontFamily(attributes, docx, toCssFontFamily) {
|
|
7806
|
+
if (!attributes || typeof attributes !== "object") return null;
|
|
7807
|
+
const ascii = attributes["w:ascii"] ?? attributes["ascii"];
|
|
7808
|
+
const themeAscii = attributes["w:asciiTheme"] ?? attributes["asciiTheme"];
|
|
7809
|
+
let resolved = ascii;
|
|
7810
|
+
if (docx && themeAscii) {
|
|
7811
|
+
const theme = docx["word/theme/theme1.xml"];
|
|
7812
|
+
const themeElements = theme?.elements;
|
|
7813
|
+
if (themeElements?.length) {
|
|
7814
|
+
const topElement = themeElements[0];
|
|
7815
|
+
const topElementElements = topElement?.elements;
|
|
7816
|
+
const themeElementsNode = topElementElements?.find((el) => el.name === "a:themeElements");
|
|
7817
|
+
const themeElementsElements = themeElementsNode?.elements;
|
|
7818
|
+
const fontScheme = themeElementsElements?.find((el) => el.name === "a:fontScheme");
|
|
7819
|
+
const fontSchemeElements = fontScheme?.elements;
|
|
7820
|
+
const prefix = themeAscii.startsWith("minor") ? "minor" : "major";
|
|
7821
|
+
const font = fontSchemeElements?.find((el) => el.name === `a:${prefix}Font`);
|
|
7822
|
+
const fontElements = font?.elements;
|
|
7823
|
+
const latin = fontElements?.find((el) => el.name === "a:latin");
|
|
7824
|
+
const typeface = latin?.attributes?.typeface;
|
|
7825
|
+
resolved = typeface || resolved;
|
|
7750
7826
|
}
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7827
|
+
}
|
|
7828
|
+
if (!resolved) return null;
|
|
7829
|
+
if (toCssFontFamily) {
|
|
7830
|
+
return toCssFontFamily(resolved, docx ?? void 0);
|
|
7831
|
+
}
|
|
7832
|
+
return resolved;
|
|
7833
|
+
}
|
|
7834
|
+
const ooxmlResolver = createOoxmlResolver({ pPr: translator$14, rPr: translator$1O });
|
|
7835
|
+
const getToCssFontFamily = () => {
|
|
7836
|
+
return SuperConverter.toCssFontFamily;
|
|
7837
|
+
};
|
|
7838
|
+
const SUBSCRIPT_SUPERSCRIPT_SCALE = 0.65;
|
|
7839
|
+
const resolveRunProperties = (params, inlineRpr, resolvedPpr, isListNumber = false, numberingDefinedInline = false) => ooxmlResolver.resolveRunProperties(params, inlineRpr, resolvedPpr, isListNumber, numberingDefinedInline);
|
|
7840
|
+
function resolveParagraphProperties(params, inlineProps, insideTable = false, overrideInlineStyleId = false, tableStyleId = null) {
|
|
7841
|
+
return ooxmlResolver.resolveParagraphProperties(
|
|
7842
|
+
params,
|
|
7843
|
+
inlineProps,
|
|
7844
|
+
insideTable,
|
|
7845
|
+
overrideInlineStyleId,
|
|
7846
|
+
tableStyleId
|
|
7847
|
+
);
|
|
7848
|
+
}
|
|
7849
|
+
const combineProperties = (propertiesArray, fullOverrideProps = [], specialHandling = {}) => {
|
|
7850
|
+
return combineProperties$1(propertiesArray, { fullOverrideProps, specialHandling });
|
|
7754
7851
|
};
|
|
7755
7852
|
const combineRunProperties = (propertiesArray) => {
|
|
7756
7853
|
return combineProperties(propertiesArray, ["fontFamily", "color"]);
|
|
@@ -7809,9 +7906,9 @@ function encodeMarksFromRPr(runProperties, docx) {
|
|
|
7809
7906
|
textStyleAttrs[key] = `${spacing}pt`;
|
|
7810
7907
|
break;
|
|
7811
7908
|
case "fontFamily":
|
|
7812
|
-
const fontFamily =
|
|
7909
|
+
const fontFamily = resolveDocxFontFamily(value, docx, getToCssFontFamily());
|
|
7813
7910
|
textStyleAttrs[key] = fontFamily;
|
|
7814
|
-
const eastAsiaFamily = value["eastAsia"];
|
|
7911
|
+
const eastAsiaFamily = typeof value === "object" && value !== null ? value["eastAsia"] : void 0;
|
|
7815
7912
|
if (eastAsiaFamily) {
|
|
7816
7913
|
const eastAsiaCss = getFontFamilyValue$1({ "w:ascii": eastAsiaFamily }, docx);
|
|
7817
7914
|
if (!fontFamily || eastAsiaCss !== textStyleAttrs.fontFamily) {
|
|
@@ -8066,11 +8163,11 @@ function encodeCSSFromRPr(runProperties, docx) {
|
|
|
8066
8163
|
}
|
|
8067
8164
|
case "fontFamily": {
|
|
8068
8165
|
if (!value) break;
|
|
8069
|
-
const fontFamily =
|
|
8166
|
+
const fontFamily = resolveDocxFontFamily(value, docx, getToCssFontFamily());
|
|
8070
8167
|
if (fontFamily) {
|
|
8071
8168
|
css["font-family"] = fontFamily;
|
|
8072
8169
|
}
|
|
8073
|
-
const eastAsiaFamily = value["eastAsia"];
|
|
8170
|
+
const eastAsiaFamily = typeof value === "object" && value !== null ? value["eastAsia"] : void 0;
|
|
8074
8171
|
if (eastAsiaFamily) {
|
|
8075
8172
|
const eastAsiaCss = getFontFamilyValue$1({ "w:ascii": eastAsiaFamily }, docx);
|
|
8076
8173
|
if (eastAsiaCss && (!fontFamily || eastAsiaCss !== fontFamily)) {
|
|
@@ -27294,7 +27391,8 @@ const encode$1 = (params, encodedAttrs = {}) => {
|
|
|
27294
27391
|
text = text.replace(/^[ \t\n\r]+/, "").replace(/[ \t\n\r]+$/, "");
|
|
27295
27392
|
}
|
|
27296
27393
|
text = text.replace(/\[\[sdspace\]\]/g, "");
|
|
27297
|
-
|
|
27394
|
+
const isWhitespaceOnly = /^[ \t\n\r]*$/.test(text);
|
|
27395
|
+
if (xmlSpace !== "preserve" && isWhitespaceOnly) {
|
|
27298
27396
|
return null;
|
|
27299
27397
|
}
|
|
27300
27398
|
} else if (!elements.length && encodedAttrs.xmlSpace === "preserve") {
|
|
@@ -30839,7 +30937,7 @@ class SuperConverter {
|
|
|
30839
30937
|
static getStoredSuperdocVersion(docx) {
|
|
30840
30938
|
return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
30841
30939
|
}
|
|
30842
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.
|
|
30940
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.3") {
|
|
30843
30941
|
return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
|
|
30844
30942
|
}
|
|
30845
30943
|
/**
|
|
@@ -31485,45 +31583,49 @@ function generateCustomXml() {
|
|
|
31485
31583
|
return DEFAULT_CUSTOM_XML;
|
|
31486
31584
|
}
|
|
31487
31585
|
export {
|
|
31488
|
-
|
|
31586
|
+
createOoxmlResolver as $,
|
|
31489
31587
|
AllSelection as A,
|
|
31490
|
-
|
|
31491
|
-
|
|
31588
|
+
htmlHandler as B,
|
|
31589
|
+
ReplaceStep as C,
|
|
31492
31590
|
DOMParser$1 as D,
|
|
31493
|
-
|
|
31591
|
+
getResolvedParagraphProperties as E,
|
|
31494
31592
|
Fragment as F,
|
|
31495
|
-
|
|
31496
|
-
|
|
31497
|
-
|
|
31498
|
-
|
|
31499
|
-
|
|
31593
|
+
changeListLevel as G,
|
|
31594
|
+
isList as H,
|
|
31595
|
+
updateNumberingProperties as I,
|
|
31596
|
+
inputRulesPlugin as J,
|
|
31597
|
+
TrackDeleteMarkName as K,
|
|
31500
31598
|
ListHelpers as L,
|
|
31501
31599
|
Mapping as M,
|
|
31502
31600
|
NodeSelection as N,
|
|
31503
|
-
|
|
31601
|
+
TrackInsertMarkName as O,
|
|
31504
31602
|
PluginKey as P,
|
|
31505
|
-
|
|
31603
|
+
TrackFormatMarkName as Q,
|
|
31506
31604
|
ReplaceAroundStep as R,
|
|
31507
31605
|
SuperConverter as S,
|
|
31508
31606
|
TextSelection as T,
|
|
31509
|
-
|
|
31510
|
-
|
|
31511
|
-
|
|
31512
|
-
|
|
31513
|
-
|
|
31514
|
-
|
|
31515
|
-
|
|
31607
|
+
AddMarkStep as U,
|
|
31608
|
+
RemoveMarkStep as V,
|
|
31609
|
+
CommandService as W,
|
|
31610
|
+
EditorState as X,
|
|
31611
|
+
unflattenListsInHtml as Y,
|
|
31612
|
+
SelectionRange as Z,
|
|
31613
|
+
Transform as _,
|
|
31516
31614
|
createDocFromHTML as a,
|
|
31517
|
-
|
|
31518
|
-
|
|
31519
|
-
|
|
31520
|
-
|
|
31521
|
-
|
|
31522
|
-
|
|
31523
|
-
|
|
31524
|
-
|
|
31525
|
-
|
|
31526
|
-
|
|
31615
|
+
translator$14 as a0,
|
|
31616
|
+
translator$1O as a1,
|
|
31617
|
+
resolveDocxFontFamily as a2,
|
|
31618
|
+
_getReferencedTableStyles as a3,
|
|
31619
|
+
decodeRPrFromMarks as a4,
|
|
31620
|
+
calculateResolvedParagraphProperties as a5,
|
|
31621
|
+
encodeCSSFromPPr as a6,
|
|
31622
|
+
encodeCSSFromRPr as a7,
|
|
31623
|
+
generateOrderedListIndex as a8,
|
|
31624
|
+
docxNumberingHelpers as a9,
|
|
31625
|
+
InputRule as aa,
|
|
31626
|
+
insertNewRelationship as ab,
|
|
31627
|
+
kebabCase as ac,
|
|
31628
|
+
getUnderlineCssString as ad,
|
|
31527
31629
|
chainableEditorState as b,
|
|
31528
31630
|
createDocFromMarkdown as c,
|
|
31529
31631
|
convertMarkdownToHTML as d,
|
|
@@ -31542,11 +31644,11 @@ export {
|
|
|
31542
31644
|
Schema$1 as q,
|
|
31543
31645
|
registeredHandlers as r,
|
|
31544
31646
|
canSplit as s,
|
|
31545
|
-
|
|
31546
|
-
|
|
31547
|
-
|
|
31647
|
+
resolveRunProperties as t,
|
|
31648
|
+
encodeMarksFromRPr as u,
|
|
31649
|
+
liftTarget as v,
|
|
31548
31650
|
wrapTextsInRuns as w,
|
|
31549
|
-
|
|
31550
|
-
|
|
31551
|
-
|
|
31651
|
+
canJoin as x,
|
|
31652
|
+
joinPoint as y,
|
|
31653
|
+
replaceStep as z
|
|
31552
31654
|
};
|