@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
|
@@ -17,7 +17,7 @@ import { createDocumentStyleContextPlugin, createDocumentStylesPlugin } from "..
|
|
|
17
17
|
import { schema } from "../prosemirror/schema/index.js";
|
|
18
18
|
import { createTextInputPlugin } from "../prosemirror/textInput.js";
|
|
19
19
|
import { applyAttrSchemaMigrations, proseDocumentParagraphSourceContract, readYjsAttrSchemaVersion, readYjsParagraphSourceContract, withParagraphSourceContract, writeYjsDocumentMetadata } from "../prosemirror/yjsDocumentMetadata.js";
|
|
20
|
-
import { CANONICAL_GAP, usesCanonicalSession } from "../types/canonicalCapabilities.js";
|
|
20
|
+
import { CANONICAL_GAP, CANONICAL_RULE, usesCanonicalSession } from "../types/canonicalCapabilities.js";
|
|
21
21
|
import { prepareCanonicalPaste } from "./canonicalClipboard.js";
|
|
22
22
|
import { canonicalCommentBody, compileCanonicalComments } from "./canonicalComments.js";
|
|
23
23
|
import { createCanonicalInputBoundary } from "./canonicalInput.js";
|
|
@@ -29,11 +29,13 @@ import { prepareCanonicalAutoformat, prepareCanonicalCommands } from "./canonica
|
|
|
29
29
|
import { createHiddenEditorApi } from "./hiddenEditorApi.js";
|
|
30
30
|
import { handleReadOnlySelectionKeyDown } from "./readOnlySelection.js";
|
|
31
31
|
import { Result, TaggedError, panic } from "better-result";
|
|
32
|
+
import { CellSelection } from "prosemirror-tables";
|
|
32
33
|
import { OP_STORIES, freshCommentId } from "@stll/docx-core/ops";
|
|
33
34
|
import { EditorState, Plugin } from "prosemirror-state";
|
|
34
35
|
import { EditorView } from "prosemirror-view";
|
|
35
36
|
// src/controller/hiddenEditorManager.ts
|
|
36
37
|
const CanonicalSessionRefusalErrorBase = TaggedError("CanonicalSessionRefusalError");
|
|
38
|
+
/** A refused input, with whether the session lacks the capability or the document forbids it. */
|
|
37
39
|
var CanonicalSessionRefusalError = class extends CanonicalSessionRefusalErrorBase {};
|
|
38
40
|
const normalizeSeedState = (state) => ensureBaseDirectionInState(ensureParaIdsInState(state));
|
|
39
41
|
const normalizeLocalSeedState = (state) => ensureBaseDirectionInState(state);
|
|
@@ -121,12 +123,11 @@ function createHiddenEditorState(options) {
|
|
|
121
123
|
recordHiddenEditorPhase(reason, "to-prose-doc", performance.now() - startedAt);
|
|
122
124
|
} else localDoc = ensureParaIdsInDoc(localDoc);
|
|
123
125
|
const styleResolverPlugin = createDocumentStylesPlugin(styles ?? document?.package.styles);
|
|
124
|
-
const numberingPlugin = createDocumentNumberingPlugin(document?.package.numbering);
|
|
125
126
|
const plugins = [
|
|
127
|
+
createDocumentNumberingPlugin(document?.package.numbering),
|
|
126
128
|
...externalPlugins,
|
|
127
129
|
...manager?.getPlugins() ?? [createTextInputPlugin()],
|
|
128
|
-
styleResolverPlugin
|
|
129
|
-
numberingPlugin
|
|
130
|
+
styleResolverPlugin
|
|
130
131
|
];
|
|
131
132
|
if (collaboration) {
|
|
132
133
|
if (!collaborationModules) panic("Collaboration modules must be loaded before creating collaborative editor state.");
|
|
@@ -222,11 +223,11 @@ const createHiddenEditorManager = (deps) => {
|
|
|
222
223
|
author: deps.getSuggestionAuthor?.() ?? "User"
|
|
223
224
|
} : { type: "editing" }));
|
|
224
225
|
};
|
|
225
|
-
const refuse = (reason,
|
|
226
|
+
const refuse = (reason, ground = { gap: CANONICAL_GAP.dispatch }) => {
|
|
226
227
|
const message = reason;
|
|
227
|
-
if (deps.onSessionRefusal) deps.onSessionRefusal(message,
|
|
228
|
+
if (deps.onSessionRefusal) deps.onSessionRefusal(message, ground);
|
|
228
229
|
else throw new CanonicalSessionRefusalError({
|
|
229
|
-
|
|
230
|
+
ground,
|
|
230
231
|
message
|
|
231
232
|
});
|
|
232
233
|
};
|
|
@@ -244,7 +245,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
244
245
|
reason,
|
|
245
246
|
documentIdentity
|
|
246
247
|
};
|
|
247
|
-
refuse(reason, CANONICAL_GAP.collaboration);
|
|
248
|
+
refuse(reason, { gap: CANONICAL_GAP.collaboration });
|
|
248
249
|
return false;
|
|
249
250
|
}
|
|
250
251
|
const result = createCanonicalSession(document, deps.getStyles());
|
|
@@ -254,7 +255,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
254
255
|
reason: result.error.message,
|
|
255
256
|
documentIdentity
|
|
256
257
|
};
|
|
257
|
-
refuse(result.error.message, result.error.
|
|
258
|
+
refuse(result.error.message, result.error.ground);
|
|
258
259
|
return false;
|
|
259
260
|
}
|
|
260
261
|
editorSession = {
|
|
@@ -269,9 +270,9 @@ const createHiddenEditorManager = (deps) => {
|
|
|
269
270
|
const canonicalState = (session) => EditorState.create({
|
|
270
271
|
doc: session.projection.doc,
|
|
271
272
|
plugins: [
|
|
273
|
+
createDocumentNumberingPlugin(session.document.package.numbering),
|
|
272
274
|
createParagraphChangeTrackerPlugin(),
|
|
273
275
|
createDocumentStyleContextPlugin(deps.getStyles() ?? session.document.package.styles),
|
|
274
|
-
createDocumentNumberingPlugin(session.document.package.numbering),
|
|
275
276
|
...[...deps.getExtensionManager()?.getPlugins() ?? [], ...deps.getExternalPlugins()].flatMap(({ props }) => props.transformPastedHTML === void 0 && props.transformPasted === void 0 && props.transformCopied === void 0 && props.clipboardTextSerializer === void 0 ? [] : [new Plugin({ props: {
|
|
276
277
|
...props.transformCopied === void 0 ? {} : { transformCopied: props.transformCopied },
|
|
277
278
|
...props.clipboardTextSerializer === void 0 ? {} : { clipboardTextSerializer: props.clipboardTextSerializer },
|
|
@@ -289,7 +290,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
289
290
|
session
|
|
290
291
|
});
|
|
291
292
|
if (result.isErr()) {
|
|
292
|
-
reportRefusal(result.error.message, result.error.
|
|
293
|
+
reportRefusal(result.error.message, result.error.ground);
|
|
293
294
|
return false;
|
|
294
295
|
}
|
|
295
296
|
const staged = result.value;
|
|
@@ -308,7 +309,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
308
309
|
if (direction === "undo" ? !session.canUndo : !session.canRedo) return false;
|
|
309
310
|
const prepared = direction === "undo" ? session.prepareUndo(view.state) : session.prepareRedo(view.state);
|
|
310
311
|
if (prepared.isErr()) {
|
|
311
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
312
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
312
313
|
return false;
|
|
313
314
|
}
|
|
314
315
|
return publishCommit(prepared.value);
|
|
@@ -329,10 +330,10 @@ const createHiddenEditorManager = (deps) => {
|
|
|
329
330
|
if (described.isErr()) {
|
|
330
331
|
if (!(described.error instanceof HyperlinkRemovalRefusal)) throw described.error;
|
|
331
332
|
const refusal = new CanonicalSessionRefusalError({
|
|
332
|
-
gap: CANONICAL_GAP.commands,
|
|
333
|
+
ground: { gap: CANONICAL_GAP.commands },
|
|
333
334
|
message: described.error.message
|
|
334
335
|
});
|
|
335
|
-
refuse(refusal.message, refusal.
|
|
336
|
+
refuse(refusal.message, refusal.ground);
|
|
336
337
|
return false;
|
|
337
338
|
}
|
|
338
339
|
const intents = described.value;
|
|
@@ -344,7 +345,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
344
345
|
}, view);
|
|
345
346
|
const prepared = prepareCanonicalCommands(editorSession.session, view.state, intents);
|
|
346
347
|
if (prepared.isErr()) {
|
|
347
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
348
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
348
349
|
return false;
|
|
349
350
|
}
|
|
350
351
|
return publishCommit(prepared.value);
|
|
@@ -364,7 +365,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
364
365
|
if (mark !== void 0) command = name === "toggleUnderline" ? toggleUnderlineMark(mark) : toggleMarkForAllScripts(mark, name === "toggleBold" ? "bold" : "italic");
|
|
365
366
|
}
|
|
366
367
|
if (command === void 0) {
|
|
367
|
-
refuse("The formatting command is unavailable.", CANONICAL_GAP.commands);
|
|
368
|
+
refuse("The formatting command is unavailable.", { gap: CANONICAL_GAP.commands });
|
|
368
369
|
return;
|
|
369
370
|
}
|
|
370
371
|
if (executeCanonicalCommand(command) === void 0) command(view.state, (transaction) => view?.dispatch(transaction), view);
|
|
@@ -372,11 +373,47 @@ const createHiddenEditorManager = (deps) => {
|
|
|
372
373
|
structure: (type) => {
|
|
373
374
|
if (!view || deps.getReadOnly() || editorSession.type !== "canonical") return;
|
|
374
375
|
syncCanonicalMode();
|
|
376
|
+
if (type === "deleteTable") {
|
|
377
|
+
const command = deps.getExtensionManager()?.getCommand("deleteTable")?.();
|
|
378
|
+
if (command === void 0) refuse("Deleting the table is unavailable.", { gap: CANONICAL_GAP.commands });
|
|
379
|
+
else executeCanonicalCommand(command);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
375
382
|
const session = editorSession.session;
|
|
376
383
|
const state = view.state;
|
|
384
|
+
if (state.selection instanceof CellSelection && (type === "split" || type === "tab" || type === "lineBreak" || type === "pageBreak")) {
|
|
385
|
+
const overCells = session.prepareCellSelectionStructure(state, (at) => type === "split" ? {
|
|
386
|
+
type: "replaceFragment",
|
|
387
|
+
from: at,
|
|
388
|
+
to: at,
|
|
389
|
+
paragraphs: [{
|
|
390
|
+
type: "paragraph",
|
|
391
|
+
content: []
|
|
392
|
+
}, {
|
|
393
|
+
type: "paragraph",
|
|
394
|
+
content: []
|
|
395
|
+
}],
|
|
396
|
+
openStart: 1,
|
|
397
|
+
openEnd: 1
|
|
398
|
+
} : {
|
|
399
|
+
type: "insertAtom",
|
|
400
|
+
from: at,
|
|
401
|
+
to: at,
|
|
402
|
+
atom: type === "tab" ? { type: "tab" } : {
|
|
403
|
+
type: "break",
|
|
404
|
+
breakType: type === "pageBreak" ? "page" : "textWrapping"
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
if (overCells.isErr()) {
|
|
408
|
+
if (overCells.error.reason !== "noChange") refuse(overCells.error.message, overCells.error.ground);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
publishCommit(overCells.value);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
377
414
|
const selection = session.projection.selectionAt(state);
|
|
378
415
|
if (selection.isErr()) {
|
|
379
|
-
refuse(selection.error.message, selection.error.
|
|
416
|
+
refuse(selection.error.message, selection.error.ground);
|
|
380
417
|
return;
|
|
381
418
|
}
|
|
382
419
|
let prepared;
|
|
@@ -426,11 +463,11 @@ const createHiddenEditorManager = (deps) => {
|
|
|
426
463
|
const from = session.projection.addressAt(state.selection.from);
|
|
427
464
|
const to = session.projection.addressAt(state.selection.to);
|
|
428
465
|
if (from.isErr()) {
|
|
429
|
-
refuse(from.error.message, from.error.
|
|
466
|
+
refuse(from.error.message, from.error.ground);
|
|
430
467
|
return;
|
|
431
468
|
}
|
|
432
469
|
if (to.isErr()) {
|
|
433
|
-
refuse(to.error.message, to.error.
|
|
470
|
+
refuse(to.error.message, to.error.ground);
|
|
434
471
|
return;
|
|
435
472
|
}
|
|
436
473
|
prepared = session.prepareIntent(state, {
|
|
@@ -447,7 +484,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
447
484
|
default: return type;
|
|
448
485
|
}
|
|
449
486
|
if (prepared.isErr()) {
|
|
450
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
487
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
451
488
|
return;
|
|
452
489
|
}
|
|
453
490
|
publishCommit(prepared.value);
|
|
@@ -461,13 +498,15 @@ const createHiddenEditorManager = (deps) => {
|
|
|
461
498
|
if (deps.getReadOnly() || editorSession.type !== "canonical") return false;
|
|
462
499
|
const begun = editorSession.session.beginComposition();
|
|
463
500
|
if (begun.isErr()) {
|
|
464
|
-
refuse(begun.error.message, begun.error.
|
|
501
|
+
refuse(begun.error.message, begun.error.ground);
|
|
465
502
|
return false;
|
|
466
503
|
}
|
|
467
504
|
return true;
|
|
468
505
|
},
|
|
469
506
|
endComposition: () => {
|
|
470
|
-
if (editorSession.type
|
|
507
|
+
if (editorSession.type !== "canonical") return;
|
|
508
|
+
editorSession.session.endComposition();
|
|
509
|
+
deps.onCanonicalCompositionEnd();
|
|
471
510
|
}
|
|
472
511
|
};
|
|
473
512
|
const input = createCanonicalInputBoundary({
|
|
@@ -499,7 +538,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
499
538
|
semantic: "replacement"
|
|
500
539
|
});
|
|
501
540
|
if (prepared.isErr()) {
|
|
502
|
-
refuse(prepared.error.message, prepared.error.
|
|
541
|
+
refuse(prepared.error.message, prepared.error.ground);
|
|
503
542
|
return true;
|
|
504
543
|
}
|
|
505
544
|
const copied = Result.try({
|
|
@@ -509,11 +548,11 @@ const createHiddenEditorManager = (deps) => {
|
|
|
509
548
|
event.clipboardData?.setData("text/plain", serialized.text);
|
|
510
549
|
},
|
|
511
550
|
catch: () => new CanonicalSessionRefusalError({
|
|
512
|
-
gap: CANONICAL_GAP.dispatch,
|
|
551
|
+
ground: { gap: CANONICAL_GAP.dispatch },
|
|
513
552
|
message: "The clipboard could not receive the cut content."
|
|
514
553
|
})
|
|
515
554
|
});
|
|
516
|
-
if (copied.isErr()) refuse(copied.error.message, copied.error.
|
|
555
|
+
if (copied.isErr()) refuse(copied.error.message, copied.error.ground);
|
|
517
556
|
else publishCommit(prepared.value);
|
|
518
557
|
return true;
|
|
519
558
|
},
|
|
@@ -525,7 +564,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
525
564
|
const rule = prepareCanonicalAutoformat(editorSession.session, view.state, intent);
|
|
526
565
|
const prepared = rule ?? editorSession.session.prepareReplace(view.state, intent);
|
|
527
566
|
if (prepared.isErr()) {
|
|
528
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
567
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
529
568
|
return;
|
|
530
569
|
}
|
|
531
570
|
const session = editorSession.session;
|
|
@@ -595,7 +634,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
595
634
|
if (modules && transaction.getMeta(modules.yProseMirror.ySyncPluginKey) !== void 0) markNoteReferenceReplay(transaction);
|
|
596
635
|
const applied = view.state.applyTransaction(transaction);
|
|
597
636
|
const noteIssue = noteReferenceTransactionIssue(transaction);
|
|
598
|
-
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, CANONICAL_GAP.dispatch, noteIssue);
|
|
637
|
+
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, { gap: CANONICAL_GAP.dispatch }, noteIssue);
|
|
599
638
|
if (editorSession.type === "canonical" && !applied.state.doc.eq(view.state.doc)) {
|
|
600
639
|
refuse("A plugin attempted an unclassified canonical document mutation.");
|
|
601
640
|
return;
|
|
@@ -624,6 +663,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
624
663
|
return deps.onKeyDown(pmView, event);
|
|
625
664
|
},
|
|
626
665
|
handleTextInput: (pmView, from, to, text) => editorSession.type === "canonical" ? input.handleTextInput(pmView, from, to, text) : false,
|
|
666
|
+
handleKeyPress: (pmView, event) => editorSession.type === "canonical" && !deps.getReadOnly() && input.handleKeyPress(pmView, event),
|
|
627
667
|
handlePaste: (pmView, _event, slice) => {
|
|
628
668
|
if (editorSession.type !== "canonical") return false;
|
|
629
669
|
if (deps.getReadOnly()) {
|
|
@@ -637,7 +677,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
637
677
|
slice
|
|
638
678
|
});
|
|
639
679
|
if (prepared.isErr()) {
|
|
640
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
680
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
641
681
|
} else publishCommit(prepared.value);
|
|
642
682
|
return true;
|
|
643
683
|
},
|
|
@@ -680,7 +720,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
680
720
|
} : { pasteTarget: target }
|
|
681
721
|
});
|
|
682
722
|
if (prepared.isErr()) {
|
|
683
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
723
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
684
724
|
} else publishCommit(prepared.value);
|
|
685
725
|
return true;
|
|
686
726
|
},
|
|
@@ -744,7 +784,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
744
784
|
plain
|
|
745
785
|
});
|
|
746
786
|
if (prepared.isErr()) {
|
|
747
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
787
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
748
788
|
return false;
|
|
749
789
|
}
|
|
750
790
|
return publishCommit(prepared.value);
|
|
@@ -848,7 +888,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
848
888
|
session
|
|
849
889
|
});
|
|
850
890
|
if (staged.isErr()) {
|
|
851
|
-
refuse(staged.error.message, staged.error.
|
|
891
|
+
refuse(staged.error.message, staged.error.ground);
|
|
852
892
|
return false;
|
|
853
893
|
}
|
|
854
894
|
storyView.updateState(staged.value.state);
|
|
@@ -908,7 +948,23 @@ const createHiddenEditorManager = (deps) => {
|
|
|
908
948
|
resolution
|
|
909
949
|
});
|
|
910
950
|
if (prepared.isErr()) {
|
|
911
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
951
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
952
|
+
return false;
|
|
953
|
+
}
|
|
954
|
+
const published = publishCommit(prepared.value);
|
|
955
|
+
if (prepared.value.lockHeld !== void 0) refuse(`Revisions ${prepared.value.lockHeld.join(", ")} stay pending: resolving them changes a locked content control.`, { rule: CANONICAL_RULE.contentControlLock });
|
|
956
|
+
return published;
|
|
957
|
+
},
|
|
958
|
+
resolveCanonicalSuggestion: (suggestionId, resolution, author) => {
|
|
959
|
+
if (!view || deps.getReadOnly() || editorSession.type !== "canonical") return false;
|
|
960
|
+
const prepared = editorSession.session.prepareSuggestion(view.state, {
|
|
961
|
+
suggestionId,
|
|
962
|
+
resolution,
|
|
963
|
+
author,
|
|
964
|
+
date: (/* @__PURE__ */ new Date()).toISOString()
|
|
965
|
+
});
|
|
966
|
+
if (prepared.isErr()) {
|
|
967
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
912
968
|
return false;
|
|
913
969
|
}
|
|
914
970
|
return publishCommit(prepared.value);
|
|
@@ -924,7 +980,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
924
980
|
applyCanonicalSectionProperties: (patch) => {
|
|
925
981
|
ensureView();
|
|
926
982
|
const fail = (message) => {
|
|
927
|
-
refuse(message, CANONICAL_GAP.sectionProperties);
|
|
983
|
+
refuse(message, { gap: CANONICAL_GAP.sectionProperties });
|
|
928
984
|
return {
|
|
929
985
|
status: "refused",
|
|
930
986
|
gap: CANONICAL_GAP.sectionProperties,
|
|
@@ -953,7 +1009,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
953
1009
|
applyCanonicalComment: (request) => {
|
|
954
1010
|
ensureView();
|
|
955
1011
|
const fail = (message, retry = "never") => {
|
|
956
|
-
if (retry === "never") refuse(message, CANONICAL_GAP.comments);
|
|
1012
|
+
if (retry === "never") refuse(message, { gap: CANONICAL_GAP.comments });
|
|
957
1013
|
return {
|
|
958
1014
|
status: "refused",
|
|
959
1015
|
gap: CANONICAL_GAP.comments,
|
|
@@ -1074,7 +1130,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
1074
1130
|
if (direction === "undo" ? !session.canUndo : !session.canRedo) return false;
|
|
1075
1131
|
const prepared = direction === "undo" ? session.prepareUndo(storyView.state, story) : session.prepareRedo(storyView.state, story);
|
|
1076
1132
|
if (prepared.isErr()) {
|
|
1077
|
-
refuse(prepared.error.message, prepared.error.
|
|
1133
|
+
refuse(prepared.error.message, prepared.error.ground);
|
|
1078
1134
|
return false;
|
|
1079
1135
|
}
|
|
1080
1136
|
return publishStoryCommit(storyView, prepared.value);
|
|
@@ -1084,7 +1140,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
1084
1140
|
if (!view || editorSession.type !== "canonical" || deps.getReadOnly()) return false;
|
|
1085
1141
|
const prepared = editorSession.session.prepareOperations(view.state, ops);
|
|
1086
1142
|
if (prepared.isErr()) {
|
|
1087
|
-
refuse(prepared.error.message, prepared.error.
|
|
1143
|
+
refuse(prepared.error.message, prepared.error.ground);
|
|
1088
1144
|
return false;
|
|
1089
1145
|
}
|
|
1090
1146
|
return publishCommit(prepared.value);
|
|
@@ -1094,7 +1150,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
1094
1150
|
if (editorSession.type !== "canonical" || editorSession.session.isComposing) return null;
|
|
1095
1151
|
const result = editorSession.session.projectStory(story);
|
|
1096
1152
|
if (result.isErr()) {
|
|
1097
|
-
refuse(result.error.message, result.error.
|
|
1153
|
+
refuse(result.error.message, result.error.ground);
|
|
1098
1154
|
return null;
|
|
1099
1155
|
}
|
|
1100
1156
|
return result.value.doc;
|
|
@@ -1107,7 +1163,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
1107
1163
|
story
|
|
1108
1164
|
});
|
|
1109
1165
|
if (prepared.isErr()) {
|
|
1110
|
-
refuse(prepared.error.message, prepared.error.
|
|
1166
|
+
refuse(prepared.error.message, prepared.error.ground);
|
|
1111
1167
|
return false;
|
|
1112
1168
|
}
|
|
1113
1169
|
return publishStoryCommit(storyView, prepared.value);
|
|
@@ -80,5 +80,7 @@ export type LayoutPipelineDeps<THfPMs> = {
|
|
|
80
80
|
markupView: DisplayMode;
|
|
81
81
|
/** Independent highlight visibility in All Markup; resolved views always hide comments. */
|
|
82
82
|
showCommentHighlights?: boolean;
|
|
83
|
+
/** Localised text for a `w:altChunk` that has no text of its own to show. */
|
|
84
|
+
altChunkMarkerText?: string;
|
|
83
85
|
};
|
|
84
86
|
export declare function runLayoutPipeline<THfPMs>(deps: LayoutPipelineDeps<THfPMs>, state: EditorState, options?: LayoutRunOptions): LayoutOutcome;
|
|
@@ -17,6 +17,7 @@ import { applyTemplatePreviewToBlocks } from "../layout-bridge/convert/templateP
|
|
|
17
17
|
import { toFlowBlocks } from "../layout-bridge/convert/toFlowBlocks.js";
|
|
18
18
|
import { getColumns } from "../layout-bridge/sectionColumns.js";
|
|
19
19
|
import { resolveAnchorLayoutInCellCompatibility } from "../layout-engine/anchorLayoutInCellCompatibility.js";
|
|
20
|
+
import { applyFootnoteContinuation, footnoteContinuationSettled, planFootnoteContinuation } from "../layout-engine/footnoteContinuation.js";
|
|
20
21
|
import { layoutDocument } from "../layout-engine/index.js";
|
|
21
22
|
import { resolveJustificationCompatibility } from "../layout-engine/justificationCompatibility.js";
|
|
22
23
|
import { recordLayoutComplete, recordLayoutError, recordLayoutPhase, recordLayoutStart, recordMarkupViewIncomplete } from "../layout-engine/layoutInstrumentation.js";
|
|
@@ -40,12 +41,13 @@ import { diffAgainstCommittedLayout } from "./committedLayoutDiff.js";
|
|
|
40
41
|
import { LAYOUT_MEASURE } from "./layoutRunOptions.js";
|
|
41
42
|
import { survivingComments } from "@stll/docx-core/ops";
|
|
42
43
|
// src/controller/layoutPipeline.ts
|
|
44
|
+
const MAX_FOOTNOTE_CONTINUATION_ROUNDS = 4;
|
|
43
45
|
const formatEndnoteTexts = (numbers, formatNumber) => {
|
|
44
46
|
const texts = /* @__PURE__ */ new Map();
|
|
45
47
|
for (const [id, displayNumber] of numbers) texts.set(id, formatNumber(displayNumber));
|
|
46
48
|
return texts;
|
|
47
49
|
};
|
|
48
|
-
const sameMeasureInputs = (left, right) => left.embeddedFontFamilyMap === right.embeddedFontFamilyMap && left.documentFontFactsCacheIdentity === right.documentFontFactsCacheIdentity && left.styles === right.styles && left.theme === right.theme && left.defaultTabStop === right.defaultTabStop && left.pageContentHeight === right.pageContentHeight && left.fontSet === right.fontSet && left.fontAlternates.size === right.fontAlternates.size && [...left.fontAlternates].every(([name, alternate]) => right.fontAlternates.get(name) === alternate) && left.markupView === right.markupView && left.showCommentHighlights === right.showCommentHighlights;
|
|
50
|
+
const sameMeasureInputs = (left, right) => left.embeddedFontFamilyMap === right.embeddedFontFamilyMap && left.documentFontFactsCacheIdentity === right.documentFontFactsCacheIdentity && left.styles === right.styles && left.theme === right.theme && left.defaultTabStop === right.defaultTabStop && left.pageContentHeight === right.pageContentHeight && left.fontSet === right.fontSet && left.fontAlternates.size === right.fontAlternates.size && [...left.fontAlternates].every(([name, alternate]) => right.fontAlternates.get(name) === alternate) && left.markupView === right.markupView && left.showCommentHighlights === right.showCommentHighlights && left.altChunkMarkerText === right.altChunkMarkerText;
|
|
49
51
|
/**
|
|
50
52
|
* The range an incremental pass re-measures, or `null` for a full measure: the
|
|
51
53
|
* committed measures must come from the same measure inputs, and the range is
|
|
@@ -139,7 +141,7 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
139
141
|
return result;
|
|
140
142
|
}
|
|
141
143
|
function runLayoutPipelineMeasured(deps, state, options) {
|
|
142
|
-
const { contentWidth, columns, pageSize, margins, pageGap, showMarginGuides, marginGuideColor, syncCoordinator, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, sectionHeaderFooterRefs, theme: _theme, sectionProperties, document, defaultTabStop, mirrorMargins, styles, layout, hfPMs, painter, pagesContainer, session, renderHfFromContentOrPm, renderHeaderFooterContentByRId, readFontSetSignature, buildFootnoteRenderItems, describeInvalidHighlightMarks, pageRenderer = PAGE_RENDERER.legacy, emptyTemplatePreviewEntries: EMPTY_TEMPLATE_PREVIEW_ENTRIES, emptyTemplatePreviewHidden: EMPTY_TEMPLATE_PREVIEW_HIDDEN, markupView, showCommentHighlights = true } = deps;
|
|
144
|
+
const { contentWidth, columns, pageSize, margins, pageGap, showMarginGuides, marginGuideColor, syncCoordinator, headerContent, footerContent, firstPageHeaderContent, firstPageFooterContent, headerContentRId, footerContentRId, firstPageHeaderContentRId, firstPageFooterContentRId, sectionHeaderFooterRefs, theme: _theme, sectionProperties, document, defaultTabStop, mirrorMargins, styles, layout, hfPMs, painter, pagesContainer, session, renderHfFromContentOrPm, renderHeaderFooterContentByRId, readFontSetSignature, buildFootnoteRenderItems, describeInvalidHighlightMarks, pageRenderer = PAGE_RENDERER.legacy, emptyTemplatePreviewEntries: EMPTY_TEMPLATE_PREVIEW_ENTRIES, emptyTemplatePreviewHidden: EMPTY_TEMPLATE_PREVIEW_HIDDEN, markupView, showCommentHighlights = true, altChunkMarkerText } = deps;
|
|
143
145
|
let outcome = {};
|
|
144
146
|
let pendingArtifacts;
|
|
145
147
|
let pendingTemplatePreview;
|
|
@@ -170,10 +172,12 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
170
172
|
fontSet,
|
|
171
173
|
fontAlternates,
|
|
172
174
|
markupView,
|
|
173
|
-
showCommentHighlights: displayCommentHighlights
|
|
175
|
+
showCommentHighlights: displayCommentHighlights,
|
|
176
|
+
...altChunkMarkerText === void 0 ? {} : { altChunkMarkerText }
|
|
174
177
|
};
|
|
175
178
|
const flowOpts = {
|
|
176
179
|
showCommentHighlights: displayCommentHighlights,
|
|
180
|
+
...altChunkMarkerText === void 0 ? {} : { altChunkMarkerText },
|
|
177
181
|
...embeddedFontFamilies,
|
|
178
182
|
...documentFontFacts === void 0 ? {} : { documentFontFacts },
|
|
179
183
|
pageContentHeight,
|
|
@@ -258,6 +262,7 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
258
262
|
return {
|
|
259
263
|
markupView,
|
|
260
264
|
showCommentHighlights: displayCommentHighlights,
|
|
265
|
+
...altChunkMarkerText === void 0 ? {} : { altChunkMarkerText },
|
|
261
266
|
...flowOpts.styles ? { styles: flowOpts.styles } : {},
|
|
262
267
|
...document?.package.numbering === void 0 ? {} : { numbering: document.package.numbering },
|
|
263
268
|
...flowOpts.defaultSize === void 0 ? {} : { defaultSize: flowOpts.defaultSize },
|
|
@@ -394,6 +399,7 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
394
399
|
const noteOptions = {
|
|
395
400
|
measureBlocks,
|
|
396
401
|
showCommentHighlights: displayCommentHighlights,
|
|
402
|
+
...altChunkMarkerText === void 0 ? {} : { altChunkMarkerText },
|
|
397
403
|
markupView
|
|
398
404
|
};
|
|
399
405
|
if (flowOpts.styles) noteOptions.styles = flowOpts.styles;
|
|
@@ -427,6 +433,16 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
427
433
|
noteAreas: endnoteAreas.noteAreas
|
|
428
434
|
});
|
|
429
435
|
};
|
|
436
|
+
const withFootnoteHeights = (nextLayoutOpts) => {
|
|
437
|
+
if (!hasFootnotes) return nextLayoutOpts;
|
|
438
|
+
const footnoteHeightById = /* @__PURE__ */ new Map();
|
|
439
|
+
for (const [id, content] of footnoteContentMap) footnoteHeightById.set(id, content.height + 0);
|
|
440
|
+
return {
|
|
441
|
+
...nextLayoutOpts,
|
|
442
|
+
footnoteHeightById,
|
|
443
|
+
footnoteContinuation: nextLayoutOpts.footnoteContinuation ?? { trailingPages: 0 }
|
|
444
|
+
};
|
|
445
|
+
};
|
|
430
446
|
phaseStartedAt = performance.now();
|
|
431
447
|
let newLayout;
|
|
432
448
|
let pageFootnoteMap = /* @__PURE__ */ new Map();
|
|
@@ -466,12 +482,7 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
466
482
|
let layoutOptsUsed = layoutOpts;
|
|
467
483
|
if (hasFootnotes) {
|
|
468
484
|
footnoteContentMap = buildFootnoteContentMap(documentFootnotes, footnoteRefs, contentWidth, buildNoteOptions());
|
|
469
|
-
|
|
470
|
-
for (const [id, content] of footnoteContentMap) footnoteHeightById.set(id, content.height + 0);
|
|
471
|
-
layoutOptsUsed = {
|
|
472
|
-
...layoutOpts,
|
|
473
|
-
footnoteHeightById
|
|
474
|
-
};
|
|
485
|
+
layoutOptsUsed = withFootnoteHeights(layoutOpts);
|
|
475
486
|
newLayout = layoutWithNoteAreas(newMeasures, layoutOptsUsed);
|
|
476
487
|
pageFootnoteMap = /* @__PURE__ */ new Map();
|
|
477
488
|
for (const page of newLayout.pages) if (page.footnoteIds && page.footnoteIds.length > 0) pageFootnoteMap.set(page.number, page.footnoteIds);
|
|
@@ -480,15 +491,6 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
480
491
|
pageFootnoteMap = /* @__PURE__ */ new Map();
|
|
481
492
|
for (const page of newLayout.pages) if (page.footnoteIds && page.footnoteIds.length > 0) pageFootnoteMap.set(page.number, page.footnoteIds);
|
|
482
493
|
};
|
|
483
|
-
const withFootnoteHeights = (nextLayoutOpts) => {
|
|
484
|
-
if (!hasFootnotes) return nextLayoutOpts;
|
|
485
|
-
const footnoteHeightById = /* @__PURE__ */ new Map();
|
|
486
|
-
for (const [id, content] of footnoteContentMap) footnoteHeightById.set(id, content.height + 0);
|
|
487
|
-
return {
|
|
488
|
-
...nextLayoutOpts,
|
|
489
|
-
footnoteHeightById
|
|
490
|
-
};
|
|
491
|
-
};
|
|
492
494
|
const relayoutWithCurrentMeasures = (nextLayoutOpts) => {
|
|
493
495
|
layoutOptsUsed = withFootnoteHeights(nextLayoutOpts);
|
|
494
496
|
newLayout = layoutWithNoteAreas(newMeasures, layoutOptsUsed);
|
|
@@ -549,6 +551,41 @@ function runLayoutPipelineMeasured(deps, state, options) {
|
|
|
549
551
|
};
|
|
550
552
|
let stabilizedFieldValues;
|
|
551
553
|
stabilizeFieldWidths();
|
|
554
|
+
if (hasFootnotes) {
|
|
555
|
+
const usedTrailingPages = () => layoutOptsUsed.footnoteContinuation?.trailingPages ?? 0;
|
|
556
|
+
const planContinuation = () => planFootnoteContinuation({
|
|
557
|
+
pages: newLayout.pages,
|
|
558
|
+
contentById: footnoteContentMap,
|
|
559
|
+
trailingPages: usedTrailingPages()
|
|
560
|
+
});
|
|
561
|
+
const relayoutFor = (reservedHeights, trailingPages) => {
|
|
562
|
+
relayoutWithCurrentMeasures({
|
|
563
|
+
...layoutOptsUsed,
|
|
564
|
+
...reservedHeights === void 0 ? {} : { footnoteReservedHeights: reservedHeights },
|
|
565
|
+
footnoteContinuation: { trailingPages }
|
|
566
|
+
});
|
|
567
|
+
stabilizeFieldWidths();
|
|
568
|
+
};
|
|
569
|
+
let continuation = planContinuation();
|
|
570
|
+
for (let round = 0; round < MAX_FOOTNOTE_CONTINUATION_ROUNDS && !footnoteContinuationSettled({
|
|
571
|
+
reservedHeights: layoutOptsUsed.footnoteReservedHeights,
|
|
572
|
+
trailingPages: usedTrailingPages()
|
|
573
|
+
}, continuation); round += 1) {
|
|
574
|
+
relayoutFor(continuation.reservedHeights, continuation.trailingPages);
|
|
575
|
+
continuation = planContinuation();
|
|
576
|
+
}
|
|
577
|
+
while (continuation.extraPages > 0) {
|
|
578
|
+
relayoutFor(layoutOptsUsed.footnoteReservedHeights, continuation.trailingPages);
|
|
579
|
+
continuation = planContinuation();
|
|
580
|
+
}
|
|
581
|
+
if (continuation.pages.size > 0) {
|
|
582
|
+
newLayout = {
|
|
583
|
+
...newLayout,
|
|
584
|
+
pages: applyFootnoteContinuation(newLayout.pages, continuation)
|
|
585
|
+
};
|
|
586
|
+
rebuildFootnotePageMap();
|
|
587
|
+
}
|
|
588
|
+
}
|
|
552
589
|
newLayout = attachAuthoredMarginsToLayoutPages(newLayout, {
|
|
553
590
|
authoredMargins: margins,
|
|
554
591
|
mirrorMargins,
|
|
@@ -37,6 +37,7 @@ export type LayoutMeasureInputs = {
|
|
|
37
37
|
/** The review view: each lays out different text, so a measure is reusable only within one. */
|
|
38
38
|
markupView: DisplayMode;
|
|
39
39
|
showCommentHighlights?: boolean;
|
|
40
|
+
altChunkMarkerText?: string;
|
|
40
41
|
};
|
|
41
42
|
export type LayoutSession = {
|
|
42
43
|
embeddedFontFamilyMap?: ReadonlyMap<string, string>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
|
|
3
3
|
import { NoteStoryKey } from "../types/editor-story.js";
|
|
4
4
|
import { HiddenEditorApi } from "./hiddenEditorApi.js";
|
|
5
5
|
import { Plugin } from "prosemirror-state";
|
|
@@ -15,7 +15,7 @@ export type NoteEditorManagerDeps = {
|
|
|
15
15
|
getDocument: () => document_d_exports.Document | null;
|
|
16
16
|
getCanonicalApi?: (() => HiddenEditorApi | null) | undefined;
|
|
17
17
|
getExperimentalSession?: (() => "canonical" | undefined) | undefined;
|
|
18
|
-
onSessionRefusal?: ((reason: string,
|
|
18
|
+
onSessionRefusal?: ((reason: string, ground: CanonicalRefusalGround, error?: Error) => void) | undefined;
|
|
19
19
|
getHost: () => HTMLElement | null;
|
|
20
20
|
getPlugins?: (() => Plugin[]) | undefined;
|
|
21
21
|
getStyles: () => document_d_exports.StyleDefinitions | null | undefined;
|
|
@@ -40,10 +40,10 @@ const buildInitialState = (document, styles, numbering, manager, externalPlugins
|
|
|
40
40
|
doc: document,
|
|
41
41
|
schema,
|
|
42
42
|
plugins: [
|
|
43
|
+
createDocumentNumberingPlugin(numbering),
|
|
43
44
|
...manager.getPlugins(),
|
|
44
45
|
...externalPlugins,
|
|
45
|
-
createDocumentStylesPlugin(styles)
|
|
46
|
-
createDocumentNumberingPlugin(numbering)
|
|
46
|
+
createDocumentStylesPlugin(styles)
|
|
47
47
|
]
|
|
48
48
|
})));
|
|
49
49
|
};
|
|
@@ -200,7 +200,7 @@ const createNoteEditorManager = (deps) => {
|
|
|
200
200
|
...canonical.props,
|
|
201
201
|
state: canonicalProjection ? EditorState.create({
|
|
202
202
|
doc: canonicalProjection,
|
|
203
|
-
plugins: [
|
|
203
|
+
plugins: [createDocumentNumberingPlugin(numbering), createDocumentStyleContextPlugin(styles)]
|
|
204
204
|
}) : buildInitialState(proseDocument, styles, numbering, manager, externalPlugins),
|
|
205
205
|
dispatchTransaction(transaction) {
|
|
206
206
|
if (canonical.dispatch(transaction)) return;
|
|
@@ -208,7 +208,7 @@ const createNoteEditorManager = (deps) => {
|
|
|
208
208
|
const docChanged = !nextState.doc.eq(view.state.doc);
|
|
209
209
|
view.updateState(nextState);
|
|
210
210
|
const noteIssue = noteReferenceTransactionIssue(transaction);
|
|
211
|
-
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, CANONICAL_GAP.dispatch, noteIssue);
|
|
211
|
+
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, { gap: CANONICAL_GAP.dispatch }, noteIssue);
|
|
212
212
|
const mountedStory = mounted.get(key);
|
|
213
213
|
if (mountedStory && docChanged) mountedStory.dirty = true;
|
|
214
214
|
deps.onTransaction?.({
|
|
@@ -257,7 +257,7 @@ const createNoteEditorManager = (deps) => {
|
|
|
257
257
|
const canonical = deps.getCanonicalApi?.()?.getCanonicalDocument();
|
|
258
258
|
if (canonical) return canonical;
|
|
259
259
|
throw new CanonicalSessionError({
|
|
260
|
-
gap: CANONICAL_GAP.authorityRouting,
|
|
260
|
+
ground: { gap: CANONICAL_GAP.authorityRouting },
|
|
261
261
|
reason: "refused",
|
|
262
262
|
message: "Canonical story snapshot is unavailable."
|
|
263
263
|
});
|