@a3s-lab/office 0.37.4 → 0.38.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 (33) hide show
  1. package/README.md +10 -1
  2. package/dist/{0~4808.js → 0~5024.js} +150 -2
  3. package/dist/0~7240.js +26 -4
  4. package/dist/0~document-editor.js +455 -13
  5. package/dist/0~spreadsheet-editor.js +52 -36
  6. package/dist/0~work-docx-export.js +215 -18
  7. package/dist/0~work-docx-import.js +4 -2
  8. package/dist/0~work-office-diagnostics.js +57 -1
  9. package/dist/4174.js +313 -112
  10. package/dist/5416.js +56 -44
  11. package/dist/core.js +56 -10
  12. package/dist/internal/features/work/editors/document-font-dialog-model.d.ts +5 -4
  13. package/dist/internal/features/work/editors/document-font-dialog-opentype-model.d.ts +53 -0
  14. package/dist/internal/features/work/editors/document-font-dialog-script-font-model.d.ts +5 -0
  15. package/dist/internal/features/work/editors/spreadsheet-auto-filter-menu.d.ts +2 -2
  16. package/dist/internal/features/work/editors/spreadsheet-auto-filter.d.ts +3 -3
  17. package/dist/internal/features/work/editors/spreadsheet-date-time-command.d.ts +2 -1
  18. package/dist/internal/features/work/editors/spreadsheet-editor-support.d.ts +2 -2
  19. package/dist/internal/features/work/editors/spreadsheet-filter-reconciliation.d.ts +3 -2
  20. package/dist/internal/features/work/work-document-equations.d.ts +4 -3
  21. package/dist/internal/features/work/work-document-format-changes.d.ts +2 -0
  22. package/dist/internal/features/work/work-document-opentype.d.ts +39 -0
  23. package/dist/internal/features/work/work-document-word-line-metrics.d.ts +1 -0
  24. package/dist/internal/features/work/work-docx-opentype-diagnostics.d.ts +3 -0
  25. package/dist/internal/features/work/work-docx-opentype-export.d.ts +19 -0
  26. package/dist/internal/features/work/work-docx-opentype-import.d.ts +8 -0
  27. package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +2 -0
  28. package/dist/internal/features/work/work-spreadsheet-dynamic-filter.d.ts +3 -2
  29. package/dist/internal/features/work/work-types.d.ts +3 -0
  30. package/dist/office-kernel.wasm +0 -0
  31. package/dist/styles.css +7 -3
  32. package/docs/latest/en/browser-editor-architecture.md +4 -2
  33. package/package.json +6 -1
@@ -1,8 +1,8 @@
1
1
  import jszip from "jszip";
2
2
  import { documentRunBorderDomAttributes, contentTypeForPart, bytesToDataUrl, OoxmlPackage, normalizeDocumentIndexesHtml, firstDescendant, normalizeDocumentParagraphId, applyDocumentParagraphIdentityToElement, descendants, documentHighlightDomAttributes, attribute as work_ooxml_package_attribute, documentHighlightFromDocxValue, serializeDocxThemeReference, normalizeDocumentTableOfContentsHtml, directChildren, documentParagraphShadingDomAttributes, documentProofingDomAttributes, documentParagraphBordersDomAttributes, directChild, documentScriptFontSegments, normalizeDocumentParagraphIdentity, documentRunShadingDomAttributes } from "./4121.js";
