@a3s-lab/office 0.28.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.
Files changed (69) hide show
  1. package/README.md +126 -3
  2. package/dist/0~1403.js +1 -1
  3. package/dist/0~4980.js +1 -1
  4. package/dist/0~7048.js +1 -1
  5. package/dist/{0~7043.js → 0~7231.js} +400 -242
  6. package/dist/{0~5093.js → 0~7360.js} +293 -53
  7. package/dist/0~7614.js +1 -1
  8. package/dist/0~document-editor.js +1535 -102
  9. package/dist/0~presentation-editor.js +1 -1
  10. package/dist/0~spreadsheet-editor.js +184 -36
  11. package/dist/0~work-docx-export.js +437 -11
  12. package/dist/0~work-docx-import.js +32 -7
  13. package/dist/0~work-office-diagnostics.js +170 -7
  14. package/dist/0~work-pptx-export.js +1 -1
  15. package/dist/0~work-pptx-import.js +1 -1
  16. package/dist/0~work-presentation-charts.js +1 -1
  17. package/dist/1544.js +14 -2
  18. package/dist/4104.js +31 -8
  19. package/dist/4121.js +3448 -0
  20. package/dist/6282.js +558 -1688
  21. package/dist/8715.js +1 -1
  22. package/dist/core.js +1 -1
  23. package/dist/index.js +1 -1
  24. package/dist/internal/features/work/editors/document-command-catalog.d.ts +27 -0
  25. package/dist/internal/features/work/editors/document-font-dialog-model.d.ts +8 -2
  26. package/dist/internal/features/work/editors/document-font-dialog-run-border-model.d.ts +24 -0
  27. package/dist/internal/features/work/editors/document-font-dialog-run-border-section.d.ts +10 -0
  28. package/dist/internal/features/work/editors/document-font-dialog-run-shading-model.d.ts +23 -0
  29. package/dist/internal/features/work/editors/document-font-dialog-run-shading-section.d.ts +8 -0
  30. package/dist/internal/features/work/editors/document-page-chrome-ribbon.d.ts +2 -1
  31. package/dist/internal/features/work/editors/document-proofing-dialog-model.d.ts +22 -0
  32. package/dist/internal/features/work/editors/document-proofing-dialog.d.ts +7 -0
  33. package/dist/internal/features/work/editors/document-table-of-contents-dialog.d.ts +10 -0
  34. package/dist/internal/features/work/editors/document-toolbar.d.ts +3 -1
  35. package/dist/internal/features/work/editors/spreadsheet-data-validation.d.ts +7 -1
  36. package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +2 -0
  37. package/dist/internal/features/work/work-document-character-formatting.d.ts +12 -0
  38. package/dist/internal/features/work/work-document-format-changes.d.ts +7 -0
  39. package/dist/internal/features/work/work-document-highlight.d.ts +9 -0
  40. package/dist/internal/features/work/work-document-outline.d.ts +1 -0
  41. package/dist/internal/features/work/work-document-paragraph-shading.d.ts +6 -0
  42. package/dist/internal/features/work/work-document-proofing.d.ts +19 -0
  43. package/dist/internal/features/work/work-document-run-border.d.ts +11 -0
  44. package/dist/internal/features/work/work-document-run-shading.d.ts +12 -0
  45. package/dist/internal/features/work/work-document-table-of-contents-node.d.ts +18 -0
  46. package/dist/internal/features/work/work-document-table-of-contents.d.ts +51 -0
  47. package/dist/internal/features/work/work-document-word-line-metrics.d.ts +4 -0
  48. package/dist/internal/features/work/work-docx-field-instructions.d.ts +1 -1
  49. package/dist/internal/features/work/work-docx-import.d.ts +3 -1
  50. package/dist/internal/features/work/work-docx-proofing-diagnostics.d.ts +3 -0
  51. package/dist/internal/features/work/work-docx-proofing.d.ts +38 -0
  52. package/dist/internal/features/work/work-docx-run-border-diagnostics.d.ts +3 -0
  53. package/dist/internal/features/work/work-docx-run-border-export.d.ts +17 -0
  54. package/dist/internal/features/work/work-docx-run-border.d.ts +20 -0
  55. package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +9 -0
  56. package/dist/internal/features/work/work-docx-run-shading-diagnostics.d.ts +3 -0
  57. package/dist/internal/features/work/work-docx-run-shading-export.d.ts +17 -0
  58. package/dist/internal/features/work/work-docx-run-shading.d.ts +20 -0
  59. package/dist/internal/features/work/work-docx-table-of-contents-export.d.ts +11 -0
  60. package/dist/internal/features/work/work-docx-table-of-contents-import.d.ts +15 -0
  61. package/dist/internal/features/work/work-spreadsheet-data-validation.d.ts +7 -0
  62. package/dist/internal/features/work/work-types.d.ts +9 -0
  63. package/dist/internal/kernel/office-kernel-protocol.d.ts +1 -0
  64. package/dist/office-kernel.wasm +0 -0
  65. package/dist/styles.css +339 -1
  66. package/docs/latest/en/browser-editor-architecture.md +72 -1
  67. package/package.json +15 -2
  68. package/dist/5184.js +0 -662
  69. package/dist/9424.js +0 -16
