@a3s-lab/office 0.30.0 → 0.32.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 (45) hide show
  1. package/README.md +25 -5
  2. package/dist/{0~7231.js → 0~4808.js} +190 -3
  3. package/dist/0~4980.js +1 -1
  4. package/dist/0~5050.js +10 -1
  5. package/dist/{0~7360.js → 0~7240.js} +245 -16
  6. package/dist/0~7614.js +1 -1
  7. package/dist/0~document-editor.js +1756 -178
  8. package/dist/0~spreadsheet-editor.js +2 -1
  9. package/dist/0~work-docx-export.js +215 -27
  10. package/dist/0~work-docx-import.js +27 -33
  11. package/dist/0~work-docx-large-document-import.js +1 -1
  12. package/dist/0~work-office-diagnostics.js +28 -7
  13. package/dist/0~work-pptx-import.js +1 -1
  14. package/dist/{1544.js → 3266.js} +17 -1862
  15. package/dist/4121.js +425 -11
  16. package/dist/4166.js +3848 -0
  17. package/dist/{6282.js → 4174.js} +812 -10
  18. package/dist/9333.js +1849 -0
  19. package/dist/core.js +5259 -4
  20. package/dist/index.js +3 -3
  21. package/dist/internal/features/work/editors/document-command-catalog.d.ts +27 -0
  22. package/dist/internal/features/work/editors/document-compare-dialog.d.ts +14 -0
  23. package/dist/internal/features/work/editors/document-dom-selection.d.ts +7 -0
  24. package/dist/internal/features/work/editors/document-editor-support.d.ts +1 -0
  25. package/dist/internal/features/work/editors/document-index-dialog.d.ts +10 -0
  26. package/dist/internal/features/work/editors/document-index-entry-dialog.d.ts +10 -0
  27. package/dist/internal/features/work/editors/document-references-ribbon.d.ts +19 -0
  28. package/dist/internal/features/work/editors/document-toolbar.d.ts +6 -1
  29. package/dist/internal/features/work/editors/use-document-comparison.d.ts +9 -0
  30. package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +3 -0
  31. package/dist/internal/features/work/work-document-changes.d.ts +5 -0
  32. package/dist/internal/features/work/work-document-compare-diff.d.ts +38 -0
  33. package/dist/internal/features/work/work-document-compare-stability.d.ts +5 -0
  34. package/dist/internal/features/work/work-document-compare.d.ts +27 -0
  35. package/dist/internal/features/work/work-document-index-fields.d.ts +19 -0
  36. package/dist/internal/features/work/work-document-index-nodes.d.ts +32 -0
  37. package/dist/internal/features/work/work-document-index.d.ts +63 -0
  38. package/dist/internal/features/work/work-docx-import.d.ts +3 -1
  39. package/dist/internal/features/work/work-docx-index-export.d.ts +14 -0
  40. package/dist/internal/features/work/work-docx-index-import.d.ts +23 -0
  41. package/dist/office-kernel.wasm +0 -0
  42. package/dist/styles.css +490 -0
  43. package/docs/latest/en/browser-editor-architecture.md +37 -0
  44. package/package.json +9 -3
  45. package/dist/4104.js +0 -9336
@@ -4,8 +4,9 @@ import { Workbook } from "@fortune-sheet/react";
4
4
  import { AArrowDown, AArrowUp, AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowDownToLine, ArrowLeft, ArrowLeftToLine, ArrowRight, ArrowRightToLine, ArrowUp, ArrowUpToLine, BadgeJapaneseYen, BarChart3, BetweenHorizontalEnd, BetweenHorizontalStart, BetweenVerticalEnd, BetweenVerticalStart, Bold, Bookmark, Calculator, CalendarClock, CalendarDays, Check, ChevronDown, ChevronLeft, ChevronRight, ClipboardPaste, Clock, Cloud, Columns3, Copy, CopyPlus, DecimalsArrowLeft, DecimalsArrowRight, Eraser, Eye, EyeOff, FileX2, Globe2, Grid2X2, Grid3X3, Hash, Info, Italic, KeyRound, Layers2, Link2, Link2Off, ListChecks, ListFilter, LocateFixed, Merge, MessageSquareX, MoveHorizontal, MoveVertical, Paintbrush, Palette, PanelLeft, PanelTop, PanelsTopLeft, Pencil, Percent, Plus, Printer, Redo2, RefreshCw, Rows3, Save, Scissors, Search, Settings2, ShieldCheck, Sigma, SortAsc, SortDesc, Strikethrough, SwatchBook, Table2, TableProperties, Trash2, TriangleAlert, Underline, Undo2, WrapText, X } from "lucide-react";
