@a3s-lab/office 0.29.0 → 0.31.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 +117 -3
- package/dist/{0~7043.js → 0~4808.js} +347 -2
- package/dist/0~5050.js +10 -1
- package/dist/{0~5093.js → 0~7240.js} +465 -55
- package/dist/0~document-editor.js +1694 -187
- package/dist/0~spreadsheet-editor.js +183 -34
- package/dist/0~work-docx-export.js +507 -31
- package/dist/0~work-docx-import.js +41 -7
- package/dist/0~work-office-diagnostics.js +146 -5
- package/dist/1544.js +13 -1
- package/dist/4104.js +29 -6
- package/dist/4121.js +2340 -1
- package/dist/6282.js +1072 -1148
- package/dist/internal/features/work/editors/document-command-catalog.d.ts +45 -0
- package/dist/internal/features/work/editors/document-dom-selection.d.ts +7 -0
- package/dist/internal/features/work/editors/document-editor-support.d.ts +1 -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-index-dialog.d.ts +10 -0
- package/dist/internal/features/work/editors/document-index-entry-dialog.d.ts +10 -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-references-ribbon.d.ts +19 -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 +6 -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 +5 -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-index-fields.d.ts +19 -0
- package/dist/internal/features/work/work-document-index-nodes.d.ts +32 -0
- package/dist/internal/features/work/work-document-index.d.ts +63 -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 +5 -1
- package/dist/internal/features/work/work-docx-index-export.d.ts +14 -0
- package/dist/internal/features/work/work-docx-index-import.d.ts +23 -0
- 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 +607 -4
- package/docs/latest/en/browser-editor-architecture.md +64 -1
- package/package.json +15 -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, documentIndexEntryHtml, attribute as work_ooxml_package_attribute, documentScriptFontFallbackSlots, 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, documentIndexHtml, 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, parseDocumentIndexEntryInstruction, resolveDocxProofing, parseDocumentIndexInstruction, 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~4808.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,376 @@ 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_index_import_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
4078
|
+
function markDocxIndexes(document) {
|
|
4079
|
+
const fields = docxFieldOccurrences(document);
|
|
4080
|
+
const entries = fields.flatMap((field, index)=>{
|
|
4081
|
+
const parsed = parseDocumentIndexEntryInstruction(field.instruction);
|
|
4082
|
+
if (!parsed.supported || !docxFieldOccurrenceIsInlineEditable(field)) return [];
|
|
4083
|
+
const marker = {
|
|
4084
|
+
start: `__A3S_WORK_INDEX_ENTRY_START_${index + 1}__`,
|
|
4085
|
+
end: `__A3S_WORK_INDEX_ENTRY_END_${index + 1}__`,
|
|
4086
|
+
id: `index-entry-import-${index + 1}`,
|
|
4087
|
+
value: parsed.value
|
|
4088
|
+
};
|
|
4089
|
+
insertFieldBoundaryMarkers(document, field, marker.start, marker.end);
|
|
4090
|
+
return [
|
|
4091
|
+
marker
|
|
4092
|
+
];
|
|
4093
|
+
});
|
|
4094
|
+
const indexes = [];
|
|
4095
|
+
for (const field of fields){
|
|
4096
|
+
if (!supportedDocxIndexField(field)) continue;
|
|
4097
|
+
const parsed = parseDocumentIndexInstruction(field.instruction);
|
|
4098
|
+
if (!parsed.supported) continue;
|
|
4099
|
+
const control = work_docx_index_import_closestAncestor(field.start, 'sdt');
|
|
4100
|
+
if (!control || !document.documentElement.contains(control)) continue;
|
|
4101
|
+
const index = indexes.length + 1;
|
|
4102
|
+
const marker = {
|
|
4103
|
+
marker: `__A3S_WORK_DOCUMENT_INDEX_${index}__`,
|
|
4104
|
+
id: `document-index-import-${index}`,
|
|
4105
|
+
options: {
|
|
4106
|
+
...parsed.options,
|
|
4107
|
+
leader: importedIndexLeader(control, parsed.options)
|
|
4108
|
+
},
|
|
4109
|
+
entries: importedIndexEntries(control, index)
|
|
4110
|
+
};
|
|
4111
|
+
control.replaceWith(markerParagraph(document, marker.marker));
|
|
4112
|
+
indexes.push(marker);
|
|
4113
|
+
}
|
|
4114
|
+
return {
|
|
4115
|
+
entries,
|
|
4116
|
+
indexes
|
|
4117
|
+
};
|
|
4118
|
+
}
|
|
4119
|
+
function applyImportedDocxIndexMarkers(document, markers) {
|
|
4120
|
+
for (const entry of markers.entries){
|
|
4121
|
+
const html = documentIndexEntryHtml({
|
|
4122
|
+
id: entry.id,
|
|
4123
|
+
...entry.value
|
|
4124
|
+
});
|
|
4125
|
+
const parsed = document.createRange().createContextualFragment(html);
|
|
4126
|
+
const replacement = parsed.firstElementChild;
|
|
4127
|
+
if (replacement instanceof HTMLElement) replaceMarkerRange(document.body, entry.start, entry.end, replacement);
|
|
4128
|
+
}
|
|
4129
|
+
const importedEntries = Array.from(document.body.querySelectorAll('[data-document-index-entry]'));
|
|
4130
|
+
for (const index of markers.indexes){
|
|
4131
|
+
const text = textNodes(document.body).find((node)=>node.data.includes(index.marker));
|
|
4132
|
+
if (!text) continue;
|
|
4133
|
+
const entries = index.entries.map((entry, entryIndex)=>{
|
|
4134
|
+
const targets = importedEntries.filter((candidate)=>normalizedTerm(candidate.dataset.indexMainEntry) === normalizedTerm(entry.mainEntry) && normalizedTerm(candidate.dataset.indexSubEntry) === normalizedTerm(entry.subEntry));
|
|
4135
|
+
const targetIds = targets.flatMap((candidate)=>{
|
|
4136
|
+
const id = candidate.dataset.indexEntryId?.trim();
|
|
4137
|
+
return id ? [
|
|
4138
|
+
id
|
|
4139
|
+
] : [];
|
|
4140
|
+
});
|
|
4141
|
+
return {
|
|
4142
|
+
...entry,
|
|
4143
|
+
pages: entry.pages.map((page)=>({
|
|
4144
|
+
...page,
|
|
4145
|
+
targetIds: targetIds.length ? targetIds : [
|
|
4146
|
+
`index-entry-import-${index.id}-${entryIndex + 1}`
|
|
4147
|
+
]
|
|
4148
|
+
}))
|
|
4149
|
+
};
|
|
4150
|
+
});
|
|
4151
|
+
const fragment = document.createRange().createContextualFragment(documentIndexHtml({
|
|
4152
|
+
id: index.id,
|
|
4153
|
+
options: index.options,
|
|
4154
|
+
entries
|
|
4155
|
+
}));
|
|
4156
|
+
closestHtmlBlock(text.parentElement)?.replaceWith(fragment);
|
|
4157
|
+
}
|
|
4158
|
+
}
|
|
4159
|
+
function hasImportedDocxIndexMarkers(markers) {
|
|
4160
|
+
return markers.entries.length > 0 || markers.indexes.length > 0;
|
|
4161
|
+
}
|
|
4162
|
+
function supportedDocxIndexEntryField(field) {
|
|
4163
|
+
return parseDocumentIndexEntryInstruction(field.instruction).supported && docxFieldOccurrenceIsInlineEditable(field);
|
|
4164
|
+
}
|
|
4165
|
+
function supportedDocxIndexField(field) {
|
|
4166
|
+
return parseDocumentIndexInstruction(field.instruction).supported && field.complete && !field.nested && !field.inDeletion && Boolean(work_docx_index_import_closestAncestor(field.start, 'sdt'));
|
|
4167
|
+
}
|
|
4168
|
+
function importedIndexEntries(control, indexNumber) {
|
|
4169
|
+
const entries = [];
|
|
4170
|
+
let currentMain = '';
|
|
4171
|
+
let row = 0;
|
|
4172
|
+
for (const paragraph of descendants(control, 'p')){
|
|
4173
|
+
const style = directChild(directChild(paragraph, 'pPr') ?? paragraph, 'pStyle');
|
|
4174
|
+
const styleName = work_ooxml_package_attribute(style ?? paragraph, 'val') ?? '';
|
|
4175
|
+
const level = /^Index([12])$/i.exec(styleName)?.[1];
|
|
4176
|
+
if (!level) continue;
|
|
4177
|
+
row += 1;
|
|
4178
|
+
const parsed = importedIndexParagraph(paragraph, indexNumber, row);
|
|
4179
|
+
if (parsed) {
|
|
4180
|
+
if ('1' === level) {
|
|
4181
|
+
currentMain = parsed.term;
|
|
4182
|
+
if (!parsed.pages.length && !parsed.crossReference) continue;
|
|
4183
|
+
entries.push({
|
|
4184
|
+
mainEntry: parsed.term,
|
|
4185
|
+
subEntry: '',
|
|
4186
|
+
crossReference: parsed.crossReference,
|
|
4187
|
+
pages: parsed.pages
|
|
4188
|
+
});
|
|
4189
|
+
continue;
|
|
4190
|
+
}
|
|
4191
|
+
if (currentMain) entries.push({
|
|
4192
|
+
mainEntry: currentMain,
|
|
4193
|
+
subEntry: parsed.term,
|
|
4194
|
+
crossReference: parsed.crossReference,
|
|
4195
|
+
pages: parsed.pages
|
|
4196
|
+
});
|
|
4197
|
+
}
|
|
4198
|
+
}
|
|
4199
|
+
return entries;
|
|
4200
|
+
}
|
|
4201
|
+
function importedIndexParagraph(paragraph, indexNumber, row) {
|
|
4202
|
+
const textElements = descendants(paragraph, 't');
|
|
4203
|
+
const values = textElements.map((element)=>element.textContent ?? '');
|
|
4204
|
+
const combined = values.join('').replace(/\s+/g, ' ').trim();
|
|
4205
|
+
if (!combined) return null;
|
|
4206
|
+
const crossReference = /^(.+?),\s*(?:see|参见)\s+(.+)$/i.exec(combined);
|
|
4207
|
+
if (crossReference?.[1] && crossReference[2]) return {
|
|
4208
|
+
term: crossReference[1].trim(),
|
|
4209
|
+
crossReference: crossReference[2].trim(),
|
|
4210
|
+
pages: []
|
|
4211
|
+
};
|
|
4212
|
+
const pageElements = textElements.filter((element)=>/^\d{1,6}$/.test((element.textContent ?? '').trim()));
|
|
4213
|
+
const pages = pageElements.map((element, pageIndex)=>{
|
|
4214
|
+
const properties = directChild(work_docx_index_import_closestAncestor(element, 'r') ?? element, 'rPr');
|
|
4215
|
+
return {
|
|
4216
|
+
pageNumber: Number((element.textContent ?? '').trim()),
|
|
4217
|
+
pageBold: Boolean(properties && directChild(properties, 'b')),
|
|
4218
|
+
pageItalic: Boolean(properties && directChild(properties, 'i')),
|
|
4219
|
+
targetIds: [
|
|
4220
|
+
`index-entry-import-${indexNumber}-${row}-${pageIndex + 1}`
|
|
4221
|
+
]
|
|
4222
|
+
};
|
|
4223
|
+
});
|
|
4224
|
+
const pageText = pageElements.map((element)=>element.textContent ?? '');
|
|
4225
|
+
let term = combined;
|
|
4226
|
+
for (const value of pageText)term = term.replace(new RegExp(`(?:,\\s*)?${escapeRegExp(value)}\\s*$`), '');
|
|
4227
|
+
term = term.replace(/[,\s]+$/, '').trim();
|
|
4228
|
+
return term ? {
|
|
4229
|
+
term,
|
|
4230
|
+
crossReference: '',
|
|
4231
|
+
pages
|
|
4232
|
+
} : null;
|
|
4233
|
+
}
|
|
4234
|
+
function importedIndexLeader(control, options) {
|
|
4235
|
+
if (!options.rightAlignPageNumbers) return 'none';
|
|
4236
|
+
const tab = descendants(control, 'tab').find((candidate)=>candidate.parentElement?.localName === 'tabs' && 'right' === work_ooxml_package_attribute(candidate, 'val'));
|
|
4237
|
+
const leader = work_ooxml_package_attribute(tab ?? control, 'leader');
|
|
4238
|
+
if ('hyphen' === leader) return 'dash';
|
|
4239
|
+
if ('underscore' === leader) return 'underline';
|
|
4240
|
+
if (!leader || 'none' === leader) return 'none';
|
|
4241
|
+
return 'dot';
|
|
4242
|
+
}
|
|
4243
|
+
function insertFieldBoundaryMarkers(document, field, start, end) {
|
|
4244
|
+
if ('fldChar' === field.start.localName && 'fldChar' === field.end.localName) {
|
|
4245
|
+
field.start.parentNode?.insertBefore(markerText(document, start), field.start);
|
|
4246
|
+
field.end.parentNode?.insertBefore(markerText(document, end), field.end.nextSibling);
|
|
4247
|
+
return;
|
|
4248
|
+
}
|
|
4249
|
+
field.start.parentNode?.insertBefore(markerRun(document, start), field.start);
|
|
4250
|
+
field.end.parentNode?.insertBefore(markerRun(document, end), field.end.nextSibling);
|
|
4251
|
+
}
|
|
4252
|
+
function markerParagraph(document, marker) {
|
|
4253
|
+
const paragraph = document.createElementNS(WORD_NAMESPACE, 'w:p');
|
|
4254
|
+
paragraph.append(markerRun(document, marker));
|
|
4255
|
+
return paragraph;
|
|
4256
|
+
}
|
|
4257
|
+
function markerRun(document, value) {
|
|
4258
|
+
const run = document.createElementNS(WORD_NAMESPACE, 'w:r');
|
|
4259
|
+
run.append(markerText(document, value));
|
|
4260
|
+
return run;
|
|
4261
|
+
}
|
|
4262
|
+
function markerText(document, value) {
|
|
4263
|
+
const text = document.createElementNS(WORD_NAMESPACE, 'w:t');
|
|
4264
|
+
text.setAttributeNS(work_docx_index_import_XML_NAMESPACE, 'xml:space', 'preserve');
|
|
4265
|
+
text.textContent = value;
|
|
4266
|
+
return text;
|
|
4267
|
+
}
|
|
4268
|
+
function replaceMarkerRange(root, start, end, replacement) {
|
|
4269
|
+
const nodes = textNodes(root);
|
|
4270
|
+
const startNode = nodes.find((node)=>node.data.includes(start));
|
|
4271
|
+
const endNode = nodes.find((node)=>node.data.includes(end));
|
|
4272
|
+
if (!startNode || !endNode) return;
|
|
4273
|
+
const range = root.ownerDocument.createRange();
|
|
4274
|
+
range.setStart(startNode, startNode.data.indexOf(start));
|
|
4275
|
+
range.setEnd(endNode, endNode.data.indexOf(end) + end.length);
|
|
4276
|
+
range.deleteContents();
|
|
4277
|
+
range.insertNode(replacement);
|
|
4278
|
+
}
|
|
4279
|
+
function textNodes(root) {
|
|
4280
|
+
const walker = root.ownerDocument?.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
4281
|
+
const nodes = [];
|
|
4282
|
+
if (!walker) return nodes;
|
|
4283
|
+
while(walker.nextNode())nodes.push(walker.currentNode);
|
|
4284
|
+
return nodes;
|
|
4285
|
+
}
|
|
4286
|
+
function closestHtmlBlock(element) {
|
|
4287
|
+
let current = element;
|
|
4288
|
+
while(current && current.parentElement?.tagName.toLowerCase() !== 'body')current = current.parentElement;
|
|
4289
|
+
return current;
|
|
4290
|
+
}
|
|
4291
|
+
function work_docx_index_import_closestAncestor(element, localName) {
|
|
4292
|
+
let current = element;
|
|
4293
|
+
while(current){
|
|
4294
|
+
if (current.localName === localName) return current;
|
|
4295
|
+
current = current.parentElement;
|
|
4296
|
+
}
|
|
4297
|
+
return null;
|
|
4298
|
+
}
|
|
4299
|
+
function normalizedTerm(value) {
|
|
4300
|
+
return (value ?? '').normalize('NFKC').replace(/\s+/g, ' ').trim().toLowerCase();
|
|
4301
|
+
}
|
|
4302
|
+
function escapeRegExp(value) {
|
|
4303
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
4304
|
+
}
|
|
4305
|
+
const work_docx_table_of_contents_import_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
4306
|
+
const work_docx_table_of_contents_import_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
4307
|
+
function markDocxTablesOfContents(document) {
|
|
4308
|
+
const tables = [];
|
|
4309
|
+
for (const element of descendants(document, 'sdt')){
|
|
4310
|
+
if (!document.documentElement.contains(element)) continue;
|
|
4311
|
+
const field = docxFieldOccurrences(element).find(supportedDocxTableOfContentsField);
|
|
4312
|
+
if (!field) continue;
|
|
4313
|
+
const parsed = parseDocumentTableOfContentsInstruction(field.instruction);
|
|
4314
|
+
if (!parsed.supported) continue;
|
|
4315
|
+
const tableIndex = tables.length + 1;
|
|
4316
|
+
const marker = {
|
|
4317
|
+
marker: `__A3S_WORK_TABLE_OF_CONTENTS_${tableIndex}__`,
|
|
4318
|
+
id: `docx-table-of-contents-${tableIndex}`,
|
|
4319
|
+
options: {
|
|
4320
|
+
...parsed.options,
|
|
4321
|
+
leader: importedTableOfContentsLeader(element, parsed.options)
|
|
4322
|
+
},
|
|
4323
|
+
entries: importedTableOfContentsEntries(element, tableIndex)
|
|
4324
|
+
};
|
|
4325
|
+
element.replaceWith(work_docx_table_of_contents_import_markerParagraph(document, marker.marker));
|
|
4326
|
+
tables.push(marker);
|
|
4327
|
+
}
|
|
4328
|
+
return {
|
|
4329
|
+
tables
|
|
4330
|
+
};
|
|
4331
|
+
}
|
|
4332
|
+
function applyImportedDocxTableOfContentsMarkers(document, markers) {
|
|
4333
|
+
const headings = importedHtmlHeadings(document);
|
|
4334
|
+
for (const table of markers.tables){
|
|
4335
|
+
const usedHeadingIndexes = new Set();
|
|
4336
|
+
const text = work_docx_table_of_contents_import_textNodes(document.body).find((node)=>node.data.includes(table.marker));
|
|
4337
|
+
if (!text) continue;
|
|
4338
|
+
const entries = table.entries.map((entry)=>{
|
|
4339
|
+
const headingIndex = headings.findIndex((heading, index)=>!usedHeadingIndexes.has(index) && heading.level === entry.level && normalizedTitle(heading.title) === normalizedTitle(entry.title));
|
|
4340
|
+
if (headingIndex < 0) return entry;
|
|
4341
|
+
usedHeadingIndexes.add(headingIndex);
|
|
4342
|
+
const heading = headings[headingIndex];
|
|
4343
|
+
return heading ? {
|
|
4344
|
+
...entry,
|
|
4345
|
+
targetId: heading.targetId
|
|
4346
|
+
} : entry;
|
|
4347
|
+
});
|
|
4348
|
+
const fragment = document.createRange().createContextualFragment(documentTableOfContentsHtml({
|
|
4349
|
+
id: table.id,
|
|
4350
|
+
options: table.options,
|
|
4351
|
+
entries
|
|
4352
|
+
}));
|
|
4353
|
+
const block = work_docx_table_of_contents_import_closestHtmlBlock(text.parentElement);
|
|
4354
|
+
if (block) block.replaceWith(fragment);
|
|
4355
|
+
}
|
|
4356
|
+
}
|
|
4357
|
+
function hasImportedDocxTableOfContentsMarkers(markers) {
|
|
4358
|
+
return markers.tables.length > 0;
|
|
4359
|
+
}
|
|
4360
|
+
function supportedDocxTableOfContentsField(field) {
|
|
4361
|
+
const parsed = parseDocumentTableOfContentsInstruction(field.instruction);
|
|
4362
|
+
return parsed.supported && field.complete && !field.nested && !field.inDeletion && Boolean(work_docx_table_of_contents_import_closestAncestor(field.start, 'sdt'));
|
|
4363
|
+
}
|
|
4364
|
+
function importedTableOfContentsEntries(element, tableIndex) {
|
|
4365
|
+
const paragraphs = descendants(element, 'p');
|
|
4366
|
+
return paragraphs.flatMap((paragraph, index)=>{
|
|
4367
|
+
const style = directChild(directChild(paragraph, 'pPr') ?? paragraph, 'pStyle');
|
|
4368
|
+
const level = Number(/^TOC([1-9])$/i.exec(work_ooxml_package_attribute(style ?? paragraph, 'val') ?? '')?.[1]);
|
|
4369
|
+
if (!level) return [];
|
|
4370
|
+
const values = descendants(paragraph, 't').map((text)=>text.textContent ?? '').filter(Boolean);
|
|
4371
|
+
const last = values.at(-1)?.trim() ?? '';
|
|
4372
|
+
const hasPageNumber = /^\d{1,6}$/.test(last);
|
|
4373
|
+
const title = (hasPageNumber ? values.slice(0, -1) : values).join('').replace(/\s+/g, ' ').trim();
|
|
4374
|
+
if (!title) return [];
|
|
4375
|
+
const hyperlink = descendants(paragraph, 'hyperlink').find((candidate)=>Boolean(work_ooxml_package_attribute(candidate, 'anchor')));
|
|
4376
|
+
const anchor = work_ooxml_package_attribute(hyperlink ?? paragraph, 'anchor')?.trim();
|
|
4377
|
+
const targetId = /^heading-[a-z0-9._:-]{1,128}$/i.test(anchor ?? '') ? anchor : `heading-import-${tableIndex}-${index + 1}`;
|
|
4378
|
+
return [
|
|
4379
|
+
{
|
|
4380
|
+
targetId,
|
|
4381
|
+
title,
|
|
4382
|
+
level,
|
|
4383
|
+
pageNumber: hasPageNumber ? Number(last) : 1
|
|
4384
|
+
}
|
|
4385
|
+
];
|
|
4386
|
+
});
|
|
4387
|
+
}
|
|
4388
|
+
function importedTableOfContentsLeader(element, options) {
|
|
4389
|
+
if (!options.showPageNumbers || !options.rightAlignPageNumbers) return 'none';
|
|
4390
|
+
const tab = descendants(element, 'tab').find((candidate)=>candidate.parentElement?.localName === 'tabs' && 'right' === work_ooxml_package_attribute(candidate, 'val'));
|
|
4391
|
+
const leader = work_ooxml_package_attribute(tab ?? element, 'leader');
|
|
4392
|
+
if ('hyphen' === leader) return 'dash';
|
|
4393
|
+
if ('underscore' === leader) return 'underline';
|
|
4394
|
+
if (!leader || 'none' === leader) return 'none';
|
|
4395
|
+
return 'dot';
|
|
4396
|
+
}
|
|
4397
|
+
function work_docx_table_of_contents_import_markerParagraph(document, marker) {
|
|
4398
|
+
const paragraph = document.createElementNS(work_docx_table_of_contents_import_WORD_NAMESPACE, 'w:p');
|
|
4399
|
+
const run = document.createElementNS(work_docx_table_of_contents_import_WORD_NAMESPACE, 'w:r');
|
|
4400
|
+
const text = document.createElementNS(work_docx_table_of_contents_import_WORD_NAMESPACE, 'w:t');
|
|
4401
|
+
text.setAttributeNS(work_docx_table_of_contents_import_XML_NAMESPACE, 'xml:space', 'preserve');
|
|
4402
|
+
text.textContent = marker;
|
|
4403
|
+
run.append(text);
|
|
4404
|
+
paragraph.append(run);
|
|
4405
|
+
return paragraph;
|
|
4406
|
+
}
|
|
4407
|
+
function importedHtmlHeadings(document) {
|
|
4408
|
+
return Array.from(document.body.querySelectorAll('h1,h2,h3,h4,h5,h6,p[data-office-outline-level]')).flatMap((heading, index)=>{
|
|
4409
|
+
const headingLevel = /^H([1-6])$/.exec(heading.tagName)?.[1];
|
|
4410
|
+
const outlineLevel = Number(heading.dataset.officeOutlineLevel);
|
|
4411
|
+
const level = headingLevel ? Number(headingLevel) : Number.isInteger(outlineLevel) && outlineLevel >= 0 && outlineLevel <= 8 ? outlineLevel + 1 : null;
|
|
4412
|
+
if (null === level) return [];
|
|
4413
|
+
const identity = normalizeDocumentParagraphId(heading.dataset.officeParagraphId);
|
|
4414
|
+
return [
|
|
4415
|
+
{
|
|
4416
|
+
title: heading.textContent ?? '',
|
|
4417
|
+
level,
|
|
4418
|
+
targetId: identity ? `heading-${identity.toLowerCase()}` : `heading-imported-${index + 1}`
|
|
4419
|
+
}
|
|
4420
|
+
];
|
|
4421
|
+
});
|
|
4422
|
+
}
|
|
4423
|
+
function work_docx_table_of_contents_import_textNodes(root) {
|
|
4424
|
+
const walker = root.ownerDocument?.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
4425
|
+
const nodes = [];
|
|
4426
|
+
if (!walker) return nodes;
|
|
4427
|
+
while(walker.nextNode())nodes.push(walker.currentNode);
|
|
4428
|
+
return nodes;
|
|
4429
|
+
}
|
|
4430
|
+
function work_docx_table_of_contents_import_closestHtmlBlock(element) {
|
|
4431
|
+
let current = element;
|
|
4432
|
+
while(current && current.parentElement?.tagName.toLowerCase() !== 'body')current = current.parentElement;
|
|
4433
|
+
return current;
|
|
4434
|
+
}
|
|
4435
|
+
function work_docx_table_of_contents_import_closestAncestor(element, localName) {
|
|
4436
|
+
let current = element;
|
|
4437
|
+
while(current){
|
|
4438
|
+
if (current.localName === localName) return current;
|
|
4439
|
+
current = current.parentElement;
|
|
4440
|
+
}
|
|
4441
|
+
return null;
|
|
4442
|
+
}
|
|
4443
|
+
function normalizedTitle(value) {
|
|
4444
|
+
return value.normalize('NFKC').replace(/\s+/g, ' ').trim().toLocaleLowerCase();
|
|
4445
|
+
}
|
|
4076
4446
|
const ON_VALUES = new Set([
|
|
4077
4447
|
'1',
|
|
4078
4448
|
'on',
|
|
@@ -4530,7 +4900,7 @@ function onOffValue(value) {
|
|
|
4530
4900
|
function work_docx_table_styles_wordAttribute(element, name) {
|
|
4531
4901
|
return work_ooxml_package_attribute(element, name) ?? work_ooxml_package_attribute(element, `w:${name}`);
|
|
4532
4902
|
}
|
|
4533
|
-
const
|
|
4903
|
+
const work_docx_paragraph_borders_import_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
4534
4904
|
const work_docx_paragraph_borders_import_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
4535
4905
|
const XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/';
|
|
4536
4906
|
const PARAGRAPH_BORDER_MARKER_PATTERN = /__A3S_WORK_PARAGRAPH_BORDER_\d+__/g;
|
|
@@ -4622,7 +4992,7 @@ function applyImportedDocxParagraphBorderMarkers(document, markers) {
|
|
|
4622
4992
|
marker,
|
|
4623
4993
|
borders
|
|
4624
4994
|
]));
|
|
4625
|
-
for (const node of
|
|
4995
|
+
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
4996
|
const borders = bordersByMarker.get(marker);
|
|
4627
4997
|
const block = borders ? closestParagraphBlock(node.parentElement, node) : null;
|
|
4628
4998
|
if (block && borders) applyParagraphBorders(block, borders);
|
|
@@ -4837,7 +5207,7 @@ function applyParagraphBorders(element, borders) {
|
|
|
4837
5207
|
}
|
|
4838
5208
|
}
|
|
4839
5209
|
function insertParagraphMarker(document, paragraph, properties, marker) {
|
|
4840
|
-
const namespace = paragraph.namespaceURI ??
|
|
5210
|
+
const namespace = paragraph.namespaceURI ?? work_docx_paragraph_borders_import_WORD_NAMESPACE;
|
|
4841
5211
|
const prefix = paragraph.prefix ?? 'w';
|
|
4842
5212
|
const run = document.createElementNS(namespace, `${prefix}:r`);
|
|
4843
5213
|
const text = document.createElementNS(namespace, `${prefix}:t`);
|
|
@@ -4847,7 +5217,7 @@ function insertParagraphMarker(document, paragraph, properties, marker) {
|
|
|
4847
5217
|
paragraph.insertBefore(run, properties.nextSibling);
|
|
4848
5218
|
}
|
|
4849
5219
|
function insertParagraphProperties(document, paragraph) {
|
|
4850
|
-
const namespace = paragraph.namespaceURI ??
|
|
5220
|
+
const namespace = paragraph.namespaceURI ?? work_docx_paragraph_borders_import_WORD_NAMESPACE;
|
|
4851
5221
|
const prefix = paragraph.prefix ?? 'w';
|
|
4852
5222
|
const properties = document.createElementNS(namespace, `${prefix}:pPr`);
|
|
4853
5223
|
paragraph.insertBefore(properties, paragraph.firstChild);
|
|
@@ -4899,7 +5269,7 @@ function isListItemBlock(node) {
|
|
|
4899
5269
|
'ul'
|
|
4900
5270
|
].includes(node.tagName.toLowerCase());
|
|
4901
5271
|
}
|
|
4902
|
-
function
|
|
5272
|
+
function work_docx_paragraph_borders_import_textNodes(root) {
|
|
4903
5273
|
const document = root.ownerDocument;
|
|
4904
5274
|
const walker = document?.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
4905
5275
|
const nodes = [];
|
|
@@ -5040,7 +5410,7 @@ function hasImportedDocxParagraphShadingMarkers(markers) {
|
|
|
5040
5410
|
function parseDocxParagraphShadingElement(element, themeSource) {
|
|
5041
5411
|
const attributes = work_docx_paragraph_shading_import_wordLeafAttributes(element, SHADING_ATTRIBUTES);
|
|
5042
5412
|
const pattern = attributes?.get('val')?.trim();
|
|
5043
|
-
if (!attributes || !
|
|
5413
|
+
if (!attributes || !work_document_paragraph_shading_DOCUMENT_PARAGRAPH_SHADING_PATTERNS.has(pattern)) return null;
|
|
5044
5414
|
const theme = work_docx_theme_resolveDocxThemeResolver(themeSource);
|
|
5045
5415
|
const color = parseShadingColor(attributes, theme, {
|
|
5046
5416
|
value: 'color',
|
|
@@ -5249,6 +5619,57 @@ function work_docx_paragraph_shading_import_textNodes(root) {
|
|
|
5249
5619
|
while(walker.nextNode())nodes.push(walker.currentNode);
|
|
5250
5620
|
return nodes;
|
|
5251
5621
|
}
|
|
5622
|
+
function inspectDocxRunShading(properties, themeSource) {
|
|
5623
|
+
return inspectDocxRunShadingWithTheme(properties, work_docx_theme_resolveDocxThemeResolver(themeSource));
|
|
5624
|
+
}
|
|
5625
|
+
function resolveDocxRunShading(propertySources, themeSource) {
|
|
5626
|
+
const theme = work_docx_theme_resolveDocxThemeResolver(themeSource);
|
|
5627
|
+
let shading;
|
|
5628
|
+
let invalidCount = 0;
|
|
5629
|
+
let spoofedCount = 0;
|
|
5630
|
+
for (const properties of propertySources){
|
|
5631
|
+
const inspection = inspectDocxRunShadingWithTheme(properties, theme);
|
|
5632
|
+
spoofedCount += inspection.spoofedCount;
|
|
5633
|
+
if ('valid' === inspection.status) shading = inspection.value;
|
|
5634
|
+
else if ('invalid' === inspection.status) {
|
|
5635
|
+
invalidCount += 1;
|
|
5636
|
+
shading = {
|
|
5637
|
+
pattern: 'nil'
|
|
5638
|
+
};
|
|
5639
|
+
}
|
|
5640
|
+
}
|
|
5641
|
+
return {
|
|
5642
|
+
shading,
|
|
5643
|
+
invalidCount,
|
|
5644
|
+
spoofedCount
|
|
5645
|
+
};
|
|
5646
|
+
}
|
|
5647
|
+
function inspectDocxRunShadingWithTheme(properties, theme) {
|
|
5648
|
+
if (!properties) return {
|
|
5649
|
+
status: 'absent',
|
|
5650
|
+
spoofedCount: 0
|
|
5651
|
+
};
|
|
5652
|
+
const matches = work_ooxml_package_directChildren(properties, 'shd');
|
|
5653
|
+
if (!matches.length) return {
|
|
5654
|
+
status: 'absent',
|
|
5655
|
+
spoofedCount: 0
|
|
5656
|
+
};
|
|
5657
|
+
const native = matches.filter((element)=>element.namespaceURI === properties.namespaceURI && DOCX_WORDPROCESSING_NAMESPACES.has(element.namespaceURI ?? ''));
|
|
5658
|
+
const spoofedCount = matches.length - native.length;
|
|
5659
|
+
if (1 !== matches.length || 1 !== native.length) return {
|
|
5660
|
+
status: 'invalid',
|
|
5661
|
+
spoofedCount
|
|
5662
|
+
};
|
|
5663
|
+
const parsed = parseDocxParagraphShadingElement(native[0], theme);
|
|
5664
|
+
return parsed ? {
|
|
5665
|
+
status: 'valid',
|
|
5666
|
+
value: parsed,
|
|
5667
|
+
spoofedCount
|
|
5668
|
+
} : {
|
|
5669
|
+
status: 'invalid',
|
|
5670
|
+
spoofedCount
|
|
5671
|
+
};
|
|
5672
|
+
}
|
|
5252
5673
|
function importedDocxUnderline(element, theme) {
|
|
5253
5674
|
const rawStyle = work_ooxml_package_attribute(element, 'val');
|
|
5254
5675
|
const style = null === rawStyle ? 'single' : normalizeDocumentUnderlineStyle(rawStyle) ?? 'single';
|
|
@@ -6926,6 +7347,7 @@ const SUPPORTED_RUN_PROPERTY_CHANGE_CHILDREN = new Set([
|
|
|
6926
7347
|
'shadow',
|
|
6927
7348
|
'emboss',
|
|
6928
7349
|
'imprint',
|
|
7350
|
+
'noProof',
|
|
6929
7351
|
'caps',
|
|
6930
7352
|
'smallCaps',
|
|
6931
7353
|
'vanish',
|
|
@@ -6943,6 +7365,7 @@ const SUPPORTED_RUN_PROPERTY_CHANGE_CHILDREN = new Set([
|
|
|
6943
7365
|
'cs',
|
|
6944
7366
|
'rtl',
|
|
6945
7367
|
'em',
|
|
7368
|
+
'lang',
|
|
6946
7369
|
'vertAlign',
|
|
6947
7370
|
'bdr'
|
|
6948
7371
|
]);
|
|
@@ -7026,6 +7449,7 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
|
|
|
7026
7449
|
let complexFontSize;
|
|
7027
7450
|
let color;
|
|
7028
7451
|
let backgroundColor;
|
|
7452
|
+
let highlightValue;
|
|
7029
7453
|
let themeColor;
|
|
7030
7454
|
let themeFill;
|
|
7031
7455
|
let bold;
|
|
@@ -7050,6 +7474,8 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
|
|
|
7050
7474
|
const hiddenText = resolveDocxHiddenText(propertySources);
|
|
7051
7475
|
const legacyTextEffects = resolveDocxLegacyTextEffects(propertySources);
|
|
7052
7476
|
const runBorder = resolveDocxRunBorder(propertySources, theme).border;
|
|
7477
|
+
const runShading = resolveDocxRunShading(propertySources, theme).shading;
|
|
7478
|
+
const proofing = resolveDocxProofing(propertySources);
|
|
7053
7479
|
for (const properties of propertySources){
|
|
7054
7480
|
bold = overriddenBoolean(bold, onOffProperty(properties, 'b'));
|
|
7055
7481
|
complexBold = overriddenBoolean(complexBold, onOffProperty(properties, 'bCs'));
|
|
@@ -7098,23 +7524,10 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
|
|
|
7098
7524
|
}
|
|
7099
7525
|
const highlight = directChild(properties, 'highlight');
|
|
7100
7526
|
if (highlight) {
|
|
7101
|
-
const value = work_docx_run_formatting_import_wordAttribute(highlight, 'val')
|
|
7527
|
+
const value = documentHighlightFromDocxValue(work_docx_run_formatting_import_wordAttribute(highlight, 'val'));
|
|
7102
7528
|
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()}`;
|
|
7529
|
+
highlightValue = value;
|
|
7530
|
+
backgroundColor = documentHighlightCssColor(value) ?? 'transparent';
|
|
7118
7531
|
themeFill = void 0;
|
|
7119
7532
|
}
|
|
7120
7533
|
}
|
|
@@ -7199,6 +7612,9 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
|
|
|
7199
7612
|
...backgroundColor ? {
|
|
7200
7613
|
backgroundColor
|
|
7201
7614
|
} : {},
|
|
7615
|
+
...highlightValue ? {
|
|
7616
|
+
highlight: highlightValue
|
|
7617
|
+
} : {},
|
|
7202
7618
|
...themeColor ? {
|
|
7203
7619
|
themeColor
|
|
7204
7620
|
} : {},
|
|
@@ -7210,16 +7626,25 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
|
|
|
7210
7626
|
} : {},
|
|
7211
7627
|
...runBorder ? {
|
|
7212
7628
|
runBorder
|
|
7629
|
+
} : {},
|
|
7630
|
+
...runShading ? {
|
|
7631
|
+
runShading
|
|
7632
|
+
} : {},
|
|
7633
|
+
...proofing.languages ? {
|
|
7634
|
+
proofingLanguages: proofing.languages
|
|
7635
|
+
} : {},
|
|
7636
|
+
...void 0 !== proofing.noProof ? {
|
|
7637
|
+
noProof: proofing.noProof
|
|
7213
7638
|
} : {}
|
|
7214
7639
|
};
|
|
7215
7640
|
}
|
|
7216
7641
|
function insertRunMarkers(document, run, properties, startMarker, endMarker) {
|
|
7217
|
-
const start =
|
|
7218
|
-
const end =
|
|
7642
|
+
const start = work_docx_run_formatting_import_markerText(document, startMarker);
|
|
7643
|
+
const end = work_docx_run_formatting_import_markerText(document, endMarker);
|
|
7219
7644
|
run.insertBefore(start, properties?.nextSibling ?? run.firstChild);
|
|
7220
7645
|
run.append(end);
|
|
7221
7646
|
}
|
|
7222
|
-
function
|
|
7647
|
+
function work_docx_run_formatting_import_markerText(document, marker) {
|
|
7223
7648
|
const text = document.createElementNS(work_docx_run_formatting_import_WORD_NAMESPACE, 'w:t');
|
|
7224
7649
|
text.setAttributeNS(work_docx_run_formatting_import_XML_NAMESPACE, 'xml:space', 'preserve');
|
|
7225
7650
|
text.textContent = marker;
|
|
@@ -7248,6 +7673,9 @@ function formattingMarkup(document, formatting) {
|
|
|
7248
7673
|
if (void 0 !== formatting.hiddenText) for (const [name, value] of Object.entries(documentHiddenTextDomAttributes(formatting.hiddenText)))span.setAttribute(name, value);
|
|
7249
7674
|
if (formatting.runBorder) for (const [name, value] of Object.entries(documentRunBorderDomAttributes(formatting.runBorder)))if ('style' === name) span.style.cssText += `; ${value}`;
|
|
7250
7675
|
else span.setAttribute(name, value);
|
|
7676
|
+
if (formatting.runShading) for (const [name, value] of Object.entries(documentRunShadingDomAttributes(formatting.runShading)))if ('style' === name) span.style.cssText += `; ${value}`;
|
|
7677
|
+
else span.setAttribute(name, value);
|
|
7678
|
+
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
7679
|
const legacyTextEffects = {
|
|
7252
7680
|
...void 0 !== formatting.legacyTextOutline ? {
|
|
7253
7681
|
outline: formatting.legacyTextOutline
|
|
@@ -7273,7 +7701,9 @@ function formattingMarkup(document, formatting) {
|
|
|
7273
7701
|
if (formatting.color) span.style.color = formatting.color;
|
|
7274
7702
|
const themeColor = serializeDocxThemeReference(formatting.themeColor ?? null);
|
|
7275
7703
|
if (themeColor) span.dataset.officeThemeColor = themeColor;
|
|
7276
|
-
if (formatting.
|
|
7704
|
+
if (formatting.highlight) for (const [name, value] of Object.entries(documentHighlightDomAttributes(formatting.highlight)))if ('style' === name) span.style.cssText += `; ${value}`;
|
|
7705
|
+
else span.setAttribute(name, value);
|
|
7706
|
+
else if (formatting.backgroundColor) span.style.backgroundColor = formatting.backgroundColor;
|
|
7277
7707
|
const themeFill = serializeDocxThemeReference(formatting.themeFill ?? null);
|
|
7278
7708
|
if (themeFill) span.dataset.officeThemeFill = themeFill;
|
|
7279
7709
|
if (formatting.textCase) applyDocumentTextCaseStyle(span, formatting.textCase);
|
|
@@ -7354,7 +7784,9 @@ function importedRunFormattingChange(runProperties, paragraphProperties, styles,
|
|
|
7354
7784
|
legacyTextShadow: beforeFormatting.legacyTextShadow,
|
|
7355
7785
|
legacyTextEmboss: beforeFormatting.legacyTextEmboss,
|
|
7356
7786
|
legacyTextImprint: beforeFormatting.legacyTextImprint,
|
|
7357
|
-
runBorder: serializeDocumentRunBorder(beforeFormatting.runBorder)
|
|
7787
|
+
runBorder: serializeDocumentRunBorder(beforeFormatting.runBorder),
|
|
7788
|
+
runShading: serializeDocumentRunShading(beforeFormatting.runShading),
|
|
7789
|
+
highlight: beforeFormatting.highlight
|
|
7358
7790
|
})
|
|
7359
7791
|
};
|
|
7360
7792
|
}
|
|
@@ -7489,32 +7921,10 @@ function work_docx_run_formatting_import_numericAttribute(element, name) {
|
|
|
7489
7921
|
function work_docx_run_formatting_import_wordAttribute(element, name) {
|
|
7490
7922
|
return work_ooxml_package_attribute(element, name) ?? work_ooxml_package_attribute(element, `w:${name}`);
|
|
7491
7923
|
}
|
|
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
7924
|
function work_docx_run_formatting_import_formatNumber(value) {
|
|
7515
7925
|
return Number(value.toFixed(2)).toString();
|
|
7516
7926
|
}
|
|
7517
7927
|
function formatLineHeightFactor(value) {
|
|
7518
7928
|
return Number(value.toFixed(4)).toString();
|
|
7519
7929
|
}
|
|
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 };
|
|
7930
|
+
export { applyImportedDocxEquationMarkers, applyImportedDocxIndexMarkers, 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, hasImportedDocxIndexMarkers, 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, markDocxIndexes, markDocxPackageEquations, markDocxParagraphAlignments, markDocxParagraphBorders, markDocxParagraphDirections, markDocxParagraphFormattingChanges, markDocxParagraphIndents, markDocxParagraphPagination, markDocxParagraphShading, markDocxParagraphSpacing, markDocxParagraphTabStops, markDocxRunFormattingIntoState, markDocxTablesOfContents, parseDirectDocxParagraphShading, parseDocxPageBorders, parseDocxPageGeometry, parseDocxPageMargins, parseDocxPaperSource, resolveDocxHiddenText, resolveDocxLegacyTextEffects, resolveDocxParagraphBordersForParagraph, resolveDocxRunBorder, resolveDocxRunShading, resolveDocxTableStyleResolver, supportedDocxIndexEntryField, supportedDocxIndexField, supportedDocxTableOfContentsField };
|