@a3s-lab/office 0.29.0 → 0.30.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 +100 -3
- package/dist/{0~7043.js → 0~7231.js} +160 -2
- package/dist/{0~5093.js → 0~7360.js} +233 -52
- package/dist/0~document-editor.js +1159 -149
- package/dist/0~spreadsheet-editor.js +183 -34
- package/dist/0~work-docx-export.js +299 -11
- package/dist/0~work-docx-import.js +30 -7
- package/dist/0~work-office-diagnostics.js +125 -5
- package/dist/1544.js +13 -1
- package/dist/4104.js +29 -6
- package/dist/4121.js +1939 -1
- package/dist/6282.js +501 -1006
- package/dist/internal/features/work/editors/document-command-catalog.d.ts +18 -0
- package/dist/internal/features/work/editors/document-font-dialog-model.d.ts +5 -2
- package/dist/internal/features/work/editors/document-font-dialog-run-shading-model.d.ts +23 -0
- package/dist/internal/features/work/editors/document-font-dialog-run-shading-section.d.ts +8 -0
- package/dist/internal/features/work/editors/document-page-chrome-ribbon.d.ts +2 -1
- package/dist/internal/features/work/editors/document-proofing-dialog-model.d.ts +22 -0
- package/dist/internal/features/work/editors/document-proofing-dialog.d.ts +7 -0
- package/dist/internal/features/work/editors/document-table-of-contents-dialog.d.ts +10 -0
- package/dist/internal/features/work/editors/document-toolbar.d.ts +3 -1
- package/dist/internal/features/work/editors/spreadsheet-data-validation.d.ts +7 -1
- package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +2 -0
- package/dist/internal/features/work/work-document-character-formatting.d.ts +8 -0
- package/dist/internal/features/work/work-document-format-changes.d.ts +6 -0
- package/dist/internal/features/work/work-document-highlight.d.ts +9 -0
- package/dist/internal/features/work/work-document-outline.d.ts +1 -0
- package/dist/internal/features/work/work-document-paragraph-shading.d.ts +6 -0
- package/dist/internal/features/work/work-document-proofing.d.ts +19 -0
- package/dist/internal/features/work/work-document-run-shading.d.ts +12 -0
- package/dist/internal/features/work/work-document-table-of-contents-node.d.ts +18 -0
- package/dist/internal/features/work/work-document-table-of-contents.d.ts +51 -0
- package/dist/internal/features/work/work-document-word-line-metrics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-field-instructions.d.ts +1 -1
- package/dist/internal/features/work/work-docx-import.d.ts +3 -1
- package/dist/internal/features/work/work-docx-proofing-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-proofing.d.ts +38 -0
- package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +7 -0
- package/dist/internal/features/work/work-docx-run-shading-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-run-shading-export.d.ts +17 -0
- package/dist/internal/features/work/work-docx-run-shading.d.ts +20 -0
- package/dist/internal/features/work/work-docx-table-of-contents-export.d.ts +11 -0
- package/dist/internal/features/work/work-docx-table-of-contents-import.d.ts +15 -0
- package/dist/internal/features/work/work-spreadsheet-data-validation.d.ts +7 -0
- package/dist/internal/features/work/work-types.d.ts +9 -0
- package/dist/internal/kernel/office-kernel-protocol.d.ts +1 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/styles.css +311 -4
- package/docs/latest/en/browser-editor-architecture.md +50 -1
- package/package.json +12 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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~
|
|
3
|
-
import { normalizeDocumentEmphasisMark,
|
|
1
|
+
import { documentRunBorderDomAttributes, normalizeDocumentRunBorder, normalizeDocumentParagraphBorder, serializeDocumentRunBorder, serializeDocumentRunShading, documentScriptFontFallbackSlots, attribute as work_ooxml_package_attribute, documentScriptFontsDomAttributes, documentHighlightFromDocxValue, documentTableOfContentsHtml, directChildren as work_ooxml_package_directChildren, documentParagraphShadingDomAttributes, serializeDocxThemeReference, documentParagraphBordersDomAttributes, normalizeDocumentScriptFontHint, normalizeDocumentScriptFonts, DOCUMENT_PARAGRAPH_BORDER_STYLES, normalizeDocumentParagraphBorders as work_document_paragraph_borders_normalizeDocumentParagraphBorders, DOCUMENT_PARAGRAPH_BORDER_EDGES, documentScriptFontFamily, normalizeDocumentThemeFont, normalizeDocumentParagraphId, documentHighlightDomAttributes, descendants, documentHighlightCssColor, xmlNamespacePrefix, normalizeDocumentFontName, documentProofingDomAttributes, work_document_paragraph_shading_DOCUMENT_PARAGRAPH_SHADING_PATTERNS, directChild, documentScriptFontSegments, childPath, parseDocumentTableOfContentsInstruction, documentRunShadingDomAttributes } from "./4121.js";
|
|
2
|
+
import { docxThemeFont, XML_NAMESPACE as work_docx_settings_xml_XML_NAMESPACE, resolveDocxProofing, 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~7231.js";
|
|
3
|
+
import { normalizeDocumentEmphasisMark, normalizeDocumentPageBorders, documentCharacterPositionDomAttributes, DOCUMENT_PAGE_BORDER_EDGES, normalizeDocumentTabStops, documentTextCaseFromWordFlags, documentStrikeDomAttributes, documentAutoLineHeight, documentKerningDomAttributes, normalizeDocumentUnderlineColor, documentCharacterScaleDomAttributes, serializeDocumentParagraphFormatting, normalizeDocumentPaperSource, documentEquationText, documentLegacyTextEffectsDomAttributes, documentLegacyTextEffectsConflict, documentCharacterSpacingDomAttributes, normalizeDocumentParagraphIndent, normalizeDocumentEquation, renderDocumentAutoLineHeight, documentUnderlineDomAttributes, normalizeDocumentUnderlineStyle, applyDocumentTextCaseStyle, documentHiddenTextDomAttributes, importedDocumentCharacterFormatting, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, createDocumentEquationElement, normalizeDocumentPageGeometry, serializeDocumentTabStops, documentWordLineHeightFactor, documentEmphasisMarkDomAttributes, normalizeDocumentPageMargins } 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;
|
|
@@ -35,9 +35,9 @@ function docxFieldOccurrences(root) {
|
|
|
35
35
|
function docxFieldOccurrenceIsInlineEditable(field) {
|
|
36
36
|
return 'orphan' !== field.syntax && field.complete && !field.nested && !field.containsNested && field.sameParagraph && !field.inDeletion;
|
|
37
37
|
}
|
|
38
|
-
function hasInvalidDocxFieldStructure(root) {
|
|
38
|
+
function hasInvalidDocxFieldStructure(root, ignore = ()=>false) {
|
|
39
39
|
const parsed = parseDocxFields(root);
|
|
40
|
-
return parsed.hasUnmatchedEnd || parsed.hasUnclosedBegin || parsed.occurrences.some((field)
|
|
40
|
+
return parsed.hasUnmatchedEnd || parsed.hasUnclosedBegin || parsed.occurrences.some((field)=>!ignore(field) && ('orphan' !== field.syntax && (!field.complete || field.nested || field.containsNested || !field.sameParagraph || field.inDeletion) || 'orphan' === field.syntax && field.inDeletion));
|
|
41
41
|
}
|
|
42
42
|
function parseDocxFields(root) {
|
|
43
43
|
const elements = Array.from(root.querySelectorAll('*'));
|
|
@@ -4073,6 +4073,147 @@ function nextEquationMarker(state) {
|
|
|
4073
4073
|
state.occupiedText += marker;
|
|
4074
4074
|
return marker;
|
|
4075
4075
|
}
|
|
4076
|
+
const WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
4077
|
+
const work_docx_table_of_contents_import_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
4078
|
+
function markDocxTablesOfContents(document) {
|
|
4079
|
+
const tables = [];
|
|
4080
|
+
for (const element of descendants(document, 'sdt')){
|
|
4081
|
+
if (!document.documentElement.contains(element)) continue;
|
|
4082
|
+
const field = docxFieldOccurrences(element).find(supportedDocxTableOfContentsField);
|
|
4083
|
+
if (!field) continue;
|
|
4084
|
+
const parsed = parseDocumentTableOfContentsInstruction(field.instruction);
|
|
4085
|
+
if (!parsed.supported) continue;
|
|
4086
|
+
const tableIndex = tables.length + 1;
|
|
4087
|
+
const marker = {
|
|
4088
|
+
marker: `__A3S_WORK_TABLE_OF_CONTENTS_${tableIndex}__`,
|
|
4089
|
+
id: `docx-table-of-contents-${tableIndex}`,
|
|
4090
|
+
options: {
|
|
4091
|
+
...parsed.options,
|
|
4092
|
+
leader: importedTableOfContentsLeader(element, parsed.options)
|
|
4093
|
+
},
|
|
4094
|
+
entries: importedTableOfContentsEntries(element, tableIndex)
|
|
4095
|
+
};
|
|
4096
|
+
element.replaceWith(markerParagraph(document, marker.marker));
|
|
4097
|
+
tables.push(marker);
|
|
4098
|
+
}
|
|
4099
|
+
return {
|
|
4100
|
+
tables
|
|
4101
|
+
};
|
|
4102
|
+
}
|
|
4103
|
+
function applyImportedDocxTableOfContentsMarkers(document, markers) {
|
|
4104
|
+
const headings = importedHtmlHeadings(document);
|
|
4105
|
+
for (const table of markers.tables){
|
|
4106
|
+
const usedHeadingIndexes = new Set();
|
|
4107
|
+
const text = textNodes(document.body).find((node)=>node.data.includes(table.marker));
|
|
4108
|
+
if (!text) continue;
|
|
4109
|
+
const entries = table.entries.map((entry)=>{
|
|
4110
|
+
const headingIndex = headings.findIndex((heading, index)=>!usedHeadingIndexes.has(index) && heading.level === entry.level && normalizedTitle(heading.title) === normalizedTitle(entry.title));
|
|
4111
|
+
if (headingIndex < 0) return entry;
|
|
4112
|
+
usedHeadingIndexes.add(headingIndex);
|
|
4113
|
+
const heading = headings[headingIndex];
|
|
4114
|
+
return heading ? {
|
|
4115
|
+
...entry,
|
|
4116
|
+
targetId: heading.targetId
|
|
4117
|
+
} : entry;
|
|
4118
|
+
});
|
|
4119
|
+
const fragment = document.createRange().createContextualFragment(documentTableOfContentsHtml({
|
|
4120
|
+
id: table.id,
|
|
4121
|
+
options: table.options,
|
|
4122
|
+
entries
|
|
4123
|
+
}));
|
|
4124
|
+
const block = closestHtmlBlock(text.parentElement);
|
|
4125
|
+
if (block) block.replaceWith(fragment);
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
function hasImportedDocxTableOfContentsMarkers(markers) {
|
|
4129
|
+
return markers.tables.length > 0;
|
|
4130
|
+
}
|
|
4131
|
+
function supportedDocxTableOfContentsField(field) {
|
|
4132
|
+
const parsed = parseDocumentTableOfContentsInstruction(field.instruction);
|
|
4133
|
+
return parsed.supported && field.complete && !field.nested && !field.inDeletion && Boolean(work_docx_table_of_contents_import_closestAncestor(field.start, 'sdt'));
|
|
4134
|
+
}
|
|
4135
|
+
function importedTableOfContentsEntries(element, tableIndex) {
|
|
4136
|
+
const paragraphs = descendants(element, 'p');
|
|
4137
|
+
return paragraphs.flatMap((paragraph, index)=>{
|
|
4138
|
+
const style = directChild(directChild(paragraph, 'pPr') ?? paragraph, 'pStyle');
|
|
4139
|
+
const level = Number(/^TOC([1-9])$/i.exec(work_ooxml_package_attribute(style ?? paragraph, 'val') ?? '')?.[1]);
|
|
4140
|
+
if (!level) return [];
|
|
4141
|
+
const values = descendants(paragraph, 't').map((text)=>text.textContent ?? '').filter(Boolean);
|
|
4142
|
+
const last = values.at(-1)?.trim() ?? '';
|
|
4143
|
+
const hasPageNumber = /^\d{1,6}$/.test(last);
|
|
4144
|
+
const title = (hasPageNumber ? values.slice(0, -1) : values).join('').replace(/\s+/g, ' ').trim();
|
|
4145
|
+
if (!title) return [];
|
|
4146
|
+
const hyperlink = descendants(paragraph, 'hyperlink').find((candidate)=>Boolean(work_ooxml_package_attribute(candidate, 'anchor')));
|
|
4147
|
+
const anchor = work_ooxml_package_attribute(hyperlink ?? paragraph, 'anchor')?.trim();
|
|
4148
|
+
const targetId = /^heading-[a-z0-9._:-]{1,128}$/i.test(anchor ?? '') ? anchor : `heading-import-${tableIndex}-${index + 1}`;
|
|
4149
|
+
return [
|
|
4150
|
+
{
|
|
4151
|
+
targetId,
|
|
4152
|
+
title,
|
|
4153
|
+
level,
|
|
4154
|
+
pageNumber: hasPageNumber ? Number(last) : 1
|
|
4155
|
+
}
|
|
4156
|
+
];
|
|
4157
|
+
});
|
|
4158
|
+
}
|
|
4159
|
+
function importedTableOfContentsLeader(element, options) {
|
|
4160
|
+
if (!options.showPageNumbers || !options.rightAlignPageNumbers) return 'none';
|
|
4161
|
+
const tab = descendants(element, 'tab').find((candidate)=>candidate.parentElement?.localName === 'tabs' && 'right' === work_ooxml_package_attribute(candidate, 'val'));
|
|
4162
|
+
const leader = work_ooxml_package_attribute(tab ?? element, 'leader');
|
|
4163
|
+
if ('hyphen' === leader) return 'dash';
|
|
4164
|
+
if ('underscore' === leader) return 'underline';
|
|
4165
|
+
if (!leader || 'none' === leader) return 'none';
|
|
4166
|
+
return 'dot';
|
|
4167
|
+
}
|
|
4168
|
+
function markerParagraph(document, marker) {
|
|
4169
|
+
const paragraph = document.createElementNS(WORD_NAMESPACE, 'w:p');
|
|
4170
|
+
const run = document.createElementNS(WORD_NAMESPACE, 'w:r');
|
|
4171
|
+
const text = document.createElementNS(WORD_NAMESPACE, 'w:t');
|
|
4172
|
+
text.setAttributeNS(work_docx_table_of_contents_import_XML_NAMESPACE, 'xml:space', 'preserve');
|
|
4173
|
+
text.textContent = marker;
|
|
4174
|
+
run.append(text);
|
|
4175
|
+
paragraph.append(run);
|
|
4176
|
+
return paragraph;
|
|
4177
|
+
}
|
|
4178
|
+
function importedHtmlHeadings(document) {
|
|
4179
|
+
return Array.from(document.body.querySelectorAll('h1,h2,h3,h4,h5,h6,p[data-office-outline-level]')).flatMap((heading, index)=>{
|
|
4180
|
+
const headingLevel = /^H([1-6])$/.exec(heading.tagName)?.[1];
|
|
4181
|
+
const outlineLevel = Number(heading.dataset.officeOutlineLevel);
|
|
4182
|
+
const level = headingLevel ? Number(headingLevel) : Number.isInteger(outlineLevel) && outlineLevel >= 0 && outlineLevel <= 8 ? outlineLevel + 1 : null;
|
|
4183
|
+
if (null === level) return [];
|
|
4184
|
+
const identity = normalizeDocumentParagraphId(heading.dataset.officeParagraphId);
|
|
4185
|
+
return [
|
|
4186
|
+
{
|
|
4187
|
+
title: heading.textContent ?? '',
|
|
4188
|
+
level,
|
|
4189
|
+
targetId: identity ? `heading-${identity.toLowerCase()}` : `heading-imported-${index + 1}`
|
|
4190
|
+
}
|
|
4191
|
+
];
|
|
4192
|
+
});
|
|
4193
|
+
}
|
|
4194
|
+
function textNodes(root) {
|
|
4195
|
+
const walker = root.ownerDocument?.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
4196
|
+
const nodes = [];
|
|
4197
|
+
if (!walker) return nodes;
|
|
4198
|
+
while(walker.nextNode())nodes.push(walker.currentNode);
|
|
4199
|
+
return nodes;
|
|
4200
|
+
}
|
|
4201
|
+
function closestHtmlBlock(element) {
|
|
4202
|
+
let current = element;
|
|
4203
|
+
while(current && current.parentElement?.tagName.toLowerCase() !== 'body')current = current.parentElement;
|
|
4204
|
+
return current;
|
|
4205
|
+
}
|
|
4206
|
+
function work_docx_table_of_contents_import_closestAncestor(element, localName) {
|
|
4207
|
+
let current = element;
|
|
4208
|
+
while(current){
|
|
4209
|
+
if (current.localName === localName) return current;
|
|
4210
|
+
current = current.parentElement;
|
|
4211
|
+
}
|
|
4212
|
+
return null;
|
|
4213
|
+
}
|
|
4214
|
+
function normalizedTitle(value) {
|
|
4215
|
+
return value.normalize('NFKC').replace(/\s+/g, ' ').trim().toLocaleLowerCase();
|
|
4216
|
+
}
|
|
4076
4217
|
const ON_VALUES = new Set([
|
|
4077
4218
|
'1',
|
|
4078
4219
|
'on',
|
|
@@ -4530,7 +4671,7 @@ function onOffValue(value) {
|
|
|
4530
4671
|
function work_docx_table_styles_wordAttribute(element, name) {
|
|
4531
4672
|
return work_ooxml_package_attribute(element, name) ?? work_ooxml_package_attribute(element, `w:${name}`);
|
|
4532
4673
|
}
|
|
4533
|
-
const
|
|
4674
|
+
const work_docx_paragraph_borders_import_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
4534
4675
|
const work_docx_paragraph_borders_import_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
4535
4676
|
const XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/';
|
|
4536
4677
|
const PARAGRAPH_BORDER_MARKER_PATTERN = /__A3S_WORK_PARAGRAPH_BORDER_\d+__/g;
|
|
@@ -4622,7 +4763,7 @@ function applyImportedDocxParagraphBorderMarkers(document, markers) {
|
|
|
4622
4763
|
marker,
|
|
4623
4764
|
borders
|
|
4624
4765
|
]));
|
|
4625
|
-
for (const node of
|
|
4766
|
+
for (const node of work_docx_paragraph_borders_import_textNodes(document.body))if (node.data.includes('__A3S_WORK_PARAGRAPH_BORDER_')) node.data = node.data.replace(PARAGRAPH_BORDER_MARKER_PATTERN, (marker)=>{
|
|
4626
4767
|
const borders = bordersByMarker.get(marker);
|
|
4627
4768
|
const block = borders ? closestParagraphBlock(node.parentElement, node) : null;
|
|
4628
4769
|
if (block && borders) applyParagraphBorders(block, borders);
|
|
@@ -4837,7 +4978,7 @@ function applyParagraphBorders(element, borders) {
|
|
|
4837
4978
|
}
|
|
4838
4979
|
}
|
|
4839
4980
|
function insertParagraphMarker(document, paragraph, properties, marker) {
|
|
4840
|
-
const namespace = paragraph.namespaceURI ??
|
|
4981
|
+
const namespace = paragraph.namespaceURI ?? work_docx_paragraph_borders_import_WORD_NAMESPACE;
|
|
4841
4982
|
const prefix = paragraph.prefix ?? 'w';
|
|
4842
4983
|
const run = document.createElementNS(namespace, `${prefix}:r`);
|
|
4843
4984
|
const text = document.createElementNS(namespace, `${prefix}:t`);
|
|
@@ -4847,7 +4988,7 @@ function insertParagraphMarker(document, paragraph, properties, marker) {
|
|
|
4847
4988
|
paragraph.insertBefore(run, properties.nextSibling);
|
|
4848
4989
|
}
|
|
4849
4990
|
function insertParagraphProperties(document, paragraph) {
|
|
4850
|
-
const namespace = paragraph.namespaceURI ??
|
|
4991
|
+
const namespace = paragraph.namespaceURI ?? work_docx_paragraph_borders_import_WORD_NAMESPACE;
|
|
4851
4992
|
const prefix = paragraph.prefix ?? 'w';
|
|
4852
4993
|
const properties = document.createElementNS(namespace, `${prefix}:pPr`);
|
|
4853
4994
|
paragraph.insertBefore(properties, paragraph.firstChild);
|
|
@@ -4899,7 +5040,7 @@ function isListItemBlock(node) {
|
|
|
4899
5040
|
'ul'
|
|
4900
5041
|
].includes(node.tagName.toLowerCase());
|
|
4901
5042
|
}
|
|
4902
|
-
function
|
|
5043
|
+
function work_docx_paragraph_borders_import_textNodes(root) {
|
|
4903
5044
|
const document = root.ownerDocument;
|
|
4904
5045
|
const walker = document?.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
4905
5046
|
const nodes = [];
|
|
@@ -5040,7 +5181,7 @@ function hasImportedDocxParagraphShadingMarkers(markers) {
|
|
|
5040
5181
|
function parseDocxParagraphShadingElement(element, themeSource) {
|
|
5041
5182
|
const attributes = work_docx_paragraph_shading_import_wordLeafAttributes(element, SHADING_ATTRIBUTES);
|
|
5042
5183
|
const pattern = attributes?.get('val')?.trim();
|
|
5043
|
-
if (!attributes || !
|
|
5184
|
+
if (!attributes || !work_document_paragraph_shading_DOCUMENT_PARAGRAPH_SHADING_PATTERNS.has(pattern)) return null;
|
|
5044
5185
|
const theme = work_docx_theme_resolveDocxThemeResolver(themeSource);
|
|
5045
5186
|
const color = parseShadingColor(attributes, theme, {
|
|
5046
5187
|
value: 'color',
|
|
@@ -5249,6 +5390,57 @@ function work_docx_paragraph_shading_import_textNodes(root) {
|
|
|
5249
5390
|
while(walker.nextNode())nodes.push(walker.currentNode);
|
|
5250
5391
|
return nodes;
|
|
5251
5392
|
}
|
|
5393
|
+
function inspectDocxRunShading(properties, themeSource) {
|
|
5394
|
+
return inspectDocxRunShadingWithTheme(properties, work_docx_theme_resolveDocxThemeResolver(themeSource));
|
|
5395
|
+
}
|
|
5396
|
+
function resolveDocxRunShading(propertySources, themeSource) {
|
|
5397
|
+
const theme = work_docx_theme_resolveDocxThemeResolver(themeSource);
|
|
5398
|
+
let shading;
|
|
5399
|
+
let invalidCount = 0;
|
|
5400
|
+
let spoofedCount = 0;
|
|
5401
|
+
for (const properties of propertySources){
|
|
5402
|
+
const inspection = inspectDocxRunShadingWithTheme(properties, theme);
|
|
5403
|
+
spoofedCount += inspection.spoofedCount;
|
|
5404
|
+
if ('valid' === inspection.status) shading = inspection.value;
|
|
5405
|
+
else if ('invalid' === inspection.status) {
|
|
5406
|
+
invalidCount += 1;
|
|
5407
|
+
shading = {
|
|
5408
|
+
pattern: 'nil'
|
|
5409
|
+
};
|
|
5410
|
+
}
|
|
5411
|
+
}
|
|
5412
|
+
return {
|
|
5413
|
+
shading,
|
|
5414
|
+
invalidCount,
|
|
5415
|
+
spoofedCount
|
|
5416
|
+
};
|
|
5417
|
+
}
|
|
5418
|
+
function inspectDocxRunShadingWithTheme(properties, theme) {
|
|
5419
|
+
if (!properties) return {
|
|
5420
|
+
status: 'absent',
|
|
5421
|
+
spoofedCount: 0
|
|
5422
|
+
};
|
|
5423
|
+
const matches = work_ooxml_package_directChildren(properties, 'shd');
|
|
5424
|
+
if (!matches.length) return {
|
|
5425
|
+
status: 'absent',
|
|
5426
|
+
spoofedCount: 0
|
|
5427
|
+
};
|
|
5428
|
+
const native = matches.filter((element)=>element.namespaceURI === properties.namespaceURI && DOCX_WORDPROCESSING_NAMESPACES.has(element.namespaceURI ?? ''));
|
|
5429
|
+
const spoofedCount = matches.length - native.length;
|
|
5430
|
+
if (1 !== matches.length || 1 !== native.length) return {
|
|
5431
|
+
status: 'invalid',
|
|
5432
|
+
spoofedCount
|
|
5433
|
+
};
|
|
5434
|
+
const parsed = parseDocxParagraphShadingElement(native[0], theme);
|
|
5435
|
+
return parsed ? {
|
|
5436
|
+
status: 'valid',
|
|
5437
|
+
value: parsed,
|
|
5438
|
+
spoofedCount
|
|
5439
|
+
} : {
|
|
5440
|
+
status: 'invalid',
|
|
5441
|
+
spoofedCount
|
|
5442
|
+
};
|
|
5443
|
+
}
|
|
5252
5444
|
function importedDocxUnderline(element, theme) {
|
|
5253
5445
|
const rawStyle = work_ooxml_package_attribute(element, 'val');
|
|
5254
5446
|
const style = null === rawStyle ? 'single' : normalizeDocumentUnderlineStyle(rawStyle) ?? 'single';
|
|
@@ -6926,6 +7118,7 @@ const SUPPORTED_RUN_PROPERTY_CHANGE_CHILDREN = new Set([
|
|
|
6926
7118
|
'shadow',
|
|
6927
7119
|
'emboss',
|
|
6928
7120
|
'imprint',
|
|
7121
|
+
'noProof',
|
|
6929
7122
|
'caps',
|
|
6930
7123
|
'smallCaps',
|
|
6931
7124
|
'vanish',
|
|
@@ -6943,6 +7136,7 @@ const SUPPORTED_RUN_PROPERTY_CHANGE_CHILDREN = new Set([
|
|
|
6943
7136
|
'cs',
|
|
6944
7137
|
'rtl',
|
|
6945
7138
|
'em',
|
|
7139
|
+
'lang',
|
|
6946
7140
|
'vertAlign',
|
|
6947
7141
|
'bdr'
|
|
6948
7142
|
]);
|
|
@@ -7026,6 +7220,7 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
|
|
|
7026
7220
|
let complexFontSize;
|
|
7027
7221
|
let color;
|
|
7028
7222
|
let backgroundColor;
|
|
7223
|
+
let highlightValue;
|
|
7029
7224
|
let themeColor;
|
|
7030
7225
|
let themeFill;
|
|
7031
7226
|
let bold;
|
|
@@ -7050,6 +7245,8 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
|
|
|
7050
7245
|
const hiddenText = resolveDocxHiddenText(propertySources);
|
|
7051
7246
|
const legacyTextEffects = resolveDocxLegacyTextEffects(propertySources);
|
|
7052
7247
|
const runBorder = resolveDocxRunBorder(propertySources, theme).border;
|
|
7248
|
+
const runShading = resolveDocxRunShading(propertySources, theme).shading;
|
|
7249
|
+
const proofing = resolveDocxProofing(propertySources);
|
|
7053
7250
|
for (const properties of propertySources){
|
|
7054
7251
|
bold = overriddenBoolean(bold, onOffProperty(properties, 'b'));
|
|
7055
7252
|
complexBold = overriddenBoolean(complexBold, onOffProperty(properties, 'bCs'));
|
|
@@ -7098,23 +7295,10 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
|
|
|
7098
7295
|
}
|
|
7099
7296
|
const highlight = directChild(properties, 'highlight');
|
|
7100
7297
|
if (highlight) {
|
|
7101
|
-
const value = work_docx_run_formatting_import_wordAttribute(highlight, 'val')
|
|
7298
|
+
const value = documentHighlightFromDocxValue(work_docx_run_formatting_import_wordAttribute(highlight, 'val'));
|
|
7102
7299
|
if (value) {
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
}
|
|
7106
|
-
} else {
|
|
7107
|
-
const shading = directChild(properties, 'shd');
|
|
7108
|
-
const fill = shading ? work_docx_run_formatting_import_wordAttribute(shading, 'fill')?.trim() : void 0;
|
|
7109
|
-
const themed = shading ? docxThemeColor(theme, work_docx_run_formatting_import_wordAttribute(shading, 'themeFill'), work_docx_run_formatting_import_wordAttribute(shading, 'themeFillTint'), work_docx_run_formatting_import_wordAttribute(shading, 'themeFillShade')) : void 0;
|
|
7110
|
-
if (themed) {
|
|
7111
|
-
backgroundColor = `#${themed}`;
|
|
7112
|
-
themeFill = work_docx_run_formatting_import_themeReference(shading, 'themeFill', 'themeFillTint', 'themeFillShade', backgroundColor);
|
|
7113
|
-
} else if (fill?.toLowerCase() === 'auto') {
|
|
7114
|
-
backgroundColor = 'transparent';
|
|
7115
|
-
themeFill = void 0;
|
|
7116
|
-
} else if (fill && /^[0-9a-f]{6}$/i.test(fill)) {
|
|
7117
|
-
backgroundColor = `#${fill.toLowerCase()}`;
|
|
7300
|
+
highlightValue = value;
|
|
7301
|
+
backgroundColor = documentHighlightCssColor(value) ?? 'transparent';
|
|
7118
7302
|
themeFill = void 0;
|
|
7119
7303
|
}
|
|
7120
7304
|
}
|
|
@@ -7199,6 +7383,9 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
|
|
|
7199
7383
|
...backgroundColor ? {
|
|
7200
7384
|
backgroundColor
|
|
7201
7385
|
} : {},
|
|
7386
|
+
...highlightValue ? {
|
|
7387
|
+
highlight: highlightValue
|
|
7388
|
+
} : {},
|
|
7202
7389
|
...themeColor ? {
|
|
7203
7390
|
themeColor
|
|
7204
7391
|
} : {},
|
|
@@ -7210,6 +7397,15 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
|
|
|
7210
7397
|
} : {},
|
|
7211
7398
|
...runBorder ? {
|
|
7212
7399
|
runBorder
|
|
7400
|
+
} : {},
|
|
7401
|
+
...runShading ? {
|
|
7402
|
+
runShading
|
|
7403
|
+
} : {},
|
|
7404
|
+
...proofing.languages ? {
|
|
7405
|
+
proofingLanguages: proofing.languages
|
|
7406
|
+
} : {},
|
|
7407
|
+
...void 0 !== proofing.noProof ? {
|
|
7408
|
+
noProof: proofing.noProof
|
|
7213
7409
|
} : {}
|
|
7214
7410
|
};
|
|
7215
7411
|
}
|
|
@@ -7248,6 +7444,9 @@ function formattingMarkup(document, formatting) {
|
|
|
7248
7444
|
if (void 0 !== formatting.hiddenText) for (const [name, value] of Object.entries(documentHiddenTextDomAttributes(formatting.hiddenText)))span.setAttribute(name, value);
|
|
7249
7445
|
if (formatting.runBorder) for (const [name, value] of Object.entries(documentRunBorderDomAttributes(formatting.runBorder)))if ('style' === name) span.style.cssText += `; ${value}`;
|
|
7250
7446
|
else span.setAttribute(name, value);
|
|
7447
|
+
if (formatting.runShading) for (const [name, value] of Object.entries(documentRunShadingDomAttributes(formatting.runShading)))if ('style' === name) span.style.cssText += `; ${value}`;
|
|
7448
|
+
else span.setAttribute(name, value);
|
|
7449
|
+
if (void 0 !== formatting.proofingLanguages || void 0 !== formatting.noProof) for (const [name, value] of Object.entries(documentProofingDomAttributes(formatting.proofingLanguages, formatting.noProof, formatting.scriptFontSlot)))span.setAttribute(name, value);
|
|
7251
7450
|
const legacyTextEffects = {
|
|
7252
7451
|
...void 0 !== formatting.legacyTextOutline ? {
|
|
7253
7452
|
outline: formatting.legacyTextOutline
|
|
@@ -7273,7 +7472,9 @@ function formattingMarkup(document, formatting) {
|
|
|
7273
7472
|
if (formatting.color) span.style.color = formatting.color;
|
|
7274
7473
|
const themeColor = serializeDocxThemeReference(formatting.themeColor ?? null);
|
|
7275
7474
|
if (themeColor) span.dataset.officeThemeColor = themeColor;
|
|
7276
|
-
if (formatting.
|
|
7475
|
+
if (formatting.highlight) for (const [name, value] of Object.entries(documentHighlightDomAttributes(formatting.highlight)))if ('style' === name) span.style.cssText += `; ${value}`;
|
|
7476
|
+
else span.setAttribute(name, value);
|
|
7477
|
+
else if (formatting.backgroundColor) span.style.backgroundColor = formatting.backgroundColor;
|
|
7277
7478
|
const themeFill = serializeDocxThemeReference(formatting.themeFill ?? null);
|
|
7278
7479
|
if (themeFill) span.dataset.officeThemeFill = themeFill;
|
|
7279
7480
|
if (formatting.textCase) applyDocumentTextCaseStyle(span, formatting.textCase);
|
|
@@ -7354,7 +7555,9 @@ function importedRunFormattingChange(runProperties, paragraphProperties, styles,
|
|
|
7354
7555
|
legacyTextShadow: beforeFormatting.legacyTextShadow,
|
|
7355
7556
|
legacyTextEmboss: beforeFormatting.legacyTextEmboss,
|
|
7356
7557
|
legacyTextImprint: beforeFormatting.legacyTextImprint,
|
|
7357
|
-
runBorder: serializeDocumentRunBorder(beforeFormatting.runBorder)
|
|
7558
|
+
runBorder: serializeDocumentRunBorder(beforeFormatting.runBorder),
|
|
7559
|
+
runShading: serializeDocumentRunShading(beforeFormatting.runShading),
|
|
7560
|
+
highlight: beforeFormatting.highlight
|
|
7358
7561
|
})
|
|
7359
7562
|
};
|
|
7360
7563
|
}
|
|
@@ -7489,32 +7692,10 @@ function work_docx_run_formatting_import_numericAttribute(element, name) {
|
|
|
7489
7692
|
function work_docx_run_formatting_import_wordAttribute(element, name) {
|
|
7490
7693
|
return work_ooxml_package_attribute(element, name) ?? work_ooxml_package_attribute(element, `w:${name}`);
|
|
7491
7694
|
}
|
|
7492
|
-
function wordHighlightColor(value) {
|
|
7493
|
-
const colors = {
|
|
7494
|
-
black: '#000000',
|
|
7495
|
-
blue: '#0000ff',
|
|
7496
|
-
cyan: '#00ffff',
|
|
7497
|
-
darkblue: '#000080',
|
|
7498
|
-
darkcyan: '#008080',
|
|
7499
|
-
darkgray: '#808080',
|
|
7500
|
-
darkgreen: '#008000',
|
|
7501
|
-
darkmagenta: '#800080',
|
|
7502
|
-
darkred: '#800000',
|
|
7503
|
-
darkyellow: '#808000',
|
|
7504
|
-
green: '#00ff00',
|
|
7505
|
-
lightgray: '#c0c0c0',
|
|
7506
|
-
magenta: '#ff00ff',
|
|
7507
|
-
none: 'transparent',
|
|
7508
|
-
red: '#ff0000',
|
|
7509
|
-
white: '#ffffff',
|
|
7510
|
-
yellow: '#ffff00'
|
|
7511
|
-
};
|
|
7512
|
-
return colors[value] ?? 'transparent';
|
|
7513
|
-
}
|
|
7514
7695
|
function work_docx_run_formatting_import_formatNumber(value) {
|
|
7515
7696
|
return Number(value.toFixed(2)).toString();
|
|
7516
7697
|
}
|
|
7517
7698
|
function formatLineHeightFactor(value) {
|
|
7518
7699
|
return Number(value.toFixed(4)).toString();
|
|
7519
7700
|
}
|
|
7520
|
-
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, inspectDocxRunBorder, inspectDocxRunFonts, isDocxEquationLikeRoot, isSupportedDocxEquationPlacement, isSupportedDocxParagraphFormattingChange, isSupportedDocxRunFormattingChange, markDocxPackageEquations, markDocxParagraphAlignments, markDocxParagraphBorders, markDocxParagraphDirections, markDocxParagraphFormattingChanges, markDocxParagraphIndents, markDocxParagraphPagination, markDocxParagraphShading, markDocxParagraphSpacing, markDocxParagraphTabStops, markDocxRunFormattingIntoState, parseDirectDocxParagraphShading, parseDocxPageBorders, parseDocxPageGeometry, parseDocxPageMargins, parseDocxPaperSource, resolveDocxHiddenText, resolveDocxLegacyTextEffects, resolveDocxParagraphBordersForParagraph, resolveDocxRunBorder, resolveDocxTableStyleResolver };
|
|
7701
|
+
export { applyImportedDocxEquationMarkers, applyImportedDocxParagraphAlignmentMarkers, applyImportedDocxParagraphBorderMarkers, applyImportedDocxParagraphDirectionMarkers, applyImportedDocxParagraphFormattingChangeMarkers, applyImportedDocxParagraphIndentMarkers, applyImportedDocxParagraphPaginationMarkers, applyImportedDocxParagraphShadingMarkers, applyImportedDocxParagraphSpacingMarkers, applyImportedDocxParagraphTabStopMarkers, applyImportedDocxRunFormattingMarkers, applyImportedDocxTableOfContentsMarkers, 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, hasImportedDocxTableOfContentsMarkers, hasInvalidDocxFieldStructure, importedDocxStrike, importedDocxUnderline, inspectDocxEquation, inspectDocxHiddenText, inspectDocxLegacyTextEffects, inspectDocxPageBorders, inspectDocxPageMarginSettings, inspectDocxPageMargins, inspectDocxPageSize, inspectDocxPaperSource, inspectDocxRunBorder, inspectDocxRunFonts, inspectDocxRunShading, isDocxEquationLikeRoot, isSupportedDocxEquationPlacement, isSupportedDocxParagraphFormattingChange, isSupportedDocxRunFormattingChange, markDocxPackageEquations, markDocxParagraphAlignments, markDocxParagraphBorders, markDocxParagraphDirections, markDocxParagraphFormattingChanges, markDocxParagraphIndents, markDocxParagraphPagination, markDocxParagraphShading, markDocxParagraphSpacing, markDocxParagraphTabStops, markDocxRunFormattingIntoState, markDocxTablesOfContents, parseDirectDocxParagraphShading, parseDocxPageBorders, parseDocxPageGeometry, parseDocxPageMargins, parseDocxPaperSource, resolveDocxHiddenText, resolveDocxLegacyTextEffects, resolveDocxParagraphBordersForParagraph, resolveDocxRunBorder, resolveDocxRunShading, resolveDocxTableStyleResolver, supportedDocxTableOfContentsField };
|