@a3s-lab/office 0.26.0 → 0.27.0
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/README.md +75 -2
- package/dist/0~4595.js +16 -2
- package/dist/0~5093.js +463 -201
- package/dist/0~6090.js +77 -77
- package/dist/{0~2805.js → 0~7043.js} +305 -2
- package/dist/0~document-editor.js +2451 -985
- package/dist/0~spreadsheet-editor.js +1324 -378
- package/dist/0~work-docx-export.js +492 -10
- package/dist/0~work-docx-import.js +171 -98
- package/dist/0~work-office-diagnostics.js +198 -4
- package/dist/{164.js → 1544.js} +1083 -785
- package/dist/4104.js +145 -29
- package/dist/6282.js +1774 -384
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/features/work/editors/document-command-catalog.d.ts +102 -0
- package/dist/internal/features/work/editors/document-font-dialog-model.d.ts +83 -0
- package/dist/internal/features/work/editors/document-font-dialog-script-font-model.d.ts +18 -0
- package/dist/internal/features/work/editors/document-font-dialog.d.ts +9 -0
- package/dist/internal/features/work/editors/document-home-ribbon.d.ts +2 -1
- package/dist/internal/features/work/editors/document-page-chrome-editor.d.ts +6 -0
- package/dist/internal/features/work/editors/document-page-chrome-ribbon.d.ts +2 -1
- package/dist/internal/features/work/editors/document-strike-ribbon.d.ts +7 -0
- package/dist/internal/features/work/editors/document-text-case-ribbon.d.ts +4 -0
- package/dist/internal/features/work/editors/document-toolbar.d.ts +3 -1
- package/dist/internal/features/work/editors/document-underline-ribbon.d.ts +9 -0
- package/dist/internal/features/work/editors/document-wps-shortcuts.d.ts +1 -0
- package/dist/internal/features/work/editors/spreadsheet-cell-fill-format.d.ts +11 -0
- package/dist/internal/features/work/editors/spreadsheet-cell-format.d.ts +2 -1
- package/dist/internal/features/work/editors/spreadsheet-format-cells-dialog-model.d.ts +13 -2
- package/dist/internal/features/work/editors/spreadsheet-format-cells-fill-panel.d.ts +13 -0
- package/dist/internal/features/work/editors/spreadsheet-format-cells-fill-preview.d.ts +6 -0
- package/dist/internal/features/work/editors/spreadsheet-format-painter.d.ts +1 -1
- package/dist/internal/features/work/editors/work-office-chrome.d.ts +9 -1
- package/dist/internal/features/work/work-document-character-formatting.d.ts +16 -1
- package/dist/internal/features/work/work-document-character-position.d.ts +9 -0
- package/dist/internal/features/work/work-document-character-scale.d.ts +8 -0
- package/dist/internal/features/work/work-document-character-spacing.d.ts +8 -0
- package/dist/internal/features/work/work-document-emphasis.d.ts +7 -0
- package/dist/internal/features/work/work-document-equations.d.ts +2 -1
- package/dist/internal/features/work/work-document-format-changes.d.ts +16 -2
- package/dist/internal/features/work/work-document-hidden-text.d.ts +5 -0
- package/dist/internal/features/work/work-document-kerning.d.ts +10 -0
- package/dist/internal/features/work/work-document-script-font-extension.d.ts +2 -0
- package/dist/internal/features/work/work-document-script-fonts.d.ts +51 -0
- package/dist/internal/features/work/work-document-strike.d.ts +21 -0
- package/dist/internal/features/work/work-document-text-case.d.ts +10 -0
- package/dist/internal/features/work/work-document-underline.d.ts +37 -0
- package/dist/internal/features/work/work-document-word-line-metrics.d.ts +12 -0
- package/dist/internal/features/work/work-docx-character-position.d.ts +2 -0
- package/dist/internal/features/work/work-docx-character-scale.d.ts +2 -0
- package/dist/internal/features/work/work-docx-character-spacing.d.ts +4 -0
- package/dist/internal/features/work/work-docx-emphasis-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-emphasis.d.ts +14 -0
- package/dist/internal/features/work/work-docx-hidden-text-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-hidden-text-export.d.ts +16 -0
- package/dist/internal/features/work/work-docx-hidden-text.d.ts +11 -0
- package/dist/internal/features/work/work-docx-kerning-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-kerning.d.ts +14 -0
- package/dist/internal/features/work/work-docx-run-fonts-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-run-fonts-export.d.ts +14 -0
- package/dist/internal/features/work/work-docx-run-fonts.d.ts +13 -0
- package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +23 -2
- package/dist/internal/features/work/work-docx-run-script-font-import.d.ts +9 -0
- package/dist/internal/features/work/work-docx-strike.d.ts +8 -0
- package/dist/internal/features/work/work-docx-theme-reference.d.ts +1 -1
- package/dist/internal/features/work/work-docx-twips.d.ts +6 -0
- package/dist/internal/features/work/work-docx-underline.d.ts +3 -0
- package/dist/internal/features/work/work-spreadsheet-gradient-fill-canvas.d.ts +10 -0
- package/dist/internal/features/work/work-spreadsheet-native-fill-canvas.d.ts +8 -0
- package/dist/internal/features/work/work-spreadsheet-pattern-fill-canvas.d.ts +8 -0
- package/dist/internal/features/work/work-xlsx-cell-style-origin.d.ts +2 -1
- package/dist/internal/features/work/work-xlsx-cell-style-writer.d.ts +3 -0
- package/dist/internal/features/work/work-xlsx-cell-styles.d.ts +4 -0
- package/dist/internal/features/work/work-xlsx-gradient-fill.d.ts +31 -0
- package/dist/internal/features/work/work-xlsx-native-fill.d.ts +17 -0
- package/dist/internal/features/work/work-xlsx-pattern-fill.d.ts +21 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/styles.css +770 -80
- package/docs/latest/en/browser-editor-architecture.md +10 -0
- package/package.json +32 -1
package/dist/6282.js
CHANGED
|
@@ -7,11 +7,12 @@ import extension_color from "@tiptap/extension-color";
|
|
|
7
7
|
import { Table, TableCell, TableHeader, TableKit, TableRow, TableView, createTable } from "@tiptap/extension-table";
|
|
8
8
|
import extension_text_align from "@tiptap/extension-text-align";
|
|
9
9
|
import font_size from "@tiptap/extension-text-style/font-size";
|
|
10
|
-
import extension_underline from "@tiptap/extension-underline";
|
|
11
10
|
import starter_kit from "@tiptap/starter-kit";
|
|
12
11
|
import { DOMParser as model_DOMParser, Fragment, Slice } from "@tiptap/pm/model";
|
|
13
12
|
import jszip from "jszip";
|
|
14
13
|
import { closeHistory, isHistoryTransaction } from "@tiptap/pm/history";
|
|
14
|
+
import extension_underline from "@tiptap/extension-underline";
|
|
15
|
+
import extension_strike from "@tiptap/extension-strike";
|
|
15
16
|
import extension_subscript from "@tiptap/extension-subscript";
|
|
16
17
|
import extension_superscript from "@tiptap/extension-superscript";
|
|
17
18
|
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
@@ -2297,6 +2298,15 @@ function themePatchTargets(localName) {
|
|
|
2297
2298
|
shadeAttribute: 'themeShade'
|
|
2298
2299
|
}
|
|
2299
2300
|
];
|
|
2301
|
+
if ('u' === localName) return [
|
|
2302
|
+
{
|
|
2303
|
+
kind: 'underline',
|
|
2304
|
+
directAttribute: 'color',
|
|
2305
|
+
themeAttribute: 'themeColor',
|
|
2306
|
+
tintAttribute: 'themeTint',
|
|
2307
|
+
shadeAttribute: 'themeShade'
|
|
2308
|
+
}
|
|
2309
|
+
];
|
|
2300
2310
|
if ('shd' === localName) return [
|
|
2301
2311
|
{
|
|
2302
2312
|
kind: 'fill',
|
|
@@ -3581,6 +3591,104 @@ function work_document_page_margins_roundFour(value) {
|
|
|
3581
3591
|
function normalizeNegativeZero(value) {
|
|
3582
3592
|
return Object.is(value, -0) ? 0 : value;
|
|
3583
3593
|
}
|
|
3594
|
+
const DOCUMENT_CHARACTER_SCALE_ATTRIBUTE = 'data-office-character-scale-percent';
|
|
3595
|
+
const DOCUMENT_CHARACTER_SCALE_MIN_PERCENT = 1;
|
|
3596
|
+
const DOCUMENT_CHARACTER_SCALE_MAX_PERCENT = 600;
|
|
3597
|
+
function normalizeDocumentCharacterScalePercent(value) {
|
|
3598
|
+
if (null == value || '' === value) return null;
|
|
3599
|
+
const scale = Number(value);
|
|
3600
|
+
return Number.isSafeInteger(scale) && scale >= DOCUMENT_CHARACTER_SCALE_MIN_PERCENT && scale <= DOCUMENT_CHARACTER_SCALE_MAX_PERCENT ? scale : null;
|
|
3601
|
+
}
|
|
3602
|
+
function documentCharacterScaleDomAttributes(value) {
|
|
3603
|
+
const scale = normalizeDocumentCharacterScalePercent(value);
|
|
3604
|
+
if (null === scale) return {};
|
|
3605
|
+
return {
|
|
3606
|
+
[DOCUMENT_CHARACTER_SCALE_ATTRIBUTE]: String(scale),
|
|
3607
|
+
style: `font-stretch: ${scale}%`
|
|
3608
|
+
};
|
|
3609
|
+
}
|
|
3610
|
+
function documentCharacterScalePercentFromElement(element) {
|
|
3611
|
+
if (element.hasAttribute(DOCUMENT_CHARACTER_SCALE_ATTRIBUTE)) return normalizeDocumentCharacterScalePercent(element.getAttribute(DOCUMENT_CHARACTER_SCALE_ATTRIBUTE));
|
|
3612
|
+
return documentCharacterScalePercentFromCss(element.style.fontStretch);
|
|
3613
|
+
}
|
|
3614
|
+
function documentCharacterScalePercentFromCss(value) {
|
|
3615
|
+
if ('string' != typeof value) return null;
|
|
3616
|
+
const source = value.trim().toLowerCase();
|
|
3617
|
+
if (!source || 'normal' === source) return null;
|
|
3618
|
+
const match = /^(\d+(?:\.\d*)?|\.\d+)%$/u.exec(source);
|
|
3619
|
+
if (!match) return null;
|
|
3620
|
+
return normalizeDocumentCharacterScalePercent(Number(match[1]));
|
|
3621
|
+
}
|
|
3622
|
+
const DOCUMENT_EMPHASIS_MARK_ATTRIBUTE = 'data-office-emphasis-mark';
|
|
3623
|
+
const DOCUMENT_EMPHASIS_MARKS = [
|
|
3624
|
+
'none',
|
|
3625
|
+
'dot',
|
|
3626
|
+
'comma',
|
|
3627
|
+
'circle',
|
|
3628
|
+
'underDot'
|
|
3629
|
+
];
|
|
3630
|
+
const DOCUMENT_EMPHASIS_MARK_SET = new Set(DOCUMENT_EMPHASIS_MARKS);
|
|
3631
|
+
function normalizeDocumentEmphasisMark(value) {
|
|
3632
|
+
return 'string' == typeof value && DOCUMENT_EMPHASIS_MARK_SET.has(value) ? value : null;
|
|
3633
|
+
}
|
|
3634
|
+
function documentEmphasisMarkCss(value) {
|
|
3635
|
+
const emphasisMark = normalizeDocumentEmphasisMark(value);
|
|
3636
|
+
if (!emphasisMark) return '';
|
|
3637
|
+
if ('none' === emphasisMark) return 'text-emphasis-style:none;-webkit-text-emphasis-style:none';
|
|
3638
|
+
const style = 'comma' === emphasisMark ? '","' : 'circle' === emphasisMark ? 'open circle' : 'filled dot';
|
|
3639
|
+
const position = 'underDot' === emphasisMark ? 'under right' : 'over right';
|
|
3640
|
+
return `text-emphasis-style:${style};text-emphasis-position:${position};-webkit-text-emphasis-style:${style};-webkit-text-emphasis-position:${position}`;
|
|
3641
|
+
}
|
|
3642
|
+
function documentEmphasisMarkDomAttributes(value) {
|
|
3643
|
+
const emphasisMark = normalizeDocumentEmphasisMark(value);
|
|
3644
|
+
if (!emphasisMark) return {};
|
|
3645
|
+
return {
|
|
3646
|
+
[DOCUMENT_EMPHASIS_MARK_ATTRIBUTE]: emphasisMark,
|
|
3647
|
+
style: documentEmphasisMarkCss(emphasisMark)
|
|
3648
|
+
};
|
|
3649
|
+
}
|
|
3650
|
+
function documentEmphasisMarkFromElement(element) {
|
|
3651
|
+
return element.hasAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE) ? normalizeDocumentEmphasisMark(element.getAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE)) : null;
|
|
3652
|
+
}
|
|
3653
|
+
const DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE = 'data-office-kerning-threshold-half-points';
|
|
3654
|
+
const DOCUMENT_KERNING_THRESHOLD_MIN_HALF_POINTS = 0;
|
|
3655
|
+
const DOCUMENT_KERNING_THRESHOLD_MAX_HALF_POINTS = 3277;
|
|
3656
|
+
const DOCUMENT_DEFAULT_FONT_SIZE_POINTS = 10.5;
|
|
3657
|
+
function normalizeDocumentKerningThresholdHalfPoints(value) {
|
|
3658
|
+
const threshold = 'number' == typeof value ? value : 'string' == typeof value && /^\+?\d+$/u.test(value.trim()) ? Number(value.trim()) : NaN;
|
|
3659
|
+
if (!Number.isSafeInteger(threshold) || threshold < DOCUMENT_KERNING_THRESHOLD_MIN_HALF_POINTS || threshold > DOCUMENT_KERNING_THRESHOLD_MAX_HALF_POINTS) return null;
|
|
3660
|
+
return Object.is(threshold, -0) ? 0 : threshold;
|
|
3661
|
+
}
|
|
3662
|
+
function documentKerningThresholdPoints(value) {
|
|
3663
|
+
const threshold = normalizeDocumentKerningThresholdHalfPoints(value);
|
|
3664
|
+
return null === threshold ? null : threshold / 2;
|
|
3665
|
+
}
|
|
3666
|
+
function documentKerningIsEffective(thresholdValue, fontSizeValue) {
|
|
3667
|
+
const threshold = normalizeDocumentKerningThresholdHalfPoints(thresholdValue);
|
|
3668
|
+
if (null === threshold) return false;
|
|
3669
|
+
if (0 === threshold) return true;
|
|
3670
|
+
return 2 * documentKerningFontSizePoints(fontSizeValue) >= threshold;
|
|
3671
|
+
}
|
|
3672
|
+
function documentKerningDomAttributes(thresholdValue, fontSizeValue) {
|
|
3673
|
+
const threshold = normalizeDocumentKerningThresholdHalfPoints(thresholdValue);
|
|
3674
|
+
if (null === threshold) return {};
|
|
3675
|
+
return {
|
|
3676
|
+
[DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE]: String(threshold),
|
|
3677
|
+
style: `font-kerning: ${documentKerningIsEffective(threshold, fontSizeValue) ? 'normal' : 'none'}`
|
|
3678
|
+
};
|
|
3679
|
+
}
|
|
3680
|
+
function documentKerningThresholdHalfPointsFromElement(element) {
|
|
3681
|
+
return element.hasAttribute(DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE) ? normalizeDocumentKerningThresholdHalfPoints(element.getAttribute(DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE)) : null;
|
|
3682
|
+
}
|
|
3683
|
+
function documentKerningFontSizePoints(value) {
|
|
3684
|
+
if ('number' == typeof value) return Number.isFinite(value) && value > 0 ? value : DOCUMENT_DEFAULT_FONT_SIZE_POINTS;
|
|
3685
|
+
if ('string' != typeof value) return DOCUMENT_DEFAULT_FONT_SIZE_POINTS;
|
|
3686
|
+
const match = /^(\d+(?:\.\d*)?|\.\d+)(pt|px)?$/iu.exec(value.trim());
|
|
3687
|
+
if (!match) return DOCUMENT_DEFAULT_FONT_SIZE_POINTS;
|
|
3688
|
+
const amount = Number(match[1]);
|
|
3689
|
+
if (!Number.isFinite(amount) || amount <= 0) return DOCUMENT_DEFAULT_FONT_SIZE_POINTS;
|
|
3690
|
+
return match[2]?.toLowerCase() === 'px' ? 0.75 * amount : amount;
|
|
3691
|
+
}
|
|
3584
3692
|
const EQUATION_SELECTOR = 'span[data-document-equation]';
|
|
3585
3693
|
const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
|
3586
3694
|
const MAX_EQUATION_DEPTH = 32;
|
|
@@ -3833,13 +3941,6 @@ const WORD_VERTICAL_ALIGNMENTS = new Set([
|
|
|
3833
3941
|
"superscript",
|
|
3834
3942
|
"subscript"
|
|
3835
3943
|
]);
|
|
3836
|
-
const WORD_EMPHASIS_MARKS = new Set([
|
|
3837
|
-
'none',
|
|
3838
|
-
'dot',
|
|
3839
|
-
'comma',
|
|
3840
|
-
'circle',
|
|
3841
|
-
'underDot'
|
|
3842
|
-
]);
|
|
3843
3944
|
const WORD_COMBINE_BRACKETS = new Set([
|
|
3844
3945
|
'none',
|
|
3845
3946
|
'round',
|
|
@@ -3851,8 +3952,6 @@ const MAX_EQUATION_WORD_FONT_LENGTH = 127;
|
|
|
3851
3952
|
const MAX_EQUATION_LANGUAGE_LENGTH = 85;
|
|
3852
3953
|
const MAX_EQUATION_FONT_SIZE = 512;
|
|
3853
3954
|
const MAX_EQUATION_CHARACTER_SPACING_TWIPS = 31680;
|
|
3854
|
-
const MAX_EQUATION_CHARACTER_SCALE_PERCENT = 600;
|
|
3855
|
-
const MAX_EQUATION_KERNING_THRESHOLD_HALF_POINTS = 3277;
|
|
3856
3955
|
const MIN_EQUATION_WORD_LINE_BORDER_EIGHTH_POINTS = 2;
|
|
3857
3956
|
const MAX_EQUATION_WORD_LINE_BORDER_EIGHTH_POINTS = 96;
|
|
3858
3957
|
const MAX_EQUATION_WORD_BORDER_SPACING_POINTS = 31;
|
|
@@ -5667,7 +5766,7 @@ function normalizeEquationWordRunProperties(source) {
|
|
|
5667
5766
|
const shading = void 0 === source.shading ? void 0 : normalizeEquationWordShading(source.shading);
|
|
5668
5767
|
const fitText = void 0 === source.fitText ? void 0 : normalizeEquationWordFitText(source.fitText);
|
|
5669
5768
|
const verticalAlignment = void 0 === source.verticalAlignment ? void 0 : WORD_VERTICAL_ALIGNMENTS.has(source.verticalAlignment) ? source.verticalAlignment : null;
|
|
5670
|
-
const emphasisMark = void 0 === source.emphasisMark ? void 0 :
|
|
5769
|
+
const emphasisMark = void 0 === source.emphasisMark ? void 0 : normalizeDocumentEmphasisMark(source.emphasisMark);
|
|
5671
5770
|
const languages = void 0 === source.languages ? void 0 : normalizeEquationWordLanguages(source.languages);
|
|
5672
5771
|
const eastAsianLayout = void 0 === source.eastAsianLayout ? void 0 : normalizeEquationWordEastAsianLayout(source.eastAsianLayout);
|
|
5673
5772
|
const glow = void 0 === source.glow ? void 0 : normalizeEquationWordGlow(source.glow);
|
|
@@ -5682,8 +5781,8 @@ function normalizeEquationWordRunProperties(source) {
|
|
|
5682
5781
|
const numberSpacing = void 0 === source.numberSpacing ? void 0 : WORD_NUMBER_SPACINGS.has(source.numberSpacing) ? source.numberSpacing : null;
|
|
5683
5782
|
const stylisticSets = void 0 === source.stylisticSets ? void 0 : normalizeEquationWordStylisticSets(source.stylisticSets);
|
|
5684
5783
|
const characterSpacingTwips = void 0 === source.characterSpacingTwips ? void 0 : normalizeEquationInteger(source.characterSpacingTwips, -MAX_EQUATION_CHARACTER_SPACING_TWIPS, MAX_EQUATION_CHARACTER_SPACING_TWIPS);
|
|
5685
|
-
const characterScalePercent = void 0 === source.characterScalePercent ? void 0 :
|
|
5686
|
-
const kerningThresholdHalfPoints = void 0 === source.kerningThresholdHalfPoints ? void 0 :
|
|
5784
|
+
const characterScalePercent = void 0 === source.characterScalePercent ? void 0 : 'number' == typeof source.characterScalePercent ? normalizeDocumentCharacterScalePercent(source.characterScalePercent) : null;
|
|
5785
|
+
const kerningThresholdHalfPoints = void 0 === source.kerningThresholdHalfPoints ? void 0 : 'number' == typeof source.kerningThresholdHalfPoints ? normalizeDocumentKerningThresholdHalfPoints(source.kerningThresholdHalfPoints) : null;
|
|
5687
5786
|
const positionHalfPoints = void 0 === source.positionHalfPoints ? void 0 : normalizeEquationInteger(source.positionHalfPoints, MIN_EQUATION_POSITION_HALF_POINTS, MAX_EQUATION_POSITION_HALF_POINTS);
|
|
5688
5787
|
const fontSize = void 0 === source.fontSize ? void 0 : normalizeEquationFontSize(source.fontSize);
|
|
5689
5788
|
const fontSizeComplexScript = void 0 === source.fontSizeComplexScript ? void 0 : normalizeEquationFontSize(source.fontSizeComplexScript);
|
|
@@ -6592,11 +6691,7 @@ function wordRunVerticalAlignmentStyles(alignment) {
|
|
|
6592
6691
|
return `vertical-align:${"superscript" === alignment ? 'super' : 'sub'};font-size:smaller`;
|
|
6593
6692
|
}
|
|
6594
6693
|
function wordRunEmphasisMarkStyles(emphasisMark) {
|
|
6595
|
-
|
|
6596
|
-
if ('none' === emphasisMark) return 'text-emphasis-style:none';
|
|
6597
|
-
const style = 'comma' === emphasisMark ? cssString(',') : 'circle' === emphasisMark ? 'open circle' : 'filled dot';
|
|
6598
|
-
const position = 'underDot' === emphasisMark ? 'under right' : 'over right';
|
|
6599
|
-
return `text-emphasis-style:${style};text-emphasis-position:${position}`;
|
|
6694
|
+
return documentEmphasisMarkCss(emphasisMark);
|
|
6600
6695
|
}
|
|
6601
6696
|
function wordRunCaseStyles(properties) {
|
|
6602
6697
|
return [
|
|
@@ -6705,6 +6800,105 @@ function validXmlText(source) {
|
|
|
6705
6800
|
function work_document_equations_isRecord(source) {
|
|
6706
6801
|
return Boolean(source) && 'object' == typeof source && !Array.isArray(source);
|
|
6707
6802
|
}
|
|
6803
|
+
const DOCUMENT_CHARACTER_POSITION_ATTRIBUTE = 'data-office-character-position-half-points';
|
|
6804
|
+
const DOCUMENT_CHARACTER_POSITION_CSS_PROPERTY = '--work-document-character-position';
|
|
6805
|
+
const DOCUMENT_CHARACTER_POSITION_MAX_HALF_POINTS = 3168;
|
|
6806
|
+
const DOCUMENT_CHARACTER_POSITION_MIN_HALF_POINTS = -DOCUMENT_CHARACTER_POSITION_MAX_HALF_POINTS;
|
|
6807
|
+
function normalizeDocumentCharacterPositionHalfPoints(value) {
|
|
6808
|
+
if (null == value || '' === value) return null;
|
|
6809
|
+
const position = Number(value);
|
|
6810
|
+
if (!Number.isSafeInteger(position) || position < DOCUMENT_CHARACTER_POSITION_MIN_HALF_POINTS || position > DOCUMENT_CHARACTER_POSITION_MAX_HALF_POINTS) return null;
|
|
6811
|
+
return Object.is(position, -0) ? 0 : position;
|
|
6812
|
+
}
|
|
6813
|
+
function documentCharacterPositionDomAttributes(value) {
|
|
6814
|
+
const position = normalizeDocumentCharacterPositionHalfPoints(value);
|
|
6815
|
+
if (null === position) return {};
|
|
6816
|
+
return {
|
|
6817
|
+
[DOCUMENT_CHARACTER_POSITION_ATTRIBUTE]: String(position),
|
|
6818
|
+
style: `${DOCUMENT_CHARACTER_POSITION_CSS_PROPERTY}: ${formatCharacterPositionPoints(position)}pt`
|
|
6819
|
+
};
|
|
6820
|
+
}
|
|
6821
|
+
function documentCharacterPositionHalfPointsFromElement(element) {
|
|
6822
|
+
if (element.hasAttribute(DOCUMENT_CHARACTER_POSITION_ATTRIBUTE)) return normalizeDocumentCharacterPositionHalfPoints(element.getAttribute(DOCUMENT_CHARACTER_POSITION_ATTRIBUTE));
|
|
6823
|
+
return documentCharacterPositionHalfPointsFromCss(element.style.getPropertyValue(DOCUMENT_CHARACTER_POSITION_CSS_PROPERTY)) ?? documentCharacterPositionHalfPointsFromCss(element.style.verticalAlign);
|
|
6824
|
+
}
|
|
6825
|
+
function documentCharacterPositionHalfPointsFromCss(value) {
|
|
6826
|
+
if ('string' != typeof value) return null;
|
|
6827
|
+
const source = value.trim().toLowerCase();
|
|
6828
|
+
if (!source || 'baseline' === source) return null;
|
|
6829
|
+
const match = /^([+-]?(?:\d+(?:\.\d*)?|\.\d+))(pt|px)?$/.exec(source);
|
|
6830
|
+
if (!match) return null;
|
|
6831
|
+
const amount = Number(match[1]);
|
|
6832
|
+
if (!Number.isFinite(amount)) return null;
|
|
6833
|
+
const unit = match[2];
|
|
6834
|
+
if (!unit && 0 !== amount) return null;
|
|
6835
|
+
const halfPoints = Math.round(amount * ('px' === unit ? 1.5 : 2));
|
|
6836
|
+
return normalizeDocumentCharacterPositionHalfPoints(halfPoints);
|
|
6837
|
+
}
|
|
6838
|
+
function documentCharacterPositionPoints(value) {
|
|
6839
|
+
const position = normalizeDocumentCharacterPositionHalfPoints(value);
|
|
6840
|
+
return null === position ? null : position / 2;
|
|
6841
|
+
}
|
|
6842
|
+
function formatCharacterPositionPoints(value) {
|
|
6843
|
+
return String(value / 2);
|
|
6844
|
+
}
|
|
6845
|
+
const DOCUMENT_CHARACTER_SPACING_ATTRIBUTE = 'data-office-character-spacing-twips';
|
|
6846
|
+
const DOCUMENT_CHARACTER_SPACING_MAX_TWIPS = 31680;
|
|
6847
|
+
const DOCUMENT_CHARACTER_SPACING_MIN_TWIPS = -DOCUMENT_CHARACTER_SPACING_MAX_TWIPS;
|
|
6848
|
+
function normalizeDocumentCharacterSpacingTwips(value) {
|
|
6849
|
+
if (null == value || '' === value) return null;
|
|
6850
|
+
const spacing = Number(value);
|
|
6851
|
+
if (!Number.isSafeInteger(spacing) || spacing < DOCUMENT_CHARACTER_SPACING_MIN_TWIPS || spacing > DOCUMENT_CHARACTER_SPACING_MAX_TWIPS) return null;
|
|
6852
|
+
return Object.is(spacing, -0) ? 0 : spacing;
|
|
6853
|
+
}
|
|
6854
|
+
function documentCharacterSpacingDomAttributes(value) {
|
|
6855
|
+
const spacing = normalizeDocumentCharacterSpacingTwips(value);
|
|
6856
|
+
if (null === spacing) return {};
|
|
6857
|
+
return {
|
|
6858
|
+
[DOCUMENT_CHARACTER_SPACING_ATTRIBUTE]: String(spacing),
|
|
6859
|
+
style: `letter-spacing: ${formatCharacterSpacingPoints(spacing)}pt`
|
|
6860
|
+
};
|
|
6861
|
+
}
|
|
6862
|
+
function documentCharacterSpacingTwipsFromElement(element) {
|
|
6863
|
+
if (element.hasAttribute(DOCUMENT_CHARACTER_SPACING_ATTRIBUTE)) return normalizeDocumentCharacterSpacingTwips(element.getAttribute(DOCUMENT_CHARACTER_SPACING_ATTRIBUTE));
|
|
6864
|
+
return documentCharacterSpacingTwipsFromCss(element.style.letterSpacing);
|
|
6865
|
+
}
|
|
6866
|
+
function documentCharacterSpacingTwipsFromCss(value) {
|
|
6867
|
+
if ('string' != typeof value) return null;
|
|
6868
|
+
const source = value.trim().toLowerCase();
|
|
6869
|
+
if (!source || 'normal' === source) return null;
|
|
6870
|
+
const match = /^([+-]?(?:\d+(?:\.\d*)?|\.\d+))(pt|px)?$/.exec(source);
|
|
6871
|
+
if (!match) return null;
|
|
6872
|
+
const amount = Number(match[1]);
|
|
6873
|
+
if (!Number.isFinite(amount)) return null;
|
|
6874
|
+
const unit = match[2];
|
|
6875
|
+
if (!unit && 0 !== amount) return null;
|
|
6876
|
+
const twips = Math.round(amount * ('px' === unit ? 15 : 20));
|
|
6877
|
+
return normalizeDocumentCharacterSpacingTwips(twips);
|
|
6878
|
+
}
|
|
6879
|
+
function documentCharacterSpacingPoints(value) {
|
|
6880
|
+
const spacing = normalizeDocumentCharacterSpacingTwips(value);
|
|
6881
|
+
return null === spacing ? null : spacing / 20;
|
|
6882
|
+
}
|
|
6883
|
+
function formatCharacterSpacingPoints(value) {
|
|
6884
|
+
return String(value / 20);
|
|
6885
|
+
}
|
|
6886
|
+
const DOCUMENT_HIDDEN_TEXT_ATTRIBUTE = 'data-office-hidden-text';
|
|
6887
|
+
const documentHiddenTextKeyboardShortcut = 'Mod-Shift-h';
|
|
6888
|
+
function normalizeDocumentHiddenText(value) {
|
|
6889
|
+
if (true === value || 'true' === value || '1' === value) return true;
|
|
6890
|
+
if (false === value || 'false' === value || '0' === value) return false;
|
|
6891
|
+
return null;
|
|
6892
|
+
}
|
|
6893
|
+
function documentHiddenTextFromElement(element) {
|
|
6894
|
+
return normalizeDocumentHiddenText(element.getAttribute(DOCUMENT_HIDDEN_TEXT_ATTRIBUTE));
|
|
6895
|
+
}
|
|
6896
|
+
function documentHiddenTextDomAttributes(value) {
|
|
6897
|
+
const hiddenText = normalizeDocumentHiddenText(value);
|
|
6898
|
+
return null === hiddenText ? {} : {
|
|
6899
|
+
[DOCUMENT_HIDDEN_TEXT_ATTRIBUTE]: String(hiddenText)
|
|
6900
|
+
};
|
|
6901
|
+
}
|
|
6708
6902
|
const IMAGE_OBJECT_ID_PATTERN = /^[0-9A-F]{8}$/;
|
|
6709
6903
|
const MAX_DOC_PROPERTIES_ID = 0xffffffff;
|
|
6710
6904
|
const MAX_WORDPROCESSING_ID = 0x7fffffff;
|
|
@@ -7714,192 +7908,935 @@ function work_document_table_row_identity_transactionMapping(transactions) {
|
|
|
7714
7908
|
for (const transaction of transactions)mapping.appendMapping(transaction.mapping);
|
|
7715
7909
|
return mapping;
|
|
7716
7910
|
}
|
|
7717
|
-
const
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7911
|
+
const DOCUMENT_TEXT_CASE_ATTRIBUTE = 'data-office-text-case';
|
|
7912
|
+
const documentTextCaseKeyboardShortcuts = {
|
|
7913
|
+
allCaps: 'Mod-Shift-a',
|
|
7914
|
+
smallCaps: 'Mod-Shift-k'
|
|
7721
7915
|
};
|
|
7722
|
-
|
|
7723
|
-
'
|
|
7724
|
-
'data-office-image-doc-properties-id',
|
|
7725
|
-
'data-office-image-anchor-id',
|
|
7726
|
-
'data-office-image-edit-id'
|
|
7727
|
-
];
|
|
7728
|
-
const PARAGRAPH_IDENTITY_ATTRIBUTES = [
|
|
7729
|
-
DOCUMENT_PARAGRAPH_ID_ATTRIBUTE,
|
|
7730
|
-
DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE
|
|
7731
|
-
];
|
|
7732
|
-
const PARAGRAPH_DEFAULT_COLLAPSED_ATTRIBUTE = 'data-office-default-collapsed';
|
|
7733
|
-
const PARAGRAPH_BORDERS_ATTRIBUTE = DOCUMENT_PARAGRAPH_BORDERS_ATTRIBUTE;
|
|
7734
|
-
const PARAGRAPH_SHADING_ATTRIBUTE = 'data-office-paragraph-shading';
|
|
7735
|
-
const TABLE_ROW_IDENTITY_ATTRIBUTES = [
|
|
7736
|
-
DOCUMENT_TABLE_ROW_ID_ATTRIBUTE,
|
|
7737
|
-
DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE
|
|
7738
|
-
];
|
|
7739
|
-
const EQUATION_ATTRIBUTES = [
|
|
7740
|
-
'aria-label',
|
|
7741
|
-
'class',
|
|
7742
|
-
'contenteditable',
|
|
7743
|
-
'data-document-equation',
|
|
7744
|
-
'data-equation-display',
|
|
7745
|
-
'data-equation-model',
|
|
7746
|
-
'role'
|
|
7747
|
-
];
|
|
7748
|
-
const MATHML_ATTRIBUTES = new Set([
|
|
7749
|
-
'accent',
|
|
7750
|
-
'accentunder',
|
|
7751
|
-
'align',
|
|
7752
|
-
'bevelled',
|
|
7753
|
-
'columnalign',
|
|
7754
|
-
'depth',
|
|
7755
|
-
'dir',
|
|
7756
|
-
'display',
|
|
7757
|
-
'fence',
|
|
7758
|
-
'height',
|
|
7759
|
-
'lang',
|
|
7760
|
-
'linethickness',
|
|
7761
|
-
'mathbackground',
|
|
7762
|
-
'mathcolor',
|
|
7763
|
-
'mathsize',
|
|
7764
|
-
'mathvariant',
|
|
7765
|
-
'notation',
|
|
7766
|
-
'rowspacing',
|
|
7767
|
-
"scriptlevel",
|
|
7768
|
-
'separator',
|
|
7769
|
-
'style',
|
|
7770
|
-
'width',
|
|
7771
|
-
'xmlns'
|
|
7772
|
-
]);
|
|
7773
|
-
const work_document_page_chrome_MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
|
7774
|
-
const MATHML_TAGS = new Set([
|
|
7775
|
-
'math',
|
|
7776
|
-
'maligngroup',
|
|
7777
|
-
'malignmark',
|
|
7778
|
-
'menclose',
|
|
7779
|
-
'mfrac',
|
|
7780
|
-
"mmultiscripts",
|
|
7781
|
-
'mo',
|
|
7782
|
-
'mover',
|
|
7783
|
-
'mpadded',
|
|
7784
|
-
'mphantom',
|
|
7785
|
-
"mprescripts",
|
|
7786
|
-
'mroot',
|
|
7787
|
-
'mrow',
|
|
7788
|
-
'msqrt',
|
|
7789
|
-
'msub',
|
|
7790
|
-
'msubsup',
|
|
7791
|
-
'msup',
|
|
7792
|
-
'mstyle',
|
|
7793
|
-
'mtable',
|
|
7794
|
-
'mtd',
|
|
7795
|
-
'mtext',
|
|
7796
|
-
'mtr',
|
|
7797
|
-
'munder',
|
|
7798
|
-
'munderover',
|
|
7799
|
-
'none'
|
|
7800
|
-
]);
|
|
7801
|
-
const ALLOWED_TAGS = new Set([
|
|
7802
|
-
'a',
|
|
7803
|
-
'b',
|
|
7804
|
-
'blockquote',
|
|
7805
|
-
'br',
|
|
7806
|
-
'div',
|
|
7807
|
-
'em',
|
|
7808
|
-
'i',
|
|
7809
|
-
'img',
|
|
7810
|
-
'li',
|
|
7811
|
-
'math',
|
|
7812
|
-
'maligngroup',
|
|
7813
|
-
'malignmark',
|
|
7814
|
-
'menclose',
|
|
7815
|
-
'mfrac',
|
|
7816
|
-
"mmultiscripts",
|
|
7817
|
-
'mo',
|
|
7818
|
-
'mover',
|
|
7819
|
-
'mpadded',
|
|
7820
|
-
'mphantom',
|
|
7821
|
-
"mprescripts",
|
|
7822
|
-
'mroot',
|
|
7823
|
-
'mrow',
|
|
7824
|
-
'msqrt',
|
|
7825
|
-
'msub',
|
|
7826
|
-
'msubsup',
|
|
7827
|
-
'msup',
|
|
7828
|
-
'mstyle',
|
|
7829
|
-
'mtable',
|
|
7830
|
-
'mtd',
|
|
7831
|
-
'mtext',
|
|
7832
|
-
'mtr',
|
|
7833
|
-
'munder',
|
|
7834
|
-
'munderover',
|
|
7835
|
-
'none',
|
|
7836
|
-
'ol',
|
|
7837
|
-
'p',
|
|
7838
|
-
's',
|
|
7839
|
-
'span',
|
|
7840
|
-
'strike',
|
|
7841
|
-
'strong',
|
|
7842
|
-
'sub',
|
|
7843
|
-
'sup',
|
|
7844
|
-
'table',
|
|
7845
|
-
'tbody',
|
|
7846
|
-
'td',
|
|
7847
|
-
'th',
|
|
7848
|
-
'thead',
|
|
7849
|
-
'tr',
|
|
7850
|
-
'u',
|
|
7851
|
-
'ul'
|
|
7852
|
-
]);
|
|
7853
|
-
function normalizeDocumentPageChrome(source, legacy = {}) {
|
|
7854
|
-
const defaultContent = normalizePageChromeContent(source?.default, {
|
|
7855
|
-
headerHtml: plainTextToPageChromeHtml(legacy.headerText),
|
|
7856
|
-
footerHtml: plainTextToPageChromeHtml(legacy.footerText),
|
|
7857
|
-
showPageNumber: Boolean(legacy.showPageNumbers)
|
|
7858
|
-
});
|
|
7859
|
-
return {
|
|
7860
|
-
differentFirstPage: Boolean(source?.differentFirstPage),
|
|
7861
|
-
differentOddEvenPages: Boolean(source?.differentOddEvenPages),
|
|
7862
|
-
default: defaultContent,
|
|
7863
|
-
first: normalizePageChromeContent(source?.first, EMPTY_CONTENT),
|
|
7864
|
-
even: normalizePageChromeContent(source?.even, EMPTY_CONTENT)
|
|
7865
|
-
};
|
|
7866
|
-
}
|
|
7867
|
-
function serializeDocumentPageChrome(chrome) {
|
|
7868
|
-
return JSON.stringify(normalizeDocumentPageChrome(chrome));
|
|
7916
|
+
function normalizeDocumentTextCase(value) {
|
|
7917
|
+
return 'none' === value || 'all-caps' === value || 'small-caps' === value ? value : null;
|
|
7869
7918
|
}
|
|
7870
|
-
function
|
|
7871
|
-
if (
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
if (legacy.headerText || legacy.footerText || void 0 !== legacy.showPageNumbers) return normalizeDocumentPageChrome(void 0, legacy);
|
|
7876
|
-
return normalizeDocumentPageChrome(fallback);
|
|
7877
|
-
}
|
|
7878
|
-
function resolveDocumentPageChrome(layout, sectionPage, physicalPage) {
|
|
7879
|
-
const chrome = normalizeDocumentPageChrome(layout.pageChrome, layout);
|
|
7880
|
-
const variant = chrome.differentFirstPage && 1 === sectionPage ? 'first' : chrome.differentOddEvenPages && physicalPage % 2 === 0 ? 'even' : 'default';
|
|
7881
|
-
return {
|
|
7882
|
-
variant,
|
|
7883
|
-
...chrome[variant]
|
|
7884
|
-
};
|
|
7885
|
-
}
|
|
7886
|
-
function documentPageChromeLegacyFields(chrome) {
|
|
7887
|
-
const normalized = normalizeDocumentPageChrome(chrome);
|
|
7888
|
-
return {
|
|
7889
|
-
headerText: pageChromePlainText(normalized.default.headerHtml) || void 0,
|
|
7890
|
-
footerText: pageChromePlainText(normalized.default.footerHtml) || void 0,
|
|
7891
|
-
showPageNumbers: normalized.default.showPageNumber
|
|
7892
|
-
};
|
|
7919
|
+
function documentTextCaseFromWordFlags(allCaps, smallCaps) {
|
|
7920
|
+
if (void 0 === allCaps && void 0 === smallCaps) return null;
|
|
7921
|
+
if (allCaps) return 'all-caps';
|
|
7922
|
+
if (smallCaps) return 'small-caps';
|
|
7923
|
+
return 'none';
|
|
7893
7924
|
}
|
|
7894
|
-
function
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
}
|
|
7902
|
-
|
|
7925
|
+
function applyDocumentTextCaseStyle(element, textCase) {
|
|
7926
|
+
element.dataset.officeTextCase = textCase;
|
|
7927
|
+
element.style.textTransform = 'all-caps' === textCase ? 'uppercase' : 'none';
|
|
7928
|
+
element.style.fontVariantCaps = 'small-caps' === textCase ? 'small-caps' : 'normal';
|
|
7929
|
+
}
|
|
7930
|
+
function documentTextCaseCss(textCase) {
|
|
7931
|
+
return [
|
|
7932
|
+
`text-transform: ${'all-caps' === textCase ? 'uppercase' : 'none'}`,
|
|
7933
|
+
`font-variant-caps: ${'small-caps' === textCase ? 'small-caps' : 'normal'}`
|
|
7934
|
+
].join('; ');
|
|
7935
|
+
}
|
|
7936
|
+
const DOCUMENT_SCRIPT_FONTS_ATTRIBUTE = "data-office-script-fonts";
|
|
7937
|
+
const DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE = "data-office-script-font-slot";
|
|
7938
|
+
const MAX_FONT_NAME_LENGTH = 127;
|
|
7939
|
+
const MAX_SERIALIZED_SCRIPT_FONTS_LENGTH = 4096;
|
|
7940
|
+
const SCRIPT_FONT_KEYS = new Set([
|
|
7941
|
+
'ascii',
|
|
7942
|
+
'highAnsi',
|
|
7943
|
+
'eastAsia',
|
|
7944
|
+
'complexScript',
|
|
7945
|
+
'hint'
|
|
7946
|
+
]);
|
|
7947
|
+
const SCRIPT_FONT_FACE_KEYS = new Set([
|
|
7948
|
+
'name',
|
|
7949
|
+
'theme',
|
|
7950
|
+
'resolved'
|
|
7951
|
+
]);
|
|
7952
|
+
const SCRIPT_FONT_HINTS = new Set([
|
|
7953
|
+
'default',
|
|
7954
|
+
'eastAsia',
|
|
7955
|
+
'cs'
|
|
7956
|
+
]);
|
|
7957
|
+
const work_document_script_fonts_THEME_FONTS = new Set([
|
|
7958
|
+
'majorEastAsia',
|
|
7959
|
+
'majorBidi',
|
|
7960
|
+
'majorAscii',
|
|
7961
|
+
'majorHAnsi',
|
|
7962
|
+
'minorEastAsia',
|
|
7963
|
+
'minorBidi',
|
|
7964
|
+
'minorAscii',
|
|
7965
|
+
'minorHAnsi'
|
|
7966
|
+
]);
|
|
7967
|
+
const SLOT_FALLBACK_ORDER = {
|
|
7968
|
+
ascii: [
|
|
7969
|
+
'ascii',
|
|
7970
|
+
'highAnsi',
|
|
7971
|
+
'eastAsia',
|
|
7972
|
+
'complexScript'
|
|
7973
|
+
],
|
|
7974
|
+
highAnsi: [
|
|
7975
|
+
'highAnsi',
|
|
7976
|
+
'ascii',
|
|
7977
|
+
'eastAsia',
|
|
7978
|
+
'complexScript'
|
|
7979
|
+
],
|
|
7980
|
+
eastAsia: [
|
|
7981
|
+
'eastAsia',
|
|
7982
|
+
'highAnsi',
|
|
7983
|
+
'ascii',
|
|
7984
|
+
'complexScript'
|
|
7985
|
+
],
|
|
7986
|
+
complexScript: [
|
|
7987
|
+
'complexScript',
|
|
7988
|
+
'highAnsi',
|
|
7989
|
+
'ascii',
|
|
7990
|
+
'eastAsia'
|
|
7991
|
+
]
|
|
7992
|
+
};
|
|
7993
|
+
const NEUTRAL_SCRIPT_CHARACTER = /^[\p{Cc}\p{Cf}\p{M}\p{N}\p{P}\p{S}\p{Z}]$/u;
|
|
7994
|
+
function normalizeDocumentScriptFonts(source) {
|
|
7995
|
+
if (!work_document_script_fonts_isRecordWithKeys(source, SCRIPT_FONT_KEYS)) return null;
|
|
7996
|
+
const normalized = {};
|
|
7997
|
+
for (const slot of scriptFontSlots){
|
|
7998
|
+
if (void 0 === source[slot]) continue;
|
|
7999
|
+
const face = normalizeDocumentScriptFontFace(source[slot]);
|
|
8000
|
+
if (!face) return null;
|
|
8001
|
+
normalized[slot] = face;
|
|
8002
|
+
}
|
|
8003
|
+
if (void 0 !== source.hint) {
|
|
8004
|
+
const hint = normalizeDocumentScriptFontHint(source.hint);
|
|
8005
|
+
if (!hint) return null;
|
|
8006
|
+
normalized.hint = hint;
|
|
8007
|
+
}
|
|
8008
|
+
return Object.keys(normalized).length ? normalized : null;
|
|
8009
|
+
}
|
|
8010
|
+
function serializeDocumentScriptFonts(source) {
|
|
8011
|
+
const fonts = normalizeDocumentScriptFonts(source);
|
|
8012
|
+
return fonts ? JSON.stringify(fonts) : null;
|
|
8013
|
+
}
|
|
8014
|
+
function parseDocumentScriptFonts(source) {
|
|
8015
|
+
if (!source || source.length > MAX_SERIALIZED_SCRIPT_FONTS_LENGTH) return null;
|
|
8016
|
+
try {
|
|
8017
|
+
return normalizeDocumentScriptFonts(JSON.parse(source));
|
|
8018
|
+
} catch {
|
|
8019
|
+
return null;
|
|
8020
|
+
}
|
|
8021
|
+
}
|
|
8022
|
+
function documentScriptFontsFromElement(element) {
|
|
8023
|
+
return parseDocumentScriptFonts(element.getAttribute(DOCUMENT_SCRIPT_FONTS_ATTRIBUTE));
|
|
8024
|
+
}
|
|
8025
|
+
function documentScriptFontSlotFromElement(element) {
|
|
8026
|
+
return normalizeDocumentScriptFontSlot(element.getAttribute(DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE));
|
|
8027
|
+
}
|
|
8028
|
+
function documentScriptFontsDomAttributes(source, slot) {
|
|
8029
|
+
const fonts = normalizeDocumentScriptFonts(source);
|
|
8030
|
+
const normalizedSlot = normalizeDocumentScriptFontSlot(slot);
|
|
8031
|
+
if (!fonts) return {};
|
|
8032
|
+
const serialized = serializeDocumentScriptFonts(fonts);
|
|
8033
|
+
if (!serialized) return {};
|
|
8034
|
+
const family = documentScriptFontFamily(fonts, normalizedSlot ?? documentScriptFontSlotFromHint(fonts.hint));
|
|
8035
|
+
return {
|
|
8036
|
+
[DOCUMENT_SCRIPT_FONTS_ATTRIBUTE]: serialized,
|
|
8037
|
+
...normalizedSlot ? {
|
|
8038
|
+
[DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE]: normalizedSlot
|
|
8039
|
+
} : {},
|
|
8040
|
+
...family ? {
|
|
8041
|
+
style: `font-family: ${family}`
|
|
8042
|
+
} : {}
|
|
8043
|
+
};
|
|
8044
|
+
}
|
|
8045
|
+
function documentScriptFontFamily(source, slot) {
|
|
8046
|
+
const fonts = normalizeDocumentScriptFonts(source);
|
|
8047
|
+
if (!fonts) return;
|
|
8048
|
+
const families = [];
|
|
8049
|
+
const seen = new Set();
|
|
8050
|
+
for (const candidate of documentScriptFontFallbackSlots(slot)){
|
|
8051
|
+
const family = documentScriptFontFaceFamily(fonts[candidate]);
|
|
8052
|
+
const key = family?.toLocaleLowerCase();
|
|
8053
|
+
if (!(!family || !key || seen.has(key))) {
|
|
8054
|
+
seen.add(key);
|
|
8055
|
+
families.push(cssFontFamily(family));
|
|
8056
|
+
}
|
|
8057
|
+
}
|
|
8058
|
+
return families.length ? families.join(', ') : void 0;
|
|
8059
|
+
}
|
|
8060
|
+
function documentScriptFontFallbackSlots(slot) {
|
|
8061
|
+
return SLOT_FALLBACK_ORDER[slot];
|
|
8062
|
+
}
|
|
8063
|
+
function documentScriptFontFamilyForRendering(source, slot, currentFontFamily) {
|
|
8064
|
+
const projected = documentScriptFontFamily(source, slot);
|
|
8065
|
+
const safeCurrent = safeCssFontFamilyList(currentFontFamily);
|
|
8066
|
+
if (!safeCurrent || !projected) return projected;
|
|
8067
|
+
const currentPrimary = documentFontNameFromCssFamily(safeCurrent);
|
|
8068
|
+
const projectedPrimary = documentFontNameFromCssFamily(projected);
|
|
8069
|
+
return currentPrimary && projectedPrimary && currentPrimary.toLocaleLowerCase() === projectedPrimary.toLocaleLowerCase() ? safeCurrent : projected;
|
|
8070
|
+
}
|
|
8071
|
+
function documentScriptFontDirectFamily(source, slot) {
|
|
8072
|
+
const fonts = normalizeDocumentScriptFonts(source);
|
|
8073
|
+
return fonts ? documentScriptFontFaceFamily(fonts[slot]) ?? null : null;
|
|
8074
|
+
}
|
|
8075
|
+
function documentScriptFontsForAllText(fontFamily) {
|
|
8076
|
+
const name = documentFontNameFromCssFamily(fontFamily);
|
|
8077
|
+
if (!name) return null;
|
|
8078
|
+
const face = {
|
|
8079
|
+
name,
|
|
8080
|
+
resolved: name
|
|
8081
|
+
};
|
|
8082
|
+
return {
|
|
8083
|
+
ascii: face,
|
|
8084
|
+
highAnsi: face,
|
|
8085
|
+
eastAsia: face,
|
|
8086
|
+
complexScript: face,
|
|
8087
|
+
hint: 'default'
|
|
8088
|
+
};
|
|
8089
|
+
}
|
|
8090
|
+
function patchDocumentScriptFonts(source, patch, fallbackFontFamily) {
|
|
8091
|
+
const current = normalizeDocumentScriptFonts(source) ?? documentScriptFontsForAllText(fallbackFontFamily) ?? {};
|
|
8092
|
+
const next = {
|
|
8093
|
+
...current
|
|
8094
|
+
};
|
|
8095
|
+
if (void 0 !== patch.latin) {
|
|
8096
|
+
const face = directFontFace(patch.latin);
|
|
8097
|
+
if (face) {
|
|
8098
|
+
next.ascii = face;
|
|
8099
|
+
next.highAnsi = face;
|
|
8100
|
+
} else {
|
|
8101
|
+
delete next.ascii;
|
|
8102
|
+
delete next.highAnsi;
|
|
8103
|
+
}
|
|
8104
|
+
}
|
|
8105
|
+
if (void 0 !== patch.eastAsia) {
|
|
8106
|
+
const face = directFontFace(patch.eastAsia);
|
|
8107
|
+
if (face) next.eastAsia = face;
|
|
8108
|
+
else delete next.eastAsia;
|
|
8109
|
+
}
|
|
8110
|
+
if (void 0 !== patch.complexScript) {
|
|
8111
|
+
const face = directFontFace(patch.complexScript);
|
|
8112
|
+
if (face) next.complexScript = face;
|
|
8113
|
+
else delete next.complexScript;
|
|
8114
|
+
}
|
|
8115
|
+
return normalizeDocumentScriptFonts(next);
|
|
8116
|
+
}
|
|
8117
|
+
function documentScriptFontSegments(text, hint = 'default', forceComplexScript = false) {
|
|
8118
|
+
if (!text) return [];
|
|
8119
|
+
if (forceComplexScript) return [
|
|
8120
|
+
{
|
|
8121
|
+
from: 0,
|
|
8122
|
+
to: text.length,
|
|
8123
|
+
slot: 'complexScript'
|
|
8124
|
+
}
|
|
8125
|
+
];
|
|
8126
|
+
const characters = [];
|
|
8127
|
+
let offset = 0;
|
|
8128
|
+
for (const character of text){
|
|
8129
|
+
const from = offset;
|
|
8130
|
+
offset += character.length;
|
|
8131
|
+
characters.push({
|
|
8132
|
+
from,
|
|
8133
|
+
to: offset,
|
|
8134
|
+
slot: strongDocumentScriptFontSlot(character)
|
|
8135
|
+
});
|
|
8136
|
+
}
|
|
8137
|
+
const fallback = documentScriptFontSlotFromHint(hint);
|
|
8138
|
+
let previous = null;
|
|
8139
|
+
for(let index = 0; index < characters.length; index += 1){
|
|
8140
|
+
const entry = characters[index];
|
|
8141
|
+
if (!entry) continue;
|
|
8142
|
+
if (entry.slot) {
|
|
8143
|
+
previous = entry.slot;
|
|
8144
|
+
continue;
|
|
8145
|
+
}
|
|
8146
|
+
let next = previous;
|
|
8147
|
+
if (!next) for(let cursor = index + 1; cursor < characters.length; cursor += 1){
|
|
8148
|
+
const candidate = characters[cursor]?.slot;
|
|
8149
|
+
if (candidate) {
|
|
8150
|
+
next = candidate;
|
|
8151
|
+
break;
|
|
8152
|
+
}
|
|
8153
|
+
}
|
|
8154
|
+
entry.slot = next ?? fallback;
|
|
8155
|
+
}
|
|
8156
|
+
const segments = [];
|
|
8157
|
+
for (const entry of characters){
|
|
8158
|
+
const slot = entry.slot ?? fallback;
|
|
8159
|
+
const prior = segments[segments.length - 1];
|
|
8160
|
+
if (prior?.slot === slot && prior.to === entry.from) prior.to = entry.to;
|
|
8161
|
+
else segments.push({
|
|
8162
|
+
from: entry.from,
|
|
8163
|
+
to: entry.to,
|
|
8164
|
+
slot
|
|
8165
|
+
});
|
|
8166
|
+
}
|
|
8167
|
+
return segments;
|
|
8168
|
+
}
|
|
8169
|
+
function normalizeDocumentScriptFontSlot(value) {
|
|
8170
|
+
return scriptFontSlots.includes(value) ? value : null;
|
|
8171
|
+
}
|
|
8172
|
+
function normalizeDocumentScriptFontHint(value) {
|
|
8173
|
+
return SCRIPT_FONT_HINTS.has(value) ? value : null;
|
|
8174
|
+
}
|
|
8175
|
+
function normalizeDocumentThemeFont(value) {
|
|
8176
|
+
return work_document_script_fonts_THEME_FONTS.has(value) ? value : null;
|
|
8177
|
+
}
|
|
8178
|
+
function documentScriptFontSlotFromHint(hint) {
|
|
8179
|
+
if ('eastAsia' === hint) return 'eastAsia';
|
|
8180
|
+
if ('cs' === hint) return 'complexScript';
|
|
8181
|
+
return 'ascii';
|
|
8182
|
+
}
|
|
8183
|
+
function documentFontNameFromCssFamily(value) {
|
|
8184
|
+
if ('string' != typeof value) return null;
|
|
8185
|
+
const source = value.trim();
|
|
8186
|
+
if (!source) return null;
|
|
8187
|
+
let family = '';
|
|
8188
|
+
const quote = source[0];
|
|
8189
|
+
if ('"' === quote || "'" === quote) {
|
|
8190
|
+
let closed = false;
|
|
8191
|
+
for(let index = 1; index < source.length; index += 1){
|
|
8192
|
+
const character = source[index];
|
|
8193
|
+
if (character === quote) {
|
|
8194
|
+
closed = true;
|
|
8195
|
+
break;
|
|
8196
|
+
}
|
|
8197
|
+
if ('\\' !== character) {
|
|
8198
|
+
family += character;
|
|
8199
|
+
continue;
|
|
8200
|
+
}
|
|
8201
|
+
const decoded = decodeCssEscape(source, index + 1);
|
|
8202
|
+
if (!decoded) return null;
|
|
8203
|
+
family += decoded.value;
|
|
8204
|
+
index = decoded.end - 1;
|
|
8205
|
+
}
|
|
8206
|
+
if (!closed) return null;
|
|
8207
|
+
} else family = source.split(',')[0] ?? '';
|
|
8208
|
+
return normalizeDocumentFontName(family);
|
|
8209
|
+
}
|
|
8210
|
+
function cssDocumentFontFamily(value) {
|
|
8211
|
+
const family = normalizeDocumentFontName(value);
|
|
8212
|
+
return family ? cssFontFamily(family) : null;
|
|
8213
|
+
}
|
|
8214
|
+
function normalizeDocumentFontName(value) {
|
|
8215
|
+
if ('string' != typeof value) return null;
|
|
8216
|
+
const normalized = value.trim();
|
|
8217
|
+
return normalized && normalized.length <= MAX_FONT_NAME_LENGTH && !/[\p{Cc}\p{Cs}]/u.test(normalized) ? normalized : null;
|
|
8218
|
+
}
|
|
8219
|
+
const scriptFontSlots = [
|
|
8220
|
+
'ascii',
|
|
8221
|
+
'highAnsi',
|
|
8222
|
+
'eastAsia',
|
|
8223
|
+
'complexScript'
|
|
8224
|
+
];
|
|
8225
|
+
function normalizeDocumentScriptFontFace(source) {
|
|
8226
|
+
if (!work_document_script_fonts_isRecordWithKeys(source, SCRIPT_FONT_FACE_KEYS)) return null;
|
|
8227
|
+
const name = void 0 === source.name ? void 0 : normalizeDocumentFontName(source.name);
|
|
8228
|
+
const resolved = void 0 === source.resolved ? void 0 : normalizeDocumentFontName(source.resolved);
|
|
8229
|
+
const theme = void 0 === source.theme ? void 0 : normalizeDocumentThemeFont(source.theme);
|
|
8230
|
+
if (void 0 !== source.name && !name || void 0 !== source.resolved && !resolved || null === theme || !name && !theme && !resolved) return null;
|
|
8231
|
+
return {
|
|
8232
|
+
...name ? {
|
|
8233
|
+
name
|
|
8234
|
+
} : {},
|
|
8235
|
+
...theme ? {
|
|
8236
|
+
theme
|
|
8237
|
+
} : {},
|
|
8238
|
+
...resolved ? {
|
|
8239
|
+
resolved
|
|
8240
|
+
} : {}
|
|
8241
|
+
};
|
|
8242
|
+
}
|
|
8243
|
+
function directFontFace(value) {
|
|
8244
|
+
if (null === value) return null;
|
|
8245
|
+
const name = documentFontNameFromCssFamily(value) ?? normalizeDocumentFontName(value);
|
|
8246
|
+
return name ? {
|
|
8247
|
+
name,
|
|
8248
|
+
resolved: name
|
|
8249
|
+
} : null;
|
|
8250
|
+
}
|
|
8251
|
+
function documentScriptFontFaceFamily(face) {
|
|
8252
|
+
return face?.resolved ?? face?.name;
|
|
8253
|
+
}
|
|
8254
|
+
function strongDocumentScriptFontSlot(character) {
|
|
8255
|
+
if (NEUTRAL_SCRIPT_CHARACTER.test(character)) return null;
|
|
8256
|
+
const codePoint = character.codePointAt(0);
|
|
8257
|
+
if (void 0 === codePoint) return null;
|
|
8258
|
+
if (isComplexScriptCodePoint(codePoint)) return 'complexScript';
|
|
8259
|
+
if (isEastAsianCodePoint(codePoint)) return 'eastAsia';
|
|
8260
|
+
return codePoint <= 0x7f ? 'ascii' : 'highAnsi';
|
|
8261
|
+
}
|
|
8262
|
+
function isComplexScriptCodePoint(codePoint) {
|
|
8263
|
+
return codePoint >= 0x0590 && codePoint <= 0x08ff || codePoint >= 0x0900 && codePoint <= 0x109f || codePoint >= 0x1780 && codePoint <= 0x18af || codePoint >= 0x1900 && codePoint <= 0x1cff || codePoint >= 0xa800 && codePoint <= 0xa8ff || codePoint >= 0xa980 && codePoint <= 0xa9df || codePoint >= 0xaa00 && codePoint <= 0xaa7f || codePoint >= 0xabc0 && codePoint <= 0xabff || codePoint >= 0xfb1d && codePoint <= 0xfdff || codePoint >= 0xfe70 && codePoint <= 0xfeff || codePoint >= 0x10a00 && codePoint <= 0x10fff || codePoint >= 0x11000 && codePoint <= 0x11fff || codePoint >= 0x1e900 && codePoint <= 0x1edff || codePoint >= 0x1ee00 && codePoint <= 0x1eeff;
|
|
8264
|
+
}
|
|
8265
|
+
function isEastAsianCodePoint(codePoint) {
|
|
8266
|
+
return codePoint >= 0x1100 && codePoint <= 0x11ff || codePoint >= 0x2e80 && codePoint <= 0xa4cf || codePoint >= 0xac00 && codePoint <= 0xd7af || codePoint >= 0xf900 && codePoint <= 0xfaff || codePoint >= 0xfe10 && codePoint <= 0xfe6f || codePoint >= 0xff00 && codePoint <= 0xffef || codePoint >= 0x20000 && codePoint <= 0x323af;
|
|
8267
|
+
}
|
|
8268
|
+
function cssFontFamily(value) {
|
|
8269
|
+
return /^(?:-?[\p{L}_])[\p{L}\p{N}_-]*$/u.test(value) ? value : `"${Array.from(value, cssStringCharacter).join('')}"`;
|
|
8270
|
+
}
|
|
8271
|
+
function cssStringCharacter(character) {
|
|
8272
|
+
return /[\\":;{}<>]/u.test(character) ? `\\${character.codePointAt(0)?.toString(16)} ` : character;
|
|
8273
|
+
}
|
|
8274
|
+
function safeCssFontFamilyList(value) {
|
|
8275
|
+
if ('string' != typeof value) return null;
|
|
8276
|
+
const source = value.trim();
|
|
8277
|
+
if (!source || source.length > 1024 || /[;{}]/u.test(source)) return null;
|
|
8278
|
+
const tokens = [];
|
|
8279
|
+
let start = 0;
|
|
8280
|
+
let quote = '';
|
|
8281
|
+
for(let index = 0; index < source.length; index += 1){
|
|
8282
|
+
const character = source[index] ?? '';
|
|
8283
|
+
if (quote) {
|
|
8284
|
+
if ('\\' === character) {
|
|
8285
|
+
index += 1;
|
|
8286
|
+
if (index >= source.length) return null;
|
|
8287
|
+
} else if (character === quote) quote = '';
|
|
8288
|
+
continue;
|
|
8289
|
+
}
|
|
8290
|
+
if ('"' === character || "'" === character) {
|
|
8291
|
+
quote = character;
|
|
8292
|
+
continue;
|
|
8293
|
+
}
|
|
8294
|
+
if (',' === character) {
|
|
8295
|
+
tokens.push(source.slice(start, index).trim());
|
|
8296
|
+
start = index + 1;
|
|
8297
|
+
}
|
|
8298
|
+
}
|
|
8299
|
+
if (quote) return null;
|
|
8300
|
+
tokens.push(source.slice(start).trim());
|
|
8301
|
+
return tokens.length && tokens.every(validCssFontFamilyToken) ? source : null;
|
|
8302
|
+
}
|
|
8303
|
+
function validCssFontFamilyToken(value) {
|
|
8304
|
+
if (!value) return false;
|
|
8305
|
+
if (value.startsWith('"')) return /^"(?:[^"\\\r\n\f]|\\(?:[\da-f]{1,6}\s?|[^\r\n\f]))*"$/iu.test(value) && null !== documentFontNameFromCssFamily(value);
|
|
8306
|
+
if (value.startsWith("'")) return /^'(?:[^'\\\r\n\f]|\\(?:[\da-f]{1,6}\s?|[^\r\n\f]))*'$/iu.test(value) && null !== documentFontNameFromCssFamily(value);
|
|
8307
|
+
return /[\p{L}_]/u.test(value) && /^[\p{L}_-][\p{L}\p{N}_ -]*$/u.test(value) && !/^(?:inherit|initial|revert(?:-layer)?|unset)$/iu.test(value);
|
|
8308
|
+
}
|
|
8309
|
+
function decodeCssEscape(source, start) {
|
|
8310
|
+
if (start >= source.length) return null;
|
|
8311
|
+
const hexadecimal = /^[\da-f]{1,6}/i.exec(source.slice(start))?.[0];
|
|
8312
|
+
if (hexadecimal) {
|
|
8313
|
+
const codePoint = Number.parseInt(hexadecimal, 16);
|
|
8314
|
+
if (0 === codePoint || codePoint > 0x10ffff || codePoint >= 0xd800 && codePoint <= 0xdfff) return null;
|
|
8315
|
+
let end = start + hexadecimal.length;
|
|
8316
|
+
if (/\s/u.test(source[end] ?? '')) end += 1;
|
|
8317
|
+
return {
|
|
8318
|
+
value: String.fromCodePoint(codePoint),
|
|
8319
|
+
end
|
|
8320
|
+
};
|
|
8321
|
+
}
|
|
8322
|
+
const value = source[start];
|
|
8323
|
+
return !value || /[\r\n\f]/u.test(value) ? null : {
|
|
8324
|
+
value,
|
|
8325
|
+
end: start + 1
|
|
8326
|
+
};
|
|
8327
|
+
}
|
|
8328
|
+
function work_document_script_fonts_isRecordWithKeys(value, allowed) {
|
|
8329
|
+
return 'object' == typeof value && null !== value && !Array.isArray(value) && Object.keys(value).every((key)=>allowed.has(key));
|
|
8330
|
+
}
|
|
8331
|
+
const workDocumentUnderlineStyles = [
|
|
8332
|
+
'none',
|
|
8333
|
+
'single',
|
|
8334
|
+
'words',
|
|
8335
|
+
'double',
|
|
8336
|
+
'thick',
|
|
8337
|
+
'dotted',
|
|
8338
|
+
'dottedHeavy',
|
|
8339
|
+
'dash',
|
|
8340
|
+
'dashedHeavy',
|
|
8341
|
+
'dashLong',
|
|
8342
|
+
'dashLongHeavy',
|
|
8343
|
+
'dotDash',
|
|
8344
|
+
'dashDotHeavy',
|
|
8345
|
+
'dotDotDash',
|
|
8346
|
+
'dashDotDotHeavy',
|
|
8347
|
+
'wave',
|
|
8348
|
+
'wavyHeavy',
|
|
8349
|
+
'wavyDouble'
|
|
8350
|
+
];
|
|
8351
|
+
const DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE = 'data-office-underline-style';
|
|
8352
|
+
const DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE = 'data-office-underline-color';
|
|
8353
|
+
const DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE = 'data-office-underline-theme-color';
|
|
8354
|
+
const documentUnderlineKeyboardShortcuts = {
|
|
8355
|
+
double: 'Mod-Shift-d',
|
|
8356
|
+
words: 'Mod-Shift-w'
|
|
8357
|
+
};
|
|
8358
|
+
const UNDERLINE_STYLE_BY_NORMALIZED_VALUE = new Map(workDocumentUnderlineStyles.map((style)=>[
|
|
8359
|
+
style.toLowerCase(),
|
|
8360
|
+
style
|
|
8361
|
+
]));
|
|
8362
|
+
const HEAVY_UNDERLINE_STYLES = new Set([
|
|
8363
|
+
'thick',
|
|
8364
|
+
'dottedHeavy',
|
|
8365
|
+
'dashedHeavy',
|
|
8366
|
+
'dashLongHeavy',
|
|
8367
|
+
'dashDotHeavy',
|
|
8368
|
+
'dashDotDotHeavy',
|
|
8369
|
+
'wavyHeavy'
|
|
8370
|
+
]);
|
|
8371
|
+
const DocumentUnderline = extension_underline.extend({
|
|
8372
|
+
addAttributes () {
|
|
8373
|
+
return {
|
|
8374
|
+
underlineStyle: {
|
|
8375
|
+
default: 'single',
|
|
8376
|
+
parseHTML: (element)=>documentUnderlineFormattingFromElement(element)?.style ?? 'single',
|
|
8377
|
+
renderHTML: ()=>({})
|
|
8378
|
+
},
|
|
8379
|
+
underlineColor: {
|
|
8380
|
+
default: null,
|
|
8381
|
+
parseHTML: (element)=>documentUnderlineFormattingFromElement(element)?.color ?? null,
|
|
8382
|
+
renderHTML: ()=>({})
|
|
8383
|
+
},
|
|
8384
|
+
underlineThemeColor: {
|
|
8385
|
+
default: null,
|
|
8386
|
+
parseHTML: (element)=>serializeDocxThemeReference(documentUnderlineFormattingFromElement(element)?.themeColor ?? null) ?? null,
|
|
8387
|
+
renderHTML: ()=>({})
|
|
8388
|
+
}
|
|
8389
|
+
};
|
|
8390
|
+
},
|
|
8391
|
+
renderHTML ({ mark, HTMLAttributes }) {
|
|
8392
|
+
const attributes = documentUnderlineDomAttributes(documentUnderlineFormattingFromMarkAttributes(mark.attrs));
|
|
8393
|
+
return [
|
|
8394
|
+
'u',
|
|
8395
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, attributes),
|
|
8396
|
+
0
|
|
8397
|
+
];
|
|
8398
|
+
},
|
|
8399
|
+
addCommands () {
|
|
8400
|
+
return {
|
|
8401
|
+
setUnderline: ()=>({ commands, editor })=>commands.setMark(this.name, documentUnderlineMarkAttributes(editor, 'single')),
|
|
8402
|
+
toggleUnderline: ()=>({ commands, editor })=>{
|
|
8403
|
+
const style = 'none' === documentUnderlineStyle(editor) ? 'single' : 'none';
|
|
8404
|
+
return commands.setMark(this.name, documentUnderlineMarkAttributes(editor, style));
|
|
8405
|
+
},
|
|
8406
|
+
unsetUnderline: ()=>({ commands })=>commands.unsetMark(this.name),
|
|
8407
|
+
setDocumentUnderline: (style, options = {})=>({ commands, editor })=>commands.setMark(this.name, documentUnderlineMarkAttributes(editor, style, options)),
|
|
8408
|
+
setDocumentUnderlineColor: (color, themeColor = null)=>({ commands, editor })=>{
|
|
8409
|
+
const normalizedColor = normalizeDocumentUnderlineColor(color);
|
|
8410
|
+
if (null !== color && !normalizedColor) return false;
|
|
8411
|
+
const style = documentUnderlineStyle(editor);
|
|
8412
|
+
return commands.setMark(this.name, documentUnderlineMarkAttributes(editor, 'none' === style ? 'single' : style, {
|
|
8413
|
+
color: normalizedColor,
|
|
8414
|
+
themeColor
|
|
8415
|
+
}));
|
|
8416
|
+
},
|
|
8417
|
+
toggleDocumentUnderlineStyle: (style)=>({ commands, editor })=>{
|
|
8418
|
+
const next = documentUnderlineStyle(editor) === style ? 'none' : style;
|
|
8419
|
+
return commands.setMark(this.name, documentUnderlineMarkAttributes(editor, next));
|
|
8420
|
+
}
|
|
8421
|
+
};
|
|
8422
|
+
},
|
|
8423
|
+
addKeyboardShortcuts () {
|
|
8424
|
+
return {
|
|
8425
|
+
'Mod-u': ()=>this.editor.commands.toggleUnderline(),
|
|
8426
|
+
'Mod-U': ()=>this.editor.commands.toggleUnderline(),
|
|
8427
|
+
[documentUnderlineKeyboardShortcuts.double]: ()=>this.editor.commands.toggleDocumentUnderlineStyle('double'),
|
|
8428
|
+
[documentUnderlineKeyboardShortcuts.words]: ()=>this.editor.commands.toggleDocumentUnderlineStyle('words')
|
|
8429
|
+
};
|
|
8430
|
+
}
|
|
8431
|
+
});
|
|
8432
|
+
function normalizeDocumentUnderlineStyle(value) {
|
|
8433
|
+
if ('string' != typeof value) return null;
|
|
8434
|
+
const normalized = value.trim().toLowerCase();
|
|
8435
|
+
if ('0' === normalized || 'false' === normalized || 'off' === normalized) return 'none';
|
|
8436
|
+
return UNDERLINE_STYLE_BY_NORMALIZED_VALUE.get(normalized) ?? null;
|
|
8437
|
+
}
|
|
8438
|
+
function normalizeDocumentUnderlineColor(value) {
|
|
8439
|
+
if ('string' != typeof value) return null;
|
|
8440
|
+
const source = value.trim();
|
|
8441
|
+
const hex = /^#?([\da-f]{6})$/i.exec(source)?.[1];
|
|
8442
|
+
if (hex) return `#${hex.toLowerCase()}`;
|
|
8443
|
+
const shortHex = /^#([\da-f]{3})$/i.exec(source)?.[1];
|
|
8444
|
+
if (shortHex) return `#${[
|
|
8445
|
+
...shortHex
|
|
8446
|
+
].map((channel)=>`${channel}${channel}`).join('').toLowerCase()}`;
|
|
8447
|
+
const rgb = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(?:1(?:\.0+)?|0?\.\d+))?\s*\)$/i.exec(source);
|
|
8448
|
+
if (!rgb) return null;
|
|
8449
|
+
const channels = rgb.slice(1, 4).map(Number);
|
|
8450
|
+
if (channels.some((channel)=>channel < 0 || channel > 255)) return null;
|
|
8451
|
+
return `#${channels.map((channel)=>channel.toString(16).padStart(2, '0')).join('')}`;
|
|
8452
|
+
}
|
|
8453
|
+
function documentUnderlineStyle(editor) {
|
|
8454
|
+
return documentUnderlineFormatting(editor)?.style ?? 'none';
|
|
8455
|
+
}
|
|
8456
|
+
function documentUnderlineColor(editor) {
|
|
8457
|
+
return documentUnderlineFormatting(editor)?.color ?? null;
|
|
8458
|
+
}
|
|
8459
|
+
function documentUnderlineFormatting(editor) {
|
|
8460
|
+
if (editor.isDestroyed || !editor.isActive('underline')) return null;
|
|
8461
|
+
return documentUnderlineFormattingFromMarkAttributes(editor.getAttributes('underline'));
|
|
8462
|
+
}
|
|
8463
|
+
function documentUnderlineFormattingFromElement(element) {
|
|
8464
|
+
const declaredStyle = normalizeDocumentUnderlineStyle(element.getAttribute(DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE));
|
|
8465
|
+
const cssLine = element.style.textDecorationLine.trim().toLowerCase().split(/\s+/);
|
|
8466
|
+
const style = declaredStyle ?? documentUnderlineStyleFromCss(element) ?? ('u' === element.tagName.toLowerCase() ? 'single' : cssLine.includes('none') ? 'none' : null);
|
|
8467
|
+
if (!style) return null;
|
|
8468
|
+
const themeColor = parseDocxThemeReference(element.getAttribute(DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE));
|
|
8469
|
+
const color = normalizeDocumentUnderlineColor(element.getAttribute(DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE)) ?? normalizeDocumentUnderlineColor(element.style.textDecorationColor) ?? themeColor?.resolved;
|
|
8470
|
+
return {
|
|
8471
|
+
style,
|
|
8472
|
+
...color ? {
|
|
8473
|
+
color
|
|
8474
|
+
} : {},
|
|
8475
|
+
...themeColor ? {
|
|
8476
|
+
themeColor
|
|
8477
|
+
} : {}
|
|
8478
|
+
};
|
|
8479
|
+
}
|
|
8480
|
+
function documentUnderlineDomAttributes(formatting) {
|
|
8481
|
+
const style = normalizeDocumentUnderlineStyle(formatting.style) ?? 'single';
|
|
8482
|
+
const color = normalizeDocumentUnderlineColor(formatting.color);
|
|
8483
|
+
const themeColor = serializeDocxThemeReference(formatting.themeColor ?? null);
|
|
8484
|
+
const declarations = documentUnderlineCssDeclarations({
|
|
8485
|
+
style,
|
|
8486
|
+
...color ? {
|
|
8487
|
+
color
|
|
8488
|
+
} : {}
|
|
8489
|
+
});
|
|
8490
|
+
return {
|
|
8491
|
+
[DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE]: style,
|
|
8492
|
+
...color ? {
|
|
8493
|
+
[DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE]: color
|
|
8494
|
+
} : {},
|
|
8495
|
+
...themeColor ? {
|
|
8496
|
+
[DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE]: themeColor
|
|
8497
|
+
} : {},
|
|
8498
|
+
style: declarations.join('; ')
|
|
8499
|
+
};
|
|
8500
|
+
}
|
|
8501
|
+
function documentUnderlineMarkAttributes(editor, style, options = {}) {
|
|
8502
|
+
const current = documentUnderlineFormatting(editor);
|
|
8503
|
+
const color = void 0 === options.color ? current?.color ?? null : normalizeDocumentUnderlineColor(options.color);
|
|
8504
|
+
const requestedTheme = void 0 === options.themeColor ? current?.themeColor ?? null : documentUnderlineThemeReference(options.themeColor);
|
|
8505
|
+
const themeColor = requestedTheme && color === requestedTheme.resolved ? serializeDocxThemeReference(requestedTheme) ?? null : null;
|
|
8506
|
+
return {
|
|
8507
|
+
underlineStyle: style,
|
|
8508
|
+
underlineColor: color,
|
|
8509
|
+
underlineThemeColor: themeColor
|
|
8510
|
+
};
|
|
8511
|
+
}
|
|
8512
|
+
function documentUnderlineFormattingFromMarkAttributes(attributes) {
|
|
8513
|
+
const style = normalizeDocumentUnderlineStyle(attributes.underlineStyle) ?? 'single';
|
|
8514
|
+
const themeColor = 'string' == typeof attributes.underlineThemeColor ? parseDocxThemeReference(attributes.underlineThemeColor) : null;
|
|
8515
|
+
const color = normalizeDocumentUnderlineColor(attributes.underlineColor) ?? themeColor?.resolved;
|
|
8516
|
+
return {
|
|
8517
|
+
style,
|
|
8518
|
+
...color ? {
|
|
8519
|
+
color
|
|
8520
|
+
} : {},
|
|
8521
|
+
...themeColor ? {
|
|
8522
|
+
themeColor
|
|
8523
|
+
} : {}
|
|
8524
|
+
};
|
|
8525
|
+
}
|
|
8526
|
+
function documentUnderlineThemeReference(value) {
|
|
8527
|
+
if ('string' == typeof value) return parseDocxThemeReference(value);
|
|
8528
|
+
return value ? parseDocxThemeReference(serializeDocxThemeReference(value)) : null;
|
|
8529
|
+
}
|
|
8530
|
+
function documentUnderlineStyleFromCss(element) {
|
|
8531
|
+
const line = element.style.textDecorationLine.trim().toLowerCase().split(/\s+/);
|
|
8532
|
+
if (line.includes('none')) return 'none';
|
|
8533
|
+
if (!line.includes('underline')) return null;
|
|
8534
|
+
switch(element.style.textDecorationStyle.trim().toLowerCase()){
|
|
8535
|
+
case 'double':
|
|
8536
|
+
return 'double';
|
|
8537
|
+
case 'dotted':
|
|
8538
|
+
return 'dotted';
|
|
8539
|
+
case 'dashed':
|
|
8540
|
+
return 'dash';
|
|
8541
|
+
case 'wavy':
|
|
8542
|
+
return 'wave';
|
|
8543
|
+
default:
|
|
8544
|
+
return 'single';
|
|
8545
|
+
}
|
|
8546
|
+
}
|
|
8547
|
+
function documentUnderlineCssDeclarations(formatting) {
|
|
8548
|
+
const { style, color } = formatting;
|
|
8549
|
+
if ('none' === style) return [
|
|
8550
|
+
'text-decoration-line: none'
|
|
8551
|
+
];
|
|
8552
|
+
const declarations = [
|
|
8553
|
+
'text-decoration-line: underline',
|
|
8554
|
+
`text-decoration-style: ${documentUnderlineCssStyle(style)}`,
|
|
8555
|
+
'text-underline-offset: 0.12em',
|
|
8556
|
+
'text-decoration-skip-ink: auto'
|
|
8557
|
+
];
|
|
8558
|
+
if (color) declarations.push(`text-decoration-color: ${color}`);
|
|
8559
|
+
if (HEAVY_UNDERLINE_STYLES.has(style)) declarations.push('text-decoration-thickness: 0.14em');
|
|
8560
|
+
return declarations;
|
|
8561
|
+
}
|
|
8562
|
+
function documentUnderlineCssStyle(style) {
|
|
8563
|
+
if ('double' === style) return 'double';
|
|
8564
|
+
if ('dotted' === style || 'dottedHeavy' === style) return 'dotted';
|
|
8565
|
+
if ('dash' === style || 'dashedHeavy' === style || 'dashLong' === style || 'dashLongHeavy' === style || 'dotDash' === style || 'dashDotHeavy' === style || 'dotDotDash' === style || 'dashDotDotHeavy' === style) return 'dashed';
|
|
8566
|
+
if ('wave' === style || 'wavyHeavy' === style || 'wavyDouble' === style) return 'wavy';
|
|
8567
|
+
return 'solid';
|
|
8568
|
+
}
|
|
8569
|
+
const workDocumentStrikeStyles = [
|
|
8570
|
+
'none',
|
|
8571
|
+
'single',
|
|
8572
|
+
'double'
|
|
8573
|
+
];
|
|
8574
|
+
const DOCUMENT_STRIKE_STYLE_ATTRIBUTE = 'data-office-strike-style';
|
|
8575
|
+
const STRIKE_STYLE_BY_NORMALIZED_VALUE = new Map(workDocumentStrikeStyles.map((style)=>[
|
|
8576
|
+
style,
|
|
8577
|
+
style
|
|
8578
|
+
]));
|
|
8579
|
+
const DocumentStrike = extension_strike.extend({
|
|
8580
|
+
addAttributes () {
|
|
8581
|
+
return {
|
|
8582
|
+
strikeStyle: {
|
|
8583
|
+
default: 'single',
|
|
8584
|
+
parseHTML: (element)=>documentStrikeFormattingFromElement(element)?.style ?? 'single',
|
|
8585
|
+
renderHTML: ()=>({})
|
|
8586
|
+
}
|
|
8587
|
+
};
|
|
8588
|
+
},
|
|
8589
|
+
renderHTML ({ mark, HTMLAttributes }) {
|
|
8590
|
+
return [
|
|
8591
|
+
's',
|
|
8592
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, documentStrikeDomAttributes(documentStrikeFormattingFromMarkAttributes(mark.attrs))),
|
|
8593
|
+
0
|
|
8594
|
+
];
|
|
8595
|
+
},
|
|
8596
|
+
addCommands () {
|
|
8597
|
+
return {
|
|
8598
|
+
setStrike: ()=>({ commands })=>commands.setMark(this.name, {
|
|
8599
|
+
strikeStyle: 'single'
|
|
8600
|
+
}),
|
|
8601
|
+
toggleStrike: ()=>({ commands, editor })=>commands.setMark(this.name, {
|
|
8602
|
+
strikeStyle: 'none' === documentStrikeStyle(editor) ? 'single' : 'none'
|
|
8603
|
+
}),
|
|
8604
|
+
unsetStrike: ()=>({ commands })=>commands.unsetMark(this.name),
|
|
8605
|
+
setDocumentStrike: (style)=>({ commands })=>commands.setMark(this.name, {
|
|
8606
|
+
strikeStyle: style
|
|
8607
|
+
}),
|
|
8608
|
+
toggleDocumentStrikeStyle: (style)=>({ commands, editor })=>commands.setMark(this.name, {
|
|
8609
|
+
strikeStyle: documentStrikeStyle(editor) === style ? 'none' : style
|
|
8610
|
+
})
|
|
8611
|
+
};
|
|
8612
|
+
},
|
|
8613
|
+
addKeyboardShortcuts () {
|
|
8614
|
+
return {};
|
|
8615
|
+
}
|
|
8616
|
+
});
|
|
8617
|
+
function normalizeDocumentStrikeStyle(value) {
|
|
8618
|
+
if ('string' != typeof value) return null;
|
|
8619
|
+
const normalized = value.trim().toLowerCase();
|
|
8620
|
+
if ('0' === normalized || 'false' === normalized || 'off' === normalized) return 'none';
|
|
8621
|
+
return STRIKE_STYLE_BY_NORMALIZED_VALUE.get(normalized) ?? null;
|
|
8622
|
+
}
|
|
8623
|
+
function documentStrikeStyle(editor) {
|
|
8624
|
+
return documentStrikeFormatting(editor)?.style ?? 'none';
|
|
8625
|
+
}
|
|
8626
|
+
function documentStrikeFormatting(editor) {
|
|
8627
|
+
if (editor.isDestroyed || !editor.isActive('strike')) return null;
|
|
8628
|
+
return documentStrikeFormattingFromMarkAttributes(editor.getAttributes('strike'));
|
|
8629
|
+
}
|
|
8630
|
+
function documentStrikeFormattingFromElement(element) {
|
|
8631
|
+
const declared = normalizeDocumentStrikeStyle(element.getAttribute(DOCUMENT_STRIKE_STYLE_ATTRIBUTE));
|
|
8632
|
+
const lines = element.style.textDecorationLine.trim().toLowerCase().split(/\s+/);
|
|
8633
|
+
const style = declared ?? (lines.includes('none') ? 'none' : lines.includes('line-through') ? 'double' === element.style.textDecorationStyle.trim().toLowerCase() ? 'double' : 'single' : [
|
|
8634
|
+
'del',
|
|
8635
|
+
's',
|
|
8636
|
+
'strike'
|
|
8637
|
+
].includes(element.tagName.toLowerCase()) ? 'single' : null);
|
|
8638
|
+
return style ? {
|
|
8639
|
+
style
|
|
8640
|
+
} : null;
|
|
8641
|
+
}
|
|
8642
|
+
function documentStrikeDomAttributes(formatting) {
|
|
8643
|
+
const style = normalizeDocumentStrikeStyle(formatting.style) ?? 'single';
|
|
8644
|
+
return {
|
|
8645
|
+
[DOCUMENT_STRIKE_STYLE_ATTRIBUTE]: style,
|
|
8646
|
+
style: 'none' === style ? 'text-decoration-line: none' : `text-decoration-line: line-through; text-decoration-style: ${'double' === style ? 'double' : 'solid'}; text-decoration-skip-ink: none`
|
|
8647
|
+
};
|
|
8648
|
+
}
|
|
8649
|
+
function documentStrikeFormattingFromMarkAttributes(attributes) {
|
|
8650
|
+
return {
|
|
8651
|
+
style: normalizeDocumentStrikeStyle(attributes.strikeStyle) ?? 'single'
|
|
8652
|
+
};
|
|
8653
|
+
}
|
|
8654
|
+
const EMPTY_CONTENT = {
|
|
8655
|
+
headerHtml: '',
|
|
8656
|
+
footerHtml: '',
|
|
8657
|
+
showPageNumber: false
|
|
8658
|
+
};
|
|
8659
|
+
const IMAGE_IDENTITY_ATTRIBUTES = [
|
|
8660
|
+
'data-office-image-object-id',
|
|
8661
|
+
'data-office-image-doc-properties-id',
|
|
8662
|
+
'data-office-image-anchor-id',
|
|
8663
|
+
'data-office-image-edit-id'
|
|
8664
|
+
];
|
|
8665
|
+
const PARAGRAPH_IDENTITY_ATTRIBUTES = [
|
|
8666
|
+
DOCUMENT_PARAGRAPH_ID_ATTRIBUTE,
|
|
8667
|
+
DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE
|
|
8668
|
+
];
|
|
8669
|
+
const PARAGRAPH_DEFAULT_COLLAPSED_ATTRIBUTE = 'data-office-default-collapsed';
|
|
8670
|
+
const PARAGRAPH_BORDERS_ATTRIBUTE = DOCUMENT_PARAGRAPH_BORDERS_ATTRIBUTE;
|
|
8671
|
+
const PARAGRAPH_SHADING_ATTRIBUTE = 'data-office-paragraph-shading';
|
|
8672
|
+
const TABLE_ROW_IDENTITY_ATTRIBUTES = [
|
|
8673
|
+
DOCUMENT_TABLE_ROW_ID_ATTRIBUTE,
|
|
8674
|
+
DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE
|
|
8675
|
+
];
|
|
8676
|
+
const EQUATION_ATTRIBUTES = [
|
|
8677
|
+
'aria-label',
|
|
8678
|
+
'class',
|
|
8679
|
+
'contenteditable',
|
|
8680
|
+
'data-document-equation',
|
|
8681
|
+
'data-equation-display',
|
|
8682
|
+
'data-equation-model',
|
|
8683
|
+
'role'
|
|
8684
|
+
];
|
|
8685
|
+
const MATHML_ATTRIBUTES = new Set([
|
|
8686
|
+
'accent',
|
|
8687
|
+
'accentunder',
|
|
8688
|
+
'align',
|
|
8689
|
+
'bevelled',
|
|
8690
|
+
'columnalign',
|
|
8691
|
+
'depth',
|
|
8692
|
+
'dir',
|
|
8693
|
+
'display',
|
|
8694
|
+
'fence',
|
|
8695
|
+
'height',
|
|
8696
|
+
'lang',
|
|
8697
|
+
'linethickness',
|
|
8698
|
+
'mathbackground',
|
|
8699
|
+
'mathcolor',
|
|
8700
|
+
'mathsize',
|
|
8701
|
+
'mathvariant',
|
|
8702
|
+
'notation',
|
|
8703
|
+
'rowspacing',
|
|
8704
|
+
"scriptlevel",
|
|
8705
|
+
'separator',
|
|
8706
|
+
'style',
|
|
8707
|
+
'width',
|
|
8708
|
+
'xmlns'
|
|
8709
|
+
]);
|
|
8710
|
+
const work_document_page_chrome_MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
|
8711
|
+
const MATHML_TAGS = new Set([
|
|
8712
|
+
'math',
|
|
8713
|
+
'maligngroup',
|
|
8714
|
+
'malignmark',
|
|
8715
|
+
'menclose',
|
|
8716
|
+
'mfrac',
|
|
8717
|
+
"mmultiscripts",
|
|
8718
|
+
'mo',
|
|
8719
|
+
'mover',
|
|
8720
|
+
'mpadded',
|
|
8721
|
+
'mphantom',
|
|
8722
|
+
"mprescripts",
|
|
8723
|
+
'mroot',
|
|
8724
|
+
'mrow',
|
|
8725
|
+
'msqrt',
|
|
8726
|
+
'msub',
|
|
8727
|
+
'msubsup',
|
|
8728
|
+
'msup',
|
|
8729
|
+
'mstyle',
|
|
8730
|
+
'mtable',
|
|
8731
|
+
'mtd',
|
|
8732
|
+
'mtext',
|
|
8733
|
+
'mtr',
|
|
8734
|
+
'munder',
|
|
8735
|
+
'munderover',
|
|
8736
|
+
'none'
|
|
8737
|
+
]);
|
|
8738
|
+
const ALLOWED_TAGS = new Set([
|
|
8739
|
+
'a',
|
|
8740
|
+
'b',
|
|
8741
|
+
'blockquote',
|
|
8742
|
+
'br',
|
|
8743
|
+
'div',
|
|
8744
|
+
'em',
|
|
8745
|
+
'i',
|
|
8746
|
+
'img',
|
|
8747
|
+
'li',
|
|
8748
|
+
'math',
|
|
8749
|
+
'maligngroup',
|
|
8750
|
+
'malignmark',
|
|
8751
|
+
'menclose',
|
|
8752
|
+
'mfrac',
|
|
8753
|
+
"mmultiscripts",
|
|
8754
|
+
'mo',
|
|
8755
|
+
'mover',
|
|
8756
|
+
'mpadded',
|
|
8757
|
+
'mphantom',
|
|
8758
|
+
"mprescripts",
|
|
8759
|
+
'mroot',
|
|
8760
|
+
'mrow',
|
|
8761
|
+
'msqrt',
|
|
8762
|
+
'msub',
|
|
8763
|
+
'msubsup',
|
|
8764
|
+
'msup',
|
|
8765
|
+
'mstyle',
|
|
8766
|
+
'mtable',
|
|
8767
|
+
'mtd',
|
|
8768
|
+
'mtext',
|
|
8769
|
+
'mtr',
|
|
8770
|
+
'munder',
|
|
8771
|
+
'munderover',
|
|
8772
|
+
'none',
|
|
8773
|
+
'ol',
|
|
8774
|
+
'p',
|
|
8775
|
+
's',
|
|
8776
|
+
'span',
|
|
8777
|
+
'strike',
|
|
8778
|
+
'strong',
|
|
8779
|
+
'sub',
|
|
8780
|
+
'sup',
|
|
8781
|
+
'table',
|
|
8782
|
+
'tbody',
|
|
8783
|
+
'td',
|
|
8784
|
+
'th',
|
|
8785
|
+
'thead',
|
|
8786
|
+
'tr',
|
|
8787
|
+
'u',
|
|
8788
|
+
'ul'
|
|
8789
|
+
]);
|
|
8790
|
+
function normalizeDocumentPageChrome(source, legacy = {}) {
|
|
8791
|
+
const defaultContent = normalizePageChromeContent(source?.default, {
|
|
8792
|
+
headerHtml: plainTextToPageChromeHtml(legacy.headerText),
|
|
8793
|
+
footerHtml: plainTextToPageChromeHtml(legacy.footerText),
|
|
8794
|
+
showPageNumber: Boolean(legacy.showPageNumbers)
|
|
8795
|
+
});
|
|
8796
|
+
return {
|
|
8797
|
+
differentFirstPage: Boolean(source?.differentFirstPage),
|
|
8798
|
+
differentOddEvenPages: Boolean(source?.differentOddEvenPages),
|
|
8799
|
+
default: defaultContent,
|
|
8800
|
+
first: normalizePageChromeContent(source?.first, EMPTY_CONTENT),
|
|
8801
|
+
even: normalizePageChromeContent(source?.even, EMPTY_CONTENT)
|
|
8802
|
+
};
|
|
8803
|
+
}
|
|
8804
|
+
function serializeDocumentPageChrome(chrome) {
|
|
8805
|
+
return JSON.stringify(normalizeDocumentPageChrome(chrome));
|
|
8806
|
+
}
|
|
8807
|
+
function parseDocumentPageChrome(source, legacy = {}, fallback) {
|
|
8808
|
+
if (source?.trim()) try {
|
|
8809
|
+
const parsed = JSON.parse(source);
|
|
8810
|
+
return normalizeDocumentPageChrome(parsed, legacy);
|
|
8811
|
+
} catch {}
|
|
8812
|
+
if (legacy.headerText || legacy.footerText || void 0 !== legacy.showPageNumbers) return normalizeDocumentPageChrome(void 0, legacy);
|
|
8813
|
+
return normalizeDocumentPageChrome(fallback);
|
|
8814
|
+
}
|
|
8815
|
+
function resolveDocumentPageChrome(layout, sectionPage, physicalPage) {
|
|
8816
|
+
const chrome = normalizeDocumentPageChrome(layout.pageChrome, layout);
|
|
8817
|
+
const variant = chrome.differentFirstPage && 1 === sectionPage ? 'first' : chrome.differentOddEvenPages && physicalPage % 2 === 0 ? 'even' : 'default';
|
|
8818
|
+
return {
|
|
8819
|
+
variant,
|
|
8820
|
+
...chrome[variant]
|
|
8821
|
+
};
|
|
8822
|
+
}
|
|
8823
|
+
function documentPageChromeLegacyFields(chrome) {
|
|
8824
|
+
const normalized = normalizeDocumentPageChrome(chrome);
|
|
8825
|
+
return {
|
|
8826
|
+
headerText: pageChromePlainText(normalized.default.headerHtml) || void 0,
|
|
8827
|
+
footerText: pageChromePlainText(normalized.default.footerHtml) || void 0,
|
|
8828
|
+
showPageNumbers: normalized.default.showPageNumber
|
|
8829
|
+
};
|
|
8830
|
+
}
|
|
8831
|
+
function updateDocumentPageChromeVariant(chrome, variant, patch) {
|
|
8832
|
+
const normalized = normalizeDocumentPageChrome(chrome);
|
|
8833
|
+
return {
|
|
8834
|
+
...normalized,
|
|
8835
|
+
[variant]: normalizePageChromeContent({
|
|
8836
|
+
...normalized[variant],
|
|
8837
|
+
...patch
|
|
8838
|
+
}, EMPTY_CONTENT)
|
|
8839
|
+
};
|
|
7903
8840
|
}
|
|
7904
8841
|
function pageChromePlainText(source) {
|
|
7905
8842
|
if (!source.trim()) return '';
|
|
@@ -7971,6 +8908,27 @@ function sanitizeAttributes(element, tag) {
|
|
|
7971
8908
|
'justify'
|
|
7972
8909
|
].includes(element.style.textAlign) ? element.style.textAlign : '';
|
|
7973
8910
|
const color = element.style.color;
|
|
8911
|
+
const scriptFonts = 'span' === tag ? documentScriptFontsFromElement(element) : null;
|
|
8912
|
+
const scriptFontSlot = 'span' === tag ? documentScriptFontSlotFromElement(element) : null;
|
|
8913
|
+
const scriptFontAttributes = scriptFonts ? documentScriptFontsDomAttributes(scriptFonts, scriptFontSlot) : {};
|
|
8914
|
+
const fontFamily = (scriptFonts ? documentScriptFontFamilyForRendering(scriptFonts, scriptFontSlot ?? documentScriptFontSlotFromHint(scriptFonts.hint), element.style.fontFamily) : null) ?? cssDocumentFontFamily(documentFontNameFromCssFamily(element.style.fontFamily));
|
|
8915
|
+
const fontSize = 'span' === tag ? normalizedPageChromeFontSize(element.style.fontSize) : null;
|
|
8916
|
+
const textCase = 'span' === tag ? normalizeDocumentTextCase(element.getAttribute(DOCUMENT_TEXT_CASE_ATTRIBUTE)) : null;
|
|
8917
|
+
const characterSpacing = 'span' === tag ? documentCharacterSpacingTwipsFromElement(element) : null;
|
|
8918
|
+
const characterScale = 'span' === tag ? documentCharacterScalePercentFromElement(element) : null;
|
|
8919
|
+
const characterScaleAttributes = documentCharacterScaleDomAttributes(characterScale);
|
|
8920
|
+
const characterPosition = 'span' === tag ? documentCharacterPositionHalfPointsFromElement(element) : null;
|
|
8921
|
+
const characterPositionAttributes = documentCharacterPositionDomAttributes(characterPosition);
|
|
8922
|
+
const characterSpacingAttributes = documentCharacterSpacingDomAttributes(characterSpacing);
|
|
8923
|
+
const kerningThreshold = 'span' === tag ? documentKerningThresholdHalfPointsFromElement(element) : null;
|
|
8924
|
+
const kerningAttributes = documentKerningDomAttributes(kerningThreshold, fontSize);
|
|
8925
|
+
const emphasisMark = 'span' === tag ? documentEmphasisMarkFromElement(element) : null;
|
|
8926
|
+
const emphasisAttributes = documentEmphasisMarkDomAttributes(emphasisMark);
|
|
8927
|
+
const hiddenText = 'span' === tag ? documentHiddenTextFromElement(element) : null;
|
|
8928
|
+
const underline = 'u' === tag ? documentUnderlineFormattingFromElement(element) : null;
|
|
8929
|
+
const underlineAttributes = underline ? documentUnderlineDomAttributes(underline) : {};
|
|
8930
|
+
const strike = 's' === tag || 'strike' === tag ? documentStrikeFormattingFromElement(element) : null;
|
|
8931
|
+
const strikeAttributes = strike ? documentStrikeDomAttributes(strike) : {};
|
|
7974
8932
|
const paragraphShading = 'p' === tag ? parseDocumentParagraphShadingElement(element) : null;
|
|
7975
8933
|
const shadingAttributes = documentParagraphShadingDomAttributes(paragraphShading);
|
|
7976
8934
|
const paragraphBorders = 'p' === tag ? parseDocumentParagraphBordersElement(element) : null;
|
|
@@ -7979,9 +8937,31 @@ function sanitizeAttributes(element, tag) {
|
|
|
7979
8937
|
element.removeAttribute('style');
|
|
7980
8938
|
element.removeAttribute(PARAGRAPH_BORDERS_ATTRIBUTE);
|
|
7981
8939
|
element.removeAttribute(PARAGRAPH_SHADING_ATTRIBUTE);
|
|
8940
|
+
element.removeAttribute(DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE);
|
|
8941
|
+
element.removeAttribute(DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE);
|
|
8942
|
+
element.removeAttribute(DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE);
|
|
8943
|
+
element.removeAttribute(DOCUMENT_STRIKE_STYLE_ATTRIBUTE);
|
|
8944
|
+
element.removeAttribute(DOCUMENT_CHARACTER_SCALE_ATTRIBUTE);
|
|
8945
|
+
element.removeAttribute(DOCUMENT_CHARACTER_POSITION_ATTRIBUTE);
|
|
8946
|
+
element.removeAttribute(DOCUMENT_CHARACTER_SPACING_ATTRIBUTE);
|
|
8947
|
+
element.removeAttribute(DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE);
|
|
8948
|
+
element.removeAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE);
|
|
8949
|
+
element.removeAttribute(DOCUMENT_HIDDEN_TEXT_ATTRIBUTE);
|
|
8950
|
+
element.removeAttribute(DOCUMENT_SCRIPT_FONTS_ATTRIBUTE);
|
|
8951
|
+
element.removeAttribute(DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE);
|
|
7982
8952
|
const styles = [
|
|
7983
8953
|
textAlign ? `text-align: ${textAlign}` : '',
|
|
7984
8954
|
color ? `color: ${color}` : '',
|
|
8955
|
+
fontFamily ? `font-family: ${fontFamily}` : '',
|
|
8956
|
+
fontSize ? `font-size: ${fontSize}` : '',
|
|
8957
|
+
textCase ? documentTextCaseCss(textCase) : '',
|
|
8958
|
+
characterScaleAttributes.style ?? '',
|
|
8959
|
+
characterPositionAttributes.style ?? '',
|
|
8960
|
+
characterSpacingAttributes.style ?? '',
|
|
8961
|
+
kerningAttributes.style ?? '',
|
|
8962
|
+
emphasisAttributes.style ?? '',
|
|
8963
|
+
underlineAttributes.style ?? '',
|
|
8964
|
+
strikeAttributes.style ?? '',
|
|
7985
8965
|
borderAttributes.style ?? '',
|
|
7986
8966
|
shadingAttributes.style ?? ''
|
|
7987
8967
|
].filter(Boolean);
|
|
@@ -8014,6 +8994,23 @@ function sanitizeAttributes(element, tag) {
|
|
|
8014
8994
|
normalizeParagraphDefaultCollapsedAttribute(element);
|
|
8015
8995
|
}
|
|
8016
8996
|
if ('tr' === tag) normalizeTableRowIdentityAttributes(element);
|
|
8997
|
+
if ('u' === tag) {
|
|
8998
|
+
for (const [name, value] of Object.entries(underlineAttributes))if ('style' !== name) element.setAttribute(name, value);
|
|
8999
|
+
}
|
|
9000
|
+
if ('s' === tag || 'strike' === tag) {
|
|
9001
|
+
for (const [name, value] of Object.entries(strikeAttributes))if ('style' !== name) element.setAttribute(name, value);
|
|
9002
|
+
}
|
|
9003
|
+
if ('span' === tag && textCase) element.setAttribute(DOCUMENT_TEXT_CASE_ATTRIBUTE, textCase);
|
|
9004
|
+
else element.removeAttribute(DOCUMENT_TEXT_CASE_ATTRIBUTE);
|
|
9005
|
+
if ('span' === tag && null !== characterSpacing) element.setAttribute(DOCUMENT_CHARACTER_SPACING_ATTRIBUTE, String(characterSpacing));
|
|
9006
|
+
if ('span' === tag && null !== characterScale) element.setAttribute(DOCUMENT_CHARACTER_SCALE_ATTRIBUTE, String(characterScale));
|
|
9007
|
+
if ('span' === tag && null !== characterPosition) element.setAttribute(DOCUMENT_CHARACTER_POSITION_ATTRIBUTE, String(characterPosition));
|
|
9008
|
+
if ('span' === tag && null !== kerningThreshold) element.setAttribute(DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE, String(kerningThreshold));
|
|
9009
|
+
if ('span' === tag && null !== emphasisMark) element.setAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE, emphasisMark);
|
|
9010
|
+
if ('span' === tag && null !== hiddenText) element.setAttribute(DOCUMENT_HIDDEN_TEXT_ATTRIBUTE, String(hiddenText));
|
|
9011
|
+
if ('span' === tag && scriptFonts) {
|
|
9012
|
+
for (const [name, value] of Object.entries(scriptFontAttributes))if ('style' !== name) element.setAttribute(name, value);
|
|
9013
|
+
}
|
|
8017
9014
|
if ('ltr' === direction || 'rtl' === direction) element.setAttribute('dir', direction);
|
|
8018
9015
|
else element.removeAttribute('dir');
|
|
8019
9016
|
const allowed = 'span' === tag && 'true' === element.dataset.documentEquation ? new Set(EQUATION_ATTRIBUTES) : 'a' === tag ? new Set([
|
|
@@ -8050,10 +9047,37 @@ function sanitizeAttributes(element, tag) {
|
|
|
8050
9047
|
'colspan',
|
|
8051
9048
|
'dir',
|
|
8052
9049
|
'rowspan',
|
|
8053
|
-
'style'
|
|
9050
|
+
'style',
|
|
9051
|
+
...'span' === tag ? [
|
|
9052
|
+
DOCUMENT_TEXT_CASE_ATTRIBUTE,
|
|
9053
|
+
DOCUMENT_CHARACTER_SCALE_ATTRIBUTE,
|
|
9054
|
+
DOCUMENT_CHARACTER_POSITION_ATTRIBUTE,
|
|
9055
|
+
DOCUMENT_CHARACTER_SPACING_ATTRIBUTE,
|
|
9056
|
+
DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE,
|
|
9057
|
+
DOCUMENT_EMPHASIS_MARK_ATTRIBUTE,
|
|
9058
|
+
DOCUMENT_HIDDEN_TEXT_ATTRIBUTE,
|
|
9059
|
+
DOCUMENT_SCRIPT_FONTS_ATTRIBUTE,
|
|
9060
|
+
DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE
|
|
9061
|
+
] : [],
|
|
9062
|
+
...'u' === tag ? [
|
|
9063
|
+
DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE,
|
|
9064
|
+
DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE,
|
|
9065
|
+
DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE
|
|
9066
|
+
] : [],
|
|
9067
|
+
...'s' === tag || 'strike' === tag ? [
|
|
9068
|
+
DOCUMENT_STRIKE_STYLE_ATTRIBUTE
|
|
9069
|
+
] : []
|
|
8054
9070
|
]);
|
|
8055
9071
|
for (const attribute of Array.from(element.attributes))if (!allowed.has(attribute.name.toLowerCase())) element.removeAttribute(attribute.name);
|
|
8056
9072
|
}
|
|
9073
|
+
function normalizedPageChromeFontSize(value) {
|
|
9074
|
+
const match = /^(\d+(?:\.\d*)?|\.\d+)(pt|px)$/iu.exec(value.trim());
|
|
9075
|
+
if (!match) return null;
|
|
9076
|
+
const amount = Number(match[1]);
|
|
9077
|
+
const points = match[2]?.toLowerCase() === 'px' ? 0.75 * amount : amount;
|
|
9078
|
+
if (!Number.isFinite(points) || points <= 0 || points > 512 || !Number.isSafeInteger(2 * points)) return null;
|
|
9079
|
+
return `${Number(points.toFixed(1))}pt`;
|
|
9080
|
+
}
|
|
8057
9081
|
function normalizeTableRowIdentityAttributes(element) {
|
|
8058
9082
|
const identity = normalizeDocumentTableRowIdentity({
|
|
8059
9083
|
rowId: element.getAttribute(TABLE_ROW_IDENTITY_ATTRIBUTES[0]),
|
|
@@ -8934,20 +9958,35 @@ const CHARACTER_FORMAT_MARK_ORDER = new Map(DOCUMENT_CHARACTER_FORMAT_MARKS.map(
|
|
|
8934
9958
|
name,
|
|
8935
9959
|
index
|
|
8936
9960
|
]));
|
|
8937
|
-
const MAX_CHARACTER_FORMAT_SNAPSHOT_BYTES =
|
|
9961
|
+
const MAX_CHARACTER_FORMAT_SNAPSHOT_BYTES = 8192;
|
|
8938
9962
|
const MAX_CHARACTER_FORMAT_ATTRIBUTE_LENGTH = 512;
|
|
8939
9963
|
const ALLOWED_ATTRIBUTES = {
|
|
8940
9964
|
bold: new Set(),
|
|
8941
9965
|
italic: new Set(),
|
|
8942
|
-
underline: new Set(
|
|
8943
|
-
|
|
9966
|
+
underline: new Set([
|
|
9967
|
+
'underlineColor',
|
|
9968
|
+
'underlineStyle',
|
|
9969
|
+
'underlineThemeColor'
|
|
9970
|
+
]),
|
|
9971
|
+
strike: new Set([
|
|
9972
|
+
'strikeStyle'
|
|
9973
|
+
]),
|
|
8944
9974
|
subscript: new Set(),
|
|
8945
9975
|
superscript: new Set(),
|
|
8946
9976
|
textStyle: new Set([
|
|
9977
|
+
'characterScalePercent',
|
|
9978
|
+
'characterPositionHalfPoints',
|
|
9979
|
+
'characterSpacingTwips',
|
|
8947
9980
|
'color',
|
|
8948
9981
|
'fontFamily',
|
|
8949
9982
|
'fontSize',
|
|
9983
|
+
'emphasisMark',
|
|
9984
|
+
'kerningThresholdHalfPoints',
|
|
9985
|
+
'hiddenText',
|
|
9986
|
+
"scriptFonts",
|
|
9987
|
+
"scriptFontSlot",
|
|
8950
9988
|
'themeColor',
|
|
9989
|
+
'textCase',
|
|
8951
9990
|
'wordLineHeightFactor',
|
|
8952
9991
|
'wordSnapToGrid'
|
|
8953
9992
|
]),
|
|
@@ -9009,18 +10048,39 @@ function importedDocumentCharacterFormatting(formatting) {
|
|
|
9009
10048
|
for (const name of [
|
|
9010
10049
|
'bold',
|
|
9011
10050
|
'italic',
|
|
9012
|
-
'underline',
|
|
9013
|
-
'strike',
|
|
9014
10051
|
"subscript",
|
|
9015
10052
|
"superscript"
|
|
9016
10053
|
])if (formatting[name]) marks.push({
|
|
9017
10054
|
type: name
|
|
9018
10055
|
});
|
|
10056
|
+
if (formatting.strike) marks.push({
|
|
10057
|
+
type: 'strike',
|
|
10058
|
+
attrs: {
|
|
10059
|
+
strikeStyle: formatting.strike.style
|
|
10060
|
+
}
|
|
10061
|
+
});
|
|
10062
|
+
if (formatting.underline) marks.push({
|
|
10063
|
+
type: 'underline',
|
|
10064
|
+
attrs: compactAttributes({
|
|
10065
|
+
underlineColor: formatting.underline.color,
|
|
10066
|
+
underlineStyle: formatting.underline.style,
|
|
10067
|
+
underlineThemeColor: serializeDocxThemeReference(formatting.underline.themeColor ?? null)
|
|
10068
|
+
})
|
|
10069
|
+
});
|
|
9019
10070
|
const textStyle = compactAttributes({
|
|
10071
|
+
characterScalePercent: formatting.characterScalePercent,
|
|
10072
|
+
characterPositionHalfPoints: formatting.characterPositionHalfPoints,
|
|
10073
|
+
characterSpacingTwips: formatting.characterSpacingTwips,
|
|
10074
|
+
kerningThresholdHalfPoints: formatting.kerningThresholdHalfPoints,
|
|
10075
|
+
emphasisMark: formatting.emphasisMark,
|
|
10076
|
+
hiddenText: formatting.hiddenText,
|
|
9020
10077
|
color: formatting.color,
|
|
9021
10078
|
fontFamily: formatting.fontFamily,
|
|
10079
|
+
scriptFonts: serializeDocumentScriptFonts(formatting.scriptFonts) ?? void 0,
|
|
10080
|
+
scriptFontSlot: formatting.scriptFontSlot,
|
|
9022
10081
|
fontSize: void 0 === formatting.fontSize ? void 0 : `${formatting.fontSize}pt`,
|
|
9023
10082
|
themeColor: formatting.themeColor,
|
|
10083
|
+
textCase: formatting.textCase,
|
|
9024
10084
|
wordLineHeightFactor: formatting.wordLineHeightFactor,
|
|
9025
10085
|
wordSnapToGrid: formatting.wordSnapToGrid
|
|
9026
10086
|
});
|
|
@@ -9048,9 +10108,61 @@ function normalizeCharacterFormatMark(value) {
|
|
|
9048
10108
|
if (void 0 !== source && !work_document_format_changes_isRecord(source)) return null;
|
|
9049
10109
|
const attrs = {};
|
|
9050
10110
|
for (const [key, candidate] of Object.entries(source ?? {}))if (allowed.has(key) && null != candidate) {
|
|
10111
|
+
if ('textStyle' === type && 'characterSpacingTwips' === key) {
|
|
10112
|
+
const spacing = normalizeDocumentCharacterSpacingTwips(candidate);
|
|
10113
|
+
if (null === spacing) return null;
|
|
10114
|
+
attrs[key] = spacing;
|
|
10115
|
+
continue;
|
|
10116
|
+
}
|
|
10117
|
+
if ('textStyle' === type && 'characterPositionHalfPoints' === key) {
|
|
10118
|
+
const position = normalizeDocumentCharacterPositionHalfPoints(candidate);
|
|
10119
|
+
if (null === position) return null;
|
|
10120
|
+
attrs[key] = position;
|
|
10121
|
+
continue;
|
|
10122
|
+
}
|
|
10123
|
+
if ('textStyle' === type && 'characterScalePercent' === key) {
|
|
10124
|
+
const scale = normalizeDocumentCharacterScalePercent(candidate);
|
|
10125
|
+
if (null === scale) return null;
|
|
10126
|
+
attrs[key] = scale;
|
|
10127
|
+
continue;
|
|
10128
|
+
}
|
|
10129
|
+
if ('textStyle' === type && 'kerningThresholdHalfPoints' === key) {
|
|
10130
|
+
const threshold = normalizeDocumentKerningThresholdHalfPoints(candidate);
|
|
10131
|
+
if (null === threshold) return null;
|
|
10132
|
+
attrs[key] = threshold;
|
|
10133
|
+
continue;
|
|
10134
|
+
}
|
|
10135
|
+
if ('textStyle' === type && 'emphasisMark' === key) {
|
|
10136
|
+
const emphasisMark = normalizeDocumentEmphasisMark(candidate);
|
|
10137
|
+
if (null === emphasisMark) return null;
|
|
10138
|
+
attrs[key] = emphasisMark;
|
|
10139
|
+
continue;
|
|
10140
|
+
}
|
|
10141
|
+
if ('textStyle' === type && 'hiddenText' === key) {
|
|
10142
|
+
const hiddenText = normalizeDocumentHiddenText(candidate);
|
|
10143
|
+
if (null === hiddenText) return null;
|
|
10144
|
+
attrs[key] = hiddenText;
|
|
10145
|
+
continue;
|
|
10146
|
+
}
|
|
10147
|
+
if ('textStyle' === type && "scriptFonts" === key) {
|
|
10148
|
+
const fonts = 'string' == typeof candidate ? serializeDocumentScriptFonts(parseDocumentScriptFonts(candidate)) : serializeDocumentScriptFonts(normalizeDocumentScriptFonts(candidate));
|
|
10149
|
+
if (!fonts) return null;
|
|
10150
|
+
attrs[key] = fonts;
|
|
10151
|
+
continue;
|
|
10152
|
+
}
|
|
10153
|
+
if ('textStyle' === type && "scriptFontSlot" === key) {
|
|
10154
|
+
const slot = normalizeDocumentScriptFontSlot(candidate);
|
|
10155
|
+
if (!slot) return null;
|
|
10156
|
+
attrs[key] = slot;
|
|
10157
|
+
continue;
|
|
10158
|
+
}
|
|
9051
10159
|
if ('string' == typeof candidate) {
|
|
9052
|
-
if (!candidate.length
|
|
9053
|
-
|
|
10160
|
+
if (!candidate.length) continue;
|
|
10161
|
+
if ('textStyle' === type && 'textCase' === key && !normalizeDocumentTextCase(candidate)) return null;
|
|
10162
|
+
if (candidate.length > MAX_CHARACTER_FORMAT_ATTRIBUTE_LENGTH) return null;
|
|
10163
|
+
const normalized = normalizeCharacterFormatStringAttribute(type, key, candidate);
|
|
10164
|
+
if (!normalized) return null;
|
|
10165
|
+
attrs[key] = normalized;
|
|
9054
10166
|
continue;
|
|
9055
10167
|
}
|
|
9056
10168
|
if ('boolean' == typeof candidate) {
|
|
@@ -9075,6 +10187,14 @@ function normalizeCharacterFormatMark(value) {
|
|
|
9075
10187
|
} : {}
|
|
9076
10188
|
};
|
|
9077
10189
|
}
|
|
10190
|
+
function normalizeCharacterFormatStringAttribute(type, key, value) {
|
|
10191
|
+
if ('strike' === type) return 'strikeStyle' === key ? normalizeDocumentStrikeStyle(value) : null;
|
|
10192
|
+
if ('underline' !== type) return value;
|
|
10193
|
+
if ('underlineStyle' === key) return normalizeDocumentUnderlineStyle(value);
|
|
10194
|
+
if ('underlineColor' === key) return normalizeDocumentUnderlineColor(value);
|
|
10195
|
+
if ('underlineThemeColor' === key) return serializeDocxThemeReference(parseDocxThemeReference(value)) ?? null;
|
|
10196
|
+
return null;
|
|
10197
|
+
}
|
|
9078
10198
|
function compareCharacterFormatMarks(left, right) {
|
|
9079
10199
|
return (CHARACTER_FORMAT_MARK_ORDER.get(left.type) ?? Number.MAX_SAFE_INTEGER) - (CHARACTER_FORMAT_MARK_ORDER.get(right.type) ?? Number.MAX_SAFE_INTEGER);
|
|
9080
10200
|
}
|
|
@@ -9083,6 +10203,7 @@ function createCharacterFormatMark(type, value) {
|
|
|
9083
10203
|
}
|
|
9084
10204
|
function compactAttributes(value) {
|
|
9085
10205
|
const entries = Object.entries(value).filter((entry)=>void 0 !== entry[1]);
|
|
10206
|
+
entries.sort(([left], [right])=>left < right ? -1 : left > right ? 1 : 0);
|
|
9086
10207
|
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
9087
10208
|
}
|
|
9088
10209
|
function work_document_format_changes_isRecord(value) {
|
|
@@ -9919,6 +11040,70 @@ function createDocumentChangeId() {
|
|
|
9919
11040
|
const random = "u" > typeof crypto && 'function' == typeof crypto.randomUUID ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
9920
11041
|
return `change-${random}`;
|
|
9921
11042
|
}
|
|
11043
|
+
const DocumentCharacterFormatting = Extension.create({
|
|
11044
|
+
name: 'documentCharacterFormatting',
|
|
11045
|
+
addCommands () {
|
|
11046
|
+
return {
|
|
11047
|
+
setDocumentCharacterScale: (characterScalePercent)=>({ commands })=>{
|
|
11048
|
+
const scale = normalizeDocumentCharacterScalePercent(characterScalePercent);
|
|
11049
|
+
return null === scale ? false : commands.setMark('textStyle', {
|
|
11050
|
+
characterScalePercent: scale
|
|
11051
|
+
});
|
|
11052
|
+
},
|
|
11053
|
+
setDocumentCharacterPosition: (characterPositionHalfPoints)=>({ commands })=>{
|
|
11054
|
+
const position = normalizeDocumentCharacterPositionHalfPoints(characterPositionHalfPoints);
|
|
11055
|
+
return null === position ? false : commands.setMark('textStyle', {
|
|
11056
|
+
characterPositionHalfPoints: position
|
|
11057
|
+
});
|
|
11058
|
+
},
|
|
11059
|
+
setDocumentCharacterSpacing: (characterSpacingTwips)=>({ commands })=>{
|
|
11060
|
+
const spacing = normalizeDocumentCharacterSpacingTwips(characterSpacingTwips);
|
|
11061
|
+
return null === spacing ? false : commands.setMark('textStyle', {
|
|
11062
|
+
characterSpacingTwips: spacing
|
|
11063
|
+
});
|
|
11064
|
+
},
|
|
11065
|
+
setDocumentKerningThreshold: (kerningThresholdHalfPoints)=>({ commands })=>{
|
|
11066
|
+
const threshold = normalizeDocumentKerningThresholdHalfPoints(kerningThresholdHalfPoints);
|
|
11067
|
+
return null === threshold ? false : commands.setMark('textStyle', {
|
|
11068
|
+
kerningThresholdHalfPoints: threshold
|
|
11069
|
+
});
|
|
11070
|
+
},
|
|
11071
|
+
unsetDocumentKerningThreshold: ()=>({ chain })=>chain().setMark('textStyle', {
|
|
11072
|
+
kerningThresholdHalfPoints: null
|
|
11073
|
+
}).removeEmptyTextStyle().run(),
|
|
11074
|
+
setDocumentEmphasisMark: (emphasisMark)=>({ commands })=>{
|
|
11075
|
+
const mark = normalizeDocumentEmphasisMark(emphasisMark);
|
|
11076
|
+
return null === mark ? false : commands.setMark('textStyle', {
|
|
11077
|
+
emphasisMark: mark
|
|
11078
|
+
});
|
|
11079
|
+
},
|
|
11080
|
+
unsetDocumentEmphasisMark: ()=>({ chain })=>chain().setMark('textStyle', {
|
|
11081
|
+
emphasisMark: null
|
|
11082
|
+
}).removeEmptyTextStyle().run(),
|
|
11083
|
+
setDocumentHiddenText: (hiddenText)=>({ commands })=>'boolean' == typeof hiddenText ? commands.setMark('textStyle', {
|
|
11084
|
+
hiddenText
|
|
11085
|
+
}) : false,
|
|
11086
|
+
unsetDocumentHiddenText: ()=>({ chain })=>chain().setMark('textStyle', {
|
|
11087
|
+
hiddenText: null
|
|
11088
|
+
}).removeEmptyTextStyle().run(),
|
|
11089
|
+
toggleDocumentHiddenText: ()=>({ commands, editor })=>commands.setDocumentHiddenText(!(normalizeDocumentHiddenText(editor.getAttributes('textStyle').hiddenText) ?? false)),
|
|
11090
|
+
setDocumentTextCase: (textCase)=>({ chain })=>chain().focus().setMark('textStyle', {
|
|
11091
|
+
textCase
|
|
11092
|
+
}).run(),
|
|
11093
|
+
toggleDocumentTextCase: (textCase)=>({ commands, editor })=>{
|
|
11094
|
+
const current = normalizeDocumentTextCase(editor.getAttributes('textStyle').textCase) ?? 'none';
|
|
11095
|
+
return commands.setDocumentTextCase(current === textCase ? 'none' : textCase);
|
|
11096
|
+
}
|
|
11097
|
+
};
|
|
11098
|
+
},
|
|
11099
|
+
addKeyboardShortcuts () {
|
|
11100
|
+
return {
|
|
11101
|
+
[documentTextCaseKeyboardShortcuts.allCaps]: ()=>this.editor.commands.toggleDocumentTextCase('all-caps'),
|
|
11102
|
+
[documentTextCaseKeyboardShortcuts.smallCaps]: ()=>this.editor.commands.toggleDocumentTextCase('small-caps'),
|
|
11103
|
+
[documentHiddenTextKeyboardShortcut]: ()=>this.editor.commands.toggleDocumentHiddenText()
|
|
11104
|
+
};
|
|
11105
|
+
}
|
|
11106
|
+
});
|
|
9922
11107
|
const DocumentSubscript = extension_subscript.extend({
|
|
9923
11108
|
excludes: "superscript",
|
|
9924
11109
|
addCommands () {
|
|
@@ -14584,6 +15769,7 @@ function documentTextLayoutContent(node) {
|
|
|
14584
15769
|
return supported ? content.join('') : null;
|
|
14585
15770
|
}
|
|
14586
15771
|
function collectDocumentTextLayoutRuns(element, expectedText, fonts, loadedFontIds, paragraphStyle = documentTextParagraphStyle(getComputedStyle(element))) {
|
|
15772
|
+
if (element.matches(`[${DOCUMENT_HIDDEN_TEXT_ATTRIBUTE}="true"]`) || element.querySelector(`[${DOCUMENT_HIDDEN_TEXT_ATTRIBUTE}="true"]`)) return null;
|
|
14587
15773
|
if (!paragraphStyle) return null;
|
|
14588
15774
|
const tokens = documentTextLayoutDomTokens(element);
|
|
14589
15775
|
if (!tokens) return null;
|
|
@@ -14591,7 +15777,7 @@ function collectDocumentTextLayoutRuns(element, expectedText, fonts, loadedFontI
|
|
|
14591
15777
|
const runs = [];
|
|
14592
15778
|
let utf16Offset = 0;
|
|
14593
15779
|
for (const token of tokens){
|
|
14594
|
-
const runStyle = documentTextLayoutRunStyle(getComputedStyle(token.styleElement), fonts, loadedFontIds, paragraphStyle, token.styleElement === element);
|
|
15780
|
+
const runStyle = documentTextLayoutRunStyle(getComputedStyle(token.styleElement), fonts, loadedFontIds, paragraphStyle, token.styleElement, token.styleElement === element);
|
|
14595
15781
|
if (!runStyle) return null;
|
|
14596
15782
|
const startUtf16 = utf16Offset;
|
|
14597
15783
|
utf16Offset += token.text.length;
|
|
@@ -14643,10 +15829,10 @@ function documentTextParagraphStyle(style) {
|
|
|
14643
15829
|
whiteSpace: 'break-spaces' === style.whiteSpace ? 'breakSpaces' : 'normal'
|
|
14644
15830
|
};
|
|
14645
15831
|
}
|
|
14646
|
-
function documentTextLayoutRunStyle(style, fonts, loadedFontIds, paragraphStyle, paragraphRoot) {
|
|
15832
|
+
function documentTextLayoutRunStyle(style, fonts, loadedFontIds, paragraphStyle, element, paragraphRoot) {
|
|
14647
15833
|
const direction = 'rtl' === style.direction ? 'rtl' : 'ltr';
|
|
14648
15834
|
const whiteSpace = 'break-spaces' === style.whiteSpace ? 'breakSpaces' : 'normal';
|
|
14649
|
-
if (direction !== paragraphStyle.direction || whiteSpace !== paragraphStyle.whiteSpace || !cssValueIs(style.whiteSpace, 'normal', 'break-spaces') || !cssValueIs(style.overflowWrap, 'normal', 'anywhere', 'break-word') || !cssValueIs(style.wordBreak, 'normal') || !cssValueIs(style.hyphens, 'manual', 'none') || !cssValueIs(style.wordSpacing, 'normal', '0', '0px') || !cssValueIs(style.textTransform, 'none') || !cssValueIs(style.fontVariationSettings, 'normal') || !cssValueIs(style.fontVariantCaps, 'normal') || !cssValueIs(style.fontVariantEastAsian, 'normal') || !cssValueIs(style.fontVariantNumeric, 'normal') || !cssValueIs(style.fontVariantPosition, 'normal') || !cssValueIs(style.fontStretch, 'normal', '100%') || !cssValueIs(style.verticalAlign, 'baseline') || !cssValueIs(style.unicodeBidi, 'normal') && !(paragraphRoot && 'isolate' === style.unicodeBidi)) return null;
|
|
15835
|
+
if (direction !== paragraphStyle.direction || whiteSpace !== paragraphStyle.whiteSpace || !cssValueIs(style.whiteSpace, 'normal', 'break-spaces') || !cssValueIs(style.overflowWrap, 'normal', 'anywhere', 'break-word') || !cssValueIs(style.wordBreak, 'normal') || !cssValueIs(style.hyphens, 'manual', 'none') || !cssValueIs(style.wordSpacing, 'normal', '0', '0px') || !cssValueIs(style.textTransform, 'none') || !cssValueIs(style.fontVariationSettings, 'normal') || !cssValueIs(style.fontVariantCaps, 'normal') || !cssValueIs(style.fontVariantEastAsian, 'normal') || !cssValueIs(style.fontVariantNumeric, 'normal') || !cssValueIs(style.fontVariantPosition, 'normal') || !cssValueIs(style.fontStretch, 'normal', '100%') || !documentTextEmphasisAllowsKernel(style, element) || !cssValueIs(style.verticalAlign, 'baseline') || !cssValueIs(style.unicodeBidi, 'normal') && !(paragraphRoot && 'isolate' === style.unicodeBidi)) return null;
|
|
14650
15836
|
const fontStyle = style.fontStyle && 'normal' !== style.fontStyle ? 'italic' === style.fontStyle ? 'italic' : null : 'normal';
|
|
14651
15837
|
if (!fontStyle) return null;
|
|
14652
15838
|
const families = cssFontFamilies(style.fontFamily);
|
|
@@ -14719,6 +15905,19 @@ function documentTextLayoutRunStyleKey(style) {
|
|
|
14719
15905
|
function cssValueIs(value, ...supported) {
|
|
14720
15906
|
return !value || supported.includes(value);
|
|
14721
15907
|
}
|
|
15908
|
+
function documentTextEmphasisAllowsKernel(style, element) {
|
|
15909
|
+
for(let current = element; current; current = current.parentElement){
|
|
15910
|
+
if (!current.hasAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE)) continue;
|
|
15911
|
+
const emphasisMark = normalizeDocumentEmphasisMark(current.getAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE));
|
|
15912
|
+
if (null !== emphasisMark) {
|
|
15913
|
+
if ('none' !== emphasisMark) return false;
|
|
15914
|
+
break;
|
|
15915
|
+
}
|
|
15916
|
+
}
|
|
15917
|
+
const standard = style.getPropertyValue('text-emphasis-style').trim();
|
|
15918
|
+
const webkit = style.getPropertyValue('-webkit-text-emphasis-style').trim();
|
|
15919
|
+
return (!standard || 'none' === standard) && (!webkit || 'none' === webkit);
|
|
15920
|
+
}
|
|
14722
15921
|
function cssLigatures(style) {
|
|
14723
15922
|
const variant = style.fontVariantLigatures;
|
|
14724
15923
|
if (variant && 'normal' !== variant && 'none' !== variant) return null;
|
|
@@ -16182,34 +17381,371 @@ const DocumentSection = core_Node.create({
|
|
|
16182
17381
|
] : []
|
|
16183
17382
|
].join(';');
|
|
16184
17383
|
return [
|
|
16185
|
-
'section',
|
|
16186
|
-
mergeAttributes(HTMLAttributes, documentSectionDomAttributes(layout, id), {
|
|
16187
|
-
class: 'work-document-section',
|
|
16188
|
-
style
|
|
16189
|
-
}),
|
|
16190
|
-
0
|
|
17384
|
+
'section',
|
|
17385
|
+
mergeAttributes(HTMLAttributes, documentSectionDomAttributes(layout, id), {
|
|
17386
|
+
class: 'work-document-section',
|
|
17387
|
+
style
|
|
17388
|
+
}),
|
|
17389
|
+
0
|
|
17390
|
+
];
|
|
17391
|
+
}
|
|
17392
|
+
});
|
|
17393
|
+
function work_document_section_node_hiddenAttribute(defaultValue) {
|
|
17394
|
+
return {
|
|
17395
|
+
default: defaultValue,
|
|
17396
|
+
rendered: false
|
|
17397
|
+
};
|
|
17398
|
+
}
|
|
17399
|
+
function numberAttribute(element, name, fallback) {
|
|
17400
|
+
const value = Number(element.dataset[name]);
|
|
17401
|
+
return Number.isFinite(value) ? value : fallback;
|
|
17402
|
+
}
|
|
17403
|
+
function nullableNumberAttribute(element, name) {
|
|
17404
|
+
const source = element.dataset[name];
|
|
17405
|
+
if (!source?.trim()) return null;
|
|
17406
|
+
const value = Number(source);
|
|
17407
|
+
return Number.isFinite(value) ? value : null;
|
|
17408
|
+
}
|
|
17409
|
+
function sectionBreakAttribute(value) {
|
|
17410
|
+
if ('continuous' === value || 'evenPage' === value || 'oddPage' === value || 'nextColumn' === value) return value;
|
|
17411
|
+
return 'nextPage';
|
|
17412
|
+
}
|
|
17413
|
+
const DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT = 1.15;
|
|
17414
|
+
const DOCUMENT_WORD_LINE_HEIGHT_FACTORS = new Map([
|
|
17415
|
+
[
|
|
17416
|
+
'arial',
|
|
17417
|
+
1.15
|
|
17418
|
+
],
|
|
17419
|
+
[
|
|
17420
|
+
'times new roman',
|
|
17421
|
+
1.15
|
|
17422
|
+
],
|
|
17423
|
+
[
|
|
17424
|
+
'calibri',
|
|
17425
|
+
1.2207
|
|
17426
|
+
],
|
|
17427
|
+
[
|
|
17428
|
+
'segoe ui',
|
|
17429
|
+
1.3301
|
|
17430
|
+
],
|
|
17431
|
+
[
|
|
17432
|
+
'microsoft yahei',
|
|
17433
|
+
1.7143
|
|
17434
|
+
],
|
|
17435
|
+
[
|
|
17436
|
+
'microsoft yahei ui',
|
|
17437
|
+
1.7143
|
|
17438
|
+
],
|
|
17439
|
+
[
|
|
17440
|
+
'simsun',
|
|
17441
|
+
1.2976
|
|
17442
|
+
],
|
|
17443
|
+
[
|
|
17444
|
+
'simhei',
|
|
17445
|
+
1.2976
|
|
17446
|
+
],
|
|
17447
|
+
[
|
|
17448
|
+
'fangsong',
|
|
17449
|
+
1.2976
|
|
17450
|
+
],
|
|
17451
|
+
[
|
|
17452
|
+
'kaiti',
|
|
17453
|
+
1.2976
|
|
17454
|
+
],
|
|
17455
|
+
[
|
|
17456
|
+
'dengxian',
|
|
17457
|
+
1.3548
|
|
17458
|
+
]
|
|
17459
|
+
]);
|
|
17460
|
+
function documentWordLineHeightFactor(fontFamily) {
|
|
17461
|
+
if ('string' != typeof fontFamily) return DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT;
|
|
17462
|
+
const family = firstCssFontFamily(fontFamily).toLocaleLowerCase();
|
|
17463
|
+
return DOCUMENT_WORD_LINE_HEIGHT_FACTORS.get(family) ?? DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT;
|
|
17464
|
+
}
|
|
17465
|
+
function normalizedDocumentWordLineHeightFactor(value) {
|
|
17466
|
+
if (null == value || '' === value) return null;
|
|
17467
|
+
const factor = Number(value);
|
|
17468
|
+
if (!Number.isFinite(factor) || factor < 0.5 || factor > 4) return null;
|
|
17469
|
+
return Number(factor.toFixed(4));
|
|
17470
|
+
}
|
|
17471
|
+
const DocumentTextStyle = TextStyle.extend({
|
|
17472
|
+
parseHTML () {
|
|
17473
|
+
return [
|
|
17474
|
+
...this.parent?.() ?? [],
|
|
17475
|
+
{
|
|
17476
|
+
tag: `span[${DOCUMENT_HIDDEN_TEXT_ATTRIBUTE}]`,
|
|
17477
|
+
consuming: false
|
|
17478
|
+
}
|
|
17479
|
+
];
|
|
17480
|
+
},
|
|
17481
|
+
addCommands () {
|
|
17482
|
+
return {
|
|
17483
|
+
...this.parent?.() ?? {},
|
|
17484
|
+
removeEmptyTextStyle: ()=>({ tr })=>{
|
|
17485
|
+
const { from, to } = tr.selection;
|
|
17486
|
+
tr.doc.nodesBetween(from, to, (node, position)=>{
|
|
17487
|
+
if (!node.isText) return true;
|
|
17488
|
+
const mark = node.marks.find((candidate)=>candidate.type === this.type && documentTextStyleAttributesAreEmpty(candidate.attrs));
|
|
17489
|
+
if (mark) tr.removeMark(Math.max(position, from), Math.min(position + node.nodeSize, to), mark);
|
|
17490
|
+
return false;
|
|
17491
|
+
});
|
|
17492
|
+
return true;
|
|
17493
|
+
}
|
|
17494
|
+
};
|
|
17495
|
+
},
|
|
17496
|
+
addAttributes () {
|
|
17497
|
+
return {
|
|
17498
|
+
characterScalePercent: {
|
|
17499
|
+
default: null,
|
|
17500
|
+
parseHTML: (element)=>documentCharacterScalePercentFromElement(element),
|
|
17501
|
+
renderHTML: (attributes)=>documentCharacterScaleDomAttributes(normalizeDocumentCharacterScalePercent(attributes.characterScalePercent))
|
|
17502
|
+
},
|
|
17503
|
+
characterPositionHalfPoints: {
|
|
17504
|
+
default: null,
|
|
17505
|
+
parseHTML: (element)=>documentCharacterPositionHalfPointsFromElement(element),
|
|
17506
|
+
renderHTML: (attributes)=>documentCharacterPositionDomAttributes(normalizeDocumentCharacterPositionHalfPoints(attributes.characterPositionHalfPoints))
|
|
17507
|
+
},
|
|
17508
|
+
characterSpacingTwips: {
|
|
17509
|
+
default: null,
|
|
17510
|
+
parseHTML: (element)=>documentCharacterSpacingTwipsFromElement(element),
|
|
17511
|
+
renderHTML: (attributes)=>documentCharacterSpacingDomAttributes(normalizeDocumentCharacterSpacingTwips(attributes.characterSpacingTwips))
|
|
17512
|
+
},
|
|
17513
|
+
emphasisMark: {
|
|
17514
|
+
default: null,
|
|
17515
|
+
parseHTML: (element)=>documentEmphasisMarkFromElement(element),
|
|
17516
|
+
renderHTML: (attributes)=>documentEmphasisMarkDomAttributes(normalizeDocumentEmphasisMark(attributes.emphasisMark))
|
|
17517
|
+
},
|
|
17518
|
+
hiddenText: {
|
|
17519
|
+
default: null,
|
|
17520
|
+
parseHTML: (element)=>documentHiddenTextFromElement(element),
|
|
17521
|
+
renderHTML: (attributes)=>documentHiddenTextDomAttributes(attributes.hiddenText)
|
|
17522
|
+
},
|
|
17523
|
+
kerningThresholdHalfPoints: {
|
|
17524
|
+
default: null,
|
|
17525
|
+
parseHTML: (element)=>documentKerningThresholdHalfPointsFromElement(element),
|
|
17526
|
+
renderHTML: (attributes)=>documentKerningDomAttributes(normalizeDocumentKerningThresholdHalfPoints(attributes.kerningThresholdHalfPoints), attributes.fontSize)
|
|
17527
|
+
},
|
|
17528
|
+
scriptFonts: {
|
|
17529
|
+
default: null,
|
|
17530
|
+
parseHTML: (element)=>serializeDocumentScriptFonts(parseDocumentScriptFonts(element.dataset.officeScriptFonts)),
|
|
17531
|
+
renderHTML: (attributes)=>{
|
|
17532
|
+
const domAttributes = documentScriptFontsDomAttributes('string' == typeof attributes.scriptFonts ? parseDocumentScriptFonts(attributes.scriptFonts) : attributes.scriptFonts, attributes.scriptFontSlot);
|
|
17533
|
+
delete domAttributes.style;
|
|
17534
|
+
return domAttributes;
|
|
17535
|
+
}
|
|
17536
|
+
},
|
|
17537
|
+
scriptFontSlot: {
|
|
17538
|
+
default: null,
|
|
17539
|
+
parseHTML: (element)=>normalizeDocumentScriptFontSlot(element.dataset.officeScriptFontSlot),
|
|
17540
|
+
renderHTML: ()=>({})
|
|
17541
|
+
},
|
|
17542
|
+
wordLineHeightFactor: {
|
|
17543
|
+
default: null,
|
|
17544
|
+
parseHTML: (element)=>normalizedDocumentWordLineHeightFactor(element.dataset.officeWordLineHeightFactor ?? element.style.getPropertyValue('--work-document-word-line-height-factor')),
|
|
17545
|
+
renderHTML: (attributes)=>{
|
|
17546
|
+
const factor = normalizedDocumentWordLineHeightFactor(attributes.wordLineHeightFactor);
|
|
17547
|
+
if (null === factor) return {};
|
|
17548
|
+
return {
|
|
17549
|
+
'data-office-word-line-height-factor': String(factor),
|
|
17550
|
+
style: `--work-document-word-line-height-factor: ${factor}`
|
|
17551
|
+
};
|
|
17552
|
+
}
|
|
17553
|
+
},
|
|
17554
|
+
wordSnapToGrid: {
|
|
17555
|
+
default: null,
|
|
17556
|
+
parseHTML: (element)=>normalizedBoolean(element.dataset.officeWordSnapToGrid),
|
|
17557
|
+
renderHTML: (attributes)=>{
|
|
17558
|
+
const value = normalizedBoolean(attributes.wordSnapToGrid);
|
|
17559
|
+
return null === value ? {} : {
|
|
17560
|
+
'data-office-word-snap-to-grid': String(value)
|
|
17561
|
+
};
|
|
17562
|
+
}
|
|
17563
|
+
},
|
|
17564
|
+
themeColor: themeReferenceAttribute('officeThemeColor'),
|
|
17565
|
+
textCase: {
|
|
17566
|
+
default: null,
|
|
17567
|
+
parseHTML: (element)=>normalizeDocumentTextCase(element.dataset.officeTextCase),
|
|
17568
|
+
renderHTML: (attributes)=>{
|
|
17569
|
+
const textCase = normalizeDocumentTextCase(attributes.textCase);
|
|
17570
|
+
return textCase ? {
|
|
17571
|
+
[DOCUMENT_TEXT_CASE_ATTRIBUTE]: textCase,
|
|
17572
|
+
style: documentTextCaseCss(textCase)
|
|
17573
|
+
} : {};
|
|
17574
|
+
}
|
|
17575
|
+
}
|
|
17576
|
+
};
|
|
17577
|
+
}
|
|
17578
|
+
});
|
|
17579
|
+
function documentTextStyleAttributesAreEmpty(attributes) {
|
|
17580
|
+
return Object.values(attributes).every((value)=>null == value || '' === value);
|
|
17581
|
+
}
|
|
17582
|
+
const DocumentHighlight = extension_highlight.extend({
|
|
17583
|
+
addKeyboardShortcuts () {
|
|
17584
|
+
return {};
|
|
17585
|
+
},
|
|
17586
|
+
addAttributes () {
|
|
17587
|
+
return {
|
|
17588
|
+
...this.parent?.(),
|
|
17589
|
+
themeFill: themeReferenceAttribute('officeThemeFill')
|
|
17590
|
+
};
|
|
17591
|
+
},
|
|
17592
|
+
parseHTML () {
|
|
17593
|
+
return [
|
|
17594
|
+
...this.parent?.() ?? [],
|
|
17595
|
+
{
|
|
17596
|
+
tag: 'span[data-office-theme-fill]'
|
|
17597
|
+
},
|
|
17598
|
+
{
|
|
17599
|
+
tag: 'span[style*="background-color"]'
|
|
17600
|
+
}
|
|
16191
17601
|
];
|
|
16192
17602
|
}
|
|
16193
17603
|
});
|
|
16194
|
-
|
|
17604
|
+
const DocumentFontFamily = font_family.extend({
|
|
17605
|
+
addCommands () {
|
|
17606
|
+
return {
|
|
17607
|
+
setFontFamily: (fontFamily)=>({ chain })=>{
|
|
17608
|
+
const scriptFonts = serializeDocumentScriptFonts(documentScriptFontsForAllText(fontFamily));
|
|
17609
|
+
return chain().setMark('textStyle', {
|
|
17610
|
+
fontFamily,
|
|
17611
|
+
scriptFonts,
|
|
17612
|
+
scriptFontSlot: null,
|
|
17613
|
+
wordLineHeightFactor: documentWordLineHeightFactor(fontFamily)
|
|
17614
|
+
}).run();
|
|
17615
|
+
},
|
|
17616
|
+
unsetFontFamily: ()=>({ chain })=>chain().setMark('textStyle', {
|
|
17617
|
+
fontFamily: null,
|
|
17618
|
+
scriptFonts: null,
|
|
17619
|
+
scriptFontSlot: null,
|
|
17620
|
+
wordLineHeightFactor: null
|
|
17621
|
+
}).removeEmptyTextStyle().run()
|
|
17622
|
+
};
|
|
17623
|
+
}
|
|
17624
|
+
});
|
|
17625
|
+
function firstCssFontFamily(value) {
|
|
17626
|
+
const source = value.trim();
|
|
17627
|
+
if (!source) return '';
|
|
17628
|
+
const quote = source[0];
|
|
17629
|
+
if ('"' === quote || "'" === quote) {
|
|
17630
|
+
const end = source.indexOf(quote, 1);
|
|
17631
|
+
if (end > 0) return source.slice(1, end).trim();
|
|
17632
|
+
}
|
|
17633
|
+
return (source.split(',')[0] ?? source).trim().replace(/^(['"])(.*)\1$/, '$2');
|
|
17634
|
+
}
|
|
17635
|
+
function normalizedBoolean(value) {
|
|
17636
|
+
if (true === value || 'true' === value || '1' === value) return true;
|
|
17637
|
+
if (false === value || 'false' === value || '0' === value) return false;
|
|
17638
|
+
return null;
|
|
17639
|
+
}
|
|
17640
|
+
function themeReferenceAttribute(datasetKey) {
|
|
16195
17641
|
return {
|
|
16196
|
-
default:
|
|
16197
|
-
|
|
17642
|
+
default: null,
|
|
17643
|
+
parseHTML: (element)=>serializeDocxThemeReference(parseDocxThemeReference(element.dataset[datasetKey])) ?? null,
|
|
17644
|
+
renderHTML: (attributes)=>{
|
|
17645
|
+
const value = serializeDocxThemeReference(parseDocxThemeReference('string' == typeof attributes['officeThemeColor' === datasetKey ? 'themeColor' : 'themeFill'] ? String(attributes['officeThemeColor' === datasetKey ? 'themeColor' : 'themeFill']) : null));
|
|
17646
|
+
return value ? {
|
|
17647
|
+
[`data-${toKebabCase(datasetKey)}`]: value
|
|
17648
|
+
} : {};
|
|
17649
|
+
}
|
|
16198
17650
|
};
|
|
16199
17651
|
}
|
|
16200
|
-
function
|
|
16201
|
-
|
|
16202
|
-
return Number.isFinite(value) ? value : fallback;
|
|
17652
|
+
function toKebabCase(value) {
|
|
17653
|
+
return value.replace(/[A-Z]/g, (character)=>`-${character.toLowerCase()}`);
|
|
16203
17654
|
}
|
|
16204
|
-
|
|
16205
|
-
|
|
16206
|
-
|
|
16207
|
-
|
|
16208
|
-
|
|
17655
|
+
const SCRIPT_FONT_NORMALIZATION_META = 'documentScriptFontNormalization';
|
|
17656
|
+
const documentScriptFontPluginKey = new PluginKey('documentScriptFontNormalization');
|
|
17657
|
+
const DocumentScriptFontFormatting = Extension.create({
|
|
17658
|
+
name: 'documentScriptFontFormatting',
|
|
17659
|
+
addProseMirrorPlugins () {
|
|
17660
|
+
return [
|
|
17661
|
+
new Plugin({
|
|
17662
|
+
key: documentScriptFontPluginKey,
|
|
17663
|
+
view (view) {
|
|
17664
|
+
const transaction = normalizeDocumentScriptFontMarks(view.state);
|
|
17665
|
+
if (transaction) view.dispatch(transaction);
|
|
17666
|
+
return {};
|
|
17667
|
+
},
|
|
17668
|
+
appendTransaction (transactions, _oldState, newState) {
|
|
17669
|
+
if (!transactions.some((transaction)=>transaction.docChanged) || transactions.some((transaction)=>transaction.getMeta(SCRIPT_FONT_NORMALIZATION_META))) return null;
|
|
17670
|
+
return normalizeDocumentScriptFontMarks(newState, changedDocumentRanges(transactions, newState), true);
|
|
17671
|
+
}
|
|
17672
|
+
})
|
|
17673
|
+
];
|
|
17674
|
+
}
|
|
17675
|
+
});
|
|
17676
|
+
function normalizeDocumentScriptFontMarks(state, ranges, includeInHistory = false) {
|
|
17677
|
+
const textStyle = state.schema.marks.textStyle;
|
|
17678
|
+
if (!textStyle) return null;
|
|
17679
|
+
const updates = [];
|
|
17680
|
+
const visited = new Set();
|
|
17681
|
+
const visit = (node, position)=>{
|
|
17682
|
+
if (!node.isText || !node.text || visited.has(position)) return;
|
|
17683
|
+
visited.add(position);
|
|
17684
|
+
const current = node.marks.find((mark)=>mark.type === textStyle);
|
|
17685
|
+
const fonts = parseDocumentScriptFonts(current?.attrs.scriptFonts);
|
|
17686
|
+
if (!current || !fonts) return;
|
|
17687
|
+
const serialized = serializeDocumentScriptFonts(fonts);
|
|
17688
|
+
if (!serialized) return;
|
|
17689
|
+
for (const segment of documentScriptFontSegments(node.text, fonts.hint)){
|
|
17690
|
+
const family = documentScriptFontFamilyForRendering(fonts, segment.slot, current.attrs.fontFamily);
|
|
17691
|
+
const attributes = {
|
|
17692
|
+
...current.attrs,
|
|
17693
|
+
scriptFonts: serialized,
|
|
17694
|
+
scriptFontSlot: segment.slot,
|
|
17695
|
+
...family ? {
|
|
17696
|
+
fontFamily: family,
|
|
17697
|
+
wordLineHeightFactor: documentWordLineHeightFactor(family)
|
|
17698
|
+
} : {}
|
|
17699
|
+
};
|
|
17700
|
+
const next = textStyle.create(attributes);
|
|
17701
|
+
if (!current.eq(next)) updates.push({
|
|
17702
|
+
from: position + segment.from,
|
|
17703
|
+
to: position + segment.to,
|
|
17704
|
+
current,
|
|
17705
|
+
next
|
|
17706
|
+
});
|
|
17707
|
+
}
|
|
17708
|
+
};
|
|
17709
|
+
if (ranges?.length) for (const range of ranges)state.doc.nodesBetween(range.from, range.to, visit);
|
|
17710
|
+
else state.doc.descendants(visit);
|
|
17711
|
+
if (!updates.length) return null;
|
|
17712
|
+
const transaction = state.tr;
|
|
17713
|
+
for (const update of updates){
|
|
17714
|
+
transaction.removeMark(update.from, update.to, update.current);
|
|
17715
|
+
transaction.addMark(update.from, update.to, update.next);
|
|
17716
|
+
}
|
|
17717
|
+
transaction.setMeta(SCRIPT_FONT_NORMALIZATION_META, true);
|
|
17718
|
+
if (!includeInHistory) transaction.setMeta('addToHistory', false);
|
|
17719
|
+
return transaction;
|
|
16209
17720
|
}
|
|
16210
|
-
function
|
|
16211
|
-
|
|
16212
|
-
|
|
17721
|
+
function changedDocumentRanges(transactions, state) {
|
|
17722
|
+
const maximum = state.doc.content.size;
|
|
17723
|
+
const ranges = [];
|
|
17724
|
+
for (const transaction of transactions)for (const map of transaction.mapping.maps)map.forEach((_oldFrom, _oldTo, newFrom, newTo)=>{
|
|
17725
|
+
ranges.push(expandedRange(newFrom, newTo, maximum));
|
|
17726
|
+
});
|
|
17727
|
+
ranges.push(expandedRange(state.selection.from, state.selection.to, maximum));
|
|
17728
|
+
return mergeRanges(ranges);
|
|
17729
|
+
}
|
|
17730
|
+
function expandedRange(from, to, maximum) {
|
|
17731
|
+
return {
|
|
17732
|
+
from: Math.max(0, Math.min(maximum, Math.min(from, to) - 2)),
|
|
17733
|
+
to: Math.max(0, Math.min(maximum, Math.max(from, to) + 2))
|
|
17734
|
+
};
|
|
17735
|
+
}
|
|
17736
|
+
function mergeRanges(ranges) {
|
|
17737
|
+
const ordered = [
|
|
17738
|
+
...ranges
|
|
17739
|
+
].filter((range)=>range.to >= range.from).sort((left, right)=>left.from - right.from || left.to - right.to);
|
|
17740
|
+
const merged = [];
|
|
17741
|
+
for (const range of ordered){
|
|
17742
|
+
const previous = merged[merged.length - 1];
|
|
17743
|
+
if (previous && range.from <= previous.to) previous.to = Math.max(previous.to, range.to);
|
|
17744
|
+
else merged.push({
|
|
17745
|
+
...range
|
|
17746
|
+
});
|
|
17747
|
+
}
|
|
17748
|
+
return merged;
|
|
16213
17749
|
}
|
|
16214
17750
|
const DOCUMENT_TAB_SELECTOR = 'span[data-document-tab]';
|
|
16215
17751
|
const DOCUMENT_TAB_BLOCK_SELECTOR = 'p, h1, h2, h3, h4, h5, h6';
|
|
@@ -18244,156 +19780,6 @@ function commonNullableValue(values) {
|
|
|
18244
19780
|
if (!values.length || values.some((value)=>null === value)) return null;
|
|
18245
19781
|
return values.every((value)=>value === values[0]) ? values[0] : null;
|
|
18246
19782
|
}
|
|
18247
|
-
const DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT = 1.15;
|
|
18248
|
-
const DOCUMENT_WORD_LINE_HEIGHT_FACTORS = new Map([
|
|
18249
|
-
[
|
|
18250
|
-
'arial',
|
|
18251
|
-
1.15
|
|
18252
|
-
],
|
|
18253
|
-
[
|
|
18254
|
-
'times new roman',
|
|
18255
|
-
1.15
|
|
18256
|
-
],
|
|
18257
|
-
[
|
|
18258
|
-
'calibri',
|
|
18259
|
-
1.2207
|
|
18260
|
-
],
|
|
18261
|
-
[
|
|
18262
|
-
'segoe ui',
|
|
18263
|
-
1.3301
|
|
18264
|
-
],
|
|
18265
|
-
[
|
|
18266
|
-
'microsoft yahei',
|
|
18267
|
-
1.7143
|
|
18268
|
-
],
|
|
18269
|
-
[
|
|
18270
|
-
'microsoft yahei ui',
|
|
18271
|
-
1.7143
|
|
18272
|
-
],
|
|
18273
|
-
[
|
|
18274
|
-
'simsun',
|
|
18275
|
-
1.2976
|
|
18276
|
-
],
|
|
18277
|
-
[
|
|
18278
|
-
'simhei',
|
|
18279
|
-
1.2976
|
|
18280
|
-
],
|
|
18281
|
-
[
|
|
18282
|
-
'fangsong',
|
|
18283
|
-
1.2976
|
|
18284
|
-
],
|
|
18285
|
-
[
|
|
18286
|
-
'kaiti',
|
|
18287
|
-
1.2976
|
|
18288
|
-
],
|
|
18289
|
-
[
|
|
18290
|
-
'dengxian',
|
|
18291
|
-
1.3548
|
|
18292
|
-
]
|
|
18293
|
-
]);
|
|
18294
|
-
function documentWordLineHeightFactor(fontFamily) {
|
|
18295
|
-
if ('string' != typeof fontFamily) return DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT;
|
|
18296
|
-
const family = firstCssFontFamily(fontFamily).toLocaleLowerCase();
|
|
18297
|
-
return DOCUMENT_WORD_LINE_HEIGHT_FACTORS.get(family) ?? DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT;
|
|
18298
|
-
}
|
|
18299
|
-
function normalizedDocumentWordLineHeightFactor(value) {
|
|
18300
|
-
if (null == value || '' === value) return null;
|
|
18301
|
-
const factor = Number(value);
|
|
18302
|
-
if (!Number.isFinite(factor) || factor < 0.5 || factor > 4) return null;
|
|
18303
|
-
return Number(factor.toFixed(4));
|
|
18304
|
-
}
|
|
18305
|
-
const DocumentTextStyle = TextStyle.extend({
|
|
18306
|
-
addAttributes () {
|
|
18307
|
-
return {
|
|
18308
|
-
wordLineHeightFactor: {
|
|
18309
|
-
default: null,
|
|
18310
|
-
parseHTML: (element)=>normalizedDocumentWordLineHeightFactor(element.dataset.officeWordLineHeightFactor ?? element.style.getPropertyValue('--work-document-word-line-height-factor')),
|
|
18311
|
-
renderHTML: (attributes)=>{
|
|
18312
|
-
const factor = normalizedDocumentWordLineHeightFactor(attributes.wordLineHeightFactor);
|
|
18313
|
-
if (null === factor) return {};
|
|
18314
|
-
return {
|
|
18315
|
-
'data-office-word-line-height-factor': String(factor),
|
|
18316
|
-
style: `--work-document-word-line-height-factor: ${factor}`
|
|
18317
|
-
};
|
|
18318
|
-
}
|
|
18319
|
-
},
|
|
18320
|
-
wordSnapToGrid: {
|
|
18321
|
-
default: null,
|
|
18322
|
-
parseHTML: (element)=>normalizedBoolean(element.dataset.officeWordSnapToGrid),
|
|
18323
|
-
renderHTML: (attributes)=>{
|
|
18324
|
-
const value = normalizedBoolean(attributes.wordSnapToGrid);
|
|
18325
|
-
return null === value ? {} : {
|
|
18326
|
-
'data-office-word-snap-to-grid': String(value)
|
|
18327
|
-
};
|
|
18328
|
-
}
|
|
18329
|
-
},
|
|
18330
|
-
themeColor: themeReferenceAttribute('officeThemeColor')
|
|
18331
|
-
};
|
|
18332
|
-
}
|
|
18333
|
-
});
|
|
18334
|
-
const DocumentHighlight = extension_highlight.extend({
|
|
18335
|
-
addAttributes () {
|
|
18336
|
-
return {
|
|
18337
|
-
...this.parent?.(),
|
|
18338
|
-
themeFill: themeReferenceAttribute('officeThemeFill')
|
|
18339
|
-
};
|
|
18340
|
-
},
|
|
18341
|
-
parseHTML () {
|
|
18342
|
-
return [
|
|
18343
|
-
...this.parent?.() ?? [],
|
|
18344
|
-
{
|
|
18345
|
-
tag: 'span[data-office-theme-fill]'
|
|
18346
|
-
},
|
|
18347
|
-
{
|
|
18348
|
-
tag: 'span[style*="background-color"]'
|
|
18349
|
-
}
|
|
18350
|
-
];
|
|
18351
|
-
}
|
|
18352
|
-
});
|
|
18353
|
-
const DocumentFontFamily = font_family.extend({
|
|
18354
|
-
addCommands () {
|
|
18355
|
-
return {
|
|
18356
|
-
setFontFamily: (fontFamily)=>({ chain })=>chain().setMark('textStyle', {
|
|
18357
|
-
fontFamily,
|
|
18358
|
-
wordLineHeightFactor: documentWordLineHeightFactor(fontFamily)
|
|
18359
|
-
}).run(),
|
|
18360
|
-
unsetFontFamily: ()=>({ chain })=>chain().setMark('textStyle', {
|
|
18361
|
-
fontFamily: null,
|
|
18362
|
-
wordLineHeightFactor: null
|
|
18363
|
-
}).removeEmptyTextStyle().run()
|
|
18364
|
-
};
|
|
18365
|
-
}
|
|
18366
|
-
});
|
|
18367
|
-
function firstCssFontFamily(value) {
|
|
18368
|
-
const source = value.trim();
|
|
18369
|
-
if (!source) return '';
|
|
18370
|
-
const quote = source[0];
|
|
18371
|
-
if ('"' === quote || "'" === quote) {
|
|
18372
|
-
const end = source.indexOf(quote, 1);
|
|
18373
|
-
if (end > 0) return source.slice(1, end).trim();
|
|
18374
|
-
}
|
|
18375
|
-
return (source.split(',')[0] ?? source).trim().replace(/^(['"])(.*)\1$/, '$2');
|
|
18376
|
-
}
|
|
18377
|
-
function normalizedBoolean(value) {
|
|
18378
|
-
if (true === value || 'true' === value || '1' === value) return true;
|
|
18379
|
-
if (false === value || 'false' === value || '0' === value) return false;
|
|
18380
|
-
return null;
|
|
18381
|
-
}
|
|
18382
|
-
function themeReferenceAttribute(datasetKey) {
|
|
18383
|
-
return {
|
|
18384
|
-
default: null,
|
|
18385
|
-
parseHTML: (element)=>serializeDocxThemeReference(parseDocxThemeReference(element.dataset[datasetKey])) ?? null,
|
|
18386
|
-
renderHTML: (attributes)=>{
|
|
18387
|
-
const value = serializeDocxThemeReference(parseDocxThemeReference('string' == typeof attributes['officeThemeColor' === datasetKey ? 'themeColor' : 'themeFill'] ? String(attributes['officeThemeColor' === datasetKey ? 'themeColor' : 'themeFill']) : null));
|
|
18388
|
-
return value ? {
|
|
18389
|
-
[`data-${toKebabCase(datasetKey)}`]: value
|
|
18390
|
-
} : {};
|
|
18391
|
-
}
|
|
18392
|
-
};
|
|
18393
|
-
}
|
|
18394
|
-
function toKebabCase(value) {
|
|
18395
|
-
return value.replace(/[A-Z]/g, (character)=>`-${character.toLowerCase()}`);
|
|
18396
|
-
}
|
|
18397
19783
|
function createWorkDocumentExtensions(options = {}) {
|
|
18398
19784
|
const changeExtension = DocumentChange.configure({
|
|
18399
19785
|
...options.isTracking ? {
|
|
@@ -18430,6 +19816,7 @@ function createWorkDocumentExtensions(options = {}) {
|
|
|
18430
19816
|
openOnClick: false
|
|
18431
19817
|
},
|
|
18432
19818
|
underline: false,
|
|
19819
|
+
strike: false,
|
|
18433
19820
|
bulletList: false,
|
|
18434
19821
|
orderedList: false,
|
|
18435
19822
|
trailingNode: {
|
|
@@ -18462,7 +19849,9 @@ function createWorkDocumentExtensions(options = {}) {
|
|
|
18462
19849
|
commentExtension,
|
|
18463
19850
|
DocumentNoteReference,
|
|
18464
19851
|
DocumentNote,
|
|
18465
|
-
|
|
19852
|
+
DocumentUnderline,
|
|
19853
|
+
DocumentStrike,
|
|
19854
|
+
DocumentCharacterFormatting,
|
|
18466
19855
|
DocumentSubscript,
|
|
18467
19856
|
DocumentSuperscript,
|
|
18468
19857
|
DocumentImage.configure({
|
|
@@ -18491,6 +19880,7 @@ function createWorkDocumentExtensions(options = {}) {
|
|
|
18491
19880
|
DocumentTableFormatting,
|
|
18492
19881
|
DocumentTableSizing,
|
|
18493
19882
|
DocumentTextStyle,
|
|
19883
|
+
DocumentScriptFontFormatting,
|
|
18494
19884
|
DocumentFontFamily,
|
|
18495
19885
|
font_size,
|
|
18496
19886
|
extension_color,
|
|
@@ -20313,4 +21703,4 @@ function registerDocumentPageSurfaceGeometry(element, provider) {
|
|
|
20313
21703
|
function documentPageSurfaceGeometryForElement(element) {
|
|
20314
21704
|
return documentPageSurfaceProviders.get(element)?.() ?? null;
|
|
20315
21705
|
}
|
|
20316
|
-
export { DEFAULT_DOCUMENT_TABLE_CELL_FORMAT, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, DEFAULT_DOCUMENT_TABLE_GEOMETRY, DOCUMENT_BOOKMARK_DUPLICATE_MESSAGE, DOCUMENT_CHUNK_HYDRATION_META, DOCUMENT_CHUNK_PAGINATION_META, DOCUMENT_CHUNK_VISIBLE_IDS_META, DOCUMENT_PAGE_BORDER_EDGES, DOCUMENT_PAGE_MARGIN_KEYS, DOCUMENT_PARAGRAPH_BORDER_EDGES, DOCUMENT_PARAGRAPH_BORDER_STYLES, DOCUMENT_PARAGRAPH_SHADING_PATTERNS, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, DOCUMENT_TABLE_STYLE_OPTIONS, DocumentEquation, DocumentImage, DocumentParagraphFormatting, DocumentParagraphIdentity, DocumentSubscript, DocumentSuperscript, DocumentTableRowIdentity, DocxThemePatchCollector, MAX_DOCUMENT_IMAGE_RELATIVE_HEIGHT, MAX_DOCUMENT_NUMBERING_START, activeDocumentBookmark, activeDocumentSection, activeDocumentTableStyle, applyDocumentImageCropToElement, applyDocumentImageIdentityToElement, applyDocumentImageLayerToElement, applyDocumentImageWrapContourToElement, applyDocumentPageGeometry, applyDocumentParagraphIdentityToElement, applyDocumentTableGeometryToElement, applyDocumentTableRowIdentityToElement, canChangeDocumentIndent, canInsertDocumentComment, canSetDocumentTableRowRepeatHeader, clampDocumentMargin, collectDocumentChanges, collectDocumentCommentAnchors, collectDocumentNotes, collectDocumentTextLayoutParagraphs, createDocumentBibliography, createDocumentEquationElement, createDocumentImageIdentityRegistry, createDocumentNoteElement, createDocumentParagraphIdentityRegistry, createSchemaDerivedWorkDocumentModel, createSchemaValidatedWorkDocumentModel, createWorkDocumentExtensions, createWorkDocumentModel, createWorkDocumentModelFromContent, createWorkOfficeDocumentCollaborationBinding as createOfficeDocumentCollaborationBinding, defaultDocumentImageWrapContour, documentAutoLineHeight, documentBookmarkNameExists, documentBookmarkReferenceInstruction, documentBulletListStyle, documentCaptionKind, documentCaptionLabel, documentChunkMountedIds, documentCitationCount, documentCitationInstruction, documentCitationStyle, documentCitationStyleDetails, documentCitationTags, documentCitationTagsFromInstruction, documentCommentDraftRange, documentCommentViews, documentContentLayoutProperties, documentEquationFromElement, documentEquationText, documentImageCropFromElement, documentImageIdentityFromElement, documentImageLayerFromElement, documentImageLayoutFromElement, documentImageLayoutOptions, documentImagePositionFromElement, documentImageProperties, documentImageWrapContourFromElement, documentInitialSectionLayout, documentLazyHtmlChunkFragment, documentLazyHtmlProjection, documentLazyHtmlProjectionFingerprint, documentModelForContent, documentModelForHtml, documentModelHasTrustedInitialIntegrityFeatures, documentModelUsesWindowing, documentNoteKey, documentNoteKind, documentOrderedListState, documentPageBordersVisible, documentPageChromeLegacyFields, documentPageGeometryForLayout, documentPageHorizontalMarginTwips, documentPageMarginBody, documentPageMarginsForLayout, documentPageMetrics, documentPageSurfaceGeometryForElement, documentPaperSizeForGeometry, documentParagraphBordersDomAttributes, documentParagraphDirection, documentParagraphIdentityFromElement, documentParagraphIndent, documentParagraphPagination, documentParagraphShadingDomAttributes, documentParagraphSpacing, documentParagraphTabStops, documentSectionById, documentSectionDomAttributes, documentSections, documentTabLeaderLabel, documentTableBordersFromElement, documentTableCellFormat, documentTableCellMarginOverridesFromElement, documentTableColumnPercentagesFromElement, documentTableGeometryFromElement, documentTableHorizontalAlignment, documentTableRowIdentityFromElement, documentTableRowOptions, documentTableSizing, documentTextLayoutBatches, documentTextStatistics, documentTransactionsOnlyHydrateChunks, documentWordLineHeightFactor, docxBookmarkReferenceTarget, docxDocumentFieldKind, editorDocumentBookmarkReferenceTargets, editorDocumentCaptionTargets, importedDocumentCharacterFormatting, initializeWorkOfficeDocumentCollaboration as initializeOfficeDocumentCollaboration, invalidateDocumentLazyHtmlProjection, isContourImageLayout, isDocumentParagraphArtBorderStyle, isValidDocumentCitationTag, materializeLazyDocumentEditorRoot, materializeWorkDocumentContent, measureDocumentLayoutBlocksIncrementally, millimetersToPixels, mountWorkLiveDocumentCapture, nextDocumentTabAlignment, normalizeDocumentBookmarkName, normalizeDocumentBookmarkNativeId, normalizeDocumentBookmarkReferencesHtml, normalizeDocumentBookmarksHtml, normalizeDocumentCaptionsHtml, normalizeDocumentCitationsHtml, normalizeDocumentColumns, normalizeDocumentEquation, normalizeDocumentFieldsHtml, normalizeDocumentHtml, normalizeDocumentImageAlignment, normalizeDocumentImageCrop, normalizeDocumentImageIdentity, normalizeDocumentImageLayer, normalizeDocumentImageLayoutOptions, normalizeDocumentImagePosition, normalizeDocumentImageWrapContour, normalizeDocumentImageWrapSide, normalizeDocumentNotesHtml, normalizeDocumentPageBorders, normalizeDocumentPageChrome, normalizeDocumentPageGeometry, normalizeDocumentPageMargins, normalizeDocumentPaperSource, normalizeDocumentParagraphBorder, normalizeDocumentParagraphBorders, normalizeDocumentParagraphId, normalizeDocumentParagraphIdentity, normalizeDocumentParagraphIndent, normalizeDocumentTabStops, normalizeDocumentTableBorderStyle, normalizeDocumentTableBorderWidth, normalizeDocumentTableRowHeightRule, normalizeDocumentTableRowIdentity, normalizeDocumentTableVerticalAlign, normalizeTableColor, normalizedTabPosition, pageTwipsToMillimeters, parseDocumentCharacterFormatting, parseDocumentParagraphBordersElement, parseDocumentParagraphFormatting, parseDocumentParagraphShadingElement, parseDocxThemeReference, patchDocumentLazyHtmlProjection, patchDocxThemeReferences, positionWorkLiveDocumentCapture, readWorkOfficeDocumentCollaboration as readOfficeDocumentCollaboration, registerDocumentPageSurfaceGeometry, renderDocumentAutoLineHeight, renderDocumentTableBorders, renderDocumentTableCellMarginOverrides, resolveDocumentPageBorders, resolveDocumentPageChrome, resolveDocumentPageMargins, resolveDocumentPageSize, resolveWorkDocumentEditorInput, retainAnchoredDocumentComments, sanitizeDocumentPageChromeHtml, selectedDocumentChunkId, serializeDocumentParagraphFormatting, serializeDocumentTabStops, serializeDocxThemeReference, serializeWorkDocumentNode, setCustomDocumentColumns, supportedDocxBookmarkReferenceInstruction, syncDocumentContentFromHtml, transferChangedDocumentTextStatistics, uniqueDocumentImageIdentity, uniqueDocumentParagraphIdentity, updateDocumentColumnWidth, updateDocumentCustomPageMillimeters, updateDocumentGutterPosition, updateDocumentMirrorMargins, updateDocumentPageChromeVariant, updateDocumentPageMarginMillimeters, updateDocumentPageMarginMode, updateDocumentPageOrientation, updateDocumentPaperSizePreset, validateDocumentBookmarkName, windowDocumentModel, workDocumentSchema, workOfficeDocumentCollaborationFragment as officeDocumentCollaborationFragment, work_document_page_margins_twipsToMillimeters, wrapsBesideImage };
|
|
21706
|
+
export { DEFAULT_DOCUMENT_TABLE_CELL_FORMAT, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, DEFAULT_DOCUMENT_TABLE_GEOMETRY, DOCUMENT_BOOKMARK_DUPLICATE_MESSAGE, DOCUMENT_CHUNK_HYDRATION_META, DOCUMENT_CHUNK_PAGINATION_META, DOCUMENT_CHUNK_VISIBLE_IDS_META, DOCUMENT_PAGE_BORDER_EDGES, DOCUMENT_PAGE_MARGIN_KEYS, DOCUMENT_PARAGRAPH_BORDER_EDGES, DOCUMENT_PARAGRAPH_BORDER_STYLES, DOCUMENT_PARAGRAPH_SHADING_PATTERNS, DOCUMENT_STRIKE_STYLE_ATTRIBUTE, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, DOCUMENT_TABLE_STYLE_OPTIONS, DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE, DocumentCharacterFormatting, DocumentEquation, DocumentFontFamily, DocumentImage, DocumentParagraphFormatting, DocumentParagraphIdentity, DocumentScriptFontFormatting, DocumentStrike, DocumentSubscript, DocumentSuperscript, DocumentTableRowIdentity, DocumentTextStyle, DocumentUnderline, DocxThemePatchCollector, MAX_DOCUMENT_IMAGE_RELATIVE_HEIGHT, MAX_DOCUMENT_NUMBERING_START, activeDocumentBookmark, activeDocumentSection, activeDocumentTableStyle, applyDocumentImageCropToElement, applyDocumentImageIdentityToElement, applyDocumentImageLayerToElement, applyDocumentImageWrapContourToElement, applyDocumentPageGeometry, applyDocumentParagraphIdentityToElement, applyDocumentTableGeometryToElement, applyDocumentTableRowIdentityToElement, applyDocumentTextCaseStyle, canChangeDocumentIndent, canInsertDocumentComment, canSetDocumentTableRowRepeatHeader, clampDocumentMargin, collectDocumentChanges, collectDocumentCommentAnchors, collectDocumentNotes, collectDocumentTextLayoutParagraphs, createDocumentBibliography, createDocumentEquationElement, createDocumentImageIdentityRegistry, createDocumentNoteElement, createDocumentParagraphIdentityRegistry, createSchemaDerivedWorkDocumentModel, createSchemaValidatedWorkDocumentModel, createWorkDocumentExtensions, createWorkDocumentModel, createWorkDocumentModelFromContent, createWorkOfficeDocumentCollaborationBinding as createOfficeDocumentCollaborationBinding, cssDocumentFontFamily, defaultDocumentImageWrapContour, documentAutoLineHeight, documentBookmarkNameExists, documentBookmarkReferenceInstruction, documentBulletListStyle, documentCaptionKind, documentCaptionLabel, documentCharacterPositionDomAttributes, documentCharacterPositionHalfPointsFromElement, documentCharacterPositionPoints, documentCharacterScaleDomAttributes, documentCharacterScalePercentFromElement, documentCharacterSpacingDomAttributes, documentCharacterSpacingPoints, documentCharacterSpacingTwipsFromElement, documentChunkMountedIds, documentCitationCount, documentCitationInstruction, documentCitationStyle, documentCitationStyleDetails, documentCitationTags, documentCitationTagsFromInstruction, documentCommentDraftRange, documentCommentViews, documentContentLayoutProperties, documentEmphasisMarkDomAttributes, documentEmphasisMarkFromElement, documentEquationFromElement, documentEquationText, documentFontNameFromCssFamily, documentHiddenTextDomAttributes, documentHiddenTextFromElement, documentHiddenTextKeyboardShortcut, documentImageCropFromElement, documentImageIdentityFromElement, documentImageLayerFromElement, documentImageLayoutFromElement, documentImageLayoutOptions, documentImagePositionFromElement, documentImageProperties, documentImageWrapContourFromElement, documentInitialSectionLayout, documentKerningDomAttributes, documentKerningIsEffective, documentKerningThresholdHalfPointsFromElement, documentKerningThresholdPoints, documentLazyHtmlChunkFragment, documentLazyHtmlProjection, documentLazyHtmlProjectionFingerprint, documentModelForContent, documentModelForHtml, documentModelHasTrustedInitialIntegrityFeatures, documentModelUsesWindowing, documentNoteKey, documentNoteKind, documentOrderedListState, documentPageBordersVisible, documentPageChromeLegacyFields, documentPageGeometryForLayout, documentPageHorizontalMarginTwips, documentPageMarginBody, documentPageMarginsForLayout, documentPageMetrics, documentPageSurfaceGeometryForElement, documentPaperSizeForGeometry, documentParagraphBordersDomAttributes, documentParagraphDirection, documentParagraphIdentityFromElement, documentParagraphIndent, documentParagraphPagination, documentParagraphShadingDomAttributes, documentParagraphSpacing, documentParagraphTabStops, documentScriptFontDirectFamily, documentScriptFontFallbackSlots, documentScriptFontFamily, documentScriptFontFamilyForRendering, documentScriptFontSegments, documentScriptFontSlotFromElement, documentScriptFontSlotFromHint, documentScriptFontsDomAttributes, documentScriptFontsFromElement, documentSectionById, documentSectionDomAttributes, documentSections, documentStrikeDomAttributes, documentStrikeFormattingFromElement, documentStrikeStyle, documentTabLeaderLabel, documentTableBordersFromElement, documentTableCellFormat, documentTableCellMarginOverridesFromElement, documentTableColumnPercentagesFromElement, documentTableGeometryFromElement, documentTableHorizontalAlignment, documentTableRowIdentityFromElement, documentTableRowOptions, documentTableSizing, documentTextCaseFromWordFlags, documentTextCaseKeyboardShortcuts, documentTextLayoutBatches, documentTextStatistics, documentTransactionsOnlyHydrateChunks, documentUnderlineColor, documentUnderlineDomAttributes, documentUnderlineFormattingFromElement, documentUnderlineKeyboardShortcuts, documentUnderlineStyle, documentWordLineHeightFactor, docxBookmarkReferenceTarget, docxDocumentFieldKind, editorDocumentBookmarkReferenceTargets, editorDocumentCaptionTargets, importedDocumentCharacterFormatting, initializeWorkOfficeDocumentCollaboration as initializeOfficeDocumentCollaboration, invalidateDocumentLazyHtmlProjection, isContourImageLayout, isDocumentParagraphArtBorderStyle, isValidDocumentCitationTag, materializeLazyDocumentEditorRoot, materializeWorkDocumentContent, measureDocumentLayoutBlocksIncrementally, millimetersToPixels, mountWorkLiveDocumentCapture, nextDocumentTabAlignment, normalizeDocumentBookmarkName, normalizeDocumentBookmarkNativeId, normalizeDocumentBookmarkReferencesHtml, normalizeDocumentBookmarksHtml, normalizeDocumentCaptionsHtml, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentCharacterScalePercent, normalizeDocumentCharacterSpacingTwips, normalizeDocumentCitationsHtml, normalizeDocumentColumns, normalizeDocumentEmphasisMark, normalizeDocumentEquation, normalizeDocumentFieldsHtml, normalizeDocumentFontName, normalizeDocumentHiddenText, normalizeDocumentHtml, normalizeDocumentImageAlignment, normalizeDocumentImageCrop, normalizeDocumentImageIdentity, normalizeDocumentImageLayer, normalizeDocumentImageLayoutOptions, normalizeDocumentImagePosition, normalizeDocumentImageWrapContour, normalizeDocumentImageWrapSide, normalizeDocumentKerningThresholdHalfPoints, normalizeDocumentNotesHtml, normalizeDocumentPageBorders, normalizeDocumentPageChrome, normalizeDocumentPageGeometry, normalizeDocumentPageMargins, normalizeDocumentPaperSource, normalizeDocumentParagraphBorder, normalizeDocumentParagraphBorders, normalizeDocumentParagraphId, normalizeDocumentParagraphIdentity, normalizeDocumentParagraphIndent, normalizeDocumentScriptFontHint, normalizeDocumentScriptFontSlot, normalizeDocumentScriptFonts, normalizeDocumentStrikeStyle, normalizeDocumentTabStops, normalizeDocumentTableBorderStyle, normalizeDocumentTableBorderWidth, normalizeDocumentTableRowHeightRule, normalizeDocumentTableRowIdentity, normalizeDocumentTableVerticalAlign, normalizeDocumentTextCase, normalizeDocumentThemeFont, normalizeDocumentUnderlineColor, normalizeDocumentUnderlineStyle, normalizeTableColor, normalizedTabPosition, pageTwipsToMillimeters, parseDocumentCharacterFormatting, parseDocumentParagraphBordersElement, parseDocumentParagraphFormatting, parseDocumentParagraphShadingElement, parseDocumentScriptFonts, parseDocxThemeReference, patchDocumentLazyHtmlProjection, patchDocumentScriptFonts, patchDocxThemeReferences, positionWorkLiveDocumentCapture, readWorkOfficeDocumentCollaboration as readOfficeDocumentCollaboration, registerDocumentPageSurfaceGeometry, renderDocumentAutoLineHeight, renderDocumentTableBorders, renderDocumentTableCellMarginOverrides, resolveDocumentPageBorders, resolveDocumentPageChrome, resolveDocumentPageMargins, resolveDocumentPageSize, resolveWorkDocumentEditorInput, retainAnchoredDocumentComments, sanitizeDocumentPageChromeHtml, selectedDocumentChunkId, serializeDocumentParagraphFormatting, serializeDocumentScriptFonts, serializeDocumentTabStops, serializeDocxThemeReference, serializeWorkDocumentNode, setCustomDocumentColumns, supportedDocxBookmarkReferenceInstruction, syncDocumentContentFromHtml, transferChangedDocumentTextStatistics, uniqueDocumentImageIdentity, uniqueDocumentParagraphIdentity, updateDocumentColumnWidth, updateDocumentCustomPageMillimeters, updateDocumentGutterPosition, updateDocumentMirrorMargins, updateDocumentPageChromeVariant, updateDocumentPageMarginMillimeters, updateDocumentPageMarginMode, updateDocumentPageOrientation, updateDocumentPaperSizePreset, validateDocumentBookmarkName, windowDocumentModel, workDocumentSchema, workOfficeDocumentCollaborationFragment as officeDocumentCollaborationFragment, work_document_page_margins_twipsToMillimeters, wrapsBesideImage };
|