@stll/folio-core 0.45.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 +85 -43
- package/dist/ai-edits/headless.js +2 -2
- 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/compare.js +2 -5
- 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/scenario.js +2 -5
- package/dist/compare/section-boundary-properties.js +1 -2
- package/dist/compare/types.d.ts +9 -1
- package/dist/compare/types.js +12 -1
- package/dist/compat/eigenpal.d.ts +2 -1
- package/dist/compat/eigenpal.js +2 -1
- package/dist/content-controls/checkboxDisplay.d.ts +17 -0
- package/dist/content-controls/checkboxDisplay.js +46 -0
- package/dist/content-controls/findContentControls.js +3 -1
- package/dist/content-controls/mutateContentControls.js +57 -43
- package/dist/controller/contentControlWidgetController.d.ts +1 -0
- package/dist/controller/contentControlWidgetController.js +3 -0
- package/dist/controller/hiddenEditorApi.js +3 -1
- package/dist/controller/hiddenEditorManager.d.ts +1 -1
- package/dist/controller/hiddenEditorManager.js +6 -3
- package/dist/controller/layoutPipeline.js +8 -3
- package/dist/display-list/build/buildDisplayList.js +20 -1
- package/dist/display-list/build/imagePrimitives.d.ts +4 -4
- package/dist/display-list/build/imagePrimitives.js +38 -18
- package/dist/display-list/build/pageBorderPrimitives.js +2 -1
- package/dist/display-list/build/paragraphPrimitives.js +113 -14
- 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 +11 -21
- package/dist/display-list/primitives.d.ts +13 -2
- package/dist/display-list/primitives.js +36 -1
- package/dist/display-list/types.d.ts +17 -0
- package/dist/document-operations.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +76 -0
- package/dist/docx/attributeRemainder.js +111 -0
- package/dist/docx/blockContentParser.d.ts +3 -1
- package/dist/docx/blockContentParser.js +102 -106
- package/dist/docx/blockPlainText.d.ts +3 -4
- package/dist/docx/blockPlainText.js +3 -0
- 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.d.ts +30 -0
- package/dist/docx/commentAnchorIndex.js +50 -0
- package/dist/docx/commentParser.d.ts +1 -1
- package/dist/docx/commentParser.js +56 -39
- package/dist/docx/commentRangeIntegrity.d.ts +16 -1
- package/dist/docx/commentRangeIntegrity.js +42 -1
- package/dist/docx/commentRangeJoin.d.ts +9 -0
- package/dist/docx/commentRangeJoin.js +33 -0
- package/dist/docx/commentReferenceCompletion.d.ts +9 -0
- package/dist/docx/commentReferenceCompletion.js +47 -0
- package/dist/docx/commentReferenceNormalization.js +3 -1
- package/dist/docx/commentReplyMarkers.js +11 -19
- package/dist/docx/compatibility.js +56 -41
- package/dist/docx/containerChildren.d.ts +208 -0
- package/dist/docx/containerChildren.gen.d.ts +43 -0
- package/dist/docx/containerChildren.gen.js +263 -0
- package/dist/docx/containerChildren.js +153 -0
- package/dist/docx/diagramPreview.d.ts +14 -2
- package/dist/docx/diagramPreview.js +81 -169
- package/dist/docx/documentParser.d.ts +1 -1
- package/dist/docx/documentParser.js +7 -4
- 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/ensureParaIds.js +17 -7
- package/dist/docx/fieldParser.d.ts +1 -1
- package/dist/docx/fieldParser.js +4 -4
- package/dist/docx/fieldState.d.ts +26 -0
- package/dist/docx/fieldState.js +53 -0
- package/dist/docx/fontTableParser.js +102 -41
- package/dist/docx/footnoteParser.d.ts +1 -1
- package/dist/docx/footnoteParser.js +10 -6
- package/dist/docx/graphicFrameLocks.d.ts +16 -4
- package/dist/docx/graphicFrameLocks.js +19 -6
- package/dist/docx/groupDrawingParser.js +4 -3
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/headerFooterReferenceNormalization.js +1 -0
- package/dist/docx/hyperlinkParser.d.ts +66 -9
- package/dist/docx/hyperlinkParser.js +153 -26
- package/dist/docx/imageParser.js +160 -115
- 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 +166 -0
- package/dist/docx/inlineWrapperContent.js +165 -0
- 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 +12 -1
- 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 +111 -0
- package/dist/docx/paraIdAttribute.js +142 -0
- package/dist/docx/paragraphParser.d.ts +10 -25
- package/dist/docx/paragraphParser.js +421 -496
- package/dist/docx/paragraphProperties.d.ts +23 -0
- package/dist/docx/paragraphProperties.js +279 -0
- package/dist/docx/paragraphPropertySource.js +7 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +3 -2
- package/dist/docx/paragraphTextBoxEnrichment.js +20 -59
- package/dist/docx/paragraphTraversal.d.ts +14 -10
- package/dist/docx/paragraphTraversal.js +53 -52
- package/dist/docx/parseWarningMessage.js +5 -1
- package/dist/docx/parserEnums.d.ts +6 -8
- package/dist/docx/parserEnums.js +4 -6
- package/dist/docx/preservedRunContent.d.ts +32 -0
- package/dist/docx/preservedRunContent.js +96 -0
- 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 +4 -6
- package/dist/docx/rezip.d.ts +28 -2
- package/dist/docx/rezip.js +152 -27
- package/dist/docx/runConsolidator.d.ts +42 -2
- package/dist/docx/runConsolidator.js +60 -6
- package/dist/docx/runParser.d.ts +55 -19
- package/dist/docx/runParser.js +394 -306
- 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 +241 -238
- package/dist/docx/selectiveSave.js +3 -2
- package/dist/docx/selectiveXmlPatch.d.ts +66 -3
- package/dist/docx/selectiveXmlPatch.js +276 -133
- package/dist/docx/serializer/blockSdtSerializer.js +2 -96
- package/dist/docx/serializer/borderSerializer.d.ts +5 -5
- package/dist/docx/serializer/borderSerializer.js +12 -10
- package/dist/docx/serializer/commentSerializer.js +5 -7
- package/dist/docx/serializer/documentSerializer.js +11 -11
- package/dist/docx/serializer/fontTableSerializer.js +31 -3
- package/dist/docx/serializer/headerFooterSerializer.js +10 -9
- package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
- package/dist/docx/serializer/markupRangeAttributes.js +9 -1
- package/dist/docx/serializer/noteSerializer.js +11 -8
- 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 +156 -236
- package/dist/docx/serializer/runSerializer.d.ts +1 -5
- package/dist/docx/serializer/runSerializer.js +134 -75
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
- package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +42 -49
- package/dist/docx/serializer/settingsSerializer.js +6 -4
- package/dist/docx/serializer/stylesSerializer.js +8 -11
- package/dist/docx/serializer/tableSerializer.js +283 -105
- 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 +20 -16
- package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
- package/dist/docx/server/materializeYjsDocx.js +9 -1
- package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
- package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
- 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 +13 -8
- 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 +11 -2
- package/dist/docx/tableParser.js +665 -220
- package/dist/docx/textBoxParser.d.ts +28 -3
- package/dist/docx/textBoxParser.js +69 -9
- 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/unzip.js +5 -4
- package/dist/docx/vmlImageParser.d.ts +30 -5
- package/dist/docx/vmlImageParser.js +91 -32
- 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/xmlEncoding.d.ts +5 -0
- package/dist/docx/xmlEncoding.js +12 -0
- package/dist/docx/xmlParser.d.ts +23 -1
- package/dist/docx/xmlParser.js +31 -2
- package/dist/fonts/embeddedFonts.js +3 -3
- package/dist/headless-layout.js +12 -1
- 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/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/headlessRevisionResolution.js +9 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +7 -2
- 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 +267 -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/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +2 -0
- 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 +69 -17
- package/dist/layout-engine/types.js +16 -1
- package/dist/layout-painter/borderStroke.d.ts +18 -4
- package/dist/layout-painter/renderImage.d.ts +5 -1
- package/dist/layout-painter/renderImage.js +10 -3
- package/dist/layout-painter/renderPage.d.ts +2 -0
- package/dist/layout-painter/renderPage.js +10 -4
- package/dist/layout-painter/renderParagraph.d.ts +14 -1
- package/dist/layout-painter/renderParagraph.js +34 -28
- 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/managers/autoSaveCodec.d.ts +9 -1
- package/dist/managers/autoSaveCodec.js +12 -4
- package/dist/markdown/renderBlock.js +3 -0
- package/dist/markdown/renderRuns.d.ts +1 -1
- package/dist/markdown/renderRuns.js +34 -6
- package/dist/markdown/renderTable.js +24 -6
- package/dist/markdown/trailers.js +4 -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/pdf/images.js +142 -6
- package/dist/prosemirror/attrs/index.d.ts +34 -5
- package/dist/prosemirror/attrs/index.js +639 -48
- package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
- package/dist/prosemirror/authoredTransformAttrs.js +64 -0
- 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 +33 -20
- package/dist/prosemirror/commands/image.d.ts +10 -3
- package/dist/prosemirror/commands/image.js +46 -29
- package/dist/prosemirror/commands/pageBreak.js +1 -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/commentReferenceAttrs.d.ts +8 -0
- package/dist/prosemirror/commentReferenceAttrs.js +33 -0
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +17 -12
- package/dist/prosemirror/conversion/fromProseDoc.js +553 -207
- 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.d.ts +7 -9
- package/dist/prosemirror/conversion/toProseDoc.js +801 -411
- package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
- package/dist/prosemirror/emptyRangeAnchor.js +158 -0
- package/dist/prosemirror/extensions/StarterKit.js +14 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +21 -16
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +48 -29
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
- package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
- 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 +65 -0
- package/dist/prosemirror/extensions/markRegistry.js +138 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +77 -0
- 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.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +49 -5
- 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.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +97 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +24 -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/PreservedBlockExtension.d.ts +32 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -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 +7 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +142 -123
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +9 -1
- 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.d.ts +39 -0
- package/dist/prosemirror/inlineWrapperStack.js +92 -0
- 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/pageBreakRunProjection.d.ts +17 -7
- package/dist/prosemirror/pageBreakRunProjection.js +19 -9
- 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 +59 -0
- package/dist/prosemirror/replacedAnnotations.js +183 -0
- package/dist/prosemirror/revisionCarriers.d.ts +86 -2
- package/dist/prosemirror/revisionCarriers.js +86 -60
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +5 -1
- package/dist/prosemirror/runFormattingInlineCarriers.js +7 -1
- 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 +3 -3
- package/dist/prosemirror/schema/marks.d.ts +47 -4
- package/dist/prosemirror/schema/nodes.d.ts +309 -26
- package/dist/prosemirror/schema/nodes.js +16 -1
- 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 +4 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +4 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
- package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
- package/dist/prosemirror/validation.js +31 -6
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
- package/dist/prosemirror/yjsDocumentMetadata.js +592 -0
- package/dist/prosemirror/zeroWidthAnchors.js +6 -0
- package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
- package/dist/render-dom/commentAnchorAttributes.js +54 -0
- package/dist/server.d.ts +3 -1
- package/dist/server.js +3 -1
- 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/clipboard.d.ts +9 -1
- package/dist/utils/clipboard.js +27 -1
- 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/imageLuminance.d.ts +15 -0
- package/dist/utils/imageLuminance.js +32 -0
- package/dist/utils/mergeDocumentContent.js +12 -20
- package/dist/utils/paragraphFormattingMerge.js +27 -6
- package/dist/utils/replaceText.js +1 -0
- 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/blockRangeMarkers.d.ts +0 -36
- package/dist/docx/blockRangeMarkers.js +0 -59
- package/dist/docx/bookmarkPlacement.d.ts +0 -9
- package/dist/docx/bookmarkPlacement.js +0 -50
- 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
- package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
- package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import { readParagraphAttrs } from "../../attrs/index.js";
|
|
2
|
-
import {
|
|
1
|
+
import { readParagraphAttrs, readTableAttrs, readTableRowAttrs } from "../../attrs/index.js";
|
|
2
|
+
import { readBookmarkBoundaryAttrs } from "../../bookmarkBoundaryAttrs.js";
|
|
3
3
|
import { findInvalidBookmarkBoundaryIds } from "../../bookmarkBoundaryIntegrity.js";
|
|
4
4
|
import { createNodeExtension } from "../create.js";
|
|
5
|
+
import { BLOCK_BOOKMARK_BOUNDARY_NODE_NAME } from "./BlockBookmarkBoundaryExtension.js";
|
|
6
|
+
import { bookmarkBoundaryAttrSpec, bookmarkBoundaryDomAttributes, parseBookmarkBoundaryDom } from "./bookmarkBoundaryDom.js";
|
|
5
7
|
import { Plugin } from "prosemirror-state";
|
|
6
8
|
//#region src/prosemirror/extensions/nodes/BookmarkBoundaryExtension.ts
|
|
7
|
-
function readNonnegativeInteger(value) {
|
|
8
|
-
if (value === null || !/^(?:0|[1-9]\d*)$/.test(value)) return false;
|
|
9
|
-
const parsed = Number(value);
|
|
10
|
-
return Number.isSafeInteger(parsed) ? parsed : false;
|
|
11
|
-
}
|
|
12
|
-
function readOptionalColumn(dom, attribute) {
|
|
13
|
-
const value = dom.getAttribute(attribute);
|
|
14
|
-
return value === null ? void 0 : readNonnegativeInteger(value);
|
|
15
|
-
}
|
|
16
9
|
/** The node name, for callers asking whether a paragraph holds any content. */
|
|
17
10
|
const BOOKMARK_BOUNDARY_NODE_NAME = "bookmarkBoundary";
|
|
11
|
+
/**
|
|
12
|
+
* Both boundary node types, because a bookmark pairs across them.
|
|
13
|
+
*
|
|
14
|
+
* A range that opens as a child of `w:body` and closes inside a paragraph is
|
|
15
|
+
* the commoner shape in real documents, so a pass that read one node type
|
|
16
|
+
* would see half of every such pair, call it unpaired, and delete it.
|
|
17
|
+
*/
|
|
18
|
+
const BOUNDARY_NODE_NAMES = /* @__PURE__ */ new Set([BOOKMARK_BOUNDARY_NODE_NAME, BLOCK_BOOKMARK_BOUNDARY_NODE_NAME]);
|
|
19
|
+
/** The markers a `table` or `tableRow` node carries, or none. */
|
|
20
|
+
const positionedBookmarksOf = (node) => {
|
|
21
|
+
const attrs = node.type.name === "table" ? readTableAttrs(node) : readTableRowAttrs(node);
|
|
22
|
+
return attrs.ok ? attrs.value._bookmarks ?? [] : [];
|
|
23
|
+
};
|
|
18
24
|
const collectInvalidBoundaries = (doc) => {
|
|
19
25
|
const boundaries = [];
|
|
20
26
|
const malformedBoundaries = [];
|
|
@@ -24,7 +30,13 @@ const collectInvalidBoundaries = (doc) => {
|
|
|
24
30
|
const attrs = readParagraphAttrs(node);
|
|
25
31
|
if (attrs.ok) for (const bookmark of attrs.value.bookmarks ?? []) paragraphBookmarkIds.add(bookmark.id);
|
|
26
32
|
}
|
|
27
|
-
if (node.type.name
|
|
33
|
+
if (node.type.name === "table" || node.type.name === "tableRow") for (const { marker } of positionedBookmarksOf(node)) boundaries.push({
|
|
34
|
+
id: marker.id,
|
|
35
|
+
type: marker.type === "bookmarkStart" ? "start" : "end",
|
|
36
|
+
position,
|
|
37
|
+
node
|
|
38
|
+
});
|
|
39
|
+
if (!BOUNDARY_NODE_NAMES.has(node.type.name)) return true;
|
|
28
40
|
const result = readBookmarkBoundaryAttrs(node);
|
|
29
41
|
if (!result.ok) {
|
|
30
42
|
malformedBoundaries.push({
|
|
@@ -44,7 +56,7 @@ const collectInvalidBoundaries = (doc) => {
|
|
|
44
56
|
return false;
|
|
45
57
|
});
|
|
46
58
|
const invalidIds = findInvalidBookmarkBoundaryIds(boundaries, paragraphBookmarkIds);
|
|
47
|
-
return [...boundaries.filter(({ id }) => invalidIds.has(id)), ...malformedBoundaries];
|
|
59
|
+
return [...boundaries.filter(({ id, node }) => invalidIds.has(id) && BOUNDARY_NODE_NAMES.has(node.type.name)), ...malformedBoundaries];
|
|
48
60
|
};
|
|
49
61
|
const BookmarkBoundaryExtension = createNodeExtension({
|
|
50
62
|
name: BOOKMARK_BOUNDARY_NODE_NAME,
|
|
@@ -55,50 +67,13 @@ const BookmarkBoundaryExtension = createNodeExtension({
|
|
|
55
67
|
marks: "_",
|
|
56
68
|
atom: true,
|
|
57
69
|
selectable: false,
|
|
58
|
-
attrs:
|
|
59
|
-
type: {},
|
|
60
|
-
id: {},
|
|
61
|
-
name: { default: null },
|
|
62
|
-
colFirst: { default: null },
|
|
63
|
-
colLast: { default: null },
|
|
64
|
-
displacedByCustomXml: { default: null }
|
|
65
|
-
},
|
|
70
|
+
attrs: bookmarkBoundaryAttrSpec,
|
|
66
71
|
parseDOM: [{
|
|
67
72
|
tag: "span[data-docx-bookmark-boundary]",
|
|
68
|
-
getAttrs
|
|
69
|
-
const type = dom.getAttribute("data-docx-bookmark-boundary");
|
|
70
|
-
const id = readNonnegativeInteger(dom.getAttribute("data-docx-bookmark-id"));
|
|
71
|
-
if (type !== "start" && type !== "end" || id === false) return false;
|
|
72
|
-
const name = dom.getAttribute("data-docx-bookmark-name");
|
|
73
|
-
if (type === "start" && !name) return false;
|
|
74
|
-
const colFirst = readOptionalColumn(dom, "data-docx-bookmark-col-first");
|
|
75
|
-
const colLast = readOptionalColumn(dom, "data-docx-bookmark-col-last");
|
|
76
|
-
if (colFirst === false || colLast === false) return false;
|
|
77
|
-
const displaced = dom.getAttribute("data-docx-bookmark-displaced");
|
|
78
|
-
return {
|
|
79
|
-
type,
|
|
80
|
-
id,
|
|
81
|
-
...name ? { name } : {},
|
|
82
|
-
...colFirst !== void 0 ? { colFirst } : {},
|
|
83
|
-
...colLast !== void 0 ? { colLast } : {},
|
|
84
|
-
...isDisplacedByCustomXml(displaced) ? { displacedByCustomXml: displaced } : {}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
73
|
+
getAttrs: parseBookmarkBoundaryDom
|
|
87
74
|
}],
|
|
88
75
|
toDOM(node) {
|
|
89
|
-
|
|
90
|
-
return ["span", {
|
|
91
|
-
"data-docx-bookmark-boundary": attrs.type,
|
|
92
|
-
"data-docx-bookmark-id": String(attrs.id),
|
|
93
|
-
...attrs.type === "start" ? { "data-docx-bookmark-name": attrs.name } : {},
|
|
94
|
-
...attrs.type === "start" && attrs.colFirst !== void 0 ? { "data-docx-bookmark-col-first": String(attrs.colFirst) } : {},
|
|
95
|
-
...attrs.type === "start" && attrs.colLast !== void 0 ? { "data-docx-bookmark-col-last": String(attrs.colLast) } : {},
|
|
96
|
-
...attrs.displacedByCustomXml !== void 0 ? { "data-docx-bookmark-displaced": attrs.displacedByCustomXml } : {},
|
|
97
|
-
"aria-hidden": "true",
|
|
98
|
-
contenteditable: "false",
|
|
99
|
-
style: "display: none;",
|
|
100
|
-
...options.getInternalClipboardToken ? { "data-docx-internal-clipboard": options.getInternalClipboardToken() } : {}
|
|
101
|
-
}];
|
|
76
|
+
return ["span", bookmarkBoundaryDomAttributes(node, options.getInternalClipboardToken?.())];
|
|
102
77
|
}
|
|
103
78
|
}),
|
|
104
79
|
onSchemaReady: () => ({ plugins: [new Plugin({ appendTransaction(transactions, _oldState, newState) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NodeExtension } from "../types.js";
|
|
2
|
+
//#region src/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts
|
|
3
|
+
/** Zero-width `w:commentReference`: where a comment's visible mark is painted. */
|
|
4
|
+
type CommentReferenceOptions = {
|
|
5
|
+
getInternalClipboardToken?: () => string;
|
|
6
|
+
};
|
|
7
|
+
/** The node name, for callers asking whether a paragraph holds any content. */
|
|
8
|
+
declare const COMMENT_REFERENCE_NODE_NAME = "commentReference";
|
|
9
|
+
declare const CommentReferenceExtension: (options?: Partial<CommentReferenceOptions> | undefined) => NodeExtension;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { COMMENT_REFERENCE_NODE_NAME, CommentReferenceExtension };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { readCommentReferenceAttrs } from "../../commentReferenceAttrs.js";
|
|
2
|
+
import { planCommentReferenceRepairs } from "../../commentReferenceIntegrity.js";
|
|
3
|
+
import { readRangeAnchorAttrs } from "../../rangeAnchorAttrs.js";
|
|
4
|
+
import { createNodeExtension } from "../create.js";
|
|
5
|
+
import "./RangeAnchorExtension.js";
|
|
6
|
+
import { Plugin } from "prosemirror-state";
|
|
7
|
+
//#region src/prosemirror/extensions/nodes/CommentReferenceExtension.ts
|
|
8
|
+
/** The node name, for callers asking whether a paragraph holds any content. */
|
|
9
|
+
const COMMENT_REFERENCE_NODE_NAME = "commentReference";
|
|
10
|
+
const surveyCommentReferences = (doc) => {
|
|
11
|
+
const references = [];
|
|
12
|
+
const markEnds = /* @__PURE__ */ new Map();
|
|
13
|
+
doc.descendants((node, position) => {
|
|
14
|
+
if (node.type.name === "commentReference") {
|
|
15
|
+
const attrs = readCommentReferenceAttrs(node);
|
|
16
|
+
references.push({
|
|
17
|
+
commentId: attrs.ok ? attrs.value.commentId : -1,
|
|
18
|
+
position,
|
|
19
|
+
size: node.nodeSize,
|
|
20
|
+
malformed: !attrs.ok
|
|
21
|
+
});
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (node.type.name === "rangeAnchor") {
|
|
25
|
+
const attrs = readRangeAnchorAttrs(node);
|
|
26
|
+
if (attrs.ok && attrs.value.start.type === "commentRangeStart") {
|
|
27
|
+
const { id } = attrs.value.start;
|
|
28
|
+
markEnds.set(id, Math.max(markEnds.get(id) ?? 0, position + node.nodeSize));
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (!node.isInline) return true;
|
|
33
|
+
for (const mark of node.marks) {
|
|
34
|
+
if (mark.type.name !== "comment") continue;
|
|
35
|
+
const commentId = mark.attrs["commentId"];
|
|
36
|
+
if (typeof commentId !== "number") continue;
|
|
37
|
+
markEnds.set(commentId, Math.max(markEnds.get(commentId) ?? 0, position + node.nodeSize));
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
references,
|
|
43
|
+
markExtents: [...markEnds].map(([commentId, end]) => ({
|
|
44
|
+
commentId,
|
|
45
|
+
end
|
|
46
|
+
}))
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const CommentReferenceExtension = createNodeExtension({
|
|
50
|
+
name: COMMENT_REFERENCE_NODE_NAME,
|
|
51
|
+
schemaNodeName: COMMENT_REFERENCE_NODE_NAME,
|
|
52
|
+
nodeSpec: (options) => ({
|
|
53
|
+
inline: true,
|
|
54
|
+
group: "inline",
|
|
55
|
+
marks: "_",
|
|
56
|
+
atom: true,
|
|
57
|
+
selectable: false,
|
|
58
|
+
attrs: { commentId: {} },
|
|
59
|
+
parseDOM: [{
|
|
60
|
+
tag: "span[data-docx-comment-reference]",
|
|
61
|
+
getAttrs(dom) {
|
|
62
|
+
const raw = dom.getAttribute("data-docx-comment-reference");
|
|
63
|
+
if (raw === null || !/^(?:0|[1-9]\d*)$/.test(raw)) return false;
|
|
64
|
+
const commentId = Number(raw);
|
|
65
|
+
return Number.isSafeInteger(commentId) ? { commentId } : false;
|
|
66
|
+
}
|
|
67
|
+
}],
|
|
68
|
+
toDOM(node) {
|
|
69
|
+
const attrs = readCommentReferenceAttrs(node);
|
|
70
|
+
return ["span", {
|
|
71
|
+
"data-docx-comment-reference": String(attrs.ok ? attrs.value.commentId : ""),
|
|
72
|
+
"aria-hidden": "true",
|
|
73
|
+
contenteditable: "false",
|
|
74
|
+
style: "display: none;",
|
|
75
|
+
...options.getInternalClipboardToken ? { "data-docx-internal-clipboard": options.getInternalClipboardToken() } : {}
|
|
76
|
+
}];
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
onSchemaReady: ({ schema }) => ({ plugins: [new Plugin({ appendTransaction(transactions, _oldState, newState) {
|
|
80
|
+
if (!transactions.some(({ docChanged }) => docChanged)) return null;
|
|
81
|
+
const referenceType = schema.nodes[COMMENT_REFERENCE_NODE_NAME];
|
|
82
|
+
if (!referenceType) return null;
|
|
83
|
+
const repairs = planCommentReferenceRepairs(surveyCommentReferences(newState.doc));
|
|
84
|
+
if (repairs.length === 0) return null;
|
|
85
|
+
const transaction = newState.tr;
|
|
86
|
+
for (const repair of repairs) {
|
|
87
|
+
if (repair.type === "delete") {
|
|
88
|
+
transaction.delete(repair.position, repair.position + repair.size);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
transaction.insert(transaction.mapping.map(repair.position), referenceType.create({ commentId: repair.commentId }));
|
|
92
|
+
}
|
|
93
|
+
return transaction;
|
|
94
|
+
} })] })
|
|
95
|
+
});
|
|
96
|
+
//#endregion
|
|
97
|
+
export { COMMENT_REFERENCE_NODE_NAME, CommentReferenceExtension };
|
|
@@ -8,16 +8,18 @@ const createFieldAttrs = () => ({
|
|
|
8
8
|
displayText: { default: "" },
|
|
9
9
|
_numberedRefBaseline: { default: void 0 },
|
|
10
10
|
fieldKind: { default: "simple" },
|
|
11
|
-
fldLock: { default:
|
|
12
|
-
dirty: { default:
|
|
11
|
+
fldLock: { default: null },
|
|
12
|
+
dirty: { default: null }
|
|
13
13
|
});
|
|
14
|
+
/** A `data-` flag a pasted field carried: absent states nothing. */
|
|
15
|
+
const statedFlag = (value) => value === void 0 ? null : value === "true";
|
|
14
16
|
const readFieldDomAttrs = (dom) => ({
|
|
15
17
|
fieldType: dom.dataset["fieldType"] ?? "UNKNOWN",
|
|
16
18
|
instruction: dom.dataset["instruction"] ?? "",
|
|
17
19
|
displayText: dom.textContent ?? "",
|
|
18
20
|
fieldKind: dom.dataset["fieldKind"] ?? "simple",
|
|
19
|
-
fldLock: dom.dataset["fldLock"]
|
|
20
|
-
dirty: dom.dataset["dirty"]
|
|
21
|
+
fldLock: statedFlag(dom.dataset["fldLock"]),
|
|
22
|
+
dirty: statedFlag(dom.dataset["dirty"])
|
|
21
23
|
});
|
|
22
24
|
const getFieldDomAttrs = (node) => {
|
|
23
25
|
const { fieldType, instruction, fieldKind, fldLock, dirty } = expectFieldAttrs(node);
|
|
@@ -26,8 +28,8 @@ const getFieldDomAttrs = (node) => {
|
|
|
26
28
|
"data-field-type": fieldType,
|
|
27
29
|
"data-instruction": instruction,
|
|
28
30
|
"data-field-kind": fieldKind,
|
|
29
|
-
...fldLock ? { "data-fld-lock":
|
|
30
|
-
...dirty ? { "data-dirty":
|
|
31
|
+
...fldLock === void 0 ? {} : { "data-fld-lock": String(fldLock) },
|
|
32
|
+
...dirty === void 0 ? {} : { "data-dirty": String(dirty) },
|
|
31
33
|
style: "outline: 1px solid var(--doc-field-outline, rgba(200,200,200,0.4)); padding: 0 1px; border-radius: 2px;"
|
|
32
34
|
};
|
|
33
35
|
};
|
|
@@ -74,7 +76,7 @@ const StructuredFieldExtension = createNodeExtension({
|
|
|
74
76
|
nodeSpec: (options) => ({
|
|
75
77
|
inline: true,
|
|
76
78
|
group: "inline",
|
|
77
|
-
content: "(text | bookmarkBoundary | tab | symbol | hardBreak | pageBreakRun | image | shape | renderedPageBreak | textBoxAnchor)+",
|
|
79
|
+
content: "(text | bookmarkBoundary | tab | symbol | hardBreak | pageBreakRun | image | shape | renderedPageBreak | textBoxAnchor | preservedXml)+",
|
|
78
80
|
atom: true,
|
|
79
81
|
selectable: true,
|
|
80
82
|
attrs: createFieldAttrs(),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { imageLuminanceFilter } from "../../../utils/imageLuminance.js";
|
|
1
2
|
import { expectImageAttrs } from "../../attrs/index.js";
|
|
2
3
|
import { createNodeExtension } from "../create.js";
|
|
3
4
|
//#region src/prosemirror/extensions/nodes/ImageExtension.ts
|
|
@@ -14,6 +15,7 @@ const ImageExtension = createNodeExtension({
|
|
|
14
15
|
draggable: true,
|
|
15
16
|
attrs: {
|
|
16
17
|
src: {},
|
|
18
|
+
preview: { default: null },
|
|
17
19
|
docPrName: { default: null },
|
|
18
20
|
alt: { default: null },
|
|
19
21
|
title: { default: null },
|
|
@@ -24,7 +26,12 @@ const ImageExtension = createNodeExtension({
|
|
|
24
26
|
displayMode: { default: "inline" },
|
|
25
27
|
cssFloat: { default: null },
|
|
26
28
|
transform: { default: null },
|
|
29
|
+
docxRotation: { default: null },
|
|
30
|
+
docxFlipH: { default: null },
|
|
31
|
+
docxFlipV: { default: null },
|
|
27
32
|
opacity: { default: null },
|
|
33
|
+
brightness: { default: null },
|
|
34
|
+
contrast: { default: null },
|
|
28
35
|
distTop: { default: null },
|
|
29
36
|
distBottom: { default: null },
|
|
30
37
|
distLeft: { default: null },
|
|
@@ -38,7 +45,10 @@ const ImageExtension = createNodeExtension({
|
|
|
38
45
|
paddingBottom: { default: null },
|
|
39
46
|
paddingLeft: { default: null },
|
|
40
47
|
position: { default: null },
|
|
41
|
-
|
|
48
|
+
anchor: { default: null },
|
|
49
|
+
wrapDistanceSlots: { default: null },
|
|
50
|
+
wrapEffectExtentSlots: { default: null },
|
|
51
|
+
wrapPolygon: { default: null },
|
|
42
52
|
decorative: { default: null },
|
|
43
53
|
hidden: { default: null },
|
|
44
54
|
docPrExtensions: { default: null },
|
|
@@ -50,6 +60,9 @@ const ImageExtension = createNodeExtension({
|
|
|
50
60
|
wrapText: { default: null },
|
|
51
61
|
hlinkHref: { default: null },
|
|
52
62
|
hlinkRId: { default: null },
|
|
63
|
+
hlinkClickSource: { default: null },
|
|
64
|
+
hlinkHoverXml: { default: null },
|
|
65
|
+
docPrId: { default: null },
|
|
53
66
|
_docxRawXml: { default: null },
|
|
54
67
|
_docxRawXmlMode: { default: null },
|
|
55
68
|
_docxRawImageFingerprint: { default: null },
|
|
@@ -66,6 +79,10 @@ const ImageExtension = createNodeExtension({
|
|
|
66
79
|
const borderWidthRaw = element.dataset["borderWidth"];
|
|
67
80
|
const opacityRaw = element.dataset["opacity"];
|
|
68
81
|
const opacityParsed = opacityRaw === void 0 ? NaN : Number(opacityRaw);
|
|
82
|
+
const brightnessRaw = element.dataset["brightness"];
|
|
83
|
+
const brightness = brightnessRaw === void 0 ? NaN : Number(brightnessRaw);
|
|
84
|
+
const contrastRaw = element.dataset["contrast"];
|
|
85
|
+
const contrast = contrastRaw === void 0 ? NaN : Number(contrastRaw);
|
|
69
86
|
return {
|
|
70
87
|
src: element.getAttribute("src") || "",
|
|
71
88
|
...alt ? { alt } : {},
|
|
@@ -78,6 +95,8 @@ const ImageExtension = createNodeExtension({
|
|
|
78
95
|
...cssFloat ? { cssFloat } : {},
|
|
79
96
|
...element.dataset["transform"] ? { transform: element.dataset["transform"] } : {},
|
|
80
97
|
...Number.isFinite(opacityParsed) ? { opacity: opacityParsed } : {},
|
|
98
|
+
...Number.isFinite(brightness) ? { brightness } : {},
|
|
99
|
+
...Number.isFinite(contrast) ? { contrast } : {},
|
|
81
100
|
...borderWidthRaw ? { borderWidth: Number(borderWidthRaw) } : {},
|
|
82
101
|
...element.dataset["borderColor"] ? { borderColor: element.dataset["borderColor"] } : {},
|
|
83
102
|
...element.dataset["borderStyle"] ? { borderStyle: element.dataset["borderStyle"] } : {}
|
|
@@ -98,6 +117,8 @@ const ImageExtension = createNodeExtension({
|
|
|
98
117
|
if (attrs.cssFloat) domAttrs["data-css-float"] = attrs.cssFloat;
|
|
99
118
|
if (attrs.transform) domAttrs["data-transform"] = attrs.transform;
|
|
100
119
|
if (attrs.opacity != null) domAttrs["data-opacity"] = String(attrs.opacity);
|
|
120
|
+
if (attrs.brightness != null) domAttrs["data-brightness"] = String(attrs.brightness);
|
|
121
|
+
if (attrs.contrast != null) domAttrs["data-contrast"] = String(attrs.contrast);
|
|
101
122
|
if (attrs.borderWidth) domAttrs["data-border-width"] = String(attrs.borderWidth);
|
|
102
123
|
if (attrs.borderColor) domAttrs["data-border-color"] = attrs.borderColor;
|
|
103
124
|
if (attrs.borderStyle) domAttrs["data-border-style"] = attrs.borderStyle;
|
|
@@ -134,6 +155,8 @@ const ImageExtension = createNodeExtension({
|
|
|
134
155
|
}
|
|
135
156
|
if (attrs.transform) styles.push(`transform: ${attrs.transform}`);
|
|
136
157
|
if (attrs.opacity != null && attrs.opacity < 1) styles.push(`opacity: ${Math.max(0, attrs.opacity)}`);
|
|
158
|
+
const luminanceFilter = imageLuminanceFilter(attrs);
|
|
159
|
+
if (luminanceFilter !== void 0) styles.push(`filter: ${luminanceFilter}`);
|
|
137
160
|
if (attrs.borderWidth && attrs.borderWidth > 0) {
|
|
138
161
|
const bStyle = attrs.borderStyle || "solid";
|
|
139
162
|
const bColor = attrs.borderColor || "#000000";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NodeExtension } from "../types.js";
|
|
2
|
+
//#region src/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts
|
|
3
|
+
/** Hidden boundary for one non-empty tracked-move range. */
|
|
4
|
+
type MoveRangeBoundaryOptions = {
|
|
5
|
+
getInternalClipboardToken?: () => string;
|
|
6
|
+
};
|
|
7
|
+
declare const MOVE_RANGE_BOUNDARY_NODE_NAME = "moveRangeBoundary";
|
|
8
|
+
declare const MOVE_RANGE_BOUNDARY_DOM_ATTRIBUTE = "data-docx-move-range-boundary";
|
|
9
|
+
declare const MoveRangeBoundaryExtension: (options?: Partial<MoveRangeBoundaryOptions> | undefined) => NodeExtension;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { MOVE_RANGE_BOUNDARY_DOM_ATTRIBUTE, MOVE_RANGE_BOUNDARY_NODE_NAME, MoveRangeBoundaryExtension };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { expectMoveRangeBoundaryAttrs, readMoveRangeMarker } from "../../moveRangeBoundaryAttrs.js";
|
|
2
|
+
import { createNodeExtension } from "../create.js";
|
|
3
|
+
//#region src/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.ts
|
|
4
|
+
/** Hidden boundary for one non-empty tracked-move range. */
|
|
5
|
+
const MOVE_RANGE_BOUNDARY_NODE_NAME = "moveRangeBoundary";
|
|
6
|
+
const MOVE_RANGE_BOUNDARY_DOM_ATTRIBUTE = "data-docx-move-range-boundary";
|
|
7
|
+
const MoveRangeBoundaryExtension = createNodeExtension({
|
|
8
|
+
name: MOVE_RANGE_BOUNDARY_NODE_NAME,
|
|
9
|
+
schemaNodeName: MOVE_RANGE_BOUNDARY_NODE_NAME,
|
|
10
|
+
nodeSpec: (options) => ({
|
|
11
|
+
inline: true,
|
|
12
|
+
group: "inline",
|
|
13
|
+
marks: "_",
|
|
14
|
+
atom: true,
|
|
15
|
+
selectable: false,
|
|
16
|
+
attrs: { marker: {} },
|
|
17
|
+
parseDOM: [{
|
|
18
|
+
tag: `span[${MOVE_RANGE_BOUNDARY_DOM_ATTRIBUTE}]`,
|
|
19
|
+
getAttrs(dom) {
|
|
20
|
+
const raw = dom.getAttribute(MOVE_RANGE_BOUNDARY_DOM_ATTRIBUTE);
|
|
21
|
+
if (raw === null) return false;
|
|
22
|
+
try {
|
|
23
|
+
const result = readMoveRangeMarker(JSON.parse(raw));
|
|
24
|
+
return result.ok ? { marker: result.value } : false;
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}],
|
|
30
|
+
toDOM(node) {
|
|
31
|
+
const marker = expectMoveRangeBoundaryAttrs(node);
|
|
32
|
+
return ["span", {
|
|
33
|
+
[MOVE_RANGE_BOUNDARY_DOM_ATTRIBUTE]: JSON.stringify(marker),
|
|
34
|
+
"aria-hidden": "true",
|
|
35
|
+
contenteditable: "false",
|
|
36
|
+
style: "display: none;",
|
|
37
|
+
...options.getInternalClipboardToken ? { "data-docx-internal-clipboard": options.getInternalClipboardToken() } : {}
|
|
38
|
+
}];
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
//#endregion
|
|
43
|
+
export { MOVE_RANGE_BOUNDARY_DOM_ATTRIBUTE, MOVE_RANGE_BOUNDARY_NODE_NAME, MoveRangeBoundaryExtension };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { NodeExtension } from "../types.js";
|
|
2
|
+
//#region src/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* A zero-width block for markup folio keeps opaquely between two blocks.
|
|
5
|
+
*
|
|
6
|
+
* The block-level twin of the `preservedXml` inline atom. A `w:permStart`
|
|
7
|
+
* between two paragraphs, an `m:oMathPara`, a `w:altChunk`, a comment or move
|
|
8
|
+
* range that opens between blocks: the editor has no model for any of it and
|
|
9
|
+
* does not need one, because it only has to not lose it. So the node renders
|
|
10
|
+
* nothing, takes no selection and holds no text.
|
|
11
|
+
*
|
|
12
|
+
* **Position is structure, not an attribute.** The node sits between the same
|
|
13
|
+
* two blocks it sat between in the source, and ProseMirror's own mapping keeps
|
|
14
|
+
* it there: inserting, splitting or deleting a neighbour moves the markup the
|
|
15
|
+
* way a reader would expect, and nothing has to keep an index honest. The
|
|
16
|
+
* alternative — an index into the container recorded on the node — drifts the
|
|
17
|
+
* first time anything around it changes, and a drifting index is how markup
|
|
18
|
+
* ends up in the wrong place rather than merely lost.
|
|
19
|
+
*
|
|
20
|
+
* Deleting a *neighbour* therefore leaves the markup attached to whatever now
|
|
21
|
+
* follows it; only a selection that covers the node itself removes it, which
|
|
22
|
+
* is the same rule the editor applies to every other block.
|
|
23
|
+
*
|
|
24
|
+
* The integrity plugin removes a node that can never write markup back: bad
|
|
25
|
+
* attributes, or an empty payload left by a paste through the DOM. Keeping one
|
|
26
|
+
* would leave a zero-width block in the document that serializes to nothing.
|
|
27
|
+
*/
|
|
28
|
+
/** The node name, for callers asking what a container holds. */
|
|
29
|
+
declare const PRESERVED_BLOCK_NODE_NAME = "preservedBlock";
|
|
30
|
+
declare const PreservedBlockExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtension;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { PRESERVED_BLOCK_NODE_NAME, PreservedBlockExtension };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { expectPreservedBlockAttrs, readPreservedBlockAttrs } from "../../attrs/index.js";
|
|
2
|
+
import { createNodeExtension } from "../create.js";
|
|
3
|
+
import { Plugin } from "prosemirror-state";
|
|
4
|
+
//#region src/prosemirror/extensions/nodes/PreservedBlockExtension.ts
|
|
5
|
+
/** The node name, for callers asking what a container holds. */
|
|
6
|
+
const PRESERVED_BLOCK_NODE_NAME = "preservedBlock";
|
|
7
|
+
/**
|
|
8
|
+
* A node that can never write markup back.
|
|
9
|
+
*
|
|
10
|
+
* Either the attributes do not read at all, or `xml` is empty: a copy that
|
|
11
|
+
* came back from a paste with its payload stripped. Keeping one would put a
|
|
12
|
+
* zero-width block in the document that serializes to nothing, so the plugin
|
|
13
|
+
* removes it rather than letting it ride along.
|
|
14
|
+
*/
|
|
15
|
+
const isUnwritable = (node) => {
|
|
16
|
+
const attrs = readPreservedBlockAttrs(node);
|
|
17
|
+
return !attrs.ok || attrs.value.xml === "";
|
|
18
|
+
};
|
|
19
|
+
const collectUnwritableBlocks = (doc) => {
|
|
20
|
+
const unwritable = [];
|
|
21
|
+
doc.descendants((node, position) => {
|
|
22
|
+
if (node.type.name !== "preservedBlock") return true;
|
|
23
|
+
if (isUnwritable(node)) unwritable.push({
|
|
24
|
+
position,
|
|
25
|
+
node
|
|
26
|
+
});
|
|
27
|
+
return false;
|
|
28
|
+
});
|
|
29
|
+
return unwritable;
|
|
30
|
+
};
|
|
31
|
+
const PreservedBlockExtension = createNodeExtension({
|
|
32
|
+
name: PRESERVED_BLOCK_NODE_NAME,
|
|
33
|
+
schemaNodeName: PRESERVED_BLOCK_NODE_NAME,
|
|
34
|
+
nodeSpec: {
|
|
35
|
+
group: "block",
|
|
36
|
+
atom: true,
|
|
37
|
+
selectable: false,
|
|
38
|
+
attrs: { xml: {} },
|
|
39
|
+
parseDOM: [{
|
|
40
|
+
tag: "div[data-docx-preserved-block]",
|
|
41
|
+
getAttrs(dom) {
|
|
42
|
+
if (!(dom instanceof HTMLElement)) return false;
|
|
43
|
+
const xml = dom.dataset["docxPreservedBlock"];
|
|
44
|
+
return xml === void 0 || xml === "" ? false : { xml };
|
|
45
|
+
}
|
|
46
|
+
}],
|
|
47
|
+
toDOM(node) {
|
|
48
|
+
const { xml } = expectPreservedBlockAttrs(node);
|
|
49
|
+
return ["div", {
|
|
50
|
+
"data-docx-preserved-block": xml,
|
|
51
|
+
"aria-hidden": "true",
|
|
52
|
+
contenteditable: "false",
|
|
53
|
+
style: "display: none;"
|
|
54
|
+
}];
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
onSchemaReady: () => ({ plugins: [new Plugin({ appendTransaction(transactions, _oldState, newState) {
|
|
58
|
+
if (!transactions.some(({ docChanged }) => docChanged)) return null;
|
|
59
|
+
const unwritable = collectUnwritableBlocks(newState.doc);
|
|
60
|
+
if (unwritable.length === 0) return null;
|
|
61
|
+
const transaction = newState.tr;
|
|
62
|
+
for (const { node, position } of unwritable.toSorted((first, second) => second.position - first.position)) transaction.delete(position, position + node.nodeSize);
|
|
63
|
+
return transaction;
|
|
64
|
+
} })] })
|
|
65
|
+
});
|
|
66
|
+
//#endregion
|
|
67
|
+
export { PRESERVED_BLOCK_NODE_NAME, PreservedBlockExtension };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NodeExtension } from "../types.js";
|
|
2
|
+
//#region src/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* An opaque inline atom for a run child folio does not model.
|
|
5
|
+
*
|
|
6
|
+
* The editor cannot edit markup it has no model for, and it does not have to:
|
|
7
|
+
* it only has to not lose it. The node carries the captured bytes untouched
|
|
8
|
+
* and shows the visible text the markup puts on the line (`w:ruby` renders its
|
|
9
|
+
* `w:rubyBase` there), so the round trip keeps both the document's text and
|
|
10
|
+
* the document's markup.
|
|
11
|
+
*/
|
|
12
|
+
/** The node name, for callers asking what a paragraph holds. */
|
|
13
|
+
declare const PRESERVED_XML_NODE_NAME = "preservedXml";
|
|
14
|
+
declare const PreservedXmlExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtension;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { PRESERVED_XML_NODE_NAME, PreservedXmlExtension };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { expectPreservedXmlAttrs } from "../../attrs/index.js";
|
|
2
|
+
import { PRESERVED_XML_LEVELS } from "../../schema/nodes.js";
|
|
3
|
+
import { createNodeExtension } from "../create.js";
|
|
4
|
+
//#region src/prosemirror/extensions/nodes/PreservedXmlExtension.ts
|
|
5
|
+
/**
|
|
6
|
+
* An opaque inline atom for a run child folio does not model.
|
|
7
|
+
*
|
|
8
|
+
* The editor cannot edit markup it has no model for, and it does not have to:
|
|
9
|
+
* it only has to not lose it. The node carries the captured bytes untouched
|
|
10
|
+
* and shows the visible text the markup puts on the line (`w:ruby` renders its
|
|
11
|
+
* `w:rubyBase` there), so the round trip keeps both the document's text and
|
|
12
|
+
* the document's markup.
|
|
13
|
+
*/
|
|
14
|
+
/** The node name, for callers asking what a paragraph holds. */
|
|
15
|
+
const PRESERVED_XML_NODE_NAME = "preservedXml";
|
|
16
|
+
const PreservedXmlExtension = createNodeExtension({
|
|
17
|
+
name: PRESERVED_XML_NODE_NAME,
|
|
18
|
+
schemaNodeName: PRESERVED_XML_NODE_NAME,
|
|
19
|
+
nodeSpec: {
|
|
20
|
+
inline: true,
|
|
21
|
+
group: "inline",
|
|
22
|
+
atom: true,
|
|
23
|
+
marks: "_",
|
|
24
|
+
selectable: false,
|
|
25
|
+
attrs: {
|
|
26
|
+
xml: {},
|
|
27
|
+
text: { default: "" },
|
|
28
|
+
level: { default: PRESERVED_XML_LEVELS.run }
|
|
29
|
+
},
|
|
30
|
+
parseDOM: [{
|
|
31
|
+
tag: "span[data-docx-preserved-xml]",
|
|
32
|
+
getAttrs(node) {
|
|
33
|
+
if (!(node instanceof HTMLElement)) return false;
|
|
34
|
+
const xml = node.dataset["docxPreservedXml"];
|
|
35
|
+
if (xml === void 0 || xml === "") return false;
|
|
36
|
+
const level = node.dataset["docxPreservedLevel"] === PRESERVED_XML_LEVELS.inline ? PRESERVED_XML_LEVELS.inline : PRESERVED_XML_LEVELS.run;
|
|
37
|
+
return {
|
|
38
|
+
xml,
|
|
39
|
+
text: node.dataset["docxPreservedText"] ?? "",
|
|
40
|
+
level
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}],
|
|
44
|
+
toDOM(node) {
|
|
45
|
+
const { xml, text, level } = expectPreservedXmlAttrs(node);
|
|
46
|
+
return [
|
|
47
|
+
"span",
|
|
48
|
+
{
|
|
49
|
+
"data-docx-preserved-xml": xml,
|
|
50
|
+
"data-docx-preserved-level": level,
|
|
51
|
+
...text === "" ? {} : { "data-docx-preserved-text": text },
|
|
52
|
+
contenteditable: "false"
|
|
53
|
+
},
|
|
54
|
+
text
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
//#endregion
|
|
60
|
+
export { PRESERVED_XML_NODE_NAME, PreservedXmlExtension };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NodeExtension } from "../types.js";
|
|
2
|
+
//#region src/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts
|
|
3
|
+
/** Zero-width comment or tracked-move range that spans no content. */
|
|
4
|
+
type RangeAnchorOptions = {
|
|
5
|
+
getInternalClipboardToken?: () => string;
|
|
6
|
+
};
|
|
7
|
+
/** The node name, for callers asking whether a paragraph holds any content. */
|
|
8
|
+
declare const RANGE_ANCHOR_NODE_NAME = "rangeAnchor";
|
|
9
|
+
/** The attribute the DOM spelling carries both markers in. */
|
|
10
|
+
declare const RANGE_ANCHOR_DOM_ATTRIBUTE = "data-docx-range-anchor";
|
|
11
|
+
declare const RangeAnchorExtension: (options?: Partial<RangeAnchorOptions> | undefined) => NodeExtension;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { RANGE_ANCHOR_DOM_ATTRIBUTE, RANGE_ANCHOR_NODE_NAME, RangeAnchorExtension };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { readRangeAnchorAttrs, readRangeAnchorValues } from "../../rangeAnchorAttrs.js";
|
|
2
|
+
import { createNodeExtension } from "../create.js";
|
|
3
|
+
//#region src/prosemirror/extensions/nodes/RangeAnchorExtension.ts
|
|
4
|
+
/** Zero-width comment or tracked-move range that spans no content. */
|
|
5
|
+
/** The node name, for callers asking whether a paragraph holds any content. */
|
|
6
|
+
const RANGE_ANCHOR_NODE_NAME = "rangeAnchor";
|
|
7
|
+
/** The attribute the DOM spelling carries both markers in. */
|
|
8
|
+
const RANGE_ANCHOR_DOM_ATTRIBUTE = "data-docx-range-anchor";
|
|
9
|
+
const RangeAnchorExtension = createNodeExtension({
|
|
10
|
+
name: RANGE_ANCHOR_NODE_NAME,
|
|
11
|
+
schemaNodeName: RANGE_ANCHOR_NODE_NAME,
|
|
12
|
+
nodeSpec: (options) => ({
|
|
13
|
+
inline: true,
|
|
14
|
+
group: "inline",
|
|
15
|
+
marks: "_",
|
|
16
|
+
atom: true,
|
|
17
|
+
selectable: false,
|
|
18
|
+
attrs: {
|
|
19
|
+
start: {},
|
|
20
|
+
end: {}
|
|
21
|
+
},
|
|
22
|
+
parseDOM: [{
|
|
23
|
+
tag: `span[${RANGE_ANCHOR_DOM_ATTRIBUTE}]`,
|
|
24
|
+
getAttrs(dom) {
|
|
25
|
+
const raw = dom.getAttribute(RANGE_ANCHOR_DOM_ATTRIBUTE);
|
|
26
|
+
if (raw === null) return false;
|
|
27
|
+
const parsed = parseMarkers(raw);
|
|
28
|
+
if (parsed === null) return false;
|
|
29
|
+
const result = readRangeAnchorValues(parsed.start, parsed.end);
|
|
30
|
+
return result.ok ? result.value : false;
|
|
31
|
+
}
|
|
32
|
+
}],
|
|
33
|
+
toDOM(node) {
|
|
34
|
+
const attrs = readRangeAnchorAttrs(node);
|
|
35
|
+
return ["span", {
|
|
36
|
+
[RANGE_ANCHOR_DOM_ATTRIBUTE]: attrs.ok ? JSON.stringify(attrs.value) : "",
|
|
37
|
+
"aria-hidden": "true",
|
|
38
|
+
contenteditable: "false",
|
|
39
|
+
style: "display: none;",
|
|
40
|
+
...options.getInternalClipboardToken ? { "data-docx-internal-clipboard": options.getInternalClipboardToken() } : {}
|
|
41
|
+
}];
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* The attribute back as an attrs bag, or `null` when it is not one.
|
|
47
|
+
*
|
|
48
|
+
* `JSON.parse` throws on malformed input reaching the schema from a paste, and
|
|
49
|
+
* a parser branch that refuses the node is the boundary this belongs at.
|
|
50
|
+
*/
|
|
51
|
+
const parseMarkers = (raw) => {
|
|
52
|
+
try {
|
|
53
|
+
const parsed = JSON.parse(raw);
|
|
54
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
55
|
+
if (!("start" in parsed) || !("end" in parsed)) return null;
|
|
56
|
+
return {
|
|
57
|
+
start: parsed.start,
|
|
58
|
+
end: parsed.end
|
|
59
|
+
};
|
|
60
|
+
} catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { RANGE_ANCHOR_DOM_ATTRIBUTE, RANGE_ANCHOR_NODE_NAME, RangeAnchorExtension };
|