5
5
  import { Fragment as external_react_Fragment, cloneElement, memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
6
6
  import { convertSpanToShareString, genarate, indexToColumnChar, update as core_update } from "@fortune-sheet/core";
7
- import { freezeImportedSpreadsheetCell, withXlsxPatternFill, spreadsheetMatrixProfile, xlsxRichTextCellText, spreadsheetTextOrientationFromAngle, spreadsheetCellValueWithDiagonalBorder, xlsxSemanticColorMatchesValue, spreadsheetUnderlineCellValue, normalizeXlsxRichTextEditSource, attachSpreadsheetShownCommentCells, sameSpreadsheetHistoryValue, isSpreadsheetConditionalComparisonOperator, defaultSpreadsheetConditionalIconThresholds, normalizeXlsxRichTextCell, activeXlsxNativeFill, xlsxPatternFillTypes, normalizeSpreadsheetDateValidationBoundary, unlockedCellCount, editableRangeRequiresCredentials, spreadsheetTextOrientationChoiceFromCell, spreadsheetConditionalThresholdValue, withSheetProtection, defaultSpreadsheetColorScaleThresholds, protectedSheetCount, sameXlsxRichTextRunStyle, withSheetSelectionPermissions, spreadsheetTextOrientationFromCell, patchSpreadsheetRichTextFontRuns, readOfficeSpreadsheetCollaboration as readWorkOfficeSpreadsheetCollaboration, spreadsheetConditionalThresholdsEqual, spreadsheetVisibleTextRotationFromCell, spreadsheetTextOrientationFromChoice, normalizeXlsxSemanticColorOrigin, withoutEditableRange, isSpreadsheetTextOrientationId, normalizeSpreadsheetConditionalVisualOptions, normalizeSpreadsheetDataValidationErrorStyle, withXlsxGradientFill, effectiveSpreadsheetPageSetup, normalizeXlsxPatternFill, normalizeXlsxRichTextColor, isHighSurrogate, xlsxNativeFillCellKeys, withEditableRange, createOfficeSpreadsheetCollaborationBinding as createWorkOfficeSpreadsheetCollaborationBinding, spreadsheetConditionalIconForValue, boundedSpreadsheetDataValidationText, spreadsheetUnderlineStyle, sheetProtectionAuthority, normalizeXlsxGradientFill, xlsxGradientFillFallbackColor, editableRangeCellCount, registerDerivedSpreadsheetMatrix, deleteXlsxNativeFills, spreadsheetTextOrientationCellStyle, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, normalizeSheetProtectionAuthority, spreadsheetProtectionKey, SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS, normalizeXlsxRichTextRun, spreadsheetDiagonalBorderFromCellValue, SPREADSHEET_CONDITIONAL_ICON_SETS, isLowSurrogate, spreadsheetConditionalComparisonNeedsUpperValue, drawSpreadsheetConditionalIcon, coalesceXlsxRichTextRuns, replaceOfficeSpreadsheetCollaboration as replaceWorkOfficeSpreadsheetCollaboration, validXlsxRichText, isSpreadsheetUnderlineStyle } from "./1544.js";
7
+ import { freezeImportedSpreadsheetCell, normalizeXlsxSemanticColorOrigin, spreadsheetMatrixProfile, withXlsxPatternFill, withoutEditableRange, normalizeSpreadsheetConditionalVisualOptions, xlsxSemanticColorMatchesValue, withXlsxGradientFill, effectiveSpreadsheetPageSetup, attachSpreadsheetShownCommentCells, normalizeXlsxPatternFill, withEditableRange, sameSpreadsheetHistoryValue, isSpreadsheetConditionalComparisonOperator, spreadsheetConditionalIconForValue, defaultSpreadsheetConditionalIconThresholds, xlsxPatternFillTypes, sheetProtectionAuthority, normalizeXlsxGradientFill, xlsxGradientFillFallbackColor, editableRangeCellCount, unlockedCellCount, registerDerivedSpreadsheetMatrix, editableRangeRequiresCredentials, SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, spreadsheetConditionalThresholdValue, normalizeSheetProtectionAuthority, withSheetProtection, spreadsheetProtectionKey, defaultSpreadsheetColorScaleThresholds, protectedSheetCount, SPREADSHEET_CONDITIONAL_ICON_SETS, withSheetSelectionPermissions, spreadsheetConditionalComparisonNeedsUpperValue, drawSpreadsheetConditionalIcon, spreadsheetConditionalThresholdsEqual } from "./9333.js";
8
8
  import { workSpreadsheetChartSupportsGrouping, spreadsheetFormulaRangesForSelection, createSpreadsheetChartFromSelection, normalizeWorkSpreadsheetDataLabelPosition, normalizeSpreadsheetPrintTitleColumns, normalizeSpreadsheetPrintTitleRows, formulaHasStructuredReference, normalizeWorkSpreadsheetErrorBars, defaultPivotValueCaption, workSpreadsheetChartSupportsBarSpacing, normalizeWorkSpreadsheetChartGrouping, spreadsheetGridSize, normalizeWorkSpreadsheetChartAxisGroup, normalizeWorkSpreadsheetScatterStyle, cloneSparseMatrix, spreadsheetPivotAggregationLabel, workSpreadsheetChartAxisIsCategoryAxis, reconcileSpreadsheetChartPreviews, normalizeWorkSpreadsheetChartAxes, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetChartLegendPosition, spreadsheetChartCount, workSpreadsheetChartTypeLabel, sparseArrayEntries, normalizeWorkSpreadsheetTrendline, effectiveSpreadsheetCalculationSettings, spreadsheetPivotIntersects, normalizeWorkSpreadsheetDataLabels, spreadsheetPivotOutputContains, normalizeSpreadsheetPrintArea, spreadsheetCellAddress, formatSpreadsheetCellRanges, normalizeWorkSpreadsheetChartLayout, spreadsheetFormulaRangeForCell, workSpreadsheetChartAxisIsValueAxis, normalizeWorkSpreadsheetChartSmoothLines, spreadsheetPivotFilterValueKey, normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetChartSeriesStyle, volatileSpreadsheetFormulaFunctions, sparseArrayIndexes, normalizeWorkSpreadsheetBubbleSizeRepresents, workSpreadsheetChartSupportsTrendlines, normalizeWorkSpreadsheetChartLegendOverlay, parseSpreadsheetChartReference, workSpreadsheetChartGroupingIsStacked, normalizeWorkSpreadsheetChartGapWidth, workSpreadsheetChartSupportsSmoothLines, refreshSpreadsheetPivotTables, createSpreadsheetPivotFromSelection, reconcileSpreadsheetPivots, spreadsheetPivotCount, sparseMatrixColumnCount, workSpreadsheetChartSupportsErrorBars, formulaHasExternalReference, isValidSpreadsheetDefinedName, spreadsheetPivotValidation, deleteSpreadsheetPivotTable, workSpreadsheetChartAxisDefaultLabelPosition, workSpreadsheetChartSupportsSeriesAnalysis, parseSpreadsheetCellRanges, spreadsheetPivotFilterItems, spreadsheetPivotFields, normalizeWorkSpreadsheetChartOverlap, spreadsheetFormulaRangeConflict, spreadsheetSheetsWithChartPreviews, workSpreadsheetChartUsesNumericXAxis, workSpreadsheetChartAxisShowsMajorGridlinesByDefault, workSpreadsheetChartSupportsAxes, normalizeWorkSpreadsheetCombinationSeriesType, normalizeWorkSpreadsheetRadarStyle } from "./8715.js";
9
+ import { spreadsheetTextOrientationFromChoice, isSpreadsheetTextOrientationId, xlsxRichTextCellText, spreadsheetTextOrientationFromAngle, spreadsheetCellValueWithDiagonalBorder, spreadsheetUnderlineCellValue, normalizeSpreadsheetDataValidationErrorStyle, normalizeXlsxRichTextEditSource, normalizeXlsxRichTextColor, isHighSurrogate, xlsxNativeFillCellKeys, createOfficeSpreadsheetCollaborationBinding as createWorkOfficeSpreadsheetCollaborationBinding, boundedSpreadsheetDataValidationText, normalizeSpreadsheetDateValidationBoundary, normalizeXlsxRichTextCell, activeXlsxNativeFill, spreadsheetUnderlineStyle, deleteXlsxNativeFills, spreadsheetTextOrientationCellStyle, spreadsheetTextOrientationChoiceFromCell, normalizeXlsxRichTextRun, spreadsheetDiagonalBorderFromCellValue, sameXlsxRichTextRunStyle, isLowSurrogate, spreadsheetTextOrientationFromCell, coalesceXlsxRichTextRuns, patchSpreadsheetRichTextFontRuns, replaceOfficeSpreadsheetCollaboration as replaceWorkOfficeSpreadsheetCollaboration, validXlsxRichText, readOfficeSpreadsheetCollaboration as readWorkOfficeSpreadsheetCollaboration, isSpreadsheetUnderlineStyle, spreadsheetVisibleTextRotationFromCell } from "./3266.js";
9
10
  import { moveOfficeMenuFocus, stepOfficeZoom, useOfficeRemoteParticipants, Popover, officePresenceColor, useOfficePublishPresenceLocation, button_Button, icon_button_IconButton, moveOfficeGridMenuFocus, office_text_field_OfficeTextField, useDialogFocusScope, useOfficeEditorWheelZoom } from "./0~6090.js";
10
11
  import { isOfficeKernelSpreadsheetError, normalizeCssColor, OFFICE_KERNEL_SPREADSHEET_MAX_ROWS, createOfficeId as createWorkId } from "./4121.js";
11
12
  import { useOfficeTaskPaneEscape, OfficeCheckbox, CommittedOfficeNumberField, useOfficeDialog, useOfficeTaskPaneModal, createOfficeKernelClient, officeFontFamilies, CollectionState, OfficeNumberField, handleOfficeTaskPaneKeyDown } from "./0~7048.js";
@@ -1,8 +1,8 @@
1
1
  import jszip from "jszip";
2
- import { normalizeDocumentBookmarkName, normalizeDocumentEmphasisMark, DOCUMENT_STRIKE_STYLE_ATTRIBUTE, applyDocumentImageIdentityToElement, documentEmphasisMarkFromElement, DOCUMENT_PAGE_BORDER_EDGES, DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE, createDocumentImageIdentityRegistry, normalizeDocumentColumns, normalizeDocumentTableVerticalAlign, normalizeDocumentTextCase, documentCharacterSpacingTwipsFromElement, documentCharacterPositionHalfPointsFromElement, documentTableColumnPercentagesFromElement, documentTableCellMarginOverridesFromElement, applyDocumentTableRowIdentityToElement, normalizeDocumentBookmarksHtml, documentImageIdentityFromElement, documentTableGeometryFromElement, normalizeDocumentTableRowHeightRule, documentNoteKey, DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE, normalizeDocumentHiddenText, documentLegacyTextEffectsConflict, normalizeDocumentTableBorderWidth, normalizeDocumentCharacterSpacingTwips, documentStrikeFormattingFromElement, normalizeDocumentTableBorderStyle, normalizeDocumentBookmarkReferencesHtml, documentCitationInstruction, documentImageWrapContourFromElement, documentImagePositionFromElement, normalizeDocumentCharacterScalePercent, normalizeDocumentUnderlineStyle, normalizeDocumentPageChrome, documentPageMarginsForLayout, normalizeDocumentImageLayer, documentKerningThresholdHalfPointsFromElement, documentImageCropFromElement, documentBookmarkReferenceInstruction, normalizeDocumentPageBorders, documentImageLayerFromElement, normalizeDocumentLegacyTextEffects, documentCaptionLabel, documentCaptionKind, DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE, isContourImageLayout, normalizeDocumentImageIdentity, normalizeTableColor, normalizeDocumentStrikeStyle, documentTableBordersFromElement, documentSections, documentCitationTags, docxDocumentFieldKind, wrapsBesideImage, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentKerningThresholdHalfPoints, defaultDocumentImageWrapContour, normalizeDocumentPaperSource, DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE, documentEquationFromElement, documentLegacyTextEffectsFromElement, parseDocumentCharacterFormatting, documentUnderlineFormattingFromElement, DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE, normalizeDocumentEquation, parseDocumentParagraphFormatting, documentTableRowIdentityFromElement, normalizeDocumentBookmarkNativeId, collectDocumentNotes, DOCUMENT_PAGE_MARGIN_KEYS, uniqueDocumentImageIdentity, documentHiddenTextFromElement, documentImageLayoutFromElement, documentPageHorizontalMarginTwips, documentPageGeometryForLayout, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, documentCharacterScalePercentFromElement, normalizeDocumentPageMargins, normalizeDocumentLegacyTextEffect, documentNoteKind } from "./6282.js";
3
- import { normalizeDocumentRunBorder, parseDocumentScriptFonts, parseDocxThemeReference, parseXml, parseDocumentRunShading, applyDocumentParagraphIdentityToElement, DOCUMENT_RUN_SHADING_ATTRIBUTE, documentScriptFontSlotFromElement, DOCUMENT_HIGHLIGHT_ATTRIBUTE, serializeDocumentScriptFonts, attribute as work_ooxml_package_attribute, createDocumentParagraphIdentityRegistry, uniqueDocumentParagraphIdentity, DOCUMENT_NO_PROOF_ATTRIBUTE, documentHighlightForCssColor, directChildren, documentTableOfContentsValueFromElement, DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE, DocxThemePatchCollector, normalizeDocumentScriptFonts, normalizeDocumentParagraphIdentity, normalizeDocumentHighlight, normalizeDocumentParagraphBorders, serializeUtf8Xml, DOCUMENT_PARAGRAPH_BORDER_EDGES, parseDocumentRunBorder, normalizeDocumentNoProof, decodeXmlBytes, documentParagraphIdentityFromElement, normalizeDocumentParagraphId, documentScriptFontFamily, descendants, resolvePartTarget, documentProofingLanguagesFromElement, documentHighlightFromElement, parseDocumentRunShadingElement, parseDocumentProofingLanguages, patchDocxThemeReferences, parseDocumentParagraphBordersElement, DOCUMENT_RUN_BORDER_ATTRIBUTE, parseDocumentRunBorderElement, xmlNamespacePrefix, documentScriptFontSlotFromHint, documentNoProofFromElement, documentScriptFontsFromElement, normalizeDocumentRunShading, normalizeDocumentScriptFontSlot, directChild, parseDocumentParagraphShadingElement, documentFontNameFromCssFamily } from "./4121.js";
2
+ import { normalizeDocumentBookmarkName, normalizeDocumentEmphasisMark, DOCUMENT_STRIKE_STYLE_ATTRIBUTE, applyDocumentImageIdentityToElement, documentEmphasisMarkFromElement, DOCUMENT_PAGE_BORDER_EDGES, DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE, createDocumentImageIdentityRegistry, normalizeDocumentColumns, normalizeDocumentTableVerticalAlign, normalizeDocumentTextCase, documentCharacterSpacingTwipsFromElement, documentCharacterPositionHalfPointsFromElement, documentTableColumnPercentagesFromElement, documentTableCellMarginOverridesFromElement, applyDocumentTableRowIdentityToElement, normalizeDocumentBookmarksHtml, documentImageIdentityFromElement, documentTableGeometryFromElement, normalizeDocumentTableRowHeightRule, documentNoteKey, DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE, normalizeDocumentHiddenText, documentLegacyTextEffectsConflict, normalizeDocumentTableBorderWidth, normalizeDocumentCharacterSpacingTwips, documentStrikeFormattingFromElement, normalizeDocumentTableBorderStyle, normalizeDocumentBookmarkReferencesHtml, documentCitationInstruction, documentImageWrapContourFromElement, documentImagePositionFromElement, normalizeDocumentCharacterScalePercent, normalizeDocumentUnderlineStyle, normalizeDocumentPageChrome, documentPageMarginsForLayout, normalizeDocumentImageLayer, documentKerningThresholdHalfPointsFromElement, documentImageCropFromElement, documentBookmarkReferenceInstruction, normalizeDocumentPageBorders, documentImageLayerFromElement, normalizeDocumentLegacyTextEffects, documentCaptionLabel, documentCaptionKind, DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE, isContourImageLayout, normalizeDocumentImageIdentity, normalizeTableColor, normalizeDocumentStrikeStyle, documentTableBordersFromElement, documentSections, documentCitationTags, docxDocumentFieldKind, wrapsBesideImage, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentKerningThresholdHalfPoints, defaultDocumentImageWrapContour, normalizeDocumentPaperSource, DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE, documentEquationFromElement, documentLegacyTextEffectsFromElement, parseDocumentCharacterFormatting, documentUnderlineFormattingFromElement, DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE, normalizeDocumentEquation, parseDocumentParagraphFormatting, documentTableRowIdentityFromElement, normalizeDocumentBookmarkNativeId, collectDocumentNotes, DOCUMENT_PAGE_MARGIN_KEYS, uniqueDocumentImageIdentity, documentHiddenTextFromElement, documentImageLayoutFromElement, documentPageHorizontalMarginTwips, documentPageGeometryForLayout, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, documentCharacterScalePercentFromElement, normalizeDocumentPageMargins, normalizeDocumentLegacyTextEffect, documentNoteKind } from "./4174.js";
3
+ import { normalizeDocumentRunBorder, parseDocumentScriptFonts, normalizeDocumentIndexesHtml, parseXml, parseDocumentRunShading, applyDocumentParagraphIdentityToElement, DOCUMENT_RUN_SHADING_ATTRIBUTE, documentScriptFontSlotFromElement, DOCUMENT_HIGHLIGHT_ATTRIBUTE, parseDocxThemeReference, serializeDocumentScriptFonts, attribute as work_ooxml_package_attribute, createDocumentParagraphIdentityRegistry, uniqueDocumentParagraphIdentity, DOCUMENT_NO_PROOF_ATTRIBUTE, documentHighlightForCssColor, directChildren, documentTableOfContentsValueFromElement, DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE, DocxThemePatchCollector, normalizeDocumentScriptFonts, normalizeDocumentParagraphIdentity, normalizeDocumentHighlight, normalizeDocumentParagraphBorders, serializeUtf8Xml, DOCUMENT_PARAGRAPH_BORDER_EDGES, parseDocumentRunBorder, normalizeDocumentNoProof, decodeXmlBytes, documentParagraphIdentityFromElement, normalizeDocumentParagraphId, documentIndexValueFromElement, descendants, resolvePartTarget, documentProofingLanguagesFromElement, documentScriptFontFamily, parseDocumentRunShadingElement, parseDocumentProofingLanguages, documentHighlightFromElement, parseDocumentParagraphBordersElement, DOCUMENT_RUN_BORDER_ATTRIBUTE, parseDocumentRunBorderElement, xmlNamespacePrefix, documentScriptFontSlotFromHint, documentNoProofFromElement, documentScriptFontsFromElement, normalizeDocumentRunShading, documentIndexEntryFromElement, directChild, normalizeDocumentScriptFontSlot, patchDocxThemeReferences, parseDocumentParagraphShadingElement, documentFontNameFromCssFamily } from "./4121.js";
4
4
  import { assignDocxNoteIds, patchDocxPageColor, normalizeDocxCommentId, assignDocxCommentThreads } from "./0~4980.js";
5
- import { paragraphTabStops, mergeDocxIgnorableExtensionsAtPairs, patchDocxBibliography, docxKerningThresholdValue, docxCharacterPositionValue, docxCharacterScaleValue, docxEmphasisMarkRunOptions, XMLNS_NAMESPACE as work_docx_settings_xml_XMLNS_NAMESPACE, paragraphAlignment, paragraphSpacingOptions, xmlNamespaceUri, hasNonWhitespaceXmlText, patchDocxExplicitZeroCharacterSpacing, cloneXmlElement, cssColorToHex, DocxParagraphDefaultCollapsedPatchCollector, assertXmlRoot, xmlDeclaredPrefix, paragraphIndent, domDirection, DOCX_WORDPROCESSING_NAMESPACES, paragraphBidirectional, XML_NAMESPACE as work_docx_settings_xml_XML_NAMESPACE, patchDocxParagraphDefaultCollapsed, xmlAttributeNamespace, dataBoolean, mergeDocxIgnorableExtensions, patchDocxExplicitZeroKerningThresholds, parseDocxColorSchemeMappingElement, paragraphPaginationOptions, DOCX_COLOR_SCHEME_MAPPING_ATTRIBUTES, documentProofingLanguageDocxOptions, xmlAttributeLocalName, cssFontSize, paragraphDirectionOptions, cssFontFamily, docxCharacterSpacingValue } from "./0~7231.js";
5
+ import { paragraphTabStops, mergeDocxIgnorableExtensionsAtPairs, patchDocxBibliography, docxKerningThresholdValue, docxCharacterPositionValue, documentIndexInstruction, docxCharacterScaleValue, XMLNS_NAMESPACE as work_docx_settings_xml_XMLNS_NAMESPACE, paragraphAlignment, xmlNamespaceUri, paragraphSpacingOptions, docxEmphasisMarkRunOptions, documentIndexEntryInstruction, hasNonWhitespaceXmlText, patchDocxExplicitZeroCharacterSpacing, cloneXmlElement, cssColorToHex, xmlDeclaredPrefix, assertXmlRoot, DOCX_WORDPROCESSING_NAMESPACES, paragraphIndent, domDirection, xmlAttributeNamespace, paragraphBidirectional, XML_NAMESPACE as work_docx_settings_xml_XML_NAMESPACE, mergeDocxIgnorableExtensions, DocxParagraphDefaultCollapsedPatchCollector, dataBoolean, patchDocxParagraphDefaultCollapsed, patchDocxExplicitZeroKerningThresholds, parseDocxColorSchemeMappingElement, paragraphPaginationOptions, DOCX_COLOR_SCHEME_MAPPING_ATTRIBUTES, documentProofingLanguageDocxOptions, xmlAttributeLocalName, cssFontSize, paragraphDirectionOptions, cssFontFamily, docxCharacterSpacingValue } from "./0~4808.js";
6
6
  import { normalizeDocumentHref } from "./0~work-document-links.js";
7
7
  const WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
8
8
  class DocxBookmarkPatchCollector {
@@ -2374,6 +2374,185 @@ function docxDocumentFieldRun(element, docx) {
2374
2374
  if (!docxDocumentFieldKind(instruction)) return new docx.TextRun(display);
2375
2375
  return new docx.SimpleField(instruction, display);
2376
2376
  }
2377
+ const work_docx_index_export_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
2378
+ const work_docx_index_export_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
2379
+ class DocxIndexPatchCollector {
2380
+ patches = [];
2381
+ add(element) {
2382
+ const value = documentIndexValueFromElement(element);
2383
+ const patch = {
2384
+ marker: `__A3S_WORK_DOCUMENT_INDEX_${this.patches.length + 1}__`,
2385
+ options: value.options,
2386
+ entries: value.entries
2387
+ };
2388
+ this.patches.push(patch);
2389
+ return patch;
2390
+ }
2391
+ }
2392
+ function docxDocumentIndex(element, docx, collector) {
2393
+ const patch = collector.add(element);
2394
+ return [
2395
+ new docx.Paragraph({
2396
+ children: [
2397
+ new docx.TextRun(patch.marker)
2398
+ ]
2399
+ })
2400
+ ];
2401
+ }
2402
+ function docxIndexEntryRun(element, docx) {
2403
+ const value = documentIndexEntryFromElement(element);
2404
+ return value ? new docx.SimpleField(documentIndexEntryInstruction(value)) : null;
2405
+ }
2406
+ async function patchDocxIndexes(buffer, patches) {
2407
+ if (!patches.length) return buffer;
2408
+ const archive = await jszip.loadAsync(buffer);
2409
+ const entry = archive.file('word/document.xml');
2410
+ if (!entry) return buffer;
2411
+ const document = parseXml(await entry.async('text'), 'generated DOCX word/document.xml');
2412
+ const paragraphs = descendants(document, 'p');
2413
+ for (const patch of patches){
2414
+ const paragraph = paragraphs.find((candidate)=>descendants(candidate, 't').some((text)=>(text.textContent ?? '').includes(patch.marker)));
2415
+ if (!paragraph) throw new Error(`Generated DOCX did not emit the marker for document index ${patch.marker}.`);
2416
+ paragraph.replaceWith(createIndexContentControl(document, patch));
2417
+ }
2418
+ archive.file('word/document.xml', new XMLSerializer().serializeToString(document));
2419
+ return archive.generateAsync({
2420
+ type: 'arraybuffer'
2421
+ });
2422
+ }
2423
+ function createIndexContentControl(document, patch) {
2424
+ const control = wordElement(document, 'sdt');
2425
+ const properties = wordElement(document, 'sdtPr');
2426
+ const documentPart = wordElement(document, 'docPartObj');
2427
+ const gallery = wordElement(document, 'docPartGallery');
2428
+ work_docx_index_export_setWordAttribute(document, gallery, 'val', 'Indexes');
2429
+ documentPart.append(gallery, wordElement(document, 'docPartUnique'));
2430
+ properties.append(documentPart);
2431
+ const content = wordElement(document, 'sdtContent');
2432
+ const fieldStart = indexFieldStartParagraph(document, patch.options);
2433
+ content.append(fieldStart);
2434
+ const cached = cachedIndexParagraphs(document, patch);
2435
+ if (!cached.length) cached.push(emptyIndexParagraph(document));
2436
+ const last = cached.at(-1);
2437
+ last?.append(fieldCharacterRun(document, 'end'));
2438
+ content.append(...cached);
2439
+ control.append(properties, content);
2440
+ return control;
2441
+ }
2442
+ function indexFieldStartParagraph(document, options) {
2443
+ const paragraph = wordElement(document, 'p');
2444
+ paragraph.append(fieldCharacterRun(document, 'begin'));
2445
+ const instructionRun = wordElement(document, 'r');
2446
+ const instruction = wordElement(document, 'instrText');
2447
+ instruction.setAttributeNS(work_docx_index_export_XML_NAMESPACE, 'xml:space', 'preserve');
2448
+ instruction.textContent = ` ${documentIndexInstruction(options)} `;
2449
+ instructionRun.append(instruction);
2450
+ paragraph.append(instructionRun, fieldCharacterRun(document, 'separate'));
2451
+ return paragraph;
2452
+ }
2453
+ function cachedIndexParagraphs(document, patch) {
2454
+ const paragraphs = [];
2455
+ let currentMain = '';
2456
+ for (const entry of patch.entries){
2457
+ if (entry.subEntry && entry.mainEntry !== currentMain) paragraphs.push(cachedIndexParagraph(document, patch.options, {
2458
+ style: 'Index1',
2459
+ term: entry.mainEntry,
2460
+ crossReference: '',
2461
+ pages: []
2462
+ }));
2463
+ paragraphs.push(cachedIndexParagraph(document, patch.options, {
2464
+ style: entry.subEntry ? 'Index2' : 'Index1',
2465
+ term: entry.subEntry || entry.mainEntry,
2466
+ crossReference: entry.crossReference,
2467
+ pages: entry.pages
2468
+ }));
2469
+ currentMain = entry.mainEntry;
2470
+ }
2471
+ return paragraphs;
2472
+ }
2473
+ function cachedIndexParagraph(document, options, source) {
2474
+ const paragraph = wordElement(document, 'p');
2475
+ const properties = wordElement(document, 'pPr');
2476
+ const style = wordElement(document, 'pStyle');
2477
+ work_docx_index_export_setWordAttribute(document, style, 'val', source.style);
2478
+ properties.append(style);
2479
+ if (source.pages.length && options.rightAlignPageNumbers) {
2480
+ const tabs = wordElement(document, 'tabs');
2481
+ const tab = wordElement(document, 'tab');
2482
+ work_docx_index_export_setWordAttribute(document, tab, 'val', 'right');
2483
+ const leader = docxIndexLeader(options.leader);
2484
+ if (leader) work_docx_index_export_setWordAttribute(document, tab, 'leader', leader);
2485
+ work_docx_index_export_setWordAttribute(document, tab, 'pos', '9360');
2486
+ tabs.append(tab);
2487
+ properties.append(tabs);
2488
+ }
2489
+ paragraph.append(properties, textRun(document, source.term));
2490
+ if (source.crossReference) {
2491
+ paragraph.append(textRun(document, `, See ${source.crossReference}`));
2492
+ return paragraph;
2493
+ }
2494
+ if (!source.pages.length) return paragraph;
2495
+ paragraph.append(options.rightAlignPageNumbers ? tabRun(document) : textRun(document, ', '));
2496
+ for (const [index, page] of source.pages.entries()){
2497
+ if (index > 0) paragraph.append(textRun(document, ', '));
2498
+ paragraph.append(textRun(document, String(page.pageNumber), {
2499
+ bold: page.pageBold,
2500
+ italic: page.pageItalic
2501
+ }));
2502
+ }
2503
+ return paragraph;
2504
+ }
2505
+ function emptyIndexParagraph(document) {
2506
+ const paragraph = wordElement(document, 'p');
2507
+ const properties = wordElement(document, 'pPr');
2508
+ const style = wordElement(document, 'pStyle');
2509
+ work_docx_index_export_setWordAttribute(document, style, 'val', 'Index1');
2510
+ properties.append(style);
2511
+ paragraph.append(properties);
2512
+ return paragraph;
2513
+ }
2514
+ function textRun(document, value, style = {}) {
2515
+ const run = wordElement(document, 'r');
2516
+ if (style.bold || style.italic) {
2517
+ const properties = wordElement(document, 'rPr');
2518
+ if (style.bold) properties.append(wordElement(document, 'b'));
2519
+ if (style.italic) properties.append(wordElement(document, 'i'));
2520
+ run.append(properties);
2521
+ }
2522
+ const text = wordElement(document, 't');
2523
+ if (/^\s|\s$/.test(value)) text.setAttributeNS(work_docx_index_export_XML_NAMESPACE, 'xml:space', 'preserve');
2524
+ text.textContent = value;
2525
+ run.append(text);
2526
+ return run;
2527
+ }
2528
+ function tabRun(document) {
2529
+ const run = wordElement(document, 'r');
2530
+ run.append(wordElement(document, 'tab'));
2531
+ return run;
2532
+ }
2533
+ function fieldCharacterRun(document, type) {
2534
+ const run = wordElement(document, 'r');
2535
+ const character = wordElement(document, 'fldChar');
2536
+ work_docx_index_export_setWordAttribute(document, character, 'fldCharType', type);
2537
+ run.append(character);
2538
+ return run;
2539
+ }
2540
+ function docxIndexLeader(value) {
2541
+ if ('dash' === value) return 'hyphen';
2542
+ if ('underline' === value) return 'underscore';
2543
+ if ('dot' === value) return 'dot';
2544
+ return null;
2545
+ }
2546
+ function wordElement(document, localName) {
2547
+ return document.createElementNS(work_docx_index_export_WORD_NAMESPACE, wordQualifiedName(document.documentElement, localName));
2548
+ }
2549
+ function work_docx_index_export_setWordAttribute(document, element, localName, value) {
2550
+ for (const candidate of Array.from(element.attributes))if (candidate.localName === localName && (candidate.namespaceURI === work_docx_index_export_WORD_NAMESPACE || !candidate.namespaceURI)) element.removeAttributeNode(candidate);
2551
+ element.setAttributeNS(work_docx_index_export_WORD_NAMESPACE, wordQualifiedName(document.documentElement, localName), value);
2552
+ }
2553
+ function wordQualifiedName(root, localName) {
2554
+ return `${xmlNamespacePrefix(root, work_docx_index_export_WORD_NAMESPACE) ?? 'w'}:${localName}`;
2555
+ }
2377
2556
  const work_docx_run_shading_export_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
2378
2557
  class DocxRunShadingPatchCollector {
2379
2558
  patches = [];
@@ -2581,17 +2760,17 @@ function setRunFormattingChange(document, run, patch) {
2581
2760
  if (existing.length > 1) throw new Error('Generated DOCX run contains duplicate properties.');
2582
2761
  const properties = existing[0] ?? insertRunProperties(document, run, wordNamespace, prefix);
2583
2762
  if (directChildren(properties, 'rPrChange').some((element)=>element.namespaceURI === wordNamespace)) throw new Error('Generated DOCX run already contains a formatting revision.');
2584
- const change = wordElement(document, wordNamespace, prefix, 'rPrChange');
2763
+ const change = work_docx_format_change_export_wordElement(document, wordNamespace, prefix, 'rPrChange');
2585
2764
  work_docx_format_change_export_setWordAttribute(change, wordNamespace, prefix, 'id', String(patch.id));
2586
2765
  work_docx_format_change_export_setWordAttribute(change, wordNamespace, prefix, 'author', patch.author);
2587
2766
  work_docx_format_change_export_setWordAttribute(change, wordNamespace, prefix, 'date', patch.date);
2588
- const before = wordElement(document, wordNamespace, prefix, 'rPr');
2767
+ const before = work_docx_format_change_export_wordElement(document, wordNamespace, prefix, 'rPr');
2589
2768
  appendFormattingProperties(document, before, wordNamespace, prefix, patch.before);
2590
2769
  change.append(before);
2591
2770
  properties.append(change);
2592
2771
  }
2593
2772
  function insertRunProperties(document, run, namespace, prefix) {
2594
- const properties = wordElement(document, namespace, prefix, 'rPr');
2773
+ const properties = work_docx_format_change_export_wordElement(document, namespace, prefix, 'rPr');
2595
2774
  run.insertBefore(properties, run.firstChild);
2596
2775
  return properties;
2597
2776
  }
@@ -2630,13 +2809,13 @@ function appendFormattingProperties(document, properties, namespace, prefix, ser
2630
2809
  function appendNoProofProperty(document, properties, namespace, prefix, mark) {
2631
2810
  const noProof = normalizeDocumentNoProof(mark?.attrs?.noProof);
2632
2811
  if (null === noProof) return;
2633
- if (noProof) properties.append(wordElement(document, namespace, prefix, 'noProof'));
2812
+ if (noProof) properties.append(work_docx_format_change_export_wordElement(document, namespace, prefix, 'noProof'));
2634
2813
  else appendValuedProperty(document, properties, namespace, prefix, 'noProof', '0');
2635
2814
  }
2636
2815
  function appendProofingLanguagesProperty(document, properties, namespace, prefix, mark) {
2637
2816
  const languages = parseDocumentProofingLanguages(mark?.attrs?.proofingLanguages);
2638
2817
  if (!languages) return;
2639
- const element = wordElement(document, namespace, prefix, 'lang');
2818
+ const element = work_docx_format_change_export_wordElement(document, namespace, prefix, 'lang');
2640
2819
  if (languages.latin) work_docx_format_change_export_setWordAttribute(element, namespace, prefix, 'val', languages.latin);
2641
2820
  if (languages.eastAsia) work_docx_format_change_export_setWordAttribute(element, namespace, prefix, 'eastAsia', languages.eastAsia);
2642
2821
  if (languages.bidi) work_docx_format_change_export_setWordAttribute(element, namespace, prefix, 'bidi', languages.bidi);
@@ -2645,7 +2824,7 @@ function appendProofingLanguagesProperty(document, properties, namespace, prefix
2645
2824
  function appendRunBorderProperty(document, properties, namespace, prefix, mark) {
2646
2825
  const border = parseDocumentRunBorder(mark?.attrs?.runBorder);
2647
2826
  if (!border) return;
2648
- const element = wordElement(document, namespace, prefix, 'bdr');
2827
+ const element = work_docx_format_change_export_wordElement(document, namespace, prefix, 'bdr');
2649
2828
  work_docx_format_change_export_setWordAttribute(element, namespace, prefix, 'val', border.style);
2650
2829
  if (border.color) {
2651
2830
  work_docx_format_change_export_setWordAttribute(element, namespace, prefix, 'color', 'auto' === border.color.value ? 'auto' : border.color.value.slice(1).toUpperCase());
@@ -2664,7 +2843,7 @@ function appendRunBorderProperty(document, properties, namespace, prefix, mark)
2664
2843
  function appendRunShadingProperty(document, properties, namespace, prefix, mark) {
2665
2844
  const shading = parseDocumentRunShading(mark?.attrs?.runShading);
2666
2845
  if (!shading) return;
2667
- const element = wordElement(document, namespace, prefix, 'shd');
2846
+ const element = work_docx_format_change_export_wordElement(document, namespace, prefix, 'shd');
2668
2847
  if (!setDocxRunShadingAttributes(document, element, shading)) return;
2669
2848
  properties.append(element);
2670
2849
  }
@@ -2695,14 +2874,14 @@ function appendLegacyTextEffectsProperties(document, properties, namespace, pref
2695
2874
  if (documentLegacyTextEffectsConflict(effects)) throw new Error('Document contains conflicting legacy text effects.');
2696
2875
  for (const name of DOCUMENT_LEGACY_TEXT_EFFECT_NAMES){
2697
2876
  const value = effects[name];
2698
- if (void 0 !== value) if (value) properties.append(wordElement(document, namespace, prefix, name));
2877
+ if (void 0 !== value) if (value) properties.append(work_docx_format_change_export_wordElement(document, namespace, prefix, name));
2699
2878
  else appendValuedProperty(document, properties, namespace, prefix, name, '0');
2700
2879
  }
2701
2880
  }
2702
2881
  function appendHiddenTextProperty(document, properties, namespace, prefix, mark) {
2703
2882
  const hiddenText = normalizeDocumentHiddenText(mark?.attrs?.hiddenText);
2704
2883
  if (null === hiddenText) return;
2705
- if (hiddenText) properties.append(wordElement(document, namespace, prefix, 'vanish'));
2884
+ if (hiddenText) properties.append(work_docx_format_change_export_wordElement(document, namespace, prefix, 'vanish'));
2706
2885
  else appendValuedProperty(document, properties, namespace, prefix, 'vanish', '0');
2707
2886
  }
2708
2887
  function appendEmphasisMarkProperty(document, properties, namespace, prefix, mark) {
@@ -2733,7 +2912,7 @@ function appendCharacterSpacingProperty(document, properties, namespace, prefix,
2733
2912
  function appendFontProperties(document, properties, namespace, prefix, mark) {
2734
2913
  const scriptFonts = parseDocumentScriptFonts('string' == typeof mark?.attrs?.scriptFonts ? mark.attrs.scriptFonts : void 0);
2735
2914
  if (scriptFonts) {
2736
- const fonts = wordElement(document, namespace, prefix, 'rFonts');
2915
+ const fonts = work_docx_format_change_export_wordElement(document, namespace, prefix, 'rFonts');
2737
2916
  for (const [name, value] of [
2738
2917
  [
2739
2918
  'ascii',
@@ -2777,7 +2956,7 @@ function appendFontProperties(document, properties, namespace, prefix, mark) {
2777
2956
  }
2778
2957
  const family = firstFontFamily(mark?.attrs?.fontFamily);
2779
2958
  if (!family) return;
2780
- const fonts = wordElement(document, namespace, prefix, 'rFonts');
2959
+ const fonts = work_docx_format_change_export_wordElement(document, namespace, prefix, 'rFonts');
2781
2960
  for (const name of [
2782
2961
  'ascii',
2783
2962
  'hAnsi',
@@ -2791,7 +2970,7 @@ function appendUnderlineProperty(document, properties, namespace, prefix, mark)
2791
2970
  const style = normalizeDocumentUnderlineStyle(mark.attrs?.underlineStyle) ?? 'single';
2792
2971
  const color = normalizedHex(mark.attrs?.underlineColor);
2793
2972
  const theme = themeReference(mark.attrs?.underlineThemeColor);
2794
- const underline = wordElement(document, namespace, prefix, 'u');
2973
+ const underline = work_docx_format_change_export_wordElement(document, namespace, prefix, 'u');
2795
2974
  work_docx_format_change_export_setWordAttribute(underline, namespace, prefix, 'val', style);
2796
2975
  const resolved = color ?? normalizedHex(theme?.resolved);
2797
2976
  if (resolved) work_docx_format_change_export_setWordAttribute(underline, namespace, prefix, 'color', resolved);
@@ -2799,7 +2978,7 @@ function appendUnderlineProperty(document, properties, namespace, prefix, mark)
2799
2978
  properties.append(underline);
2800
2979
  }
2801
2980
  function appendBooleanProperty(document, properties, namespace, prefix, marks, mark, property) {
2802
- if (marks.has(mark)) properties.append(wordElement(document, namespace, prefix, property));
2981
+ if (marks.has(mark)) properties.append(work_docx_format_change_export_wordElement(document, namespace, prefix, property));
2803
2982
  }
2804
2983
  function appendStrikeProperties(document, properties, namespace, prefix, mark) {
2805
2984
  if (!mark) return;
@@ -2808,14 +2987,14 @@ function appendStrikeProperties(document, properties, namespace, prefix, mark) {
2808
2987
  appendValuedProperty(document, properties, namespace, prefix, 'dstrike', 'double' === style ? '1' : '0');
2809
2988
  }
2810
2989
  function appendValuedProperty(document, properties, namespace, prefix, property, value) {
2811
- const element = wordElement(document, namespace, prefix, property);
2990
+ const element = work_docx_format_change_export_wordElement(document, namespace, prefix, property);
2812
2991
  work_docx_format_change_export_setWordAttribute(element, namespace, prefix, 'val', value);
2813
2992
  properties.append(element);
2814
2993
  }
2815
2994
  function appendTextCaseProperties(document, properties, namespace, prefix, mark) {
2816
2995
  const textCase = mark?.attrs?.textCase;
2817
- if ('all-caps' === textCase) properties.append(wordElement(document, namespace, prefix, 'caps'));
2818
- else if ('small-caps' === textCase) properties.append(wordElement(document, namespace, prefix, 'smallCaps'));
2996
+ if ('all-caps' === textCase) properties.append(work_docx_format_change_export_wordElement(document, namespace, prefix, 'caps'));
2997
+ else if ('small-caps' === textCase) properties.append(work_docx_format_change_export_wordElement(document, namespace, prefix, 'smallCaps'));
2819
2998
  else if ('none' === textCase) {
2820
2999
  appendValuedProperty(document, properties, namespace, prefix, 'caps', '0');
2821
3000
  appendValuedProperty(document, properties, namespace, prefix, 'smallCaps', '0');
@@ -2825,7 +3004,7 @@ function appendColorProperty(document, properties, namespace, prefix, mark) {
2825
3004
  const color = normalizedHex(mark?.attrs?.color);
2826
3005
  const theme = themeReference(mark?.attrs?.themeColor);
2827
3006
  if (!color && !theme) return;
2828
- const element = wordElement(document, namespace, prefix, 'color');
3007
+ const element = work_docx_format_change_export_wordElement(document, namespace, prefix, 'color');
2829
3008
  work_docx_format_change_export_setWordAttribute(element, namespace, prefix, 'val', color ?? normalizedHex(theme?.resolved) ?? '000000');
2830
3009
  if (theme) setThemeAttributes(element, namespace, prefix, theme, 'themeColor');
2831
3010
  properties.append(element);
@@ -2843,7 +3022,7 @@ function appendHighlightProperty(document, properties, namespace, prefix, mark,
2843
3022
  const fill = normalizedHex(mark?.attrs?.color);
2844
3023
  const theme = themeReference(mark?.attrs?.themeFill);
2845
3024
  if (!fill && !theme) return;
2846
- const shading = wordElement(document, namespace, prefix, 'shd');
3025
+ const shading = work_docx_format_change_export_wordElement(document, namespace, prefix, 'shd');
2847
3026
  work_docx_format_change_export_setWordAttribute(shading, namespace, prefix, 'val', 'clear');
2848
3027
  work_docx_format_change_export_setWordAttribute(shading, namespace, prefix, 'color', 'auto');
2849
3028
  work_docx_format_change_export_setWordAttribute(shading, namespace, prefix, 'fill', fill ?? normalizedHex(theme?.resolved) ?? 'FFFFFF');
@@ -2891,7 +3070,7 @@ function normalizedHex(value) {
2891
3070
  const match = /^#?([0-9a-f]{6})$/i.exec(value.trim());
2892
3071
  return match?.[1]?.toUpperCase() ?? null;
2893
3072
  }
2894
- function wordElement(document, namespace, prefix, name) {
3073
+ function work_docx_format_change_export_wordElement(document, namespace, prefix, name) {
2895
3074
  return document.createElementNS(namespace, `${prefix}:${name}`);
2896
3075
  }
2897
3076
  function work_docx_format_change_export_setWordAttribute(element, namespace, prefix, name, value) {
@@ -3665,10 +3844,10 @@ async function patchDocxNumberingRestartRules(buffer, rules) {
3665
3844
  if (!definition) continue;
3666
3845
  let restart = directChild(definition, 'lvlRestart');
3667
3846
  if (!restart) {
3668
- restart = document.createElementNS(work_docx_numbering_WORD_NAMESPACE, wordQualifiedName(document.documentElement, 'lvlRestart'));
3847
+ restart = document.createElementNS(work_docx_numbering_WORD_NAMESPACE, work_docx_numbering_wordQualifiedName(document.documentElement, 'lvlRestart'));
3669
3848
  definition.insertBefore(restart, directChild(definition, 'pPr') ?? null);
3670
3849
  }
3671
- restart.setAttributeNS(work_docx_numbering_WORD_NAMESPACE, wordQualifiedName(document.documentElement, 'val'), String(restartAfterLevel));
3850
+ restart.setAttributeNS(work_docx_numbering_WORD_NAMESPACE, work_docx_numbering_wordQualifiedName(document.documentElement, 'val'), String(restartAfterLevel));
3672
3851
  }
3673
3852
  }
3674
3853
  archive.file('word/numbering.xml', new XMLSerializer().serializeToString(document));
@@ -3676,7 +3855,7 @@ async function patchDocxNumberingRestartRules(buffer, rules) {
3676
3855
  type: 'arraybuffer'
3677
3856
  });
3678
3857
  }
3679
- function wordQualifiedName(root, localName) {
3858
+ function work_docx_numbering_wordQualifiedName(root, localName) {
3680
3859
  return `${xmlNamespacePrefix(root, work_docx_numbering_WORD_NAMESPACE) ?? root.prefix ?? 'w'}:${localName}`;
3681
3860
  }
3682
3861
  const work_docx_paragraph_format_change_export_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
@@ -8212,7 +8391,7 @@ async function createDocxBlob(content, sourcePackage) {
8212
8391
  const docx = await import("docx");
8213
8392
  const normalizedContent = {
8214
8393
  ...content,
8215
- html: normalizeDocumentBookmarkReferencesHtml(normalizeDocumentBookmarksHtml(content.html))
8394
+ html: normalizeDocumentIndexesHtml(normalizeDocumentBookmarkReferencesHtml(normalizeDocumentBookmarksHtml(content.html)))
8216
8395
  };
8217
8396
  const noteCollection = collectDocumentNotes(normalizedContent.html);
8218
8397
  const comments = anchoredDocumentComments(normalizedContent);
@@ -8252,6 +8431,7 @@ async function createDocxBlob(content, sourcePackage) {
8252
8431
  usedNativeTextEffectMarkers: new Set(),
8253
8432
  paragraphFormattingChangePatches: new DocxParagraphFormattingChangePatchCollector(),
8254
8433
  tableOfContentsPatches: new DocxTableOfContentsPatchCollector(),
8434
+ indexPatches: new DocxIndexPatchCollector(),
8255
8435
  hasExplicitZeroCharacterSpacing: false,
8256
8436
  hasExplicitZeroKerningThreshold: false
8257
8437
  };
@@ -8323,7 +8503,8 @@ async function createDocxBlob(content, sourcePackage) {
8323
8503
  const paragraphDefaultCollapsedPatched = await patchDocxParagraphDefaultCollapsed(bookmarkPatched, noteContext.paragraphDefaultCollapsedPatches.patches);
8324
8504
  const paragraphIdentityPatched = await patchDocxParagraphIdentities(paragraphDefaultCollapsedPatched, noteContext.paragraphIdentityPatches.patches);
8325
8505
  const tableOfContentsPatched = await patchDocxTableOfContents(paragraphIdentityPatched, noteContext.tableOfContentsPatches.patches);
8326
- const paragraphFormattingChangesPatched = await patchDocxParagraphFormattingChanges(tableOfContentsPatched, noteContext.paragraphFormattingChangePatches.patches);
8506
+ const indexPatched = await patchDocxIndexes(tableOfContentsPatched, noteContext.indexPatches.patches);
8507
+ const paragraphFormattingChangesPatched = await patchDocxParagraphFormattingChanges(indexPatched, noteContext.paragraphFormattingChangePatches.patches);
8327
8508
  const equationPatched = await patchDocxEquations(paragraphFormattingChangesPatched, noteContext.equationPatches.patches);
8328
8509
  const patched = await patchDocxPageColor(equationPatched, normalizedContent.pageColor);
8329
8510
  const preserved = sourcePackage ? await preserveDocxSourcePackage(patched, sourcePackage, {
@@ -8497,6 +8678,7 @@ async function blockToFileChildren(element, docx, noteContext) {
8497
8678
  if (element.hasAttribute('data-document-table-of-contents')) return [
8498
8679
  docxTableOfContents(element, docx, noteContext.tableOfContentsPatches)
8499
8680
  ];
8681
+ if (element.hasAttribute('data-document-index')) return docxDocumentIndex(element, docx, noteContext.indexPatches);
8500
8682
  if (element.hasAttribute('data-document-caption')) return [
8501
8683
  docxCaptionParagraph(element, await paragraphRuns(element, docx, noteContext), docx, paragraphBidirectional(element))
8502
8684
  ];
@@ -8608,6 +8790,12 @@ async function work_docx_export_inlineRuns(root, docx, noteContext) {
8608
8790
  if (node.hasAttribute('data-document-field')) return [
8609
8791
  docxDocumentFieldRun(node, docx)
8610
8792
  ];
8793
+ if (node.hasAttribute('data-document-index-entry')) {
8794
+ const entry = docxIndexEntryRun(node, docx);
8795
+ return entry ? [
8796
+ entry
8797
+ ] : [];
8798
+ }
8611
8799
  if (node.hasAttribute('data-document-equation')) {
8612
8800
  const equation = noteContext.equationPatches.marker(node);
8613
8801
  return [
@@ -1,8 +1,8 @@
1
1
  import jszip from "jszip";
2
- import { documentRunBorderDomAttributes, contentTypeForPart, bytesToDataUrl, OoxmlPackage, 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 "./6282.js";
4
- import { markDocxRunFormattingIntoState, applyImportedDocxParagraphSpacingMarkers, hasImportedDocxParagraphDirectionMarkers, hasImportedDocxParagraphIndentMarkers, resolveDocxParagraphBordersForParagraph, applyImportedDocxParagraphShadingMarkers, markDocxParagraphSpacing, docxCaptionBookmark, docxFieldResultText, createDocxParagraphStyleResolver, docxTableCellStyleLayers, createImportedDocxRunFormattingMarkerState, parseDocxPaperSource, resolveDocxLegacyTextEffects, markDocxTablesOfContents, hasImportedDocxParagraphSpacingMarkers, docxTablePropertySources, applyImportedDocxTableOfContentsMarkers, parseDocxPageMargins, parseDirectDocxParagraphShading, markDocxPackageEquations, parseDocxPageGeometry, markDocxParagraphIndents, resolveDocxRunBorder, 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~7360.js";
5
- import { readDocxBibliography, resolveDocxProofing, XMLNS_NAMESPACE, docxCharacterScalePercentFromProperties, docxCharacterSpacingTwipsFromProperties, parseBoundedDocxInteger, xmlAttributeLocalName, resolveDocxEmphasisMark, createDocxThemeResolver, docxCharacterPositionHalfPointsFromProperties, docxThemeColor, parseDocxParagraphDefaultCollapsed, resolveDocxKerningThresholdHalfPoints, resolveDocxThemeResolver, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace } from "./0~7231.js";
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";
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";
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';
@@ -508,34 +508,17 @@ function work_docx_change_import_markerRun(document, value) {
508
508
  return run;
509
509
  }
510
510
  function wrapMarkerRange(root, start, end, wrapper) {
511
- const nodes = work_docx_change_import_textNodes(root);
512
- const startNode = nodes.find((node)=>node.data.includes(start));
513
- const endNode = nodes.find((node)=>node.data.includes(end));
514
- if (!startNode || !endNode) return false;
515
- const startIndex = startNode.data.indexOf(start);
516
- const endIndex = endNode.data.indexOf(end);
517
- if (startNode === endNode && endIndex < startIndex) return false;
518
- const range = root.ownerDocument.createRange();
519
- range.setStart(startNode, startIndex);
520
- range.setEnd(endNode, endIndex + end.length);
521
- const content = range.extractContents();
522
- work_docx_change_import_removeMarkerText(content, start);
523
- work_docx_change_import_removeMarkerText(content, end);
524
- wrapper.append(content);
525
- range.insertNode(wrapper);
511
+ const html = root.innerHTML;
512
+ const startIndex = html.indexOf(start);
513
+ const endIndex = html.indexOf(end, startIndex + start.length);
514
+ if (startIndex < 0 || endIndex < 0) return false;
515
+ const closingTag = `</${wrapper.localName}>`;
516
+ const serializedWrapper = wrapper.outerHTML;
517
+ if (!serializedWrapper.endsWith(closingTag)) return false;
518
+ const openingTag = serializedWrapper.slice(0, -closingTag.length);
519
+ root.innerHTML = `${html.slice(0, startIndex)}${openingTag}${html.slice(startIndex + start.length, endIndex)}${closingTag}${html.slice(endIndex + end.length)}`;
526
520
  return true;
527
521
  }
528
- function work_docx_change_import_removeMarkerText(root, marker) {
529
- for (const node of work_docx_change_import_textNodes(root))node.data = node.data.replace(marker, '');
530
- }
531
- function work_docx_change_import_textNodes(root) {
532
- const document = root.ownerDocument;
533
- const walker = document?.createTreeWalker(root, NodeFilter.SHOW_TEXT);
534
- const nodes = [];
535
- if (!walker) return nodes;
536
- while(walker.nextNode())nodes.push(walker.currentNode);
537
- return nodes;
538
- }
539
522
  function closestRevision(element) {
540
523
  let current = element;
541
524
  while(current){
@@ -2899,6 +2882,10 @@ async function prepareDocxImport(buffer, sourcePackage) {
2899
2882
  tableOfContentsMarkers: {
2900
2883
  tables: []
2901
2884
  },
2885
+ indexMarkers: {
2886
+ entries: [],
2887
+ indexes: []
2888
+ },
2902
2889
  equationMarkers: {
2903
2890
  equations: []
2904
2891
  },
@@ -2965,6 +2952,7 @@ async function prepareDocxImport(buffer, sourcePackage) {
2965
2952
  const document = await archive.xml('word/document.xml');
2966
2953
  const pageColor = importDocxPageColor(document);
2967
2954
  const tableOfContentsMarkers = markDocxTablesOfContents(document);
2955
+ const indexMarkers = markDocxIndexes(document);
2968
2956
  const paragraphIdentityMarkers = markDocxParagraphIdentities(document);
2969
2957
  const numbering = archive.has('word/numbering.xml') ? await archive.xml('word/numbering.xml') : null;
2970
2958
  const commentMarkers = await markDocxComments(document, archive);
@@ -3009,7 +2997,7 @@ async function prepareDocxImport(buffer, sourcePackage) {
3009
2997
  const trackChanges = Boolean(settings && firstDescendant(settings, 'trackRevisions')) || changeMarkers.changes.length > 0 || paragraphFormattingChangeMarkers.paragraphs.length > 0 || runFormattingMarkers.runs.some((run)=>Boolean(run.change));
3010
2998
  const sectionElements = effectiveSectionProperties(document);
3011
2999
  if (!sectionElements.length) return {
3012
- conversionBuffer: hasImportedDocxCaptionMarkers(captionMarkers) || hasImportedDocxBookmarkMarkers(bookmarkMarkers) || hasImportedDocxChangeMarkers(changeMarkers) || hasImportedDocxCommentMarkers(commentMarkers) || hasImportedDocxCitationMarkers(citationMarkers) || hasImportedDocxFieldMarkers(fieldMarkers) || hasImportedDocxTableOfContentsMarkers(tableOfContentsMarkers) || equationMarkers.changed || hasImportedDocxListMarkers(listMarkers) || hasImportedDocxImageLayoutMarkers(imageLayoutMarkers) || hasImportedDocxParagraphIdentityMarkers(paragraphIdentityMarkers) || hasImportedDocxParagraphFormattingChangeMarkers(paragraphFormattingChangeMarkers) || hasImportedDocxParagraphAlignmentMarkers(paragraphAlignmentMarkers) || hasImportedDocxParagraphDirectionMarkers(paragraphDirectionMarkers) || hasImportedDocxParagraphIndentMarkers(paragraphIndentMarkers) || hasImportedDocxParagraphSpacingMarkers(paragraphSpacingMarkers) || hasImportedDocxParagraphBorderMarkers(paragraphBorderMarkers) || hasImportedDocxParagraphShadingMarkers(paragraphShadingMarkers) || hasImportedDocxParagraphPaginationMarkers(paragraphPaginationMarkers) || hasImportedDocxRunFormattingMarkers(runFormattingMarkers) || hasImportedDocxParagraphTabStopMarkers(tabStopMarkers) || hasImportedDocxTableCellMarkers(tableCellMarkers) || hasImportedDocxTableRowMarkers(tableRowMarkers) || hasImportedDocxTableSizingMarkers(tableSizingMarkers) ? await writeDocumentXml(buffer, document, equationMarkers.parts) : buffer,
3000
+ conversionBuffer: hasImportedDocxCaptionMarkers(captionMarkers) || hasImportedDocxBookmarkMarkers(bookmarkMarkers) || hasImportedDocxChangeMarkers(changeMarkers) || hasImportedDocxCommentMarkers(commentMarkers) || hasImportedDocxCitationMarkers(citationMarkers) || hasImportedDocxFieldMarkers(fieldMarkers) || hasImportedDocxTableOfContentsMarkers(tableOfContentsMarkers) || hasImportedDocxIndexMarkers(indexMarkers) || equationMarkers.changed || hasImportedDocxListMarkers(listMarkers) || hasImportedDocxImageLayoutMarkers(imageLayoutMarkers) || hasImportedDocxParagraphIdentityMarkers(paragraphIdentityMarkers) || hasImportedDocxParagraphFormattingChangeMarkers(paragraphFormattingChangeMarkers) || hasImportedDocxParagraphAlignmentMarkers(paragraphAlignmentMarkers) || hasImportedDocxParagraphDirectionMarkers(paragraphDirectionMarkers) || hasImportedDocxParagraphIndentMarkers(paragraphIndentMarkers) || hasImportedDocxParagraphSpacingMarkers(paragraphSpacingMarkers) || hasImportedDocxParagraphBorderMarkers(paragraphBorderMarkers) || hasImportedDocxParagraphShadingMarkers(paragraphShadingMarkers) || hasImportedDocxParagraphPaginationMarkers(paragraphPaginationMarkers) || hasImportedDocxRunFormattingMarkers(runFormattingMarkers) || hasImportedDocxParagraphTabStopMarkers(tabStopMarkers) || hasImportedDocxTableCellMarkers(tableCellMarkers) || hasImportedDocxTableRowMarkers(tableRowMarkers) || hasImportedDocxTableSizingMarkers(tableSizingMarkers) ? await writeDocumentXml(buffer, document, equationMarkers.parts) : buffer,
3013
3001
  sections: [
3014
3002
  {
3015
3003
  id: 'document-section-1',
@@ -3023,6 +3011,7 @@ async function prepareDocxImport(buffer, sourcePackage) {
3023
3011
  commentMarkers,
3024
3012
  fieldMarkers,
3025
3013
  tableOfContentsMarkers,
3014
+ indexMarkers,
3026
3015
  equationMarkers: equationMarkers.markers,
3027
3016
  citationMarkers,
3028
3017
  listMarkers,
@@ -3058,7 +3047,7 @@ async function prepareDocxImport(buffer, sourcePackage) {
3058
3047
  }
3059
3048
  if (sections.length > 1) addSectionMarkers(document, sectionElements);
3060
3049
  return {
3061
- conversionBuffer: sections.length > 1 || hasImportedDocxCaptionMarkers(captionMarkers) || hasImportedDocxBookmarkMarkers(bookmarkMarkers) || hasImportedDocxChangeMarkers(changeMarkers) || hasImportedDocxCommentMarkers(commentMarkers) || hasImportedDocxCitationMarkers(citationMarkers) || hasImportedDocxFieldMarkers(fieldMarkers) || hasImportedDocxTableOfContentsMarkers(tableOfContentsMarkers) || equationMarkers.changed || hasImportedDocxListMarkers(listMarkers) || hasImportedDocxImageLayoutMarkers(imageLayoutMarkers) || hasImportedDocxParagraphIdentityMarkers(paragraphIdentityMarkers) || hasImportedDocxParagraphFormattingChangeMarkers(paragraphFormattingChangeMarkers) || hasImportedDocxParagraphAlignmentMarkers(paragraphAlignmentMarkers) || hasImportedDocxParagraphDirectionMarkers(paragraphDirectionMarkers) || hasImportedDocxParagraphIndentMarkers(paragraphIndentMarkers) || hasImportedDocxParagraphSpacingMarkers(paragraphSpacingMarkers) || hasImportedDocxParagraphBorderMarkers(paragraphBorderMarkers) || hasImportedDocxParagraphShadingMarkers(paragraphShadingMarkers) || hasImportedDocxParagraphPaginationMarkers(paragraphPaginationMarkers) || hasImportedDocxRunFormattingMarkers(runFormattingMarkers) || hasImportedDocxParagraphTabStopMarkers(tabStopMarkers) || hasImportedDocxTableCellMarkers(tableCellMarkers) || hasImportedDocxTableRowMarkers(tableRowMarkers) || hasImportedDocxTableSizingMarkers(tableSizingMarkers) ? await writeDocumentXml(buffer, document, equationMarkers.parts) : buffer,
3050
+ conversionBuffer: sections.length > 1 || hasImportedDocxCaptionMarkers(captionMarkers) || hasImportedDocxBookmarkMarkers(bookmarkMarkers) || hasImportedDocxChangeMarkers(changeMarkers) || hasImportedDocxCommentMarkers(commentMarkers) || hasImportedDocxCitationMarkers(citationMarkers) || hasImportedDocxFieldMarkers(fieldMarkers) || hasImportedDocxTableOfContentsMarkers(tableOfContentsMarkers) || hasImportedDocxIndexMarkers(indexMarkers) || equationMarkers.changed || hasImportedDocxListMarkers(listMarkers) || hasImportedDocxImageLayoutMarkers(imageLayoutMarkers) || hasImportedDocxParagraphIdentityMarkers(paragraphIdentityMarkers) || hasImportedDocxParagraphFormattingChangeMarkers(paragraphFormattingChangeMarkers) || hasImportedDocxParagraphAlignmentMarkers(paragraphAlignmentMarkers) || hasImportedDocxParagraphDirectionMarkers(paragraphDirectionMarkers) || hasImportedDocxParagraphIndentMarkers(paragraphIndentMarkers) || hasImportedDocxParagraphSpacingMarkers(paragraphSpacingMarkers) || hasImportedDocxParagraphBorderMarkers(paragraphBorderMarkers) || hasImportedDocxParagraphShadingMarkers(paragraphShadingMarkers) || hasImportedDocxParagraphPaginationMarkers(paragraphPaginationMarkers) || hasImportedDocxRunFormattingMarkers(runFormattingMarkers) || hasImportedDocxParagraphTabStopMarkers(tabStopMarkers) || hasImportedDocxTableCellMarkers(tableCellMarkers) || hasImportedDocxTableRowMarkers(tableRowMarkers) || hasImportedDocxTableSizingMarkers(tableSizingMarkers) ? await writeDocumentXml(buffer, document, equationMarkers.parts) : buffer,
3062
3051
  sections,
3063
3052
  pageColor,
3064
3053
  captionMarkers,
@@ -3067,6 +3056,7 @@ async function prepareDocxImport(buffer, sourcePackage) {
3067
3056
  commentMarkers,
3068
3057
  fieldMarkers,
3069
3058
  tableOfContentsMarkers,
3059
+ indexMarkers,
3070
3060
  equationMarkers: equationMarkers.markers,
3071
3061
  citationMarkers,
3072
3062
  listMarkers,
@@ -3104,6 +3094,9 @@ function applyDocxSectionsToHtml(html, sections, captionMarkers = {
3104
3094
  fields: []
3105
3095
  }, tableOfContentsMarkers = {
3106
3096
  tables: []
3097
+ }, indexMarkers = {
3098
+ entries: [],
3099
+ indexes: []
3107
3100
  }, equationMarkers = {
3108
3101
  equations: []
3109
3102
  }, citationMarkers = {
@@ -3172,6 +3165,7 @@ function applyDocxSectionsToHtml(html, sections, captionMarkers = {
3172
3165
  applyImportedDocxCommentMarkers(document, commentMarkers);
3173
3166
  applyImportedDocxParagraphIdentityMarkers(document, paragraphIdentityMarkers);
3174
3167
  applyImportedDocxTableOfContentsMarkers(document, tableOfContentsMarkers);
3168
+ applyImportedDocxIndexMarkers(document, indexMarkers);
3175
3169
  const notes = extractMammothDocumentNotes(document);
3176
3170
  const sourceNodes = Array.from(document.body.childNodes);
3177
3171
  document.body.replaceChildren();
@@ -3196,7 +3190,7 @@ function applyDocxSectionsToHtml(html, sections, captionMarkers = {
3196
3190
  document.body.append(missing);
3197
3191
  }
3198
3192
  placeMammothDocumentNotes(document, notes);
3199
- return normalizeDocumentBookmarkReferencesHtml(normalizeDocumentBookmarksHtml(normalizeDocumentCitationsHtml(normalizeDocumentTableOfContentsHtml(normalizeDocumentFieldsHtml(normalizeDocumentCaptionsHtml(normalizeDocumentNotesHtml(document.body.innerHTML)))), bibliography)));
3193
+ return normalizeDocumentIndexesHtml(normalizeDocumentBookmarkReferencesHtml(normalizeDocumentBookmarksHtml(normalizeDocumentCitationsHtml(normalizeDocumentTableOfContentsHtml(normalizeDocumentFieldsHtml(normalizeDocumentCaptionsHtml(normalizeDocumentNotesHtml(document.body.innerHTML)))), bibliography))));
3200
3194
  }
3201
3195
  async function readDocxLayout(buffer) {
3202
3196
  const prepared = await prepareDocxImport(buffer);