@a3s-lab/office 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +89 -2
  2. package/dist/0~4595.js +16 -2
  3. package/dist/0~5093.js +563 -201
  4. package/dist/0~6090.js +77 -77
  5. package/dist/{0~2805.js → 0~7043.js} +305 -2
  6. package/dist/0~document-editor.js +2633 -976
  7. package/dist/0~spreadsheet-editor.js +1324 -378
  8. package/dist/0~work-docx-export.js +737 -17
  9. package/dist/0~work-docx-import.js +173 -98
  10. package/dist/0~work-office-diagnostics.js +250 -5
  11. package/dist/{164.js → 1544.js} +1083 -785
  12. package/dist/4104.js +145 -29
  13. package/dist/5184.js +13 -0
  14. package/dist/6282.js +1898 -345
  15. package/dist/core.js +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/internal/features/work/editors/document-command-catalog.d.ts +102 -0
  18. package/dist/internal/features/work/editors/document-font-dialog-model.d.ts +111 -0
  19. package/dist/internal/features/work/editors/document-font-dialog-script-font-model.d.ts +18 -0
  20. package/dist/internal/features/work/editors/document-font-dialog.d.ts +9 -0
  21. package/dist/internal/features/work/editors/document-home-ribbon.d.ts +2 -1
  22. package/dist/internal/features/work/editors/document-page-chrome-editor.d.ts +6 -0
  23. package/dist/internal/features/work/editors/document-page-chrome-ribbon.d.ts +2 -1
  24. package/dist/internal/features/work/editors/document-strike-ribbon.d.ts +7 -0
  25. package/dist/internal/features/work/editors/document-text-case-ribbon.d.ts +4 -0
  26. package/dist/internal/features/work/editors/document-toolbar.d.ts +3 -1
  27. package/dist/internal/features/work/editors/document-underline-ribbon.d.ts +9 -0
  28. package/dist/internal/features/work/editors/document-wps-shortcuts.d.ts +1 -0
  29. package/dist/internal/features/work/editors/spreadsheet-cell-fill-format.d.ts +11 -0
  30. package/dist/internal/features/work/editors/spreadsheet-cell-format.d.ts +2 -1
  31. package/dist/internal/features/work/editors/spreadsheet-format-cells-dialog-model.d.ts +13 -2
  32. package/dist/internal/features/work/editors/spreadsheet-format-cells-fill-panel.d.ts +13 -0
  33. package/dist/internal/features/work/editors/spreadsheet-format-cells-fill-preview.d.ts +6 -0
  34. package/dist/internal/features/work/editors/spreadsheet-format-painter.d.ts +1 -1
  35. package/dist/internal/features/work/editors/work-office-chrome.d.ts +9 -1
  36. package/dist/internal/features/work/work-document-character-formatting.d.ts +16 -1
  37. package/dist/internal/features/work/work-document-character-position.d.ts +9 -0
  38. package/dist/internal/features/work/work-document-character-scale.d.ts +8 -0
  39. package/dist/internal/features/work/work-document-character-spacing.d.ts +8 -0
  40. package/dist/internal/features/work/work-document-emphasis.d.ts +7 -0
  41. package/dist/internal/features/work/work-document-equations.d.ts +2 -1
  42. package/dist/internal/features/work/work-document-format-changes.d.ts +20 -2
  43. package/dist/internal/features/work/work-document-hidden-text.d.ts +5 -0
  44. package/dist/internal/features/work/work-document-kerning.d.ts +10 -0
  45. package/dist/internal/features/work/work-document-legacy-text-effects.d.ts +27 -0
  46. package/dist/internal/features/work/work-document-script-font-extension.d.ts +2 -0
  47. package/dist/internal/features/work/work-document-script-fonts.d.ts +51 -0
  48. package/dist/internal/features/work/work-document-strike.d.ts +21 -0
  49. package/dist/internal/features/work/work-document-text-case.d.ts +10 -0
  50. package/dist/internal/features/work/work-document-underline.d.ts +37 -0
  51. package/dist/internal/features/work/work-document-word-line-metrics.d.ts +16 -0
  52. package/dist/internal/features/work/work-docx-character-position.d.ts +2 -0
  53. package/dist/internal/features/work/work-docx-character-scale.d.ts +2 -0
  54. package/dist/internal/features/work/work-docx-character-spacing.d.ts +4 -0
  55. package/dist/internal/features/work/work-docx-emphasis-diagnostics.d.ts +3 -0
  56. package/dist/internal/features/work/work-docx-emphasis.d.ts +14 -0
  57. package/dist/internal/features/work/work-docx-hidden-text-diagnostics.d.ts +3 -0
  58. package/dist/internal/features/work/work-docx-hidden-text-export.d.ts +17 -0
  59. package/dist/internal/features/work/work-docx-hidden-text.d.ts +11 -0
  60. package/dist/internal/features/work/work-docx-kerning-diagnostics.d.ts +3 -0
  61. package/dist/internal/features/work/work-docx-kerning.d.ts +14 -0
  62. package/dist/internal/features/work/work-docx-legacy-text-effects-diagnostics.d.ts +3 -0
  63. package/dist/internal/features/work/work-docx-legacy-text-effects-export.d.ts +18 -0
  64. package/dist/internal/features/work/work-docx-legacy-text-effects.d.ts +12 -0
  65. package/dist/internal/features/work/work-docx-run-fonts-diagnostics.d.ts +3 -0
  66. package/dist/internal/features/work/work-docx-run-fonts-export.d.ts +14 -0
  67. package/dist/internal/features/work/work-docx-run-fonts.d.ts +13 -0
  68. package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +27 -2
  69. package/dist/internal/features/work/work-docx-run-property-order.d.ts +2 -0
  70. package/dist/internal/features/work/work-docx-run-script-font-import.d.ts +9 -0
  71. package/dist/internal/features/work/work-docx-strike.d.ts +8 -0
  72. package/dist/internal/features/work/work-docx-theme-reference.d.ts +1 -1
  73. package/dist/internal/features/work/work-docx-twips.d.ts +6 -0
  74. package/dist/internal/features/work/work-docx-underline.d.ts +3 -0
  75. package/dist/internal/features/work/work-spreadsheet-gradient-fill-canvas.d.ts +10 -0
  76. package/dist/internal/features/work/work-spreadsheet-native-fill-canvas.d.ts +8 -0
  77. package/dist/internal/features/work/work-spreadsheet-pattern-fill-canvas.d.ts +8 -0
  78. package/dist/internal/features/work/work-xlsx-cell-style-origin.d.ts +2 -1
  79. package/dist/internal/features/work/work-xlsx-cell-style-writer.d.ts +3 -0
  80. package/dist/internal/features/work/work-xlsx-cell-styles.d.ts +4 -0
  81. package/dist/internal/features/work/work-xlsx-gradient-fill.d.ts +31 -0
  82. package/dist/internal/features/work/work-xlsx-native-fill.d.ts +17 -0
  83. package/dist/internal/features/work/work-xlsx-pattern-fill.d.ts +21 -0
  84. package/dist/office-kernel.wasm +0 -0
  85. package/dist/styles.css +809 -78
  86. package/docs/latest/en/browser-editor-architecture.md +24 -0
  87. package/package.json +35 -1
@@ -1,8 +1,8 @@
1
1
  import jszip from "jszip";
