@stll/folio-core 0.46.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.js +26 -24
- package/dist/ai-edits/headless.js +1 -1
- package/dist/ai-edits/read.d.ts +1 -0
- package/dist/ai-edits/read.js +1 -0
- package/dist/ai-edits/snapshot.js +32 -27
- package/dist/ai-edits/table-cell-mutations.js +15 -7
- package/dist/ai-edits/table-geometry.js +21 -18
- package/dist/ai-edits/table-template.js +2 -2
- package/dist/compare/content-alignment.js +108 -12
- package/dist/compare/content-types.d.ts +8 -2
- package/dist/compare/content.js +2 -11
- package/dist/compare/plan.js +7 -4
- package/dist/compare/section-boundary-properties.js +1 -2
- package/dist/content-controls/checkboxDisplay.d.ts +8 -2
- package/dist/content-controls/checkboxDisplay.js +11 -5
- package/dist/content-controls/mutateContentControls.js +41 -42
- package/dist/controller/layoutPipeline.js +8 -3
- package/dist/display-list/build/buildDisplayList.js +7 -7
- package/dist/display-list/build/imagePrimitives.d.ts +4 -4
- package/dist/display-list/build/imagePrimitives.js +38 -20
- package/dist/display-list/build/pageBorderPrimitives.js +2 -1
- package/dist/display-list/build/paragraphPrimitives.js +93 -13
- package/dist/display-list/build/previewPrimitives.d.ts +10 -0
- package/dist/display-list/build/previewPrimitives.js +89 -0
- package/dist/display-list/build/strokes.d.ts +177 -8
- package/dist/display-list/build/strokes.js +167 -47
- package/dist/display-list/build/tablePrimitives.js +4 -2
- package/dist/display-list/build/textBoxPrimitives.js +6 -4
- package/dist/display-list/build/textDecorations.d.ts +15 -1
- package/dist/display-list/build/textDecorations.js +15 -1
- package/dist/display-list/dom/renderDisplayListToDom.js +1 -19
- package/dist/display-list/primitives.d.ts +13 -2
- package/dist/display-list/primitives.js +36 -1
- package/dist/document-operations.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +34 -1
- package/dist/docx/attributeRemainder.js +49 -3
- package/dist/docx/blockContentParser.d.ts +2 -0
- package/dist/docx/blockContentParser.js +39 -67
- package/dist/docx/blockPlainText.js +3 -1
- package/dist/docx/borderParser.js +26 -11
- package/dist/docx/builtInStyles.d.ts +8 -16
- package/dist/docx/builtInStyles.js +54 -17
- package/dist/docx/commentAnchorIndex.js +1 -1
- package/dist/docx/commentParser.js +3 -3
- package/dist/docx/commentRangeIntegrity.js +1 -1
- package/dist/docx/commentRangeJoin.js +1 -1
- package/dist/docx/commentReferenceNormalization.js +3 -2
- package/dist/docx/commentReplyMarkers.js +1 -1
- package/dist/docx/compatibility.js +56 -42
- package/dist/docx/containerChildren.d.ts +110 -13
- package/dist/docx/containerChildren.gen.d.ts +16 -1
- package/dist/docx/containerChildren.gen.js +18 -1
- package/dist/docx/containerChildren.js +63 -13
- package/dist/docx/diagramPreview.d.ts +14 -2
- package/dist/docx/diagramPreview.js +81 -169
- package/dist/docx/documentParser.js +4 -1
- package/dist/docx/drawingAnchor.d.ts +87 -0
- package/dist/docx/drawingAnchor.js +201 -0
- package/dist/docx/drawingUtils.d.ts +43 -38
- package/dist/docx/drawingUtils.js +205 -118
- package/dist/docx/fontTableParser.js +102 -41
- package/dist/docx/footnoteParser.js +10 -6
- package/dist/docx/groupDrawingParser.js +4 -3
- package/dist/docx/headerFooterReferenceNormalization.js +1 -1
- package/dist/docx/hyperlinkParser.d.ts +45 -7
- package/dist/docx/hyperlinkParser.js +126 -57
- package/dist/docx/imageParser.js +127 -107
- package/dist/docx/index.d.ts +2 -1
- package/dist/docx/index.js +2 -1
- package/dist/docx/inlineContentRemovals.d.ts +28 -0
- package/dist/docx/inlineContentRemovals.js +46 -0
- package/dist/docx/inlineWrapperContent.d.ts +84 -3
- package/dist/docx/inlineWrapperContent.js +85 -4
- package/dist/docx/inlineWrapperParser.d.ts +11 -0
- package/dist/docx/inlineWrapperParser.js +60 -0
- package/dist/docx/nonVisualDrawingProps.d.ts +5 -13
- package/dist/docx/normalizeBaseDirection.js +4 -2
- package/dist/docx/numberingParser.d.ts +25 -2
- package/dist/docx/numberingParser.js +264 -361
- package/dist/docx/numberingReference.d.ts +9 -16
- package/dist/docx/numberingReference.js +17 -16
- package/dist/docx/numberingReferenceNormalization.js +7 -7
- package/dist/docx/ooxmlCounterFormatter.d.ts +1 -1
- package/dist/docx/ooxmlCounterFormatter.js +4 -1
- package/dist/docx/paraIdAttribute.d.ts +91 -1
- package/dist/docx/paraIdAttribute.js +79 -1
- package/dist/docx/paragraphParser.d.ts +9 -24
- package/dist/docx/paragraphParser.js +212 -396
- package/dist/docx/paragraphProperties.d.ts +23 -0
- package/dist/docx/paragraphProperties.js +279 -0
- package/dist/docx/paragraphPropertySource.js +2 -0
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +14 -7
- package/dist/docx/paragraphTraversal.d.ts +14 -10
- package/dist/docx/paragraphTraversal.js +47 -49
- package/dist/docx/parseWarningMessage.js +3 -0
- package/dist/docx/parserEnums.d.ts +6 -8
- package/dist/docx/parserEnums.js +4 -6
- package/dist/docx/preservedRunContent.js +16 -6
- package/dist/docx/previewBudget.d.ts +44 -23
- package/dist/docx/previewBudget.js +61 -30
- package/dist/docx/propertyElementAttributes.d.ts +178 -0
- package/dist/docx/propertyElementAttributes.js +114 -0
- package/dist/docx/renderedPageBreakNormalization.js +2 -2
- package/dist/docx/rezip.d.ts +28 -2
- package/dist/docx/rezip.js +78 -9
- package/dist/docx/runConsolidator.d.ts +42 -2
- package/dist/docx/runConsolidator.js +60 -6
- package/dist/docx/runParser.d.ts +54 -18
- package/dist/docx/runParser.js +379 -295
- package/dist/docx/runPayload.d.ts +5 -0
- package/dist/docx/runPayload.js +4 -0
- package/dist/docx/sdtProperties.d.ts +39 -5
- package/dist/docx/sdtProperties.js +205 -84
- package/dist/docx/sdtPropertiesPatch.d.ts +5 -9
- package/dist/docx/sdtPropertiesPatch.js +68 -112
- package/dist/docx/sectionParser.d.ts +1 -2
- package/dist/docx/sectionParser.js +236 -240
- package/dist/docx/selectiveSave.js +3 -2
- package/dist/docx/selectiveXmlPatch.d.ts +21 -2
- package/dist/docx/selectiveXmlPatch.js +195 -99
- package/dist/docx/serializer/blockSdtSerializer.js +2 -96
- package/dist/docx/serializer/borderSerializer.d.ts +5 -5
- package/dist/docx/serializer/borderSerializer.js +10 -8
- package/dist/docx/serializer/documentSerializer.js +3 -0
- package/dist/docx/serializer/fontTableSerializer.js +31 -3
- package/dist/docx/serializer/headerFooterSerializer.js +3 -0
- package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
- package/dist/docx/serializer/markupRangeAttributes.js +9 -1
- package/dist/docx/serializer/noteSerializer.js +3 -0
- package/dist/docx/serializer/numberingSerializer.d.ts +1 -6
- package/dist/docx/serializer/numberingSerializer.js +81 -79
- package/dist/docx/serializer/paragraphSerializer.d.ts +1 -9
- package/dist/docx/serializer/paragraphSerializer.js +88 -188
- package/dist/docx/serializer/runSerializer.d.ts +1 -5
- package/dist/docx/serializer/runSerializer.js +109 -59
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
- package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +34 -45
- package/dist/docx/serializer/settingsSerializer.js +6 -4
- package/dist/docx/serializer/stylesSerializer.js +8 -11
- package/dist/docx/serializer/tableSerializer.js +268 -100
- package/dist/docx/serializer/textFormattingSerializer.d.ts +28 -4
- package/dist/docx/serializer/textFormattingSerializer.js +111 -101
- package/dist/docx/serializer/xmlUtils.d.ts +1 -1
- package/dist/docx/serializer/xmlUtils.js +1 -1
- package/dist/docx/server/createBilingualDocument.js +18 -16
- package/dist/docx/server/migrateYjsAttrSchema.js +3 -3
- package/dist/docx/settingsParser.js +7 -4
- package/dist/docx/shadingParser.d.ts +2 -1
- package/dist/docx/shadingParser.js +43 -7
- package/dist/docx/shapeParser.js +8 -3
- package/dist/docx/strictNames.d.ts +11 -0
- package/dist/docx/strictNames.gen.d.ts +45 -0
- package/dist/docx/strictNames.gen.js +50 -0
- package/dist/docx/strictNames.js +43 -0
- package/dist/docx/strictValueEncodings.gen.js +133 -131
- package/dist/docx/styleParser.js +17 -349
- package/dist/docx/tableParser.d.ts +10 -1
- package/dist/docx/tableParser.js +505 -181
- package/dist/docx/textBoxParser.d.ts +3 -1
- package/dist/docx/textBoxParser.js +18 -8
- package/dist/docx/themeColorAttribute.d.ts +13 -0
- package/dist/docx/themeColorAttribute.js +24 -0
- package/dist/docx/trackedMoveRangeNormalization.js +2 -1
- package/dist/docx/vmlImageParser.d.ts +13 -4
- package/dist/docx/vmlImageParser.js +74 -31
- package/dist/docx/vmlPreview.js +2 -2
- package/dist/docx/wrapPolygon.d.ts +30 -0
- package/dist/docx/wrapPolygon.js +70 -0
- package/dist/docx/xmlParser.d.ts +14 -1
- package/dist/docx/xmlParser.js +18 -2
- package/dist/fonts/embeddedFonts.js +3 -3
- package/dist/headless-layout.js +2 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
- package/dist/i18n/messages/catalogs.gen.js +102 -34
- package/dist/i18n/messages/messages.gen.d.ts +4 -0
- package/dist/internal/headlessRevisionResolution.js +9 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +3 -1
- package/dist/internal/paragraphFormattingSerialization.d.ts +20 -9
- package/dist/internal/paragraphFormattingSerialization.js +118 -83
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +17 -12
- package/dist/layout-bridge/convert/toFlowBlocks.js +177 -101
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +53 -17
- package/dist/layout-engine/measure/measureBlocks.d.ts +3 -0
- package/dist/layout-engine/measure/measureBlocks.js +6 -10
- package/dist/layout-engine/measure/tableCellGrid.js +2 -1
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/measure/tableInlinePlacement.js +2 -5
- package/dist/layout-engine/paragraphSequence.js +3 -2
- package/dist/layout-engine/renderedBreakReconciliation.js +2 -1
- package/dist/layout-engine/section-breaks.d.ts +49 -2
- package/dist/layout-engine/section-breaks.js +55 -4
- package/dist/layout-engine/types.d.ts +47 -17
- package/dist/layout-engine/types.js +16 -1
- package/dist/layout-painter/borderStroke.d.ts +18 -4
- package/dist/layout-painter/renderPage.js +6 -4
- package/dist/layout-painter/renderParagraph.d.ts +2 -1
- package/dist/layout-painter/renderParagraph.js +13 -26
- package/dist/layout-painter/renderTable.d.ts +4 -1
- package/dist/layout-painter/renderTable.js +22 -22
- package/dist/layout-painter/renderTextBox.js +5 -3
- package/dist/markdown/renderBlock.js +3 -1
- package/dist/markdown/renderRuns.js +7 -2
- package/dist/markdown/renderTable.js +2 -1
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
- package/dist/paged-layout/sectionBlockWidths.js +26 -4
- package/dist/prosemirror/attrs/index.d.ts +22 -4
- package/dist/prosemirror/attrs/index.js +498 -60
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +9 -1
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +22 -3
- package/dist/prosemirror/commands/comments.js +68 -53
- package/dist/prosemirror/commands/contentControls.js +24 -19
- package/dist/prosemirror/commands/image.d.ts +1 -1
- package/dist/prosemirror/commands/image.js +4 -1
- package/dist/prosemirror/commands/paragraph.d.ts +2 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +12 -4
- package/dist/prosemirror/commands/propertyChangeScope.js +22 -4
- package/dist/prosemirror/commands/sectionBreak.d.ts +33 -1
- package/dist/prosemirror/commands/sectionBreak.js +187 -11
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +18 -2
- package/dist/prosemirror/conversion/fromProseDoc.js +330 -183
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +39 -0
- package/dist/prosemirror/conversion/preservedSinkCarriers.js +19 -0
- package/dist/prosemirror/conversion/runShadingMark.js +14 -1
- package/dist/prosemirror/conversion/sdtAttrs.d.ts +10 -1
- package/dist/prosemirror/conversion/sdtAttrs.js +19 -5
- package/dist/prosemirror/conversion/toProseDoc.js +371 -141
- package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
- package/dist/prosemirror/emptyRangeAnchor.js +158 -0
- package/dist/prosemirror/extensions/StarterKit.js +8 -2
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +19 -15
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
- package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +4 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +5 -5
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +3 -1
- package/dist/prosemirror/extensions/features/pasteCleanup.js +56 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +5 -4
- package/dist/prosemirror/extensions/markRegistry.d.ts +26 -2
- package/dist/prosemirror/extensions/markRegistry.js +73 -10
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +17 -3
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +26 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +134 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -1
- package/dist/prosemirror/extensions/marks/UnderlineExtension.js +12 -18
- package/dist/prosemirror/extensions/marks/markUtils.js +2 -1
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +29 -0
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.js +46 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +4 -3
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +18 -13
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +28 -53
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +10 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +8 -1
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +43 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +65 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +22 -16
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +4 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +141 -123
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +4 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +23 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.js +57 -0
- package/dist/prosemirror/extensions/types.d.ts +12 -3
- package/dist/prosemirror/index.d.ts +4 -2
- package/dist/prosemirror/index.js +2 -1
- package/dist/prosemirror/inlineWrapperStack.js +20 -3
- package/dist/prosemirror/listMarker.d.ts +2 -2
- package/dist/prosemirror/listMarker.js +7 -8
- package/dist/prosemirror/listRenderingAttrs.js +11 -1
- package/dist/prosemirror/listState.d.ts +62 -0
- package/dist/prosemirror/listState.js +49 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +13 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.js +114 -0
- package/dist/prosemirror/numberedRefFields.js +4 -4
- package/dist/prosemirror/numberingAttr.d.ts +55 -0
- package/dist/prosemirror/numberingAttr.js +74 -0
- package/dist/prosemirror/outlineLevelAttr.d.ts +29 -0
- package/dist/prosemirror/outlineLevelAttr.js +42 -0
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +9 -0
- package/dist/prosemirror/paragraphFormattingProvenance.js +4 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +3 -6
- package/dist/prosemirror/plugins/selectionTracker.js +3 -10
- package/dist/prosemirror/rangeAnchorAttrs.d.ts +14 -0
- package/dist/prosemirror/rangeAnchorAttrs.js +101 -0
- package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.js +24 -6
- package/dist/prosemirror/revisionCarriers.d.ts +86 -2
- package/dist/prosemirror/revisionCarriers.js +86 -60
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +2 -0
- package/dist/prosemirror/runFormattingInlineCarriers.js +2 -0
- package/dist/prosemirror/runIdentity.d.ts +28 -0
- package/dist/prosemirror/runIdentity.js +36 -0
- package/dist/prosemirror/runStyleFormatting.js +1 -1
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/marks.d.ts +23 -4
- package/dist/prosemirror/schema/nodes.d.ts +220 -24
- package/dist/prosemirror/sectionCarrier.d.ts +37 -0
- package/dist/prosemirror/sectionCarrier.js +40 -0
- package/dist/prosemirror/selectionState.d.ts +3 -0
- package/dist/prosemirror/selectionState.js +4 -1
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +5 -4
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +15 -13
- package/dist/prosemirror/tableResize.js +5 -6
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +2 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
- package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
- package/dist/prosemirror/validation.js +17 -6
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +2 -2
- package/dist/prosemirror/yjsDocumentMetadata.js +428 -7
- package/dist/prosemirror/zeroWidthAnchors.js +4 -0
- package/dist/style-sets/extract.js +4 -4
- package/dist/style-sets/stellaStyle.js +36 -23
- package/dist/types/colors.d.ts +2 -2
- package/dist/types/content.d.ts +2 -2
- package/dist/types/documentEnumValues.d.ts +53 -26
- package/dist/types/documentEnumValues.js +72 -174
- package/dist/types/formatting.d.ts +2 -2
- package/dist/types/index.d.ts +9 -2
- package/dist/utils/borderCss.d.ts +246 -0
- package/dist/utils/borderCss.js +325 -0
- package/dist/utils/colorResolver.d.ts +4 -3
- package/dist/utils/colorResolver.js +45 -76
- package/dist/utils/createDocument.js +24 -6
- package/dist/utils/findReplace.js +52 -10
- package/dist/utils/formatToStyle.d.ts +84 -2
- package/dist/utils/formatToStyle.js +133 -52
- package/dist/utils/headingCollector.js +3 -2
- package/dist/utils/mergeDocumentContent.js +5 -3
- package/dist/utils/paragraphFormattingMerge.js +27 -6
- package/dist/utils/replaceText.js +1 -1
- package/dist/utils/tableOperations.d.ts +5 -3
- package/dist/utils/tableOperations.js +14 -1
- package/dist/utils/tablePlacement.d.ts +7 -0
- package/dist/utils/tablePlacement.js +14 -0
- package/dist/utils/textDirectionFlow.d.ts +15 -0
- package/dist/utils/textDirectionFlow.js +38 -0
- package/dist/utils/textFormattingMerge.js +16 -4
- package/package.json +10 -10
- package/dist/ai-edits/__fixtures__/paragraphs.d.ts +0 -17
- package/dist/ai-edits/__fixtures__/paragraphs.js +0 -33
- package/dist/compare/__fixtures__/body-sequence.d.ts +0 -119
- package/dist/compare/__fixtures__/body-sequence.js +0 -225
- package/dist/compare/__fixtures__/nested-table.d.ts +0 -16
- package/dist/compare/__fixtures__/nested-table.js +0 -50
- package/dist/compare/__fixtures__/numbered-list.d.ts +0 -34
- package/dist/compare/__fixtures__/numbered-list.js +0 -85
- package/dist/docx/bookmarkPlacement.d.ts +0 -9
- package/dist/docx/bookmarkPlacement.js +0 -52
- package/dist/fonts/embeddedFontTable.d.ts +0 -45
- package/dist/fonts/embeddedFontTable.js +0 -80
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +0 -13
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +0 -39
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { statesNoBorder } from "@stll/docx-core/model";
|
|
2
|
+
//#region src/utils/borderCss.ts
|
|
3
|
+
/**
|
|
4
|
+
* The one OOXML border style → CSS `border-style` table.
|
|
5
|
+
*
|
|
6
|
+
* There were three of these and they covered different amounts of the
|
|
7
|
+
* enumeration. `TableExtension` rendered the nine `thinThick`/`thickThin` gap
|
|
8
|
+
* styles as `double` and `dashDotStroked` as `dashed`; the layout bridge and
|
|
9
|
+
* `formatToStyle` fell through to `solid`, so a table cell and the paragraph
|
|
10
|
+
* above it painted the same authored border differently. The three agreed
|
|
11
|
+
* wherever they overlapped, so this table is their union rather than a new
|
|
12
|
+
* decision: a rendering decision per enumeration member is a table, and a table
|
|
13
|
+
* has one owner.
|
|
14
|
+
*
|
|
15
|
+
* Totality is the point of the `satisfies`: `ST_Border` is generated from the
|
|
16
|
+
* committed schema graph, so a schema refresh that adds a member fails the
|
|
17
|
+
* build here rather than quietly painting it as a plain line.
|
|
18
|
+
*/
|
|
19
|
+
/** The CSS `border-style` keywords folio paints a border with, in one tuple. */
|
|
20
|
+
const CSS_BORDER_STYLE_VALUES = [
|
|
21
|
+
"none",
|
|
22
|
+
"solid",
|
|
23
|
+
"double",
|
|
24
|
+
"dotted",
|
|
25
|
+
"dashed",
|
|
26
|
+
"groove",
|
|
27
|
+
"ridge",
|
|
28
|
+
"inset",
|
|
29
|
+
"outset"
|
|
30
|
+
];
|
|
31
|
+
const CSS_BORDER_STYLES_DECLARED = new Set(CSS_BORDER_STYLE_VALUES);
|
|
32
|
+
/** Whether folio paints a border with this CSS keyword. */
|
|
33
|
+
const isCssBorderStyle = (value) => CSS_BORDER_STYLES_DECLARED.has(value);
|
|
34
|
+
/**
|
|
35
|
+
* Read the CSS keyword an editor attribute carries into the union folio paints.
|
|
36
|
+
*
|
|
37
|
+
* The attribute is a bare `string` because a host may write any CSS keyword
|
|
38
|
+
* into it. A keyword folio does not paint is not guessed at: the caller gets
|
|
39
|
+
* `undefined` and applies its own default.
|
|
40
|
+
*/
|
|
41
|
+
const cssBorderStyleOf = (value) => value !== void 0 && isCssBorderStyle(value) ? value : void 0;
|
|
42
|
+
/**
|
|
43
|
+
* Every `ST_Border` member's CSS rendering.
|
|
44
|
+
*
|
|
45
|
+
* The art borders (`apples` … `zigZagStitch`) and the gap-patterned line
|
|
46
|
+
* styles degrade to a plain line, which is how Word itself degrades where the
|
|
47
|
+
* specialised glyphs are unavailable; folio paints the underlying line and
|
|
48
|
+
* round-trips the member. `custom` names art supplied by a relationship, so it
|
|
49
|
+
* degrades the same way.
|
|
50
|
+
*/
|
|
51
|
+
const CSS_BORDER_STYLES = {
|
|
52
|
+
nil: "none",
|
|
53
|
+
none: "none",
|
|
54
|
+
single: "solid",
|
|
55
|
+
thick: "solid",
|
|
56
|
+
double: "double",
|
|
57
|
+
dotted: "dotted",
|
|
58
|
+
dashed: "dashed",
|
|
59
|
+
dotDash: "dashed",
|
|
60
|
+
dotDotDash: "dotted",
|
|
61
|
+
triple: "double",
|
|
62
|
+
thinThickSmallGap: "double",
|
|
63
|
+
thickThinSmallGap: "double",
|
|
64
|
+
thinThickThinSmallGap: "double",
|
|
65
|
+
thinThickMediumGap: "double",
|
|
66
|
+
thickThinMediumGap: "double",
|
|
67
|
+
thinThickThinMediumGap: "double",
|
|
68
|
+
thinThickLargeGap: "double",
|
|
69
|
+
thickThinLargeGap: "double",
|
|
70
|
+
thinThickThinLargeGap: "double",
|
|
71
|
+
wave: "solid",
|
|
72
|
+
doubleWave: "double",
|
|
73
|
+
dashSmallGap: "dashed",
|
|
74
|
+
dashDotStroked: "dashed",
|
|
75
|
+
threeDEmboss: "ridge",
|
|
76
|
+
threeDEngrave: "groove",
|
|
77
|
+
outset: "outset",
|
|
78
|
+
inset: "inset",
|
|
79
|
+
apples: "solid",
|
|
80
|
+
archedScallops: "solid",
|
|
81
|
+
babyPacifier: "solid",
|
|
82
|
+
babyRattle: "solid",
|
|
83
|
+
balloons3Colors: "solid",
|
|
84
|
+
balloonsHotAir: "solid",
|
|
85
|
+
basicBlackDashes: "solid",
|
|
86
|
+
basicBlackDots: "solid",
|
|
87
|
+
basicBlackSquares: "solid",
|
|
88
|
+
basicThinLines: "solid",
|
|
89
|
+
basicWhiteDashes: "solid",
|
|
90
|
+
basicWhiteDots: "solid",
|
|
91
|
+
basicWhiteSquares: "solid",
|
|
92
|
+
basicWideInline: "solid",
|
|
93
|
+
basicWideMidline: "solid",
|
|
94
|
+
basicWideOutline: "solid",
|
|
95
|
+
bats: "solid",
|
|
96
|
+
birds: "solid",
|
|
97
|
+
birdsFlight: "solid",
|
|
98
|
+
cabins: "solid",
|
|
99
|
+
cakeSlice: "solid",
|
|
100
|
+
candyCorn: "solid",
|
|
101
|
+
celticKnotwork: "solid",
|
|
102
|
+
certificateBanner: "solid",
|
|
103
|
+
chainLink: "solid",
|
|
104
|
+
champagneBottle: "solid",
|
|
105
|
+
checkedBarBlack: "solid",
|
|
106
|
+
checkedBarColor: "solid",
|
|
107
|
+
checkered: "solid",
|
|
108
|
+
christmasTree: "solid",
|
|
109
|
+
circlesLines: "solid",
|
|
110
|
+
circlesRectangles: "solid",
|
|
111
|
+
classicalWave: "solid",
|
|
112
|
+
clocks: "solid",
|
|
113
|
+
compass: "solid",
|
|
114
|
+
confetti: "solid",
|
|
115
|
+
confettiGrays: "solid",
|
|
116
|
+
confettiOutline: "solid",
|
|
117
|
+
confettiStreamers: "solid",
|
|
118
|
+
confettiWhite: "solid",
|
|
119
|
+
cornerTriangles: "solid",
|
|
120
|
+
couponCutoutDashes: "solid",
|
|
121
|
+
couponCutoutDots: "solid",
|
|
122
|
+
crazyMaze: "solid",
|
|
123
|
+
creaturesButterfly: "solid",
|
|
124
|
+
creaturesFish: "solid",
|
|
125
|
+
creaturesInsects: "solid",
|
|
126
|
+
creaturesLadyBug: "solid",
|
|
127
|
+
crossStitch: "solid",
|
|
128
|
+
cup: "solid",
|
|
129
|
+
decoArch: "solid",
|
|
130
|
+
decoArchColor: "solid",
|
|
131
|
+
decoBlocks: "solid",
|
|
132
|
+
diamondsGray: "solid",
|
|
133
|
+
doubleD: "solid",
|
|
134
|
+
doubleDiamonds: "solid",
|
|
135
|
+
earth1: "solid",
|
|
136
|
+
earth2: "solid",
|
|
137
|
+
earth3: "solid",
|
|
138
|
+
eclipsingSquares1: "solid",
|
|
139
|
+
eclipsingSquares2: "solid",
|
|
140
|
+
eggsBlack: "solid",
|
|
141
|
+
fans: "solid",
|
|
142
|
+
film: "solid",
|
|
143
|
+
firecrackers: "solid",
|
|
144
|
+
flowersBlockPrint: "solid",
|
|
145
|
+
flowersDaisies: "solid",
|
|
146
|
+
flowersModern1: "solid",
|
|
147
|
+
flowersModern2: "solid",
|
|
148
|
+
flowersPansy: "solid",
|
|
149
|
+
flowersRedRose: "solid",
|
|
150
|
+
flowersRoses: "solid",
|
|
151
|
+
flowersTeacup: "solid",
|
|
152
|
+
flowersTiny: "solid",
|
|
153
|
+
gems: "solid",
|
|
154
|
+
gingerbreadMan: "solid",
|
|
155
|
+
gradient: "solid",
|
|
156
|
+
handmade1: "solid",
|
|
157
|
+
handmade2: "solid",
|
|
158
|
+
heartBalloon: "solid",
|
|
159
|
+
heartGray: "solid",
|
|
160
|
+
hearts: "solid",
|
|
161
|
+
heebieJeebies: "solid",
|
|
162
|
+
holly: "solid",
|
|
163
|
+
houseFunky: "solid",
|
|
164
|
+
hypnotic: "solid",
|
|
165
|
+
iceCreamCones: "solid",
|
|
166
|
+
lightBulb: "solid",
|
|
167
|
+
lightning1: "solid",
|
|
168
|
+
lightning2: "solid",
|
|
169
|
+
mapPins: "solid",
|
|
170
|
+
mapleLeaf: "solid",
|
|
171
|
+
mapleMuffins: "solid",
|
|
172
|
+
marquee: "solid",
|
|
173
|
+
marqueeToothed: "solid",
|
|
174
|
+
moons: "solid",
|
|
175
|
+
mosaic: "solid",
|
|
176
|
+
musicNotes: "solid",
|
|
177
|
+
northwest: "solid",
|
|
178
|
+
ovals: "solid",
|
|
179
|
+
packages: "solid",
|
|
180
|
+
palmsBlack: "solid",
|
|
181
|
+
palmsColor: "solid",
|
|
182
|
+
paperClips: "solid",
|
|
183
|
+
papyrus: "solid",
|
|
184
|
+
partyFavor: "solid",
|
|
185
|
+
partyGlass: "solid",
|
|
186
|
+
pencils: "solid",
|
|
187
|
+
people: "solid",
|
|
188
|
+
peopleWaving: "solid",
|
|
189
|
+
peopleHats: "solid",
|
|
190
|
+
poinsettias: "solid",
|
|
191
|
+
postageStamp: "solid",
|
|
192
|
+
pumpkin1: "solid",
|
|
193
|
+
pushPinNote2: "solid",
|
|
194
|
+
pushPinNote1: "solid",
|
|
195
|
+
pyramids: "solid",
|
|
196
|
+
pyramidsAbove: "solid",
|
|
197
|
+
quadrants: "solid",
|
|
198
|
+
rings: "solid",
|
|
199
|
+
safari: "solid",
|
|
200
|
+
sawtooth: "solid",
|
|
201
|
+
sawtoothGray: "solid",
|
|
202
|
+
scaredCat: "solid",
|
|
203
|
+
seattle: "solid",
|
|
204
|
+
shadowedSquares: "solid",
|
|
205
|
+
sharksTeeth: "solid",
|
|
206
|
+
shorebirdTracks: "solid",
|
|
207
|
+
skyrocket: "solid",
|
|
208
|
+
snowflakeFancy: "solid",
|
|
209
|
+
snowflakes: "solid",
|
|
210
|
+
sombrero: "solid",
|
|
211
|
+
southwest: "solid",
|
|
212
|
+
stars: "solid",
|
|
213
|
+
starsTop: "solid",
|
|
214
|
+
stars3d: "solid",
|
|
215
|
+
starsBlack: "solid",
|
|
216
|
+
starsShadowed: "solid",
|
|
217
|
+
sun: "solid",
|
|
218
|
+
swirligig: "solid",
|
|
219
|
+
tornPaper: "solid",
|
|
220
|
+
tornPaperBlack: "solid",
|
|
221
|
+
trees: "solid",
|
|
222
|
+
triangleParty: "solid",
|
|
223
|
+
triangles: "solid",
|
|
224
|
+
triangle1: "solid",
|
|
225
|
+
triangle2: "solid",
|
|
226
|
+
triangleCircle1: "solid",
|
|
227
|
+
triangleCircle2: "solid",
|
|
228
|
+
shapes1: "solid",
|
|
229
|
+
shapes2: "solid",
|
|
230
|
+
twistedLines1: "solid",
|
|
231
|
+
twistedLines2: "solid",
|
|
232
|
+
vine: "solid",
|
|
233
|
+
waveline: "solid",
|
|
234
|
+
weavingAngles: "solid",
|
|
235
|
+
weavingBraid: "solid",
|
|
236
|
+
weavingRibbon: "solid",
|
|
237
|
+
weavingStrips: "solid",
|
|
238
|
+
whiteFlowers: "solid",
|
|
239
|
+
woodwork: "solid",
|
|
240
|
+
xIllusions: "solid",
|
|
241
|
+
zanyTriangles: "solid",
|
|
242
|
+
zigZag: "solid",
|
|
243
|
+
zigZagStitch: "solid",
|
|
244
|
+
custom: "solid"
|
|
245
|
+
};
|
|
246
|
+
/** The CSS keyword for an edge that paints nothing. */
|
|
247
|
+
const CSS_NO_BORDER = "none";
|
|
248
|
+
/**
|
|
249
|
+
* Whether a laid-out border paints a line.
|
|
250
|
+
*
|
|
251
|
+
* Only an explicit `none` does not: a border with a width but no style paints
|
|
252
|
+
* the CSS initial `solid`, which is what the measurers and the painter have
|
|
253
|
+
* always assumed. The argument is a CSS keyword, never an `ST_Border` member —
|
|
254
|
+
* `nil` cannot reach here, which is what typing `BorderStyle.style` bought.
|
|
255
|
+
*/
|
|
256
|
+
const paintsCssBorder = (style) => style !== CSS_NO_BORDER;
|
|
257
|
+
/**
|
|
258
|
+
* The CSS `border-style` for a parsed `w:val`.
|
|
259
|
+
*
|
|
260
|
+
* A token the schema does not declare paints as a plain line: the member is
|
|
261
|
+
* kept for the round trip, but nothing can be inferred about how it draws.
|
|
262
|
+
*/
|
|
263
|
+
const cssBorderStyle = (style) => {
|
|
264
|
+
if (style === void 0) return "solid";
|
|
265
|
+
if (statesNoBorder(style)) return "none";
|
|
266
|
+
return typeof style === "string" ? CSS_BORDER_STYLES[style] : "solid";
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Every `ST_PresetLineDashVal` member's CSS `border-style` rendering.
|
|
270
|
+
*
|
|
271
|
+
* A shape or text-box outline reaches the DOM painter and the editor node as a
|
|
272
|
+
* CSS border, so the dash has to be translated rather than forwarded: `sysDash`
|
|
273
|
+
* in a `border` shorthand invalidates the whole declaration and the outline
|
|
274
|
+
* disappears. CSS has three periodic keywords, so the dash-length and system
|
|
275
|
+
* variants collapse; the model keeps the authored member for the round trip.
|
|
276
|
+
*
|
|
277
|
+
* Not the inverse of {@link CSS_BORDER_PRESET_DASHES}: both directions are
|
|
278
|
+
* many-to-one, so neither can be derived from the other.
|
|
279
|
+
*/
|
|
280
|
+
const PRESET_DASH_CSS_BORDER_STYLES = {
|
|
281
|
+
solid: "solid",
|
|
282
|
+
dot: "dotted",
|
|
283
|
+
dash: "dashed",
|
|
284
|
+
lgDash: "dashed",
|
|
285
|
+
dashDot: "dashed",
|
|
286
|
+
lgDashDot: "dashed",
|
|
287
|
+
lgDashDotDot: "dashed",
|
|
288
|
+
sysDash: "dashed",
|
|
289
|
+
sysDot: "dotted",
|
|
290
|
+
sysDashDot: "dashed",
|
|
291
|
+
sysDashDotDot: "dashed"
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* The CSS `border-style` for a parsed `a:prstDash@val`.
|
|
295
|
+
*
|
|
296
|
+
* A token the schema does not declare paints as a plain line, the way an
|
|
297
|
+
* undeclared `ST_Border` member does: the member is kept for the round trip,
|
|
298
|
+
* but nothing can be inferred about how it draws.
|
|
299
|
+
*/
|
|
300
|
+
const cssBorderStyleForDash = (dash) => {
|
|
301
|
+
if (dash === void 0) return "solid";
|
|
302
|
+
return typeof dash === "string" ? PRESET_DASH_CSS_BORDER_STYLES[dash] : "solid";
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Every CSS `border-style` folio paints, as the preset dash it serializes to.
|
|
306
|
+
*
|
|
307
|
+
* An image border is authored in CSS on the editor node and written back as an
|
|
308
|
+
* `a:ln` outline, so the translation has to be total: a keyword with no entry
|
|
309
|
+
* was serialized as `solid` by a partial table that could not say so.
|
|
310
|
+
*/
|
|
311
|
+
const CSS_BORDER_PRESET_DASHES = {
|
|
312
|
+
none: "solid",
|
|
313
|
+
solid: "solid",
|
|
314
|
+
double: "solid",
|
|
315
|
+
dotted: "dot",
|
|
316
|
+
dashed: "dash",
|
|
317
|
+
groove: "solid",
|
|
318
|
+
ridge: "solid",
|
|
319
|
+
inset: "solid",
|
|
320
|
+
outset: "solid"
|
|
321
|
+
};
|
|
322
|
+
/** The preset dash an authored CSS border style serializes to. */
|
|
323
|
+
const presetDashForCssBorderStyle = (style) => CSS_BORDER_PRESET_DASHES[cssBorderStyleOf(style) ?? "solid"];
|
|
324
|
+
//#endregion
|
|
325
|
+
export { CSS_BORDER_STYLES, CSS_BORDER_STYLE_VALUES, cssBorderStyle, cssBorderStyleForDash, cssBorderStyleOf, paintsCssBorder, presetDashForCssBorderStyle };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { ThemeColor } from "@stll/docx-core/model";
|
|
2
3
|
//#region src/utils/colorResolver.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Public form of the same hex-color check, for callers that read a color
|
|
@@ -77,7 +78,7 @@ declare function parseColorString(colorString: string | undefined): document_d_e
|
|
|
77
78
|
* @param shade - Optional shade modifier
|
|
78
79
|
* @returns ColorValue object
|
|
79
80
|
*/
|
|
80
|
-
declare function createThemeColor(themeColor:
|
|
81
|
+
declare function createThemeColor(themeColor: ThemeColor, tint?: number, shade?: number): document_d_exports.ColorValue;
|
|
81
82
|
/**
|
|
82
83
|
* Create a ColorValue from RGB hex
|
|
83
84
|
*
|
|
@@ -128,8 +129,8 @@ declare function resolveHighlightToCss(value: string): string;
|
|
|
128
129
|
type ThemeMatrixCell = {
|
|
129
130
|
/** Resolved hex color (6 chars, no #) */
|
|
130
131
|
hex: string;
|
|
131
|
-
/**
|
|
132
|
-
themeSlot:
|
|
132
|
+
/** The `w:themeColor` token this swatch writes */
|
|
133
|
+
themeSlot: ThemeColor;
|
|
133
134
|
/** Tint hex modifier if applicable (e.g., "CC") */
|
|
134
135
|
tint?: string;
|
|
135
136
|
/** Shade hex modifier if applicable (e.g., "BF") */
|
|
@@ -1,5 +1,26 @@
|
|
|
1
|
+
import { THEME_COLOR_BY_SCHEME_COLOR_VALUE, isSchemeColorValue, isThemeColor, themeColorSlot } from "@stll/docx-core/model";
|
|
1
2
|
//#region src/utils/colorResolver.ts
|
|
2
3
|
/**
|
|
4
|
+
* Color Resolver - Convert OOXML colors to CSS
|
|
5
|
+
*
|
|
6
|
+
* Handles:
|
|
7
|
+
* - Theme color references (accent1, dk1, etc.)
|
|
8
|
+
* - RGB hex values
|
|
9
|
+
* - "auto" colors (context-dependent)
|
|
10
|
+
* - Tint/shade modifications
|
|
11
|
+
*
|
|
12
|
+
* OOXML Color References:
|
|
13
|
+
* - w:color/@w:val - RGB hex or "auto"
|
|
14
|
+
* - w:color/@w:themeColor - Theme color slot
|
|
15
|
+
* - w:color/@w:themeTint - Tint modifier (0-255, hex)
|
|
16
|
+
* - w:color/@w:themeShade - Shade modifier (0-255, hex)
|
|
17
|
+
*
|
|
18
|
+
* Tint/Shade Calculations:
|
|
19
|
+
* - Tint makes color lighter (blend with white)
|
|
20
|
+
* - Shade makes color darker (blend with black)
|
|
21
|
+
* - Value is in hex (00-FF), converted to 0-1 for calculation
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
3
24
|
* Strict hex-color validator shared by every OOXML → CSS color path in this
|
|
4
25
|
* module. OOXML readers are lenient about `w:val`/`w:fill` attribute content
|
|
5
26
|
* and theme swatch text, so a crafted `<w:color>`, table shading, or
|
|
@@ -69,38 +90,6 @@ const HIGHLIGHT_COLORS = {
|
|
|
69
90
|
none: ""
|
|
70
91
|
};
|
|
71
92
|
/**
|
|
72
|
-
* Map alternative theme color names to standard slots
|
|
73
|
-
* OOXML uses different names in different contexts
|
|
74
|
-
*/
|
|
75
|
-
const THEME_COLOR_ALIASES = {
|
|
76
|
-
dk1: "dk1",
|
|
77
|
-
lt1: "lt1",
|
|
78
|
-
dk2: "dk2",
|
|
79
|
-
lt2: "lt2",
|
|
80
|
-
accent1: "accent1",
|
|
81
|
-
accent2: "accent2",
|
|
82
|
-
accent3: "accent3",
|
|
83
|
-
accent4: "accent4",
|
|
84
|
-
accent5: "accent5",
|
|
85
|
-
accent6: "accent6",
|
|
86
|
-
hlink: "hlink",
|
|
87
|
-
folHlink: "folHlink",
|
|
88
|
-
dark1: "dk1",
|
|
89
|
-
light1: "lt1",
|
|
90
|
-
dark2: "dk2",
|
|
91
|
-
light2: "lt2",
|
|
92
|
-
hyperlink: "hlink",
|
|
93
|
-
followedHyperlink: "folHlink",
|
|
94
|
-
background1: "lt1",
|
|
95
|
-
text1: "dk1",
|
|
96
|
-
background2: "lt2",
|
|
97
|
-
text2: "dk2",
|
|
98
|
-
tx1: "dk1",
|
|
99
|
-
tx2: "dk2",
|
|
100
|
-
bg1: "lt1",
|
|
101
|
-
bg2: "lt2"
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
93
|
* Parse a hex color modifier value (tint or shade)
|
|
105
94
|
* OOXML stores tint/shade as hex string (00-FF) representing 0-255
|
|
106
95
|
*
|
|
@@ -173,46 +162,22 @@ function applyShade(hex, shade) {
|
|
|
173
162
|
return rgbToHex(rgb.r * shade, rgb.g * shade, rgb.b * shade);
|
|
174
163
|
}
|
|
175
164
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* @param theme - Theme object
|
|
179
|
-
* @param slot - Color slot name
|
|
180
|
-
* @returns Hex color (6 characters, no #)
|
|
165
|
+
* The hex a theme slot paints, falling back to the Office default theme when
|
|
166
|
+
* the package carries no `theme1.xml` or leaves the slot empty.
|
|
181
167
|
*/
|
|
182
168
|
function getThemeColorValue(theme, slot) {
|
|
183
|
-
|
|
184
|
-
const schemeKeys = [
|
|
185
|
-
"dk1",
|
|
186
|
-
"lt1",
|
|
187
|
-
"dk2",
|
|
188
|
-
"lt2",
|
|
189
|
-
"accent1",
|
|
190
|
-
"accent2",
|
|
191
|
-
"accent3",
|
|
192
|
-
"accent4",
|
|
193
|
-
"accent5",
|
|
194
|
-
"accent6",
|
|
195
|
-
"hlink",
|
|
196
|
-
"folHlink"
|
|
197
|
-
];
|
|
198
|
-
const isSchemeKey = (key) => schemeKeys.includes(key);
|
|
199
|
-
if (!theme?.colorScheme) {
|
|
200
|
-
if (isSchemeKey(schemeKey)) return DEFAULT_THEME_COLORS[schemeKey] ?? "000000";
|
|
201
|
-
return "000000";
|
|
202
|
-
}
|
|
203
|
-
if (isSchemeKey(schemeKey)) return theme.colorScheme[schemeKey] ?? DEFAULT_THEME_COLORS[schemeKey] ?? "000000";
|
|
204
|
-
return "000000";
|
|
169
|
+
return theme?.colorScheme?.[slot] ?? DEFAULT_THEME_COLORS[slot];
|
|
205
170
|
}
|
|
206
171
|
/**
|
|
207
|
-
*
|
|
172
|
+
* Read a colour name as a theme reference.
|
|
208
173
|
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
174
|
+
* Accepts both vocabularies: `ST_ThemeColor`, as a `w:themeColor` writes it,
|
|
175
|
+
* and `ST_SchemeColorVal`, as a DrawingML reference or a host-supplied slot
|
|
176
|
+
* name does.
|
|
211
177
|
*/
|
|
212
|
-
function
|
|
213
|
-
if (
|
|
214
|
-
|
|
215
|
-
return THEME_COLOR_ALIASES[colorName] ?? THEME_COLOR_ALIASES[normalized] ?? null;
|
|
178
|
+
function resolveThemeColorName(colorName) {
|
|
179
|
+
if (isThemeColor(colorName)) return colorName;
|
|
180
|
+
return isSchemeColorValue(colorName) ? THEME_COLOR_BY_SCHEME_COLOR_VALUE[colorName] ?? void 0 : void 0;
|
|
216
181
|
}
|
|
217
182
|
/**
|
|
218
183
|
* Resolve a ColorValue to a CSS color string
|
|
@@ -228,7 +193,7 @@ function resolveColor(color, theme, defaultColor = "000000") {
|
|
|
228
193
|
if (color.auto) return `#${safeDefault}`;
|
|
229
194
|
let hexColor;
|
|
230
195
|
if (color.themeColor) {
|
|
231
|
-
const slot =
|
|
196
|
+
const slot = themeColorSlot(color.themeColor);
|
|
232
197
|
if (slot) hexColor = getThemeColorValue(theme, slot);
|
|
233
198
|
else hexColor = color.rgb ?? defaultColor;
|
|
234
199
|
if (color.themeTint) {
|
|
@@ -323,8 +288,8 @@ function parseColorString(colorString) {
|
|
|
323
288
|
if (!colorString) return;
|
|
324
289
|
const normalized = colorString.trim();
|
|
325
290
|
if (normalized.toLowerCase() === "auto") return { auto: true };
|
|
326
|
-
const
|
|
327
|
-
if (
|
|
291
|
+
const themeColor = resolveThemeColorName(normalized);
|
|
292
|
+
if (themeColor) return { themeColor };
|
|
328
293
|
const hex = normalized.replace(/^#/u, "").toUpperCase();
|
|
329
294
|
if (/^[0-9A-F]{6}$/iu.test(hex)) return { rgb: hex };
|
|
330
295
|
if (/^[0-9A-F]{3}$/iu.test(hex)) return { rgb: hex.split("").map((c) => c + c).join("") };
|
|
@@ -455,24 +420,27 @@ const STANDARD_TEXT_COLORS = [
|
|
|
455
420
|
}
|
|
456
421
|
];
|
|
457
422
|
/**
|
|
458
|
-
* Theme color column order matching Word's color picker
|
|
459
|
-
*
|
|
423
|
+
* Theme color column order matching Word's color picker.
|
|
424
|
+
*
|
|
425
|
+
* Spelled as `ST_ThemeColor`, because the swatch a user picks is written into a
|
|
426
|
+
* `w:themeColor` attribute; the DrawingML slot it paints with comes from
|
|
427
|
+
* `themeColorSlot`.
|
|
460
428
|
*/
|
|
461
429
|
const THEME_MATRIX_COLUMNS = [
|
|
462
430
|
{
|
|
463
|
-
slot: "
|
|
431
|
+
slot: "background1",
|
|
464
432
|
name: "Background 1"
|
|
465
433
|
},
|
|
466
434
|
{
|
|
467
|
-
slot: "
|
|
435
|
+
slot: "text1",
|
|
468
436
|
name: "Text 1"
|
|
469
437
|
},
|
|
470
438
|
{
|
|
471
|
-
slot: "
|
|
439
|
+
slot: "background2",
|
|
472
440
|
name: "Background 2"
|
|
473
441
|
},
|
|
474
442
|
{
|
|
475
|
-
slot: "
|
|
443
|
+
slot: "text2",
|
|
476
444
|
name: "Text 2"
|
|
477
445
|
},
|
|
478
446
|
{
|
|
@@ -566,7 +534,8 @@ function getThemeTintShadeHex(baseHex, type, fraction) {
|
|
|
566
534
|
function generateThemeTintShadeMatrix(colorScheme) {
|
|
567
535
|
const scheme = colorScheme ?? DEFAULT_THEME_COLORS;
|
|
568
536
|
return THEME_MATRIX_ROWS.map((row) => THEME_MATRIX_COLUMNS.map((col) => {
|
|
569
|
-
const
|
|
537
|
+
const slot = themeColorSlot(col.slot);
|
|
538
|
+
const baseHex = slot === void 0 ? "000000" : scheme[slot] ?? DEFAULT_THEME_COLORS[slot];
|
|
570
539
|
let hex;
|
|
571
540
|
if (row.type === "base") hex = baseHex.toUpperCase();
|
|
572
541
|
else if (row.type === "tint") hex = applyTint(baseHex, row.value);
|
|
@@ -96,7 +96,10 @@ function getDefaultStyles() {
|
|
|
96
96
|
spaceBefore: 400,
|
|
97
97
|
spaceAfter: 120,
|
|
98
98
|
lineSpacing: 240,
|
|
99
|
-
outlineLevel:
|
|
99
|
+
outlineLevel: {
|
|
100
|
+
kind: "heading",
|
|
101
|
+
level: 0
|
|
102
|
+
}
|
|
100
103
|
}
|
|
101
104
|
},
|
|
102
105
|
{
|
|
@@ -119,7 +122,10 @@ function getDefaultStyles() {
|
|
|
119
122
|
spaceBefore: 360,
|
|
120
123
|
spaceAfter: 80,
|
|
121
124
|
lineSpacing: 240,
|
|
122
|
-
outlineLevel:
|
|
125
|
+
outlineLevel: {
|
|
126
|
+
kind: "heading",
|
|
127
|
+
level: 1
|
|
128
|
+
}
|
|
123
129
|
}
|
|
124
130
|
},
|
|
125
131
|
{
|
|
@@ -142,7 +148,10 @@ function getDefaultStyles() {
|
|
|
142
148
|
spaceBefore: 320,
|
|
143
149
|
spaceAfter: 80,
|
|
144
150
|
lineSpacing: 240,
|
|
145
|
-
outlineLevel:
|
|
151
|
+
outlineLevel: {
|
|
152
|
+
kind: "heading",
|
|
153
|
+
level: 2
|
|
154
|
+
}
|
|
146
155
|
}
|
|
147
156
|
},
|
|
148
157
|
{
|
|
@@ -165,7 +174,10 @@ function getDefaultStyles() {
|
|
|
165
174
|
spaceBefore: 280,
|
|
166
175
|
spaceAfter: 80,
|
|
167
176
|
lineSpacing: 240,
|
|
168
|
-
outlineLevel:
|
|
177
|
+
outlineLevel: {
|
|
178
|
+
kind: "heading",
|
|
179
|
+
level: 3
|
|
180
|
+
}
|
|
169
181
|
}
|
|
170
182
|
},
|
|
171
183
|
{
|
|
@@ -188,7 +200,10 @@ function getDefaultStyles() {
|
|
|
188
200
|
spaceBefore: 240,
|
|
189
201
|
spaceAfter: 80,
|
|
190
202
|
lineSpacing: 240,
|
|
191
|
-
outlineLevel:
|
|
203
|
+
outlineLevel: {
|
|
204
|
+
kind: "heading",
|
|
205
|
+
level: 4
|
|
206
|
+
}
|
|
192
207
|
}
|
|
193
208
|
},
|
|
194
209
|
{
|
|
@@ -212,7 +227,10 @@ function getDefaultStyles() {
|
|
|
212
227
|
spaceBefore: 240,
|
|
213
228
|
spaceAfter: 80,
|
|
214
229
|
lineSpacing: 240,
|
|
215
|
-
outlineLevel:
|
|
230
|
+
outlineLevel: {
|
|
231
|
+
kind: "heading",
|
|
232
|
+
level: 5
|
|
233
|
+
}
|
|
216
234
|
}
|
|
217
235
|
},
|
|
218
236
|
{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { panic } from "better-result";
|
|
1
2
|
//#region src/utils/findReplace.ts
|
|
2
3
|
const createDefaultFindOptions = () => ({
|
|
3
4
|
matchCase: false,
|
|
@@ -101,17 +102,58 @@ const getRunSearchProjection = (run) => {
|
|
|
101
102
|
pageBreakOffsets
|
|
102
103
|
};
|
|
103
104
|
};
|
|
104
|
-
const getHyperlinkSearchProjection = (hyperlink) => joinSearchProjections(hyperlink.children.flatMap((child) =>
|
|
105
|
+
const getHyperlinkSearchProjection = (hyperlink) => joinSearchProjections(hyperlink.children.flatMap((child) => {
|
|
106
|
+
if (child.type === "run") return [getRunSearchProjection(child)];
|
|
107
|
+
return child.type === "inlineWrapper" ? [getParagraphContentSearchProjection(child)] : [];
|
|
108
|
+
}));
|
|
109
|
+
/** Nothing on the line: a marker, or markup with no text under it. */
|
|
110
|
+
const noSearchText = () => ({
|
|
111
|
+
text: "",
|
|
112
|
+
pageBreakOffsets: []
|
|
113
|
+
});
|
|
114
|
+
/**
|
|
115
|
+
* The text one paragraph content item puts on the line, for searching.
|
|
116
|
+
*
|
|
117
|
+
* A `switch` with a `never` default rather than an `if`-chain ending in the
|
|
118
|
+
* empty projection: a chain answers "no text" for a member nobody considered,
|
|
119
|
+
* and a member that holds runs and answers "no text" is text the reader can
|
|
120
|
+
* see and find cannot. That is what the revision wrappers and the transparent
|
|
121
|
+
* inline wrappers were doing — a search for a phrase inside a `w:bdo`, a smart
|
|
122
|
+
* tag or an insertion found nothing.
|
|
123
|
+
*
|
|
124
|
+
* The offsets this produces are resolved back to an editor position by
|
|
125
|
+
* `resolveFindMatchRange`, against the text `getSearchableParagraphText`
|
|
126
|
+
* builds from the ProseMirror tree. So the two have to agree character for
|
|
127
|
+
* character, and this one mirrors that one: every text node counts, including
|
|
128
|
+
* the deleted and moved-away text the editor still shows struck through. A
|
|
129
|
+
* member skipped here shifts every later offset and the replacement lands on
|
|
130
|
+
* the wrong characters.
|
|
131
|
+
*/
|
|
105
132
|
const getParagraphContentSearchProjection = (content) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
133
|
+
switch (content.type) {
|
|
134
|
+
case "run": return getRunSearchProjection(content);
|
|
135
|
+
case "hyperlink": return getHyperlinkSearchProjection(content);
|
|
136
|
+
case "inlineSdt":
|
|
137
|
+
case "simpleField":
|
|
138
|
+
case "inlineWrapper":
|
|
139
|
+
case "insertion":
|
|
140
|
+
case "deletion":
|
|
141
|
+
case "moveFrom":
|
|
142
|
+
case "moveTo": return joinSearchProjections(content.content.map(getParagraphContentSearchProjection));
|
|
143
|
+
case "complexField": return joinSearchProjections(content.fieldResult.map(getRunSearchProjection));
|
|
144
|
+
case "bookmarkStart":
|
|
145
|
+
case "bookmarkEnd":
|
|
146
|
+
case "commentRangeStart":
|
|
147
|
+
case "commentRangeEnd":
|
|
148
|
+
case "commentReference":
|
|
149
|
+
case "moveFromRangeStart":
|
|
150
|
+
case "moveFromRangeEnd":
|
|
151
|
+
case "moveToRangeStart":
|
|
152
|
+
case "moveToRangeEnd":
|
|
153
|
+
case "mathEquation":
|
|
154
|
+
case "preservedInline": return noSearchText();
|
|
155
|
+
default: panic(`Unsupported paragraph content: ${JSON.stringify(content)}`);
|
|
156
|
+
}
|
|
115
157
|
};
|
|
116
158
|
const getParagraphSearchProjection = (paragraph) => joinSearchProjections(paragraph.content.map(getParagraphContentSearchProjection));
|
|
117
159
|
const findContentIndexAtOffset = (paragraph, offset) => {
|