@a3s-lab/office 0.26.0 → 0.28.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 +89 -2
- package/dist/0~4595.js +16 -2
- package/dist/0~5093.js +563 -201
- package/dist/0~6090.js +77 -77
- package/dist/{0~2805.js → 0~7043.js} +305 -2
- package/dist/0~document-editor.js +2633 -976
- package/dist/0~spreadsheet-editor.js +1324 -378
- package/dist/0~work-docx-export.js +737 -17
- package/dist/0~work-docx-import.js +173 -98
- package/dist/0~work-office-diagnostics.js +250 -5
- package/dist/{164.js → 1544.js} +1083 -785
- package/dist/4104.js +145 -29
- package/dist/5184.js +13 -0
- package/dist/6282.js +1898 -345
- 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 +111 -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 +20 -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-legacy-text-effects.d.ts +27 -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 +16 -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 +17 -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-legacy-text-effects-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-legacy-text-effects-export.d.ts +18 -0
- package/dist/internal/features/work/work-docx-legacy-text-effects.d.ts +12 -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 +27 -2
- package/dist/internal/features/work/work-docx-run-property-order.d.ts +2 -0
- 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 +809 -78
- package/docs/latest/en/browser-editor-architecture.md +24 -0
- package/package.json +35 -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,207 @@ 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
|
+
}
|
|
6902
|
+
const DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE = 'data-office-legacy-text-outline';
|
|
6903
|
+
const DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE = 'data-office-legacy-text-shadow';
|
|
6904
|
+
const DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE = 'data-office-legacy-text-emboss';
|
|
6905
|
+
const DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE = 'data-office-legacy-text-imprint';
|
|
6906
|
+
const DOCUMENT_LEGACY_TEXT_EFFECT_NAMES = [
|
|
6907
|
+
'outline',
|
|
6908
|
+
'shadow',
|
|
6909
|
+
'emboss',
|
|
6910
|
+
'imprint'
|
|
6911
|
+
];
|
|
6912
|
+
const ATTRIBUTE_BY_EFFECT = {
|
|
6913
|
+
outline: DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE,
|
|
6914
|
+
shadow: DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE,
|
|
6915
|
+
emboss: DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE,
|
|
6916
|
+
imprint: DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE
|
|
6917
|
+
};
|
|
6918
|
+
const TEXT_STYLE_ATTRIBUTE_BY_EFFECT = {
|
|
6919
|
+
outline: 'legacyTextOutline',
|
|
6920
|
+
shadow: 'legacyTextShadow',
|
|
6921
|
+
emboss: 'legacyTextEmboss',
|
|
6922
|
+
imprint: 'legacyTextImprint'
|
|
6923
|
+
};
|
|
6924
|
+
function normalizeDocumentLegacyTextEffect(value) {
|
|
6925
|
+
if (true === value || 'true' === value || '1' === value) return true;
|
|
6926
|
+
if (false === value || 'false' === value || '0' === value) return false;
|
|
6927
|
+
return null;
|
|
6928
|
+
}
|
|
6929
|
+
function normalizeDocumentLegacyTextEffects(value) {
|
|
6930
|
+
if (!work_document_legacy_text_effects_isRecord(value)) return null;
|
|
6931
|
+
const allowed = new Set(DOCUMENT_LEGACY_TEXT_EFFECT_NAMES);
|
|
6932
|
+
if (Object.keys(value).some((key)=>!allowed.has(key))) return null;
|
|
6933
|
+
const effects = {};
|
|
6934
|
+
for (const name of DOCUMENT_LEGACY_TEXT_EFFECT_NAMES)if (Object.hasOwn(value, name)) {
|
|
6935
|
+
if ('boolean' != typeof value[name]) return null;
|
|
6936
|
+
effects[name] = value[name];
|
|
6937
|
+
}
|
|
6938
|
+
return documentLegacyTextEffectsConflict(effects) ? null : effects;
|
|
6939
|
+
}
|
|
6940
|
+
function documentLegacyTextEffectsConflict(effects) {
|
|
6941
|
+
if (true === effects.emboss && (true === effects.outline || true === effects.shadow || true === effects.imprint)) return true;
|
|
6942
|
+
return true === effects.imprint && (true === effects.outline || true === effects.shadow || true === effects.emboss);
|
|
6943
|
+
}
|
|
6944
|
+
function documentLegacyTextEffectFromElement(element, effect) {
|
|
6945
|
+
return normalizeDocumentLegacyTextEffect(element.getAttribute(ATTRIBUTE_BY_EFFECT[effect]));
|
|
6946
|
+
}
|
|
6947
|
+
function documentLegacyTextEffectsFromElement(element) {
|
|
6948
|
+
const effects = {};
|
|
6949
|
+
for (const name of DOCUMENT_LEGACY_TEXT_EFFECT_NAMES){
|
|
6950
|
+
const attribute = ATTRIBUTE_BY_EFFECT[name];
|
|
6951
|
+
const value = documentLegacyTextEffectFromElement(element, name);
|
|
6952
|
+
if (element.hasAttribute(attribute) && null === value) return null;
|
|
6953
|
+
if (null !== value) effects[name] = value;
|
|
6954
|
+
}
|
|
6955
|
+
return documentLegacyTextEffectsConflict(effects) ? null : effects;
|
|
6956
|
+
}
|
|
6957
|
+
function documentLegacyTextEffectsFromTextStyleAttributes(attributes) {
|
|
6958
|
+
const effects = {};
|
|
6959
|
+
for (const name of DOCUMENT_LEGACY_TEXT_EFFECT_NAMES){
|
|
6960
|
+
const rawValue = attributes[TEXT_STYLE_ATTRIBUTE_BY_EFFECT[name]];
|
|
6961
|
+
if (null == rawValue) continue;
|
|
6962
|
+
const value = normalizeDocumentLegacyTextEffect(rawValue);
|
|
6963
|
+
if (null === value) return null;
|
|
6964
|
+
if (null !== value) effects[name] = value;
|
|
6965
|
+
}
|
|
6966
|
+
return documentLegacyTextEffectsConflict(effects) ? null : effects;
|
|
6967
|
+
}
|
|
6968
|
+
function documentLegacyTextEffectsDomAttributes(value) {
|
|
6969
|
+
const effects = normalizeDocumentLegacyTextEffects(value);
|
|
6970
|
+
if (!effects) return {};
|
|
6971
|
+
return Object.fromEntries(DOCUMENT_LEGACY_TEXT_EFFECT_NAMES.flatMap((name)=>void 0 === effects[name] ? [] : [
|
|
6972
|
+
[
|
|
6973
|
+
ATTRIBUTE_BY_EFFECT[name],
|
|
6974
|
+
String(effects[name])
|
|
6975
|
+
]
|
|
6976
|
+
]));
|
|
6977
|
+
}
|
|
6978
|
+
function documentLegacyTextEffectsCss(value) {
|
|
6979
|
+
const effects = normalizeDocumentLegacyTextEffects(value);
|
|
6980
|
+
if (!effects) return {};
|
|
6981
|
+
if (effects.emboss) return {
|
|
6982
|
+
textShadow: '-0.045em -0.045em 0 rgba(255, 255, 255, 0.9), 0.045em 0.045em 0 rgba(0, 0, 0, 0.52)'
|
|
6983
|
+
};
|
|
6984
|
+
if (effects.imprint) return {
|
|
6985
|
+
textShadow: '0.045em 0.045em 0 rgba(255, 255, 255, 0.9), -0.045em -0.045em 0 rgba(0, 0, 0, 0.52)'
|
|
6986
|
+
};
|
|
6987
|
+
return {
|
|
6988
|
+
...effects.outline ? {
|
|
6989
|
+
WebkitTextFillColor: 'transparent',
|
|
6990
|
+
WebkitTextStroke: '0.045em currentColor',
|
|
6991
|
+
paintOrder: 'stroke fill'
|
|
6992
|
+
} : {},
|
|
6993
|
+
...effects.shadow ? {
|
|
6994
|
+
textShadow: '0.08em 0.08em 0 currentColor'
|
|
6995
|
+
} : {}
|
|
6996
|
+
};
|
|
6997
|
+
}
|
|
6998
|
+
function documentLegacyTextStyleAttributeName(effect) {
|
|
6999
|
+
return TEXT_STYLE_ATTRIBUTE_BY_EFFECT[effect];
|
|
7000
|
+
}
|
|
7001
|
+
function work_document_legacy_text_effects_isRecord(value) {
|
|
7002
|
+
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
7003
|
+
}
|
|
6708
7004
|
const IMAGE_OBJECT_ID_PATTERN = /^[0-9A-F]{8}$/;
|
|
6709
7005
|
const MAX_DOC_PROPERTIES_ID = 0xffffffff;
|
|
6710
7006
|
const MAX_WORDPROCESSING_ID = 0x7fffffff;
|
|
@@ -7714,154 +8010,897 @@ function work_document_table_row_identity_transactionMapping(transactions) {
|
|
|
7714
8010
|
for (const transaction of transactions)mapping.appendMapping(transaction.mapping);
|
|
7715
8011
|
return mapping;
|
|
7716
8012
|
}
|
|
7717
|
-
const
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
8013
|
+
const DOCUMENT_TEXT_CASE_ATTRIBUTE = 'data-office-text-case';
|
|
8014
|
+
const documentTextCaseKeyboardShortcuts = {
|
|
8015
|
+
allCaps: 'Mod-Shift-a',
|
|
8016
|
+
smallCaps: 'Mod-Shift-k'
|
|
7721
8017
|
};
|
|
7722
|
-
|
|
7723
|
-
'
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
'
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
'
|
|
7750
|
-
'
|
|
7751
|
-
'
|
|
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'
|
|
8018
|
+
function normalizeDocumentTextCase(value) {
|
|
8019
|
+
return 'none' === value || 'all-caps' === value || 'small-caps' === value ? value : null;
|
|
8020
|
+
}
|
|
8021
|
+
function documentTextCaseFromWordFlags(allCaps, smallCaps) {
|
|
8022
|
+
if (void 0 === allCaps && void 0 === smallCaps) return null;
|
|
8023
|
+
if (allCaps) return 'all-caps';
|
|
8024
|
+
if (smallCaps) return 'small-caps';
|
|
8025
|
+
return 'none';
|
|
8026
|
+
}
|
|
8027
|
+
function applyDocumentTextCaseStyle(element, textCase) {
|
|
8028
|
+
element.dataset.officeTextCase = textCase;
|
|
8029
|
+
element.style.textTransform = 'all-caps' === textCase ? 'uppercase' : 'none';
|
|
8030
|
+
element.style.fontVariantCaps = 'small-caps' === textCase ? 'small-caps' : 'normal';
|
|
8031
|
+
}
|
|
8032
|
+
function documentTextCaseCss(textCase) {
|
|
8033
|
+
return [
|
|
8034
|
+
`text-transform: ${'all-caps' === textCase ? 'uppercase' : 'none'}`,
|
|
8035
|
+
`font-variant-caps: ${'small-caps' === textCase ? 'small-caps' : 'normal'}`
|
|
8036
|
+
].join('; ');
|
|
8037
|
+
}
|
|
8038
|
+
const DOCUMENT_SCRIPT_FONTS_ATTRIBUTE = "data-office-script-fonts";
|
|
8039
|
+
const DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE = "data-office-script-font-slot";
|
|
8040
|
+
const MAX_FONT_NAME_LENGTH = 127;
|
|
8041
|
+
const MAX_SERIALIZED_SCRIPT_FONTS_LENGTH = 4096;
|
|
8042
|
+
const SCRIPT_FONT_KEYS = new Set([
|
|
8043
|
+
'ascii',
|
|
8044
|
+
'highAnsi',
|
|
8045
|
+
'eastAsia',
|
|
8046
|
+
'complexScript',
|
|
8047
|
+
'hint'
|
|
7772
8048
|
]);
|
|
7773
|
-
const
|
|
7774
|
-
|
|
7775
|
-
'
|
|
7776
|
-
'
|
|
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'
|
|
8049
|
+
const SCRIPT_FONT_FACE_KEYS = new Set([
|
|
8050
|
+
'name',
|
|
8051
|
+
'theme',
|
|
8052
|
+
'resolved'
|
|
7800
8053
|
]);
|
|
7801
|
-
const
|
|
7802
|
-
'
|
|
7803
|
-
'
|
|
7804
|
-
'
|
|
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'
|
|
8054
|
+
const SCRIPT_FONT_HINTS = new Set([
|
|
8055
|
+
'default',
|
|
8056
|
+
'eastAsia',
|
|
8057
|
+
'cs'
|
|
7852
8058
|
]);
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
8059
|
+
const work_document_script_fonts_THEME_FONTS = new Set([
|
|
8060
|
+
'majorEastAsia',
|
|
8061
|
+
'majorBidi',
|
|
8062
|
+
'majorAscii',
|
|
8063
|
+
'majorHAnsi',
|
|
8064
|
+
'minorEastAsia',
|
|
8065
|
+
'minorBidi',
|
|
8066
|
+
'minorAscii',
|
|
8067
|
+
'minorHAnsi'
|
|
8068
|
+
]);
|
|
8069
|
+
const SLOT_FALLBACK_ORDER = {
|
|
8070
|
+
ascii: [
|
|
8071
|
+
'ascii',
|
|
8072
|
+
'highAnsi',
|
|
8073
|
+
'eastAsia',
|
|
8074
|
+
'complexScript'
|
|
8075
|
+
],
|
|
8076
|
+
highAnsi: [
|
|
8077
|
+
'highAnsi',
|
|
8078
|
+
'ascii',
|
|
8079
|
+
'eastAsia',
|
|
8080
|
+
'complexScript'
|
|
8081
|
+
],
|
|
8082
|
+
eastAsia: [
|
|
8083
|
+
'eastAsia',
|
|
8084
|
+
'highAnsi',
|
|
8085
|
+
'ascii',
|
|
8086
|
+
'complexScript'
|
|
8087
|
+
],
|
|
8088
|
+
complexScript: [
|
|
8089
|
+
'complexScript',
|
|
8090
|
+
'highAnsi',
|
|
8091
|
+
'ascii',
|
|
8092
|
+
'eastAsia'
|
|
8093
|
+
]
|
|
8094
|
+
};
|
|
8095
|
+
const NEUTRAL_SCRIPT_CHARACTER = /^[\p{Cc}\p{Cf}\p{M}\p{N}\p{P}\p{S}\p{Z}]$/u;
|
|
8096
|
+
function normalizeDocumentScriptFonts(source) {
|
|
8097
|
+
if (!work_document_script_fonts_isRecordWithKeys(source, SCRIPT_FONT_KEYS)) return null;
|
|
8098
|
+
const normalized = {};
|
|
8099
|
+
for (const slot of scriptFontSlots){
|
|
8100
|
+
if (void 0 === source[slot]) continue;
|
|
8101
|
+
const face = normalizeDocumentScriptFontFace(source[slot]);
|
|
8102
|
+
if (!face) return null;
|
|
8103
|
+
normalized[slot] = face;
|
|
8104
|
+
}
|
|
8105
|
+
if (void 0 !== source.hint) {
|
|
8106
|
+
const hint = normalizeDocumentScriptFontHint(source.hint);
|
|
8107
|
+
if (!hint) return null;
|
|
8108
|
+
normalized.hint = hint;
|
|
8109
|
+
}
|
|
8110
|
+
return Object.keys(normalized).length ? normalized : null;
|
|
8111
|
+
}
|
|
8112
|
+
function serializeDocumentScriptFonts(source) {
|
|
8113
|
+
const fonts = normalizeDocumentScriptFonts(source);
|
|
8114
|
+
return fonts ? JSON.stringify(fonts) : null;
|
|
8115
|
+
}
|
|
8116
|
+
function parseDocumentScriptFonts(source) {
|
|
8117
|
+
if (!source || source.length > MAX_SERIALIZED_SCRIPT_FONTS_LENGTH) return null;
|
|
8118
|
+
try {
|
|
8119
|
+
return normalizeDocumentScriptFonts(JSON.parse(source));
|
|
8120
|
+
} catch {
|
|
8121
|
+
return null;
|
|
8122
|
+
}
|
|
8123
|
+
}
|
|
8124
|
+
function documentScriptFontsFromElement(element) {
|
|
8125
|
+
return parseDocumentScriptFonts(element.getAttribute(DOCUMENT_SCRIPT_FONTS_ATTRIBUTE));
|
|
8126
|
+
}
|
|
8127
|
+
function documentScriptFontSlotFromElement(element) {
|
|
8128
|
+
return normalizeDocumentScriptFontSlot(element.getAttribute(DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE));
|
|
8129
|
+
}
|
|
8130
|
+
function documentScriptFontsDomAttributes(source, slot) {
|
|
8131
|
+
const fonts = normalizeDocumentScriptFonts(source);
|
|
8132
|
+
const normalizedSlot = normalizeDocumentScriptFontSlot(slot);
|
|
8133
|
+
if (!fonts) return {};
|
|
8134
|
+
const serialized = serializeDocumentScriptFonts(fonts);
|
|
8135
|
+
if (!serialized) return {};
|
|
8136
|
+
const family = documentScriptFontFamily(fonts, normalizedSlot ?? documentScriptFontSlotFromHint(fonts.hint));
|
|
8137
|
+
return {
|
|
8138
|
+
[DOCUMENT_SCRIPT_FONTS_ATTRIBUTE]: serialized,
|
|
8139
|
+
...normalizedSlot ? {
|
|
8140
|
+
[DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE]: normalizedSlot
|
|
8141
|
+
} : {},
|
|
8142
|
+
...family ? {
|
|
8143
|
+
style: `font-family: ${family}`
|
|
8144
|
+
} : {}
|
|
8145
|
+
};
|
|
8146
|
+
}
|
|
8147
|
+
function documentScriptFontFamily(source, slot) {
|
|
8148
|
+
const fonts = normalizeDocumentScriptFonts(source);
|
|
8149
|
+
if (!fonts) return;
|
|
8150
|
+
const families = [];
|
|
8151
|
+
const seen = new Set();
|
|
8152
|
+
for (const candidate of documentScriptFontFallbackSlots(slot)){
|
|
8153
|
+
const family = documentScriptFontFaceFamily(fonts[candidate]);
|
|
8154
|
+
const key = family?.toLocaleLowerCase();
|
|
8155
|
+
if (!(!family || !key || seen.has(key))) {
|
|
8156
|
+
seen.add(key);
|
|
8157
|
+
families.push(cssFontFamily(family));
|
|
8158
|
+
}
|
|
8159
|
+
}
|
|
8160
|
+
return families.length ? families.join(', ') : void 0;
|
|
8161
|
+
}
|
|
8162
|
+
function documentScriptFontFallbackSlots(slot) {
|
|
8163
|
+
return SLOT_FALLBACK_ORDER[slot];
|
|
8164
|
+
}
|
|
8165
|
+
function documentScriptFontFamilyForRendering(source, slot, currentFontFamily) {
|
|
8166
|
+
const projected = documentScriptFontFamily(source, slot);
|
|
8167
|
+
const safeCurrent = safeCssFontFamilyList(currentFontFamily);
|
|
8168
|
+
if (!safeCurrent || !projected) return projected;
|
|
8169
|
+
const currentPrimary = documentFontNameFromCssFamily(safeCurrent);
|
|
8170
|
+
const projectedPrimary = documentFontNameFromCssFamily(projected);
|
|
8171
|
+
return currentPrimary && projectedPrimary && currentPrimary.toLocaleLowerCase() === projectedPrimary.toLocaleLowerCase() ? safeCurrent : projected;
|
|
8172
|
+
}
|
|
8173
|
+
function documentScriptFontDirectFamily(source, slot) {
|
|
8174
|
+
const fonts = normalizeDocumentScriptFonts(source);
|
|
8175
|
+
return fonts ? documentScriptFontFaceFamily(fonts[slot]) ?? null : null;
|
|
8176
|
+
}
|
|
8177
|
+
function documentScriptFontsForAllText(fontFamily) {
|
|
8178
|
+
const name = documentFontNameFromCssFamily(fontFamily);
|
|
8179
|
+
if (!name) return null;
|
|
8180
|
+
const face = {
|
|
8181
|
+
name,
|
|
8182
|
+
resolved: name
|
|
8183
|
+
};
|
|
8184
|
+
return {
|
|
8185
|
+
ascii: face,
|
|
8186
|
+
highAnsi: face,
|
|
8187
|
+
eastAsia: face,
|
|
8188
|
+
complexScript: face,
|
|
8189
|
+
hint: 'default'
|
|
8190
|
+
};
|
|
8191
|
+
}
|
|
8192
|
+
function patchDocumentScriptFonts(source, patch, fallbackFontFamily) {
|
|
8193
|
+
const current = normalizeDocumentScriptFonts(source) ?? documentScriptFontsForAllText(fallbackFontFamily) ?? {};
|
|
8194
|
+
const next = {
|
|
8195
|
+
...current
|
|
8196
|
+
};
|
|
8197
|
+
if (void 0 !== patch.latin) {
|
|
8198
|
+
const face = directFontFace(patch.latin);
|
|
8199
|
+
if (face) {
|
|
8200
|
+
next.ascii = face;
|
|
8201
|
+
next.highAnsi = face;
|
|
8202
|
+
} else {
|
|
8203
|
+
delete next.ascii;
|
|
8204
|
+
delete next.highAnsi;
|
|
8205
|
+
}
|
|
8206
|
+
}
|
|
8207
|
+
if (void 0 !== patch.eastAsia) {
|
|
8208
|
+
const face = directFontFace(patch.eastAsia);
|
|
8209
|
+
if (face) next.eastAsia = face;
|
|
8210
|
+
else delete next.eastAsia;
|
|
8211
|
+
}
|
|
8212
|
+
if (void 0 !== patch.complexScript) {
|
|
8213
|
+
const face = directFontFace(patch.complexScript);
|
|
8214
|
+
if (face) next.complexScript = face;
|
|
8215
|
+
else delete next.complexScript;
|
|
8216
|
+
}
|
|
8217
|
+
return normalizeDocumentScriptFonts(next);
|
|
8218
|
+
}
|
|
8219
|
+
function documentScriptFontSegments(text, hint = 'default', forceComplexScript = false) {
|
|
8220
|
+
if (!text) return [];
|
|
8221
|
+
if (forceComplexScript) return [
|
|
8222
|
+
{
|
|
8223
|
+
from: 0,
|
|
8224
|
+
to: text.length,
|
|
8225
|
+
slot: 'complexScript'
|
|
8226
|
+
}
|
|
8227
|
+
];
|
|
8228
|
+
const characters = [];
|
|
8229
|
+
let offset = 0;
|
|
8230
|
+
for (const character of text){
|
|
8231
|
+
const from = offset;
|
|
8232
|
+
offset += character.length;
|
|
8233
|
+
characters.push({
|
|
8234
|
+
from,
|
|
8235
|
+
to: offset,
|
|
8236
|
+
slot: strongDocumentScriptFontSlot(character)
|
|
8237
|
+
});
|
|
8238
|
+
}
|
|
8239
|
+
const fallback = documentScriptFontSlotFromHint(hint);
|
|
8240
|
+
let previous = null;
|
|
8241
|
+
for(let index = 0; index < characters.length; index += 1){
|
|
8242
|
+
const entry = characters[index];
|
|
8243
|
+
if (!entry) continue;
|
|
8244
|
+
if (entry.slot) {
|
|
8245
|
+
previous = entry.slot;
|
|
8246
|
+
continue;
|
|
8247
|
+
}
|
|
8248
|
+
let next = previous;
|
|
8249
|
+
if (!next) for(let cursor = index + 1; cursor < characters.length; cursor += 1){
|
|
8250
|
+
const candidate = characters[cursor]?.slot;
|
|
8251
|
+
if (candidate) {
|
|
8252
|
+
next = candidate;
|
|
8253
|
+
break;
|
|
8254
|
+
}
|
|
8255
|
+
}
|
|
8256
|
+
entry.slot = next ?? fallback;
|
|
8257
|
+
}
|
|
8258
|
+
const segments = [];
|
|
8259
|
+
for (const entry of characters){
|
|
8260
|
+
const slot = entry.slot ?? fallback;
|
|
8261
|
+
const prior = segments[segments.length - 1];
|
|
8262
|
+
if (prior?.slot === slot && prior.to === entry.from) prior.to = entry.to;
|
|
8263
|
+
else segments.push({
|
|
8264
|
+
from: entry.from,
|
|
8265
|
+
to: entry.to,
|
|
8266
|
+
slot
|
|
8267
|
+
});
|
|
8268
|
+
}
|
|
8269
|
+
return segments;
|
|
8270
|
+
}
|
|
8271
|
+
function normalizeDocumentScriptFontSlot(value) {
|
|
8272
|
+
return scriptFontSlots.includes(value) ? value : null;
|
|
8273
|
+
}
|
|
8274
|
+
function normalizeDocumentScriptFontHint(value) {
|
|
8275
|
+
return SCRIPT_FONT_HINTS.has(value) ? value : null;
|
|
8276
|
+
}
|
|
8277
|
+
function normalizeDocumentThemeFont(value) {
|
|
8278
|
+
return work_document_script_fonts_THEME_FONTS.has(value) ? value : null;
|
|
8279
|
+
}
|
|
8280
|
+
function documentScriptFontSlotFromHint(hint) {
|
|
8281
|
+
if ('eastAsia' === hint) return 'eastAsia';
|
|
8282
|
+
if ('cs' === hint) return 'complexScript';
|
|
8283
|
+
return 'ascii';
|
|
8284
|
+
}
|
|
8285
|
+
function documentFontNameFromCssFamily(value) {
|
|
8286
|
+
if ('string' != typeof value) return null;
|
|
8287
|
+
const source = value.trim();
|
|
8288
|
+
if (!source) return null;
|
|
8289
|
+
let family = '';
|
|
8290
|
+
const quote = source[0];
|
|
8291
|
+
if ('"' === quote || "'" === quote) {
|
|
8292
|
+
let closed = false;
|
|
8293
|
+
for(let index = 1; index < source.length; index += 1){
|
|
8294
|
+
const character = source[index];
|
|
8295
|
+
if (character === quote) {
|
|
8296
|
+
closed = true;
|
|
8297
|
+
break;
|
|
8298
|
+
}
|
|
8299
|
+
if ('\\' !== character) {
|
|
8300
|
+
family += character;
|
|
8301
|
+
continue;
|
|
8302
|
+
}
|
|
8303
|
+
const decoded = decodeCssEscape(source, index + 1);
|
|
8304
|
+
if (!decoded) return null;
|
|
8305
|
+
family += decoded.value;
|
|
8306
|
+
index = decoded.end - 1;
|
|
8307
|
+
}
|
|
8308
|
+
if (!closed) return null;
|
|
8309
|
+
} else family = source.split(',')[0] ?? '';
|
|
8310
|
+
return normalizeDocumentFontName(family);
|
|
8311
|
+
}
|
|
8312
|
+
function cssDocumentFontFamily(value) {
|
|
8313
|
+
const family = normalizeDocumentFontName(value);
|
|
8314
|
+
return family ? cssFontFamily(family) : null;
|
|
8315
|
+
}
|
|
8316
|
+
function normalizeDocumentFontName(value) {
|
|
8317
|
+
if ('string' != typeof value) return null;
|
|
8318
|
+
const normalized = value.trim();
|
|
8319
|
+
return normalized && normalized.length <= MAX_FONT_NAME_LENGTH && !/[\p{Cc}\p{Cs}]/u.test(normalized) ? normalized : null;
|
|
8320
|
+
}
|
|
8321
|
+
const scriptFontSlots = [
|
|
8322
|
+
'ascii',
|
|
8323
|
+
'highAnsi',
|
|
8324
|
+
'eastAsia',
|
|
8325
|
+
'complexScript'
|
|
8326
|
+
];
|
|
8327
|
+
function normalizeDocumentScriptFontFace(source) {
|
|
8328
|
+
if (!work_document_script_fonts_isRecordWithKeys(source, SCRIPT_FONT_FACE_KEYS)) return null;
|
|
8329
|
+
const name = void 0 === source.name ? void 0 : normalizeDocumentFontName(source.name);
|
|
8330
|
+
const resolved = void 0 === source.resolved ? void 0 : normalizeDocumentFontName(source.resolved);
|
|
8331
|
+
const theme = void 0 === source.theme ? void 0 : normalizeDocumentThemeFont(source.theme);
|
|
8332
|
+
if (void 0 !== source.name && !name || void 0 !== source.resolved && !resolved || null === theme || !name && !theme && !resolved) return null;
|
|
8333
|
+
return {
|
|
8334
|
+
...name ? {
|
|
8335
|
+
name
|
|
8336
|
+
} : {},
|
|
8337
|
+
...theme ? {
|
|
8338
|
+
theme
|
|
8339
|
+
} : {},
|
|
8340
|
+
...resolved ? {
|
|
8341
|
+
resolved
|
|
8342
|
+
} : {}
|
|
8343
|
+
};
|
|
8344
|
+
}
|
|
8345
|
+
function directFontFace(value) {
|
|
8346
|
+
if (null === value) return null;
|
|
8347
|
+
const name = documentFontNameFromCssFamily(value) ?? normalizeDocumentFontName(value);
|
|
8348
|
+
return name ? {
|
|
8349
|
+
name,
|
|
8350
|
+
resolved: name
|
|
8351
|
+
} : null;
|
|
8352
|
+
}
|
|
8353
|
+
function documentScriptFontFaceFamily(face) {
|
|
8354
|
+
return face?.resolved ?? face?.name;
|
|
8355
|
+
}
|
|
8356
|
+
function strongDocumentScriptFontSlot(character) {
|
|
8357
|
+
if (NEUTRAL_SCRIPT_CHARACTER.test(character)) return null;
|
|
8358
|
+
const codePoint = character.codePointAt(0);
|
|
8359
|
+
if (void 0 === codePoint) return null;
|
|
8360
|
+
if (isComplexScriptCodePoint(codePoint)) return 'complexScript';
|
|
8361
|
+
if (isEastAsianCodePoint(codePoint)) return 'eastAsia';
|
|
8362
|
+
return codePoint <= 0x7f ? 'ascii' : 'highAnsi';
|
|
8363
|
+
}
|
|
8364
|
+
function isComplexScriptCodePoint(codePoint) {
|
|
8365
|
+
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;
|
|
8366
|
+
}
|
|
8367
|
+
function isEastAsianCodePoint(codePoint) {
|
|
8368
|
+
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;
|
|
8369
|
+
}
|
|
8370
|
+
function cssFontFamily(value) {
|
|
8371
|
+
return /^(?:-?[\p{L}_])[\p{L}\p{N}_-]*$/u.test(value) ? value : `"${Array.from(value, cssStringCharacter).join('')}"`;
|
|
8372
|
+
}
|
|
8373
|
+
function cssStringCharacter(character) {
|
|
8374
|
+
return /[\\":;{}<>]/u.test(character) ? `\\${character.codePointAt(0)?.toString(16)} ` : character;
|
|
8375
|
+
}
|
|
8376
|
+
function safeCssFontFamilyList(value) {
|
|
8377
|
+
if ('string' != typeof value) return null;
|
|
8378
|
+
const source = value.trim();
|
|
8379
|
+
if (!source || source.length > 1024 || /[;{}]/u.test(source)) return null;
|
|
8380
|
+
const tokens = [];
|
|
8381
|
+
let start = 0;
|
|
8382
|
+
let quote = '';
|
|
8383
|
+
for(let index = 0; index < source.length; index += 1){
|
|
8384
|
+
const character = source[index] ?? '';
|
|
8385
|
+
if (quote) {
|
|
8386
|
+
if ('\\' === character) {
|
|
8387
|
+
index += 1;
|
|
8388
|
+
if (index >= source.length) return null;
|
|
8389
|
+
} else if (character === quote) quote = '';
|
|
8390
|
+
continue;
|
|
8391
|
+
}
|
|
8392
|
+
if ('"' === character || "'" === character) {
|
|
8393
|
+
quote = character;
|
|
8394
|
+
continue;
|
|
8395
|
+
}
|
|
8396
|
+
if (',' === character) {
|
|
8397
|
+
tokens.push(source.slice(start, index).trim());
|
|
8398
|
+
start = index + 1;
|
|
8399
|
+
}
|
|
8400
|
+
}
|
|
8401
|
+
if (quote) return null;
|
|
8402
|
+
tokens.push(source.slice(start).trim());
|
|
8403
|
+
return tokens.length && tokens.every(validCssFontFamilyToken) ? source : null;
|
|
8404
|
+
}
|
|
8405
|
+
function validCssFontFamilyToken(value) {
|
|
8406
|
+
if (!value) return false;
|
|
8407
|
+
if (value.startsWith('"')) return /^"(?:[^"\\\r\n\f]|\\(?:[\da-f]{1,6}\s?|[^\r\n\f]))*"$/iu.test(value) && null !== documentFontNameFromCssFamily(value);
|
|
8408
|
+
if (value.startsWith("'")) return /^'(?:[^'\\\r\n\f]|\\(?:[\da-f]{1,6}\s?|[^\r\n\f]))*'$/iu.test(value) && null !== documentFontNameFromCssFamily(value);
|
|
8409
|
+
return /[\p{L}_]/u.test(value) && /^[\p{L}_-][\p{L}\p{N}_ -]*$/u.test(value) && !/^(?:inherit|initial|revert(?:-layer)?|unset)$/iu.test(value);
|
|
8410
|
+
}
|
|
8411
|
+
function decodeCssEscape(source, start) {
|
|
8412
|
+
if (start >= source.length) return null;
|
|
8413
|
+
const hexadecimal = /^[\da-f]{1,6}/i.exec(source.slice(start))?.[0];
|
|
8414
|
+
if (hexadecimal) {
|
|
8415
|
+
const codePoint = Number.parseInt(hexadecimal, 16);
|
|
8416
|
+
if (0 === codePoint || codePoint > 0x10ffff || codePoint >= 0xd800 && codePoint <= 0xdfff) return null;
|
|
8417
|
+
let end = start + hexadecimal.length;
|
|
8418
|
+
if (/\s/u.test(source[end] ?? '')) end += 1;
|
|
8419
|
+
return {
|
|
8420
|
+
value: String.fromCodePoint(codePoint),
|
|
8421
|
+
end
|
|
8422
|
+
};
|
|
8423
|
+
}
|
|
8424
|
+
const value = source[start];
|
|
8425
|
+
return !value || /[\r\n\f]/u.test(value) ? null : {
|
|
8426
|
+
value,
|
|
8427
|
+
end: start + 1
|
|
8428
|
+
};
|
|
8429
|
+
}
|
|
8430
|
+
function work_document_script_fonts_isRecordWithKeys(value, allowed) {
|
|
8431
|
+
return 'object' == typeof value && null !== value && !Array.isArray(value) && Object.keys(value).every((key)=>allowed.has(key));
|
|
8432
|
+
}
|
|
8433
|
+
const workDocumentUnderlineStyles = [
|
|
8434
|
+
'none',
|
|
8435
|
+
'single',
|
|
8436
|
+
'words',
|
|
8437
|
+
'double',
|
|
8438
|
+
'thick',
|
|
8439
|
+
'dotted',
|
|
8440
|
+
'dottedHeavy',
|
|
8441
|
+
'dash',
|
|
8442
|
+
'dashedHeavy',
|
|
8443
|
+
'dashLong',
|
|
8444
|
+
'dashLongHeavy',
|
|
8445
|
+
'dotDash',
|
|
8446
|
+
'dashDotHeavy',
|
|
8447
|
+
'dotDotDash',
|
|
8448
|
+
'dashDotDotHeavy',
|
|
8449
|
+
'wave',
|
|
8450
|
+
'wavyHeavy',
|
|
8451
|
+
'wavyDouble'
|
|
8452
|
+
];
|
|
8453
|
+
const DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE = 'data-office-underline-style';
|
|
8454
|
+
const DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE = 'data-office-underline-color';
|
|
8455
|
+
const DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE = 'data-office-underline-theme-color';
|
|
8456
|
+
const documentUnderlineKeyboardShortcuts = {
|
|
8457
|
+
double: 'Mod-Shift-d',
|
|
8458
|
+
words: 'Mod-Shift-w'
|
|
8459
|
+
};
|
|
8460
|
+
const UNDERLINE_STYLE_BY_NORMALIZED_VALUE = new Map(workDocumentUnderlineStyles.map((style)=>[
|
|
8461
|
+
style.toLowerCase(),
|
|
8462
|
+
style
|
|
8463
|
+
]));
|
|
8464
|
+
const HEAVY_UNDERLINE_STYLES = new Set([
|
|
8465
|
+
'thick',
|
|
8466
|
+
'dottedHeavy',
|
|
8467
|
+
'dashedHeavy',
|
|
8468
|
+
'dashLongHeavy',
|
|
8469
|
+
'dashDotHeavy',
|
|
8470
|
+
'dashDotDotHeavy',
|
|
8471
|
+
'wavyHeavy'
|
|
8472
|
+
]);
|
|
8473
|
+
const DocumentUnderline = extension_underline.extend({
|
|
8474
|
+
addAttributes () {
|
|
8475
|
+
return {
|
|
8476
|
+
underlineStyle: {
|
|
8477
|
+
default: 'single',
|
|
8478
|
+
parseHTML: (element)=>documentUnderlineFormattingFromElement(element)?.style ?? 'single',
|
|
8479
|
+
renderHTML: ()=>({})
|
|
8480
|
+
},
|
|
8481
|
+
underlineColor: {
|
|
8482
|
+
default: null,
|
|
8483
|
+
parseHTML: (element)=>documentUnderlineFormattingFromElement(element)?.color ?? null,
|
|
8484
|
+
renderHTML: ()=>({})
|
|
8485
|
+
},
|
|
8486
|
+
underlineThemeColor: {
|
|
8487
|
+
default: null,
|
|
8488
|
+
parseHTML: (element)=>serializeDocxThemeReference(documentUnderlineFormattingFromElement(element)?.themeColor ?? null) ?? null,
|
|
8489
|
+
renderHTML: ()=>({})
|
|
8490
|
+
}
|
|
8491
|
+
};
|
|
8492
|
+
},
|
|
8493
|
+
renderHTML ({ mark, HTMLAttributes }) {
|
|
8494
|
+
const attributes = documentUnderlineDomAttributes(documentUnderlineFormattingFromMarkAttributes(mark.attrs));
|
|
8495
|
+
return [
|
|
8496
|
+
'u',
|
|
8497
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, attributes),
|
|
8498
|
+
0
|
|
8499
|
+
];
|
|
8500
|
+
},
|
|
8501
|
+
addCommands () {
|
|
8502
|
+
return {
|
|
8503
|
+
setUnderline: ()=>({ commands, editor })=>commands.setMark(this.name, documentUnderlineMarkAttributes(editor, 'single')),
|
|
8504
|
+
toggleUnderline: ()=>({ commands, editor })=>{
|
|
8505
|
+
const style = 'none' === documentUnderlineStyle(editor) ? 'single' : 'none';
|
|
8506
|
+
return commands.setMark(this.name, documentUnderlineMarkAttributes(editor, style));
|
|
8507
|
+
},
|
|
8508
|
+
unsetUnderline: ()=>({ commands })=>commands.unsetMark(this.name),
|
|
8509
|
+
setDocumentUnderline: (style, options = {})=>({ commands, editor })=>commands.setMark(this.name, documentUnderlineMarkAttributes(editor, style, options)),
|
|
8510
|
+
setDocumentUnderlineColor: (color, themeColor = null)=>({ commands, editor })=>{
|
|
8511
|
+
const normalizedColor = normalizeDocumentUnderlineColor(color);
|
|
8512
|
+
if (null !== color && !normalizedColor) return false;
|
|
8513
|
+
const style = documentUnderlineStyle(editor);
|
|
8514
|
+
return commands.setMark(this.name, documentUnderlineMarkAttributes(editor, 'none' === style ? 'single' : style, {
|
|
8515
|
+
color: normalizedColor,
|
|
8516
|
+
themeColor
|
|
8517
|
+
}));
|
|
8518
|
+
},
|
|
8519
|
+
toggleDocumentUnderlineStyle: (style)=>({ commands, editor })=>{
|
|
8520
|
+
const next = documentUnderlineStyle(editor) === style ? 'none' : style;
|
|
8521
|
+
return commands.setMark(this.name, documentUnderlineMarkAttributes(editor, next));
|
|
8522
|
+
}
|
|
8523
|
+
};
|
|
8524
|
+
},
|
|
8525
|
+
addKeyboardShortcuts () {
|
|
8526
|
+
return {
|
|
8527
|
+
'Mod-u': ()=>this.editor.commands.toggleUnderline(),
|
|
8528
|
+
'Mod-U': ()=>this.editor.commands.toggleUnderline(),
|
|
8529
|
+
[documentUnderlineKeyboardShortcuts.double]: ()=>this.editor.commands.toggleDocumentUnderlineStyle('double'),
|
|
8530
|
+
[documentUnderlineKeyboardShortcuts.words]: ()=>this.editor.commands.toggleDocumentUnderlineStyle('words')
|
|
8531
|
+
};
|
|
8532
|
+
}
|
|
8533
|
+
});
|
|
8534
|
+
function normalizeDocumentUnderlineStyle(value) {
|
|
8535
|
+
if ('string' != typeof value) return null;
|
|
8536
|
+
const normalized = value.trim().toLowerCase();
|
|
8537
|
+
if ('0' === normalized || 'false' === normalized || 'off' === normalized) return 'none';
|
|
8538
|
+
return UNDERLINE_STYLE_BY_NORMALIZED_VALUE.get(normalized) ?? null;
|
|
8539
|
+
}
|
|
8540
|
+
function normalizeDocumentUnderlineColor(value) {
|
|
8541
|
+
if ('string' != typeof value) return null;
|
|
8542
|
+
const source = value.trim();
|
|
8543
|
+
const hex = /^#?([\da-f]{6})$/i.exec(source)?.[1];
|
|
8544
|
+
if (hex) return `#${hex.toLowerCase()}`;
|
|
8545
|
+
const shortHex = /^#([\da-f]{3})$/i.exec(source)?.[1];
|
|
8546
|
+
if (shortHex) return `#${[
|
|
8547
|
+
...shortHex
|
|
8548
|
+
].map((channel)=>`${channel}${channel}`).join('').toLowerCase()}`;
|
|
8549
|
+
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);
|
|
8550
|
+
if (!rgb) return null;
|
|
8551
|
+
const channels = rgb.slice(1, 4).map(Number);
|
|
8552
|
+
if (channels.some((channel)=>channel < 0 || channel > 255)) return null;
|
|
8553
|
+
return `#${channels.map((channel)=>channel.toString(16).padStart(2, '0')).join('')}`;
|
|
8554
|
+
}
|
|
8555
|
+
function documentUnderlineStyle(editor) {
|
|
8556
|
+
return documentUnderlineFormatting(editor)?.style ?? 'none';
|
|
8557
|
+
}
|
|
8558
|
+
function documentUnderlineColor(editor) {
|
|
8559
|
+
return documentUnderlineFormatting(editor)?.color ?? null;
|
|
8560
|
+
}
|
|
8561
|
+
function documentUnderlineFormatting(editor) {
|
|
8562
|
+
if (editor.isDestroyed || !editor.isActive('underline')) return null;
|
|
8563
|
+
return documentUnderlineFormattingFromMarkAttributes(editor.getAttributes('underline'));
|
|
8564
|
+
}
|
|
8565
|
+
function documentUnderlineFormattingFromElement(element) {
|
|
8566
|
+
const declaredStyle = normalizeDocumentUnderlineStyle(element.getAttribute(DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE));
|
|
8567
|
+
const cssLine = element.style.textDecorationLine.trim().toLowerCase().split(/\s+/);
|
|
8568
|
+
const style = declaredStyle ?? documentUnderlineStyleFromCss(element) ?? ('u' === element.tagName.toLowerCase() ? 'single' : cssLine.includes('none') ? 'none' : null);
|
|
8569
|
+
if (!style) return null;
|
|
8570
|
+
const themeColor = parseDocxThemeReference(element.getAttribute(DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE));
|
|
8571
|
+
const color = normalizeDocumentUnderlineColor(element.getAttribute(DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE)) ?? normalizeDocumentUnderlineColor(element.style.textDecorationColor) ?? themeColor?.resolved;
|
|
8572
|
+
return {
|
|
8573
|
+
style,
|
|
8574
|
+
...color ? {
|
|
8575
|
+
color
|
|
8576
|
+
} : {},
|
|
8577
|
+
...themeColor ? {
|
|
8578
|
+
themeColor
|
|
8579
|
+
} : {}
|
|
8580
|
+
};
|
|
8581
|
+
}
|
|
8582
|
+
function documentUnderlineDomAttributes(formatting) {
|
|
8583
|
+
const style = normalizeDocumentUnderlineStyle(formatting.style) ?? 'single';
|
|
8584
|
+
const color = normalizeDocumentUnderlineColor(formatting.color);
|
|
8585
|
+
const themeColor = serializeDocxThemeReference(formatting.themeColor ?? null);
|
|
8586
|
+
const declarations = documentUnderlineCssDeclarations({
|
|
8587
|
+
style,
|
|
8588
|
+
...color ? {
|
|
8589
|
+
color
|
|
8590
|
+
} : {}
|
|
8591
|
+
});
|
|
8592
|
+
return {
|
|
8593
|
+
[DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE]: style,
|
|
8594
|
+
...color ? {
|
|
8595
|
+
[DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE]: color
|
|
8596
|
+
} : {},
|
|
8597
|
+
...themeColor ? {
|
|
8598
|
+
[DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE]: themeColor
|
|
8599
|
+
} : {},
|
|
8600
|
+
style: declarations.join('; ')
|
|
8601
|
+
};
|
|
8602
|
+
}
|
|
8603
|
+
function documentUnderlineMarkAttributes(editor, style, options = {}) {
|
|
8604
|
+
const current = documentUnderlineFormatting(editor);
|
|
8605
|
+
const color = void 0 === options.color ? current?.color ?? null : normalizeDocumentUnderlineColor(options.color);
|
|
8606
|
+
const requestedTheme = void 0 === options.themeColor ? current?.themeColor ?? null : documentUnderlineThemeReference(options.themeColor);
|
|
8607
|
+
const themeColor = requestedTheme && color === requestedTheme.resolved ? serializeDocxThemeReference(requestedTheme) ?? null : null;
|
|
8608
|
+
return {
|
|
8609
|
+
underlineStyle: style,
|
|
8610
|
+
underlineColor: color,
|
|
8611
|
+
underlineThemeColor: themeColor
|
|
8612
|
+
};
|
|
8613
|
+
}
|
|
8614
|
+
function documentUnderlineFormattingFromMarkAttributes(attributes) {
|
|
8615
|
+
const style = normalizeDocumentUnderlineStyle(attributes.underlineStyle) ?? 'single';
|
|
8616
|
+
const themeColor = 'string' == typeof attributes.underlineThemeColor ? parseDocxThemeReference(attributes.underlineThemeColor) : null;
|
|
8617
|
+
const color = normalizeDocumentUnderlineColor(attributes.underlineColor) ?? themeColor?.resolved;
|
|
8618
|
+
return {
|
|
8619
|
+
style,
|
|
8620
|
+
...color ? {
|
|
8621
|
+
color
|
|
8622
|
+
} : {},
|
|
8623
|
+
...themeColor ? {
|
|
8624
|
+
themeColor
|
|
8625
|
+
} : {}
|
|
8626
|
+
};
|
|
8627
|
+
}
|
|
8628
|
+
function documentUnderlineThemeReference(value) {
|
|
8629
|
+
if ('string' == typeof value) return parseDocxThemeReference(value);
|
|
8630
|
+
return value ? parseDocxThemeReference(serializeDocxThemeReference(value)) : null;
|
|
8631
|
+
}
|
|
8632
|
+
function documentUnderlineStyleFromCss(element) {
|
|
8633
|
+
const line = element.style.textDecorationLine.trim().toLowerCase().split(/\s+/);
|
|
8634
|
+
if (line.includes('none')) return 'none';
|
|
8635
|
+
if (!line.includes('underline')) return null;
|
|
8636
|
+
switch(element.style.textDecorationStyle.trim().toLowerCase()){
|
|
8637
|
+
case 'double':
|
|
8638
|
+
return 'double';
|
|
8639
|
+
case 'dotted':
|
|
8640
|
+
return 'dotted';
|
|
8641
|
+
case 'dashed':
|
|
8642
|
+
return 'dash';
|
|
8643
|
+
case 'wavy':
|
|
8644
|
+
return 'wave';
|
|
8645
|
+
default:
|
|
8646
|
+
return 'single';
|
|
8647
|
+
}
|
|
8648
|
+
}
|
|
8649
|
+
function documentUnderlineCssDeclarations(formatting) {
|
|
8650
|
+
const { style, color } = formatting;
|
|
8651
|
+
if ('none' === style) return [
|
|
8652
|
+
'text-decoration-line: none'
|
|
8653
|
+
];
|
|
8654
|
+
const declarations = [
|
|
8655
|
+
'text-decoration-line: underline',
|
|
8656
|
+
`text-decoration-style: ${documentUnderlineCssStyle(style)}`,
|
|
8657
|
+
'text-underline-offset: 0.12em',
|
|
8658
|
+
'text-decoration-skip-ink: auto'
|
|
8659
|
+
];
|
|
8660
|
+
if (color) declarations.push(`text-decoration-color: ${color}`);
|
|
8661
|
+
if (HEAVY_UNDERLINE_STYLES.has(style)) declarations.push('text-decoration-thickness: 0.14em');
|
|
8662
|
+
return declarations;
|
|
8663
|
+
}
|
|
8664
|
+
function documentUnderlineCssStyle(style) {
|
|
8665
|
+
if ('double' === style) return 'double';
|
|
8666
|
+
if ('dotted' === style || 'dottedHeavy' === style) return 'dotted';
|
|
8667
|
+
if ('dash' === style || 'dashedHeavy' === style || 'dashLong' === style || 'dashLongHeavy' === style || 'dotDash' === style || 'dashDotHeavy' === style || 'dotDotDash' === style || 'dashDotDotHeavy' === style) return 'dashed';
|
|
8668
|
+
if ('wave' === style || 'wavyHeavy' === style || 'wavyDouble' === style) return 'wavy';
|
|
8669
|
+
return 'solid';
|
|
8670
|
+
}
|
|
8671
|
+
const workDocumentStrikeStyles = [
|
|
8672
|
+
'none',
|
|
8673
|
+
'single',
|
|
8674
|
+
'double'
|
|
8675
|
+
];
|
|
8676
|
+
const DOCUMENT_STRIKE_STYLE_ATTRIBUTE = 'data-office-strike-style';
|
|
8677
|
+
const STRIKE_STYLE_BY_NORMALIZED_VALUE = new Map(workDocumentStrikeStyles.map((style)=>[
|
|
8678
|
+
style,
|
|
8679
|
+
style
|
|
8680
|
+
]));
|
|
8681
|
+
const DocumentStrike = extension_strike.extend({
|
|
8682
|
+
addAttributes () {
|
|
8683
|
+
return {
|
|
8684
|
+
strikeStyle: {
|
|
8685
|
+
default: 'single',
|
|
8686
|
+
parseHTML: (element)=>documentStrikeFormattingFromElement(element)?.style ?? 'single',
|
|
8687
|
+
renderHTML: ()=>({})
|
|
8688
|
+
}
|
|
8689
|
+
};
|
|
8690
|
+
},
|
|
8691
|
+
renderHTML ({ mark, HTMLAttributes }) {
|
|
8692
|
+
return [
|
|
8693
|
+
's',
|
|
8694
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, documentStrikeDomAttributes(documentStrikeFormattingFromMarkAttributes(mark.attrs))),
|
|
8695
|
+
0
|
|
8696
|
+
];
|
|
8697
|
+
},
|
|
8698
|
+
addCommands () {
|
|
8699
|
+
return {
|
|
8700
|
+
setStrike: ()=>({ commands })=>commands.setMark(this.name, {
|
|
8701
|
+
strikeStyle: 'single'
|
|
8702
|
+
}),
|
|
8703
|
+
toggleStrike: ()=>({ commands, editor })=>commands.setMark(this.name, {
|
|
8704
|
+
strikeStyle: 'none' === documentStrikeStyle(editor) ? 'single' : 'none'
|
|
8705
|
+
}),
|
|
8706
|
+
unsetStrike: ()=>({ commands })=>commands.unsetMark(this.name),
|
|
8707
|
+
setDocumentStrike: (style)=>({ commands })=>commands.setMark(this.name, {
|
|
8708
|
+
strikeStyle: style
|
|
8709
|
+
}),
|
|
8710
|
+
toggleDocumentStrikeStyle: (style)=>({ commands, editor })=>commands.setMark(this.name, {
|
|
8711
|
+
strikeStyle: documentStrikeStyle(editor) === style ? 'none' : style
|
|
8712
|
+
})
|
|
8713
|
+
};
|
|
8714
|
+
},
|
|
8715
|
+
addKeyboardShortcuts () {
|
|
8716
|
+
return {};
|
|
8717
|
+
}
|
|
8718
|
+
});
|
|
8719
|
+
function normalizeDocumentStrikeStyle(value) {
|
|
8720
|
+
if ('string' != typeof value) return null;
|
|
8721
|
+
const normalized = value.trim().toLowerCase();
|
|
8722
|
+
if ('0' === normalized || 'false' === normalized || 'off' === normalized) return 'none';
|
|
8723
|
+
return STRIKE_STYLE_BY_NORMALIZED_VALUE.get(normalized) ?? null;
|
|
8724
|
+
}
|
|
8725
|
+
function documentStrikeStyle(editor) {
|
|
8726
|
+
return documentStrikeFormatting(editor)?.style ?? 'none';
|
|
8727
|
+
}
|
|
8728
|
+
function documentStrikeFormatting(editor) {
|
|
8729
|
+
if (editor.isDestroyed || !editor.isActive('strike')) return null;
|
|
8730
|
+
return documentStrikeFormattingFromMarkAttributes(editor.getAttributes('strike'));
|
|
8731
|
+
}
|
|
8732
|
+
function documentStrikeFormattingFromElement(element) {
|
|
8733
|
+
const declared = normalizeDocumentStrikeStyle(element.getAttribute(DOCUMENT_STRIKE_STYLE_ATTRIBUTE));
|
|
8734
|
+
const lines = element.style.textDecorationLine.trim().toLowerCase().split(/\s+/);
|
|
8735
|
+
const style = declared ?? (lines.includes('none') ? 'none' : lines.includes('line-through') ? 'double' === element.style.textDecorationStyle.trim().toLowerCase() ? 'double' : 'single' : [
|
|
8736
|
+
'del',
|
|
8737
|
+
's',
|
|
8738
|
+
'strike'
|
|
8739
|
+
].includes(element.tagName.toLowerCase()) ? 'single' : null);
|
|
8740
|
+
return style ? {
|
|
8741
|
+
style
|
|
8742
|
+
} : null;
|
|
8743
|
+
}
|
|
8744
|
+
function documentStrikeDomAttributes(formatting) {
|
|
8745
|
+
const style = normalizeDocumentStrikeStyle(formatting.style) ?? 'single';
|
|
8746
|
+
return {
|
|
8747
|
+
[DOCUMENT_STRIKE_STYLE_ATTRIBUTE]: style,
|
|
8748
|
+
style: 'none' === style ? 'text-decoration-line: none' : `text-decoration-line: line-through; text-decoration-style: ${'double' === style ? 'double' : 'solid'}; text-decoration-skip-ink: none`
|
|
8749
|
+
};
|
|
8750
|
+
}
|
|
8751
|
+
function documentStrikeFormattingFromMarkAttributes(attributes) {
|
|
8752
|
+
return {
|
|
8753
|
+
style: normalizeDocumentStrikeStyle(attributes.strikeStyle) ?? 'single'
|
|
8754
|
+
};
|
|
8755
|
+
}
|
|
8756
|
+
const EMPTY_CONTENT = {
|
|
8757
|
+
headerHtml: '',
|
|
8758
|
+
footerHtml: '',
|
|
8759
|
+
showPageNumber: false
|
|
8760
|
+
};
|
|
8761
|
+
const IMAGE_IDENTITY_ATTRIBUTES = [
|
|
8762
|
+
'data-office-image-object-id',
|
|
8763
|
+
'data-office-image-doc-properties-id',
|
|
8764
|
+
'data-office-image-anchor-id',
|
|
8765
|
+
'data-office-image-edit-id'
|
|
8766
|
+
];
|
|
8767
|
+
const PARAGRAPH_IDENTITY_ATTRIBUTES = [
|
|
8768
|
+
DOCUMENT_PARAGRAPH_ID_ATTRIBUTE,
|
|
8769
|
+
DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE
|
|
8770
|
+
];
|
|
8771
|
+
const PARAGRAPH_DEFAULT_COLLAPSED_ATTRIBUTE = 'data-office-default-collapsed';
|
|
8772
|
+
const PARAGRAPH_BORDERS_ATTRIBUTE = DOCUMENT_PARAGRAPH_BORDERS_ATTRIBUTE;
|
|
8773
|
+
const PARAGRAPH_SHADING_ATTRIBUTE = 'data-office-paragraph-shading';
|
|
8774
|
+
const TABLE_ROW_IDENTITY_ATTRIBUTES = [
|
|
8775
|
+
DOCUMENT_TABLE_ROW_ID_ATTRIBUTE,
|
|
8776
|
+
DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE
|
|
8777
|
+
];
|
|
8778
|
+
const EQUATION_ATTRIBUTES = [
|
|
8779
|
+
'aria-label',
|
|
8780
|
+
'class',
|
|
8781
|
+
'contenteditable',
|
|
8782
|
+
'data-document-equation',
|
|
8783
|
+
'data-equation-display',
|
|
8784
|
+
'data-equation-model',
|
|
8785
|
+
'role'
|
|
8786
|
+
];
|
|
8787
|
+
const MATHML_ATTRIBUTES = new Set([
|
|
8788
|
+
'accent',
|
|
8789
|
+
'accentunder',
|
|
8790
|
+
'align',
|
|
8791
|
+
'bevelled',
|
|
8792
|
+
'columnalign',
|
|
8793
|
+
'depth',
|
|
8794
|
+
'dir',
|
|
8795
|
+
'display',
|
|
8796
|
+
'fence',
|
|
8797
|
+
'height',
|
|
8798
|
+
'lang',
|
|
8799
|
+
'linethickness',
|
|
8800
|
+
'mathbackground',
|
|
8801
|
+
'mathcolor',
|
|
8802
|
+
'mathsize',
|
|
8803
|
+
'mathvariant',
|
|
8804
|
+
'notation',
|
|
8805
|
+
'rowspacing',
|
|
8806
|
+
"scriptlevel",
|
|
8807
|
+
'separator',
|
|
8808
|
+
'style',
|
|
8809
|
+
'width',
|
|
8810
|
+
'xmlns'
|
|
8811
|
+
]);
|
|
8812
|
+
const work_document_page_chrome_MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
|
8813
|
+
const MATHML_TAGS = new Set([
|
|
8814
|
+
'math',
|
|
8815
|
+
'maligngroup',
|
|
8816
|
+
'malignmark',
|
|
8817
|
+
'menclose',
|
|
8818
|
+
'mfrac',
|
|
8819
|
+
"mmultiscripts",
|
|
8820
|
+
'mo',
|
|
8821
|
+
'mover',
|
|
8822
|
+
'mpadded',
|
|
8823
|
+
'mphantom',
|
|
8824
|
+
"mprescripts",
|
|
8825
|
+
'mroot',
|
|
8826
|
+
'mrow',
|
|
8827
|
+
'msqrt',
|
|
8828
|
+
'msub',
|
|
8829
|
+
'msubsup',
|
|
8830
|
+
'msup',
|
|
8831
|
+
'mstyle',
|
|
8832
|
+
'mtable',
|
|
8833
|
+
'mtd',
|
|
8834
|
+
'mtext',
|
|
8835
|
+
'mtr',
|
|
8836
|
+
'munder',
|
|
8837
|
+
'munderover',
|
|
8838
|
+
'none'
|
|
8839
|
+
]);
|
|
8840
|
+
const ALLOWED_TAGS = new Set([
|
|
8841
|
+
'a',
|
|
8842
|
+
'b',
|
|
8843
|
+
'blockquote',
|
|
8844
|
+
'br',
|
|
8845
|
+
'div',
|
|
8846
|
+
'em',
|
|
8847
|
+
'i',
|
|
8848
|
+
'img',
|
|
8849
|
+
'li',
|
|
8850
|
+
'math',
|
|
8851
|
+
'maligngroup',
|
|
8852
|
+
'malignmark',
|
|
8853
|
+
'menclose',
|
|
8854
|
+
'mfrac',
|
|
8855
|
+
"mmultiscripts",
|
|
8856
|
+
'mo',
|
|
8857
|
+
'mover',
|
|
8858
|
+
'mpadded',
|
|
8859
|
+
'mphantom',
|
|
8860
|
+
"mprescripts",
|
|
8861
|
+
'mroot',
|
|
8862
|
+
'mrow',
|
|
8863
|
+
'msqrt',
|
|
8864
|
+
'msub',
|
|
8865
|
+
'msubsup',
|
|
8866
|
+
'msup',
|
|
8867
|
+
'mstyle',
|
|
8868
|
+
'mtable',
|
|
8869
|
+
'mtd',
|
|
8870
|
+
'mtext',
|
|
8871
|
+
'mtr',
|
|
8872
|
+
'munder',
|
|
8873
|
+
'munderover',
|
|
8874
|
+
'none',
|
|
8875
|
+
'ol',
|
|
8876
|
+
'p',
|
|
8877
|
+
's',
|
|
8878
|
+
'span',
|
|
8879
|
+
'strike',
|
|
8880
|
+
'strong',
|
|
8881
|
+
'sub',
|
|
8882
|
+
'sup',
|
|
8883
|
+
'table',
|
|
8884
|
+
'tbody',
|
|
8885
|
+
'td',
|
|
8886
|
+
'th',
|
|
8887
|
+
'thead',
|
|
8888
|
+
'tr',
|
|
8889
|
+
'u',
|
|
8890
|
+
'ul'
|
|
8891
|
+
]);
|
|
8892
|
+
function normalizeDocumentPageChrome(source, legacy = {}) {
|
|
8893
|
+
const defaultContent = normalizePageChromeContent(source?.default, {
|
|
8894
|
+
headerHtml: plainTextToPageChromeHtml(legacy.headerText),
|
|
8895
|
+
footerHtml: plainTextToPageChromeHtml(legacy.footerText),
|
|
8896
|
+
showPageNumber: Boolean(legacy.showPageNumbers)
|
|
8897
|
+
});
|
|
8898
|
+
return {
|
|
8899
|
+
differentFirstPage: Boolean(source?.differentFirstPage),
|
|
8900
|
+
differentOddEvenPages: Boolean(source?.differentOddEvenPages),
|
|
8901
|
+
default: defaultContent,
|
|
8902
|
+
first: normalizePageChromeContent(source?.first, EMPTY_CONTENT),
|
|
8903
|
+
even: normalizePageChromeContent(source?.even, EMPTY_CONTENT)
|
|
7865
8904
|
};
|
|
7866
8905
|
}
|
|
7867
8906
|
function serializeDocumentPageChrome(chrome) {
|
|
@@ -7971,6 +9010,29 @@ function sanitizeAttributes(element, tag) {
|
|
|
7971
9010
|
'justify'
|
|
7972
9011
|
].includes(element.style.textAlign) ? element.style.textAlign : '';
|
|
7973
9012
|
const color = element.style.color;
|
|
9013
|
+
const scriptFonts = 'span' === tag ? documentScriptFontsFromElement(element) : null;
|
|
9014
|
+
const scriptFontSlot = 'span' === tag ? documentScriptFontSlotFromElement(element) : null;
|
|
9015
|
+
const scriptFontAttributes = scriptFonts ? documentScriptFontsDomAttributes(scriptFonts, scriptFontSlot) : {};
|
|
9016
|
+
const fontFamily = (scriptFonts ? documentScriptFontFamilyForRendering(scriptFonts, scriptFontSlot ?? documentScriptFontSlotFromHint(scriptFonts.hint), element.style.fontFamily) : null) ?? cssDocumentFontFamily(documentFontNameFromCssFamily(element.style.fontFamily));
|
|
9017
|
+
const fontSize = 'span' === tag ? normalizedPageChromeFontSize(element.style.fontSize) : null;
|
|
9018
|
+
const textCase = 'span' === tag ? normalizeDocumentTextCase(element.getAttribute(DOCUMENT_TEXT_CASE_ATTRIBUTE)) : null;
|
|
9019
|
+
const characterSpacing = 'span' === tag ? documentCharacterSpacingTwipsFromElement(element) : null;
|
|
9020
|
+
const characterScale = 'span' === tag ? documentCharacterScalePercentFromElement(element) : null;
|
|
9021
|
+
const characterScaleAttributes = documentCharacterScaleDomAttributes(characterScale);
|
|
9022
|
+
const characterPosition = 'span' === tag ? documentCharacterPositionHalfPointsFromElement(element) : null;
|
|
9023
|
+
const characterPositionAttributes = documentCharacterPositionDomAttributes(characterPosition);
|
|
9024
|
+
const characterSpacingAttributes = documentCharacterSpacingDomAttributes(characterSpacing);
|
|
9025
|
+
const kerningThreshold = 'span' === tag ? documentKerningThresholdHalfPointsFromElement(element) : null;
|
|
9026
|
+
const kerningAttributes = documentKerningDomAttributes(kerningThreshold, fontSize);
|
|
9027
|
+
const emphasisMark = 'span' === tag ? documentEmphasisMarkFromElement(element) : null;
|
|
9028
|
+
const emphasisAttributes = documentEmphasisMarkDomAttributes(emphasisMark);
|
|
9029
|
+
const hiddenText = 'span' === tag ? documentHiddenTextFromElement(element) : null;
|
|
9030
|
+
const legacyTextEffects = 'span' === tag ? documentLegacyTextEffectsFromElement(element) ?? {} : {};
|
|
9031
|
+
const legacyTextEffectAttributes = documentLegacyTextEffectsDomAttributes(legacyTextEffects);
|
|
9032
|
+
const underline = 'u' === tag ? documentUnderlineFormattingFromElement(element) : null;
|
|
9033
|
+
const underlineAttributes = underline ? documentUnderlineDomAttributes(underline) : {};
|
|
9034
|
+
const strike = 's' === tag || 'strike' === tag ? documentStrikeFormattingFromElement(element) : null;
|
|
9035
|
+
const strikeAttributes = strike ? documentStrikeDomAttributes(strike) : {};
|
|
7974
9036
|
const paragraphShading = 'p' === tag ? parseDocumentParagraphShadingElement(element) : null;
|
|
7975
9037
|
const shadingAttributes = documentParagraphShadingDomAttributes(paragraphShading);
|
|
7976
9038
|
const paragraphBorders = 'p' === tag ? parseDocumentParagraphBordersElement(element) : null;
|
|
@@ -7979,9 +9041,35 @@ function sanitizeAttributes(element, tag) {
|
|
|
7979
9041
|
element.removeAttribute('style');
|
|
7980
9042
|
element.removeAttribute(PARAGRAPH_BORDERS_ATTRIBUTE);
|
|
7981
9043
|
element.removeAttribute(PARAGRAPH_SHADING_ATTRIBUTE);
|
|
9044
|
+
element.removeAttribute(DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE);
|
|
9045
|
+
element.removeAttribute(DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE);
|
|
9046
|
+
element.removeAttribute(DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE);
|
|
9047
|
+
element.removeAttribute(DOCUMENT_STRIKE_STYLE_ATTRIBUTE);
|
|
9048
|
+
element.removeAttribute(DOCUMENT_CHARACTER_SCALE_ATTRIBUTE);
|
|
9049
|
+
element.removeAttribute(DOCUMENT_CHARACTER_POSITION_ATTRIBUTE);
|
|
9050
|
+
element.removeAttribute(DOCUMENT_CHARACTER_SPACING_ATTRIBUTE);
|
|
9051
|
+
element.removeAttribute(DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE);
|
|
9052
|
+
element.removeAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE);
|
|
9053
|
+
element.removeAttribute(DOCUMENT_HIDDEN_TEXT_ATTRIBUTE);
|
|
9054
|
+
element.removeAttribute(DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE);
|
|
9055
|
+
element.removeAttribute(DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE);
|
|
9056
|
+
element.removeAttribute(DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE);
|
|
9057
|
+
element.removeAttribute(DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE);
|
|
9058
|
+
element.removeAttribute(DOCUMENT_SCRIPT_FONTS_ATTRIBUTE);
|
|
9059
|
+
element.removeAttribute(DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE);
|
|
7982
9060
|
const styles = [
|
|
7983
9061
|
textAlign ? `text-align: ${textAlign}` : '',
|
|
7984
9062
|
color ? `color: ${color}` : '',
|
|
9063
|
+
fontFamily ? `font-family: ${fontFamily}` : '',
|
|
9064
|
+
fontSize ? `font-size: ${fontSize}` : '',
|
|
9065
|
+
textCase ? documentTextCaseCss(textCase) : '',
|
|
9066
|
+
characterScaleAttributes.style ?? '',
|
|
9067
|
+
characterPositionAttributes.style ?? '',
|
|
9068
|
+
characterSpacingAttributes.style ?? '',
|
|
9069
|
+
kerningAttributes.style ?? '',
|
|
9070
|
+
emphasisAttributes.style ?? '',
|
|
9071
|
+
underlineAttributes.style ?? '',
|
|
9072
|
+
strikeAttributes.style ?? '',
|
|
7985
9073
|
borderAttributes.style ?? '',
|
|
7986
9074
|
shadingAttributes.style ?? ''
|
|
7987
9075
|
].filter(Boolean);
|
|
@@ -8014,6 +9102,24 @@ function sanitizeAttributes(element, tag) {
|
|
|
8014
9102
|
normalizeParagraphDefaultCollapsedAttribute(element);
|
|
8015
9103
|
}
|
|
8016
9104
|
if ('tr' === tag) normalizeTableRowIdentityAttributes(element);
|
|
9105
|
+
if ('u' === tag) {
|
|
9106
|
+
for (const [name, value] of Object.entries(underlineAttributes))if ('style' !== name) element.setAttribute(name, value);
|
|
9107
|
+
}
|
|
9108
|
+
if ('s' === tag || 'strike' === tag) {
|
|
9109
|
+
for (const [name, value] of Object.entries(strikeAttributes))if ('style' !== name) element.setAttribute(name, value);
|
|
9110
|
+
}
|
|
9111
|
+
if ('span' === tag && textCase) element.setAttribute(DOCUMENT_TEXT_CASE_ATTRIBUTE, textCase);
|
|
9112
|
+
else element.removeAttribute(DOCUMENT_TEXT_CASE_ATTRIBUTE);
|
|
9113
|
+
if ('span' === tag && null !== characterSpacing) element.setAttribute(DOCUMENT_CHARACTER_SPACING_ATTRIBUTE, String(characterSpacing));
|
|
9114
|
+
if ('span' === tag && null !== characterScale) element.setAttribute(DOCUMENT_CHARACTER_SCALE_ATTRIBUTE, String(characterScale));
|
|
9115
|
+
if ('span' === tag && null !== characterPosition) element.setAttribute(DOCUMENT_CHARACTER_POSITION_ATTRIBUTE, String(characterPosition));
|
|
9116
|
+
if ('span' === tag && null !== kerningThreshold) element.setAttribute(DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE, String(kerningThreshold));
|
|
9117
|
+
if ('span' === tag && null !== emphasisMark) element.setAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE, emphasisMark);
|
|
9118
|
+
if ('span' === tag && null !== hiddenText) element.setAttribute(DOCUMENT_HIDDEN_TEXT_ATTRIBUTE, String(hiddenText));
|
|
9119
|
+
if ('span' === tag) for (const [name, value] of Object.entries(legacyTextEffectAttributes))element.setAttribute(name, value);
|
|
9120
|
+
if ('span' === tag && scriptFonts) {
|
|
9121
|
+
for (const [name, value] of Object.entries(scriptFontAttributes))if ('style' !== name) element.setAttribute(name, value);
|
|
9122
|
+
}
|
|
8017
9123
|
if ('ltr' === direction || 'rtl' === direction) element.setAttribute('dir', direction);
|
|
8018
9124
|
else element.removeAttribute('dir');
|
|
8019
9125
|
const allowed = 'span' === tag && 'true' === element.dataset.documentEquation ? new Set(EQUATION_ATTRIBUTES) : 'a' === tag ? new Set([
|
|
@@ -8050,10 +9156,41 @@ function sanitizeAttributes(element, tag) {
|
|
|
8050
9156
|
'colspan',
|
|
8051
9157
|
'dir',
|
|
8052
9158
|
'rowspan',
|
|
8053
|
-
'style'
|
|
9159
|
+
'style',
|
|
9160
|
+
...'span' === tag ? [
|
|
9161
|
+
DOCUMENT_TEXT_CASE_ATTRIBUTE,
|
|
9162
|
+
DOCUMENT_CHARACTER_SCALE_ATTRIBUTE,
|
|
9163
|
+
DOCUMENT_CHARACTER_POSITION_ATTRIBUTE,
|
|
9164
|
+
DOCUMENT_CHARACTER_SPACING_ATTRIBUTE,
|
|
9165
|
+
DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE,
|
|
9166
|
+
DOCUMENT_EMPHASIS_MARK_ATTRIBUTE,
|
|
9167
|
+
DOCUMENT_HIDDEN_TEXT_ATTRIBUTE,
|
|
9168
|
+
DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE,
|
|
9169
|
+
DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE,
|
|
9170
|
+
DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE,
|
|
9171
|
+
DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE,
|
|
9172
|
+
DOCUMENT_SCRIPT_FONTS_ATTRIBUTE,
|
|
9173
|
+
DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE
|
|
9174
|
+
] : [],
|
|
9175
|
+
...'u' === tag ? [
|
|
9176
|
+
DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE,
|
|
9177
|
+
DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE,
|
|
9178
|
+
DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE
|
|
9179
|
+
] : [],
|
|
9180
|
+
...'s' === tag || 'strike' === tag ? [
|
|
9181
|
+
DOCUMENT_STRIKE_STYLE_ATTRIBUTE
|
|
9182
|
+
] : []
|
|
8054
9183
|
]);
|
|
8055
9184
|
for (const attribute of Array.from(element.attributes))if (!allowed.has(attribute.name.toLowerCase())) element.removeAttribute(attribute.name);
|
|
8056
9185
|
}
|
|
9186
|
+
function normalizedPageChromeFontSize(value) {
|
|
9187
|
+
const match = /^(\d+(?:\.\d*)?|\.\d+)(pt|px)$/iu.exec(value.trim());
|
|
9188
|
+
if (!match) return null;
|
|
9189
|
+
const amount = Number(match[1]);
|
|
9190
|
+
const points = match[2]?.toLowerCase() === 'px' ? 0.75 * amount : amount;
|
|
9191
|
+
if (!Number.isFinite(points) || points <= 0 || points > 512 || !Number.isSafeInteger(2 * points)) return null;
|
|
9192
|
+
return `${Number(points.toFixed(1))}pt`;
|
|
9193
|
+
}
|
|
8057
9194
|
function normalizeTableRowIdentityAttributes(element) {
|
|
8058
9195
|
const identity = normalizeDocumentTableRowIdentity({
|
|
8059
9196
|
rowId: element.getAttribute(TABLE_ROW_IDENTITY_ATTRIBUTES[0]),
|
|
@@ -8934,20 +10071,39 @@ const CHARACTER_FORMAT_MARK_ORDER = new Map(DOCUMENT_CHARACTER_FORMAT_MARKS.map(
|
|
|
8934
10071
|
name,
|
|
8935
10072
|
index
|
|
8936
10073
|
]));
|
|
8937
|
-
const MAX_CHARACTER_FORMAT_SNAPSHOT_BYTES =
|
|
10074
|
+
const MAX_CHARACTER_FORMAT_SNAPSHOT_BYTES = 8192;
|
|
8938
10075
|
const MAX_CHARACTER_FORMAT_ATTRIBUTE_LENGTH = 512;
|
|
8939
10076
|
const ALLOWED_ATTRIBUTES = {
|
|
8940
10077
|
bold: new Set(),
|
|
8941
10078
|
italic: new Set(),
|
|
8942
|
-
underline: new Set(
|
|
8943
|
-
|
|
10079
|
+
underline: new Set([
|
|
10080
|
+
'underlineColor',
|
|
10081
|
+
'underlineStyle',
|
|
10082
|
+
'underlineThemeColor'
|
|
10083
|
+
]),
|
|
10084
|
+
strike: new Set([
|
|
10085
|
+
'strikeStyle'
|
|
10086
|
+
]),
|
|
8944
10087
|
subscript: new Set(),
|
|
8945
10088
|
superscript: new Set(),
|
|
8946
10089
|
textStyle: new Set([
|
|
10090
|
+
'characterScalePercent',
|
|
10091
|
+
'characterPositionHalfPoints',
|
|
10092
|
+
'characterSpacingTwips',
|
|
8947
10093
|
'color',
|
|
8948
10094
|
'fontFamily',
|
|
8949
10095
|
'fontSize',
|
|
10096
|
+
'emphasisMark',
|
|
10097
|
+
'kerningThresholdHalfPoints',
|
|
10098
|
+
'hiddenText',
|
|
10099
|
+
'legacyTextOutline',
|
|
10100
|
+
'legacyTextShadow',
|
|
10101
|
+
'legacyTextEmboss',
|
|
10102
|
+
'legacyTextImprint',
|
|
10103
|
+
"scriptFonts",
|
|
10104
|
+
"scriptFontSlot",
|
|
8950
10105
|
'themeColor',
|
|
10106
|
+
'textCase',
|
|
8951
10107
|
'wordLineHeightFactor',
|
|
8952
10108
|
'wordSnapToGrid'
|
|
8953
10109
|
]),
|
|
@@ -9009,18 +10165,43 @@ function importedDocumentCharacterFormatting(formatting) {
|
|
|
9009
10165
|
for (const name of [
|
|
9010
10166
|
'bold',
|
|
9011
10167
|
'italic',
|
|
9012
|
-
'underline',
|
|
9013
|
-
'strike',
|
|
9014
10168
|
"subscript",
|
|
9015
10169
|
"superscript"
|
|
9016
10170
|
])if (formatting[name]) marks.push({
|
|
9017
10171
|
type: name
|
|
9018
10172
|
});
|
|
10173
|
+
if (formatting.strike) marks.push({
|
|
10174
|
+
type: 'strike',
|
|
10175
|
+
attrs: {
|
|
10176
|
+
strikeStyle: formatting.strike.style
|
|
10177
|
+
}
|
|
10178
|
+
});
|
|
10179
|
+
if (formatting.underline) marks.push({
|
|
10180
|
+
type: 'underline',
|
|
10181
|
+
attrs: compactAttributes({
|
|
10182
|
+
underlineColor: formatting.underline.color,
|
|
10183
|
+
underlineStyle: formatting.underline.style,
|
|
10184
|
+
underlineThemeColor: serializeDocxThemeReference(formatting.underline.themeColor ?? null)
|
|
10185
|
+
})
|
|
10186
|
+
});
|
|
9019
10187
|
const textStyle = compactAttributes({
|
|
10188
|
+
characterScalePercent: formatting.characterScalePercent,
|
|
10189
|
+
characterPositionHalfPoints: formatting.characterPositionHalfPoints,
|
|
10190
|
+
characterSpacingTwips: formatting.characterSpacingTwips,
|
|
10191
|
+
kerningThresholdHalfPoints: formatting.kerningThresholdHalfPoints,
|
|
10192
|
+
emphasisMark: formatting.emphasisMark,
|
|
10193
|
+
hiddenText: formatting.hiddenText,
|
|
10194
|
+
legacyTextOutline: formatting.legacyTextOutline,
|
|
10195
|
+
legacyTextShadow: formatting.legacyTextShadow,
|
|
10196
|
+
legacyTextEmboss: formatting.legacyTextEmboss,
|
|
10197
|
+
legacyTextImprint: formatting.legacyTextImprint,
|
|
9020
10198
|
color: formatting.color,
|
|
9021
10199
|
fontFamily: formatting.fontFamily,
|
|
10200
|
+
scriptFonts: serializeDocumentScriptFonts(formatting.scriptFonts) ?? void 0,
|
|
10201
|
+
scriptFontSlot: formatting.scriptFontSlot,
|
|
9022
10202
|
fontSize: void 0 === formatting.fontSize ? void 0 : `${formatting.fontSize}pt`,
|
|
9023
10203
|
themeColor: formatting.themeColor,
|
|
10204
|
+
textCase: formatting.textCase,
|
|
9024
10205
|
wordLineHeightFactor: formatting.wordLineHeightFactor,
|
|
9025
10206
|
wordSnapToGrid: formatting.wordSnapToGrid
|
|
9026
10207
|
});
|
|
@@ -9048,9 +10229,72 @@ function normalizeCharacterFormatMark(value) {
|
|
|
9048
10229
|
if (void 0 !== source && !work_document_format_changes_isRecord(source)) return null;
|
|
9049
10230
|
const attrs = {};
|
|
9050
10231
|
for (const [key, candidate] of Object.entries(source ?? {}))if (allowed.has(key) && null != candidate) {
|
|
10232
|
+
if ('textStyle' === type && 'characterSpacingTwips' === key) {
|
|
10233
|
+
const spacing = normalizeDocumentCharacterSpacingTwips(candidate);
|
|
10234
|
+
if (null === spacing) return null;
|
|
10235
|
+
attrs[key] = spacing;
|
|
10236
|
+
continue;
|
|
10237
|
+
}
|
|
10238
|
+
if ('textStyle' === type && 'characterPositionHalfPoints' === key) {
|
|
10239
|
+
const position = normalizeDocumentCharacterPositionHalfPoints(candidate);
|
|
10240
|
+
if (null === position) return null;
|
|
10241
|
+
attrs[key] = position;
|
|
10242
|
+
continue;
|
|
10243
|
+
}
|
|
10244
|
+
if ('textStyle' === type && 'characterScalePercent' === key) {
|
|
10245
|
+
const scale = normalizeDocumentCharacterScalePercent(candidate);
|
|
10246
|
+
if (null === scale) return null;
|
|
10247
|
+
attrs[key] = scale;
|
|
10248
|
+
continue;
|
|
10249
|
+
}
|
|
10250
|
+
if ('textStyle' === type && 'kerningThresholdHalfPoints' === key) {
|
|
10251
|
+
const threshold = normalizeDocumentKerningThresholdHalfPoints(candidate);
|
|
10252
|
+
if (null === threshold) return null;
|
|
10253
|
+
attrs[key] = threshold;
|
|
10254
|
+
continue;
|
|
10255
|
+
}
|
|
10256
|
+
if ('textStyle' === type && 'emphasisMark' === key) {
|
|
10257
|
+
const emphasisMark = normalizeDocumentEmphasisMark(candidate);
|
|
10258
|
+
if (null === emphasisMark) return null;
|
|
10259
|
+
attrs[key] = emphasisMark;
|
|
10260
|
+
continue;
|
|
10261
|
+
}
|
|
10262
|
+
if ('textStyle' === type && 'hiddenText' === key) {
|
|
10263
|
+
const hiddenText = normalizeDocumentHiddenText(candidate);
|
|
10264
|
+
if (null === hiddenText) return null;
|
|
10265
|
+
attrs[key] = hiddenText;
|
|
10266
|
+
continue;
|
|
10267
|
+
}
|
|
10268
|
+
if ('textStyle' === type && [
|
|
10269
|
+
'legacyTextOutline',
|
|
10270
|
+
'legacyTextShadow',
|
|
10271
|
+
'legacyTextEmboss',
|
|
10272
|
+
'legacyTextImprint'
|
|
10273
|
+
].includes(key)) {
|
|
10274
|
+
const effect = normalizeDocumentLegacyTextEffect(candidate);
|
|
10275
|
+
if (null === effect) return null;
|
|
10276
|
+
attrs[key] = effect;
|
|
10277
|
+
continue;
|
|
10278
|
+
}
|
|
10279
|
+
if ('textStyle' === type && "scriptFonts" === key) {
|
|
10280
|
+
const fonts = 'string' == typeof candidate ? serializeDocumentScriptFonts(parseDocumentScriptFonts(candidate)) : serializeDocumentScriptFonts(normalizeDocumentScriptFonts(candidate));
|
|
10281
|
+
if (!fonts) return null;
|
|
10282
|
+
attrs[key] = fonts;
|
|
10283
|
+
continue;
|
|
10284
|
+
}
|
|
10285
|
+
if ('textStyle' === type && "scriptFontSlot" === key) {
|
|
10286
|
+
const slot = normalizeDocumentScriptFontSlot(candidate);
|
|
10287
|
+
if (!slot) return null;
|
|
10288
|
+
attrs[key] = slot;
|
|
10289
|
+
continue;
|
|
10290
|
+
}
|
|
9051
10291
|
if ('string' == typeof candidate) {
|
|
9052
|
-
if (!candidate.length
|
|
9053
|
-
|
|
10292
|
+
if (!candidate.length) continue;
|
|
10293
|
+
if ('textStyle' === type && 'textCase' === key && !normalizeDocumentTextCase(candidate)) return null;
|
|
10294
|
+
if (candidate.length > MAX_CHARACTER_FORMAT_ATTRIBUTE_LENGTH) return null;
|
|
10295
|
+
const normalized = normalizeCharacterFormatStringAttribute(type, key, candidate);
|
|
10296
|
+
if (!normalized) return null;
|
|
10297
|
+
attrs[key] = normalized;
|
|
9054
10298
|
continue;
|
|
9055
10299
|
}
|
|
9056
10300
|
if ('boolean' == typeof candidate) {
|
|
@@ -9063,6 +10307,12 @@ function normalizeCharacterFormatMark(value) {
|
|
|
9063
10307
|
}
|
|
9064
10308
|
return null;
|
|
9065
10309
|
}
|
|
10310
|
+
if ('textStyle' === type && documentLegacyTextEffectsConflict({
|
|
10311
|
+
outline: 'boolean' == typeof attrs.legacyTextOutline ? attrs.legacyTextOutline : void 0,
|
|
10312
|
+
shadow: 'boolean' == typeof attrs.legacyTextShadow ? attrs.legacyTextShadow : void 0,
|
|
10313
|
+
emboss: 'boolean' == typeof attrs.legacyTextEmboss ? attrs.legacyTextEmboss : void 0,
|
|
10314
|
+
imprint: 'boolean' == typeof attrs.legacyTextImprint ? attrs.legacyTextImprint : void 0
|
|
10315
|
+
})) return null;
|
|
9066
10316
|
const keys = Object.keys(attrs).sort();
|
|
9067
10317
|
const normalizedAttributes = keys.length ? Object.fromEntries(keys.map((key)=>[
|
|
9068
10318
|
key,
|
|
@@ -9075,6 +10325,14 @@ function normalizeCharacterFormatMark(value) {
|
|
|
9075
10325
|
} : {}
|
|
9076
10326
|
};
|
|
9077
10327
|
}
|
|
10328
|
+
function normalizeCharacterFormatStringAttribute(type, key, value) {
|
|
10329
|
+
if ('strike' === type) return 'strikeStyle' === key ? normalizeDocumentStrikeStyle(value) : null;
|
|
10330
|
+
if ('underline' !== type) return value;
|
|
10331
|
+
if ('underlineStyle' === key) return normalizeDocumentUnderlineStyle(value);
|
|
10332
|
+
if ('underlineColor' === key) return normalizeDocumentUnderlineColor(value);
|
|
10333
|
+
if ('underlineThemeColor' === key) return serializeDocxThemeReference(parseDocxThemeReference(value)) ?? null;
|
|
10334
|
+
return null;
|
|
10335
|
+
}
|
|
9078
10336
|
function compareCharacterFormatMarks(left, right) {
|
|
9079
10337
|
return (CHARACTER_FORMAT_MARK_ORDER.get(left.type) ?? Number.MAX_SAFE_INTEGER) - (CHARACTER_FORMAT_MARK_ORDER.get(right.type) ?? Number.MAX_SAFE_INTEGER);
|
|
9080
10338
|
}
|
|
@@ -9083,6 +10341,7 @@ function createCharacterFormatMark(type, value) {
|
|
|
9083
10341
|
}
|
|
9084
10342
|
function compactAttributes(value) {
|
|
9085
10343
|
const entries = Object.entries(value).filter((entry)=>void 0 !== entry[1]);
|
|
10344
|
+
entries.sort(([left], [right])=>left < right ? -1 : left > right ? 1 : 0);
|
|
9086
10345
|
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
9087
10346
|
}
|
|
9088
10347
|
function work_document_format_changes_isRecord(value) {
|
|
@@ -9919,6 +11178,70 @@ function createDocumentChangeId() {
|
|
|
9919
11178
|
const random = "u" > typeof crypto && 'function' == typeof crypto.randomUUID ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
9920
11179
|
return `change-${random}`;
|
|
9921
11180
|
}
|
|
11181
|
+
const DocumentCharacterFormatting = Extension.create({
|
|
11182
|
+
name: 'documentCharacterFormatting',
|
|
11183
|
+
addCommands () {
|
|
11184
|
+
return {
|
|
11185
|
+
setDocumentCharacterScale: (characterScalePercent)=>({ commands })=>{
|
|
11186
|
+
const scale = normalizeDocumentCharacterScalePercent(characterScalePercent);
|
|
11187
|
+
return null === scale ? false : commands.setMark('textStyle', {
|
|
11188
|
+
characterScalePercent: scale
|
|
11189
|
+
});
|
|
11190
|
+
},
|
|
11191
|
+
setDocumentCharacterPosition: (characterPositionHalfPoints)=>({ commands })=>{
|
|
11192
|
+
const position = normalizeDocumentCharacterPositionHalfPoints(characterPositionHalfPoints);
|
|
11193
|
+
return null === position ? false : commands.setMark('textStyle', {
|
|
11194
|
+
characterPositionHalfPoints: position
|
|
11195
|
+
});
|
|
11196
|
+
},
|
|
11197
|
+
setDocumentCharacterSpacing: (characterSpacingTwips)=>({ commands })=>{
|
|
11198
|
+
const spacing = normalizeDocumentCharacterSpacingTwips(characterSpacingTwips);
|
|
11199
|
+
return null === spacing ? false : commands.setMark('textStyle', {
|
|
11200
|
+
characterSpacingTwips: spacing
|
|
11201
|
+
});
|
|
11202
|
+
},
|
|
11203
|
+
setDocumentKerningThreshold: (kerningThresholdHalfPoints)=>({ commands })=>{
|
|
11204
|
+
const threshold = normalizeDocumentKerningThresholdHalfPoints(kerningThresholdHalfPoints);
|
|
11205
|
+
return null === threshold ? false : commands.setMark('textStyle', {
|
|
11206
|
+
kerningThresholdHalfPoints: threshold
|
|
11207
|
+
});
|
|
11208
|
+
},
|
|
11209
|
+
unsetDocumentKerningThreshold: ()=>({ chain })=>chain().setMark('textStyle', {
|
|
11210
|
+
kerningThresholdHalfPoints: null
|
|
11211
|
+
}).removeEmptyTextStyle().run(),
|
|
11212
|
+
setDocumentEmphasisMark: (emphasisMark)=>({ commands })=>{
|
|
11213
|
+
const mark = normalizeDocumentEmphasisMark(emphasisMark);
|
|
11214
|
+
return null === mark ? false : commands.setMark('textStyle', {
|
|
11215
|
+
emphasisMark: mark
|
|
11216
|
+
});
|
|
11217
|
+
},
|
|
11218
|
+
unsetDocumentEmphasisMark: ()=>({ chain })=>chain().setMark('textStyle', {
|
|
11219
|
+
emphasisMark: null
|
|
11220
|
+
}).removeEmptyTextStyle().run(),
|
|
11221
|
+
setDocumentHiddenText: (hiddenText)=>({ commands })=>'boolean' == typeof hiddenText ? commands.setMark('textStyle', {
|
|
11222
|
+
hiddenText
|
|
11223
|
+
}) : false,
|
|
11224
|
+
unsetDocumentHiddenText: ()=>({ chain })=>chain().setMark('textStyle', {
|
|
11225
|
+
hiddenText: null
|
|
11226
|
+
}).removeEmptyTextStyle().run(),
|
|
11227
|
+
toggleDocumentHiddenText: ()=>({ commands, editor })=>commands.setDocumentHiddenText(!(normalizeDocumentHiddenText(editor.getAttributes('textStyle').hiddenText) ?? false)),
|
|
11228
|
+
setDocumentTextCase: (textCase)=>({ chain })=>chain().focus().setMark('textStyle', {
|
|
11229
|
+
textCase
|
|
11230
|
+
}).run(),
|
|
11231
|
+
toggleDocumentTextCase: (textCase)=>({ commands, editor })=>{
|
|
11232
|
+
const current = normalizeDocumentTextCase(editor.getAttributes('textStyle').textCase) ?? 'none';
|
|
11233
|
+
return commands.setDocumentTextCase(current === textCase ? 'none' : textCase);
|
|
11234
|
+
}
|
|
11235
|
+
};
|
|
11236
|
+
},
|
|
11237
|
+
addKeyboardShortcuts () {
|
|
11238
|
+
return {
|
|
11239
|
+
[documentTextCaseKeyboardShortcuts.allCaps]: ()=>this.editor.commands.toggleDocumentTextCase('all-caps'),
|
|
11240
|
+
[documentTextCaseKeyboardShortcuts.smallCaps]: ()=>this.editor.commands.toggleDocumentTextCase('small-caps'),
|
|
11241
|
+
[documentHiddenTextKeyboardShortcut]: ()=>this.editor.commands.toggleDocumentHiddenText()
|
|
11242
|
+
};
|
|
11243
|
+
}
|
|
11244
|
+
});
|
|
9922
11245
|
const DocumentSubscript = extension_subscript.extend({
|
|
9923
11246
|
excludes: "superscript",
|
|
9924
11247
|
addCommands () {
|
|
@@ -14584,6 +15907,7 @@ function documentTextLayoutContent(node) {
|
|
|
14584
15907
|
return supported ? content.join('') : null;
|
|
14585
15908
|
}
|
|
14586
15909
|
function collectDocumentTextLayoutRuns(element, expectedText, fonts, loadedFontIds, paragraphStyle = documentTextParagraphStyle(getComputedStyle(element))) {
|
|
15910
|
+
if (element.matches(`[${DOCUMENT_HIDDEN_TEXT_ATTRIBUTE}="true"]`) || element.querySelector(`[${DOCUMENT_HIDDEN_TEXT_ATTRIBUTE}="true"]`)) return null;
|
|
14587
15911
|
if (!paragraphStyle) return null;
|
|
14588
15912
|
const tokens = documentTextLayoutDomTokens(element);
|
|
14589
15913
|
if (!tokens) return null;
|
|
@@ -14591,7 +15915,7 @@ function collectDocumentTextLayoutRuns(element, expectedText, fonts, loadedFontI
|
|
|
14591
15915
|
const runs = [];
|
|
14592
15916
|
let utf16Offset = 0;
|
|
14593
15917
|
for (const token of tokens){
|
|
14594
|
-
const runStyle = documentTextLayoutRunStyle(getComputedStyle(token.styleElement), fonts, loadedFontIds, paragraphStyle, token.styleElement === element);
|
|
15918
|
+
const runStyle = documentTextLayoutRunStyle(getComputedStyle(token.styleElement), fonts, loadedFontIds, paragraphStyle, token.styleElement, token.styleElement === element);
|
|
14595
15919
|
if (!runStyle) return null;
|
|
14596
15920
|
const startUtf16 = utf16Offset;
|
|
14597
15921
|
utf16Offset += token.text.length;
|
|
@@ -14643,10 +15967,10 @@ function documentTextParagraphStyle(style) {
|
|
|
14643
15967
|
whiteSpace: 'break-spaces' === style.whiteSpace ? 'breakSpaces' : 'normal'
|
|
14644
15968
|
};
|
|
14645
15969
|
}
|
|
14646
|
-
function documentTextLayoutRunStyle(style, fonts, loadedFontIds, paragraphStyle, paragraphRoot) {
|
|
15970
|
+
function documentTextLayoutRunStyle(style, fonts, loadedFontIds, paragraphStyle, element, paragraphRoot) {
|
|
14647
15971
|
const direction = 'rtl' === style.direction ? 'rtl' : 'ltr';
|
|
14648
15972
|
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;
|
|
15973
|
+
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
15974
|
const fontStyle = style.fontStyle && 'normal' !== style.fontStyle ? 'italic' === style.fontStyle ? 'italic' : null : 'normal';
|
|
14651
15975
|
if (!fontStyle) return null;
|
|
14652
15976
|
const families = cssFontFamilies(style.fontFamily);
|
|
@@ -14719,6 +16043,19 @@ function documentTextLayoutRunStyleKey(style) {
|
|
|
14719
16043
|
function cssValueIs(value, ...supported) {
|
|
14720
16044
|
return !value || supported.includes(value);
|
|
14721
16045
|
}
|
|
16046
|
+
function documentTextEmphasisAllowsKernel(style, element) {
|
|
16047
|
+
for(let current = element; current; current = current.parentElement){
|
|
16048
|
+
if (!current.hasAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE)) continue;
|
|
16049
|
+
const emphasisMark = normalizeDocumentEmphasisMark(current.getAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE));
|
|
16050
|
+
if (null !== emphasisMark) {
|
|
16051
|
+
if ('none' !== emphasisMark) return false;
|
|
16052
|
+
break;
|
|
16053
|
+
}
|
|
16054
|
+
}
|
|
16055
|
+
const standard = style.getPropertyValue('text-emphasis-style').trim();
|
|
16056
|
+
const webkit = style.getPropertyValue('-webkit-text-emphasis-style').trim();
|
|
16057
|
+
return (!standard || 'none' === standard) && (!webkit || 'none' === webkit);
|
|
16058
|
+
}
|
|
14722
16059
|
function cssLigatures(style) {
|
|
14723
16060
|
const variant = style.fontVariantLigatures;
|
|
14724
16061
|
if (variant && 'normal' !== variant && 'none' !== variant) return null;
|
|
@@ -16182,34 +17519,396 @@ const DocumentSection = core_Node.create({
|
|
|
16182
17519
|
] : []
|
|
16183
17520
|
].join(';');
|
|
16184
17521
|
return [
|
|
16185
|
-
'section',
|
|
16186
|
-
mergeAttributes(HTMLAttributes, documentSectionDomAttributes(layout, id), {
|
|
16187
|
-
class: 'work-document-section',
|
|
16188
|
-
style
|
|
16189
|
-
}),
|
|
16190
|
-
0
|
|
17522
|
+
'section',
|
|
17523
|
+
mergeAttributes(HTMLAttributes, documentSectionDomAttributes(layout, id), {
|
|
17524
|
+
class: 'work-document-section',
|
|
17525
|
+
style
|
|
17526
|
+
}),
|
|
17527
|
+
0
|
|
17528
|
+
];
|
|
17529
|
+
}
|
|
17530
|
+
});
|
|
17531
|
+
function work_document_section_node_hiddenAttribute(defaultValue) {
|
|
17532
|
+
return {
|
|
17533
|
+
default: defaultValue,
|
|
17534
|
+
rendered: false
|
|
17535
|
+
};
|
|
17536
|
+
}
|
|
17537
|
+
function numberAttribute(element, name, fallback) {
|
|
17538
|
+
const value = Number(element.dataset[name]);
|
|
17539
|
+
return Number.isFinite(value) ? value : fallback;
|
|
17540
|
+
}
|
|
17541
|
+
function nullableNumberAttribute(element, name) {
|
|
17542
|
+
const source = element.dataset[name];
|
|
17543
|
+
if (!source?.trim()) return null;
|
|
17544
|
+
const value = Number(source);
|
|
17545
|
+
return Number.isFinite(value) ? value : null;
|
|
17546
|
+
}
|
|
17547
|
+
function sectionBreakAttribute(value) {
|
|
17548
|
+
if ('continuous' === value || 'evenPage' === value || 'oddPage' === value || 'nextColumn' === value) return value;
|
|
17549
|
+
return 'nextPage';
|
|
17550
|
+
}
|
|
17551
|
+
const DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT = 1.15;
|
|
17552
|
+
const DOCUMENT_WORD_LINE_HEIGHT_FACTORS = new Map([
|
|
17553
|
+
[
|
|
17554
|
+
'arial',
|
|
17555
|
+
1.15
|
|
17556
|
+
],
|
|
17557
|
+
[
|
|
17558
|
+
'times new roman',
|
|
17559
|
+
1.15
|
|
17560
|
+
],
|
|
17561
|
+
[
|
|
17562
|
+
'calibri',
|
|
17563
|
+
1.2207
|
|
17564
|
+
],
|
|
17565
|
+
[
|
|
17566
|
+
'segoe ui',
|
|
17567
|
+
1.3301
|
|
17568
|
+
],
|
|
17569
|
+
[
|
|
17570
|
+
'microsoft yahei',
|
|
17571
|
+
1.7143
|
|
17572
|
+
],
|
|
17573
|
+
[
|
|
17574
|
+
'microsoft yahei ui',
|
|
17575
|
+
1.7143
|
|
17576
|
+
],
|
|
17577
|
+
[
|
|
17578
|
+
'simsun',
|
|
17579
|
+
1.2976
|
|
17580
|
+
],
|
|
17581
|
+
[
|
|
17582
|
+
'simhei',
|
|
17583
|
+
1.2976
|
|
17584
|
+
],
|
|
17585
|
+
[
|
|
17586
|
+
'fangsong',
|
|
17587
|
+
1.2976
|
|
17588
|
+
],
|
|
17589
|
+
[
|
|
17590
|
+
'kaiti',
|
|
17591
|
+
1.2976
|
|
17592
|
+
],
|
|
17593
|
+
[
|
|
17594
|
+
'dengxian',
|
|
17595
|
+
1.3548
|
|
17596
|
+
]
|
|
17597
|
+
]);
|
|
17598
|
+
function documentWordLineHeightFactor(fontFamily) {
|
|
17599
|
+
if ('string' != typeof fontFamily) return DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT;
|
|
17600
|
+
const family = firstCssFontFamily(fontFamily).toLocaleLowerCase();
|
|
17601
|
+
return DOCUMENT_WORD_LINE_HEIGHT_FACTORS.get(family) ?? DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT;
|
|
17602
|
+
}
|
|
17603
|
+
function normalizedDocumentWordLineHeightFactor(value) {
|
|
17604
|
+
if (null == value || '' === value) return null;
|
|
17605
|
+
const factor = Number(value);
|
|
17606
|
+
if (!Number.isFinite(factor) || factor < 0.5 || factor > 4) return null;
|
|
17607
|
+
return Number(factor.toFixed(4));
|
|
17608
|
+
}
|
|
17609
|
+
const DocumentTextStyle = TextStyle.extend({
|
|
17610
|
+
parseHTML () {
|
|
17611
|
+
return [
|
|
17612
|
+
...this.parent?.() ?? [],
|
|
17613
|
+
{
|
|
17614
|
+
tag: `span[${DOCUMENT_HIDDEN_TEXT_ATTRIBUTE}]`,
|
|
17615
|
+
consuming: false
|
|
17616
|
+
},
|
|
17617
|
+
...[
|
|
17618
|
+
DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE,
|
|
17619
|
+
DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE,
|
|
17620
|
+
DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE,
|
|
17621
|
+
DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE
|
|
17622
|
+
].map((attribute)=>({
|
|
17623
|
+
tag: `span[${attribute}]`,
|
|
17624
|
+
consuming: false
|
|
17625
|
+
}))
|
|
17626
|
+
];
|
|
17627
|
+
},
|
|
17628
|
+
addCommands () {
|
|
17629
|
+
return {
|
|
17630
|
+
...this.parent?.() ?? {},
|
|
17631
|
+
removeEmptyTextStyle: ()=>({ tr })=>{
|
|
17632
|
+
const { from, to } = tr.selection;
|
|
17633
|
+
tr.doc.nodesBetween(from, to, (node, position)=>{
|
|
17634
|
+
if (!node.isText) return true;
|
|
17635
|
+
const mark = node.marks.find((candidate)=>candidate.type === this.type && documentTextStyleAttributesAreEmpty(candidate.attrs));
|
|
17636
|
+
if (mark) tr.removeMark(Math.max(position, from), Math.min(position + node.nodeSize, to), mark);
|
|
17637
|
+
return false;
|
|
17638
|
+
});
|
|
17639
|
+
return true;
|
|
17640
|
+
}
|
|
17641
|
+
};
|
|
17642
|
+
},
|
|
17643
|
+
addAttributes () {
|
|
17644
|
+
return {
|
|
17645
|
+
characterScalePercent: {
|
|
17646
|
+
default: null,
|
|
17647
|
+
parseHTML: (element)=>documentCharacterScalePercentFromElement(element),
|
|
17648
|
+
renderHTML: (attributes)=>documentCharacterScaleDomAttributes(normalizeDocumentCharacterScalePercent(attributes.characterScalePercent))
|
|
17649
|
+
},
|
|
17650
|
+
characterPositionHalfPoints: {
|
|
17651
|
+
default: null,
|
|
17652
|
+
parseHTML: (element)=>documentCharacterPositionHalfPointsFromElement(element),
|
|
17653
|
+
renderHTML: (attributes)=>documentCharacterPositionDomAttributes(normalizeDocumentCharacterPositionHalfPoints(attributes.characterPositionHalfPoints))
|
|
17654
|
+
},
|
|
17655
|
+
characterSpacingTwips: {
|
|
17656
|
+
default: null,
|
|
17657
|
+
parseHTML: (element)=>documentCharacterSpacingTwipsFromElement(element),
|
|
17658
|
+
renderHTML: (attributes)=>documentCharacterSpacingDomAttributes(normalizeDocumentCharacterSpacingTwips(attributes.characterSpacingTwips))
|
|
17659
|
+
},
|
|
17660
|
+
emphasisMark: {
|
|
17661
|
+
default: null,
|
|
17662
|
+
parseHTML: (element)=>documentEmphasisMarkFromElement(element),
|
|
17663
|
+
renderHTML: (attributes)=>documentEmphasisMarkDomAttributes(normalizeDocumentEmphasisMark(attributes.emphasisMark))
|
|
17664
|
+
},
|
|
17665
|
+
hiddenText: {
|
|
17666
|
+
default: null,
|
|
17667
|
+
parseHTML: (element)=>documentHiddenTextFromElement(element),
|
|
17668
|
+
renderHTML: (attributes)=>documentHiddenTextDomAttributes(attributes.hiddenText)
|
|
17669
|
+
},
|
|
17670
|
+
legacyTextOutline: legacyTextEffectAttribute('outline'),
|
|
17671
|
+
legacyTextShadow: legacyTextEffectAttribute('shadow'),
|
|
17672
|
+
legacyTextEmboss: legacyTextEffectAttribute('emboss'),
|
|
17673
|
+
legacyTextImprint: legacyTextEffectAttribute('imprint'),
|
|
17674
|
+
kerningThresholdHalfPoints: {
|
|
17675
|
+
default: null,
|
|
17676
|
+
parseHTML: (element)=>documentKerningThresholdHalfPointsFromElement(element),
|
|
17677
|
+
renderHTML: (attributes)=>documentKerningDomAttributes(normalizeDocumentKerningThresholdHalfPoints(attributes.kerningThresholdHalfPoints), attributes.fontSize)
|
|
17678
|
+
},
|
|
17679
|
+
scriptFonts: {
|
|
17680
|
+
default: null,
|
|
17681
|
+
parseHTML: (element)=>serializeDocumentScriptFonts(parseDocumentScriptFonts(element.dataset.officeScriptFonts)),
|
|
17682
|
+
renderHTML: (attributes)=>{
|
|
17683
|
+
const domAttributes = documentScriptFontsDomAttributes('string' == typeof attributes.scriptFonts ? parseDocumentScriptFonts(attributes.scriptFonts) : attributes.scriptFonts, attributes.scriptFontSlot);
|
|
17684
|
+
delete domAttributes.style;
|
|
17685
|
+
return domAttributes;
|
|
17686
|
+
}
|
|
17687
|
+
},
|
|
17688
|
+
scriptFontSlot: {
|
|
17689
|
+
default: null,
|
|
17690
|
+
parseHTML: (element)=>normalizeDocumentScriptFontSlot(element.dataset.officeScriptFontSlot),
|
|
17691
|
+
renderHTML: ()=>({})
|
|
17692
|
+
},
|
|
17693
|
+
wordLineHeightFactor: {
|
|
17694
|
+
default: null,
|
|
17695
|
+
parseHTML: (element)=>normalizedDocumentWordLineHeightFactor(element.dataset.officeWordLineHeightFactor ?? element.style.getPropertyValue('--work-document-word-line-height-factor')),
|
|
17696
|
+
renderHTML: (attributes)=>{
|
|
17697
|
+
const factor = normalizedDocumentWordLineHeightFactor(attributes.wordLineHeightFactor);
|
|
17698
|
+
if (null === factor) return {};
|
|
17699
|
+
return {
|
|
17700
|
+
'data-office-word-line-height-factor': String(factor),
|
|
17701
|
+
style: `--work-document-word-line-height-factor: ${factor}`
|
|
17702
|
+
};
|
|
17703
|
+
}
|
|
17704
|
+
},
|
|
17705
|
+
wordSnapToGrid: {
|
|
17706
|
+
default: null,
|
|
17707
|
+
parseHTML: (element)=>normalizedBoolean(element.dataset.officeWordSnapToGrid),
|
|
17708
|
+
renderHTML: (attributes)=>{
|
|
17709
|
+
const value = normalizedBoolean(attributes.wordSnapToGrid);
|
|
17710
|
+
return null === value ? {} : {
|
|
17711
|
+
'data-office-word-snap-to-grid': String(value)
|
|
17712
|
+
};
|
|
17713
|
+
}
|
|
17714
|
+
},
|
|
17715
|
+
themeColor: themeReferenceAttribute('officeThemeColor'),
|
|
17716
|
+
textCase: {
|
|
17717
|
+
default: null,
|
|
17718
|
+
parseHTML: (element)=>normalizeDocumentTextCase(element.dataset.officeTextCase),
|
|
17719
|
+
renderHTML: (attributes)=>{
|
|
17720
|
+
const textCase = normalizeDocumentTextCase(attributes.textCase);
|
|
17721
|
+
return textCase ? {
|
|
17722
|
+
[DOCUMENT_TEXT_CASE_ATTRIBUTE]: textCase,
|
|
17723
|
+
style: documentTextCaseCss(textCase)
|
|
17724
|
+
} : {};
|
|
17725
|
+
}
|
|
17726
|
+
}
|
|
17727
|
+
};
|
|
17728
|
+
}
|
|
17729
|
+
});
|
|
17730
|
+
function legacyTextEffectAttribute(effect) {
|
|
17731
|
+
return {
|
|
17732
|
+
default: null,
|
|
17733
|
+
parseHTML: (element)=>documentLegacyTextEffectFromElement(element, effect),
|
|
17734
|
+
renderHTML: (attributes)=>{
|
|
17735
|
+
const value = normalizeDocumentLegacyTextEffect(attributes[documentLegacyTextStyleAttributeName(effect)]);
|
|
17736
|
+
return null === value ? {} : documentLegacyTextEffectsDomAttributes({
|
|
17737
|
+
[effect]: value
|
|
17738
|
+
});
|
|
17739
|
+
}
|
|
17740
|
+
};
|
|
17741
|
+
}
|
|
17742
|
+
function documentTextStyleAttributesAreEmpty(attributes) {
|
|
17743
|
+
return Object.values(attributes).every((value)=>null == value || '' === value);
|
|
17744
|
+
}
|
|
17745
|
+
const DocumentHighlight = extension_highlight.extend({
|
|
17746
|
+
addKeyboardShortcuts () {
|
|
17747
|
+
return {};
|
|
17748
|
+
},
|
|
17749
|
+
addAttributes () {
|
|
17750
|
+
return {
|
|
17751
|
+
...this.parent?.(),
|
|
17752
|
+
themeFill: themeReferenceAttribute('officeThemeFill')
|
|
17753
|
+
};
|
|
17754
|
+
},
|
|
17755
|
+
parseHTML () {
|
|
17756
|
+
return [
|
|
17757
|
+
...this.parent?.() ?? [],
|
|
17758
|
+
{
|
|
17759
|
+
tag: 'span[data-office-theme-fill]'
|
|
17760
|
+
},
|
|
17761
|
+
{
|
|
17762
|
+
tag: 'span[style*="background-color"]'
|
|
17763
|
+
}
|
|
16191
17764
|
];
|
|
16192
17765
|
}
|
|
16193
17766
|
});
|
|
16194
|
-
|
|
17767
|
+
const DocumentFontFamily = font_family.extend({
|
|
17768
|
+
addCommands () {
|
|
17769
|
+
return {
|
|
17770
|
+
setFontFamily: (fontFamily)=>({ chain })=>{
|
|
17771
|
+
const scriptFonts = serializeDocumentScriptFonts(documentScriptFontsForAllText(fontFamily));
|
|
17772
|
+
return chain().setMark('textStyle', {
|
|
17773
|
+
fontFamily,
|
|
17774
|
+
scriptFonts,
|
|
17775
|
+
scriptFontSlot: null,
|
|
17776
|
+
wordLineHeightFactor: documentWordLineHeightFactor(fontFamily)
|
|
17777
|
+
}).run();
|
|
17778
|
+
},
|
|
17779
|
+
unsetFontFamily: ()=>({ chain })=>chain().setMark('textStyle', {
|
|
17780
|
+
fontFamily: null,
|
|
17781
|
+
scriptFonts: null,
|
|
17782
|
+
scriptFontSlot: null,
|
|
17783
|
+
wordLineHeightFactor: null
|
|
17784
|
+
}).removeEmptyTextStyle().run()
|
|
17785
|
+
};
|
|
17786
|
+
}
|
|
17787
|
+
});
|
|
17788
|
+
function firstCssFontFamily(value) {
|
|
17789
|
+
const source = value.trim();
|
|
17790
|
+
if (!source) return '';
|
|
17791
|
+
const quote = source[0];
|
|
17792
|
+
if ('"' === quote || "'" === quote) {
|
|
17793
|
+
const end = source.indexOf(quote, 1);
|
|
17794
|
+
if (end > 0) return source.slice(1, end).trim();
|
|
17795
|
+
}
|
|
17796
|
+
return (source.split(',')[0] ?? source).trim().replace(/^(['"])(.*)\1$/, '$2');
|
|
17797
|
+
}
|
|
17798
|
+
function normalizedBoolean(value) {
|
|
17799
|
+
if (true === value || 'true' === value || '1' === value) return true;
|
|
17800
|
+
if (false === value || 'false' === value || '0' === value) return false;
|
|
17801
|
+
return null;
|
|
17802
|
+
}
|
|
17803
|
+
function themeReferenceAttribute(datasetKey) {
|
|
16195
17804
|
return {
|
|
16196
|
-
default:
|
|
16197
|
-
|
|
17805
|
+
default: null,
|
|
17806
|
+
parseHTML: (element)=>serializeDocxThemeReference(parseDocxThemeReference(element.dataset[datasetKey])) ?? null,
|
|
17807
|
+
renderHTML: (attributes)=>{
|
|
17808
|
+
const value = serializeDocxThemeReference(parseDocxThemeReference('string' == typeof attributes['officeThemeColor' === datasetKey ? 'themeColor' : 'themeFill'] ? String(attributes['officeThemeColor' === datasetKey ? 'themeColor' : 'themeFill']) : null));
|
|
17809
|
+
return value ? {
|
|
17810
|
+
[`data-${toKebabCase(datasetKey)}`]: value
|
|
17811
|
+
} : {};
|
|
17812
|
+
}
|
|
16198
17813
|
};
|
|
16199
17814
|
}
|
|
16200
|
-
function
|
|
16201
|
-
|
|
16202
|
-
return Number.isFinite(value) ? value : fallback;
|
|
17815
|
+
function toKebabCase(value) {
|
|
17816
|
+
return value.replace(/[A-Z]/g, (character)=>`-${character.toLowerCase()}`);
|
|
16203
17817
|
}
|
|
16204
|
-
|
|
16205
|
-
|
|
16206
|
-
|
|
16207
|
-
|
|
16208
|
-
|
|
17818
|
+
const SCRIPT_FONT_NORMALIZATION_META = 'documentScriptFontNormalization';
|
|
17819
|
+
const documentScriptFontPluginKey = new PluginKey('documentScriptFontNormalization');
|
|
17820
|
+
const DocumentScriptFontFormatting = Extension.create({
|
|
17821
|
+
name: 'documentScriptFontFormatting',
|
|
17822
|
+
addProseMirrorPlugins () {
|
|
17823
|
+
return [
|
|
17824
|
+
new Plugin({
|
|
17825
|
+
key: documentScriptFontPluginKey,
|
|
17826
|
+
view (view) {
|
|
17827
|
+
const transaction = normalizeDocumentScriptFontMarks(view.state);
|
|
17828
|
+
if (transaction) view.dispatch(transaction);
|
|
17829
|
+
return {};
|
|
17830
|
+
},
|
|
17831
|
+
appendTransaction (transactions, _oldState, newState) {
|
|
17832
|
+
if (!transactions.some((transaction)=>transaction.docChanged) || transactions.some((transaction)=>transaction.getMeta(SCRIPT_FONT_NORMALIZATION_META))) return null;
|
|
17833
|
+
return normalizeDocumentScriptFontMarks(newState, changedDocumentRanges(transactions, newState), true);
|
|
17834
|
+
}
|
|
17835
|
+
})
|
|
17836
|
+
];
|
|
17837
|
+
}
|
|
17838
|
+
});
|
|
17839
|
+
function normalizeDocumentScriptFontMarks(state, ranges, includeInHistory = false) {
|
|
17840
|
+
const textStyle = state.schema.marks.textStyle;
|
|
17841
|
+
if (!textStyle) return null;
|
|
17842
|
+
const updates = [];
|
|
17843
|
+
const visited = new Set();
|
|
17844
|
+
const visit = (node, position)=>{
|
|
17845
|
+
if (!node.isText || !node.text || visited.has(position)) return;
|
|
17846
|
+
visited.add(position);
|
|
17847
|
+
const current = node.marks.find((mark)=>mark.type === textStyle);
|
|
17848
|
+
const fonts = parseDocumentScriptFonts(current?.attrs.scriptFonts);
|
|
17849
|
+
if (!current || !fonts) return;
|
|
17850
|
+
const serialized = serializeDocumentScriptFonts(fonts);
|
|
17851
|
+
if (!serialized) return;
|
|
17852
|
+
for (const segment of documentScriptFontSegments(node.text, fonts.hint)){
|
|
17853
|
+
const family = documentScriptFontFamilyForRendering(fonts, segment.slot, current.attrs.fontFamily);
|
|
17854
|
+
const attributes = {
|
|
17855
|
+
...current.attrs,
|
|
17856
|
+
scriptFonts: serialized,
|
|
17857
|
+
scriptFontSlot: segment.slot,
|
|
17858
|
+
...family ? {
|
|
17859
|
+
fontFamily: family,
|
|
17860
|
+
wordLineHeightFactor: documentWordLineHeightFactor(family)
|
|
17861
|
+
} : {}
|
|
17862
|
+
};
|
|
17863
|
+
const next = textStyle.create(attributes);
|
|
17864
|
+
if (!current.eq(next)) updates.push({
|
|
17865
|
+
from: position + segment.from,
|
|
17866
|
+
to: position + segment.to,
|
|
17867
|
+
current,
|
|
17868
|
+
next
|
|
17869
|
+
});
|
|
17870
|
+
}
|
|
17871
|
+
};
|
|
17872
|
+
if (ranges?.length) for (const range of ranges)state.doc.nodesBetween(range.from, range.to, visit);
|
|
17873
|
+
else state.doc.descendants(visit);
|
|
17874
|
+
if (!updates.length) return null;
|
|
17875
|
+
const transaction = state.tr;
|
|
17876
|
+
for (const update of updates){
|
|
17877
|
+
transaction.removeMark(update.from, update.to, update.current);
|
|
17878
|
+
transaction.addMark(update.from, update.to, update.next);
|
|
17879
|
+
}
|
|
17880
|
+
transaction.setMeta(SCRIPT_FONT_NORMALIZATION_META, true);
|
|
17881
|
+
if (!includeInHistory) transaction.setMeta('addToHistory', false);
|
|
17882
|
+
return transaction;
|
|
16209
17883
|
}
|
|
16210
|
-
function
|
|
16211
|
-
|
|
16212
|
-
|
|
17884
|
+
function changedDocumentRanges(transactions, state) {
|
|
17885
|
+
const maximum = state.doc.content.size;
|
|
17886
|
+
const ranges = [];
|
|
17887
|
+
for (const transaction of transactions)for (const map of transaction.mapping.maps)map.forEach((_oldFrom, _oldTo, newFrom, newTo)=>{
|
|
17888
|
+
ranges.push(expandedRange(newFrom, newTo, maximum));
|
|
17889
|
+
});
|
|
17890
|
+
ranges.push(expandedRange(state.selection.from, state.selection.to, maximum));
|
|
17891
|
+
return mergeRanges(ranges);
|
|
17892
|
+
}
|
|
17893
|
+
function expandedRange(from, to, maximum) {
|
|
17894
|
+
return {
|
|
17895
|
+
from: Math.max(0, Math.min(maximum, Math.min(from, to) - 2)),
|
|
17896
|
+
to: Math.max(0, Math.min(maximum, Math.max(from, to) + 2))
|
|
17897
|
+
};
|
|
17898
|
+
}
|
|
17899
|
+
function mergeRanges(ranges) {
|
|
17900
|
+
const ordered = [
|
|
17901
|
+
...ranges
|
|
17902
|
+
].filter((range)=>range.to >= range.from).sort((left, right)=>left.from - right.from || left.to - right.to);
|
|
17903
|
+
const merged = [];
|
|
17904
|
+
for (const range of ordered){
|
|
17905
|
+
const previous = merged[merged.length - 1];
|
|
17906
|
+
if (previous && range.from <= previous.to) previous.to = Math.max(previous.to, range.to);
|
|
17907
|
+
else merged.push({
|
|
17908
|
+
...range
|
|
17909
|
+
});
|
|
17910
|
+
}
|
|
17911
|
+
return merged;
|
|
16213
17912
|
}
|
|
16214
17913
|
const DOCUMENT_TAB_SELECTOR = 'span[data-document-tab]';
|
|
16215
17914
|
const DOCUMENT_TAB_BLOCK_SELECTOR = 'p, h1, h2, h3, h4, h5, h6';
|
|
@@ -18244,156 +19943,6 @@ function commonNullableValue(values) {
|
|
|
18244
19943
|
if (!values.length || values.some((value)=>null === value)) return null;
|
|
18245
19944
|
return values.every((value)=>value === values[0]) ? values[0] : null;
|
|
18246
19945
|
}
|
|
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
19946
|
function createWorkDocumentExtensions(options = {}) {
|
|
18398
19947
|
const changeExtension = DocumentChange.configure({
|
|
18399
19948
|
...options.isTracking ? {
|
|
@@ -18430,6 +19979,7 @@ function createWorkDocumentExtensions(options = {}) {
|
|
|
18430
19979
|
openOnClick: false
|
|
18431
19980
|
},
|
|
18432
19981
|
underline: false,
|
|
19982
|
+
strike: false,
|
|
18433
19983
|
bulletList: false,
|
|
18434
19984
|
orderedList: false,
|
|
18435
19985
|
trailingNode: {
|
|
@@ -18462,7 +20012,9 @@ function createWorkDocumentExtensions(options = {}) {
|
|
|
18462
20012
|
commentExtension,
|
|
18463
20013
|
DocumentNoteReference,
|
|
18464
20014
|
DocumentNote,
|
|
18465
|
-
|
|
20015
|
+
DocumentUnderline,
|
|
20016
|
+
DocumentStrike,
|
|
20017
|
+
DocumentCharacterFormatting,
|
|
18466
20018
|
DocumentSubscript,
|
|
18467
20019
|
DocumentSuperscript,
|
|
18468
20020
|
DocumentImage.configure({
|
|
@@ -18491,6 +20043,7 @@ function createWorkDocumentExtensions(options = {}) {
|
|
|
18491
20043
|
DocumentTableFormatting,
|
|
18492
20044
|
DocumentTableSizing,
|
|
18493
20045
|
DocumentTextStyle,
|
|
20046
|
+
DocumentScriptFontFormatting,
|
|
18494
20047
|
DocumentFontFamily,
|
|
18495
20048
|
font_size,
|
|
18496
20049
|
extension_color,
|
|
@@ -20313,4 +21866,4 @@ function registerDocumentPageSurfaceGeometry(element, provider) {
|
|
|
20313
21866
|
function documentPageSurfaceGeometryForElement(element) {
|
|
20314
21867
|
return documentPageSurfaceProviders.get(element)?.() ?? null;
|
|
20315
21868
|
}
|
|
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 };
|
|
21869
|
+
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_LEGACY_TEXT_EFFECT_NAMES, DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE, 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, documentLegacyTextEffectsConflict, documentLegacyTextEffectsCss, documentLegacyTextEffectsDomAttributes, documentLegacyTextEffectsFromElement, documentLegacyTextEffectsFromTextStyleAttributes, 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, normalizeDocumentLegacyTextEffect, normalizeDocumentLegacyTextEffects, 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 };
|