2
- import { contentTypeForPart, directChildren, bytesToDataUrl, OoxmlPackage, firstDescendant, descendants, directChild, attribute } from "./5184.js";
3
- import { normalizeDocumentBookmarkName, documentInitialSectionLayout, normalizeDocumentFieldsHtml, applyDocumentImageIdentityToElement, renderDocumentTableCellMarginOverrides, documentCaptionLabel, documentTableBordersFromElement, isContourImageLayout, normalizeDocumentCitationsHtml, createDocumentImageIdentityRegistry, normalizeDocumentColumns, normalizeDocumentImageIdentity, normalizeDocumentImageWrapSide, applyDocumentParagraphIdentityToElement, docxDocumentFieldKind, serializeDocxThemeReference, renderDocumentTableBorders, docxBookmarkReferenceTarget, normalizeDocumentImagePosition, wrapsBesideImage, documentPageChromeLegacyFields, normalizeDocumentImageWrapContour, documentParagraphShadingDomAttributes, normalizeDocumentBookmarksHtml, documentParagraphBordersDomAttributes, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, applyDocumentTableRowIdentityToElement, normalizeDocumentCaptionsHtml, normalizeDocumentParagraphIdentity, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, DEFAULT_DOCUMENT_TABLE_GEOMETRY, documentSectionDomAttributes, documentPageMarginBody, normalizeDocumentImageAlignment, normalizeDocumentParagraphId, applyDocumentImageLayerToElement, normalizeDocumentBookmarkNativeId, normalizeDocumentTableRowIdentity, uniqueDocumentImageIdentity, normalizeDocumentBookmarkReferencesHtml, documentCitationTagsFromInstruction, applyDocumentImageWrapContourToElement, normalizeDocumentNotesHtml, applyDocumentTableGeometryToElement, normalizeDocumentImageCrop, normalizeDocumentPageChrome, normalizeDocumentImageLayoutOptions, applyDocumentImageCropToElement, documentPageMarginsForLayout, applyDocumentPageGeometry, documentContentLayoutProperties, createDocumentNoteElement, normalizeDocumentImageLayer, DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, documentBookmarkReferenceInstruction } from "./6282.js";
4
- import { markDocxParagraphFormattingChanges, markDocxParagraphIndents, parseDocxPageGeometry, parseDocxPageBorders, docxCaptionReferenceTarget, applyImportedDocxEquationMarkers, hasImportedDocxParagraphPaginationMarkers, createDocxTableStyleResolver, applyImportedDocxParagraphSpacingMarkers, hasImportedDocxParagraphShadingMarkers, hasImportedDocxParagraphDirectionMarkers, isDocxEquationLikeRoot, inspectDocxPageMarginSettings, applyImportedDocxParagraphFormattingChangeMarkers, hasImportedDocxParagraphTabStopMarkers, hasImportedDocxRunFormattingMarkers, hasImportedDocxParagraphIndentMarkers, docxCaptionSequenceKind, resolveDocxParagraphBordersForParagraph, applyImportedDocxRunFormattingMarkers, markDocxParagraphAlignments, markDocxParagraphDirections, applyImportedDocxParagraphShadingMarkers, markDocxParagraphSpacing, hasImportedDocxParagraphBorderMarkers, hasImportedDocxParagraphFormattingChangeMarkers, docxCaptionBookmark, docxFieldResultText, createDocxParagraphStyleResolver, docxEquationHtml, docxFieldOccurrences, hasImportedDocxParagraphAlignmentMarkers, markDocxParagraphTabStops, applyImportedDocxParagraphIndentMarkers, resolveDocxTableStyleResolver, applyImportedDocxParagraphDirectionMarkers, docxTableCellStyleLayers, applyImportedDocxParagraphAlignmentMarkers, markDocxParagraphPagination, markDocxParagraphBorders, markDocxRunFormatting, applyImportedDocxParagraphTabStopMarkers, docxFieldOccurrenceIsInlineEditable, applyImportedDocxParagraphBorderMarkers, applyImportedDocxParagraphPaginationMarkers, parseDocxPaperSource, hasImportedDocxParagraphSpacingMarkers, docxTablePropertySources, parseDirectDocxParagraphShading, parseDocxPageMargins, markDocxParagraphShading, markDocxPackageEquations } from "./0~5093.js";
5
- import { xmlAttributeLocalName, readDocxBibliography, createDocxThemeResolver, docxThemeColor, parseDocxParagraphDefaultCollapsed, resolveDocxThemeResolver, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace } from "./0~2805.js";
2
+ import { contentTypeForPart, directChildren, bytesToDataUrl, OoxmlPackage, firstDescendant, descendants, directChild, attribute as work_ooxml_package_attribute } from "./5184.js";
3
+ import { normalizeDocumentBookmarkName, renderDocumentTableCellMarginOverrides, applyDocumentImageIdentityToElement, documentCharacterPositionDomAttributes, createDocumentImageIdentityRegistry, normalizeDocumentColumns, documentStrikeDomAttributes, normalizeDocumentImageWrapContour, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, normalizeDocumentBookmarksHtml, applyDocumentTableRowIdentityToElement, normalizeDocumentCaptionsHtml, documentCharacterSpacingDomAttributes, normalizeDocumentImageAlignment, normalizeDocumentParagraphId, applyDocumentImageLayerToElement, normalizeDocumentNotesHtml, normalizeDocumentBookmarkReferencesHtml, documentCitationTagsFromInstruction, applyDocumentImageWrapContourToElement, documentUnderlineDomAttributes, documentHiddenTextDomAttributes, normalizeDocumentPageChrome, normalizeDocumentImageLayoutOptions, applyDocumentImageCropToElement, documentPageMarginsForLayout, applyDocumentPageGeometry, createDocumentNoteElement, normalizeDocumentImageLayer, DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, documentBookmarkReferenceInstruction, documentInitialSectionLayout, normalizeDocumentFieldsHtml, documentCaptionLabel, documentTableBordersFromElement, isContourImageLayout, normalizeDocumentCitationsHtml, normalizeDocumentImageIdentity, normalizeDocumentImageWrapSide, applyDocumentParagraphIdentityToElement, documentKerningDomAttributes, docxDocumentFieldKind, serializeDocxThemeReference, renderDocumentTableBorders, docxBookmarkReferenceTarget, normalizeDocumentImagePosition, wrapsBesideImage, documentPageChromeLegacyFields, documentParagraphShadingDomAttributes, documentCharacterScaleDomAttributes, documentParagraphBordersDomAttributes, DEFAULT_DOCUMENT_TABLE_GEOMETRY, documentSectionDomAttributes, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, normalizeDocumentParagraphIdentity, documentPageMarginBody, documentLegacyTextEffectsDomAttributes, normalizeDocumentTableRowIdentity, normalizeDocumentBookmarkNativeId, uniqueDocumentImageIdentity, applyDocumentTableGeometryToElement, normalizeDocumentImageCrop, documentContentLayoutProperties, documentEmphasisMarkDomAttributes } from "./6282.js";
4
+ import { markDocxRunFormattingIntoState, applyImportedDocxParagraphSpacingMarkers, hasImportedDocxParagraphDirectionMarkers, hasImportedDocxParagraphIndentMarkers, resolveDocxParagraphBordersForParagraph, applyImportedDocxParagraphShadingMarkers, markDocxParagraphSpacing, docxCaptionBookmark, docxFieldResultText, createDocxParagraphStyleResolver, docxTableCellStyleLayers, createImportedDocxRunFormattingMarkerState, parseDocxPaperSource, resolveDocxLegacyTextEffects, hasImportedDocxParagraphSpacingMarkers, docxTablePropertySources, parseDocxPageMargins, parseDirectDocxParagraphShading, markDocxPackageEquations, parseDocxPageGeometry, markDocxParagraphIndents, docxCaptionReferenceTarget, applyImportedDocxEquationMarkers, hasImportedDocxParagraphPaginationMarkers, createDocxTableStyleResolver, hasImportedDocxParagraphShadingMarkers, isDocxEquationLikeRoot, importedDocxStrike, docxTableRunPropertySources, inspectDocxPageMarginSettings, hasImportedDocxRunFormattingMarkers, applyImportedDocxParagraphFormattingChangeMarkers, hasImportedDocxParagraphTabStopMarkers, docxCaptionSequenceKind, applyImportedDocxRunFormattingMarkers, markDocxParagraphAlignments, markDocxParagraphDirections, hasImportedDocxParagraphBorderMarkers, hasImportedDocxParagraphFormattingChangeMarkers, resolveDocxHiddenText, docxEquationHtml, docxFieldOccurrences, hasImportedDocxParagraphAlignmentMarkers, markDocxParagraphTabStops, applyImportedDocxParagraphIndentMarkers, resolveDocxTableStyleResolver, applyImportedDocxParagraphTabStopMarkers, applyImportedDocxParagraphDirectionMarkers, applyImportedDocxParagraphAlignmentMarkers, importedDocxUnderline, markDocxParagraphBorders, markDocxParagraphPagination, docxFieldOccurrenceIsInlineEditable, applyImportedDocxParagraphBorderMarkers, applyImportedDocxParagraphPaginationMarkers, docxRunPropertySources, markDocxParagraphFormattingChanges, markDocxParagraphShading, parseDocxPageBorders } from "./0~5093.js";
5
+ import { readDocxBibliography, XMLNS_NAMESPACE, docxCharacterScalePercentFromProperties, docxCharacterSpacingTwipsFromProperties, parseBoundedDocxInteger, xmlAttributeLocalName, resolveDocxEmphasisMark, createDocxThemeResolver, docxCharacterPositionHalfPointsFromProperties, docxThemeColor, parseDocxParagraphDefaultCollapsed, resolveDocxKerningThresholdHalfPoints, resolveDocxThemeResolver, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace } from "./0~7043.js";
6
6
  import { importDocxPageColor, importedDocumentNoteId } from "./0~4980.js";
