@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/0~5093.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { descendants, directChildren as work_ooxml_package_directChildren, xmlNamespacePrefix, directChild, attribute as work_ooxml_package_attribute, childPath } from "./5184.js";
|
|
2
|
-
import {
|
|
3
|
-
import { DOCUMENT_PARAGRAPH_BORDER_STYLES, normalizeDocumentParagraphBorders as work_document_paragraph_borders_normalizeDocumentParagraphBorders, DOCUMENT_PARAGRAPH_BORDER_EDGES,
|
|
2
|
+
import { docxThemeFont, XML_NAMESPACE as work_docx_settings_xml_XML_NAMESPACE, XMLNS_NAMESPACE as work_docx_settings_xml_XMLNS_NAMESPACE, STRICT_WORDPROCESSING_NAMESPACE, docxCharacterSpacingTwipsFromProperties, parseBoundedDocxInteger, xmlAttributeLocalName, docxCharacterScalePercentFromProperties, resolveDocxEmphasisMark, docxCharacterPositionHalfPointsFromProperties, docxThemeColor, parseDocxParagraphDefaultCollapsed, resolveDocxKerningThresholdHalfPoints, resolveDocxThemeResolver as work_docx_theme_resolveDocxThemeResolver, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace, parseDocxTwipsMeasure } from "./0~7043.js";
|
|
3
|
+
import { normalizeDocumentEmphasisMark, documentWordLineHeightFactor, normalizeDocumentPageBorders, normalizeDocumentParagraphBorder, documentCharacterPositionDomAttributes, DOCUMENT_PAGE_BORDER_EDGES, normalizeDocumentTabStops, documentTextCaseFromWordFlags, DOCUMENT_PARAGRAPH_SHADING_PATTERNS, documentStrikeDomAttributes, documentAutoLineHeight, documentScriptFontFallbackSlots, normalizeDocumentUnderlineColor, documentScriptFontsDomAttributes, documentKerningDomAttributes, documentCharacterScaleDomAttributes, documentParagraphShadingDomAttributes, serializeDocxThemeReference, documentParagraphBordersDomAttributes, normalizeDocumentScriptFontHint, serializeDocumentParagraphFormatting, normalizeDocumentPaperSource, documentEquationText, normalizeDocumentScriptFonts, documentLegacyTextEffectsDomAttributes, documentLegacyTextEffectsConflict, DOCUMENT_PARAGRAPH_BORDER_STYLES, normalizeDocumentParagraphBorders as work_document_paragraph_borders_normalizeDocumentParagraphBorders, DOCUMENT_PARAGRAPH_BORDER_EDGES, normalizeDocumentParagraphIndent, documentScriptFontFamily, normalizeDocumentEquation, normalizeDocumentThemeFont, documentCharacterSpacingDomAttributes, renderDocumentAutoLineHeight, documentUnderlineDomAttributes, normalizeDocumentUnderlineStyle, normalizeDocumentFontName, applyDocumentTextCaseStyle, documentHiddenTextDomAttributes, importedDocumentCharacterFormatting, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, createDocumentEquationElement, normalizeDocumentPageGeometry, serializeDocumentTabStops, documentEmphasisMarkDomAttributes, normalizeDocumentPageMargins, documentScriptFontSegments } from "./6282.js";
|
|
4
4
|
function docxCaptionSequenceKind(instruction) {
|
|
5
5
|
const identifier = /^\s*SEQ\s+([^\s\\]+)/i.exec(instruction)?.[1]?.toLowerCase();
|
|
6
6
|
if (!identifier) return null;
|
|
@@ -1066,13 +1066,6 @@ const WORD_VERTICAL_ALIGNMENTS = new Set([
|
|
|
1066
1066
|
"superscript",
|
|
1067
1067
|
"subscript"
|
|
1068
1068
|
]);
|
|
1069
|
-
const WORD_EMPHASIS_MARKS = new Set([
|
|
1070
|
-
'none',
|
|
1071
|
-
'dot',
|
|
1072
|
-
'comma',
|
|
1073
|
-
'circle',
|
|
1074
|
-
'underDot'
|
|
1075
|
-
]);
|
|
1076
1069
|
const WORD_COMBINE_BRACKETS = new Set([
|
|
1077
1070
|
'none',
|
|
1078
1071
|
'round',
|
|
@@ -1096,8 +1089,6 @@ const MAX_WORD_FONT_NAME_LENGTH = 127;
|
|
|
1096
1089
|
const MAX_WORD_LANGUAGE_LENGTH = 85;
|
|
1097
1090
|
const MAX_WORD_HALF_POINT_SIZE = 1024;
|
|
1098
1091
|
const MAX_WORD_CHARACTER_SPACING_TWIPS = 31680;
|
|
1099
|
-
const MAX_WORD_CHARACTER_SCALE_PERCENT = 600;
|
|
1100
|
-
const MAX_WORD_KERNING_THRESHOLD_HALF_POINTS = 3277;
|
|
1101
1092
|
const MIN_WORD_LINE_BORDER_EIGHTH_POINTS = 2;
|
|
1102
1093
|
const MAX_WORD_LINE_BORDER_EIGHTH_POINTS = 96;
|
|
1103
1094
|
const MAX_WORD_BORDER_SPACING_POINTS = 31;
|
|
@@ -1561,7 +1552,7 @@ function parseWordRunProperties(properties) {
|
|
|
1561
1552
|
const color = parseWordRunColor(children.get('color'));
|
|
1562
1553
|
const characterSpacingTwips = parseWordRequiredInteger(children.get('spacing'), -MAX_WORD_CHARACTER_SPACING_TWIPS, MAX_WORD_CHARACTER_SPACING_TWIPS);
|
|
1563
1554
|
const characterScalePercent = parseWordCharacterScale(children.get('w'));
|
|
1564
|
-
const kerningThresholdHalfPoints = parseWordRequiredInteger(children.get('kern'), 0,
|
|
1555
|
+
const kerningThresholdHalfPoints = parseWordRequiredInteger(children.get('kern'), 0, 3277);
|
|
1565
1556
|
const positionHalfPoints = parseWordPosition(children.get('position'));
|
|
1566
1557
|
const fontSize = parseWordHalfPointSize(children.get('sz'));
|
|
1567
1558
|
const fontSizeComplexScript = parseWordHalfPointSize(children.get('szCs'));
|
|
@@ -1980,7 +1971,7 @@ function parseWordCharacterScale(element) {
|
|
|
1980
1971
|
]));
|
|
1981
1972
|
if (!attributes) return null;
|
|
1982
1973
|
if (!attributes.size) return 100;
|
|
1983
|
-
return wordIntegerValue(attributes.get('val')?.trim() ?? '', 1,
|
|
1974
|
+
return wordIntegerValue(attributes.get('val')?.trim() ?? '', 1, 600);
|
|
1984
1975
|
}
|
|
1985
1976
|
function parseWordPosition(element) {
|
|
1986
1977
|
if (!element) return;
|
|
@@ -2170,7 +2161,7 @@ function parseWordEmphasisMark(element) {
|
|
|
2170
2161
|
'val'
|
|
2171
2162
|
]));
|
|
2172
2163
|
const value = attributes?.get('val')?.trim();
|
|
2173
|
-
return attributes?.size === 1
|
|
2164
|
+
return attributes?.size === 1 ? normalizeDocumentEmphasisMark(value) : null;
|
|
2174
2165
|
}
|
|
2175
2166
|
function parseWordLanguages(element) {
|
|
2176
2167
|
if (!element) return;
|
|
@@ -4082,6 +4073,129 @@ function nextEquationMarker(state) {
|
|
|
4082
4073
|
state.occupiedText += marker;
|
|
4083
4074
|
return marker;
|
|
4084
4075
|
}
|
|
4076
|
+
const ON_VALUES = new Set([
|
|
4077
|
+
'1',
|
|
4078
|
+
'on',
|
|
4079
|
+
'true'
|
|
4080
|
+
]);
|
|
4081
|
+
const OFF_VALUES = new Set([
|
|
4082
|
+
'0',
|
|
4083
|
+
'off',
|
|
4084
|
+
'false'
|
|
4085
|
+
]);
|
|
4086
|
+
function inspectDocxHiddenText(properties) {
|
|
4087
|
+
if (!properties) return {
|
|
4088
|
+
status: 'absent'
|
|
4089
|
+
};
|
|
4090
|
+
const localMatches = work_ooxml_package_directChildren(properties, 'vanish');
|
|
4091
|
+
if (!localMatches.length) return {
|
|
4092
|
+
status: 'absent'
|
|
4093
|
+
};
|
|
4094
|
+
const nativeMatches = localMatches.filter((element)=>DOCX_WORDPROCESSING_NAMESPACES.has(element.namespaceURI ?? ''));
|
|
4095
|
+
if (1 !== localMatches.length || 1 !== nativeMatches.length) return {
|
|
4096
|
+
status: 'invalid'
|
|
4097
|
+
};
|
|
4098
|
+
const vanish = nativeMatches[0];
|
|
4099
|
+
if (work_ooxml_package_directChildren(vanish).length || Array.from(vanish.childNodes).some((node)=>(node.nodeType === Node.TEXT_NODE || node.nodeType === Node.CDATA_SECTION_NODE) && Boolean(node.textContent?.trim()))) return {
|
|
4100
|
+
status: 'invalid'
|
|
4101
|
+
};
|
|
4102
|
+
const attributes = Array.from(vanish.attributes).filter((attribute)=>xmlAttributeNamespace(vanish, attribute) !== work_docx_settings_xml_XMLNS_NAMESPACE && 'xmlns' !== attribute.name && !attribute.name.startsWith('xmlns:'));
|
|
4103
|
+
if (!attributes.length) return {
|
|
4104
|
+
status: 'valid',
|
|
4105
|
+
value: true
|
|
4106
|
+
};
|
|
4107
|
+
if (1 !== attributes.length || 'val' !== xmlAttributeLocalName(attributes[0]) || !DOCX_WORDPROCESSING_NAMESPACES.has(xmlAttributeNamespace(vanish, attributes[0]) ?? '')) return {
|
|
4108
|
+
status: 'invalid'
|
|
4109
|
+
};
|
|
4110
|
+
const value = attributes[0].value;
|
|
4111
|
+
if (ON_VALUES.has(value)) return {
|
|
4112
|
+
status: 'valid',
|
|
4113
|
+
value: true
|
|
4114
|
+
};
|
|
4115
|
+
if (OFF_VALUES.has(value)) return {
|
|
4116
|
+
status: 'valid',
|
|
4117
|
+
value: false
|
|
4118
|
+
};
|
|
4119
|
+
return {
|
|
4120
|
+
status: 'invalid'
|
|
4121
|
+
};
|
|
4122
|
+
}
|
|
4123
|
+
function docxHiddenTextFromProperties(properties) {
|
|
4124
|
+
const inspection = inspectDocxHiddenText(properties);
|
|
4125
|
+
return 'valid' === inspection.status ? inspection.value : void 0;
|
|
4126
|
+
}
|
|
4127
|
+
function resolveDocxHiddenText(propertySources) {
|
|
4128
|
+
let hiddenText;
|
|
4129
|
+
for (const properties of propertySources){
|
|
4130
|
+
const candidate = docxHiddenTextFromProperties(properties);
|
|
4131
|
+
if (void 0 !== candidate) hiddenText = candidate;
|
|
4132
|
+
}
|
|
4133
|
+
return hiddenText;
|
|
4134
|
+
}
|
|
4135
|
+
const work_docx_legacy_text_effects_ON_VALUES = new Set([
|
|
4136
|
+
'1',
|
|
4137
|
+
'on',
|
|
4138
|
+
'true'
|
|
4139
|
+
]);
|
|
4140
|
+
const work_docx_legacy_text_effects_OFF_VALUES = new Set([
|
|
4141
|
+
'0',
|
|
4142
|
+
'off',
|
|
4143
|
+
'false'
|
|
4144
|
+
]);
|
|
4145
|
+
function inspectDocxLegacyTextEffects(properties) {
|
|
4146
|
+
if (!properties) return {
|
|
4147
|
+
status: 'absent'
|
|
4148
|
+
};
|
|
4149
|
+
const effects = {};
|
|
4150
|
+
let present = false;
|
|
4151
|
+
for (const name of DOCUMENT_LEGACY_TEXT_EFFECT_NAMES){
|
|
4152
|
+
const localMatches = work_ooxml_package_directChildren(properties, name);
|
|
4153
|
+
if (!localMatches.length) continue;
|
|
4154
|
+
present = true;
|
|
4155
|
+
const nativeMatches = localMatches.filter((element)=>DOCX_WORDPROCESSING_NAMESPACES.has(element.namespaceURI ?? ''));
|
|
4156
|
+
if (1 !== localMatches.length || 1 !== nativeMatches.length) return {
|
|
4157
|
+
status: 'invalid'
|
|
4158
|
+
};
|
|
4159
|
+
const value = inspectOnOffLeaf(nativeMatches[0]);
|
|
4160
|
+
if (null === value) return {
|
|
4161
|
+
status: 'invalid'
|
|
4162
|
+
};
|
|
4163
|
+
effects[name] = value;
|
|
4164
|
+
}
|
|
4165
|
+
if (!present) return {
|
|
4166
|
+
status: 'absent'
|
|
4167
|
+
};
|
|
4168
|
+
return documentLegacyTextEffectsConflict(effects) ? {
|
|
4169
|
+
status: 'invalid'
|
|
4170
|
+
} : {
|
|
4171
|
+
status: 'valid',
|
|
4172
|
+
value: effects
|
|
4173
|
+
};
|
|
4174
|
+
}
|
|
4175
|
+
function resolveDocxLegacyTextEffects(propertySources) {
|
|
4176
|
+
const effects = {};
|
|
4177
|
+
let present = false;
|
|
4178
|
+
for (const properties of propertySources){
|
|
4179
|
+
const inspection = inspectDocxLegacyTextEffects(properties);
|
|
4180
|
+
if ('invalid' === inspection.status) return;
|
|
4181
|
+
if ('valid' === inspection.status) {
|
|
4182
|
+
Object.assign(effects, inspection.value);
|
|
4183
|
+
present = true;
|
|
4184
|
+
if (documentLegacyTextEffectsConflict(effects)) return;
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
return present ? effects : void 0;
|
|
4188
|
+
}
|
|
4189
|
+
function inspectOnOffLeaf(element) {
|
|
4190
|
+
if (work_ooxml_package_directChildren(element).length || Array.from(element.childNodes).some((node)=>(node.nodeType === Node.TEXT_NODE || node.nodeType === Node.CDATA_SECTION_NODE) && Boolean(node.textContent?.trim()))) return null;
|
|
4191
|
+
const attributes = Array.from(element.attributes).filter((attribute)=>xmlAttributeNamespace(element, attribute) !== work_docx_settings_xml_XMLNS_NAMESPACE && 'xmlns' !== attribute.name && !attribute.name.startsWith('xmlns:'));
|
|
4192
|
+
if (!attributes.length) return true;
|
|
4193
|
+
if (1 !== attributes.length || 'val' !== xmlAttributeLocalName(attributes[0]) || !DOCX_WORDPROCESSING_NAMESPACES.has(xmlAttributeNamespace(element, attributes[0]) ?? '')) return null;
|
|
4194
|
+
const value = attributes[0].value;
|
|
4195
|
+
if (work_docx_legacy_text_effects_ON_VALUES.has(value)) return true;
|
|
4196
|
+
if (work_docx_legacy_text_effects_OFF_VALUES.has(value)) return false;
|
|
4197
|
+
return null;
|
|
4198
|
+
}
|
|
4085
4199
|
const MAX_STYLE_INHERITANCE_DEPTH = 64;
|
|
4086
4200
|
function createDocxParagraphStyleResolver(stylesDocument) {
|
|
4087
4201
|
if (!stylesDocument) return {
|
|
@@ -4640,14 +4754,14 @@ function parseBorderColor(attributes, theme) {
|
|
|
4640
4754
|
if (!semanticValue) return null;
|
|
4641
4755
|
return {
|
|
4642
4756
|
value: semanticValue,
|
|
4643
|
-
theme:
|
|
4757
|
+
theme: work_docx_paragraph_borders_import_themeReference(themeName, semanticValue, tint, shade)
|
|
4644
4758
|
};
|
|
4645
4759
|
}
|
|
4646
4760
|
if ('none' === themeName) {
|
|
4647
4761
|
const value = color ?? 'auto';
|
|
4648
4762
|
return {
|
|
4649
4763
|
value,
|
|
4650
|
-
theme:
|
|
4764
|
+
theme: work_docx_paragraph_borders_import_themeReference(themeName, 'auto' === value ? '#000000' : value, tint, shade)
|
|
4651
4765
|
};
|
|
4652
4766
|
}
|
|
4653
4767
|
if (!color) return null;
|
|
@@ -4655,7 +4769,7 @@ function parseBorderColor(attributes, theme) {
|
|
|
4655
4769
|
value: color
|
|
4656
4770
|
};
|
|
4657
4771
|
}
|
|
4658
|
-
function
|
|
4772
|
+
function work_docx_paragraph_borders_import_themeReference(theme, resolved, tint, shade) {
|
|
4659
4773
|
return {
|
|
4660
4774
|
theme,
|
|
4661
4775
|
resolved,
|
|
@@ -5084,6 +5198,66 @@ function work_docx_paragraph_shading_import_textNodes(root) {
|
|
|
5084
5198
|
while(walker.nextNode())nodes.push(walker.currentNode);
|
|
5085
5199
|
return nodes;
|
|
5086
5200
|
}
|
|
5201
|
+
function importedDocxUnderline(element, theme) {
|
|
5202
|
+
const rawStyle = work_ooxml_package_attribute(element, 'val');
|
|
5203
|
+
const style = null === rawStyle ? 'single' : normalizeDocumentUnderlineStyle(rawStyle) ?? 'single';
|
|
5204
|
+
const themeName = work_ooxml_package_attribute(element, 'themeColor')?.trim();
|
|
5205
|
+
const tint = normalizedByteHex(work_ooxml_package_attribute(element, 'themeTint'));
|
|
5206
|
+
const shade = normalizedByteHex(work_ooxml_package_attribute(element, 'themeShade'));
|
|
5207
|
+
const themed = theme && themeName ? docxThemeColor(theme, themeName, tint, shade) : void 0;
|
|
5208
|
+
const direct = normalizeDocumentUnderlineColor(work_ooxml_package_attribute(element, 'color'));
|
|
5209
|
+
const color = themed ? `#${themed}` : direct;
|
|
5210
|
+
const themeColor = themeName && color ? underlineThemeReference(themeName, color, tint, shade) : void 0;
|
|
5211
|
+
return {
|
|
5212
|
+
style,
|
|
5213
|
+
...color ? {
|
|
5214
|
+
color
|
|
5215
|
+
} : {},
|
|
5216
|
+
...themeColor ? {
|
|
5217
|
+
themeColor
|
|
5218
|
+
} : {}
|
|
5219
|
+
};
|
|
5220
|
+
}
|
|
5221
|
+
function underlineThemeReference(theme, resolved, tint, shade) {
|
|
5222
|
+
return {
|
|
5223
|
+
theme,
|
|
5224
|
+
resolved,
|
|
5225
|
+
...tint ? {
|
|
5226
|
+
tint
|
|
5227
|
+
} : {},
|
|
5228
|
+
...shade ? {
|
|
5229
|
+
shade
|
|
5230
|
+
} : {}
|
|
5231
|
+
};
|
|
5232
|
+
}
|
|
5233
|
+
function normalizedByteHex(value) {
|
|
5234
|
+
const normalized = value?.trim().toUpperCase();
|
|
5235
|
+
return normalized && /^[0-9A-F]{2}$/.test(normalized) ? normalized : void 0;
|
|
5236
|
+
}
|
|
5237
|
+
function importedDocxStrikeFlags(properties) {
|
|
5238
|
+
return {
|
|
5239
|
+
...importedFlag(directChild(properties, 'strike'), 'single'),
|
|
5240
|
+
...importedFlag(directChild(properties, 'dstrike'), 'double')
|
|
5241
|
+
};
|
|
5242
|
+
}
|
|
5243
|
+
function importedDocxStrike(properties) {
|
|
5244
|
+
const flags = importedDocxStrikeFlags(properties);
|
|
5245
|
+
return resolvedDocxStrikeFormatting(flags.single, flags.double);
|
|
5246
|
+
}
|
|
5247
|
+
function resolvedDocxStrikeFormatting(single, double, materializeNone = false) {
|
|
5248
|
+
if (void 0 === single && void 0 === double && !materializeNone) return;
|
|
5249
|
+
const style = double ? 'double' : single ? 'single' : 'none';
|
|
5250
|
+
return {
|
|
5251
|
+
style
|
|
5252
|
+
};
|
|
5253
|
+
}
|
|
5254
|
+
function importedFlag(element, name) {
|
|
5255
|
+
if (!element) return {};
|
|
5256
|
+
const value = work_ooxml_package_attribute(element, 'val')?.trim().toLowerCase();
|
|
5257
|
+
return {
|
|
5258
|
+
[name]: '0' !== value && 'false' !== value && 'off' !== value
|
|
5259
|
+
};
|
|
5260
|
+
}
|
|
5087
5261
|
const PAGE_BORDER_EDGE_SET = new Set(DOCUMENT_PAGE_BORDER_EDGES);
|
|
5088
5262
|
const PAGE_BORDER_ATTRIBUTES = new Set([
|
|
5089
5263
|
'zOrder',
|
|
@@ -5231,64 +5405,6 @@ function hasNonWhitespaceText(element) {
|
|
|
5231
5405
|
function work_docx_page_borders_import_isNamespaceDeclaration(attribute) {
|
|
5232
5406
|
return attribute.namespaceURI === work_docx_settings_xml_XMLNS_NAMESPACE || 'xmlns' === attribute.name || attribute.name.startsWith('xmlns:');
|
|
5233
5407
|
}
|
|
5234
|
-
const STRICT_WORDPROCESSING_NAMESPACE = 'http://purl.oclc.org/ooxml/wordprocessingml/main';
|
|
5235
|
-
const UNIVERSAL_TWIP_RATIOS = {
|
|
5236
|
-
mm: [
|
|
5237
|
-
7200n,
|
|
5238
|
-
127n
|
|
5239
|
-
],
|
|
5240
|
-
cm: [
|
|
5241
|
-
72000n,
|
|
5242
|
-
127n
|
|
5243
|
-
],
|
|
5244
|
-
in: [
|
|
5245
|
-
1440n,
|
|
5246
|
-
1n
|
|
5247
|
-
],
|
|
5248
|
-
pt: [
|
|
5249
|
-
20n,
|
|
5250
|
-
1n
|
|
5251
|
-
],
|
|
5252
|
-
pc: [
|
|
5253
|
-
240n,
|
|
5254
|
-
1n
|
|
5255
|
-
],
|
|
5256
|
-
pi: [
|
|
5257
|
-
240n,
|
|
5258
|
-
1n
|
|
5259
|
-
]
|
|
5260
|
-
};
|
|
5261
|
-
function parseDocxTwipsMeasure(source, options) {
|
|
5262
|
-
const integer = parseBoundedDocxInteger(source, {
|
|
5263
|
-
minimum: options.minimum,
|
|
5264
|
-
maximum: options.maximum,
|
|
5265
|
-
signed: options.signed
|
|
5266
|
-
});
|
|
5267
|
-
if (null !== integer) return integer;
|
|
5268
|
-
return options.strict ? parseStrictUniversalTwips(source, options) : null;
|
|
5269
|
-
}
|
|
5270
|
-
function parseBoundedDocxInteger(source, options) {
|
|
5271
|
-
if (source.length > 32) return null;
|
|
5272
|
-
const pattern = options.signed ? /^[+-]?\d+$/u : /^\+?\d+$/u;
|
|
5273
|
-
if (!pattern.test(source)) return null;
|
|
5274
|
-
const value = Number(source);
|
|
5275
|
-
return Number.isSafeInteger(value) && value >= options.minimum && value <= options.maximum ? Object.is(value, -0) ? 0 : value : null;
|
|
5276
|
-
}
|
|
5277
|
-
function parseStrictUniversalTwips(source, options) {
|
|
5278
|
-
if (source.length > 64) return null;
|
|
5279
|
-
const match = /^(-?)(\d+)(?:\.(\d+))?(mm|cm|in|pt|pc|pi)$/u.exec(source);
|
|
5280
|
-
if (!match) return null;
|
|
5281
|
-
const [, sign, whole = '', fraction = '', unit = ''] = match;
|
|
5282
|
-
if (!options.signed && sign) return null;
|
|
5283
|
-
const conversion = UNIVERSAL_TWIP_RATIOS[unit];
|
|
5284
|
-
if (!conversion) return null;
|
|
5285
|
-
const denominator = 10n ** BigInt(fraction.length) * conversion[1];
|
|
5286
|
-
const numerator = BigInt(`${whole}${fraction}`) * conversion[0] * (sign ? -1n : 1n);
|
|
5287
|
-
if (numerator % denominator !== 0n) return null;
|
|
5288
|
-
const twips = numerator / denominator;
|
|
5289
|
-
if (twips < BigInt(options.minimum) || twips > BigInt(options.maximum)) return null;
|
|
5290
|
-
return Number(twips);
|
|
5291
|
-
}
|
|
5292
5408
|
const PAGE_MARGIN_ATTRIBUTE_SET = new Set([
|
|
5293
5409
|
'top',
|
|
5294
5410
|
'right',
|
|
@@ -6599,6 +6715,151 @@ function work_docx_paragraph_format_change_import_textNodes(root) {
|
|
|
6599
6715
|
while(walker.nextNode())nodes.push(walker.currentNode);
|
|
6600
6716
|
return nodes;
|
|
6601
6717
|
}
|
|
6718
|
+
const FONT_ATTRIBUTES = new Set([
|
|
6719
|
+
'ascii',
|
|
6720
|
+
'hAnsi',
|
|
6721
|
+
'eastAsia',
|
|
6722
|
+
'cs',
|
|
6723
|
+
'asciiTheme',
|
|
6724
|
+
'hAnsiTheme',
|
|
6725
|
+
'eastAsiaTheme',
|
|
6726
|
+
'cstheme',
|
|
6727
|
+
'hint'
|
|
6728
|
+
]);
|
|
6729
|
+
const EMPTY_THEME = {
|
|
6730
|
+
colors: new Map(),
|
|
6731
|
+
fonts: new Map()
|
|
6732
|
+
};
|
|
6733
|
+
function inspectDocxRunFonts(properties, theme = EMPTY_THEME) {
|
|
6734
|
+
if (!properties) return {
|
|
6735
|
+
status: 'absent'
|
|
6736
|
+
};
|
|
6737
|
+
const candidates = work_ooxml_package_directChildren(properties, 'rFonts');
|
|
6738
|
+
if (!candidates.length) return {
|
|
6739
|
+
status: 'absent'
|
|
6740
|
+
};
|
|
6741
|
+
if (1 !== candidates.length) return {
|
|
6742
|
+
status: 'invalid'
|
|
6743
|
+
};
|
|
6744
|
+
const value = parseDocxRunFontsElement(candidates[0], theme);
|
|
6745
|
+
return void 0 === value ? {
|
|
6746
|
+
status: 'invalid'
|
|
6747
|
+
} : {
|
|
6748
|
+
status: 'valid',
|
|
6749
|
+
value
|
|
6750
|
+
};
|
|
6751
|
+
}
|
|
6752
|
+
function resolveDocxRunFonts(propertySources, theme) {
|
|
6753
|
+
const resolved = {};
|
|
6754
|
+
let found = false;
|
|
6755
|
+
for (const properties of propertySources){
|
|
6756
|
+
const inspection = inspectDocxRunFonts(properties, theme);
|
|
6757
|
+
if ('valid' !== inspection.status || !inspection.value) continue;
|
|
6758
|
+
found = true;
|
|
6759
|
+
const next = inspection.value;
|
|
6760
|
+
for (const slot of [
|
|
6761
|
+
'ascii',
|
|
6762
|
+
'highAnsi',
|
|
6763
|
+
'eastAsia',
|
|
6764
|
+
'complexScript'
|
|
6765
|
+
])if (next[slot]) resolved[slot] = next[slot];
|
|
6766
|
+
if (next.hint) resolved.hint = next.hint;
|
|
6767
|
+
}
|
|
6768
|
+
return found ? normalizeDocumentScriptFonts(resolved) : null;
|
|
6769
|
+
}
|
|
6770
|
+
function parseDocxRunFontsElement(element, theme = EMPTY_THEME) {
|
|
6771
|
+
if (!element || 'rFonts' !== element.localName || !DOCX_WORDPROCESSING_NAMESPACES.has(element.namespaceURI ?? '') || work_ooxml_package_directChildren(element).length || Array.from(element.childNodes).some((node)=>node.nodeType === Node.TEXT_NODE && node.textContent?.trim())) return;
|
|
6772
|
+
const attributes = new Map();
|
|
6773
|
+
for (const item of Array.from(element.attributes)){
|
|
6774
|
+
if (item.namespaceURI === work_docx_settings_xml_XMLNS_NAMESPACE || 'xmlns' === item.name || item.name.startsWith('xmlns:')) continue;
|
|
6775
|
+
const name = xmlAttributeLocalName(item);
|
|
6776
|
+
if (!FONT_ATTRIBUTES.has(name) || !DOCX_WORDPROCESSING_NAMESPACES.has(xmlAttributeNamespace(element, item) ?? '') || attributes.has(name)) return;
|
|
6777
|
+
attributes.set(name, item.value);
|
|
6778
|
+
}
|
|
6779
|
+
const ascii = fontFace(attributes.get('ascii'), attributes.get('asciiTheme'), theme);
|
|
6780
|
+
const highAnsi = fontFace(attributes.get('hAnsi'), attributes.get('hAnsiTheme'), theme);
|
|
6781
|
+
const eastAsia = fontFace(attributes.get('eastAsia'), attributes.get('eastAsiaTheme'), theme);
|
|
6782
|
+
const complexScript = fontFace(attributes.get('cs'), attributes.get('cstheme'), theme);
|
|
6783
|
+
const hintValue = attributes.get('hint');
|
|
6784
|
+
const hint = void 0 === hintValue ? void 0 : normalizeDocumentScriptFontHint(hintValue);
|
|
6785
|
+
if (void 0 === ascii || void 0 === highAnsi || void 0 === eastAsia || void 0 === complexScript || null === hint) return;
|
|
6786
|
+
return normalizeDocumentScriptFonts({
|
|
6787
|
+
...ascii ? {
|
|
6788
|
+
ascii
|
|
6789
|
+
} : {},
|
|
6790
|
+
...highAnsi ? {
|
|
6791
|
+
highAnsi
|
|
6792
|
+
} : {},
|
|
6793
|
+
...eastAsia ? {
|
|
6794
|
+
eastAsia
|
|
6795
|
+
} : {},
|
|
6796
|
+
...complexScript ? {
|
|
6797
|
+
complexScript
|
|
6798
|
+
} : {},
|
|
6799
|
+
...hint ? {
|
|
6800
|
+
hint
|
|
6801
|
+
} : {}
|
|
6802
|
+
});
|
|
6803
|
+
}
|
|
6804
|
+
function fontFace(directSource, themeSource, theme) {
|
|
6805
|
+
const name = void 0 === directSource ? void 0 : normalizeDocumentFontName(directSource);
|
|
6806
|
+
const themeReference = void 0 === themeSource ? void 0 : normalizeDocumentThemeFont(themeSource);
|
|
6807
|
+
if (void 0 !== directSource && !name || null === themeReference) return;
|
|
6808
|
+
if (!name && !themeReference) return null;
|
|
6809
|
+
const themedFamily = themeReference ? docxThemeFont(theme, themeReference) : void 0;
|
|
6810
|
+
const resolved = themedFamily ?? name;
|
|
6811
|
+
return {
|
|
6812
|
+
...name ? {
|
|
6813
|
+
name
|
|
6814
|
+
} : {},
|
|
6815
|
+
...themeReference ? {
|
|
6816
|
+
theme: themeReference
|
|
6817
|
+
} : {},
|
|
6818
|
+
...resolved ? {
|
|
6819
|
+
resolved
|
|
6820
|
+
} : {}
|
|
6821
|
+
};
|
|
6822
|
+
}
|
|
6823
|
+
function directDocxRunText(run) {
|
|
6824
|
+
return directDocxRunTextElements(run).map((child)=>child.textContent ?? '').join('');
|
|
6825
|
+
}
|
|
6826
|
+
function markSegmentedDocxRunFormatting(run, state, segments, formattingFor, changeFor, createMarkers) {
|
|
6827
|
+
let runOffset = 0;
|
|
6828
|
+
for (const textElement of directDocxRunTextElements(run)){
|
|
6829
|
+
const source = textElement.textContent ?? '';
|
|
6830
|
+
const elementFrom = runOffset;
|
|
6831
|
+
const elementTo = elementFrom + source.length;
|
|
6832
|
+
runOffset = elementTo;
|
|
6833
|
+
if (!source) continue;
|
|
6834
|
+
const replacement = [];
|
|
6835
|
+
for (const segment of segments){
|
|
6836
|
+
const from = Math.max(elementFrom, segment.from);
|
|
6837
|
+
const to = Math.min(elementTo, segment.to);
|
|
6838
|
+
if (to <= from) continue;
|
|
6839
|
+
const text = source.slice(from - elementFrom, to - elementFrom);
|
|
6840
|
+
const formatting = formattingFor(text, segment.slot);
|
|
6841
|
+
const change = changeFor(text, segment.slot);
|
|
6842
|
+
if (!Object.keys(formatting).length && !change) {
|
|
6843
|
+
replacement.push(text);
|
|
6844
|
+
continue;
|
|
6845
|
+
}
|
|
6846
|
+
const { startMarker, endMarker } = createMarkers();
|
|
6847
|
+
replacement.push(startMarker, text, endMarker);
|
|
6848
|
+
state.markers.runs.push({
|
|
6849
|
+
startMarker,
|
|
6850
|
+
endMarker,
|
|
6851
|
+
formatting,
|
|
6852
|
+
...change ? {
|
|
6853
|
+
change
|
|
6854
|
+
} : {}
|
|
6855
|
+
});
|
|
6856
|
+
}
|
|
6857
|
+
textElement.textContent = replacement.join('');
|
|
6858
|
+
}
|
|
6859
|
+
}
|
|
6860
|
+
function directDocxRunTextElements(run) {
|
|
6861
|
+
return Array.from(run.children).filter((child)=>'t' === child.localName || 'delText' === child.localName);
|
|
6862
|
+
}
|
|
6602
6863
|
const work_docx_run_formatting_import_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
6603
6864
|
const work_docx_run_formatting_import_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
6604
6865
|
const RUN_FORMATTING_MARKER_PATTERN = /__A3S_WORK_RUN_(?:START|END)_\d+__/g;
|
|
@@ -6610,6 +6871,17 @@ const SUPPORTED_RUN_PROPERTY_CHANGE_CHILDREN = new Set([
|
|
|
6610
6871
|
'u',
|
|
6611
6872
|
'strike',
|
|
6612
6873
|
'dstrike',
|
|
6874
|
+
'outline',
|
|
6875
|
+
'shadow',
|
|
6876
|
+
'emboss',
|
|
6877
|
+
'imprint',
|
|
6878
|
+
'caps',
|
|
6879
|
+
'smallCaps',
|
|
6880
|
+
'vanish',
|
|
6881
|
+
'spacing',
|
|
6882
|
+
'w',
|
|
6883
|
+
'kern',
|
|
6884
|
+
'position',
|
|
6613
6885
|
'rFonts',
|
|
6614
6886
|
'sz',
|
|
6615
6887
|
'szCs',
|
|
@@ -6619,28 +6891,47 @@ const SUPPORTED_RUN_PROPERTY_CHANGE_CHILDREN = new Set([
|
|
|
6619
6891
|
'snapToGrid',
|
|
6620
6892
|
'cs',
|
|
6621
6893
|
'rtl',
|
|
6894
|
+
'em',
|
|
6622
6895
|
'vertAlign'
|
|
6623
6896
|
]);
|
|
6624
|
-
function
|
|
6625
|
-
|
|
6897
|
+
function createImportedDocxRunFormattingMarkerState(documents) {
|
|
6898
|
+
return {
|
|
6899
|
+
markers: {
|
|
6900
|
+
runs: []
|
|
6901
|
+
},
|
|
6902
|
+
nextMarker: 1,
|
|
6903
|
+
occupiedText: documents.map((document)=>document.documentElement.textContent ?? '').join('')
|
|
6904
|
+
};
|
|
6905
|
+
}
|
|
6906
|
+
function markDocxRunFormattingIntoState(document, state, styleSource, themeSource, tableStyleSource) {
|
|
6626
6907
|
const styles = resolveDocxParagraphStyleResolver(styleSource);
|
|
6627
6908
|
const theme = work_docx_theme_resolveDocxThemeResolver(themeSource);
|
|
6628
6909
|
const tableStyles = resolveDocxTableStyleResolver(tableStyleSource);
|
|
6629
6910
|
for (const run of descendants(document, 'r')){
|
|
6630
|
-
const runText =
|
|
6631
|
-
if (!runText
|
|
6911
|
+
const runText = directDocxRunText(run);
|
|
6912
|
+
if (!runText) continue;
|
|
6632
6913
|
const paragraph = work_docx_run_formatting_import_closestAncestor(run, 'p');
|
|
6633
6914
|
if (!paragraph) continue;
|
|
6634
6915
|
const paragraphProperties = directChild(paragraph, 'pPr');
|
|
6635
6916
|
const runProperties = directChild(run, 'rPr');
|
|
6636
|
-
const
|
|
6637
|
-
const
|
|
6917
|
+
const contextualProperties = docxTableRunPropertySources(run, tableStyles);
|
|
6918
|
+
const propertySources = docxRunPropertySources(paragraphProperties, runProperties, styles, contextualProperties);
|
|
6919
|
+
const scriptFonts = resolveDocxRunFonts(propertySources, theme);
|
|
6920
|
+
const forceComplexScript = propertySourcesUseComplexScript(propertySources);
|
|
6921
|
+
const scriptSegments = documentScriptFontSegments(runText, scriptFonts?.hint, forceComplexScript);
|
|
6922
|
+
const formattingFor = (text, scriptFontSlot)=>resolvedRunFormatting(propertySources, theme, text, scriptFontSlot, scriptFonts);
|
|
6923
|
+
const changeFor = (text, scriptFontSlot)=>importedRunFormattingChange(runProperties, paragraphProperties, styles, contextualProperties, theme, text, scriptFontSlot);
|
|
6924
|
+
if (scriptSegments.length > 1) {
|
|
6925
|
+
markSegmentedDocxRunFormatting(run, state, scriptSegments, formattingFor, changeFor, ()=>nextRunFormattingMarkers(state));
|
|
6926
|
+
continue;
|
|
6927
|
+
}
|
|
6928
|
+
const scriptFontSlot = scriptSegments[0]?.slot;
|
|
6929
|
+
const formatting = formattingFor(runText, scriptFontSlot);
|
|
6930
|
+
const change = changeFor(runText, scriptFontSlot);
|
|
6638
6931
|
if (!Object.keys(formatting).length && !change) continue;
|
|
6639
|
-
const
|
|
6640
|
-
const startMarker = `__A3S_WORK_RUN_START_${index}__`;
|
|
6641
|
-
const endMarker = `__A3S_WORK_RUN_END_${index}__`;
|
|
6932
|
+
const { startMarker, endMarker } = nextRunFormattingMarkers(state);
|
|
6642
6933
|
insertRunMarkers(document, run, runProperties, startMarker, endMarker);
|
|
6643
|
-
runs.push({
|
|
6934
|
+
state.markers.runs.push({
|
|
6644
6935
|
startMarker,
|
|
6645
6936
|
endMarker,
|
|
6646
6937
|
formatting,
|
|
@@ -6649,9 +6940,6 @@ function markDocxRunFormatting(document, styleSource, themeSource, tableStyleSou
|
|
|
6649
6940
|
} : {}
|
|
6650
6941
|
});
|
|
6651
6942
|
}
|
|
6652
|
-
return {
|
|
6653
|
-
runs
|
|
6654
|
-
};
|
|
6655
6943
|
}
|
|
6656
6944
|
function applyImportedDocxRunFormattingMarkers(document, markers) {
|
|
6657
6945
|
const replacements = new Map();
|
|
@@ -6664,13 +6952,24 @@ function applyImportedDocxRunFormattingMarkers(document, markers) {
|
|
|
6664
6952
|
replacements.set(marker.startMarker, `${change.start}${markup.start}`);
|
|
6665
6953
|
replacements.set(marker.endMarker, `${markup.end}${change.end}`);
|
|
6666
6954
|
}
|
|
6667
|
-
document.body.innerHTML = document.body.innerHTML.replace(RUN_FORMATTING_MARKER_PATTERN, (marker)=>replacements.get(marker) ??
|
|
6955
|
+
document.body.innerHTML = document.body.innerHTML.replace(RUN_FORMATTING_MARKER_PATTERN, (marker)=>replacements.get(marker) ?? marker);
|
|
6956
|
+
}
|
|
6957
|
+
function nextRunFormattingMarkers(state) {
|
|
6958
|
+
while(true){
|
|
6959
|
+
const index = state.nextMarker;
|
|
6960
|
+
state.nextMarker += 1;
|
|
6961
|
+
const startMarker = `__A3S_WORK_RUN_START_${index}__`;
|
|
6962
|
+
const endMarker = `__A3S_WORK_RUN_END_${index}__`;
|
|
6963
|
+
if (!state.occupiedText.includes(startMarker) && !state.occupiedText.includes(endMarker)) return {
|
|
6964
|
+
startMarker,
|
|
6965
|
+
endMarker
|
|
6966
|
+
};
|
|
6967
|
+
}
|
|
6668
6968
|
}
|
|
6669
6969
|
function hasImportedDocxRunFormattingMarkers(markers) {
|
|
6670
6970
|
return markers.runs.length > 0;
|
|
6671
6971
|
}
|
|
6672
|
-
function resolvedRunFormatting(propertySources, theme, runText) {
|
|
6673
|
-
const fonts = {};
|
|
6972
|
+
function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlot, resolvedScriptFonts = resolveDocxRunFonts(propertySources, theme)) {
|
|
6674
6973
|
let fontSize;
|
|
6675
6974
|
let complexFontSize;
|
|
6676
6975
|
let color;
|
|
@@ -6683,20 +6982,35 @@ function resolvedRunFormatting(propertySources, theme, runText) {
|
|
|
6683
6982
|
let complexItalic;
|
|
6684
6983
|
let underline;
|
|
6685
6984
|
let strike;
|
|
6985
|
+
let doubleStrike;
|
|
6686
6986
|
let subscript;
|
|
6687
6987
|
let superscript;
|
|
6688
6988
|
let snapToGrid;
|
|
6689
6989
|
let complexScriptFormatting;
|
|
6690
6990
|
let rightToLeft;
|
|
6691
|
-
let
|
|
6991
|
+
let allCaps;
|
|
6992
|
+
let smallCaps;
|
|
6993
|
+
let characterScalePercent;
|
|
6994
|
+
let characterPositionHalfPoints;
|
|
6995
|
+
let characterSpacingTwips;
|
|
6996
|
+
const kerningThresholdHalfPoints = resolveDocxKerningThresholdHalfPoints(propertySources);
|
|
6997
|
+
const emphasisMark = resolveDocxEmphasisMark(propertySources);
|
|
6998
|
+
const hiddenText = resolveDocxHiddenText(propertySources);
|
|
6999
|
+
const legacyTextEffects = resolveDocxLegacyTextEffects(propertySources);
|
|
6692
7000
|
for (const properties of propertySources){
|
|
6693
7001
|
bold = overriddenBoolean(bold, onOffProperty(properties, 'b'));
|
|
6694
7002
|
complexBold = overriddenBoolean(complexBold, onOffProperty(properties, 'bCs'));
|
|
6695
7003
|
italic = overriddenBoolean(italic, onOffProperty(properties, 'i'));
|
|
6696
7004
|
complexItalic = overriddenBoolean(complexItalic, onOffProperty(properties, 'iCs'));
|
|
6697
|
-
underline =
|
|
6698
|
-
|
|
6699
|
-
strike = overriddenBoolean(strike,
|
|
7005
|
+
underline = overriddenValue(underline, underlineProperty(properties, theme));
|
|
7006
|
+
const importedStrike = importedDocxStrikeFlags(properties);
|
|
7007
|
+
strike = overriddenBoolean(strike, importedStrike.single);
|
|
7008
|
+
doubleStrike = overriddenBoolean(doubleStrike, importedStrike.double);
|
|
7009
|
+
allCaps = overriddenBoolean(allCaps, onOffProperty(properties, 'caps'));
|
|
7010
|
+
smallCaps = overriddenBoolean(smallCaps, onOffProperty(properties, 'smallCaps'));
|
|
7011
|
+
characterSpacingTwips = overriddenValue(characterSpacingTwips, docxCharacterSpacingTwipsFromProperties(properties));
|
|
7012
|
+
characterScalePercent = overriddenValue(characterScalePercent, docxCharacterScalePercentFromProperties(properties));
|
|
7013
|
+
characterPositionHalfPoints = overriddenValue(characterPositionHalfPoints, docxCharacterPositionHalfPointsFromProperties(properties));
|
|
6700
7014
|
const verticalAlign = directChild(properties, 'vertAlign');
|
|
6701
7015
|
if (verticalAlign) {
|
|
6702
7016
|
const value = work_docx_run_formatting_import_wordAttribute(verticalAlign, 'val')?.trim().toLowerCase();
|
|
@@ -6710,14 +7024,6 @@ function resolvedRunFormatting(propertySources, theme, runText) {
|
|
|
6710
7024
|
snapToGrid = overriddenBoolean(snapToGrid, onOffProperty(properties, 'snapToGrid'));
|
|
6711
7025
|
complexScriptFormatting = overriddenBoolean(complexScriptFormatting, onOffProperty(properties, 'cs'));
|
|
6712
7026
|
rightToLeft = overriddenBoolean(rightToLeft, onOffProperty(properties, 'rtl'));
|
|
6713
|
-
const runFonts = directChild(properties, 'rFonts');
|
|
6714
|
-
if (runFonts) {
|
|
6715
|
-
fontHint = resolvedFontHint(runFonts) ?? fontHint;
|
|
6716
|
-
assignFont(fonts, 'ascii', resolvedFont(runFonts, 'ascii', 'asciiTheme', theme));
|
|
6717
|
-
assignFont(fonts, 'hAnsi', resolvedFont(runFonts, 'hAnsi', 'hAnsiTheme', theme));
|
|
6718
|
-
assignFont(fonts, 'eastAsia', resolvedFont(runFonts, 'eastAsia', 'eastAsiaTheme', theme));
|
|
6719
|
-
assignFont(fonts, 'complex', resolvedFont(runFonts, 'cs', 'cstheme', theme));
|
|
6720
|
-
}
|
|
6721
7027
|
const size = work_docx_run_formatting_import_numericAttribute(directChild(properties, 'sz'), 'val');
|
|
6722
7028
|
if (void 0 !== size && size > 0) fontSize = Math.min(512, size / 2);
|
|
6723
7029
|
const complexSize = work_docx_run_formatting_import_numericAttribute(directChild(properties, 'szCs'), 'val');
|
|
@@ -6760,19 +7066,15 @@ function resolvedRunFormatting(propertySources, theme, runText) {
|
|
|
6760
7066
|
}
|
|
6761
7067
|
}
|
|
6762
7068
|
}
|
|
6763
|
-
const fontSlot = true === complexScriptFormatting || true === rightToLeft ? '
|
|
6764
|
-
const usesComplexFormatting = '
|
|
7069
|
+
const fontSlot = true === complexScriptFormatting || true === rightToLeft ? 'complexScript' : requestedFontSlot ?? documentScriptFontSegments(runText, resolvedScriptFonts?.hint)[0]?.slot ?? 'ascii';
|
|
7070
|
+
const usesComplexFormatting = 'complexScript' === fontSlot;
|
|
6765
7071
|
const resolvedBold = usesComplexFormatting ? complexBold ?? bold : bold;
|
|
6766
7072
|
const resolvedItalic = usesComplexFormatting ? complexItalic ?? italic : italic;
|
|
6767
7073
|
const resolvedFontSize = usesComplexFormatting ? complexFontSize ?? fontSize : fontSize;
|
|
6768
|
-
|
|
6769
|
-
if (!fontFamily) fontFamily = uniqueFonts(orderedFonts({
|
|
6770
|
-
ascii: docxThemeFont(theme, 'minorAscii'),
|
|
6771
|
-
hAnsi: docxThemeFont(theme, 'minorHAnsi'),
|
|
6772
|
-
eastAsia: docxThemeFont(theme, 'minorEastAsia'),
|
|
6773
|
-
complex: docxThemeFont(theme, 'minorBidi')
|
|
6774
|
-
}, fontSlot));
|
|
7074
|
+
const fontFamily = documentScriptFontFamily(resolvedScriptFonts, fontSlot) ?? defaultThemeFontFamily(theme, fontSlot);
|
|
6775
7075
|
const hasRunPropertySource = propertySources.length > 0;
|
|
7076
|
+
const resolvedStrike = resolvedDocxStrikeFormatting(strike, doubleStrike, hasRunPropertySource);
|
|
7077
|
+
const textCase = documentTextCaseFromWordFlags(allCaps, smallCaps);
|
|
6776
7078
|
return {
|
|
6777
7079
|
...void 0 !== resolvedBold || hasRunPropertySource ? {
|
|
6778
7080
|
bold: resolvedBold ?? false
|
|
@@ -6781,10 +7083,12 @@ function resolvedRunFormatting(propertySources, theme, runText) {
|
|
|
6781
7083
|
italic: resolvedItalic ?? false
|
|
6782
7084
|
} : {},
|
|
6783
7085
|
...void 0 !== underline || hasRunPropertySource ? {
|
|
6784
|
-
underline: underline ??
|
|
7086
|
+
underline: underline ?? {
|
|
7087
|
+
style: 'none'
|
|
7088
|
+
}
|
|
6785
7089
|
} : {},
|
|
6786
|
-
...
|
|
6787
|
-
strike:
|
|
7090
|
+
...resolvedStrike ? {
|
|
7091
|
+
strike: resolvedStrike
|
|
6788
7092
|
} : {},
|
|
6789
7093
|
...void 0 !== subscript ? {
|
|
6790
7094
|
subscript
|
|
@@ -6792,10 +7096,44 @@ function resolvedRunFormatting(propertySources, theme, runText) {
|
|
|
6792
7096
|
...void 0 !== superscript ? {
|
|
6793
7097
|
superscript
|
|
6794
7098
|
} : {},
|
|
7099
|
+
...void 0 !== characterScalePercent ? {
|
|
7100
|
+
characterScalePercent
|
|
7101
|
+
} : {},
|
|
7102
|
+
...void 0 !== characterPositionHalfPoints ? {
|
|
7103
|
+
characterPositionHalfPoints
|
|
7104
|
+
} : {},
|
|
7105
|
+
...void 0 !== characterSpacingTwips ? {
|
|
7106
|
+
characterSpacingTwips
|
|
7107
|
+
} : {},
|
|
7108
|
+
...void 0 !== kerningThresholdHalfPoints ? {
|
|
7109
|
+
kerningThresholdHalfPoints
|
|
7110
|
+
} : {},
|
|
7111
|
+
...void 0 !== emphasisMark ? {
|
|
7112
|
+
emphasisMark
|
|
7113
|
+
} : {},
|
|
7114
|
+
...void 0 !== hiddenText ? {
|
|
7115
|
+
hiddenText
|
|
7116
|
+
} : {},
|
|
7117
|
+
...legacyTextEffects?.outline !== void 0 ? {
|
|
7118
|
+
legacyTextOutline: legacyTextEffects.outline
|
|
7119
|
+
} : {},
|
|
7120
|
+
...legacyTextEffects?.shadow !== void 0 ? {
|
|
7121
|
+
legacyTextShadow: legacyTextEffects.shadow
|
|
7122
|
+
} : {},
|
|
7123
|
+
...legacyTextEffects?.emboss !== void 0 ? {
|
|
7124
|
+
legacyTextEmboss: legacyTextEffects.emboss
|
|
7125
|
+
} : {},
|
|
7126
|
+
...legacyTextEffects?.imprint !== void 0 ? {
|
|
7127
|
+
legacyTextImprint: legacyTextEffects.imprint
|
|
7128
|
+
} : {},
|
|
6795
7129
|
...fontFamily ? {
|
|
6796
7130
|
fontFamily,
|
|
6797
7131
|
wordLineHeightFactor: documentWordLineHeightFactor(fontFamily)
|
|
6798
7132
|
} : {},
|
|
7133
|
+
...resolvedScriptFonts ? {
|
|
7134
|
+
scriptFonts: resolvedScriptFonts,
|
|
7135
|
+
scriptFontSlot: fontSlot
|
|
7136
|
+
} : {},
|
|
6799
7137
|
...void 0 !== resolvedFontSize ? {
|
|
6800
7138
|
fontSize: resolvedFontSize
|
|
6801
7139
|
} : {},
|
|
@@ -6813,6 +7151,9 @@ function resolvedRunFormatting(propertySources, theme, runText) {
|
|
|
6813
7151
|
} : {},
|
|
6814
7152
|
...themeFill ? {
|
|
6815
7153
|
themeFill
|
|
7154
|
+
} : {},
|
|
7155
|
+
...textCase ? {
|
|
7156
|
+
textCase
|
|
6816
7157
|
} : {}
|
|
6817
7158
|
};
|
|
6818
7159
|
}
|
|
@@ -6832,8 +7173,38 @@ function formattingMarkup(document, formatting) {
|
|
|
6832
7173
|
const span = document.createElement('span');
|
|
6833
7174
|
if (false === formatting.bold) span.style.fontWeight = 'normal';
|
|
6834
7175
|
if (false === formatting.italic) span.style.fontStyle = 'normal';
|
|
6835
|
-
|
|
7176
|
+
const underlineEnabled = void 0 !== formatting.underline && 'none' !== formatting.underline.style;
|
|
7177
|
+
const strikeEnabled = void 0 !== formatting.strike && 'none' !== formatting.strike.style;
|
|
7178
|
+
if ((formatting.underline?.style === 'none' || formatting.strike?.style === 'none') && !underlineEnabled && !strikeEnabled) span.style.textDecorationLine = 'none';
|
|
6836
7179
|
if (formatting.fontFamily) span.style.fontFamily = formatting.fontFamily;
|
|
7180
|
+
if (formatting.scriptFonts) for (const [name, value] of Object.entries(documentScriptFontsDomAttributes(formatting.scriptFonts, formatting.scriptFontSlot)))if ('style' === name) span.style.cssText += `; ${value}`;
|
|
7181
|
+
else span.setAttribute(name, value);
|
|
7182
|
+
if (void 0 !== formatting.characterSpacingTwips) for (const [name, value] of Object.entries(documentCharacterSpacingDomAttributes(formatting.characterSpacingTwips)))if ('style' === name) span.style.cssText += `; ${value}`;
|
|
7183
|
+
else span.setAttribute(name, value);
|
|
7184
|
+
if (void 0 !== formatting.characterScalePercent) for (const [name, value] of Object.entries(documentCharacterScaleDomAttributes(formatting.characterScalePercent)))if ('style' === name) span.style.cssText += `; ${value}`;
|
|
7185
|
+
else span.setAttribute(name, value);
|
|
7186
|
+
if (void 0 !== formatting.kerningThresholdHalfPoints) for (const [name, value] of Object.entries(documentKerningDomAttributes(formatting.kerningThresholdHalfPoints, formatting.fontSize)))if ('style' === name) span.style.cssText += `; ${value}`;
|
|
7187
|
+
else span.setAttribute(name, value);
|
|
7188
|
+
if (void 0 !== formatting.characterPositionHalfPoints) for (const [name, value] of Object.entries(documentCharacterPositionDomAttributes(formatting.characterPositionHalfPoints)))if ('style' === name) span.style.cssText += `; ${value}`;
|
|
7189
|
+
else span.setAttribute(name, value);
|
|
7190
|
+
if (void 0 !== formatting.emphasisMark) for (const [name, value] of Object.entries(documentEmphasisMarkDomAttributes(formatting.emphasisMark)))if ('style' === name) span.style.cssText += `; ${value}`;
|
|
7191
|
+
else span.setAttribute(name, value);
|
|
7192
|
+
if (void 0 !== formatting.hiddenText) for (const [name, value] of Object.entries(documentHiddenTextDomAttributes(formatting.hiddenText)))span.setAttribute(name, value);
|
|
7193
|
+
const legacyTextEffects = {
|
|
7194
|
+
...void 0 !== formatting.legacyTextOutline ? {
|
|
7195
|
+
outline: formatting.legacyTextOutline
|
|
7196
|
+
} : {},
|
|
7197
|
+
...void 0 !== formatting.legacyTextShadow ? {
|
|
7198
|
+
shadow: formatting.legacyTextShadow
|
|
7199
|
+
} : {},
|
|
7200
|
+
...void 0 !== formatting.legacyTextEmboss ? {
|
|
7201
|
+
emboss: formatting.legacyTextEmboss
|
|
7202
|
+
} : {},
|
|
7203
|
+
...void 0 !== formatting.legacyTextImprint ? {
|
|
7204
|
+
imprint: formatting.legacyTextImprint
|
|
7205
|
+
} : {}
|
|
7206
|
+
};
|
|
7207
|
+
for (const [name, value] of Object.entries(documentLegacyTextEffectsDomAttributes(legacyTextEffects)))span.setAttribute(name, value);
|
|
6837
7208
|
if (void 0 !== formatting.wordLineHeightFactor) {
|
|
6838
7209
|
const factor = formatLineHeightFactor(formatting.wordLineHeightFactor);
|
|
6839
7210
|
span.dataset.officeWordLineHeightFactor = factor;
|
|
@@ -6847,38 +7218,69 @@ function formattingMarkup(document, formatting) {
|
|
|
6847
7218
|
if (formatting.backgroundColor) span.style.backgroundColor = formatting.backgroundColor;
|
|
6848
7219
|
const themeFill = serializeDocxThemeReference(formatting.themeFill ?? null);
|
|
6849
7220
|
if (themeFill) span.dataset.officeThemeFill = themeFill;
|
|
7221
|
+
if (formatting.textCase) applyDocumentTextCaseStyle(span, formatting.textCase);
|
|
6850
7222
|
const html = span.outerHTML;
|
|
6851
|
-
const
|
|
7223
|
+
const wrappers = [
|
|
6852
7224
|
...formatting.bold ? [
|
|
6853
|
-
|
|
7225
|
+
{
|
|
7226
|
+
start: '<strong>',
|
|
7227
|
+
end: '</strong>'
|
|
7228
|
+
}
|
|
6854
7229
|
] : [],
|
|
6855
7230
|
...formatting.italic ? [
|
|
6856
|
-
|
|
7231
|
+
{
|
|
7232
|
+
start: '<em>',
|
|
7233
|
+
end: '</em>'
|
|
7234
|
+
}
|
|
6857
7235
|
] : [],
|
|
6858
7236
|
...formatting.underline ? [
|
|
6859
|
-
|
|
7237
|
+
underlineFormattingWrapper(document, formatting.underline)
|
|
6860
7238
|
] : [],
|
|
6861
7239
|
...formatting.strike ? [
|
|
6862
|
-
|
|
7240
|
+
strikeFormattingWrapper(document, formatting.strike)
|
|
6863
7241
|
] : [],
|
|
6864
7242
|
...formatting.subscript ? [
|
|
6865
|
-
|
|
7243
|
+
{
|
|
7244
|
+
start: '<sub>',
|
|
7245
|
+
end: '</sub>'
|
|
7246
|
+
}
|
|
6866
7247
|
] : [],
|
|
6867
7248
|
...formatting.superscript ? [
|
|
6868
|
-
|
|
7249
|
+
{
|
|
7250
|
+
start: '<sup>',
|
|
7251
|
+
end: '</sup>'
|
|
7252
|
+
}
|
|
6869
7253
|
] : []
|
|
6870
7254
|
];
|
|
6871
7255
|
return {
|
|
6872
|
-
start: `${html.slice(0, html.indexOf('>') + 1)}${
|
|
7256
|
+
start: `${html.slice(0, html.indexOf('>') + 1)}${wrappers.map((wrapper)=>wrapper.start).join('')}`,
|
|
6873
7257
|
end: `${[
|
|
6874
|
-
...
|
|
6875
|
-
].reverse().map((
|
|
7258
|
+
...wrappers
|
|
7259
|
+
].reverse().map((wrapper)=>wrapper.end).join('')}</span>`
|
|
7260
|
+
};
|
|
7261
|
+
}
|
|
7262
|
+
function underlineFormattingWrapper(document, formatting) {
|
|
7263
|
+
const underline = document.createElement('u');
|
|
7264
|
+
for (const [name, value] of Object.entries(documentUnderlineDomAttributes(formatting)))underline.setAttribute(name, value);
|
|
7265
|
+
const html = underline.outerHTML;
|
|
7266
|
+
return {
|
|
7267
|
+
start: html.slice(0, html.indexOf('>') + 1),
|
|
7268
|
+
end: '</u>'
|
|
7269
|
+
};
|
|
7270
|
+
}
|
|
7271
|
+
function strikeFormattingWrapper(document, formatting) {
|
|
7272
|
+
const strike = document.createElement('s');
|
|
7273
|
+
for (const [name, value] of Object.entries(documentStrikeDomAttributes(formatting)))strike.setAttribute(name, value);
|
|
7274
|
+
const html = strike.outerHTML;
|
|
7275
|
+
return {
|
|
7276
|
+
start: html.slice(0, html.indexOf('>') + 1),
|
|
7277
|
+
end: '</s>'
|
|
6876
7278
|
};
|
|
6877
7279
|
}
|
|
6878
|
-
function importedRunFormattingChange(runProperties, paragraphProperties, styles, contextualProperties, theme, runText) {
|
|
7280
|
+
function importedRunFormattingChange(runProperties, paragraphProperties, styles, contextualProperties, theme, runText, requestedFontSlot) {
|
|
6879
7281
|
const parsed = supportedRunFormattingChange(runProperties);
|
|
6880
7282
|
if (!parsed) return;
|
|
6881
|
-
const beforeFormatting = resolvedRunFormatting(docxRunPropertySources(paragraphProperties, parsed.properties, styles, contextualProperties), theme, runText);
|
|
7283
|
+
const beforeFormatting = resolvedRunFormatting(docxRunPropertySources(paragraphProperties, parsed.properties, styles, contextualProperties), theme, runText, requestedFontSlot);
|
|
6882
7284
|
return {
|
|
6883
7285
|
id: `docx-format-change-${parsed.id}`,
|
|
6884
7286
|
author: parsed.author,
|
|
@@ -6886,7 +7288,14 @@ function importedRunFormattingChange(runProperties, paragraphProperties, styles,
|
|
|
6886
7288
|
before: importedDocumentCharacterFormatting({
|
|
6887
7289
|
...beforeFormatting,
|
|
6888
7290
|
themeColor: serializeDocxThemeReference(beforeFormatting.themeColor ?? null),
|
|
6889
|
-
themeFill: serializeDocxThemeReference(beforeFormatting.themeFill ?? null)
|
|
7291
|
+
themeFill: serializeDocxThemeReference(beforeFormatting.themeFill ?? null),
|
|
7292
|
+
scriptFonts: beforeFormatting.scriptFonts,
|
|
7293
|
+
scriptFontSlot: beforeFormatting.scriptFontSlot,
|
|
7294
|
+
textCase: beforeFormatting.textCase,
|
|
7295
|
+
legacyTextOutline: beforeFormatting.legacyTextOutline,
|
|
7296
|
+
legacyTextShadow: beforeFormatting.legacyTextShadow,
|
|
7297
|
+
legacyTextEmboss: beforeFormatting.legacyTextEmboss,
|
|
7298
|
+
legacyTextImprint: beforeFormatting.legacyTextImprint
|
|
6890
7299
|
})
|
|
6891
7300
|
};
|
|
6892
7301
|
}
|
|
@@ -6942,8 +7351,8 @@ function work_docx_run_formatting_import_normalizeRevisionDate(value) {
|
|
|
6942
7351
|
function work_docx_run_formatting_import_themeReference(element, themeName, tintName, shadeName, resolved) {
|
|
6943
7352
|
const theme = work_docx_run_formatting_import_wordAttribute(element, themeName)?.trim();
|
|
6944
7353
|
if (!theme) return;
|
|
6945
|
-
const tint =
|
|
6946
|
-
const shade =
|
|
7354
|
+
const tint = work_docx_run_formatting_import_normalizedByteHex(work_docx_run_formatting_import_wordAttribute(element, tintName));
|
|
7355
|
+
const shade = work_docx_run_formatting_import_normalizedByteHex(work_docx_run_formatting_import_wordAttribute(element, shadeName));
|
|
6947
7356
|
return {
|
|
6948
7357
|
theme,
|
|
6949
7358
|
resolved,
|
|
@@ -6955,27 +7364,35 @@ function work_docx_run_formatting_import_themeReference(element, themeName, tint
|
|
|
6955
7364
|
} : {}
|
|
6956
7365
|
};
|
|
6957
7366
|
}
|
|
6958
|
-
function
|
|
7367
|
+
function work_docx_run_formatting_import_normalizedByteHex(value) {
|
|
6959
7368
|
const normalized = value?.trim().toUpperCase();
|
|
6960
7369
|
return normalized && /^[0-9A-F]{2}$/.test(normalized) ? normalized : void 0;
|
|
6961
7370
|
}
|
|
6962
7371
|
function overriddenBoolean(current, next) {
|
|
6963
7372
|
return void 0 === next ? current : next;
|
|
6964
7373
|
}
|
|
7374
|
+
function overriddenValue(current, next) {
|
|
7375
|
+
return void 0 === next ? current : next;
|
|
7376
|
+
}
|
|
7377
|
+
function propertySourcesUseComplexScript(propertySources) {
|
|
7378
|
+
let complexScript;
|
|
7379
|
+
let rightToLeft;
|
|
7380
|
+
for (const properties of propertySources){
|
|
7381
|
+
complexScript = overriddenBoolean(complexScript, onOffProperty(properties, 'cs'));
|
|
7382
|
+
rightToLeft = overriddenBoolean(rightToLeft, onOffProperty(properties, 'rtl'));
|
|
7383
|
+
}
|
|
7384
|
+
return true === complexScript || true === rightToLeft;
|
|
7385
|
+
}
|
|
6965
7386
|
function onOffProperty(properties, propertyName) {
|
|
6966
7387
|
const element = directChild(properties, propertyName);
|
|
6967
7388
|
if (!element) return;
|
|
6968
7389
|
const value = work_docx_run_formatting_import_wordAttribute(element, 'val')?.trim().toLowerCase();
|
|
6969
7390
|
return '0' !== value && 'false' !== value && 'off' !== value;
|
|
6970
7391
|
}
|
|
6971
|
-
function underlineProperty(properties) {
|
|
7392
|
+
function underlineProperty(properties, theme) {
|
|
6972
7393
|
const element = directChild(properties, 'u');
|
|
6973
7394
|
if (!element) return;
|
|
6974
|
-
|
|
6975
|
-
return '0' !== value && 'false' !== value && 'off' !== value && 'none' !== value;
|
|
6976
|
-
}
|
|
6977
|
-
function directRunText(run) {
|
|
6978
|
-
return Array.from(run.children).filter((child)=>'t' === child.localName || 'delText' === child.localName).map((child)=>child.textContent ?? '').join('');
|
|
7395
|
+
return importedDocxUnderline(element, theme);
|
|
6979
7396
|
}
|
|
6980
7397
|
function work_docx_run_formatting_import_closestAncestor(element, localName) {
|
|
6981
7398
|
let current = element.parentElement;
|
|
@@ -6985,69 +7402,14 @@ function work_docx_run_formatting_import_closestAncestor(element, localName) {
|
|
|
6985
7402
|
}
|
|
6986
7403
|
return null;
|
|
6987
7404
|
}
|
|
6988
|
-
function
|
|
6989
|
-
const
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
if ('eastasia' === hint) return 'eastAsia';
|
|
6995
|
-
if ('cs' === hint) return 'complex';
|
|
6996
|
-
if ('default' === hint) return 'ascii';
|
|
6997
|
-
}
|
|
6998
|
-
function orderedFonts(fonts, preferred) {
|
|
6999
|
-
const order = {
|
|
7000
|
-
ascii: [
|
|
7001
|
-
'ascii',
|
|
7002
|
-
'hAnsi',
|
|
7003
|
-
'eastAsia',
|
|
7004
|
-
'complex'
|
|
7005
|
-
],
|
|
7006
|
-
hAnsi: [
|
|
7007
|
-
'hAnsi',
|
|
7008
|
-
'ascii',
|
|
7009
|
-
'eastAsia',
|
|
7010
|
-
'complex'
|
|
7011
|
-
],
|
|
7012
|
-
eastAsia: [
|
|
7013
|
-
'eastAsia',
|
|
7014
|
-
'hAnsi',
|
|
7015
|
-
'ascii',
|
|
7016
|
-
'complex'
|
|
7017
|
-
],
|
|
7018
|
-
complex: [
|
|
7019
|
-
'complex',
|
|
7020
|
-
'hAnsi',
|
|
7021
|
-
'ascii',
|
|
7022
|
-
'eastAsia'
|
|
7023
|
-
]
|
|
7405
|
+
function defaultThemeFontFamily(theme, preferred) {
|
|
7406
|
+
const fonts = {
|
|
7407
|
+
ascii: docxThemeFont(theme, 'minorAscii'),
|
|
7408
|
+
highAnsi: docxThemeFont(theme, 'minorHAnsi'),
|
|
7409
|
+
eastAsia: docxThemeFont(theme, 'minorEastAsia'),
|
|
7410
|
+
complexScript: docxThemeFont(theme, 'minorBidi')
|
|
7024
7411
|
};
|
|
7025
|
-
return
|
|
7026
|
-
}
|
|
7027
|
-
function docxFontSlotForText(text, hint) {
|
|
7028
|
-
for (const character of text){
|
|
7029
|
-
const codePoint = character.codePointAt(0);
|
|
7030
|
-
if (!(void 0 === codePoint || isNeutralCodePoint(codePoint))) {
|
|
7031
|
-
if (isComplexScriptCodePoint(codePoint)) return 'complex';
|
|
7032
|
-
if (isEastAsianCodePoint(codePoint)) return 'eastAsia';
|
|
7033
|
-
return codePoint <= 0x7f ? 'ascii' : 'hAnsi';
|
|
7034
|
-
}
|
|
7035
|
-
}
|
|
7036
|
-
return hint ?? 'ascii';
|
|
7037
|
-
}
|
|
7038
|
-
function isNeutralCodePoint(codePoint) {
|
|
7039
|
-
return codePoint <= 0x20 || codePoint <= 0x7f && !(codePoint >= 0x41 && codePoint <= 0x5a || codePoint >= 0x61 && codePoint <= 0x7a) || codePoint >= 0x300 && codePoint <= 0x36f || codePoint >= 0x2000 && codePoint <= 0x206f;
|
|
7040
|
-
}
|
|
7041
|
-
function isComplexScriptCodePoint(codePoint) {
|
|
7042
|
-
return codePoint >= 0x0590 && codePoint <= 0x08ff || codePoint >= 0xfb1d && codePoint <= 0xfdff || codePoint >= 0xfe70 && codePoint <= 0xfeff || codePoint >= 0x1ee00 && codePoint <= 0x1eeff;
|
|
7043
|
-
}
|
|
7044
|
-
function isEastAsianCodePoint(codePoint) {
|
|
7045
|
-
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;
|
|
7046
|
-
}
|
|
7047
|
-
function resolvedFont(element, explicitName, themeName, theme) {
|
|
7048
|
-
const explicit = work_docx_run_formatting_import_wordAttribute(element, explicitName);
|
|
7049
|
-
if (explicit?.trim()) return explicit;
|
|
7050
|
-
return docxThemeFont(theme, work_docx_run_formatting_import_wordAttribute(element, themeName)) ?? null;
|
|
7412
|
+
return uniqueFonts(documentScriptFontFallbackSlots(preferred).map((slot)=>fonts[slot]));
|
|
7051
7413
|
}
|
|
7052
7414
|
function uniqueFonts(values) {
|
|
7053
7415
|
const fonts = [
|
|
@@ -7096,4 +7458,4 @@ function work_docx_run_formatting_import_formatNumber(value) {
|
|
|
7096
7458
|
function formatLineHeightFactor(value) {
|
|
7097
7459
|
return Number(value.toFixed(4)).toString();
|
|
7098
7460
|
}
|
|
7099
|
-
export { applyImportedDocxEquationMarkers, applyImportedDocxParagraphAlignmentMarkers, applyImportedDocxParagraphBorderMarkers, applyImportedDocxParagraphDirectionMarkers, applyImportedDocxParagraphFormattingChangeMarkers, applyImportedDocxParagraphIndentMarkers, applyImportedDocxParagraphPaginationMarkers, applyImportedDocxParagraphShadingMarkers, applyImportedDocxParagraphSpacingMarkers, applyImportedDocxParagraphTabStopMarkers, applyImportedDocxRunFormattingMarkers, createDocxParagraphStyleResolver, createDocxTableStyleResolver, docxCaptionBookmark, docxCaptionReferenceTarget, docxCaptionSequenceKind, docxEquationHtml, docxFieldInstructions, docxFieldOccurrenceIsInlineEditable, docxFieldOccurrences, docxFieldResultText, docxTableCellStyleLayers, docxTablePropertySources, hasImportedDocxParagraphAlignmentMarkers, hasImportedDocxParagraphBorderMarkers, hasImportedDocxParagraphDirectionMarkers, hasImportedDocxParagraphFormattingChangeMarkers, hasImportedDocxParagraphIndentMarkers, hasImportedDocxParagraphPaginationMarkers, hasImportedDocxParagraphShadingMarkers, hasImportedDocxParagraphSpacingMarkers, hasImportedDocxParagraphTabStopMarkers, hasImportedDocxRunFormattingMarkers, hasInvalidDocxFieldStructure, inspectDocxEquation, inspectDocxPageBorders, inspectDocxPageMarginSettings, inspectDocxPageMargins, inspectDocxPageSize, inspectDocxPaperSource, isDocxEquationLikeRoot, isSupportedDocxEquationPlacement, isSupportedDocxParagraphFormattingChange, isSupportedDocxRunFormattingChange, markDocxPackageEquations, markDocxParagraphAlignments, markDocxParagraphBorders, markDocxParagraphDirections, markDocxParagraphFormattingChanges, markDocxParagraphIndents, markDocxParagraphPagination, markDocxParagraphShading, markDocxParagraphSpacing, markDocxParagraphTabStops,
|
|
7461
|
+
export { applyImportedDocxEquationMarkers, applyImportedDocxParagraphAlignmentMarkers, applyImportedDocxParagraphBorderMarkers, applyImportedDocxParagraphDirectionMarkers, applyImportedDocxParagraphFormattingChangeMarkers, applyImportedDocxParagraphIndentMarkers, applyImportedDocxParagraphPaginationMarkers, applyImportedDocxParagraphShadingMarkers, applyImportedDocxParagraphSpacingMarkers, applyImportedDocxParagraphTabStopMarkers, applyImportedDocxRunFormattingMarkers, createDocxParagraphStyleResolver, createDocxTableStyleResolver, createImportedDocxRunFormattingMarkerState, docxCaptionBookmark, docxCaptionReferenceTarget, docxCaptionSequenceKind, docxEquationHtml, docxFieldInstructions, docxFieldOccurrenceIsInlineEditable, docxFieldOccurrences, docxFieldResultText, docxRunPropertySources, docxTableCellStyleLayers, docxTablePropertySources, docxTableRunPropertySources, hasImportedDocxParagraphAlignmentMarkers, hasImportedDocxParagraphBorderMarkers, hasImportedDocxParagraphDirectionMarkers, hasImportedDocxParagraphFormattingChangeMarkers, hasImportedDocxParagraphIndentMarkers, hasImportedDocxParagraphPaginationMarkers, hasImportedDocxParagraphShadingMarkers, hasImportedDocxParagraphSpacingMarkers, hasImportedDocxParagraphTabStopMarkers, hasImportedDocxRunFormattingMarkers, hasInvalidDocxFieldStructure, importedDocxStrike, importedDocxUnderline, inspectDocxEquation, inspectDocxHiddenText, inspectDocxLegacyTextEffects, inspectDocxPageBorders, inspectDocxPageMarginSettings, inspectDocxPageMargins, inspectDocxPageSize, inspectDocxPaperSource, inspectDocxRunFonts, isDocxEquationLikeRoot, isSupportedDocxEquationPlacement, isSupportedDocxParagraphFormattingChange, isSupportedDocxRunFormattingChange, markDocxPackageEquations, markDocxParagraphAlignments, markDocxParagraphBorders, markDocxParagraphDirections, markDocxParagraphFormattingChanges, markDocxParagraphIndents, markDocxParagraphPagination, markDocxParagraphShading, markDocxParagraphSpacing, markDocxParagraphTabStops, markDocxRunFormattingIntoState, parseDirectDocxParagraphShading, parseDocxPageBorders, parseDocxPageGeometry, parseDocxPageMargins, parseDocxPaperSource, resolveDocxHiddenText, resolveDocxLegacyTextEffects, resolveDocxParagraphBordersForParagraph, resolveDocxTableStyleResolver };
|