@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
|
@@ -4,12 +4,13 @@ import { bookmarkMarkerFromAttrs, readBookmarkBoundaryAttrs } from "../prosemirr
|
|
|
4
4
|
import { readCommentRangeBoundaryAttrs } from "../prosemirror/commentRangeBoundaryAttrs.js";
|
|
5
5
|
import { HYPHEN_TEXT_CARRIERS } from "../prosemirror/conversion/hyphenTextCarriers.js";
|
|
6
6
|
import "../prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js";
|
|
7
|
+
import "../prosemirror/extensions/nodes/RenderedPageBreakExtension.js";
|
|
7
8
|
import { readMoveRangeBoundaryAttrs } from "../prosemirror/moveRangeBoundaryAttrs.js";
|
|
8
9
|
import { readRangeAnchorAttrs } from "../prosemirror/rangeAnchorAttrs.js";
|
|
9
10
|
import { PRESERVED_XML_LEVELS } from "../prosemirror/schema/nodes.js";
|
|
10
11
|
import { Result, TaggedError, panic } from "better-result";
|
|
11
12
|
import { hasIllegalXmlCharacters } from "@stll/docx-core";
|
|
12
|
-
import { inlineLeafSpans, paragraphLogicalText } from "@stll/docx-core/ops";
|
|
13
|
+
import { defaultInsertionGap, inlineLeafSpans, paragraphLogicalText } from "@stll/docx-core/ops";
|
|
13
14
|
// src/controller/canonicalInlineProjection.ts
|
|
14
15
|
const CANONICAL_SOURCE_INLINE_POLICIES = {
|
|
15
16
|
run: "container",
|
|
@@ -19,7 +20,7 @@ const CANONICAL_SOURCE_INLINE_POLICIES = {
|
|
|
19
20
|
moveFrom: "container",
|
|
20
21
|
moveTo: "container",
|
|
21
22
|
inlineWrapper: "container",
|
|
22
|
-
inlineSdt: "
|
|
23
|
+
inlineSdt: "container",
|
|
23
24
|
simpleField: "leaf",
|
|
24
25
|
complexField: "leaf",
|
|
25
26
|
mathEquation: "leaf",
|
|
@@ -44,7 +45,7 @@ const CANONICAL_SOURCE_INLINE_POLICIES = {
|
|
|
44
45
|
instrText: "rawField",
|
|
45
46
|
softHyphen: "leaf",
|
|
46
47
|
noBreakHyphen: "leaf",
|
|
47
|
-
renderedPageBreak: "
|
|
48
|
+
renderedPageBreak: "leaf",
|
|
48
49
|
preservedXml: "leaf",
|
|
49
50
|
drawing: "leaf",
|
|
50
51
|
shape: "leaf"
|
|
@@ -68,8 +69,8 @@ const CANONICAL_NATIVE_INLINE_POLICIES = {
|
|
|
68
69
|
tab: "unit",
|
|
69
70
|
textBoxAnchor: "unit",
|
|
70
71
|
commentReference: "unit",
|
|
71
|
-
renderedPageBreak: "
|
|
72
|
-
sdt: "
|
|
72
|
+
renderedPageBreak: "markers",
|
|
73
|
+
sdt: "control"
|
|
73
74
|
};
|
|
74
75
|
const nativePolicies = new Map(Object.entries(CANONICAL_NATIVE_INLINE_POLICIES));
|
|
75
76
|
const InlineProjectionErrorBase = TaggedError("InlineProjectionError");
|
|
@@ -78,22 +79,13 @@ const refuse = (message) => Result.err(new InlineProjectionError({ message }));
|
|
|
78
79
|
/** Every source variant makes a decision before conversion can discard its positions. */
|
|
79
80
|
const canonicalInlineSourceIssue = (items, context = "paragraph") => {
|
|
80
81
|
for (const item of items) switch (CANONICAL_SOURCE_INLINE_POLICIES[item.type]) {
|
|
81
|
-
case "control":
|
|
82
|
-
if (context === "fieldPayload" && item.type === "inlineSdt") {
|
|
83
|
-
const issue = canonicalInlineSourceIssue(item.content, context);
|
|
84
|
-
if (issue !== null) return issue;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
return "Canonical editing cannot preserve inline content-control boundary positions.";
|
|
88
82
|
case "rawField":
|
|
89
83
|
if (context === "fieldPayload") break;
|
|
90
84
|
return "Canonical editing cannot preserve unstructured field instructions; a structured field is required.";
|
|
91
|
-
case "layout": return "Canonical editing cannot preserve cached rendered page-break positions.";
|
|
92
85
|
case "text":
|
|
93
86
|
if (item.type === "text" && (hasIllegalXmlCharacters(item.text) || /[\t\r\n]/u.test(item.text))) return "Canonical text requires valid XML characters and explicit tab or break elements.";
|
|
94
87
|
break;
|
|
95
88
|
case "container": {
|
|
96
|
-
if ((item.type === "insertion" || item.type === "deletion") && item.resolutionJoins !== void 0 && item.content.some((child) => child.type === "hyperlink")) return "Canonical editing cannot preserve hyperlink wrapper review provenance.";
|
|
97
89
|
const children = sourceContainerChildren(item);
|
|
98
90
|
const issue = canonicalInlineSourceIssue(children, context);
|
|
99
91
|
if (issue !== null) return issue;
|
|
@@ -118,7 +110,8 @@ const sourceContainerChildren = (item) => {
|
|
|
118
110
|
case "deletion":
|
|
119
111
|
case "moveFrom":
|
|
120
112
|
case "moveTo":
|
|
121
|
-
case "inlineWrapper":
|
|
113
|
+
case "inlineWrapper":
|
|
114
|
+
case "inlineSdt": return item.content;
|
|
122
115
|
default: return panic(`Source policy incorrectly classified ${item.type} as a container.`);
|
|
123
116
|
}
|
|
124
117
|
};
|
|
@@ -126,7 +119,7 @@ const sourceContainerChildren = (item) => {
|
|
|
126
119
|
const canonicalNativeCells = (paragraph) => {
|
|
127
120
|
const cells = [];
|
|
128
121
|
let issue;
|
|
129
|
-
|
|
122
|
+
const visit = (node, from) => {
|
|
130
123
|
if (issue !== void 0) return;
|
|
131
124
|
const to = from + node.nodeSize;
|
|
132
125
|
switch (nativePolicies.get(node.type.name)) {
|
|
@@ -185,7 +178,14 @@ const canonicalNativeCells = (paragraph) => {
|
|
|
185
178
|
to,
|
|
186
179
|
node
|
|
187
180
|
});
|
|
188
|
-
} else if (node.type.name === "
|
|
181
|
+
} else if (node.type.name === "renderedPageBreak") cells.push({
|
|
182
|
+
type: "zeroWidth",
|
|
183
|
+
sources: [{ type: "renderedPageBreak" }],
|
|
184
|
+
from,
|
|
185
|
+
to,
|
|
186
|
+
node
|
|
187
|
+
});
|
|
188
|
+
else if (node.type.name === "moveRangeBoundary") {
|
|
189
189
|
const attrs = readMoveRangeBoundaryAttrs(node);
|
|
190
190
|
if (!attrs.ok) {
|
|
191
191
|
issue = "Canonical editing requires valid move-range boundary attributes.";
|
|
@@ -269,6 +269,23 @@ const canonicalNativeCells = (paragraph) => {
|
|
|
269
269
|
});
|
|
270
270
|
return;
|
|
271
271
|
}
|
|
272
|
+
case "control":
|
|
273
|
+
cells.push({
|
|
274
|
+
type: "zeroWidth",
|
|
275
|
+
sources: [],
|
|
276
|
+
from,
|
|
277
|
+
to: from + 1,
|
|
278
|
+
node
|
|
279
|
+
});
|
|
280
|
+
node.forEach((child, offset) => visit(child, from + 1 + offset));
|
|
281
|
+
cells.push({
|
|
282
|
+
type: "zeroWidth",
|
|
283
|
+
sources: [],
|
|
284
|
+
from: to - 1,
|
|
285
|
+
to,
|
|
286
|
+
node
|
|
287
|
+
});
|
|
288
|
+
return;
|
|
272
289
|
case "refused":
|
|
273
290
|
issue = `Canonical editing cannot preserve ${node.type.name} boundary positions.`;
|
|
274
291
|
return;
|
|
@@ -276,7 +293,8 @@ const canonicalNativeCells = (paragraph) => {
|
|
|
276
293
|
issue = `Canonical editing has no position mapping for inline ${node.type.name}.`;
|
|
277
294
|
return;
|
|
278
295
|
}
|
|
279
|
-
}
|
|
296
|
+
};
|
|
297
|
+
paragraph.forEach((node, from) => visit(node, from));
|
|
280
298
|
return issue === void 0 ? Result.ok(cells) : refuse(issue);
|
|
281
299
|
};
|
|
282
300
|
const sameSourceMarker = (left, right) => {
|
|
@@ -290,19 +308,34 @@ const sameSourceMarker = (left, right) => {
|
|
|
290
308
|
case "moveToRangeStart":
|
|
291
309
|
case "moveToRangeEnd": return right.type === left.type && left.id === right.id;
|
|
292
310
|
case "noteMarker": return right.type === "noteMarker" && left.kind === right.kind;
|
|
311
|
+
case "renderedPageBreak": return right.type === "renderedPageBreak";
|
|
293
312
|
case "preservedInline": return right.type === "preservedInline" && left.xml === right.xml && left.text === right.text;
|
|
294
313
|
default: return false;
|
|
295
314
|
}
|
|
296
315
|
};
|
|
316
|
+
/**
|
|
317
|
+
* What each input of a paragraph's projection depends on: the paragraph
|
|
318
|
+
* alone (its source records and its editor node), or the story around it.
|
|
319
|
+
* A cached projection is reused only for the same paragraph inputs, and only
|
|
320
|
+
* where every story fact it read still holds. Total over the inputs: an input
|
|
321
|
+
* added to them does not compile until it is placed in one half or the other.
|
|
322
|
+
*/
|
|
323
|
+
const INLINE_INPUT_DEPENDENCY = {
|
|
324
|
+
source: "paragraph",
|
|
325
|
+
paragraph: "paragraph",
|
|
326
|
+
pairedBookmarkIds: "story",
|
|
327
|
+
commentContext: "story"
|
|
328
|
+
};
|
|
329
|
+
const PARAGRAPH_INPUT_FIELDS = Object.keys(INLINE_INPUT_DEPENDENCY).filter((field) => INLINE_INPUT_DEPENDENCY[field] === "paragraph");
|
|
297
330
|
/** Marks carry nonempty ranges; explicit range anchors carry empty ranges. */
|
|
298
331
|
const commentMarkTransitions = ({ source, paragraph, commentContext, explicitCommentIds }) => {
|
|
299
332
|
const spans = inlineLeafSpans(source.content);
|
|
300
|
-
const
|
|
301
|
-
const
|
|
333
|
+
const ownRangedIds = /* @__PURE__ */ new Set();
|
|
334
|
+
const ownPointIds = /* @__PURE__ */ new Set();
|
|
302
335
|
const finalIds = new Set(commentContext?.openIds);
|
|
303
336
|
for (const { node } of spans) {
|
|
304
|
-
if (node.type === "commentRangeStart" || node.type === "commentRangeEnd")
|
|
305
|
-
if (node.type === "commentReference")
|
|
337
|
+
if (node.type === "commentRangeStart" || node.type === "commentRangeEnd") ownRangedIds.add(node.id);
|
|
338
|
+
if (node.type === "commentReference") ownPointIds.add(node.id);
|
|
306
339
|
if (node.type === "commentRangeStart") finalIds.add(node.id);
|
|
307
340
|
if (node.type === "commentRangeEnd") finalIds.delete(node.id);
|
|
308
341
|
}
|
|
@@ -329,9 +362,9 @@ const commentMarkTransitions = ({ source, paragraph, commentContext, explicitCom
|
|
|
329
362
|
return;
|
|
330
363
|
}
|
|
331
364
|
const id = attrs.value.commentId;
|
|
332
|
-
if (rangedIds.has(id)) {
|
|
365
|
+
if (ownRangedIds.has(id) || (commentContext?.rangedIds.has(id) ?? false)) {
|
|
333
366
|
if (!explicitCommentIds.has(id)) current.add(id);
|
|
334
|
-
} else if (!pointIds.has(id)) {
|
|
367
|
+
} else if (!ownPointIds.has(id) && !(commentContext?.pointIds.has(id) ?? false)) {
|
|
335
368
|
issue = "Canonical editing cannot attribute a comment mark to its source.";
|
|
336
369
|
return;
|
|
337
370
|
}
|
|
@@ -397,7 +430,26 @@ const projectCanonicalInline = ({ source, paragraph, pairedBookmarkIds, commentC
|
|
|
397
430
|
const boundaries = Array.from({ length: text.length + 1 }, () => []);
|
|
398
431
|
let index = 0;
|
|
399
432
|
let consumed = 0;
|
|
433
|
+
const insertionOrdinals = /* @__PURE__ */ new Map();
|
|
434
|
+
const insertionOrdinalAt = (offset) => {
|
|
435
|
+
const known = insertionOrdinals.get(offset);
|
|
436
|
+
if (known !== void 0) return known;
|
|
437
|
+
const ordinal = defaultInsertionGap(source.content, offset).zeroWidthBefore;
|
|
438
|
+
insertionOrdinals.set(offset, ordinal);
|
|
439
|
+
return ordinal;
|
|
440
|
+
};
|
|
441
|
+
const extents = /* @__PURE__ */ new Map();
|
|
400
442
|
const addGap = (position, gap) => {
|
|
443
|
+
const key = `${gap.offset}:${position}`;
|
|
444
|
+
const extent = extents.get(key);
|
|
445
|
+
if (extent === void 0) extents.set(key, {
|
|
446
|
+
first: gap.zeroWidthBefore,
|
|
447
|
+
last: gap.zeroWidthBefore
|
|
448
|
+
});
|
|
449
|
+
else {
|
|
450
|
+
extent.first = Math.min(extent.first, gap.zeroWidthBefore);
|
|
451
|
+
extent.last = Math.max(extent.last, gap.zeroWidthBefore);
|
|
452
|
+
}
|
|
401
453
|
const gaps = boundaries.at(gap.offset);
|
|
402
454
|
if (!gaps) panic(`Source leaf offset ${gap.offset} exceeds paragraph ${source.paraId}.`);
|
|
403
455
|
const existing = gaps.findIndex((entry) => entry.position === position);
|
|
@@ -405,8 +457,13 @@ const projectCanonicalInline = ({ source, paragraph, pairedBookmarkIds, commentC
|
|
|
405
457
|
position,
|
|
406
458
|
zeroWidthBefore: gap.zeroWidthBefore
|
|
407
459
|
};
|
|
408
|
-
if (existing < 0)
|
|
409
|
-
|
|
460
|
+
if (existing < 0) {
|
|
461
|
+
gaps.push(entry);
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
const preferred = insertionOrdinalAt(gap.offset);
|
|
465
|
+
const kept = gaps[existing] ?? panic("Missing canonical seam gap");
|
|
466
|
+
if (Math.abs(entry.zeroWidthBefore - preferred) < Math.abs(kept.zeroWidthBefore - preferred)) gaps[existing] = entry;
|
|
410
467
|
};
|
|
411
468
|
const consumeErasedLeaves = (position) => {
|
|
412
469
|
while (consumed === 0) {
|
|
@@ -430,6 +487,16 @@ const projectCanonicalInline = ({ source, paragraph, pairedBookmarkIds, commentC
|
|
|
430
487
|
});
|
|
431
488
|
for (const cell of native.value) {
|
|
432
489
|
consumeErasedLeaves(cell.from);
|
|
490
|
+
if (cell.type === "zeroWidth" && cell.sources.length === 0) {
|
|
491
|
+
if (consumed !== 0) return refuse("Canonical editing cannot place a content control edge inside text.");
|
|
492
|
+
const gap = spans.at(index)?.before ?? spans.at(index - 1)?.after ?? {
|
|
493
|
+
offset: 0,
|
|
494
|
+
zeroWidthBefore: 0
|
|
495
|
+
};
|
|
496
|
+
addGap(cell.from, gap);
|
|
497
|
+
addGap(cell.to, gap);
|
|
498
|
+
continue;
|
|
499
|
+
}
|
|
433
500
|
let span = spans.at(index);
|
|
434
501
|
if (!span) return refuse(`Canonical editing cannot map native ${cell.node.type.name} to a source leaf.`);
|
|
435
502
|
addGap(cell.from, consumed === 0 ? span.before : {
|
|
@@ -499,9 +566,106 @@ const projectCanonicalInline = ({ source, paragraph, pairedBookmarkIds, commentC
|
|
|
499
566
|
const missing = spans.at(index);
|
|
500
567
|
if (missing || consumed !== 0) return refuse(`Canonical editing cannot display the source positions of ${missing?.node.type ?? "incomplete text"}.`);
|
|
501
568
|
if (boundaries.some((gaps) => gaps.length === 0)) return refuse("Canonical editing lost a source character boundary.");
|
|
569
|
+
const seams = boundaries.map((gaps, offset) => gaps.map(({ position }) => extents.get(`${offset}:${position}`) ?? panic("A canonical gap lost its seam")));
|
|
502
570
|
return Result.ok({
|
|
503
571
|
text,
|
|
504
|
-
boundaries
|
|
572
|
+
boundaries,
|
|
573
|
+
seams
|
|
505
574
|
});
|
|
506
575
|
};
|
|
507
|
-
|
|
576
|
+
/** A membership whose answers one paragraph's projection read, recorded to check later. */
|
|
577
|
+
var RecordedMembership = class {
|
|
578
|
+
answers = /* @__PURE__ */ new Map();
|
|
579
|
+
source;
|
|
580
|
+
constructor(source) {
|
|
581
|
+
this.source = source;
|
|
582
|
+
}
|
|
583
|
+
has(value) {
|
|
584
|
+
const answer = this.source.has(value);
|
|
585
|
+
this.answers.set(value, answer);
|
|
586
|
+
return answer;
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
const answersHold = (answers, set) => {
|
|
590
|
+
for (const [value, answer] of answers) if (set.has(value) !== answer) return false;
|
|
591
|
+
return true;
|
|
592
|
+
};
|
|
593
|
+
const sameIds = (left, right) => {
|
|
594
|
+
let index = 0;
|
|
595
|
+
for (const value of right) {
|
|
596
|
+
if (left[index] !== value) return false;
|
|
597
|
+
index += 1;
|
|
598
|
+
}
|
|
599
|
+
return index === left.length;
|
|
600
|
+
};
|
|
601
|
+
/** The story inputs behind recorders, and what they read once the projection ran. */
|
|
602
|
+
const recordStory = (story) => {
|
|
603
|
+
const pairedBookmarkIds = new RecordedMembership(story.pairedBookmarkIds);
|
|
604
|
+
const context = story.commentContext;
|
|
605
|
+
if (context === void 0) return {
|
|
606
|
+
recorded: { pairedBookmarkIds },
|
|
607
|
+
reads: () => ({
|
|
608
|
+
pairedBookmarkIds: pairedBookmarkIds.answers,
|
|
609
|
+
commentContext: void 0
|
|
610
|
+
})
|
|
611
|
+
};
|
|
612
|
+
const rangedIds = new RecordedMembership(context.rangedIds);
|
|
613
|
+
const pointIds = new RecordedMembership(context.pointIds);
|
|
614
|
+
const openIds = [...context.openIds];
|
|
615
|
+
return {
|
|
616
|
+
recorded: {
|
|
617
|
+
pairedBookmarkIds,
|
|
618
|
+
commentContext: {
|
|
619
|
+
rangedIds,
|
|
620
|
+
pointIds,
|
|
621
|
+
openIds: new Set(openIds)
|
|
622
|
+
}
|
|
623
|
+
},
|
|
624
|
+
reads: () => ({
|
|
625
|
+
pairedBookmarkIds: pairedBookmarkIds.answers,
|
|
626
|
+
commentContext: {
|
|
627
|
+
rangedIds: rangedIds.answers,
|
|
628
|
+
pointIds: pointIds.answers,
|
|
629
|
+
openIds
|
|
630
|
+
}
|
|
631
|
+
})
|
|
632
|
+
};
|
|
633
|
+
};
|
|
634
|
+
const storyReadsHold = (reads, story) => {
|
|
635
|
+
if (!answersHold(reads.pairedBookmarkIds, story.pairedBookmarkIds)) return false;
|
|
636
|
+
const read = reads.commentContext;
|
|
637
|
+
const context = story.commentContext;
|
|
638
|
+
if (read === void 0 || context === void 0) return read === void 0 && context === void 0;
|
|
639
|
+
return sameIds(read.openIds, context.openIds) && answersHold(read.rangedIds, context.rangedIds) && answersHold(read.pointIds, context.pointIds);
|
|
640
|
+
};
|
|
641
|
+
/**
|
|
642
|
+
* Paragraph projections kept across projections of a story.
|
|
643
|
+
*
|
|
644
|
+
* A paragraph an edit left keeps its source records, and the block cache
|
|
645
|
+
* keeps its editor node, so its gaps can be reused where the story facts its
|
|
646
|
+
* projection read are the same: the comments open at its start and the
|
|
647
|
+
* comment and bookmark ids it asked about. Gap positions are relative to the
|
|
648
|
+
* paragraph, so a reused projection holds wherever the paragraph now starts.
|
|
649
|
+
*/
|
|
650
|
+
var InlineProjectionCache = class {
|
|
651
|
+
paragraphs = /* @__PURE__ */ new WeakMap();
|
|
652
|
+
project(args) {
|
|
653
|
+
const known = this.paragraphs.get(args.source);
|
|
654
|
+
if (known !== void 0 && PARAGRAPH_INPUT_FIELDS.every((field) => known.inputs[field] === args[field]) && storyReadsHold(known.reads, args)) return Result.ok(known.projection);
|
|
655
|
+
const { recorded, reads } = recordStory(args);
|
|
656
|
+
const projected = projectCanonicalInline({
|
|
657
|
+
...args,
|
|
658
|
+
...recorded
|
|
659
|
+
});
|
|
660
|
+
if (projected.isOk()) this.paragraphs.set(args.source, {
|
|
661
|
+
inputs: {
|
|
662
|
+
source: args.source,
|
|
663
|
+
paragraph: args.paragraph
|
|
664
|
+
},
|
|
665
|
+
reads: reads(),
|
|
666
|
+
projection: projected.value
|
|
667
|
+
});
|
|
668
|
+
return projected;
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
export { CANONICAL_NATIVE_INLINE_POLICIES, CANONICAL_SOURCE_INLINE_POLICIES, InlineProjectionCache, canonicalInlineSourceIssue, canonicalNativeCells, projectCanonicalInline };
|
|
@@ -14,7 +14,7 @@ type ReplaceTextInput = {
|
|
|
14
14
|
});
|
|
15
15
|
type CanonicalInputOptions = {
|
|
16
16
|
replace: (input: ReplaceTextInput) => void;
|
|
17
|
-
structure?: (type: "split" | "joinBackward" | "joinForward" | "lineBreak" | "pageBreak" | "tab" | "indent" | "outdent") => void;
|
|
17
|
+
structure?: (type: "split" | "joinBackward" | "joinForward" | "lineBreak" | "pageBreak" | "tab" | "indent" | "outdent" | "deleteTable") => void;
|
|
18
18
|
command?: (name: "toggleBold" | "toggleItalic" | "toggleUnderline") => void;
|
|
19
19
|
breakUndoGroup?: () => void;
|
|
20
20
|
beginComposition?: () => boolean;
|
|
@@ -25,13 +25,13 @@ type CanonicalInputOptions = {
|
|
|
25
25
|
redo: () => boolean;
|
|
26
26
|
refuse: (reason: string) => void;
|
|
27
27
|
};
|
|
28
|
-
/** Native changes require a preceding, classified input event at the same state. */
|
|
29
28
|
export declare const createCanonicalInputBoundary: (options: CanonicalInputOptions) => {
|
|
30
29
|
reset: () => void;
|
|
31
30
|
readonly isComposing: boolean;
|
|
32
31
|
acceptComposition: (view: EditorView, transaction: Transaction) => boolean;
|
|
33
32
|
handleTextInput: (view: EditorView, from: number, to: number, text: string) => boolean;
|
|
34
33
|
handleKeyDown: (view: EditorView, event: KeyboardEvent) => boolean;
|
|
34
|
+
handleKeyPress: (view: EditorView, event: KeyboardEvent) => boolean;
|
|
35
35
|
handleDOMEvents: {
|
|
36
36
|
keydown: (view: EditorView, event: KeyboardEvent) => boolean;
|
|
37
37
|
compositionstart: (view: EditorView) => boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getEditorInputTargetRange, handleEditorBeforeInput } from "../prosemirror/textInput.js";
|
|
2
2
|
import { createCanonicalComposition } from "./canonicalComposition.js";
|
|
3
3
|
import { deletionRange, isCanonicalJoinBoundary } from "./canonicalSession.js";
|
|
4
|
+
import { CellSelection } from "prosemirror-tables";
|
|
4
5
|
import { ReplaceStep } from "prosemirror-transform";
|
|
5
6
|
import { Selection, TextSelection } from "prosemirror-state";
|
|
6
7
|
// src/controller/canonicalInput.ts
|
|
@@ -11,6 +12,23 @@ const CANONICAL_COMPOSITION_INPUT_TYPES = [
|
|
|
11
12
|
"deleteByComposition"
|
|
12
13
|
];
|
|
13
14
|
/** Native changes require a preceding, classified input event at the same state. */
|
|
15
|
+
/**
|
|
16
|
+
* ProseMirror treats the end of one text node and the start of the next run as
|
|
17
|
+
* one position, so it leaves whichever the browser holds. Chromium's IME can
|
|
18
|
+
* resolve that caret against the start of the document, even when it reports the
|
|
19
|
+
* right node, until the selection is set again. A composition starts where the
|
|
20
|
+
* model's caret is: in the text before it, or at a paragraph's start in the first.
|
|
21
|
+
*/
|
|
22
|
+
const placeCompositionCaret = (view) => {
|
|
23
|
+
const { selection } = view.state;
|
|
24
|
+
const native = view.dom.ownerDocument.getSelection();
|
|
25
|
+
if (!selection.empty || !native?.isCollapsed) return;
|
|
26
|
+
const before = view.domAtPos(selection.from, -1);
|
|
27
|
+
const { node, offset } = before.node.nodeType === before.node.TEXT_NODE ? before : view.domAtPos(selection.from, 1);
|
|
28
|
+
if (node.nodeType !== node.TEXT_NODE) return;
|
|
29
|
+
native.removeAllRanges();
|
|
30
|
+
native.collapse(node, offset);
|
|
31
|
+
};
|
|
14
32
|
const createCanonicalInputBoundary = (options) => {
|
|
15
33
|
const composition = createCanonicalComposition({
|
|
16
34
|
begin: () => options.beginComposition?.() ?? true,
|
|
@@ -104,6 +122,26 @@ const createCanonicalInputBoundary = (options) => {
|
|
|
104
122
|
refuseNativeMutation(view);
|
|
105
123
|
return true;
|
|
106
124
|
},
|
|
125
|
+
/**
|
|
126
|
+
* ProseMirror types a key over a selection that is not text inside one
|
|
127
|
+
* paragraph (one across paragraphs, a whole document, cells, a node) itself
|
|
128
|
+
* from keypress, cancelling it, so no beforeinput ever classifies that
|
|
129
|
+
* text. It is the same typing a beforeinput carries, at the same selection.
|
|
130
|
+
*/
|
|
131
|
+
handleKeyPress: (view, event) => {
|
|
132
|
+
if (composition.active || composition.pendingFinal) return false;
|
|
133
|
+
const { selection } = view.state;
|
|
134
|
+
if (selection instanceof TextSelection && selection.$from.sameParent(selection.$to)) return false;
|
|
135
|
+
const text = String.fromCharCode(event.charCode);
|
|
136
|
+
if (/[\r\n]/u.test(text)) return false;
|
|
137
|
+
options.replace({
|
|
138
|
+
from: selection.from,
|
|
139
|
+
to: selection.to,
|
|
140
|
+
text,
|
|
141
|
+
semantic: "typing"
|
|
142
|
+
});
|
|
143
|
+
return true;
|
|
144
|
+
},
|
|
107
145
|
handleKeyDown: (view, event) => {
|
|
108
146
|
if (event.isComposing || event.keyCode === 229) return false;
|
|
109
147
|
beginGesture();
|
|
@@ -178,7 +216,13 @@ const createCanonicalInputBoundary = (options) => {
|
|
|
178
216
|
if (!composition.active) options.refuse("Only plain character deletion is available in this session.");
|
|
179
217
|
return true;
|
|
180
218
|
}
|
|
181
|
-
|
|
219
|
+
const selection = view.state.selection;
|
|
220
|
+
if (selection instanceof CellSelection && selection.isRowSelection() && selection.isColSelection() && options.structure !== void 0) {
|
|
221
|
+
closeGroup();
|
|
222
|
+
options.structure("deleteTable");
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
if (selection.empty && options.structure !== void 0 && isCanonicalJoinBoundary(view.state, event.key === "Backspace" ? "backward" : "forward")) {
|
|
182
226
|
closeGroup();
|
|
183
227
|
options.structure(event.key === "Backspace" ? "joinBackward" : "joinForward");
|
|
184
228
|
return true;
|
|
@@ -205,6 +249,7 @@ const createCanonicalInputBoundary = (options) => {
|
|
|
205
249
|
compositionstart: (view) => {
|
|
206
250
|
beginGesture();
|
|
207
251
|
composition.start(view);
|
|
252
|
+
placeCompositionCaret(view);
|
|
208
253
|
return false;
|
|
209
254
|
},
|
|
210
255
|
compositionend: (view, event) => {
|
|
@@ -246,7 +291,7 @@ const createCanonicalInputBoundary = (options) => {
|
|
|
246
291
|
}
|
|
247
292
|
const nativeFinal = view.composing && (event.inputType === "insertText" || event.inputType === "insertReplacementText");
|
|
248
293
|
const nativeStillComposing = view.composing;
|
|
249
|
-
if (nativeFinal) composition.authorizeNative(view, "explicitFinal");
|
|
294
|
+
if (nativeFinal) composition.authorizeNative(view, "explicitFinal", event.data);
|
|
250
295
|
const recovered = composition.recover(view);
|
|
251
296
|
composition.forgetCompleted();
|
|
252
297
|
proposal = { type: "idle" };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { ListNormalizationCache } from "../docx/listModelNormalization.js";
|
|
1
2
|
import { DocumentOp } from "./canonicalOperations.js";
|
|
2
3
|
import { Document } from "@stll/docx-core";
|
|
3
4
|
/** Canonical edits share list model normalization with the headless projection. */
|
|
4
|
-
export declare const normalizeCanonicalListRendering: (document: Document) => {
|
|
5
|
+
export declare const normalizeCanonicalListRendering: (document: Document, cache?: ListNormalizationCache) => {
|
|
5
6
|
document: Document;
|
|
6
7
|
inverse: DocumentOp[];
|
|
7
8
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizeListModelRendering } from "../docx/listModelNormalization.js";
|
|
2
2
|
// src/controller/canonicalListRendering.ts
|
|
3
3
|
/** Canonical edits share list model normalization with the headless projection. */
|
|
4
|
-
const normalizeCanonicalListRendering = normalizeListModelRendering;
|
|
4
|
+
const normalizeCanonicalListRendering = (document, cache) => normalizeListModelRendering(document, cache === void 0 ? {} : { cache });
|
|
5
5
|
export { normalizeCanonicalListRendering };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { LockedControlViolation } from "@stll/docx-core/model";
|
|
3
|
+
/**
|
|
4
|
+
* What a change from `before` to `after` does to a locked content control,
|
|
5
|
+
* judged on the result rather than the steps that produced it, so every path
|
|
6
|
+
* into the session meets the same rule.
|
|
7
|
+
*/
|
|
8
|
+
export declare const lockViolationBetween: (before: document_d_exports.Document, after: document_d_exports.Document) => LockedControlViolation | null;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { contentControlLockAllows, locksContent, locksControl } from "@stll/docx-core/model";
|
|
2
|
+
import { documentStories, findStoryBody } from "@stll/docx-core/ops";
|
|
3
|
+
// src/controller/canonicalLockGuard.ts
|
|
4
|
+
/** Comment marks, anchors and identities: what a lock does not hold still. */
|
|
5
|
+
const IGNORED_KEYS = /* @__PURE__ */ new Set(["paraId", "textId"]);
|
|
6
|
+
const IGNORED_ITEMS = /* @__PURE__ */ new Set([
|
|
7
|
+
"commentRangeStart",
|
|
8
|
+
"commentRangeEnd",
|
|
9
|
+
"commentReference"
|
|
10
|
+
]);
|
|
11
|
+
const isIgnoredItem = (item) => typeof item === "object" && item !== null && "type" in item && IGNORED_ITEMS.has(String(item.type));
|
|
12
|
+
const isRevisionIdentity = (key, value) => key === "preservedAttributes" && Array.isArray(value);
|
|
13
|
+
/** What a control holds, as the lock judges it. */
|
|
14
|
+
const signatureOf = (content) => JSON.stringify(content, (key, value) => {
|
|
15
|
+
if (IGNORED_KEYS.has(key)) return void 0;
|
|
16
|
+
if (isRevisionIdentity(key, value)) return value.filter(({ name }) => typeof name !== "string" || !name.startsWith("rsid"));
|
|
17
|
+
if (Array.isArray(value)) return value.filter((item) => !isIgnoredItem(item));
|
|
18
|
+
return value;
|
|
19
|
+
});
|
|
20
|
+
const storyKey = (story) => {
|
|
21
|
+
if (story === "main") return "main";
|
|
22
|
+
return "rId" in story ? `${story.kind}:${story.rId}` : `${story.kind}:${String(story.id)}`;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Every content control in the document, keyed by its story and `w:id`, or by
|
|
26
|
+
* its order among the controls without one.
|
|
27
|
+
*/
|
|
28
|
+
const controlsOf = (document) => {
|
|
29
|
+
const controls = /* @__PURE__ */ new Map();
|
|
30
|
+
for (const story of documentStories(document)) {
|
|
31
|
+
const body = findStoryBody(document, story);
|
|
32
|
+
if (body === void 0) continue;
|
|
33
|
+
let anonymous = 0;
|
|
34
|
+
const visit = (value) => {
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
for (const item of value) visit(item);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (typeof value !== "object" || value === null) return;
|
|
40
|
+
const node = value;
|
|
41
|
+
if (node.type === "blockSdt" || node.type === "inlineSdt") {
|
|
42
|
+
const id = node.properties?.id;
|
|
43
|
+
const key = `${storyKey(story)}#${id === void 0 ? `anonymous ${String(anonymous++)}` : String(id)}`;
|
|
44
|
+
controls.set(key, {
|
|
45
|
+
lock: node.properties?.lock,
|
|
46
|
+
signature: signatureOf(node.content)
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
for (const child of Object.values(value)) visit(child);
|
|
50
|
+
};
|
|
51
|
+
visit(body.content);
|
|
52
|
+
}
|
|
53
|
+
return controls;
|
|
54
|
+
};
|
|
55
|
+
const lockedControls = /* @__PURE__ */ new WeakMap();
|
|
56
|
+
const lockedIn = (document) => {
|
|
57
|
+
let locked = lockedControls.get(document);
|
|
58
|
+
if (locked === void 0) {
|
|
59
|
+
locked = new Map([...controlsOf(document)].filter(([, { lock }]) => locksContent(lock) || locksControl(lock)));
|
|
60
|
+
lockedControls.set(document, locked);
|
|
61
|
+
}
|
|
62
|
+
return locked;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* What a change from `before` to `after` does to a locked content control,
|
|
66
|
+
* judged on the result rather than the steps that produced it, so every path
|
|
67
|
+
* into the session meets the same rule.
|
|
68
|
+
*/
|
|
69
|
+
const lockViolationBetween = (before, after) => {
|
|
70
|
+
const locked = lockedIn(before);
|
|
71
|
+
if (locked.size === 0 || before === after) return null;
|
|
72
|
+
const now = controlsOf(after);
|
|
73
|
+
for (const [key, { lock, signature }] of locked) {
|
|
74
|
+
if (lock === void 0) continue;
|
|
75
|
+
const kept = now.get(key);
|
|
76
|
+
if (kept === void 0) {
|
|
77
|
+
if (!contentControlLockAllows(lock, "removeControl")) return {
|
|
78
|
+
lock,
|
|
79
|
+
change: "removeControl"
|
|
80
|
+
};
|
|
81
|
+
} else if (kept.signature !== signature && !contentControlLockAllows(lock, "editContent")) return {
|
|
82
|
+
lock,
|
|
83
|
+
change: "editContent"
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
};
|
|
88
|
+
export { lockViolationBetween };
|
|
@@ -10,10 +10,10 @@ export declare const CANONICAL_PUBLIC_OPERATION_DISPOSITIONS: {
|
|
|
10
10
|
readonly splitBlock: "compile";
|
|
11
11
|
readonly formatRange: "compile";
|
|
12
12
|
readonly mergeBlockWithNext: "compile";
|
|
13
|
-
readonly setBlockParagraphProperties: "
|
|
14
|
-
readonly insertAfterBlock: "
|
|
15
|
-
readonly insertBeforeBlock: "
|
|
16
|
-
readonly deleteBlock: "
|
|
13
|
+
readonly setBlockParagraphProperties: "compile";
|
|
14
|
+
readonly insertAfterBlock: "compile";
|
|
15
|
+
readonly insertBeforeBlock: "compile";
|
|
16
|
+
readonly deleteBlock: "compile";
|
|
17
17
|
readonly commentOnBlock: "compile";
|
|
18
18
|
readonly commentOnRange: "compile";
|
|
19
19
|
readonly insertTable: "publicOps.tableStructure";
|
|
@@ -41,6 +41,14 @@ export declare class CanonicalPublicOperations {
|
|
|
41
41
|
constructor(options: CanonicalPublicOperationsOptions);
|
|
42
42
|
apply(options: CanonicalPublicOperationOptions): FolioDocumentOperationResult;
|
|
43
43
|
undo(handle: FolioDocumentOperationUndoHandle): FolioDocumentOperationUndoResult;
|
|
44
|
+
/**
|
|
45
|
+
* A whole paragraph removed as the editor removes a selection of it with
|
|
46
|
+
* its paragraph mark: from its start to the start of the paragraph after
|
|
47
|
+
* it, or, for the paragraph that ends its block list, from the end of the
|
|
48
|
+
* paragraph before it, whose mark then ends the list. Tracked, the text and
|
|
49
|
+
* the mark are marked deleted.
|
|
50
|
+
*/
|
|
51
|
+
private resolveBlockDeletion;
|
|
44
52
|
private resolve;
|
|
45
53
|
}
|
|
46
54
|
export {};
|