7
7
  const WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
8
8
  const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
@@ -10,7 +10,7 @@ const MAX_BOOKMARK_NAME_LENGTH = 40;
10
10
  const MAX_BOOKMARK_NATIVE_ID = 0x7fffffff;
11
11
  function markDocxBookmarks(document) {
12
12
  const captionBookmarks = captionBookmarkStarts(document);
13
- const captionNames = new Set(Array.from(captionBookmarks).map((bookmark)=>attribute(bookmark, 'name')?.trim().toLowerCase()).filter((name)=>Boolean(name)));
13
+ const captionNames = new Set(Array.from(captionBookmarks).map((bookmark)=>work_ooxml_package_attribute(bookmark, 'name')?.trim().toLowerCase()).filter((name)=>Boolean(name)));
14
14
  const pairs = docxBookmarkPairs(document).filter((pair)=>!captionBookmarks.has(pair.start) && '_GoBack' !== pair.sourceName);
15
15
  const names = new Set();
16
16
  const normalizedNames = new Map();
@@ -96,19 +96,19 @@ function docxBookmarkPairs(document) {
96
96
  const pairs = [];
97
97
  for (const element of Array.from(document.getElementsByTagName('*'))){
98
98
  if ('bookmarkStart' === element.localName) {
99
- const id = attribute(element, 'id')?.trim() ?? '';
99
+ const id = work_ooxml_package_attribute(element, 'id')?.trim() ?? '';
100
100
  const stack = open.get(id) ?? [];
101
101
  stack.push(element);
102
102
  open.set(id, stack);
103
103
  continue;
104
104
  }
105
105
  if ('bookmarkEnd' !== element.localName) continue;
106
- const id = attribute(element, 'id')?.trim() ?? '';
106
+ const id = work_ooxml_package_attribute(element, 'id')?.trim() ?? '';
107
107
  const start = open.get(id)?.pop();
108
108
  if (start) pairs.push({
109
109
  start,
110
110
  end: element,
111
- sourceName: attribute(start, 'name')?.trim() ?? '',
111
+ sourceName: work_ooxml_package_attribute(start, 'name')?.trim() ?? '',
112
112
  sourceNativeId: id
113
113
  });
114
114
  }
@@ -287,7 +287,7 @@ function markDocxCaptionFields(document) {
287
287
  })).find((item)=>Boolean(item.kind));
288
288
  if (!sequence) continue;
289
289
  const bookmark = docxCaptionBookmark(paragraph, sequence.field);
290
- const bookmarkName = attribute(bookmark ?? paragraph, 'name')?.trim() ?? '';
290
+ const bookmarkName = work_ooxml_package_attribute(bookmark ?? paragraph, 'name')?.trim() ?? '';
291
291
  const id = uniqueCaptionId(bookmarkName, sequence.kind, captions.length + 1, captions);
292
292
  if (bookmarkName) bookmarkTargets.set(bookmarkName, id);
293
293
  const marker = captionMarker(captions.length + 1, id, sequence.kind);
