@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
|
@@ -7,6 +7,7 @@ import { encloseWholeControls } from "../contentControlRevisions.js";
|
|
|
7
7
|
import { splitBlockClearBorders } from "../extensions/features/BaseKeymapExtension.js";
|
|
8
8
|
import { JOINED_RUNS_RESTYLED_META } from "../extensions/features/JoinedRunStyleExtension.js";
|
|
9
9
|
import { expandNoteReferenceDeletionRange } from "../extensions/marks/noteReferenceDeletion.js";
|
|
10
|
+
import { isInlineAnchor } from "../extensions/nodes/inlineAnchorDom.js";
|
|
10
11
|
import { carryParagraphProperties, paragraphLeftAfter, recordReplacedParagraphProperties } from "../paragraphPropertyCarry.js";
|
|
11
12
|
import { createPluginKeyOwner } from "../pluginKeyOwner.js";
|
|
12
13
|
import { rebaseParagraphRuns } from "../rebaseParagraphRunFormatting.js";
|
|
@@ -21,7 +22,7 @@ import { selectLockedInlineControl } from "./lockedControlKeyHandling.js";
|
|
|
21
22
|
import { mintRevisionId, seedRevisionIdsFromDoc } from "./revisionIds.js";
|
|
22
23
|
import { Slice } from "prosemirror-model";
|
|
23
24
|
import { CellSelection } from "prosemirror-tables";
|
|
24
|
-
import { Mapping, ReplaceStep } from "prosemirror-transform";
|
|
25
|
+
import { Mapping, ReplaceAroundStep, ReplaceStep } from "prosemirror-transform";
|
|
25
26
|
import { AllSelection, EditorState, Plugin, Selection, TextSelection } from "prosemirror-state";
|
|
26
27
|
import { isHistoryTransaction } from "prosemirror-history";
|
|
27
28
|
import { joinBackward, joinForward, selectNodeBackward, selectNodeForward } from "prosemirror-commands";
|
|
@@ -122,6 +123,7 @@ function findAdjacentRevisionForRange(doc, from, to, markTypeName, author) {
|
|
|
122
123
|
*/
|
|
123
124
|
function markRangeAsDeleted(tr, doc, from, to, deletionType, pluginState, joinState) {
|
|
124
125
|
let hasMarkableContent = false;
|
|
126
|
+
const stepsBeforeDoc = doc === tr.doc ? tr.mapping.maps.length : 0;
|
|
125
127
|
doc.nodesBetween(from, to, (node, pos) => {
|
|
126
128
|
if (!canCarryTrackedRunMark(node)) return;
|
|
127
129
|
if (Math.max(pos, from) >= Math.min(pos + node.nodeSize, to)) return;
|
|
@@ -149,7 +151,7 @@ function markRangeAsDeleted(tr, doc, from, to, deletionType, pluginState, joinSt
|
|
|
149
151
|
const $first = doc.resolve(from);
|
|
150
152
|
const $last = doc.resolve(to);
|
|
151
153
|
if (joinState && removedMark && $first.parent.type.name === "paragraph" && $last.parent.type.name === "paragraph" && $first.parent !== $last.parent && from > $first.start()) {
|
|
152
|
-
const lastPos =
|
|
154
|
+
const lastPos = tr.mapping.slice(stepsBeforeDoc).map($last.before());
|
|
153
155
|
const lastMark = tr.doc.nodeAt(lastPos)?.attrs["pPrMark"];
|
|
154
156
|
const survivorPos = lastMark?.kind === "del" || lastMark?.kind === "moveFrom" ? paragraphLeftAfter({
|
|
155
157
|
doc: tr.doc,
|
|
@@ -248,20 +250,25 @@ function handleSuggestionPaste(view, slice, pluginState) {
|
|
|
248
250
|
if (!insertionType || !deletionType) return false;
|
|
249
251
|
if (selection.empty) {
|
|
250
252
|
const { $from } = selection;
|
|
251
|
-
const
|
|
253
|
+
const closedBlocks = slice.openStart === 0 && slice.openEnd === 0 && slice.content.firstChild?.isBlock === true;
|
|
252
254
|
const prefix = $from.parent.content.cut(0, $from.parentOffset);
|
|
253
|
-
let deletedPrefix =
|
|
255
|
+
let deletedPrefix = false;
|
|
256
|
+
let keptPrefix = false;
|
|
254
257
|
prefix.forEach((node) => {
|
|
255
|
-
if (
|
|
258
|
+
if (isInlineAnchor(node)) return;
|
|
259
|
+
if (node.marks.some((mark) => mark.type === deletionType)) deletedPrefix = true;
|
|
260
|
+
else keptPrefix = true;
|
|
256
261
|
});
|
|
257
|
-
|
|
262
|
+
deletedPrefix &&= !keptPrefix;
|
|
263
|
+
if (!closedBlocks || $from.parent.type.name !== "paragraph" || !deletedPrefix) return false;
|
|
258
264
|
const suffix = $from.parent.content.cut($from.parentOffset);
|
|
259
265
|
let deletedSuffix = true;
|
|
260
266
|
suffix.forEach((node) => {
|
|
261
267
|
if (!node.marks.some((mark) => mark.type === deletionType)) deletedSuffix = false;
|
|
262
268
|
});
|
|
269
|
+
const rotates = deletedSuffix && ($from.parent.attrs["pPrMark"]?.kind ?? "del") === "del" && paragraphEndsItsContainer($from.doc.resolve($from.before()), "paragraph") && slice.content.firstChild?.type === $from.parent.type && slice.content.lastChild?.type === $from.parent.type;
|
|
263
270
|
const tr = view.state.tr.setMeta(SUGGESTION_META, true).setMeta("paste", true);
|
|
264
|
-
const at = $from.before();
|
|
271
|
+
const at = rotates ? $from.after() : $from.before();
|
|
265
272
|
tr.replaceRange(at, at, slice);
|
|
266
273
|
const revision = makeMarkAttrs(pluginState);
|
|
267
274
|
const end = tr.mapping.map(at, 1);
|
|
@@ -271,7 +278,26 @@ function handleSuggestionPaste(view, slice, pluginState) {
|
|
|
271
278
|
to: end,
|
|
272
279
|
revision
|
|
273
280
|
});
|
|
281
|
+
tr.doc.nodesBetween(at, end, (node, pos) => {
|
|
282
|
+
if (node.type.name !== "paragraph" || node.attrs["pPrMark"] != null) return false;
|
|
283
|
+
tr.setNodeAttribute(pos, "pPrMark", {
|
|
284
|
+
kind: "ins",
|
|
285
|
+
info: {
|
|
286
|
+
id: revision.revisionId,
|
|
287
|
+
author: revision.author,
|
|
288
|
+
date: revision.date
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
return false;
|
|
292
|
+
});
|
|
274
293
|
markRangeAsInserted(tr, tr.doc, at, end, insertionType, deletionType, revision);
|
|
294
|
+
if (rotates) {
|
|
295
|
+
const rotation = tr.steps.length;
|
|
296
|
+
rotateIntoFinalParagraph(view.state, tr, $from.before(), revision);
|
|
297
|
+
tr.setSelection(TextSelection.near(tr.doc.resolve(tr.mapping.slice(rotation).map(end, -1)), -1));
|
|
298
|
+
view.dispatch(tr.scrollIntoView());
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
275
301
|
if (deletedSuffix && $from.parent.attrs["pPrMark"] == null && !paragraphEndsItsContainer($from.doc.resolve($from.before()), "paragraph")) tr.setNodeAttribute(tr.mapping.map($from.before()), "pPrMark", {
|
|
276
302
|
kind: "del",
|
|
277
303
|
info: makeParagraphMarkInfo(pluginState)
|
|
@@ -344,9 +370,9 @@ function handleSuggestionPaste(view, slice, pluginState) {
|
|
|
344
370
|
});
|
|
345
371
|
markRangeAsInserted(tr, tr.doc, insertFrom, insertTo, insertionType, deletionType, insertAttrs);
|
|
346
372
|
if (!inlineSlice) carryAcross();
|
|
347
|
-
if (
|
|
348
|
-
const $end = tr.doc.resolve(tr.mapping.map(to));
|
|
349
|
-
if ($end.parent.type.name === "paragraph" && $end.before() !== tr.mapping.map($from.before())) recordReplacedParagraphProperties({
|
|
373
|
+
if ($to.parent.type.name === "paragraph") {
|
|
374
|
+
const $end = tr.doc.resolve(closedBlocks ? Math.max(insertFrom, insertTo - 1) : tr.mapping.map(to));
|
|
375
|
+
if ($end.parent.type.name === "paragraph" && $end.before() !== tr.mapping.map($from.before()) && expectParagraphAttrs($end.parent).pPrMark?.kind !== "ins") recordReplacedParagraphProperties({
|
|
350
376
|
tr,
|
|
351
377
|
position: $end.before(),
|
|
352
378
|
replaced: $to.parent,
|
|
@@ -379,7 +405,8 @@ function handleSuggestionPaste(view, slice, pluginState) {
|
|
|
379
405
|
insertFrom = Math.min(tr.mapping.slice(rotation).map(insertFrom, -1), joined);
|
|
380
406
|
insertTo = tr.mapping.slice(rotation).map(insertTo);
|
|
381
407
|
}
|
|
382
|
-
tr.
|
|
408
|
+
const caret = beforeStruck && !wholeBlocks ? tr.mapping.map(to) : insertTo;
|
|
409
|
+
tr.setSelection(TextSelection.near(tr.doc.resolve(caret)));
|
|
383
410
|
view.dispatch(tr.scrollIntoView());
|
|
384
411
|
return true;
|
|
385
412
|
}
|
|
@@ -391,6 +418,13 @@ function handleSuggestionPaste(view, slice, pluginState) {
|
|
|
391
418
|
* last one ends the cell, so its paragraph mark is tracked as added too:
|
|
392
419
|
* rejecting then drops it and accepting joins the struck paragraphs into it.
|
|
393
420
|
*/
|
|
421
|
+
const holdsOnlyStruckText = (paragraph, deletion) => {
|
|
422
|
+
let struck = true;
|
|
423
|
+
paragraph.forEach((node) => {
|
|
424
|
+
if (!node.marks.some((mark) => mark.type === deletion)) struck = false;
|
|
425
|
+
});
|
|
426
|
+
return struck;
|
|
427
|
+
};
|
|
394
428
|
function handleSuggestionTableCellPaste(view, slice, pluginState) {
|
|
395
429
|
const insertionType = view.state.schema.marks["insertion"];
|
|
396
430
|
const deletionType = view.state.schema.marks["deletion"];
|
|
@@ -434,15 +468,25 @@ function handleSuggestionTableCellPaste(view, slice, pluginState) {
|
|
|
434
468
|
});
|
|
435
469
|
}
|
|
436
470
|
const emptyInsertions = [];
|
|
437
|
-
|
|
471
|
+
const struckBreaks = [];
|
|
472
|
+
tr.doc.nodeAt(cellPos)?.forEach((node, offset, index) => {
|
|
438
473
|
const pos = cellPos + 1 + offset;
|
|
439
|
-
if (pos
|
|
474
|
+
if (pos >= pastedFrom || node.type.name !== "paragraph" || !isCurrentAuthorParagraphInsertion(node.attrs["pPrMark"], pluginState.author)) return;
|
|
475
|
+
if (node.content.size === 0) emptyInsertions.push({
|
|
440
476
|
from: pos,
|
|
441
477
|
to: pos + node.nodeSize
|
|
442
478
|
});
|
|
479
|
+
else if (holdsOnlyStruckText(node, deletionType) && isCurrentAuthorParagraphInsertion(cell.maybeChild(index)?.attrs["pPrMark"], pluginState.author)) struckBreaks.push(pos + node.nodeSize);
|
|
443
480
|
});
|
|
444
481
|
const retraction = tr.mapping.maps.length;
|
|
445
482
|
for (const range of emptyInsertions.toReversed()) tr.delete(range.from, range.to);
|
|
483
|
+
for (const boundary of struckBreaks.toReversed()) {
|
|
484
|
+
const at = tr.mapping.slice(retraction).map(boundary);
|
|
485
|
+
const { nodeBefore, nodeAfter } = tr.doc.resolve(at);
|
|
486
|
+
if (nodeBefore?.type.name !== "paragraph" || !nodeAfter) continue;
|
|
487
|
+
tr.setNodeMarkup(at - nodeBefore.nodeSize, void 0, nodeAfter.attrs);
|
|
488
|
+
tr.join(at);
|
|
489
|
+
}
|
|
446
490
|
const retracted = tr.mapping.slice(retraction);
|
|
447
491
|
pastedFrom = retracted.map(pastedFrom);
|
|
448
492
|
insertTo = retracted.map(insertTo);
|
|
@@ -686,7 +730,7 @@ function caretDeleteTarget(state, direction) {
|
|
|
686
730
|
while (cursor >= $from.start() && cursor <= $from.end()) {
|
|
687
731
|
const adjacent = backward ? state.doc.resolve(cursor).nodeBefore : state.doc.resolve(cursor).nodeAfter;
|
|
688
732
|
if (!adjacent) return { type: "paragraphEdge" };
|
|
689
|
-
if (adjacent
|
|
733
|
+
if (!isInlineAnchor(adjacent) && !adjacent.marks.some((mark) => mark.type === state.schema.marks["deletion"])) {
|
|
690
734
|
const size = adjacent.isAtom && !adjacent.isText ? adjacent.nodeSize : 1;
|
|
691
735
|
return {
|
|
692
736
|
type: "inlineUnit",
|
|
@@ -797,7 +841,7 @@ function isCurrentAuthorParagraphInsertion(value, author) {
|
|
|
797
841
|
/**
|
|
798
842
|
* Handle delete (forward or backward) in suggestion mode.
|
|
799
843
|
*/
|
|
800
|
-
function handleSuggestionDelete(state, dispatch, direction) {
|
|
844
|
+
function handleSuggestionDelete(state, dispatch, direction, { cut = false } = {}) {
|
|
801
845
|
const pluginState = suggestionModeKey.getState(state);
|
|
802
846
|
if (!pluginState?.active) return false;
|
|
803
847
|
const { $from, $to, empty } = state.selection;
|
|
@@ -813,8 +857,11 @@ function handleSuggestionDelete(state, dispatch, direction) {
|
|
|
813
857
|
to: rangeTo.pos
|
|
814
858
|
}).sort((a, b) => b.from - a.from);
|
|
815
859
|
for (const { from, to } of ranges) markRangeAsDeleted(tr, state.doc, from, to, deletionType, pluginState, state);
|
|
816
|
-
if (state.selection instanceof CellSelection) tr.setSelection(state.selection.map(tr.doc, tr.mapping));
|
|
817
|
-
else {
|
|
860
|
+
if (state.selection instanceof CellSelection && !cut) tr.setSelection(state.selection.map(tr.doc, tr.mapping));
|
|
861
|
+
else if (state.selection instanceof CellSelection) {
|
|
862
|
+
const caret = Selection.findFrom(tr.doc.resolve(tr.mapping.map(state.selection.to)), -1);
|
|
863
|
+
if (caret) tr.setSelection(caret);
|
|
864
|
+
} else {
|
|
818
865
|
const cursorPos = tr.mapping.map($to.pos);
|
|
819
866
|
tr.setSelection(TextSelection.near(tr.doc.resolve(cursorPos)));
|
|
820
867
|
}
|
|
@@ -858,12 +905,35 @@ function handleSuggestionDelete(state, dispatch, direction) {
|
|
|
858
905
|
return true;
|
|
859
906
|
}
|
|
860
907
|
/** Apply the editor's selected-content deletion path for a host cut action. */
|
|
861
|
-
const deleteSelectionAsSuggestion = (state, dispatch) => state.selection.empty ? false : handleSuggestionDelete(state, dispatch, "forward");
|
|
862
|
-
|
|
908
|
+
const deleteSelectionAsSuggestion = (state, dispatch) => state.selection.empty ? false : handleSuggestionDelete(state, dispatch, "forward", { cut: true });
|
|
909
|
+
/**
|
|
910
|
+
* PM reads the removal of cancelled text back from the DOM, which can take the
|
|
911
|
+
* text around it along and drop its revision marks. The same text was there when
|
|
912
|
+
* the composition started: put back what it was.
|
|
913
|
+
*/
|
|
914
|
+
function restoreAfterCancelledComposition(view, startDoc) {
|
|
915
|
+
const { doc } = view.state;
|
|
916
|
+
const start = startDoc.content.findDiffStart(doc.content);
|
|
917
|
+
const end = startDoc.content.findDiffEnd(doc.content);
|
|
918
|
+
if (start === null || end === null) return;
|
|
919
|
+
if (end.a !== end.b || end.a <= start || startDoc.textBetween(start, end.a, "\n", "\n") !== doc.textBetween(start, end.a, "\n", "\n")) return;
|
|
920
|
+
const tr = view.state.tr.replace(start, end.a, startDoc.slice(start, end.a));
|
|
921
|
+
tr.setMeta(SUGGESTION_META, true);
|
|
922
|
+
tr.setMeta("addToHistory", false);
|
|
923
|
+
view.dispatch(tr);
|
|
924
|
+
}
|
|
925
|
+
function markComposedAsInsertion({ view, from, startDoc, foreignSize, foreignEdit, pluginState, replaced, compositionId }) {
|
|
863
926
|
const insertionType = view.state.schema.marks["insertion"];
|
|
864
927
|
const deletionType = view.state.schema.marks["deletion"];
|
|
865
928
|
if (!insertionType || !deletionType) return;
|
|
866
|
-
const
|
|
929
|
+
const { doc } = view.state;
|
|
930
|
+
const composedSize = doc.content.size - startDoc.content.size - foreignSize + (replaced?.size ?? 0);
|
|
931
|
+
const to = Math.min(from + composedSize, view.state.selection.to);
|
|
932
|
+
if (doc.eq(startDoc)) return;
|
|
933
|
+
if (composedSize === 0 && !replaced) {
|
|
934
|
+
if (!foreignEdit) restoreAfterCancelledComposition(view, startDoc);
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
867
937
|
if (to <= from && !replaced) return;
|
|
868
938
|
const tr = view.state.tr;
|
|
869
939
|
tr.setMeta(SUGGESTION_META, true);
|
|
@@ -907,15 +977,24 @@ function recordSplitParagraph(tr, before, step, insertedFrom, insertedTo, attrs)
|
|
|
907
977
|
if ($last.parent.type.name === "paragraph") lastPos = $last.before();
|
|
908
978
|
else if ($last.nodeBefore?.type.name === "paragraph") lastPos = insertedTo - $last.nodeBefore.nodeSize;
|
|
909
979
|
if ($first.parent.type.name !== "paragraph" || lastPos === null || lastPos === $first.before()) return;
|
|
980
|
+
const revision = {
|
|
981
|
+
id: attrs.revisionId,
|
|
982
|
+
author: attrs.author,
|
|
983
|
+
date: attrs.date
|
|
984
|
+
};
|
|
985
|
+
const { pPrMark } = expectParagraphAttrs(split);
|
|
986
|
+
if (pPrMark) {
|
|
987
|
+
tr.setNodeAttribute(lastPos, "pPrMark", pPrMark);
|
|
988
|
+
tr.setNodeAttribute($first.before(), "pPrMark", {
|
|
989
|
+
kind: "ins",
|
|
990
|
+
info: revision
|
|
991
|
+
});
|
|
992
|
+
}
|
|
910
993
|
recordReplacedParagraphProperties({
|
|
911
994
|
tr,
|
|
912
995
|
position: lastPos,
|
|
913
996
|
replaced: split,
|
|
914
|
-
revision
|
|
915
|
-
id: attrs.revisionId,
|
|
916
|
-
author: attrs.author,
|
|
917
|
-
date: attrs.date
|
|
918
|
-
}
|
|
997
|
+
revision
|
|
919
998
|
});
|
|
920
999
|
}
|
|
921
1000
|
/**
|
|
@@ -950,6 +1029,62 @@ function restoreReplacedInline({ tr, replaced, deletionType, pluginState }) {
|
|
|
950
1029
|
markRangeAsDeleted(tr, tr.doc, pos, pos + content.size, deletionType, pluginState);
|
|
951
1030
|
}
|
|
952
1031
|
}
|
|
1032
|
+
const readableContent = (content) => content.textBetween(0, content.size, "", "");
|
|
1033
|
+
/**
|
|
1034
|
+
* The inline content a step puts in place of a selection, or null for block
|
|
1035
|
+
* content. Between containers, the step also carries the text after the
|
|
1036
|
+
* selection over into the first one, and fills out what it cut with empty blocks.
|
|
1037
|
+
*/
|
|
1038
|
+
const insertedInline = (step, $to, to) => {
|
|
1039
|
+
const { content } = step.slice;
|
|
1040
|
+
let inline = content;
|
|
1041
|
+
while (inline.firstChild && !inline.firstChild.isInline) inline = inline.firstChild.content;
|
|
1042
|
+
if (readableContent(inline) !== readableContent(content)) return null;
|
|
1043
|
+
if (step.to === to || step instanceof ReplaceAroundStep) return inline;
|
|
1044
|
+
const tail = $to.parent.content.cut($to.parentOffset);
|
|
1045
|
+
const kept = inline.size - tail.size;
|
|
1046
|
+
return kept >= 0 && inline.cut(kept).eq(tail) ? inline.cut(0, kept) : null;
|
|
1047
|
+
};
|
|
1048
|
+
/**
|
|
1049
|
+
* A transaction the plugin did not build (a key binding, a command) replacing a
|
|
1050
|
+
* selection that spans textblocks. Null for anything else: table structure and
|
|
1051
|
+
* block content have their own paths, and a replacement inside one textblock
|
|
1052
|
+
* is `replacedInline`'s.
|
|
1053
|
+
*/
|
|
1054
|
+
function spanningReplacement(oldState, userTr) {
|
|
1055
|
+
const [step] = userTr.steps;
|
|
1056
|
+
const { doc, selection } = oldState;
|
|
1057
|
+
if (userTr.steps.length !== 1 || !(step instanceof ReplaceStep || step instanceof ReplaceAroundStep) || userTr.before !== doc || selection.empty) return null;
|
|
1058
|
+
const selectsAll = selection instanceof AllSelection;
|
|
1059
|
+
const from = selectsAll ? Selection.atStart(doc).from : selection.from;
|
|
1060
|
+
const to = selectsAll ? Selection.atEnd(doc).to : selection.to;
|
|
1061
|
+
const $from = doc.resolve(from);
|
|
1062
|
+
const $to = doc.resolve(to);
|
|
1063
|
+
if (!$from.parent.inlineContent || !$to.parent.inlineContent || $from.sameParent($to) || step.from > from || step.to < to || step instanceof ReplaceAroundStep && step.gapFrom < to) return null;
|
|
1064
|
+
const inserted = insertedInline(step, $to, to);
|
|
1065
|
+
return inserted && {
|
|
1066
|
+
step,
|
|
1067
|
+
from,
|
|
1068
|
+
to,
|
|
1069
|
+
inserted
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Put the document back and make the same replacement as typing over the
|
|
1074
|
+
* selection does: the selected text is struck and what replaced it follows, so
|
|
1075
|
+
* rejecting restores the source and accepting matches the direct edit.
|
|
1076
|
+
*/
|
|
1077
|
+
function trackSpanningReplacement({ tr, oldState, replacement: { step, from, to, inserted }, insertionType, deletionType, pluginState }) {
|
|
1078
|
+
tr.step(step.invert(oldState.doc));
|
|
1079
|
+
const restored = tr.mapping.maps.length;
|
|
1080
|
+
markRangeAsDeleted(tr, tr.doc, from, to, deletionType, pluginState, oldState);
|
|
1081
|
+
const at = tr.mapping.slice(restored).map(to);
|
|
1082
|
+
tr.insert(at, inserted);
|
|
1083
|
+
const end = at + inserted.size;
|
|
1084
|
+
tr.removeMark(at, end, deletionType);
|
|
1085
|
+
markRangeAsInserted(tr, tr.doc, at, end, insertionType, deletionType, makeMarkAttrs(pluginState));
|
|
1086
|
+
tr.setSelection(TextSelection.near(tr.doc.resolve(end), -1));
|
|
1087
|
+
}
|
|
953
1088
|
/**
|
|
954
1089
|
* Create the suggestion mode plugin.
|
|
955
1090
|
* When active, text edits become tracked changes.
|
|
@@ -957,6 +1092,9 @@ function restoreReplacedInline({ tr, replaced, deletionType, pluginState }) {
|
|
|
957
1092
|
function createSuggestionModePlugin(initialActive = false, author = "User") {
|
|
958
1093
|
let composing = false;
|
|
959
1094
|
let compositionFrom = null;
|
|
1095
|
+
let compositionStartDoc = null;
|
|
1096
|
+
let compositionForeignSize = 0;
|
|
1097
|
+
let compositionForeignEdit = false;
|
|
960
1098
|
let compositionReplaced = null;
|
|
961
1099
|
let compositionId = null;
|
|
962
1100
|
return new Plugin({
|
|
@@ -972,6 +1110,11 @@ function createSuggestionModePlugin(initialActive = false, author = "User") {
|
|
|
972
1110
|
apply(tr, state) {
|
|
973
1111
|
const nativeCompositionId = tr.getMeta("composition");
|
|
974
1112
|
if (composing && tr.docChanged && typeof nativeCompositionId === "number") compositionId = nativeCompositionId;
|
|
1113
|
+
if (composing && tr.docChanged && tr.getMeta("y-sync$") !== void 0) {
|
|
1114
|
+
compositionForeignEdit = true;
|
|
1115
|
+
compositionForeignSize += tr.doc.content.size - tr.before.content.size;
|
|
1116
|
+
if (compositionFrom !== null) compositionFrom = tr.mapping.map(compositionFrom);
|
|
1117
|
+
}
|
|
975
1118
|
const meta = tr.getMeta(suggestionModeKey);
|
|
976
1119
|
if (meta) return {
|
|
977
1120
|
...state,
|
|
@@ -991,7 +1134,7 @@ function createSuggestionModePlugin(initialActive = false, author = "User") {
|
|
|
991
1134
|
data.setData("text/html", dom.innerHTML);
|
|
992
1135
|
data.setData("text/plain", text);
|
|
993
1136
|
event.preventDefault();
|
|
994
|
-
return handleSuggestionDelete(view.state, view.dispatch, "forward");
|
|
1137
|
+
return handleSuggestionDelete(view.state, view.dispatch, "forward", { cut: true });
|
|
995
1138
|
},
|
|
996
1139
|
compositionstart(view) {
|
|
997
1140
|
if (!suggestionModeKey.getState(view.state)?.active) return false;
|
|
@@ -1000,16 +1143,21 @@ function createSuggestionModePlugin(initialActive = false, author = "User") {
|
|
|
1000
1143
|
compositionId = null;
|
|
1001
1144
|
const { from, to } = view.state.selection;
|
|
1002
1145
|
compositionFrom = from;
|
|
1146
|
+
compositionStartDoc = view.state.doc;
|
|
1147
|
+
compositionForeignSize = 0;
|
|
1148
|
+
compositionForeignEdit = false;
|
|
1003
1149
|
compositionReplaced = from === to ? null : view.state.doc.slice(from, to);
|
|
1004
1150
|
return false;
|
|
1005
1151
|
},
|
|
1006
1152
|
compositionend(view) {
|
|
1007
1153
|
const pluginState = suggestionModeKey.getState(view.state);
|
|
1008
1154
|
const from = compositionFrom;
|
|
1155
|
+
const startDoc = compositionStartDoc;
|
|
1009
1156
|
const replaced = compositionReplaced;
|
|
1010
1157
|
compositionFrom = null;
|
|
1158
|
+
compositionStartDoc = null;
|
|
1011
1159
|
compositionReplaced = null;
|
|
1012
|
-
if (!pluginState?.active || from == null) {
|
|
1160
|
+
if (!pluginState?.active || from == null || !startDoc) {
|
|
1013
1161
|
composing = false;
|
|
1014
1162
|
compositionId = null;
|
|
1015
1163
|
return false;
|
|
@@ -1021,6 +1169,9 @@ function createSuggestionModePlugin(initialActive = false, author = "User") {
|
|
|
1021
1169
|
if (current?.active) markComposedAsInsertion({
|
|
1022
1170
|
view,
|
|
1023
1171
|
from,
|
|
1172
|
+
startDoc,
|
|
1173
|
+
foreignSize: compositionForeignSize,
|
|
1174
|
+
foreignEdit: compositionForeignEdit,
|
|
1024
1175
|
pluginState: current,
|
|
1025
1176
|
replaced,
|
|
1026
1177
|
compositionId: nativeCompositionId
|
|
@@ -1040,6 +1191,7 @@ function createSuggestionModePlugin(initialActive = false, author = "User") {
|
|
|
1040
1191
|
handleKeyDown(view, event) {
|
|
1041
1192
|
const pluginState = suggestionModeKey.getState(view.state);
|
|
1042
1193
|
if (!pluginState?.active) return false;
|
|
1194
|
+
if (composing) return false;
|
|
1043
1195
|
if (selectLockedInlineControl(view, event)) return true;
|
|
1044
1196
|
if (event.key === "Enter" && !event.shiftKey && !event.metaKey && !event.ctrlKey && !event.altKey) {
|
|
1045
1197
|
const { $from, empty } = view.state.selection;
|
|
@@ -1049,8 +1201,9 @@ function createSuggestionModePlugin(initialActive = false, author = "User") {
|
|
|
1049
1201
|
if (event.key === "Backspace" && undoInputRule(view.state, view.dispatch)) return true;
|
|
1050
1202
|
if (event.key === "Backspace" || event.key === "Delete") {
|
|
1051
1203
|
const { $from, empty } = view.state.selection;
|
|
1052
|
-
|
|
1053
|
-
if (event.
|
|
1204
|
+
const atListItemStart = event.key === "Backspace" && empty && $from.parentOffset === 0 && $from.parent.type.name === "paragraph" && expectParagraphAttrs($from.parent).numPr?.kind === "reference";
|
|
1205
|
+
if (atListItemStart && !event.ctrlKey && !event.metaKey && !event.shiftKey) return false;
|
|
1206
|
+
if (event.key === "Backspace" && !atListItemStart && clearIndentOnBackspace(view.state, (tr) => {
|
|
1054
1207
|
const revision = makeMarkAttrs(pluginState);
|
|
1055
1208
|
recordReplacedParagraphProperties({
|
|
1056
1209
|
tr,
|
|
@@ -1083,7 +1236,7 @@ function createSuggestionModePlugin(initialActive = false, author = "User") {
|
|
|
1083
1236
|
return handleSuggestionTableCellPaste(view, slice, pluginState) || handleSuggestionPaste(view, slice, pluginState);
|
|
1084
1237
|
}
|
|
1085
1238
|
},
|
|
1086
|
-
appendTransaction(transactions,
|
|
1239
|
+
appendTransaction(transactions, oldState, newState) {
|
|
1087
1240
|
const pluginState = suggestionModeKey.getState(newState);
|
|
1088
1241
|
if (!pluginState?.active) return null;
|
|
1089
1242
|
if (composing) return null;
|
|
@@ -1097,6 +1250,18 @@ function createSuggestionModePlugin(initialActive = false, author = "User") {
|
|
|
1097
1250
|
const deletionType = newState.schema.marks["deletion"];
|
|
1098
1251
|
const laterMaps = transactions.slice(transactions.indexOf(userTr) + 1).flatMap((transaction) => transaction.mapping.maps);
|
|
1099
1252
|
const restoresReplaced = userTr.getMeta("appendedTransaction") === void 0;
|
|
1253
|
+
const spanning = deletionType && restoresReplaced && newState.doc === userTr.doc ? spanningReplacement(oldState, userTr) : null;
|
|
1254
|
+
if (deletionType && spanning) {
|
|
1255
|
+
trackSpanningReplacement({
|
|
1256
|
+
tr,
|
|
1257
|
+
oldState,
|
|
1258
|
+
replacement: spanning,
|
|
1259
|
+
insertionType,
|
|
1260
|
+
deletionType,
|
|
1261
|
+
pluginState
|
|
1262
|
+
});
|
|
1263
|
+
return tr;
|
|
1264
|
+
}
|
|
1100
1265
|
const replaced = [];
|
|
1101
1266
|
for (const [stepIndex, step] of userTr.steps.entries()) {
|
|
1102
1267
|
const stepMap = step.getMap();
|
|
@@ -78,6 +78,21 @@ const FIELD_PATH_HEAD_RE = /^[\p{L}_]/u;
|
|
|
78
78
|
* keeps a real expression on exact matching.
|
|
79
79
|
*/
|
|
80
80
|
const filterChainPath = ({ conditionPath }) => conditionPath !== void 0 && isFieldPath(conditionPath) && FIELD_PATH_HEAD_RE.test(conditionPath) ? conditionPath : void 0;
|
|
81
|
+
const isPreviewSpan = (span) => typeof span === "object" && span !== null && typeof Reflect.get(span, "text") === "string";
|
|
82
|
+
/**
|
|
83
|
+
* The value stored under one key, read like {@link ownVerdict}: only a key the
|
|
84
|
+
* host set itself, holding text or a list of text spans, counts. A marker named
|
|
85
|
+
* after an inherited property (`constructor`) or holding a malformed value
|
|
86
|
+
* keeps its authored text.
|
|
87
|
+
*/
|
|
88
|
+
const ownPreviewValue = (values, key) => {
|
|
89
|
+
if (!Object.hasOwn(values, key)) return;
|
|
90
|
+
const value = values[key];
|
|
91
|
+
if (typeof value === "string") return value;
|
|
92
|
+
if (typeof value !== "object" || value === null) return;
|
|
93
|
+
const runs = Reflect.get(value, "runs");
|
|
94
|
+
return Array.isArray(runs) && runs.every(isPreviewSpan) ? { runs } : void 0;
|
|
95
|
+
};
|
|
81
96
|
/**
|
|
82
97
|
* The verdict stored under one key. Only a key the host set itself, holding a
|
|
83
98
|
* real boolean, counts: an inherited property (`constructor`, or a boolean the
|
|
@@ -189,7 +204,7 @@ function collectPreviewEntries(ranges, values, hidden) {
|
|
|
189
204
|
const entries = [];
|
|
190
205
|
for (const range of ranges) {
|
|
191
206
|
if (range.kind !== "placeholder" && range.kind !== "clause") continue;
|
|
192
|
-
const value = values
|
|
207
|
+
const value = ownPreviewValue(values, range.expr);
|
|
193
208
|
if (value === void 0 || templatePreviewValueText(value) === "") continue;
|
|
194
209
|
if (hidden.some((block) => range.from >= block.from && range.from < block.to)) continue;
|
|
195
210
|
entries.push({
|
|
@@ -6,7 +6,7 @@ import { paragraphRunStyleContext } from "./runStyleFormatting.js";
|
|
|
6
6
|
import { Mark } from "prosemirror-model";
|
|
7
7
|
// src/prosemirror/rebaseParagraphRuns.ts
|
|
8
8
|
/** Two contexts that lend runs the same formatting: rebasing between them changes nothing. */
|
|
9
|
-
const sameRunStyleContext = (source, target) =>
|
|
9
|
+
const sameRunStyleContext = (source, target) => formattingEquals(source.baseParagraphFormatting, target.baseParagraphFormatting) && formattingEquals(source.paragraphFormatting, target.paragraphFormatting) && formattingEquals(source.paragraphMarkFormatting, target.paragraphMarkFormatting);
|
|
10
10
|
/** Rebuild rendered marks after the paragraph's style cascade changes. */
|
|
11
11
|
const rebaseParagraphRuns = ({ tr, position, previous, target, styleResolver, range, storedMarks: initialStoredMarks }) => {
|
|
12
12
|
const paragraph = tr.doc.nodeAt(position);
|
|
@@ -147,6 +147,7 @@ const createResolvedCommentPointCollector = ({ removes, retiresStructure }) => {
|
|
|
147
147
|
const removedWithStructure = removedStructures.some(({ from, to }) => position > from && position < to);
|
|
148
148
|
for (const mark of node.marks) {
|
|
149
149
|
if (mark.type.name !== "comment") continue;
|
|
150
|
+
if (mark.attrs["point"] === true) continue;
|
|
150
151
|
const id = mark.attrs["commentId"];
|
|
151
152
|
if (!removedWithStructure && !removes(node, position)) retained.add(id);
|
|
152
153
|
else if (!points.has(id)) points.set(id, position);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
/**
|
|
3
|
+
* What a row omits, as its placeholders hold it now: column edits move them, and
|
|
4
|
+
* the formatting the row was read with goes stale. Before its cells, this is
|
|
5
|
+
* what places them. After them it stays a statement of no more than the row
|
|
6
|
+
* omits: the row may stop short of the table by more than it states.
|
|
7
|
+
*/
|
|
8
|
+
export declare const rowGridOmissions: (row: Node, statedAfter: number) => {
|
|
9
|
+
gridBefore: number;
|
|
10
|
+
gridAfter: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/prosemirror/rowGridOmissions.ts
|
|
2
|
+
/**
|
|
3
|
+
* What a row omits, as its placeholders hold it now: column edits move them, and
|
|
4
|
+
* the formatting the row was read with goes stale. Before its cells, this is
|
|
5
|
+
* what places them. After them it stays a statement of no more than the row
|
|
6
|
+
* omits: the row may stop short of the table by more than it states.
|
|
7
|
+
*/
|
|
8
|
+
const rowGridOmissions = (row, statedAfter) => {
|
|
9
|
+
let before = 0;
|
|
10
|
+
let after = 0;
|
|
11
|
+
row.forEach((cell) => {
|
|
12
|
+
const colspan = Number(cell.attrs["colspan"]) || 1;
|
|
13
|
+
if (cell.attrs["_omittedGridSlot"] === "before") before += colspan;
|
|
14
|
+
if (cell.attrs["_omittedGridSlot"] === "after") after += colspan;
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
gridBefore: before,
|
|
18
|
+
gridAfter: Math.min(statedAfter, after)
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export { rowGridOmissions };
|
|
@@ -9,7 +9,6 @@ export type MarksToTextFormattingOptions = {
|
|
|
9
9
|
baseParagraphFormatting?: document_d_exports.TextFormatting | undefined;
|
|
10
10
|
inheritedFormatting?: document_d_exports.TextFormatting | undefined;
|
|
11
11
|
paragraphMarkFormatting?: document_d_exports.TextFormatting | undefined;
|
|
12
|
-
paragraphMarkPrecedesStyle?: boolean | undefined;
|
|
13
12
|
styleResolver?: RunStyleResolver | null | undefined;
|
|
14
13
|
};
|
|
15
14
|
/** Overlay only changed visual marks; private authored properties stay with the run. */
|
|
@@ -533,8 +533,7 @@ function marksToTextFormatting(marks, options) {
|
|
|
533
533
|
const runContext = {
|
|
534
534
|
baseParagraphFormatting: options?.baseParagraphFormatting,
|
|
535
535
|
paragraphFormatting: options?.inheritedFormatting,
|
|
536
|
-
paragraphMarkFormatting: options?.paragraphMarkFormatting
|
|
537
|
-
paragraphMarkPrecedesStyle: options?.paragraphMarkPrecedesStyle ?? false
|
|
536
|
+
paragraphMarkFormatting: options?.paragraphMarkFormatting
|
|
538
537
|
};
|
|
539
538
|
const paragraphFormatting = paragraphFormattingForRun({
|
|
540
539
|
context: runContext,
|
|
@@ -557,8 +556,7 @@ function marksToTextFormatting(marks, options) {
|
|
|
557
556
|
const suppressedParagraphFormatting = suppressParagraphMarkFormatting({
|
|
558
557
|
baseFormatting: options.baseParagraphFormatting,
|
|
559
558
|
directFormatting: authoredFormatting,
|
|
560
|
-
paragraphMarkFormatting: options.paragraphMarkFormatting
|
|
561
|
-
paragraphMarkPrecedesStyle: options.paragraphMarkPrecedesStyle ?? false
|
|
559
|
+
paragraphMarkFormatting: options.paragraphMarkFormatting
|
|
562
560
|
});
|
|
563
561
|
const suppressedInheritedFormatting = resolveEffectiveRunStyleFormatting({
|
|
564
562
|
marks,
|
|
@@ -12,7 +12,6 @@ const readAuthoredRunFormatting = ({ context, marks, styleResolver }) => marksTo
|
|
|
12
12
|
baseParagraphFormatting: context.baseParagraphFormatting,
|
|
13
13
|
inheritedFormatting: context.paragraphFormatting,
|
|
14
14
|
paragraphMarkFormatting: context.paragraphMarkFormatting,
|
|
15
|
-
paragraphMarkPrecedesStyle: context.paragraphMarkPrecedesStyle,
|
|
16
15
|
...styleResolver !== void 0 ? { styleResolver } : {}
|
|
17
16
|
});
|
|
18
17
|
/** Preserve the authored distinction between an absent and empty property set in revisions. */
|
|
@@ -49,7 +48,8 @@ const reconcileRunFormattingMarks = ({ authoredFormatting, context, node, styleR
|
|
|
49
48
|
const paragraphMarkOverrides = isParagraphMarkSuppressionEligible(authoredFormatting) ? getParagraphMarkSuppressionOverrides({
|
|
50
49
|
directFormatting: authoredFormatting,
|
|
51
50
|
paragraphMarkFormatting: context.paragraphMarkFormatting,
|
|
52
|
-
suppressedFormatting: paragraphFormatting
|
|
51
|
+
suppressedFormatting: paragraphFormatting,
|
|
52
|
+
characterStyleFormatting: authoredFormatting.styleId === void 0 ? void 0 : styleResolver?.getRunStyleOwnProperties(authoredFormatting.styleId) ?? void 0
|
|
53
53
|
}) : void 0;
|
|
54
54
|
const overrideFormatting = mergeTextFormatting(paragraphMarkOverrides, authoredFormatting);
|
|
55
55
|
const formattingMarks = textFormattingToMarks(effectiveFormatting, node.type.schema, {
|
|
@@ -36,8 +36,7 @@ const restoreHistoricalRunFormatting = ({ node, paragraphContext, styleResolver
|
|
|
36
36
|
context: {
|
|
37
37
|
baseParagraphFormatting: paragraphContext.baseParagraphFormatting,
|
|
38
38
|
paragraphFormatting: paragraphContext.baseParagraphFormatting,
|
|
39
|
-
paragraphMarkFormatting: void 0
|
|
40
|
-
paragraphMarkPrecedesStyle: false
|
|
39
|
+
paragraphMarkFormatting: void 0
|
|
41
40
|
},
|
|
42
41
|
marks: node.marks,
|
|
43
42
|
...styleResolver !== void 0 ? { styleResolver } : {}
|
|
@@ -7,25 +7,35 @@ export declare const hasDirectRunFormatting: (formatting: document_d_exports.Tex
|
|
|
7
7
|
/** A stated run property or character style establishes paragraph-mark suppression. */
|
|
8
8
|
export declare const isParagraphMarkSuppressionEligible: (formatting: document_d_exports.TextFormatting | undefined) => boolean;
|
|
9
9
|
export declare const stripParagraphMarkOnlyFormatting: (formatting: document_d_exports.TextFormatting) => document_d_exports.TextFormatting | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Whether a paragraph's mark lends its run properties to the paragraph's
|
|
12
|
+
* runs: only when the paragraph has no style. One rule for reading a run and
|
|
13
|
+
* for the save's view of what a run inherited.
|
|
14
|
+
*/
|
|
15
|
+
export declare const paragraphMarkLendsRuns: (styleId: string | undefined) => boolean;
|
|
10
16
|
export declare const stripParagraphMarkFormattingForBodyRuns: (formatting: document_d_exports.TextFormatting) => document_d_exports.TextFormatting | undefined;
|
|
11
17
|
type SuppressParagraphMarkFormattingOptions = {
|
|
12
18
|
baseFormatting: document_d_exports.TextFormatting | undefined;
|
|
13
19
|
directFormatting: document_d_exports.TextFormatting | undefined;
|
|
14
20
|
paragraphMarkFormatting: document_d_exports.TextFormatting | undefined;
|
|
15
|
-
paragraphMarkPrecedesStyle?: boolean;
|
|
16
21
|
};
|
|
17
|
-
export declare const suppressParagraphMarkFormatting: ({ baseFormatting, directFormatting, paragraphMarkFormatting
|
|
22
|
+
export declare const suppressParagraphMarkFormatting: ({ baseFormatting, directFormatting, paragraphMarkFormatting }: SuppressParagraphMarkFormattingOptions) => document_d_exports.TextFormatting | undefined;
|
|
18
23
|
type GetParagraphMarkSuppressionOverridesOptions = {
|
|
19
24
|
directFormatting: document_d_exports.TextFormatting | undefined;
|
|
20
25
|
paragraphMarkFormatting: document_d_exports.TextFormatting | undefined;
|
|
21
26
|
suppressedFormatting: document_d_exports.TextFormatting | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The run's own character style. A property it states is the style's to
|
|
29
|
+
* give, not the paragraph mark's to take away: the run keeps it as the
|
|
30
|
+
* style cascade resolves it, with no override saying it is off.
|
|
31
|
+
*/
|
|
32
|
+
characterStyleFormatting: document_d_exports.TextFormatting | undefined;
|
|
22
33
|
};
|
|
23
|
-
export declare const getParagraphMarkSuppressionOverrides: ({ directFormatting, paragraphMarkFormatting, suppressedFormatting }: GetParagraphMarkSuppressionOverridesOptions) => document_d_exports.TextFormatting | undefined;
|
|
34
|
+
export declare const getParagraphMarkSuppressionOverrides: ({ directFormatting, paragraphMarkFormatting, suppressedFormatting, characterStyleFormatting }: GetParagraphMarkSuppressionOverridesOptions) => document_d_exports.TextFormatting | undefined;
|
|
24
35
|
export type ParagraphRunStyleContext = {
|
|
25
36
|
baseParagraphFormatting: document_d_exports.TextFormatting | undefined;
|
|
26
37
|
paragraphFormatting: document_d_exports.TextFormatting | undefined;
|
|
27
38
|
paragraphMarkFormatting: document_d_exports.TextFormatting | undefined;
|
|
28
|
-
paragraphMarkPrecedesStyle: boolean;
|
|
29
39
|
};
|
|
30
40
|
export type RunStyleResolver = Pick<StyleEngine, "builtInStyles" | "getDefaultCharacterStyle" | "getDefaultParagraphStyle" | "getDocDefaults" | "getRunStyleOwnProperties" | "getStyle" | "resolveParagraphStyle">;
|
|
31
41
|
type ResolveParagraphBodyRunFormattingOptions = {
|