3
- import { normalizeDocumentBookmarkName, renderDocumentTableCellMarginOverrides, applyDocumentImageIdentityToElement, documentCharacterPositionDomAttributes, createDocumentImageIdentityRegistry, normalizeDocumentColumns, documentStrikeDomAttributes, normalizeDocumentImageWrapContour, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, normalizeDocumentBookmarksHtml, applyDocumentTableRowIdentityToElement, normalizeDocumentCaptionsHtml, documentCharacterSpacingDomAttributes, normalizeDocumentImageAlignment, 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, documentKerningDomAttributes, docxDocumentFieldKind, renderDocumentTableBorders, docxBookmarkReferenceTarget, normalizeDocumentImagePosition, wrapsBesideImage, documentPageChromeLegacyFields, documentCharacterScaleDomAttributes, DEFAULT_DOCUMENT_TABLE_GEOMETRY, documentSectionDomAttributes, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, documentPageMarginBody, documentLegacyTextEffectsDomAttributes, normalizeDocumentTableRowIdentity, normalizeDocumentBookmarkNativeId, uniqueDocumentImageIdentity, applyDocumentTableGeometryToElement, normalizeDocumentImageCrop, documentContentLayoutProperties, documentEmphasisMarkDomAttributes } from "./4174.js";
3
+ import { normalizeDocumentBookmarkName, renderDocumentTableCellMarginOverrides, applyDocumentImageIdentityToElement, documentCharacterPositionDomAttributes, createDocumentImageIdentityRegistry, normalizeDocumentColumns, documentStrikeDomAttributes, normalizeDocumentImageWrapContour, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, normalizeDocumentBookmarksHtml, applyDocumentTableRowIdentityToElement, normalizeDocumentCaptionsHtml, documentCharacterSpacingDomAttributes, normalizeDocumentImageAlignment, 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, documentKerningDomAttributes, docxDocumentFieldKind, renderDocumentTableBorders, docxBookmarkReferenceTarget, normalizeDocumentImagePosition, wrapsBesideImage, documentPageChromeLegacyFields, documentCharacterScaleDomAttributes, DEFAULT_DOCUMENT_TABLE_GEOMETRY, documentSectionDomAttributes, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, documentPageMarginBody, documentLegacyTextEffectsDomAttributes, normalizeDocumentTableRowIdentity, normalizeDocumentBookmarkNativeId, documentOpenTypeDomAttributes, uniqueDocumentImageIdentity, applyDocumentTableGeometryToElement, normalizeDocumentImageCrop, documentContentLayoutProperties, documentEmphasisMarkDomAttributes } from "./4174.js";
4
4
  import { hasImportedDocxIndexMarkers, markDocxRunFormattingIntoState, applyImportedDocxParagraphSpacingMarkers, hasImportedDocxParagraphDirectionMarkers, hasImportedDocxParagraphIndentMarkers, resolveDocxParagraphBordersForParagraph, applyImportedDocxParagraphShadingMarkers, markDocxParagraphSpacing, docxCaptionBookmark, docxFieldResultText, createDocxParagraphStyleResolver, docxTableCellStyleLayers, createImportedDocxRunFormattingMarkerState, parseDocxPaperSource, resolveDocxLegacyTextEffects, markDocxTablesOfContents, hasImportedDocxParagraphSpacingMarkers, applyImportedDocxIndexMarkers, applyImportedDocxTableOfContentsMarkers, markDocxIndexes, parseDocxPageMargins, docxTablePropertySources, parseDirectDocxParagraphShading, markDocxParagraphIndents, markDocxPackageEquations, resolveDocxRunBorder, parseDocxPageGeometry, docxCaptionReferenceTarget, applyImportedDocxEquationMarkers, hasImportedDocxParagraphPaginationMarkers, createDocxTableStyleResolver, hasImportedDocxParagraphShadingMarkers, isDocxEquationLikeRoot, importedDocxStrike, docxTableRunPropertySources, inspectDocxPageMarginSettings, hasImportedDocxRunFormattingMarkers, applyImportedDocxParagraphFormattingChangeMarkers, hasImportedDocxTableOfContentsMarkers, hasImportedDocxParagraphTabStopMarkers, resolveDocxRunShading, docxCaptionSequenceKind, applyImportedDocxRunFormattingMarkers, markDocxParagraphAlignments, markDocxParagraphDirections, hasImportedDocxParagraphBorderMarkers, hasImportedDocxParagraphFormattingChangeMarkers, resolveDocxHiddenText, docxEquationHtml, docxFieldOccurrences, hasImportedDocxParagraphAlignmentMarkers, markDocxParagraphTabStops, applyImportedDocxParagraphIndentMarkers, resolveDocxTableStyleResolver, applyImportedDocxParagraphDirectionMarkers, applyImportedDocxParagraphAlignmentMarkers, markDocxParagraphPagination, importedDocxUnderline, markDocxParagraphBorders, applyImportedDocxParagraphTabStopMarkers, applyImportedDocxParagraphPaginationMarkers, docxFieldOccurrenceIsInlineEditable, applyImportedDocxParagraphBorderMarkers, docxRunPropertySources, markDocxParagraphFormattingChanges, markDocxParagraphShading, parseDocxPageBorders } from "./0~7240.js";
