@stll/folio-core 0.66.2 → 0.68.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.d.ts +9 -1
- package/dist/ai-edits/apply.js +138 -17
- package/dist/ai-edits/batch-claims.js +5 -3
- package/dist/ai-edits/clean-text.js +4 -1
- package/dist/ai-edits/headless.d.ts +36 -21
- package/dist/ai-edits/headless.js +104 -34
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/note-references.d.ts +6 -0
- package/dist/ai-edits/note-references.js +7 -1
- package/dist/ai-edits/read.d.ts +19 -0
- package/dist/ai-edits/read.js +6 -4
- package/dist/ai-edits/snapshot.d.ts +6 -0
- package/dist/ai-edits/snapshot.js +32 -17
- package/dist/ai-edits/table-cell-mutations.js +3 -2
- package/dist/ai-edits/table-row-column-mutations.js +20 -6
- package/dist/ai-edits/types.d.ts +9 -1
- package/dist/ai-suggestions/apply.js +13 -4
- package/dist/compare/compare.js +2 -1
- package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
- package/dist/compare/inserted-resource-snapshot.js +7 -3
- package/dist/controller/canonicalClipboard.js +29 -12
- package/dist/controller/canonicalComposition.d.ts +1 -1
- package/dist/controller/canonicalComposition.js +77 -19
- package/dist/controller/canonicalInlineProjection.d.ts +35 -10
- package/dist/controller/canonicalInlineProjection.js +192 -28
- package/dist/controller/canonicalInput.d.ts +2 -2
- package/dist/controller/canonicalInput.js +47 -2
- package/dist/controller/canonicalListRendering.d.ts +2 -1
- package/dist/controller/canonicalListRendering.js +1 -1
- package/dist/controller/canonicalLockGuard.d.ts +8 -0
- package/dist/controller/canonicalLockGuard.js +88 -0
- package/dist/controller/canonicalPublicOperations.d.ts +12 -4
- package/dist/controller/canonicalPublicOperations.js +274 -20
- package/dist/controller/canonicalSession.d.ts +87 -7
- package/dist/controller/canonicalSession.js +328 -75
- package/dist/controller/canonicalStoryEditor.d.ts +3 -2
- package/dist/controller/canonicalStoryEditor.js +4 -3
- package/dist/controller/canonicalStructure.d.ts +2 -1
- package/dist/controller/canonicalStructure.js +129 -7
- package/dist/controller/contentControlWidgetController.d.ts +5 -0
- package/dist/controller/contentControlWidgetController.js +13 -1
- package/dist/controller/folioEditor.js +1 -0
- package/dist/controller/headerFooterEditorManager.d.ts +2 -2
- package/dist/controller/headerFooterEditorManager.js +5 -5
- package/dist/controller/hiddenEditorApi.d.ts +6 -0
- package/dist/controller/hiddenEditorApi.js +1 -0
- package/dist/controller/hiddenEditorManager.d.ts +10 -3
- package/dist/controller/hiddenEditorManager.js +94 -38
- package/dist/controller/layoutPipeline.d.ts +2 -0
- package/dist/controller/layoutPipeline.js +55 -18
- package/dist/controller/layoutSession.d.ts +1 -0
- package/dist/controller/noteEditorManager.d.ts +2 -2
- package/dist/controller/noteEditorManager.js +5 -5
- package/dist/display-list/build/pageFurniture.js +41 -19
- package/dist/display-list/build/tablePrimitives.d.ts +3 -1
- package/dist/display-list/build/tablePrimitives.js +49 -14
- package/dist/display-list/dom/renderDisplayListToDom.js +4 -4
- package/dist/document-operations.d.ts +8 -0
- package/dist/document-operations.js +4 -3
- package/dist/docx/blockContentParser.d.ts +7 -3
- package/dist/docx/blockContentParser.js +2 -3
- package/dist/docx/blockPlainText.js +2 -0
- package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
- package/dist/docx/bookmarkRangeJoin.js +43 -0
- package/dist/docx/canonicalSave.js +5 -1
- package/dist/docx/canonicalSessionInput.d.ts +5 -1
- package/dist/docx/canonicalSessionInput.js +7 -2
- package/dist/docx/chartPreview.d.ts +4 -1
- package/dist/docx/chartPreview.js +26 -15
- package/dist/docx/commentAnchorIndex.d.ts +21 -5
- package/dist/docx/commentAnchorIndex.js +39 -11
- package/dist/docx/commentRangeIntegrity.js +30 -24
- package/dist/docx/commentRangeJoin.d.ts +4 -0
- package/dist/docx/commentRangeJoin.js +26 -12
- package/dist/docx/commentReferenceCompletion.js +5 -4
- package/dist/docx/commentReferenceNormalization.js +40 -18
- package/dist/docx/compatibility.js +9 -2
- package/dist/docx/containerChildren.js +22 -1
- package/dist/docx/encryption/compoundFile.js +9 -1
- package/dist/docx/encryption/encryptionInfo.js +16 -2
- package/dist/docx/ensureParaIds.js +46 -7
- package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
- package/dist/docx/ensureUniqueControlIds.js +110 -0
- package/dist/docx/headerFooterVerbatim.d.ts +7 -0
- package/dist/docx/headerFooterVerbatim.js +13 -2
- package/dist/docx/hostCommentThreads.d.ts +17 -0
- package/dist/docx/hostCommentThreads.js +49 -0
- package/dist/docx/hyperlinkParser.js +9 -2
- package/dist/docx/inlineWrapperContent.d.ts +8 -1
- package/dist/docx/inlineWrapperContent.js +9 -2
- package/dist/docx/listMarkerComputation.d.ts +35 -1
- package/dist/docx/listMarkerComputation.js +39 -1
- package/dist/docx/listModelNormalization.d.ts +44 -1
- package/dist/docx/listModelNormalization.js +227 -96
- package/dist/docx/mainDocumentPart.d.ts +6 -0
- package/dist/docx/mainDocumentPart.js +65 -0
- package/dist/docx/markupRangeMarker.d.ts +14 -0
- package/dist/docx/markupRangeMarker.js +15 -1
- package/dist/docx/metadataPrivacy.js +43 -22
- package/dist/docx/normalizeBaseDirection.js +3 -1
- package/dist/docx/packageParts.d.ts +1 -1
- package/dist/docx/packageParts.js +10 -4
- package/dist/docx/paragraphParser.js +159 -48
- package/dist/docx/paragraphPropertySource.d.ts +7 -0
- package/dist/docx/paragraphPropertySource.js +22 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
- package/dist/docx/paragraphTraversal.js +2 -0
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +6 -0
- package/dist/docx/previewBudget.d.ts +6 -0
- package/dist/docx/previewBudget.js +7 -1
- package/dist/docx/renderedPageBreakNormalization.js +1 -1
- package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
- package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
- package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
- package/dist/docx/reviewResolutionProvenance.js +110 -25
- package/dist/docx/rezip.d.ts +6 -0
- package/dist/docx/rezip.js +42 -25
- package/dist/docx/selectiveSave.js +6 -10
- package/dist/docx/selectiveXmlPatch.d.ts +5 -4
- package/dist/docx/selectiveXmlPatch.js +11 -7
- package/dist/docx/serializer/documentSerializer.js +3 -1
- package/dist/docx/serializer/headerFooterSerializer.js +3 -1
- package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
- package/dist/docx/serializer/markupRangeAttributes.js +6 -1
- package/dist/docx/serializer/noteSerializer.d.ts +17 -4
- package/dist/docx/serializer/noteSerializer.js +23 -16
- package/dist/docx/serializer/paragraphSerializer.js +56 -12
- package/dist/docx/serializer/runSerializer.d.ts +1 -3
- package/dist/docx/serializer/runSerializer.js +2 -2
- package/dist/docx/serializer/tableSerializer.d.ts +4 -0
- package/dist/docx/serializer/tableSerializer.js +4 -2
- package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
- package/dist/docx/server/createBilingualDocument.js +27 -5
- package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
- package/dist/docx/sessionListPruning.d.ts +2 -0
- package/dist/docx/sessionListPruning.js +50 -0
- package/dist/docx/shapeAlternateContent.js +19 -0
- package/dist/docx/splitRevisionPieces.d.ts +10 -0
- package/dist/docx/splitRevisionPieces.js +14 -0
- package/dist/docx/storyBlockReplay.js +4 -0
- package/dist/docx/structuralXmlPatch.js +19 -7
- package/dist/docx/tableParser.d.ts +6 -2
- package/dist/docx/tableParser.js +2 -3
- package/dist/docx/textBoxContentParser.d.ts +11 -0
- package/dist/docx/textBoxContentParser.js +51 -0
- package/dist/docx/textBoxParser.d.ts +0 -5
- package/dist/docx/textBoxParser.js +1 -23
- package/dist/docx/unzip.js +2 -0
- package/dist/docx/verticalMergeProjection.js +1 -1
- package/dist/fonts/fontsourceFaces.d.ts +2 -8
- package/dist/fonts/fontsourceFaces.js +1 -7
- package/dist/i18n/messages/ar.gen.js +3 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +51 -0
- package/dist/i18n/messages/catalogs.gen.js +51 -0
- package/dist/i18n/messages/cs.gen.js +3 -0
- package/dist/i18n/messages/de.gen.js +3 -0
- package/dist/i18n/messages/en.gen.js +3 -0
- package/dist/i18n/messages/es.gen.js +3 -0
- package/dist/i18n/messages/et.gen.js +3 -0
- package/dist/i18n/messages/fr.gen.js +3 -0
- package/dist/i18n/messages/he.gen.js +3 -0
- package/dist/i18n/messages/hi.gen.js +3 -0
- package/dist/i18n/messages/hu.gen.js +3 -0
- package/dist/i18n/messages/lt.gen.js +3 -0
- package/dist/i18n/messages/lv.gen.js +3 -0
- package/dist/i18n/messages/messages.gen.d.ts +3 -0
- package/dist/i18n/messages/pl.gen.js +3 -0
- package/dist/i18n/messages/pt-BR.gen.js +3 -0
- package/dist/i18n/messages/sk.gen.js +3 -0
- package/dist/i18n/messages/tr.gen.js +3 -0
- package/dist/i18n/messages/zh-CN.gen.js +3 -0
- package/dist/internal/acceptedBlockProjection.js +2 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
- package/dist/internal/revisionResolutionInline.js +1 -2
- package/dist/internal/wholeStoryRevisionResolution.js +57 -12
- package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +10 -0
- package/dist/layout-bridge/convert/altChunkPlaceholder.js +70 -0
- package/dist/layout-bridge/convert/fixedTableColumnWidths.js +2 -1
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +10 -0
- package/dist/layout-bridge/convert/flowConversionShared.js +11 -1
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +4 -1
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
- package/dist/layout-bridge/convert/tableConversion.js +25 -10
- package/dist/layout-bridge/convert/toFlowBlocks.js +4 -0
- package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
- package/dist/layout-bridge/engine/blockIndex.js +12 -0
- package/dist/layout-bridge/engine/clickToPosition.js +5 -1
- package/dist/layout-bridge/engine/hitTest.js +9 -10
- package/dist/layout-bridge/engine/selectionRects.js +6 -6
- package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
- package/dist/layout-engine/footnoteContinuation.js +210 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +7 -2
- package/dist/layout-engine/measure/cache.js +10 -5
- package/dist/layout-engine/measure/measureParagraph.js +1 -1
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +1 -0
- package/dist/layout-engine/measure/tableVisibleBand.d.ts +16 -0
- package/dist/layout-engine/measure/tableVisibleBand.js +28 -0
- package/dist/layout-engine/tableLayout.js +34 -7
- package/dist/layout-engine/tableRowBreak.d.ts +46 -0
- package/dist/layout-engine/tableRowBreak.js +193 -36
- package/dist/layout-engine/types.d.ts +43 -3
- package/dist/layout-painter/previewSvg.d.ts +8 -0
- package/dist/layout-painter/previewSvg.js +47 -0
- package/dist/layout-painter/renderImage.js +2 -1
- package/dist/layout-painter/renderPage.d.ts +5 -4
- package/dist/layout-painter/renderPage.js +52 -20
- package/dist/layout-painter/renderParagraph.js +3 -2
- package/dist/layout-painter/renderTable.d.ts +5 -2
- package/dist/layout-painter/renderTable.js +39 -22
- package/dist/managers/AutoSaveManager.d.ts +5 -1
- package/dist/managers/FindReplaceManager.js +3 -10
- package/dist/markdown/escape.d.ts +20 -1
- package/dist/markdown/escape.js +43 -1
- package/dist/markdown/renderBlock.js +4 -1
- package/dist/markdown/renderParagraph.js +13 -27
- package/dist/markdown/renderTable.js +6 -2
- package/dist/markdown/trailers.js +1 -0
- package/dist/pdf/images.d.ts +17 -1
- package/dist/pdf/images.js +22 -4
- package/dist/pdf/writePdf.js +4 -2
- package/dist/prosemirror/anchoredTextBoxes.d.ts +2 -1
- package/dist/prosemirror/attrs/index.js +1 -0
- package/dist/prosemirror/canonicalCommands.d.ts +39 -1
- package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
- package/dist/prosemirror/canonicalTableCommands.js +362 -0
- package/dist/prosemirror/commands/comments.d.ts +25 -0
- package/dist/prosemirror/commands/comments.js +122 -18
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.d.ts +9 -0
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.js +36 -0
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +1 -1
- package/dist/prosemirror/commands/pastePlainText.d.ts +6 -0
- package/dist/prosemirror/commands/pastePlainText.js +13 -3
- package/dist/prosemirror/commands/resolveAllTableChanges.js +30 -2
- package/dist/prosemirror/commentIdAllocator.js +2 -2
- package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
- package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +8 -2
- package/dist/prosemirror/commentReferenceIntegrity.js +22 -8
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +115 -35
- package/dist/prosemirror/conversion/index.d.ts +1 -1
- package/dist/prosemirror/conversion/toProseDoc.d.ts +128 -1
- package/dist/prosemirror/conversion/toProseDoc.js +325 -55
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -9
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +46 -11
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +22 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
- package/dist/prosemirror/extensions/marks/CommentExtension.js +6 -3
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +5 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +8 -4
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -1
- package/dist/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +4 -3
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +119 -38
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.js +21 -0
- package/dist/prosemirror/index.d.ts +2 -2
- package/dist/prosemirror/listLabels.js +3 -2
- package/dist/prosemirror/listNumbering.d.ts +6 -0
- package/dist/prosemirror/listNumbering.js +12 -9
- package/dist/prosemirror/lockedControls.d.ts +13 -0
- package/dist/prosemirror/lockedControls.js +106 -0
- package/dist/prosemirror/markupViewProjection.js +1 -1
- package/dist/prosemirror/noteReferenceReview.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +4 -1
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -8
- package/dist/prosemirror/plugins/suggestionMode.js +195 -30
- package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
- package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -0
- package/dist/prosemirror/rowGridOmissions.d.ts +11 -0
- package/dist/prosemirror/rowGridOmissions.js +21 -0
- package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
- package/dist/prosemirror/runFormattingFromMarks.js +2 -4
- package/dist/prosemirror/runFormattingReconciliation.js +2 -2
- package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
- package/dist/prosemirror/runStyleFormatting.js +16 -13
- package/dist/prosemirror/schema/marks.d.ts +6 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
- package/dist/prosemirror/tableGridMutation.d.ts +19 -2
- package/dist/prosemirror/tableGridMutation.js +118 -15
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +2 -0
- package/dist/prosemirror/tablePositionedBookmarks.js +80 -0
- package/dist/prosemirror/validation.js +2 -1
- package/dist/redline.js +23 -9
- package/dist/server.d.ts +2 -2
- package/dist/style-sets/extract.js +2 -2
- package/dist/types/canonicalCapabilities.d.ts +29 -8
- package/dist/types/canonicalCapabilities.js +13 -9
- package/dist/utils/cssString.d.ts +7 -0
- package/dist/utils/cssString.js +9 -0
- package/dist/utils/fontResolver.js +4 -1
- package/dist/utils/replaceText.d.ts +11 -0
- package/dist/utils/replaceText.js +39 -7
- package/dist/version-comparison.d.ts +9 -1
- package/dist/version-comparison.js +11 -5
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@ import { resolveColorValueToHex } from "../../docx/drawingUtils.js";
|
|
|
3
3
|
import { isInlineSdtContent, isTrackedChangeWrapperChild } from "../../docx/inlineWrapperContent.js";
|
|
4
4
|
import { listRenderingDefinitionsMatch, resolveListRenderingDefinition } from "../../docx/listRendering.js";
|
|
5
5
|
import { getCachedNumberingMap } from "../../docx/numberingParser.js";
|
|
6
|
-
import { PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, createProseParagraphWithPropertySource, getDocumentParagraphPropertySourceContract, paragraphFormattingWithAuthoredIndentation, proseParagraphAttrsWithoutPropertySource, recreateProseNodeWithParagraphPropertySource, transportTableCellsWithParagraphPropertySources } from "../../docx/paragraphPropertySource.js";
|
|
6
|
+
import { PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, createProseParagraphWithPropertySource, getDocumentParagraphPropertySourceContract, paragraphFormattingWithAuthoredIndentation, paragraphPropertySourceState, proseParagraphAttrsWithoutPropertySource, recreateProseNodeWithParagraphPropertySource, transportTableCellsWithParagraphPropertySources } from "../../docx/paragraphPropertySource.js";
|
|
7
7
|
import { visitInlineContentSlots, visitInlineContentSlotsInContent } from "../../docx/paragraphTraversal.js";
|
|
8
8
|
import { isBaselineVertAlign } from "../../docx/runParser.js";
|
|
9
9
|
import { replayableShapeAlternateContent } from "../../docx/shapeAlternateContent.js";
|
|
@@ -30,6 +30,7 @@ import { withEnclosingRevision } from "../contentControlRevisions.js";
|
|
|
30
30
|
import { emptyFieldRunPropertyChanges } from "../emptyFieldResultRuns.js";
|
|
31
31
|
import { planEmptyRanges } from "../emptyRangeAnchor.js";
|
|
32
32
|
import { textFormattingToMarks } from "../extensions/marks/markUtils.js";
|
|
33
|
+
import { BLOCK_COMMENT_RANGE_BOUNDARY_NODE_NAME } from "../extensions/nodes/BlockCommentRangeBoundaryExtension.js";
|
|
33
34
|
import { BLOCK_MOVE_RANGE_BOUNDARY_NODE_NAME } from "../extensions/nodes/BlockMoveRangeBoundaryExtension.js";
|
|
34
35
|
import { COMMENT_RANGE_BOUNDARY_NODE_NAME } from "../extensions/nodes/CommentRangeBoundaryExtension.js";
|
|
35
36
|
import { MOVE_RANGE_BOUNDARY_NODE_NAME } from "../extensions/nodes/MoveRangeBoundaryExtension.js";
|
|
@@ -85,11 +86,10 @@ const pageBreakProjectionWarn = (warn) => warn === void 0 ? noPageBreakProjectio
|
|
|
85
86
|
* span carrying a guessed/copied id could collide with and hijack a real
|
|
86
87
|
* text box anchored in a completely different document.
|
|
87
88
|
*/
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
};
|
|
89
|
+
const newTextBoxGroupSalt = () => Math.random().toString(36).slice(2, 10);
|
|
90
|
+
/** Text-box group ids under one salt, counted from `counter`. */
|
|
91
|
+
const textBoxGroupIdsFrom = (salt, counter) => () => `${salt}:${counter.value++}`;
|
|
92
|
+
const createTextBoxGroupIdFactory = (salt = newTextBoxGroupSalt()) => textBoxGroupIdsFrom(salt, { value: 0 });
|
|
93
93
|
/**
|
|
94
94
|
* The identity mark for one authored `w:r`, or `null` when it carries nothing
|
|
95
95
|
* worth a mark.
|
|
@@ -144,6 +144,11 @@ const collectPairedBookmarkIds = (blocks) => {
|
|
|
144
144
|
position += 1;
|
|
145
145
|
counts.set(id, count);
|
|
146
146
|
};
|
|
147
|
+
const countMarkersWhere = (markers, stands) => {
|
|
148
|
+
for (const { index, marker } of markers ?? []) if (stands(index)) countBoundary(marker.id, marker.type === "bookmarkStart" ? "start" : "end");
|
|
149
|
+
};
|
|
150
|
+
const countMarkersAt = (markers, at) => countMarkersWhere(markers, (index) => index === at);
|
|
151
|
+
const countMarkersFrom = (markers, from) => countMarkersWhere(markers, (index) => index >= from);
|
|
147
152
|
const visitRun = (run) => {
|
|
148
153
|
for (const content of run.content) if (content.type === "shape" && content.shape.textBody) visitBlocks(content.shape.textBody.content);
|
|
149
154
|
};
|
|
@@ -167,7 +172,8 @@ const collectPairedBookmarkIds = (blocks) => {
|
|
|
167
172
|
break;
|
|
168
173
|
case "preservedInline": break;
|
|
169
174
|
case "inlineWrapper":
|
|
170
|
-
|
|
175
|
+
case "complexField":
|
|
176
|
+
visitParagraphContent(child);
|
|
171
177
|
break;
|
|
172
178
|
default: panic(`Unsupported hyperlink child: ${JSON.stringify(child)}`);
|
|
173
179
|
}
|
|
@@ -218,11 +224,15 @@ const collectPairedBookmarkIds = (blocks) => {
|
|
|
218
224
|
for (const content of block.content) visitParagraphContent(content);
|
|
219
225
|
break;
|
|
220
226
|
case "table":
|
|
221
|
-
for (const
|
|
222
|
-
|
|
223
|
-
for (const
|
|
224
|
-
|
|
227
|
+
for (const [rowIndex, row] of block.rows.entries()) {
|
|
228
|
+
countMarkersAt(block.bookmarks, rowIndex);
|
|
229
|
+
for (const [cellIndex, cell] of row.cells.entries()) {
|
|
230
|
+
countMarkersAt(row.bookmarks, cellIndex);
|
|
231
|
+
visitBlocks(cell.content);
|
|
232
|
+
}
|
|
233
|
+
countMarkersFrom(row.bookmarks, row.cells.length);
|
|
225
234
|
}
|
|
235
|
+
countMarkersFrom(block.bookmarks, block.rows.length);
|
|
226
236
|
break;
|
|
227
237
|
case "blockSdt":
|
|
228
238
|
case "blockCustomXml":
|
|
@@ -235,6 +245,8 @@ const collectPairedBookmarkIds = (blocks) => {
|
|
|
235
245
|
case "bookmarkEnd":
|
|
236
246
|
countBoundary(block.id, "end");
|
|
237
247
|
break;
|
|
248
|
+
case "commentRangeStart":
|
|
249
|
+
case "commentRangeEnd":
|
|
238
250
|
case "moveFromRangeStart":
|
|
239
251
|
case "moveFromRangeEnd":
|
|
240
252
|
case "moveToRangeStart":
|
|
@@ -245,6 +257,143 @@ const collectPairedBookmarkIds = (blocks) => {
|
|
|
245
257
|
visitBlocks(blocks);
|
|
246
258
|
return new Set([...counts].flatMap(([id, count]) => count.starts === 1 && count.ends === 1 && count.firstStart !== void 0 && count.firstEnd !== void 0 && count.firstStart < count.firstEnd ? [id] : []));
|
|
247
259
|
};
|
|
260
|
+
/** A membership whose answers a block's conversion read, recorded to check later. */
|
|
261
|
+
var RecordedMembership = class {
|
|
262
|
+
answers = /* @__PURE__ */ new Map();
|
|
263
|
+
source;
|
|
264
|
+
constructor(source) {
|
|
265
|
+
this.source = source;
|
|
266
|
+
}
|
|
267
|
+
has(value) {
|
|
268
|
+
const answer = this.source.has(value);
|
|
269
|
+
this.answers.set(value, answer);
|
|
270
|
+
return answer;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
const sameIds = (left, right) => left.length === right.length && left.every((value, index) => value === right[index]);
|
|
274
|
+
const setReadsHold = (reads, set) => {
|
|
275
|
+
for (const [value, answer] of reads.answers) if (set.has(value) !== answer) return false;
|
|
276
|
+
return true;
|
|
277
|
+
};
|
|
278
|
+
const storyReadsHold = (reads, state) => (!reads.textBoxGroups.used || reads.textBoxGroups.start === state.textBoxGroups.value) && (reads.hyperlinks.taken === 0 || reads.hyperlinks.start === state.hyperlinks.value) && (reads.noteOccurrences.taken === 0 || reads.noteOccurrences.start === state.noteOccurrences.value) && setReadsHold(reads.pairedBookmarkIds, state.pairedBookmarkIds) && setReadsHold(reads.storyRangedCommentIds, state.storyRangedCommentIds) && sameIds(reads.openCommentIds.start, [...state.openCommentIds]);
|
|
279
|
+
/** Advance the story past a block whose reads hold, as converting it would. */
|
|
280
|
+
const advanceStory = (reads, state) => {
|
|
281
|
+
state.textBoxGroups.value += reads.textBoxGroups.taken;
|
|
282
|
+
state.hyperlinks.value += reads.hyperlinks.taken;
|
|
283
|
+
state.noteOccurrences.value += reads.noteOccurrences.taken;
|
|
284
|
+
state.openCommentIds.clear();
|
|
285
|
+
for (const id of reads.openCommentIds.end) state.openCommentIds.add(id);
|
|
286
|
+
};
|
|
287
|
+
const setReadsOf = (set) => ({ answers: set.answers });
|
|
288
|
+
const sameState = (left, right) => left.length === right.length && left.every((value, index) => value === right[index]);
|
|
289
|
+
/**
|
|
290
|
+
* Converted blocks kept across projections of one story.
|
|
291
|
+
*
|
|
292
|
+
* A block is the same object in the next document when an edit left it, so
|
|
293
|
+
* its nodes can be reused where the story facts its conversion read are the
|
|
294
|
+
* same: the counters it drew from, the comments open at its start, and the
|
|
295
|
+
* bookmark and comment ids it asked about. The package inputs (styles,
|
|
296
|
+
* theme, numbering) are part of the cache: a projection over other ones
|
|
297
|
+
* starts the cache over.
|
|
298
|
+
*/
|
|
299
|
+
var ProjectionBlockCache = class {
|
|
300
|
+
salt = newTextBoxGroupSalt();
|
|
301
|
+
inputs;
|
|
302
|
+
context;
|
|
303
|
+
blocks = /* @__PURE__ */ new WeakMap();
|
|
304
|
+
/** The package context for these inputs, the cache started over if they changed. */
|
|
305
|
+
packageContext(inputs) {
|
|
306
|
+
const current = this.inputs;
|
|
307
|
+
if (this.context !== void 0 && current !== void 0 && current.styles === inputs.styles && current.theme === inputs.theme && current.numbering === inputs.numbering && current.warn === inputs.warn) return this.context;
|
|
308
|
+
this.inputs = inputs;
|
|
309
|
+
this.blocks = /* @__PURE__ */ new WeakMap();
|
|
310
|
+
this.context = {
|
|
311
|
+
styleResolver: createStyleEngine(inputs.styles),
|
|
312
|
+
listRenderings: /* @__PURE__ */ new Map(),
|
|
313
|
+
numbering: inputs.numbering === void 0 ? void 0 : getCachedNumberingMap(inputs.numbering),
|
|
314
|
+
theme: inputs.theme,
|
|
315
|
+
pageBreakRunSourceDescendants: buildPageBreakRunSourceDescendantIndex([]),
|
|
316
|
+
warnPageBreakProjection: pageBreakProjectionWarn(inputs.warn),
|
|
317
|
+
createMark: createMarkInterner(schema)
|
|
318
|
+
};
|
|
319
|
+
return this.context;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* The nodes of `paragraph` from the story state it starts at, reused when
|
|
323
|
+
* every story fact its last conversion read still holds, else converted.
|
|
324
|
+
*/
|
|
325
|
+
paragraph(paragraph, state, convert) {
|
|
326
|
+
const known = this.blocks.get(paragraph);
|
|
327
|
+
const sourceState = paragraphPropertySourceState(paragraph);
|
|
328
|
+
if (known !== void 0 && sameState(known.sourceState, sourceState) && storyReadsHold(known.reads, state)) {
|
|
329
|
+
advanceStory(known.reads, state);
|
|
330
|
+
return known.nodes;
|
|
331
|
+
}
|
|
332
|
+
const context = this.context ?? panic("A block cache converts after its package context");
|
|
333
|
+
const textBoxGroups = {
|
|
334
|
+
start: state.textBoxGroups.value,
|
|
335
|
+
taken: 0
|
|
336
|
+
};
|
|
337
|
+
const hyperlinks = {
|
|
338
|
+
start: state.hyperlinks.value,
|
|
339
|
+
taken: 0
|
|
340
|
+
};
|
|
341
|
+
const noteOccurrences = {
|
|
342
|
+
start: state.noteOccurrences.value,
|
|
343
|
+
taken: 0
|
|
344
|
+
};
|
|
345
|
+
const pairedBookmarkIds = new RecordedMembership(state.pairedBookmarkIds);
|
|
346
|
+
const storyRangedCommentIds = new RecordedMembership(state.storyRangedCommentIds);
|
|
347
|
+
const openStart = [...state.openCommentIds];
|
|
348
|
+
const story = {
|
|
349
|
+
nextTextBoxGroupId: () => {
|
|
350
|
+
textBoxGroups.taken += 1;
|
|
351
|
+
return `${this.salt}:${state.textBoxGroups.value++}`;
|
|
352
|
+
},
|
|
353
|
+
nextHyperlinkInstanceIndex: () => {
|
|
354
|
+
hyperlinks.taken += 1;
|
|
355
|
+
return state.hyperlinks.value++;
|
|
356
|
+
},
|
|
357
|
+
nextNoteReferenceOccurrenceId: () => {
|
|
358
|
+
noteOccurrences.taken += 1;
|
|
359
|
+
return `source-note:${state.noteOccurrences.value++}`;
|
|
360
|
+
},
|
|
361
|
+
pairedBookmarkIds,
|
|
362
|
+
storyRangedCommentIds,
|
|
363
|
+
openCommentIds: state.openCommentIds
|
|
364
|
+
};
|
|
365
|
+
const nodes = convert({
|
|
366
|
+
listRenderings: context.listRenderings,
|
|
367
|
+
numbering: context.numbering,
|
|
368
|
+
theme: context.theme,
|
|
369
|
+
pageBreakRunSourceDescendants: context.pageBreakRunSourceDescendants,
|
|
370
|
+
warnPageBreakProjection: context.warnPageBreakProjection,
|
|
371
|
+
createMark: context.createMark,
|
|
372
|
+
...story
|
|
373
|
+
}, story.nextTextBoxGroupId());
|
|
374
|
+
const saltMark = `"${this.salt}:`;
|
|
375
|
+
const reads = {
|
|
376
|
+
textBoxGroups: {
|
|
377
|
+
...textBoxGroups,
|
|
378
|
+
used: nodes.some((node) => JSON.stringify(node.toJSON()).includes(saltMark))
|
|
379
|
+
},
|
|
380
|
+
hyperlinks,
|
|
381
|
+
noteOccurrences,
|
|
382
|
+
pairedBookmarkIds: setReadsOf(pairedBookmarkIds),
|
|
383
|
+
storyRangedCommentIds: setReadsOf(storyRangedCommentIds),
|
|
384
|
+
openCommentIds: {
|
|
385
|
+
start: openStart,
|
|
386
|
+
end: [...state.openCommentIds]
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
this.blocks.set(paragraph, {
|
|
390
|
+
nodes,
|
|
391
|
+
reads,
|
|
392
|
+
sourceState: paragraphPropertySourceState(paragraph)
|
|
393
|
+
});
|
|
394
|
+
return nodes;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
248
397
|
/**
|
|
249
398
|
* Convert a Document to a ProseMirror document
|
|
250
399
|
*
|
|
@@ -254,34 +403,50 @@ const collectPairedBookmarkIds = (blocks) => {
|
|
|
254
403
|
function toProseDoc(document, options) {
|
|
255
404
|
const paragraphs = document.package.document.content;
|
|
256
405
|
const nodes = [];
|
|
257
|
-
const
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
406
|
+
const cache = options?.blockCache;
|
|
407
|
+
const packageInputs = {
|
|
408
|
+
styles: options?.styles ?? document.package.styles,
|
|
409
|
+
theme: options?.theme ?? document.package.theme ?? null,
|
|
410
|
+
numbering: document.package.numbering,
|
|
411
|
+
warn: options?.warn
|
|
412
|
+
};
|
|
413
|
+
const shared = cache?.packageContext(packageInputs);
|
|
414
|
+
shared?.pageBreakRunSourceDescendants.include(paragraphs);
|
|
415
|
+
const styleResolver = shared?.styleResolver ?? createStyleEngine(packageInputs.styles);
|
|
416
|
+
const salt = cache?.salt ?? options?.textBoxGroupSalt ?? newTextBoxGroupSalt();
|
|
417
|
+
const story = {
|
|
418
|
+
textBoxGroups: { value: 0 },
|
|
419
|
+
hyperlinks: { value: 0 },
|
|
420
|
+
noteOccurrences: { value: 0 },
|
|
421
|
+
pairedBookmarkIds: collectPairedBookmarkIds(paragraphs),
|
|
272
422
|
storyRangedCommentIds: rangedCommentIds(paragraphs),
|
|
273
|
-
openCommentIds: /* @__PURE__ */ new Set()
|
|
274
|
-
|
|
275
|
-
|
|
423
|
+
openCommentIds: /* @__PURE__ */ new Set()
|
|
424
|
+
};
|
|
425
|
+
const conversionContext = {
|
|
426
|
+
listRenderings: shared?.listRenderings ?? /* @__PURE__ */ new Map(),
|
|
427
|
+
numbering: shared?.numbering ?? (packageInputs.numbering === void 0 ? void 0 : getCachedNumberingMap(packageInputs.numbering)),
|
|
428
|
+
theme: shared?.theme ?? packageInputs.theme,
|
|
429
|
+
nextTextBoxGroupId: textBoxGroupIdsFrom(salt, story.textBoxGroups),
|
|
430
|
+
nextHyperlinkInstanceIndex: () => story.hyperlinks.value++,
|
|
431
|
+
nextNoteReferenceOccurrenceId: () => `source-note:${story.noteOccurrences.value++}`,
|
|
432
|
+
pairedBookmarkIds: story.pairedBookmarkIds,
|
|
433
|
+
pageBreakRunSourceDescendants: shared?.pageBreakRunSourceDescendants ?? buildPageBreakRunSourceDescendantIndex(paragraphs),
|
|
434
|
+
storyRangedCommentIds: story.storyRangedCommentIds,
|
|
435
|
+
openCommentIds: story.openCommentIds,
|
|
436
|
+
warnPageBreakProjection: shared?.warnPageBreakProjection ?? pageBreakProjectionWarn(options?.warn),
|
|
437
|
+
createMark: shared?.createMark ?? createMarkInterner(schema)
|
|
276
438
|
};
|
|
277
439
|
const convertBodyBlocks = (blocks) => {
|
|
278
440
|
const out = [];
|
|
279
441
|
for (const block of blocks) switch (block.type) {
|
|
280
442
|
case "paragraph":
|
|
281
|
-
out.push(...convertParagraphWithTextBoxes(block, styleResolver, {
|
|
282
|
-
textBoxGroupId: nextTextBoxGroupId(),
|
|
443
|
+
out.push(...cache === void 0 ? convertParagraphWithTextBoxes(block, styleResolver, {
|
|
444
|
+
textBoxGroupId: conversionContext.nextTextBoxGroupId(),
|
|
283
445
|
context: conversionContext
|
|
284
|
-
}))
|
|
446
|
+
}) : cache.paragraph(block, story, (context, textBoxGroupId) => convertParagraphWithTextBoxes(block, styleResolver, {
|
|
447
|
+
textBoxGroupId,
|
|
448
|
+
context
|
|
449
|
+
})));
|
|
285
450
|
break;
|
|
286
451
|
case "table":
|
|
287
452
|
out.push(convertTable(block, styleResolver, conversionContext));
|
|
@@ -299,6 +464,10 @@ function toProseDoc(document, options) {
|
|
|
299
464
|
case "bookmarkEnd":
|
|
300
465
|
out.push(convertBlockBookmarkBoundary(block));
|
|
301
466
|
break;
|
|
467
|
+
case "commentRangeStart":
|
|
468
|
+
case "commentRangeEnd":
|
|
469
|
+
out.push(convertBlockCommentRangeBoundary(block, conversionContext.openCommentIds));
|
|
470
|
+
break;
|
|
302
471
|
case "moveFromRangeStart":
|
|
303
472
|
case "moveFromRangeEnd":
|
|
304
473
|
case "moveToRangeStart":
|
|
@@ -347,6 +516,16 @@ function convertPreservedBlock(block) {
|
|
|
347
516
|
function convertBlockBookmarkBoundary(block) {
|
|
348
517
|
return schema.node("blockBookmarkBoundary", bookmarkBoundaryAttrsFromMarker(block));
|
|
349
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* A comment range marker standing between blocks, kept between the same two.
|
|
521
|
+
* It opens or closes the comment for the text that follows, as the same
|
|
522
|
+
* marker inside a paragraph does, so the comment's mark covers that text.
|
|
523
|
+
*/
|
|
524
|
+
function convertBlockCommentRangeBoundary(block, openCommentIds) {
|
|
525
|
+
if (block.type === "commentRangeStart") openCommentIds.add(block.id);
|
|
526
|
+
else openCommentIds.delete(block.id);
|
|
527
|
+
return schema.node(BLOCK_COMMENT_RANGE_BOUNDARY_NODE_NAME, { marker: block });
|
|
528
|
+
}
|
|
350
529
|
/** A move range marker standing between blocks, kept between the same two. */
|
|
351
530
|
function convertBlockMoveRangeBoundary(block) {
|
|
352
531
|
return schema.node(BLOCK_MOVE_RANGE_BOUNDARY_NODE_NAME, { marker: block });
|
|
@@ -544,7 +723,8 @@ function convertParagraph(paragraph, styleResolver, context, extraRunFormatting,
|
|
|
544
723
|
const paragraphMarkOverrides = getParagraphMarkSuppressionOverrides({
|
|
545
724
|
directFormatting: formatting,
|
|
546
725
|
paragraphMarkFormatting: inheritableParagraphRunFormatting,
|
|
547
|
-
suppressedFormatting
|
|
726
|
+
suppressedFormatting,
|
|
727
|
+
characterStyleFormatting: formatting?.styleId === void 0 ? void 0 : styleResolver?.getRunStyleOwnProperties(formatting.styleId) ?? void 0
|
|
548
728
|
}) ?? (inheritableParagraphRunFormatting ? {} : void 0);
|
|
549
729
|
return {
|
|
550
730
|
formatting: suppressedFormatting,
|
|
@@ -701,7 +881,10 @@ function applyCommentMarks(nodes, commentIds) {
|
|
|
701
881
|
});
|
|
702
882
|
}
|
|
703
883
|
function anchorPointComment(nodes, commentId) {
|
|
704
|
-
const commentMark = schema.marks["comment"]?.create({
|
|
884
|
+
const commentMark = schema.marks["comment"]?.create({
|
|
885
|
+
commentId,
|
|
886
|
+
point: true
|
|
887
|
+
});
|
|
705
888
|
if (!commentMark) return;
|
|
706
889
|
for (let index = nodes.length - 1; index >= 0; index--) {
|
|
707
890
|
const node = nodes[index];
|
|
@@ -742,6 +925,26 @@ const withTrackedRunMark = (node, mark, ancestor) => {
|
|
|
742
925
|
if (canCarryTrackedRunMark(node)) return node.mark(mark.addToSet(node.marks));
|
|
743
926
|
return node;
|
|
744
927
|
};
|
|
928
|
+
/** A revision's info as the review surface reads it: a suggestion's says so. */
|
|
929
|
+
const suggestedRevisionInfo = (info) => info.suggestionId === void 0 ? info : {
|
|
930
|
+
...info,
|
|
931
|
+
provenance: "suggested"
|
|
932
|
+
};
|
|
933
|
+
/**
|
|
934
|
+
* The mark a run's property changes ride. Changes that all belong to one
|
|
935
|
+
* pending suggestion show as that suggestion, as tracked text does.
|
|
936
|
+
*/
|
|
937
|
+
const runPropertyChangeMark = (changes) => {
|
|
938
|
+
const suggestionIds = new Set(changes.map(({ info }) => info.suggestionId));
|
|
939
|
+
const [suggestionId] = suggestionIds;
|
|
940
|
+
return schema.mark("runPropertyChange", {
|
|
941
|
+
changes: [...changes],
|
|
942
|
+
...suggestionIds.size === 1 && suggestionId !== void 0 ? {
|
|
943
|
+
provenance: "suggested",
|
|
944
|
+
suggestionId
|
|
945
|
+
} : {}
|
|
946
|
+
});
|
|
947
|
+
};
|
|
745
948
|
function convertTrackedChange(change, markType, nextHyperlinkInstanceIndex, runScope, runFormattingResolvers, styleResolver, moveKind, textBoxAnchors, wrappedBy, openCommentIds, options = {}) {
|
|
746
949
|
const nodes = [];
|
|
747
950
|
const preserveParentBoundaryOwnership = options.preserveParentBoundaryOwnership ?? true;
|
|
@@ -842,6 +1045,10 @@ function convertTrackedChange(change, markType, nextHyperlinkInstanceIndex, runS
|
|
|
842
1045
|
date: change.info.date ?? null,
|
|
843
1046
|
utcDate: change.info.utcDate?.value ?? null,
|
|
844
1047
|
initials: change.info.initials ?? null,
|
|
1048
|
+
...change.info.suggestionId === void 0 ? {} : {
|
|
1049
|
+
provenance: "suggested",
|
|
1050
|
+
suggestionId: change.info.suggestionId
|
|
1051
|
+
},
|
|
845
1052
|
moveKind,
|
|
846
1053
|
_docxOuterWrapperCount: wrappedBy.length,
|
|
847
1054
|
_docxResolutionJoins: change.resolutionJoins ?? null,
|
|
@@ -878,7 +1085,11 @@ function paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOver
|
|
|
878
1085
|
if (formatting?.numPrFromStyle) attrs.numPrFromStyle = paragraphNumberingAttr(formatting.numPrFromStyle);
|
|
879
1086
|
if (paragraph.listRendering && formatting?.numPr?.kind !== "none") Object.assign(attrs, CLEARED_LIST_RENDERING_ATTRS, listRenderingAttrPatch(paragraph.listRendering));
|
|
880
1087
|
if (formatting) attrs._originalFormatting = formatting;
|
|
881
|
-
if (paragraph.propertyChanges && paragraph.propertyChanges.length > 0) attrs._propertyChanges = paragraph.propertyChanges.map(({ previousFormatting, ...
|
|
1088
|
+
if (paragraph.propertyChanges && paragraph.propertyChanges.length > 0) attrs._propertyChanges = paragraph.propertyChanges.map(({ previousFormatting, ...modelChange }) => {
|
|
1089
|
+
const change = {
|
|
1090
|
+
...modelChange,
|
|
1091
|
+
info: suggestedRevisionInfo(modelChange.info)
|
|
1092
|
+
};
|
|
882
1093
|
if (previousFormatting === void 0) return change;
|
|
883
1094
|
const { numPr, numPrFromStyle, ...rest } = previousFormatting;
|
|
884
1095
|
return {
|
|
@@ -891,7 +1102,10 @@ function paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOver
|
|
|
891
1102
|
};
|
|
892
1103
|
});
|
|
893
1104
|
if (paragraph.preservedAttributes && paragraph.preservedAttributes.length > 0) attrs._preservedAttributes = paragraph.preservedAttributes;
|
|
894
|
-
if (paragraph.pPrMark) attrs.pPrMark = paragraph.pPrMark
|
|
1105
|
+
if (paragraph.pPrMark) attrs.pPrMark = paragraph.pPrMark.info.suggestionId === void 0 ? paragraph.pPrMark : {
|
|
1106
|
+
...paragraph.pPrMark,
|
|
1107
|
+
info: suggestedRevisionInfo(paragraph.pPrMark.info)
|
|
1108
|
+
};
|
|
895
1109
|
const set = (key, val) => {
|
|
896
1110
|
if (val !== void 0) attrs[key] = val;
|
|
897
1111
|
};
|
|
@@ -1100,10 +1314,11 @@ function convertTable(table, styleResolver, context) {
|
|
|
1100
1314
|
const totalRows = table.rows.length;
|
|
1101
1315
|
const gridColumnCount = columnWidths?.length ?? 0;
|
|
1102
1316
|
const totalColumns = gridColumnCount > 0 ? gridColumnCount : countTableColumns(table.rows);
|
|
1317
|
+
const mapWidth = table.rows.some((row) => row.cells.length === 0) ? Math.max(countTableColumns(table.rows), totalColumns) : countTableColumns(table.rows);
|
|
1103
1318
|
const rows = table.rows.map((row, rowIndex) => {
|
|
1104
1319
|
const isFirstRowStyled = rowIndex === 0 && look.firstRow;
|
|
1105
1320
|
const resolvedRowJustification = tableStyle?.trPr?.justification ?? fallbackTableStyle?.trPr?.justification;
|
|
1106
|
-
return convertTableRow(row, styleResolver, context, isFirstRowStyled, columnWidths, totalWidth, conditionalStyles, tableRowBand(look, rowIndex, totalRows), look, resolvedTableBorders, rowIndex, totalRows, totalColumns, rowSpanMap, cellMarginsAttr, resolvedRowJustification);
|
|
1321
|
+
return convertTableRow(row, styleResolver, context, isFirstRowStyled, columnWidths, totalWidth, conditionalStyles, tableRowBand(look, rowIndex, totalRows), look, resolvedTableBorders, rowIndex, totalRows, totalColumns, mapWidth, rowSpanMap, cellMarginsAttr, resolvedRowJustification);
|
|
1107
1322
|
});
|
|
1108
1323
|
return schema.node("table", attrs, rows);
|
|
1109
1324
|
}
|
|
@@ -1133,7 +1348,7 @@ function createOmittedGridSlotCell({ colspan, slot, columnWidths, totalWidth, st
|
|
|
1133
1348
|
/**
|
|
1134
1349
|
* Convert a TableRow to a ProseMirror table row node
|
|
1135
1350
|
*/
|
|
1136
|
-
function convertTableRow(row, styleResolver, context, isHeaderRow, columnWidths, totalWidth, conditionalStyles, rowBand, tableLook, tableBorders, rowIndex, totalRows, totalColumns, rowSpanMap, defaultCellMargins, resolvedJustification) {
|
|
1351
|
+
function convertTableRow(row, styleResolver, context, isHeaderRow, columnWidths, totalWidth, conditionalStyles, rowBand, tableLook, tableBorders, rowIndex, totalRows, totalColumns, mapWidth, rowSpanMap, defaultCellMargins, resolvedJustification) {
|
|
1137
1352
|
const attrsWithoutStructuralChange = { isHeader: !!row.formatting?.header };
|
|
1138
1353
|
if (row.formatting?.height?.value !== void 0) attrsWithoutStructuralChange.height = row.formatting.height.value;
|
|
1139
1354
|
if (row.formatting?.heightRule) attrsWithoutStructuralChange.heightRule = row.formatting.heightRule;
|
|
@@ -1253,8 +1468,9 @@ function convertTableRow(row, styleResolver, context, isHeaderRow, columnWidths,
|
|
|
1253
1468
|
defaultCellMargins
|
|
1254
1469
|
}));
|
|
1255
1470
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1471
|
+
const omittedAfter = Math.max(gridAfter, (mapWidth ?? 0) - colIndex);
|
|
1472
|
+
if (omittedAfter > 0) cells.push(createOmittedGridSlotCell({
|
|
1473
|
+
colspan: omittedAfter,
|
|
1258
1474
|
slot: "after",
|
|
1259
1475
|
columnWidths,
|
|
1260
1476
|
totalWidth,
|
|
@@ -1375,6 +1591,10 @@ function convertTableCell({ cell, styleResolver, context, isHeader, gridWidthPer
|
|
|
1375
1591
|
case "bookmarkEnd":
|
|
1376
1592
|
nodes.push(convertBlockBookmarkBoundary(block));
|
|
1377
1593
|
break;
|
|
1594
|
+
case "commentRangeStart":
|
|
1595
|
+
case "commentRangeEnd":
|
|
1596
|
+
nodes.push(convertBlockCommentRangeBoundary(block, context.openCommentIds));
|
|
1597
|
+
break;
|
|
1378
1598
|
case "moveFromRangeStart":
|
|
1379
1599
|
case "moveFromRangeEnd":
|
|
1380
1600
|
case "moveToRangeStart":
|
|
@@ -1533,7 +1753,7 @@ function convertField(field, { getInheritedRunFormatting, styleResolver, nextHyp
|
|
|
1533
1753
|
const displayText = getInlineDisplayText(schema.node("paragraph", null, inlineNodes));
|
|
1534
1754
|
const emptyResultRuns = displayText === "" && resultRuns.length > 0 && (field.type === "complexField" || field.content.length === resultRuns.length) && resultRuns.every((run) => run.content.every((item) => item.type === "text" && item.text === "")) ? resultRuns : void 0;
|
|
1535
1755
|
const resultPropertyChanges = emptyResultRuns ? emptyFieldRunPropertyChanges(emptyResultRuns) : fieldPropertyChanges;
|
|
1536
|
-
if (!createStructuredField && resultPropertyChanges && resultPropertyChanges.length > 0) marks.push(
|
|
1756
|
+
if (!createStructuredField && resultPropertyChanges && resultPropertyChanges.length > 0) marks.push(runPropertyChangeMark(resultPropertyChanges));
|
|
1537
1757
|
const fieldNode = schema.node(createStructuredField ? "structuredField" : "field", {
|
|
1538
1758
|
fieldType: field.fieldType,
|
|
1539
1759
|
instruction: field.instruction,
|
|
@@ -1733,7 +1953,7 @@ function convertRun(run, resolvedStyleFormatting, runScope, styleResolver, textB
|
|
|
1733
1953
|
styleResolver,
|
|
1734
1954
|
createMark: runScope.createMark
|
|
1735
1955
|
});
|
|
1736
|
-
if (run.propertyChanges && run.propertyChanges.length > 0) marks.push(
|
|
1956
|
+
if (run.propertyChanges && run.propertyChanges.length > 0) marks.push(runPropertyChangeMark(run.propertyChanges));
|
|
1737
1957
|
const identity = runIdentityMark(run, runScope.nextRunIdentityId);
|
|
1738
1958
|
if (identity) marks.push(identity);
|
|
1739
1959
|
for (const content of run.content) {
|
|
@@ -1967,7 +2187,7 @@ const RUN_FORMATTING_INFERENCE = {
|
|
|
1967
2187
|
italic: "ordinary-toggle",
|
|
1968
2188
|
italicCs: "structural",
|
|
1969
2189
|
underline: "underline",
|
|
1970
|
-
strike: "
|
|
2190
|
+
strike: "strike",
|
|
1971
2191
|
doubleStrike: "double-strike",
|
|
1972
2192
|
vertAlign: "visible-value",
|
|
1973
2193
|
smallCaps: "visible-boolean",
|
|
@@ -2040,6 +2260,10 @@ const canReconstructAuthoredRunFormatting = ({ directFormatting, effectiveFormat
|
|
|
2040
2260
|
case "underline":
|
|
2041
2261
|
if (typeof directValue === "object" && directValue !== null && Reflect.get(directValue, "style") !== "none" && Reflect.get(directValue, "color") === void 0 && sameFormattingValue(directValue, effectiveValue) && !sameFormattingValue(directValue, inheritedValue)) continue;
|
|
2042
2262
|
return false;
|
|
2263
|
+
case "strike":
|
|
2264
|
+
if (directValue === false) continue;
|
|
2265
|
+
if (directValue === true && inheritedFormatting?.strike !== true && inheritedFormatting?.doubleStrike !== true && effectiveFormatting?.doubleStrike !== true) continue;
|
|
2266
|
+
return false;
|
|
2043
2267
|
case "double-strike":
|
|
2044
2268
|
if (directValue === false) continue;
|
|
2045
2269
|
if (directValue === true && inheritedFormatting?.strike !== true && inheritedFormatting?.doubleStrike !== true) continue;
|
|
@@ -2454,7 +2678,7 @@ function convertHyperlink(hyperlink, { getInheritedRunFormatting, styleResolver,
|
|
|
2454
2678
|
styleResolver,
|
|
2455
2679
|
createMark: runScope.createMark
|
|
2456
2680
|
});
|
|
2457
|
-
if (child.propertyChanges && child.propertyChanges.length > 0) runMarks.push(
|
|
2681
|
+
if (child.propertyChanges && child.propertyChanges.length > 0) runMarks.push(runPropertyChangeMark(child.propertyChanges));
|
|
2458
2682
|
const identity = runIdentityMark(child, runScope.nextRunIdentityId);
|
|
2459
2683
|
if (identity) runMarks.push(identity);
|
|
2460
2684
|
const allMarks = [...runMarks, linkMark];
|
|
@@ -2469,6 +2693,19 @@ function convertHyperlink(hyperlink, { getInheritedRunFormatting, styleResolver,
|
|
|
2469
2693
|
}));
|
|
2470
2694
|
break;
|
|
2471
2695
|
}
|
|
2696
|
+
case "complexField": {
|
|
2697
|
+
const fieldNode = convertField(child, {
|
|
2698
|
+
getInheritedRunFormatting,
|
|
2699
|
+
styleResolver,
|
|
2700
|
+
nextHyperlinkInstanceIndex: () => panic("A complex field result holds no hyperlink."),
|
|
2701
|
+
runScope,
|
|
2702
|
+
textBoxAnchors,
|
|
2703
|
+
openCommentIds
|
|
2704
|
+
});
|
|
2705
|
+
if (fieldNode) childNodes.push(fieldNode.mark(linkMark.addToSet(fieldNode.marks)));
|
|
2706
|
+
commentsAlreadyApplied = true;
|
|
2707
|
+
break;
|
|
2708
|
+
}
|
|
2472
2709
|
}
|
|
2473
2710
|
const wrappedNodes = withInlineWrapperMark(childNodes, stack, {
|
|
2474
2711
|
hyperlinkIndex,
|
|
@@ -2801,17 +3038,46 @@ function convertTextBox(textBox, styleResolver, options) {
|
|
|
2801
3038
|
...options.context,
|
|
2802
3039
|
openCommentIds: /* @__PURE__ */ new Set()
|
|
2803
3040
|
};
|
|
2804
|
-
const
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
3041
|
+
const convertBoxBlocks = (blocks) => {
|
|
3042
|
+
const nodes = [];
|
|
3043
|
+
for (const block of blocks) switch (block.type) {
|
|
3044
|
+
case "paragraph":
|
|
3045
|
+
nodes.push(...convertParagraphWithTextBoxes(block, styleResolver, {
|
|
3046
|
+
textBoxGroupId: textBoxContext.nextTextBoxGroupId(),
|
|
3047
|
+
context: textBoxContext
|
|
3048
|
+
}));
|
|
3049
|
+
break;
|
|
3050
|
+
case "table":
|
|
3051
|
+
nodes.push(convertTable(block, styleResolver, textBoxContext));
|
|
3052
|
+
break;
|
|
3053
|
+
case "blockSdt":
|
|
3054
|
+
nodes.push(convertBlockSdt(block, convertBoxBlocks));
|
|
3055
|
+
break;
|
|
3056
|
+
case "blockCustomXml":
|
|
3057
|
+
nodes.push(convertBlockCustomXml(block, convertBoxBlocks));
|
|
3058
|
+
break;
|
|
3059
|
+
case "preservedBlock":
|
|
3060
|
+
nodes.push(convertPreservedBlock(block));
|
|
3061
|
+
break;
|
|
3062
|
+
case "bookmarkStart":
|
|
3063
|
+
case "bookmarkEnd":
|
|
3064
|
+
nodes.push(convertBlockBookmarkBoundary(block));
|
|
3065
|
+
break;
|
|
3066
|
+
case "commentRangeStart":
|
|
3067
|
+
case "commentRangeEnd":
|
|
3068
|
+
nodes.push(convertBlockCommentRangeBoundary(block, textBoxContext.openCommentIds));
|
|
3069
|
+
break;
|
|
3070
|
+
case "moveFromRangeStart":
|
|
3071
|
+
case "moveFromRangeEnd":
|
|
3072
|
+
case "moveToRangeStart":
|
|
3073
|
+
case "moveToRangeEnd":
|
|
3074
|
+
nodes.push(convertBlockMoveRangeBoundary(block));
|
|
3075
|
+
break;
|
|
3076
|
+
default: return block;
|
|
2812
3077
|
}
|
|
2813
|
-
|
|
2814
|
-
}
|
|
3078
|
+
return nodes;
|
|
3079
|
+
};
|
|
3080
|
+
const contentNodes = convertBoxBlocks(textBox.content);
|
|
2815
3081
|
if (contentNodes.length === 0) contentNodes.push(schema.node("paragraph", {}, []));
|
|
2816
3082
|
const wrapType = textBox.wrap?.type;
|
|
2817
3083
|
const wrapText = textBox.wrap?.wrapText;
|
|
@@ -2970,6 +3236,10 @@ function headerFooterToProseDoc(content, options) {
|
|
|
2970
3236
|
case "bookmarkEnd":
|
|
2971
3237
|
out.push(convertBlockBookmarkBoundary(block));
|
|
2972
3238
|
break;
|
|
3239
|
+
case "commentRangeStart":
|
|
3240
|
+
case "commentRangeEnd":
|
|
3241
|
+
out.push(convertBlockCommentRangeBoundary(block, conversionContext.openCommentIds));
|
|
3242
|
+
break;
|
|
2973
3243
|
case "moveFromRangeStart":
|
|
2974
3244
|
case "moveFromRangeEnd":
|
|
2975
3245
|
case "moveToRangeStart":
|
|
@@ -2995,4 +3265,4 @@ function footnoteToProseDoc(content, options) {
|
|
|
2995
3265
|
function createEmptyDoc() {
|
|
2996
3266
|
return schema.node("doc", null, [schema.node("paragraph", {}, [])]);
|
|
2997
3267
|
}
|
|
2998
|
-
export { collectPairedBookmarkIds, createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, hostParagraphAttrs, standaloneTableCellToProseMirror, toProseDoc };
|
|
3268
|
+
export { ProjectionBlockCache, collectPairedBookmarkIds, createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, hostParagraphAttrs, standaloneTableCellToProseMirror, toProseDoc };
|
|
@@ -20,6 +20,7 @@ import { PasteStyleInlinerExtension } from "./features/PasteStyleInlinerExtensio
|
|
|
20
20
|
import { SelectionTrackerExtension } from "./features/SelectionTrackerExtension.js";
|
|
21
21
|
import { MARK_EXTENSIONS, MARK_NESTING_ORDER } from "./markRegistry.js";
|
|
22
22
|
import { BlockBookmarkBoundaryExtension } from "./nodes/BlockBookmarkBoundaryExtension.js";
|
|
23
|
+
import { BlockCommentRangeBoundaryExtension } from "./nodes/BlockCommentRangeBoundaryExtension.js";
|
|
23
24
|
import { BlockCustomXmlExtension } from "./nodes/BlockCustomXmlExtension.js";
|
|
24
25
|
import { BlockMoveRangeBoundaryExtension } from "./nodes/BlockMoveRangeBoundaryExtension.js";
|
|
25
26
|
import { BlockSdtExtension } from "./nodes/BlockSdtExtension.js";
|
|
@@ -73,6 +74,7 @@ function createStarterKit(options = {}) {
|
|
|
73
74
|
add("bookmarkBoundary", BookmarkBoundaryExtension({ getInternalClipboardToken }));
|
|
74
75
|
add("blockBookmarkBoundary", BlockBookmarkBoundaryExtension({ getInternalClipboardToken }));
|
|
75
76
|
add("blockMoveRangeBoundary", BlockMoveRangeBoundaryExtension({ getInternalClipboardToken }));
|
|
77
|
+
add("blockCommentRangeBoundary", BlockCommentRangeBoundaryExtension());
|
|
76
78
|
add("commentReference", CommentReferenceExtension({ getInternalClipboardToken }));
|
|
77
79
|
add("commentRangeBoundary", CommentRangeBoundaryExtension({ getInternalClipboardToken }));
|
|
78
80
|
add("moveRangeBoundary", MoveRangeBoundaryExtension({ getInternalClipboardToken }));
|
|
@@ -14,7 +14,7 @@ const DocExtension = createNodeExtension({
|
|
|
14
14
|
_adjustLineHeightInTable: { default: false },
|
|
15
15
|
_doNotUseIndentAsNumberingTabStop: { default: false }
|
|
16
16
|
},
|
|
17
|
-
content: "(paragraph | horizontalRule | pageBreak | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary)+"
|
|
17
|
+
content: "(paragraph | horizontalRule | pageBreak | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary | blockCommentRangeBoundary)+"
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
export { DocExtension };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../../../types/document.js";
|
|
2
2
|
import { NumberingMap } from "../../../docx/numberingParser.js";
|
|
3
3
|
import { NodeExtension } from "../types.js";
|
|
4
|
-
import { EditorState } from "prosemirror-state";
|
|
4
|
+
import { Command, EditorState } from "prosemirror-state";
|
|
5
5
|
export type ResolvedStyleAttrs = {
|
|
6
6
|
paragraphFormatting?: document_d_exports.ParagraphFormatting;
|
|
7
7
|
runFormatting?: document_d_exports.TextFormatting;
|
|
@@ -33,4 +33,6 @@ export type GenerateTableOfContentsOptions = {
|
|
|
33
33
|
/** Heading text for the table, in the document's language. */
|
|
34
34
|
title: string;
|
|
35
35
|
};
|
|
36
|
+
/** Set the selected paragraphs' writing direction. */
|
|
37
|
+
export declare const setParagraphDirection: (direction: "ltr" | "rtl") => Command;
|
|
36
38
|
export declare const ParagraphExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtension;
|