@@ -1,6 +1,6 @@
1
- import { descendants, directChildren as work_ooxml_package_directChildren, xmlNamespacePrefix, directChild, attribute as work_ooxml_package_attribute, childPath } from "./5184.js";
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";
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)=>'orphan' !== field.syntax && (!field.complete || field.nested || field.containsNested || !field.sameParagraph || field.inDeletion) || 'orphan' === field.syntax && field.inDeletion);
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 WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
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 textNodes(document.body))if (node.data.includes('__A3S_WORK_PARAGRAPH_BORDER_')) node.data = node.data.replace(PARAGRAPH_BORDER_MARKER_PATTERN, (marker)=>{
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 ?? WORD_NAMESPACE;
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 ?? WORD_NAMESPACE;
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 textNodes(root) {
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 = [];
@@ -4907,6 +5048,57 @@ function textNodes(root) {
4907
5048
  while(walker.nextNode())nodes.push(walker.currentNode);
4908
5049
  return nodes;
4909
5050
  }
5051
+ function inspectDocxRunBorder(properties, themeSource) {
5052
+ return inspectDocxRunBorderWithTheme(properties, work_docx_theme_resolveDocxThemeResolver(themeSource));
5053
+ }
5054
+ function resolveDocxRunBorder(propertySources, themeSource) {
5055
+ const theme = work_docx_theme_resolveDocxThemeResolver(themeSource);
5056
+ let border;
5057
+ let invalidCount = 0;
5058
+ let spoofedCount = 0;
5059
+ for (const properties of propertySources){
5060
+ const inspection = inspectDocxRunBorderWithTheme(properties, theme);
5061
+ spoofedCount += inspection.spoofedCount;
5062
+ if ('valid' === inspection.status) border = inspection.value;
5063
+ else if ('invalid' === inspection.status) {
5064
+ invalidCount += 1;
5065
+ border = {
5066
+ style: 'nil'
5067
+ };
5068
+ }
5069
+ }
5070
+ return {
5071
+ border,
5072
+ invalidCount,
5073
+ spoofedCount
5074
+ };
5075
+ }
5076
+ function inspectDocxRunBorderWithTheme(properties, theme) {
5077
+ if (!properties) return {
5078
+ status: 'absent',
5079
+ spoofedCount: 0
5080
+ };
5081
+ const matches = work_ooxml_package_directChildren(properties, 'bdr');
5082
+ if (!matches.length) return {
5083
+ status: 'absent',
5084
+ spoofedCount: 0
5085
+ };
5086
+ const native = matches.filter((element)=>element.namespaceURI === properties.namespaceURI);
5087
+ const spoofedCount = matches.length - native.length;
5088
+ if (1 !== matches.length || 1 !== native.length) return {
5089
+ status: 'invalid',
5090
+ spoofedCount
5091
+ };
5092
+ const parsed = normalizeDocumentRunBorder(parseDocxBorderElement(native[0], theme));
5093
+ return parsed ? {
5094
+ status: 'valid',
5095
+ value: parsed,
5096
+ spoofedCount
5097
+ } : {
5098
+ status: 'invalid',
5099
+ spoofedCount
5100
+ };
5101
+ }
4910
5102
  const work_docx_paragraph_shading_import_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
4911
5103
  const work_docx_paragraph_shading_import_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
4912
5104
  const work_docx_paragraph_shading_import_XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/';
@@ -4989,7 +5181,7 @@ function hasImportedDocxParagraphShadingMarkers(markers) {
4989
5181
  function parseDocxParagraphShadingElement(element, themeSource) {
4990
5182
  const attributes = work_docx_paragraph_shading_import_wordLeafAttributes(element, SHADING_ATTRIBUTES);
4991
5183
  const pattern = attributes?.get('val')?.trim();
4992
- if (!attributes || !DOCUMENT_PARAGRAPH_SHADING_PATTERNS.has(pattern)) return null;
5184
+ if (!attributes || !work_document_paragraph_shading_DOCUMENT_PARAGRAPH_SHADING_PATTERNS.has(pattern)) return null;
4993
5185
  const theme = work_docx_theme_resolveDocxThemeResolver(themeSource);
4994
5186
  const color = parseShadingColor(attributes, theme, {
4995
5187
  value: 'color',
@@ -5198,6 +5390,57 @@ function work_docx_paragraph_shading_import_textNodes(root) {
5198
5390
  while(walker.nextNode())nodes.push(walker.currentNode);
5199
5391
  return nodes;
5200
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
+ }
5201
5444
  function importedDocxUnderline(element, theme) {
5202
5445
  const rawStyle = work_ooxml_package_attribute(element, 'val');
5203
5446
  const style = null === rawStyle ? 'single' : normalizeDocumentUnderlineStyle(rawStyle) ?? 'single';
@@ -6875,6 +7118,7 @@ const SUPPORTED_RUN_PROPERTY_CHANGE_CHILDREN = new Set([
6875
7118
  'shadow',
6876
7119
  'emboss',
6877
7120
  'imprint',
7121
+ 'noProof',
6878
7122
  'caps',
6879
7123
  'smallCaps',
6880
7124
  'vanish',
@@ -6892,7 +7136,9 @@ const SUPPORTED_RUN_PROPERTY_CHANGE_CHILDREN = new Set([
6892
7136
  'cs',
6893
7137
  'rtl',
6894
7138
  'em',
6895
- 'vertAlign'
7139
+ 'lang',
7140
+ 'vertAlign',
7141
+ 'bdr'
6896
7142
  ]);
6897
7143
  function createImportedDocxRunFormattingMarkerState(documents) {
6898
7144
  return {
@@ -6974,6 +7220,7 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
6974
7220
  let complexFontSize;
6975
7221
  let color;
6976
7222
  let backgroundColor;
7223
+ let highlightValue;
6977
7224
  let themeColor;
6978
7225
  let themeFill;
6979
7226
  let bold;
@@ -6997,6 +7244,9 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
6997
7244
  const emphasisMark = resolveDocxEmphasisMark(propertySources);
6998
7245
  const hiddenText = resolveDocxHiddenText(propertySources);
6999
7246
  const legacyTextEffects = resolveDocxLegacyTextEffects(propertySources);
7247
+ const runBorder = resolveDocxRunBorder(propertySources, theme).border;
7248
+ const runShading = resolveDocxRunShading(propertySources, theme).shading;
7249
+ const proofing = resolveDocxProofing(propertySources);
7000
7250
  for (const properties of propertySources){
7001
7251
  bold = overriddenBoolean(bold, onOffProperty(properties, 'b'));
7002
7252
  complexBold = overriddenBoolean(complexBold, onOffProperty(properties, 'bCs'));
@@ -7045,23 +7295,10 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
7045
7295
  }
7046
7296
  const highlight = directChild(properties, 'highlight');
7047
7297
  if (highlight) {
7048
- const value = work_docx_run_formatting_import_wordAttribute(highlight, 'val')?.trim().toLowerCase();
7298
+ const value = documentHighlightFromDocxValue(work_docx_run_formatting_import_wordAttribute(highlight, 'val'));
7049
7299
  if (value) {
7050
- backgroundColor = wordHighlightColor(value);
7051
- themeFill = void 0;
7052
- }
7053
- } else {
7054
- const shading = directChild(properties, 'shd');
7055
- const fill = shading ? work_docx_run_formatting_import_wordAttribute(shading, 'fill')?.trim() : void 0;
7056
- 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;
7057
- if (themed) {
7058
- backgroundColor = `#${themed}`;
7059
- themeFill = work_docx_run_formatting_import_themeReference(shading, 'themeFill', 'themeFillTint', 'themeFillShade', backgroundColor);
7060
- } else if (fill?.toLowerCase() === 'auto') {
7061
- backgroundColor = 'transparent';
7062
- themeFill = void 0;
7063
- } else if (fill && /^[0-9a-f]{6}$/i.test(fill)) {
7064
- backgroundColor = `#${fill.toLowerCase()}`;
7300
+ highlightValue = value;
7301
+ backgroundColor = documentHighlightCssColor(value) ?? 'transparent';
7065
7302
  themeFill = void 0;
7066
7303
  }
7067
7304
  }
@@ -7146,6 +7383,9 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
7146
7383
  ...backgroundColor ? {
7147
7384
  backgroundColor
7148
7385
  } : {},
7386
+ ...highlightValue ? {
7387
+ highlight: highlightValue
7388
+ } : {},
7149
7389
  ...themeColor ? {
7150
7390
  themeColor
7151
7391
  } : {},
@@ -7154,6 +7394,18 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
7154
7394
  } : {},
7155
7395
  ...textCase ? {
7156
7396
  textCase
7397
+ } : {},
7398
+ ...runBorder ? {
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
7157
7409
  } : {}
7158
7410
  };
7159
7411
  }
@@ -7190,6 +7442,11 @@ function formattingMarkup(document, formatting) {
7190
7442
  if (void 0 !== formatting.emphasisMark) for (const [name, value] of Object.entries(documentEmphasisMarkDomAttributes(formatting.emphasisMark)))if ('style' === name) span.style.cssText += `; ${value}`;
7191
7443
  else span.setAttribute(name, value);
7192
7444
  if (void 0 !== formatting.hiddenText) for (const [name, value] of Object.entries(documentHiddenTextDomAttributes(formatting.hiddenText)))span.setAttribute(name, value);
7445
+ if (formatting.runBorder) for (const [name, value] of Object.entries(documentRunBorderDomAttributes(formatting.runBorder)))if ('style' === name) span.style.cssText += `; ${value}`;
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);
7193
7450
  const legacyTextEffects = {
7194
7451
  ...void 0 !== formatting.legacyTextOutline ? {
7195
7452
  outline: formatting.legacyTextOutline
@@ -7215,7 +7472,9 @@ function formattingMarkup(document, formatting) {
7215
7472
  if (formatting.color) span.style.color = formatting.color;
7216
7473
  const themeColor = serializeDocxThemeReference(formatting.themeColor ?? null);
7217
7474
  if (themeColor) span.dataset.officeThemeColor = themeColor;
7218
- if (formatting.backgroundColor) span.style.backgroundColor = formatting.backgroundColor;
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;
7219
7478
  const themeFill = serializeDocxThemeReference(formatting.themeFill ?? null);
7220
7479
  if (themeFill) span.dataset.officeThemeFill = themeFill;
7221
7480
  if (formatting.textCase) applyDocumentTextCaseStyle(span, formatting.textCase);
@@ -7295,7 +7554,10 @@ function importedRunFormattingChange(runProperties, paragraphProperties, styles,
7295
7554
  legacyTextOutline: beforeFormatting.legacyTextOutline,
7296
7555
  legacyTextShadow: beforeFormatting.legacyTextShadow,
7297
7556
  legacyTextEmboss: beforeFormatting.legacyTextEmboss,
7298
- legacyTextImprint: beforeFormatting.legacyTextImprint
7557
+ legacyTextImprint: beforeFormatting.legacyTextImprint,
7558
+ runBorder: serializeDocumentRunBorder(beforeFormatting.runBorder),
7559
+ runShading: serializeDocumentRunShading(beforeFormatting.runShading),
7560
+ highlight: beforeFormatting.highlight
7299
7561
  })
7300
7562
  };
7301
7563
  }
@@ -7430,32 +7692,10 @@ function work_docx_run_formatting_import_numericAttribute(element, name) {
7430
7692
  function work_docx_run_formatting_import_wordAttribute(element, name) {
7431
7693
  return work_ooxml_package_attribute(element, name) ?? work_ooxml_package_attribute(element, `w:${name}`);
7432
7694
  }
7433
- function wordHighlightColor(value) {
7434
- const colors = {
7435
- black: '#000000',
7436
- blue: '#0000ff',
7437
- cyan: '#00ffff',
7438
- darkblue: '#000080',
7439
- darkcyan: '#008080',
7440
- darkgray: '#808080',
7441
- darkgreen: '#008000',
7442
- darkmagenta: '#800080',
7443
- darkred: '#800000',
7444
- darkyellow: '#808000',
7445
- green: '#00ff00',
7446
- lightgray: '#c0c0c0',
7447
- magenta: '#ff00ff',
7448
- none: 'transparent',
7449
- red: '#ff0000',
7450
- white: '#ffffff',
7451
- yellow: '#ffff00'
7452
- };
7453
- return colors[value] ?? 'transparent';
7454
- }
7455
7695
  function work_docx_run_formatting_import_formatNumber(value) {
7456
7696
  return Number(value.toFixed(2)).toString();
7457
7697
  }
7458
7698
  function formatLineHeightFactor(value) {
7459
7699
  return Number(value.toFixed(4)).toString();
7460
7700
  }
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 };
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 };
package/dist/0~7614.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import jszip from "jszip";
2
- import { descendants, directChildren, directChild, xmlNamespacePrefix, attribute, firstDescendant, parseXml } from "./5184.js";
2
+ import { descendants, directChildren, directChild, xmlNamespacePrefix, attribute, firstDescendant, parseXml } from "./4121.js";
3
3
  import { normalizePresentationChartDataLabelPosition, normalizePresentationChartDataLabels, normalizePresentationChartSeriesStyle } from "./0~work-presentation-charts.js";
4
4
  import { parseXlsxChartSeriesStyle, xlsxChartSeriesMarkerXml, parseXlsxTrendline, isSupportedXlsxChartLegend, isSupportedXlsxChartPlotLayout, isSupportedXlsxChartSeriesFormatting, parseXlsxChartPlotLayout, parseXlsxChartLegend, xlsxChartSeriesShapePropertiesXml, parseXlsxErrorBars } from "./4104.js";
5
5
  import { workSpreadsheetChartSupportsErrorBars, workSpreadsheetChartSupportsGrouping, normalizeWorkSpreadsheetChartSmoothLines, workSpreadsheetChartSupportsSeriesAnalysis, normalizeWorkSpreadsheetChartSeriesStyle, normalizeWorkSpreadsheetErrorBars, normalizeWorkSpreadsheetChartOverlap, workSpreadsheetChartUsesNumericXAxis, workSpreadsheetChartSupportsBarSpacing, normalizeWorkSpreadsheetChartLegendOverlay, normalizeWorkSpreadsheetChartGapWidth, normalizeWorkSpreadsheetChartGrouping, workSpreadsheetChartSupportsTrendlines, workSpreadsheetChartSupportsSmoothLines, normalizeWorkSpreadsheetTrendline } from "./8715.js";