@@ -442,13 +442,13 @@ function markDocxTextChanges(document) {
442
442
  if (!revisionText(revision, kind)) continue;
443
443
  if ('deletion' === kind) convertDeletedText(document, revision);
444
444
  const index = changes.length + 1;
445
- const sourceId = attribute(revision, 'id')?.trim() ?? '';
445
+ const sourceId = work_ooxml_package_attribute(revision, 'id')?.trim() ?? '';
446
446
  const id = uniqueChangeId(sourceId ? `docx-change-${sourceId}` : `docx-change-${index}`, changes);
447
447
  const marker = {
448
448
  id,
449
449
  kind,
450
- author: attribute(revision, 'author')?.trim() || '未知审阅者',
451
- date: normalizeDate(attribute(revision, 'date')),
450
+ author: work_ooxml_package_attribute(revision, 'author')?.trim() || '未知审阅者',
451
+ date: normalizeDate(work_ooxml_package_attribute(revision, 'date')),
452
452
  start: `__A3S_WORK_CHANGE_START_${index}__`,
453
453
  end: `__A3S_WORK_CHANGE_END_${index}__`
454
454
  };
@@ -712,7 +712,7 @@ function importDocxColumns(element, fallback) {
712
712
  const columnElements = directChildren(element, 'col');
713
713
  const sourceCount = numberAttribute(element, 'num') || columnElements.length || fallback.count;
714
714
  const count = Math.min(6, Math.max(1, sourceCount));
715
- const spacingAttribute = attribute(element, 'space');
715
+ const spacingAttribute = work_ooxml_package_attribute(element, 'space');
716
716
  const spacing = null === spacingAttribute ? fallback.spacing : twipsToMillimeters(Number(spacingAttribute), fallback.spacing);
717
717
  const base = {
718
718
  count,
@@ -724,7 +724,7 @@ function importDocxColumns(element, fallback) {
724
724
  ...base,
725
725
  count: Math.min(count, columnElements.length),
726
726
  custom: columnElements.slice(0, count).map((column, index)=>{
727
- const columnSpacing = attribute(column, 'space');
727
+ const columnSpacing = work_ooxml_package_attribute(column, 'space');
728
728
  return {
729
729
  widthPercent: Math.max(1, numberAttribute(column, 'w')),
730
730
  spacing: index === Math.min(count, columnElements.length) - 1 ? 0 : null === columnSpacing ? spacing : twipsToMillimeters(Number(columnSpacing), spacing)
@@ -733,11 +733,11 @@ function importDocxColumns(element, fallback) {
733
733
  });
734
734
  }
735
735
  function numberAttribute(element, name) {
736
- const value = Number(attribute(element, name));
736
+ const value = Number(work_ooxml_package_attribute(element, name));
737
737
  return Number.isFinite(value) ? value : 0;
738
738
  }
739
739
  function enabledAttribute(element, name) {
740
- const value = attribute(element, name)?.toLowerCase();
740
+ const value = work_ooxml_package_attribute(element, name)?.toLowerCase();
741
741
  return '1' === value || 'true' === value || 'on' === value;
742
742
  }
743
743
  function twipsToMillimeters(value, fallback) {
@@ -763,9 +763,9 @@ async function markDocxComments(document, archive) {
763
763
  const comments = [];
764
764
  const starts = descendants(document, 'commentRangeStart').sort(work_docx_comment_import_compareDocumentOrder);
765
765
  for (const start of starts){
766
- const sourceId = attribute(start, 'id')?.trim() ?? '';
766
+ const sourceId = work_ooxml_package_attribute(start, 'id')?.trim() ?? '';
767
767
  if (!sourceId) continue;
768
- const end = descendants(document, 'commentRangeEnd').find((candidate)=>attribute(candidate, 'id') === sourceId && Boolean(start.compareDocumentPosition(candidate) & Node.DOCUMENT_POSITION_FOLLOWING));
768
+ const end = descendants(document, 'commentRangeEnd').find((candidate)=>work_ooxml_package_attribute(candidate, 'id') === sourceId && Boolean(start.compareDocumentPosition(candidate) & Node.DOCUMENT_POSITION_FOLLOWING));
769
769
  if (!end?.parentNode || !start.parentNode) continue;
770
770
  const workId = workIds.get(sourceId) ?? uniqueWorkCommentId(`docx-comment-${sourceId}`, comments);
771
771
  if (!workIds.has(sourceId)) {
@@ -782,7 +782,7 @@ async function markDocxComments(document, archive) {
782
782
  end.parentNode.insertBefore(work_docx_comment_import_markerRun(document, range.end), end.nextSibling);
783
783
  start.remove();
784
784
  end.remove();
785
- for (const reference of descendants(document, 'commentReference').filter((candidate)=>attribute(candidate, 'id') === sourceId))reference.remove();
785
+ for (const reference of descendants(document, 'commentReference').filter((candidate)=>work_ooxml_package_attribute(candidate, 'id') === sourceId))reference.remove();
786
786
  ranges.push(range);
787
787
  }
788
788
  return {
@@ -806,12 +806,12 @@ async function readCommentDefinitions(archive) {
806
806
  const extended = await readCommentExtended(archive);
807
807
  return descendants(document, 'comment').map((comment)=>{
808
808
  const paragraphs = descendants(comment, 'p');
809
- const paraId = attribute(paragraphs.at(-1) ?? comment, 'paraId')?.trim() ?? '';
809
+ const paraId = work_ooxml_package_attribute(paragraphs.at(-1) ?? comment, 'paraId')?.trim() ?? '';
810
810
  const metadata = extended.get(paraId);
811
811
  return {
812
- sourceId: attribute(comment, 'id')?.trim() ?? '',
813
- author: attribute(comment, 'author')?.trim() || '未知审阅者',
814
- date: work_docx_comment_import_normalizeDate(attribute(comment, 'date')),
812
+ sourceId: work_ooxml_package_attribute(comment, 'id')?.trim() ?? '',
813
+ author: work_ooxml_package_attribute(comment, 'author')?.trim() || '未知审阅者',
814
+ date: work_docx_comment_import_normalizeDate(work_ooxml_package_attribute(comment, 'date')),
815
815
  text: commentText(comment),
816
816
  paraId,
817
817
  parentParaId: metadata?.parentParaId ?? '',
@@ -823,12 +823,12 @@ async function readCommentExtended(archive) {
823
823
  if (!archive.has('word/commentsExtended.xml')) return new Map();
824
824
  const document = await archive.xml('word/commentsExtended.xml');
825
825
  return new Map(descendants(document, 'commentEx').map((comment)=>{
826
- const paraId = attribute(comment, 'paraId')?.trim() ?? '';
826
+ const paraId = work_ooxml_package_attribute(comment, 'paraId')?.trim() ?? '';
827
827
  return [
828
828
  paraId,
829
829
  {
830
- parentParaId: attribute(comment, 'paraIdParent')?.trim() ?? '',
831
- resolved: '1' === attribute(comment, 'done') || 'true' === attribute(comment, 'done')
830
+ parentParaId: work_ooxml_package_attribute(comment, 'paraIdParent')?.trim() ?? '',
831
+ resolved: '1' === work_ooxml_package_attribute(comment, 'done') || 'true' === work_ooxml_package_attribute(comment, 'done')
832
832
  }
833
833
  ];
834
834
  }).filter(([paraId])=>Boolean(paraId)));
@@ -1156,7 +1156,7 @@ function anchorWrapDistance(anchor, layout) {
1156
1156
  return distance / EMUS_PER_MILLIMETER;
1157
1157
  }
1158
1158
  function anchorWrapSide(anchor, layout) {
1159
- return normalizeDocumentImageWrapSide(attribute(anchorWrapElement(anchor, layout) ?? anchor, 'wrapText'));
1159
+ return normalizeDocumentImageWrapSide(work_ooxml_package_attribute(anchorWrapElement(anchor, layout) ?? anchor, 'wrapText'));
1160
1160
  }
1161
1161
  function anchorWrapElement(anchor, layout) {
1162
1162
  if ('square' === layout) return directChild(anchor, 'wrapSquare');
@@ -1172,10 +1172,10 @@ function anchorWrapContour(anchor, layout) {
1172
1172
  const vertices = directChildren(polygon);
1173
1173
  if (vertices[0]?.localName !== 'start' || vertices.slice(1).some((element)=>'lineTo' !== element.localName)) return null;
1174
1174
  return normalizeDocumentImageWrapContour({
1175
- edited: attribute(polygon, 'edited'),
1175
+ edited: work_ooxml_package_attribute(polygon, 'edited'),
1176
1176
  points: vertices.map((point)=>({
1177
- x: attribute(point, 'x'),
1178
- y: attribute(point, 'y')
1177
+ x: work_ooxml_package_attribute(point, 'x'),
1178
+ y: work_ooxml_package_attribute(point, 'y')
1179
1179
  }))
1180
1180
  });
1181
1181
  }
@@ -1188,8 +1188,8 @@ function anchorPosition(anchor) {
1188
1188
  return normalizeDocumentImagePosition({
1189
1189
  horizontalOffset,
1190
1190
  verticalOffset,
1191
- horizontalReference: horizontal ? attribute(horizontal, 'relativeFrom') : null,
1192
- verticalReference: vertical ? attribute(vertical, 'relativeFrom') : null
1191
+ horizontalReference: horizontal ? work_ooxml_package_attribute(horizontal, 'relativeFrom') : null,
1192
+ verticalReference: vertical ? work_ooxml_package_attribute(vertical, 'relativeFrom') : null
1193
1193
  });
1194
1194
  }
1195
1195
  function anchorCrop(anchor) {
@@ -1204,7 +1204,7 @@ function anchorCrop(anchor) {
1204
1204
  }
1205
1205
  function anchorLayer(anchor) {
1206
1206
  return normalizeDocumentImageLayer({
1207
- relativeHeight: attribute(anchor, 'relativeHeight'),
1207
+ relativeHeight: work_ooxml_package_attribute(anchor, 'relativeHeight'),
1208
1208
  behindDocument: anchorBooleanAttribute(anchor, 'behindDoc', false),
1209
1209
  allowOverlap: anchorBooleanAttribute(anchor, 'allowOverlap', false),
1210
1210
  layoutInCell: anchorBooleanAttribute(anchor, 'layoutInCell', true),
@@ -1214,13 +1214,13 @@ function anchorLayer(anchor) {
1214
1214
  function drawingIdentitySource(anchor) {
1215
1215
  const properties = directChild(anchor, 'docPr');
1216
1216
  return {
1217
- docPropertiesId: properties ? attribute(properties, 'id') : null,
1218
- anchorId: attribute(anchor, 'anchorId'),
1219
- editId: attribute(anchor, 'editId')
1217
+ docPropertiesId: properties ? work_ooxml_package_attribute(properties, 'id') : null,
1218
+ anchorId: work_ooxml_package_attribute(anchor, 'anchorId'),
1219
+ editId: work_ooxml_package_attribute(anchor, 'editId')
1220
1220
  };
1221
1221
  }
1222
1222
  function cropPercentage(source, name) {
1223
- const value = attribute(source, name)?.trim() ?? '';
1223
+ const value = work_ooxml_package_attribute(source, name)?.trim() ?? '';
1224
1224
  if (!value) return 0;
1225
1225
  const number = Number(value.endsWith('%') ? value.slice(0, -1) : value);
1226
1226
  if (!Number.isFinite(number)) return 0;
@@ -1267,14 +1267,14 @@ function applyImageLayout(image, options, position, crop, contour, layer, identi
1267
1267
  if (layer) applyDocumentImageLayerToElement(image, layer);
1268
1268
  }
1269
1269
  function anchorBooleanAttribute(element, name, fallback) {
1270
- const value = attribute(element, name)?.trim().toLowerCase();
1270
+ const value = work_ooxml_package_attribute(element, name)?.trim().toLowerCase();
1271
1271
  if ('1' === value || 'true' === value || 'on' === value) return true;
1272
1272
  if ('0' === value || 'false' === value || 'off' === value) return false;
1273
1273
  return fallback;
1274
1274
  }
1275
1275
  function numericAttribute(element, name) {
1276
1276
  if (!element) return null;
1277
- const source = attribute(element, name);
1277
+ const source = work_ooxml_package_attribute(element, name);
1278
1278
  if (null === source || !source.trim()) return null;
1279
1279
  const value = Number(source);
1280
1280
  return Number.isFinite(value) && value >= 0 ? value : null;
@@ -1486,14 +1486,14 @@ function insertParagraphMarker(document, paragraph, marker) {
1486
1486
  }
1487
1487
  function integerAttribute(element, name) {
1488
1488
  if (!element) return null;
1489
- const source = attribute(element, name) ?? (name.includes(':') ? null : attribute(element, `w:${name}`));
1489
+ const source = work_ooxml_package_attribute(element, name) ?? (name.includes(':') ? null : work_ooxml_package_attribute(element, `w:${name}`));
1490
1490
  if (null === source) return null;
1491
1491
  const value = Number(source);
1492
1492
  return Number.isSafeInteger(value) && value >= 0 ? value : null;
1493
1493
  }
1494
1494
  function signedIntegerAttribute(element, name) {
1495
1495
  if (!element) return null;
1496
- const source = attribute(element, name) ?? (name.includes(':') ? null : attribute(element, `w:${name}`));
1496
+ const source = work_ooxml_package_attribute(element, name) ?? (name.includes(':') ? null : work_ooxml_package_attribute(element, `w:${name}`));
1497
1497
  if (null === source) return null;
1498
1498
  const value = Number(source);
1499
1499
  return Number.isSafeInteger(value) ? value : null;
@@ -1503,12 +1503,12 @@ function setOptionalDataset(element, key, value) {
1503
1503
  }
1504
1504
  function stringAttribute(element, name) {
1505
1505
  if (!element) return null;
1506
- const value = attribute(element, name) ?? (name.includes(':') ? null : attribute(element, `w:${name}`));
1506
+ const value = work_ooxml_package_attribute(element, name) ?? (name.includes(':') ? null : work_ooxml_package_attribute(element, `w:${name}`));
1507
1507
  return value?.trim() || null;
1508
1508
  }
1509
1509
  function rawStringAttribute(element, name) {
1510
1510
  if (!element) return null;
1511
- return attribute(element, name) ?? (name.includes(':') ? null : attribute(element, `w:${name}`));
1511
+ return work_ooxml_package_attribute(element, name) ?? (name.includes(':') ? null : work_ooxml_package_attribute(element, `w:${name}`));
1512
1512
  }
1513
1513
  function work_docx_list_import_textNodes(root) {
1514
1514
  const document = root.ownerDocument;
@@ -1658,8 +1658,8 @@ async function importVariant(section, variant, archive, documentRelationships, f
1658
1658
  };
1659
1659
  }
1660
1660
  async function importReferencedPart(section, referenceName, variant, archive, documentRelationships) {
1661
- const reference = directChildren(section, referenceName).find((element)=>(attribute(element, 'type') ?? 'default') === variant);
1662
- const relationship = documentRelationships.get(attribute(reference ?? section, 'r:id') ?? '');
1661
+ const reference = directChildren(section, referenceName).find((element)=>(work_ooxml_package_attribute(element, 'type') ?? 'default') === variant);
1662
+ const relationship = documentRelationships.get(work_ooxml_package_attribute(reference ?? section, 'r:id') ?? '');
1663
1663
  if (!relationship || 'External' === relationship.targetMode || !archive.has(relationship.target)) return null;
1664
1664
  const document = await archive.xml(relationship.target);
1665
1665
  return {
@@ -1687,7 +1687,15 @@ async function pageChromePartHtml(document, archive, partPath) {
1687
1687
  }
1688
1688
  async function paragraphHtml(paragraph, archive, relationships, theme, paragraphStyles, tableStyles) {
1689
1689
  const properties = directChild(paragraph, 'pPr');
1690
- const alignmentValue = attribute(firstDescendant(properties, 'jc') ?? paragraph, 'val');
1690
+ const runContext = {
1691
+ archive,
1692
+ relationships,
1693
+ theme,
1694
+ paragraphProperties: properties,
1695
+ paragraphStyles,
1696
+ tableStyles
1697
+ };
1698
+ const alignmentValue = work_ooxml_package_attribute(firstDescendant(properties, 'jc') ?? paragraph, 'val');
1691
1699
  const alignment = 'center' === alignmentValue ? 'center' : 'right' === alignmentValue || 'end' === alignmentValue ? 'right' : 'both' === alignmentValue || 'distribute' === alignmentValue ? 'justify' : 'left' === alignmentValue || 'start' === alignmentValue ? 'left' : '';
1692
1700
  const field = {
1693
1701
  active: false,
@@ -1702,19 +1710,19 @@ async function paragraphHtml(paragraph, archive, relationships, theme, paragraph
1702
1710
  continue;
1703
1711
  }
1704
1712
  if ('hyperlink' === child.localName) {
1705
- const content = await containerRunsHtml(child, field, archive, relationships);
1706
- const relationship = relationships.get(attribute(child, 'r:id') ?? '');
1707
- const anchor = attribute(child, 'anchor');
1713
+ const content = await containerRunsHtml(child, field, runContext);
1714
+ const relationship = relationships.get(work_ooxml_package_attribute(child, 'r:id') ?? '');
1715
+ const anchor = work_ooxml_package_attribute(child, 'anchor');
1708
1716
  const href = relationship?.targetMode === 'External' ? relationship.target : anchor ? `#${anchor}` : '';
1709
1717
  html += href ? `<a href="${escapeHtml(href)}">${content}</a>` : content;
1710
1718
  continue;
1711
1719
  }
1712
1720
  if ('fldSimple' === child.localName) {
1713
- const instruction = attribute(child, 'instr') ?? '';
1714
- if (!/\bPAGE\b/i.test(instruction)) html += await containerRunsHtml(child, field, archive, relationships);
1721
+ const instruction = work_ooxml_package_attribute(child, 'instr') ?? '';
1722
+ if (!/\bPAGE\b/i.test(instruction)) html += await containerRunsHtml(child, field, runContext);
1715
1723
  continue;
1716
1724
  }
1717
- html += await containerRunsHtml(child, field, archive, relationships);
1725
+ html += await containerRunsHtml(child, field, runContext);
1718
1726
  }
1719
1727
  const identityAttributes = paragraphIdentityAttributes(paragraph);
1720
1728
  const defaultCollapsed = properties ? parseDocxParagraphDefaultCollapsed(properties) : {
@@ -1744,23 +1752,23 @@ function paragraphIdentityAttributes(paragraph) {
1744
1752
  });
1745
1753
  return identity ? ` data-office-paragraph-id="${identity.paragraphId}" data-office-paragraph-text-id="${identity.textId}"` : '';
1746
1754
  }
1747
- async function containerRunsHtml(container, field, archive, relationships) {
1748
- if ('r' === container.localName) return runHtml(container, field, archive, relationships);
1755
+ async function containerRunsHtml(container, field, context) {
1756
+ if ('r' === container.localName) return runHtml(container, field, context);
1749
1757
  let html = '';
1750
1758
  for (const child of directChildren(container)){
1751
1759
  if (isDocxEquationLikeRoot(child)) {
1752
1760
  html += docxEquationHtml(child);
1753
1761
  continue;
1754
1762
  }
1755
- html += await containerRunsHtml(child, field, archive, relationships);
1763
+ html += await containerRunsHtml(child, field, context);
1756
1764
  }
1757
1765
  return html;
1758
1766
  }
1759
- async function runHtml(run, field, archive, relationships) {
1767
+ async function runHtml(run, field, context) {
1760
1768
  let content = '';
1761
1769
  for (const child of directChildren(run)){
1762
1770
  if ('fldChar' === child.localName) {
1763
- updateFieldState(field, attribute(child, 'fldCharType'));
1771
+ updateFieldState(field, work_ooxml_package_attribute(child, 'fldCharType'));
1764
1772
  continue;
1765
1773
  }
1766
1774
  if ('instrText' === child.localName) {
@@ -1775,30 +1783,62 @@ async function runHtml(run, field, archive, relationships) {
1775
1783
  if ('t' === child.localName) content += escapeHtml(child.textContent ?? '');
1776
1784
  if ('tab' === child.localName) content += '&#9;';
1777
1785
  if ('br' === child.localName || 'cr' === child.localName) content += '<br>';
1778
- if ('drawing' === child.localName) content += await drawingHtml(child, archive, relationships);
1786
+ if ('drawing' === child.localName) content += await drawingHtml(child, context.archive, context.relationships);
1779
1787
  }
1780
1788
  }
1781
1789
  if (!content) return '';
1782
1790
  const properties = directChild(run, 'rPr');
1791
+ const propertySources = docxRunPropertySources(context.paragraphProperties, properties, context.paragraphStyles, docxTableRunPropertySources(run, context.tableStyles));
1783
1792
  if (enabledElement(directChild(properties ?? run, 'b'))) content = `<strong>${content}</strong>`;
1784
1793
  if (enabledElement(directChild(properties ?? run, 'i'))) content = `<em>${content}</em>`;
1785
1794
  const underline = directChild(properties ?? run, 'u');
1786
- if (underline && 'none' !== attribute(underline, 'val')) content = `<u>${content}</u>`;
1787
- if (enabledElement(directChild(properties ?? run, 'strike')) || enabledElement(directChild(properties ?? run, 'dstrike'))) content = `<s>${content}</s>`;
1788
- const verticalAlign = attribute(directChild(properties ?? run, 'vertAlign') ?? run, 'val');
1795
+ if (underline) {
1796
+ const attributes = documentUnderlineDomAttributes(importedDocxUnderline(underline, context.theme));
1797
+ content = `<u${htmlAttributes(attributes)}>${content}</u>`;
1798
+ }
1799
+ const strike = importedDocxStrike(properties ?? run);
1800
+ if (strike) content = `<s${htmlAttributes(documentStrikeDomAttributes(strike))}>${content}</s>`;
1801
+ const verticalAlign = work_ooxml_package_attribute(directChild(properties ?? run, 'vertAlign') ?? run, 'val');
1789
1802
  if ("superscript" === verticalAlign) content = `<sup>${content}</sup>`;
1790
1803
  if ("subscript" === verticalAlign) content = `<sub>${content}</sub>`;
1791
- const color = attribute(directChild(properties ?? run, 'color') ?? run, 'val');
1804
+ const characterScale = docxCharacterScalePercentFromProperties(properties ?? run);
1805
+ if (void 0 !== characterScale) content = `<span${htmlAttributes(documentCharacterScaleDomAttributes(characterScale))}>${content}</span>`;
1806
+ const fontSize = resolveDocxPageChromeFontSizePoints(propertySources);
1807
+ const kerningThreshold = resolveDocxKerningThresholdHalfPoints(propertySources);
1808
+ if (void 0 !== fontSize || void 0 !== kerningThreshold) {
1809
+ const attributes = void 0 === kerningThreshold ? {} : documentKerningDomAttributes(kerningThreshold, fontSize);
1810
+ const styles = [
1811
+ void 0 === fontSize ? '' : `font-size: ${work_docx_page_chrome_import_formatNumber(fontSize)}pt`,
1812
+ attributes.style ?? ''
1813
+ ].filter(Boolean);
1814
+ content = `<span${htmlAttributes({
1815
+ ...attributes,
1816
+ ...styles.length ? {
1817
+ style: styles.join('; ')
1818
+ } : {}
1819
+ })}>${content}</span>`;
1820
+ }
1821
+ const characterPosition = docxCharacterPositionHalfPointsFromProperties(properties ?? run);
1822
+ if (void 0 !== characterPosition) content = `<span${htmlAttributes(documentCharacterPositionDomAttributes(characterPosition))}>${content}</span>`;
1823
+ const emphasisMark = resolveDocxEmphasisMark(propertySources);
1824
+ if (void 0 !== emphasisMark) content = `<span${htmlAttributes(documentEmphasisMarkDomAttributes(emphasisMark))}>${content}</span>`;
1825
+ const hiddenText = resolveDocxHiddenText(propertySources);
1826
+ if (void 0 !== hiddenText) content = `<span${htmlAttributes(documentHiddenTextDomAttributes(hiddenText))}>${content}</span>`;
1827
+ const legacyTextEffects = resolveDocxLegacyTextEffects(propertySources);
1828
+ if (legacyTextEffects) content = `<span${htmlAttributes(documentLegacyTextEffectsDomAttributes(legacyTextEffects))}>${content}</span>`;
1829
+ const characterSpacing = docxCharacterSpacingTwipsFromProperties(properties ?? run);
1830
+ if (void 0 !== characterSpacing) content = `<span${htmlAttributes(documentCharacterSpacingDomAttributes(characterSpacing))}>${content}</span>`;
1831
+ const color = work_ooxml_package_attribute(directChild(properties ?? run, 'color') ?? run, 'val');
1792
1832
  if (color && /^[0-9a-f]{6}$/i.test(color)) content = `<span style="color: #${color}">${content}</span>`;
1793
1833
  return content;
1794
1834
  }
1795
1835
  async function drawingHtml(drawing, archive, relationships) {
1796
- const relationship = relationships.get(attribute(firstDescendant(drawing, 'blip') ?? drawing, 'embed') ?? '');
1836
+ const relationship = relationships.get(work_ooxml_package_attribute(firstDescendant(drawing, 'blip') ?? drawing, 'embed') ?? '');
1797
1837
  if (!relationship || 'External' === relationship.targetMode || !archive.has(relationship.target)) return '';
1798
1838
  const source = bytesToDataUrl(await archive.bytes(relationship.target), contentTypeForPart(relationship.target));
1799
1839
  const extent = firstDescendant(drawing, 'extent');
1800
- const width = Math.max(1, Math.round(Number(attribute(extent ?? drawing, 'cx')) / 9525));
1801
- const height = Math.max(1, Math.round(Number(attribute(extent ?? drawing, 'cy')) / 9525));
1840
+ const width = Math.max(1, Math.round(Number(work_ooxml_package_attribute(extent ?? drawing, 'cx')) / 9525));
1841
+ const height = Math.max(1, Math.round(Number(work_ooxml_package_attribute(extent ?? drawing, 'cy')) / 9525));
1802
1842
  const identityAttributes = drawingIdentityAttributes(drawing);
1803
1843
  return `<img src="${source}" alt="Header or footer image"${width > 1 ? ` width="${width}"` : ''}${height > 1 ? ` height="${height}"` : ''}${identityAttributes}>`;
1804
1844
  }
@@ -1842,19 +1882,48 @@ function tableRowIdentityAttributes(row) {
1842
1882
  return identity ? ` ${DOCUMENT_TABLE_ROW_ID_ATTRIBUTE}="${identity.rowId}" ${DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE}="${identity.rowTextId}"` : '';
1843
1883
  }
1844
1884
  function containsPageNumber(document) {
1845
- return descendants(document, 'instrText').some((element)=>/\bPAGE\b/i.test(element.textContent ?? '')) || descendants(document, 'fldSimple').some((element)=>/\bPAGE\b/i.test(attribute(element, 'instr') ?? ''));
1885
+ return descendants(document, 'instrText').some((element)=>/\bPAGE\b/i.test(element.textContent ?? '')) || descendants(document, 'fldSimple').some((element)=>/\bPAGE\b/i.test(work_ooxml_package_attribute(element, 'instr') ?? ''));
1846
1886
  }
1847
1887
  function hasVariantReference(section, variant) {
1848
1888
  return [
1849
1889
  ...directChildren(section, 'headerReference'),
1850
1890
  ...directChildren(section, 'footerReference')
1851
- ].some((element)=>(attribute(element, 'type') ?? 'default') === variant);
1891
+ ].some((element)=>(work_ooxml_package_attribute(element, 'type') ?? 'default') === variant);
1852
1892
  }
1853
1893
  function enabledElement(element) {
1854
1894
  if (!element) return false;
1855
- const value = attribute(element, 'val')?.toLowerCase();
1895
+ const value = work_ooxml_package_attribute(element, 'val')?.toLowerCase();
1856
1896
  return '0' !== value && 'false' !== value && 'off' !== value;
1857
1897
  }
1898
+ function resolveDocxPageChromeFontSizePoints(propertySources) {
1899
+ let fontSize;
1900
+ for (const properties of propertySources){
1901
+ const candidate = docxPageChromeFontSizePointsFromProperties(properties);
1902
+ if (void 0 !== candidate) fontSize = candidate;
1903
+ }
1904
+ return fontSize;
1905
+ }
1906
+ function docxPageChromeFontSizePointsFromProperties(properties) {
1907
+ const localMatches = directChildren(properties, 'sz');
1908
+ const nativeMatches = localMatches.filter((element)=>DOCX_WORDPROCESSING_NAMESPACES.has(element.namespaceURI ?? ''));
1909
+ if (1 !== localMatches.length || 1 !== nativeMatches.length) return;
1910
+ const size = nativeMatches[0];
1911
+ if (directChildren(size).length || Array.from(size.childNodes).some((node)=>(node.nodeType === Node.TEXT_NODE || node.nodeType === Node.CDATA_SECTION_NODE) && Boolean(node.textContent?.trim()))) return;
1912
+ const attributes = Array.from(size.attributes).filter((attribute)=>xmlAttributeNamespace(size, attribute) !== XMLNS_NAMESPACE && 'xmlns' !== attribute.name && !attribute.name.startsWith('xmlns:'));
1913
+ if (1 !== attributes.length || 'val' !== xmlAttributeLocalName(attributes[0]) || !DOCX_WORDPROCESSING_NAMESPACES.has(xmlAttributeNamespace(size, attributes[0]) ?? '')) return;
1914
+ const halfPoints = parseBoundedDocxInteger(attributes[0].value.trim(), {
1915
+ minimum: 1,
1916
+ maximum: 1024,
1917
+ signed: false
1918
+ });
1919
+ return null === halfPoints ? void 0 : halfPoints / 2;
1920
+ }
1921
+ function work_docx_page_chrome_import_formatNumber(value) {
1922
+ return Number(value.toFixed(2)).toString();
1923
+ }
1924
+ function htmlAttributes(attributes) {
1925
+ return Object.entries(attributes).map(([name, value])=>` ${name}="${escapeHtml(value)}"`).join('');
1926
+ }
1858
1927
  function escapeHtml(value) {
1859
1928
  return value.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;');
1860
1929
  }
@@ -2148,9 +2217,9 @@ function importedTableCellMargins(layers) {
2148
2217
  }
2149
2218
  function assignCellMargin(target, side, element) {
2150
2219
  if (!element) return;
2151
- const type = attribute(element, 'type');
2220
+ const type = work_ooxml_package_attribute(element, 'type');
2152
2221
  if (type && 'dxa' !== type) return;
2153
- const twips = Number(attribute(element, 'w'));
2222
+ const twips = Number(work_ooxml_package_attribute(element, 'w'));
2154
2223
  if (!Number.isFinite(twips) || twips < 0) return;
2155
2224
  target[side] = Math.round(twips * PIXELS_PER_TWIP * 100) / 100;
2156
2225
  }
@@ -2233,16 +2302,16 @@ function compactBorders(borders) {
2233
2302
  }
2234
2303
  function parseBorder(edge, theme) {
2235
2304
  if (!edge) return null;
2236
- const style = tableBorderStyle(attribute(edge, 'val'));
2305
+ const style = tableBorderStyle(work_ooxml_package_attribute(edge, 'val'));
2237
2306
  if (!style) return null;
2238
2307
  if ('none' === style) return {
2239
2308
  color: '#000000',
2240
2309
  style,
2241
2310
  width: 0
2242
2311
  };
2243
- const themed = docxThemeColor(theme, attribute(edge, 'themeColor'), attribute(edge, 'themeTint'), attribute(edge, 'themeShade'));
2244
- const color = themed ? `#${themed}` : ooxmlColor(attribute(edge, 'color')) ?? '#000000';
2245
- const size = Number(attribute(edge, 'sz'));
2312
+ const themed = docxThemeColor(theme, work_ooxml_package_attribute(edge, 'themeColor'), work_ooxml_package_attribute(edge, 'themeTint'), work_ooxml_package_attribute(edge, 'themeShade'));
2313
+ const color = themed ? `#${themed}` : ooxmlColor(work_ooxml_package_attribute(edge, 'color')) ?? '#000000';
2314
+ const size = Number(work_ooxml_package_attribute(edge, 'sz'));
2246
2315
  const width = Number.isFinite(size) && size > 0 ? size / 6 : 1;
2247
2316
  return {
2248
2317
  color,
@@ -2264,7 +2333,7 @@ function importedTableCellBackgroundColor(layers, theme) {
2264
2333
  return color;
2265
2334
  }
2266
2335
  function tableCellBackgroundColor(shading, theme) {
2267
- const themed = docxThemeColor(theme, attribute(shading, 'themeFill'), attribute(shading, 'themeFillTint'), attribute(shading, 'themeFillShade'));
2336
+ const themed = docxThemeColor(theme, work_ooxml_package_attribute(shading, 'themeFill'), work_ooxml_package_attribute(shading, 'themeFillTint'), work_ooxml_package_attribute(shading, 'themeFillShade'));
2268
2337
  if (themed) {
2269
2338
  const color = `#${themed}`;
2270
2339
  return {
@@ -2272,15 +2341,15 @@ function tableCellBackgroundColor(shading, theme) {
2272
2341
  theme: themeReference(shading, 'themeFill', 'themeFillTint', 'themeFillShade', color)
2273
2342
  };
2274
2343
  }
2275
- const color = ooxmlColor(attribute(shading, 'fill'));
2344
+ const color = ooxmlColor(work_ooxml_package_attribute(shading, 'fill'));
2276
2345
  return color ? {
2277
2346
  color
2278
2347
  } : null;
2279
2348
  }
2280
2349
  function themeReference(element, themeName, tintName, shadeName, resolved) {
2281
- const theme = attribute(element, themeName)?.trim() ?? '';
2282
- const tint = normalizedByteHex(attribute(element, tintName));
2283
- const shade = normalizedByteHex(attribute(element, shadeName));
2350
+ const theme = work_ooxml_package_attribute(element, themeName)?.trim() ?? '';
2351
+ const tint = normalizedByteHex(work_ooxml_package_attribute(element, tintName));
2352
+ const shade = normalizedByteHex(work_ooxml_package_attribute(element, shadeName));
2284
2353
  return {
2285
2354
  theme,
2286
2355
  resolved,
@@ -2301,7 +2370,7 @@ function importedTableCellVerticalAlign(layers) {
2301
2370
  for (const layer of layers){
2302
2371
  const element = layer.cellProperties ? directChild(layer.cellProperties, 'vAlign') : void 0;
2303
2372
  if (!element) continue;
2304
- const value = tableVerticalAlign(attribute(element, 'val'));
2373
+ const value = tableVerticalAlign(work_ooxml_package_attribute(element, 'val'));
2305
2374
  if (value) alignment = value;
2306
2375
  }
2307
2376
  return alignment;
@@ -2380,8 +2449,8 @@ function markDocxTableRows(document) {
2380
2449
  const cantSplit = properties ? directChild(properties, 'cantSplit') : void 0;
2381
2450
  const repeatHeader = properties ? directChild(properties, 'tblHeader') : void 0;
2382
2451
  const height = properties ? directChild(properties, 'trHeight') : void 0;
2383
- const rowHeight = height ? twipsToPixels(Number(attribute(height, 'val'))) : null;
2384
- const rowHeightRule = tableRowHeightRule(attribute(height ?? row, 'hRule'));
2452
+ const rowHeight = height ? twipsToPixels(Number(work_ooxml_package_attribute(height, 'val'))) : null;
2453
+ const rowHeightRule = tableRowHeightRule(work_ooxml_package_attribute(height ?? row, 'hRule'));
2385
2454
  const rowIdentity = identities.get(row);
2386
2455
  const uniqueIdentity = rowIdentity && 1 === identityCounts.get(rowIdentity.rowId) ? rowIdentity : null;
2387
2456
  if (!cantSplit && !repeatHeader && null === rowHeight && !uniqueIdentity) continue;
@@ -2482,7 +2551,7 @@ function work_docx_table_row_import_word2010Attribute(element, localName) {
2482
2551
  return Array.from(element.attributes).find((item)=>xmlAttributeLocalName(item) === localName && xmlAttributeNamespace(element, item) === work_docx_table_row_import_WORD_2010_NAMESPACE)?.value ?? null;
2483
2552
  }
2484
2553
  function onOffValue(element) {
2485
- const value = (attribute(element, 'val') ?? attribute(element, 'w:val'))?.trim().toLowerCase();
2554
+ const value = (work_ooxml_package_attribute(element, 'val') ?? work_ooxml_package_attribute(element, 'w:val'))?.trim().toLowerCase();
2486
2555
  return '0' !== value && 'false' !== value && 'off' !== value;
2487
2556
  }
2488
2557
  function setBooleanAttribute(element, name, value) {
@@ -2523,7 +2592,7 @@ function markDocxTableSizing(document, tableStyleSource) {
2523
2592
  const paragraph = firstTableParagraph(document, table);
2524
2593
  if (!paragraph) continue;
2525
2594
  const grid = directChild(table, 'tblGrid');
2526
- const columnWidths = grid ? directChildren(grid, 'gridCol').map((column)=>work_docx_table_sizing_import_twipsToPixels(Number(attribute(column, 'w')), false)).filter((width)=>null !== width) : [];
2595
+ const columnWidths = grid ? directChildren(grid, 'gridCol').map((column)=>work_docx_table_sizing_import_twipsToPixels(Number(work_ooxml_package_attribute(column, 'w')), false)).filter((width)=>null !== width) : [];
2527
2596
  const marker = `__A3S_WORK_TABLE_SIZING_${tables.length + 1}__`;
2528
2597
  insertMarker(document, paragraph, marker);
2529
2598
  tables.push({
@@ -2574,13 +2643,13 @@ function importedTableGeometry(propertySources) {
2574
2643
  };
2575
2644
  for (const properties of propertySources){
2576
2645
  const layoutElement = directChild(properties, 'tblLayout');
2577
- const layoutValue = layoutElement ? importedTableLayout(attribute(layoutElement, 'type')) : null;
2646
+ const layoutValue = layoutElement ? importedTableLayout(work_ooxml_package_attribute(layoutElement, 'type')) : null;
2578
2647
  if (layoutValue) layout = layoutValue;
2579
2648
  const widthElement = directChild(properties, 'tblW');
2580
2649
  const widthValue = widthElement ? importedTablePreferredWidth(widthElement) : null;
2581
2650
  if (widthValue) width = widthValue;
2582
2651
  const alignmentElement = directChild(properties, 'jc');
2583
- const alignmentValue = alignmentElement ? importedTableAlignment(attribute(alignmentElement, 'val')) : null;
2652
+ const alignmentValue = alignmentElement ? importedTableAlignment(work_ooxml_package_attribute(alignmentElement, 'val')) : null;
2584
2653
  if (alignmentValue) alignment = alignmentValue;
2585
2654
  const indentElement = directChild(properties, 'tblInd');
2586
2655
  const indentValue = indentElement ? tableWidthPixels(indentElement, true) : null;
@@ -2604,13 +2673,13 @@ function importedTableLayout(value) {
2604
2673
  return 'autofit' === value ? 'autofit' : null;
2605
2674
  }
2606
2675
  function importedTablePreferredWidth(width) {
2607
- const type = attribute(width, 'type');
2676
+ const type = work_ooxml_package_attribute(width, 'type');
2608
2677
  if ('auto' === type || 'nil' === type) return {
2609
2678
  type: 'auto',
2610
2679
  value: null
2611
2680
  };
2612
2681
  if ('pct' === type) {
2613
- const value = percentageValue(attribute(width, 'w'));
2682
+ const value = percentageValue(work_ooxml_package_attribute(width, 'w'));
2614
2683
  return null === value ? null : {
2615
2684
  type: 'percent',
2616
2685
  value
@@ -2649,9 +2718,9 @@ function assignMargin(target, side, element) {
2649
2718
  if (null !== value) target[side] = value;
2650
2719
  }
2651
2720
  function tableWidthPixels(element, allowZero) {
2652
- const type = attribute(element, 'type');
2721
+ const type = work_ooxml_package_attribute(element, 'type');
2653
2722
  if (type && 'dxa' !== type) return null;
2654
- return work_docx_table_sizing_import_twipsToPixels(Number(attribute(element, 'w')), allowZero);
2723
+ return work_docx_table_sizing_import_twipsToPixels(Number(work_ooxml_package_attribute(element, 'w')), allowZero);
2655
2724
  }
2656
2725
  function percentageValue(value) {
2657
2726
  const normalized = value?.trim();
@@ -2703,9 +2772,9 @@ function importedColumnPercentages(table, columnWidths) {
2703
2772
  for (const cell of directChildren(row, 'tc')){
2704
2773
  const properties = directChild(cell, 'tcPr');
2705
2774
  const gridSpan = directChild(properties ?? cell, 'gridSpan');
2706
- const span = Math.max(1, Number(gridSpan ? attribute(gridSpan, 'val') : null) || 1);
2775
+ const span = Math.max(1, Number(gridSpan ? work_ooxml_package_attribute(gridSpan, 'val') : null) || 1);
2707
2776
  const width = directChild(properties ?? cell, 'tcW');
2708
- const total = width && 'pct' === attribute(width, 'type') ? percentageValue(attribute(width, 'w')) : null;
2777
+ const total = width && 'pct' === work_ooxml_package_attribute(width, 'type') ? percentageValue(work_ooxml_package_attribute(width, 'w')) : null;
2709
2778
  if (null !== total) {
2710
2779
  const physical = columnWidths.slice(column, column + span);
2711
2780
  const physicalTotal = physical.reduce((sum, value)=>sum + value, 0);
@@ -2725,7 +2794,7 @@ function logicalTableColumnCount(table) {
2725
2794
  const count = directChildren(row, 'tc').reduce((sum, cell)=>{
2726
2795
  const properties = directChild(cell, 'tcPr');
2727
2796
  const gridSpan = directChild(properties ?? cell, 'gridSpan');
2728
- const span = Number(gridSpan ? attribute(gridSpan, 'val') : null);
2797
+ const span = Number(gridSpan ? work_ooxml_package_attribute(gridSpan, 'val') : null);
2729
2798
  return sum + (Number.isSafeInteger(span) && span > 0 ? span : 1);
2730
2799
  }, rowGridBefore(row));
2731
2800
  return Math.max(maximum, count);
@@ -2734,7 +2803,7 @@ function logicalTableColumnCount(table) {
2734
2803
  function rowGridBefore(row) {
2735
2804
  const properties = directChild(row, 'trPr');
2736
2805
  const gridBefore = directChild(properties ?? row, 'gridBefore');
2737
- const value = Number(gridBefore ? attribute(gridBefore, 'val') : null);
2806
+ const value = Number(gridBefore ? work_ooxml_package_attribute(gridBefore, 'val') : null);
2738
2807
  return Number.isSafeInteger(value) && value > 0 ? value : 0;
2739
2808
  }
2740
2809
  function firstTableParagraph(document, table) {
@@ -2905,7 +2974,13 @@ async function prepareDocxImport(buffer, sourcePackage) {
2905
2974
  const theme = createDocxThemeResolver(themeDocument, settings);
2906
2975
  const paragraphBorderMarkers = markDocxParagraphBorders(document, paragraphStyles, theme, tableStyles);
2907
2976
  const paragraphShadingMarkers = markDocxParagraphShading(document, paragraphStyles, theme, tableStyles);
2908
- const runFormattingMarkers = markDocxRunFormatting(document, paragraphStyles, theme, tableStyles);
2977
+ const runFormattingMarkerState = createImportedDocxRunFormattingMarkerState([
2978
+ document,
2979
+ ...equationMarkers.parts.map((part)=>part.document)
2980
+ ]);
2981
+ markDocxRunFormattingIntoState(document, runFormattingMarkerState, paragraphStyles, theme, tableStyles);
2982
+ for (const part of equationMarkers.parts)markDocxRunFormattingIntoState(part.document, runFormattingMarkerState, paragraphStyles, theme, tableStyles);
2983
+ const runFormattingMarkers = runFormattingMarkerState.markers;
2909
2984
  const paragraphFormattingChangeMarkers = markDocxParagraphFormattingChanges(document, paragraphStyles, theme, tableStyles);
2910
2985
  const tabStopMarkers = markDocxParagraphTabStops(document, paragraphStyles, tableStyles);
2911
2986
  const tableCellMarkers = markDocxTableCells(document, theme, tableStyles);
@@ -3152,7 +3227,7 @@ async function parseSectionLayout(section, archive, relationships, previous, odd
3152
3227
  return pageGeometry ? applyDocumentPageGeometry(layout, pageGeometry) : layout;
3153
3228
  }
3154
3229
  function parseDocumentGrid(element) {
3155
- const sourceType = attribute(element, 'type');
3230
+ const sourceType = work_ooxml_package_attribute(element, 'type');
3156
3231
  const type = 'lines' === sourceType || 'linesAndChars' === sourceType || 'snapToChars' === sourceType ? sourceType : 'default';
3157
3232
  const sourceLinePitch = work_docx_import_numberAttribute(element, 'linePitch');
3158
3233
  return {
@@ -3237,13 +3312,13 @@ function sectionMarker(index) {
3237
3312
  }
3238
3313
  function parseSectionBreak(element) {
3239
3314
  if (!element) return 'nextPage';
3240
- const value = attribute(element, 'val');
3315
+ const value = work_ooxml_package_attribute(element, 'val');
3241
3316
  if ('continuous' === value || 'evenPage' === value || 'oddPage' === value || 'nextColumn' === value) return value;
3242
3317
  return 'nextPage';
3243
3318
  }
3244
3319
  function work_docx_import_numberAttribute(element, name) {
3245
3320
  if (!element) return 0;
3246
- const value = Number(attribute(element, name));
3321
+ const value = Number(work_ooxml_package_attribute(element, name));
3247
3322
  return Number.isFinite(value) ? value : 0;
3248
3323
  }
3249
3324
  function work_docx_import_closestAncestor(element, localName) {