5
- import { readDocxBibliography, resolveDocxProofing, XMLNS_NAMESPACE, docxCharacterScalePercentFromProperties, docxCharacterSpacingTwipsFromProperties, parseBoundedDocxInteger, xmlAttributeLocalName, resolveDocxEmphasisMark, createDocxThemeResolver, docxCharacterPositionHalfPointsFromProperties, docxThemeColor, parseDocxParagraphDefaultCollapsed, resolveDocxKerningThresholdHalfPoints, resolveDocxThemeResolver, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace } from "./0~4808.js";
5
+ import { readDocxBibliography, resolveDocxProofing, XMLNS_NAMESPACE, docxCharacterScalePercentFromProperties, docxCharacterSpacingTwipsFromProperties, parseBoundedDocxInteger, resolveDocxOpenTypeFeatures, xmlAttributeLocalName, resolveDocxEmphasisMark, createDocxThemeResolver, docxCharacterPositionHalfPointsFromProperties, docxThemeColor, parseDocxParagraphDefaultCollapsed, resolveDocxKerningThresholdHalfPoints, resolveDocxThemeResolver, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace } from "./0~5024.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';
@@ -1801,6 +1801,8 @@ async function runHtml(run, field, context) {
1801
1801
  } : {}
1802
1802
  })}>${content}</span>`;
1803
1803
  }
1804
+ const openTypeFeatures = resolveDocxOpenTypeFeatures(propertySources).features;
1805
+ if (openTypeFeatures) content = `<span${htmlAttributes(documentOpenTypeDomAttributes(openTypeFeatures))}>${content}</span>`;
1804
1806
  const characterPosition = docxCharacterPositionHalfPointsFromProperties(properties ?? run);
1805
1807
  if (void 0 !== characterPosition) content = `<span${htmlAttributes(documentCharacterPositionDomAttributes(characterPosition))}>${content}</span>`;
1806
1808
  const emphasisMark = resolveDocxEmphasisMark(propertySources);
@@ -3,7 +3,7 @@ import { contentTypeForPart, directChildren, OoxmlPackage, parseXml, firstDescen
3
3
  import { normalizeDocumentBookmarkName, docxBookmarkReferenceTarget, normalizeDocumentBookmarkNativeId, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, supportedDocxBookmarkReferenceInstruction, documentCitationTagsFromInstruction, docxDocumentFieldKind } from "./4174.js";
4
4
  import { markDocxParagraphShading, inspectDocxPageSize, docxCaptionBookmark, hasInvalidDocxFieldStructure, inspectDocxLegacyTextEffects, inspectDocxPageMargins, inspectDocxPaperSource, createDocxParagraphStyleResolver, supportedDocxTableOfContentsField, docxFieldOccurrences, supportedDocxIndexEntryField, createDocxTableStyleResolver, inspectDocxEquation, inspectDocxPageMarginSettings, inspectDocxRunFonts, inspectDocxRunBorder, inspectDocxRunShading, markDocxParagraphBorders, isSupportedDocxParagraphFormattingChange, docxFieldOccurrenceIsInlineEditable, supportedDocxIndexField, docxCaptionSequenceKind, inspectDocxHiddenText, inspectDocxPageBorders, isSupportedDocxRunFormattingChange, docxFieldInstructions, isSupportedDocxEquationPlacement } from "./0~7240.js";
5
5
  import { normalizeDocumentHref } from "./0~work-document-links.js";
6
- import { xmlAttributeLocalName, inspectDocxProofingLanguages, readDocxBibliography, inspectDocxEmphasisMark, createDocxThemeResolver, inspectDocxNoProof, parseDocxParagraphDefaultCollapsed, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace, inspectDocxKerningThresholdHalfPoints } from "./0~4808.js";
6
+ import { xmlAttributeLocalName, resolveDocxOpenTypeFeatures, inspectDocxProofingLanguages, readDocxBibliography, inspectDocxEmphasisMark, createDocxThemeResolver, DOCX_WORD_2010_NAMESPACE, inspectDocxNoProof, parseDocxParagraphDefaultCollapsed, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace, inspectDocxKerningThresholdHalfPoints } from "./0~5024.js";
7
7
  import { updateSpreadsheetWorksheetCompatibilitySummary, inspectXlsxPivotTables, isSupportedXlsxChartLegend, isSupportedXlsxChartPlotLayout, xlsxChartNodeUsesStackedGrouping, isSupportedXlsxChartSeriesFormatting, readXlsxFormulaFeaturesFromPackage, inspectXlsxHeaderFooterText, emptySpreadsheetWorksheetCompatibilitySummary, isSupportedXlsxWorksheetImageContentType, MAX_XLSX_WORKSHEET_IMAGE_BYTES, xlsxChartSeriesFormattingShapeProperties, diagnoseXlsxProtection, isEditableXlsxPaperSizeCode, isSupportedXlsxCombinationChartNodes } from "./4166.js";
8
8
  import { spreadsheetConditionalComparisonNeedsUpperValue, isSpreadsheetConditionalIconSetName, isSpreadsheetConditionalComparisonOperator, spreadsheetConditionalIconSetCount, xlsxWorksheetCellEntries } from "./9333.js";
9
9
  import { formulaHasStructuredReference, formulaHasExternalReference, parseSpreadsheetPrintTitles, volatileSpreadsheetFormulaFunctions, stripSpreadsheetSheetQualifier } from "./8715.js";
@@ -606,6 +606,61 @@ function noteIssue(code, message, severity = 'warning') {
606
606
  severity
607
607
  };
608
608
  }
609
+ const OPEN_TYPE_DIAGNOSTIC_PART_PATTERN = /^word\/(?:document|styles|header\d*|footer\d*|footnotes|endnotes|comments)\.xml$/i;
610
+ const OPEN_TYPE_PROPERTY_NAMES = new Set([
611
+ 'ligatures',
612
+ 'numForm',
613
+ 'numSpacing',
614
+ 'stylisticSets',
615
+ 'cntxtAlts'
616
+ ]);
617
+ async function diagnoseDocxOpenTypeTypography(archive, document) {
618
+ const parts = [
619
+ {
620
+ path: 'word/document.xml',
621
+ document
622
+ }
623
+ ];
624
+ for (const path of archive.paths('word/'))if ('word/document.xml' !== path.toLowerCase() && OPEN_TYPE_DIAGNOSTIC_PART_PATTERN.test(path)) parts.push({
625
+ path,
626
+ document: await archive.xml(path)
627
+ });
628
+ let validCount = 0;
629
+ let invalidCount = 0;
630
+ let spoofedCount = 0;
631
+ for (const part of parts){
632
+ const propertySets = descendants(part.document, 'rPr').filter((element)=>DOCX_WORDPROCESSING_NAMESPACES.has(element.namespaceURI ?? ''));
633
+ for (const properties of propertySets){
634
+ const candidates = directChildren(properties).filter((child)=>OPEN_TYPE_PROPERTY_NAMES.has(child.localName));
635
+ if (!candidates.length) continue;
636
+ const inspection = resolveDocxOpenTypeFeatures([
637
+ properties
638
+ ]);
639
+ if (inspection.features) validCount += 1;
640
+ invalidCount += inspection.invalidCount;
641
+ spoofedCount += inspection.spoofedCount;
642
+ }
643
+ for (const name of OPEN_TYPE_PROPERTY_NAMES)for (const property of descendants(part.document, name)){
644
+ const parent = property.parentElement;
645
+ if (!(parent?.localName === 'rPr' && DOCX_WORDPROCESSING_NAMESPACES.has(parent.namespaceURI ?? ''))) if (property.namespaceURI === DOCX_WORD_2010_NAMESPACE) invalidCount += 1;
646
+ else spoofedCount += 1;
647
+ }
648
+ }
649
+ const issues = [];
650
+ if (validCount) issues.push({
651
+ code: 'docx.typography.opentype',
652
+ severity: 'info',
653
+ feature: 'OpenType typography',
654
+ message: `${validCount} native OpenType run-property set(s) preserve all 16 w14:ligatures combinations, default, lining, or old-style number forms, default, proportional, or tabular number spacing, style sets 1-20, and contextual alternates through inheritance, body and static-story editing, formatting revisions, CSS projection, and DOCX export.`
655
+ });
656
+ if (invalidCount || spoofedCount) issues.push({
657
+ code: 'docx.typography.opentype.invalid',
658
+ severity: 'warning',
659
+ feature: 'OpenType typography',
660
+ message: `${invalidCount + spoofedCount} malformed, duplicated, misplaced, namespace-spoofed, text-bearing, child-bearing, extra-attribute, unknown, or out-of-range OpenType run-property value(s) are ignored instead of enabling untrusted typography.`
661
+ });
662
+ return issues;
663
+ }
609
664
  async function diagnoseDocxPageBorders(archive, document) {
610
665
  const themePath = archive.paths('word/theme/').find((path)=>/\/theme\d*\.xml$/i.test(path));
611
666
  const themeDocument = themePath ? await archive.xml(themePath) : null;
@@ -2108,6 +2163,7 @@ async function analyzeDocxCompatibility(file, messages, sourcePackage) {
2108
2163
  issues.push(...await diagnoseDocxEquations(archive, document));
2109
2164
  if (document) {
2110
2165
  issues.push(...await diagnoseDocxKerning(archive, document));
2166
+ issues.push(...await diagnoseDocxOpenTypeTypography(archive, document));
2111
2167
  issues.push(...await diagnoseDocxEmphasisMarks(archive, document));
2112
2168
  issues.push(...await diagnoseDocxHiddenText(archive, document));
2113
2169
  issues.push(...await diagnoseDocxLegacyTextEffects(archive, document));