@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { applyTableColumnDeletion, applyTableColumnInsertion, applyTableRowDeletion } from "../../../ai-edits/table-row-column-mutations.js";
|
|
1
2
|
import { setTableLookFlags } from "../../../docx/tableLook.js";
|
|
2
3
|
import { TABLE_JUSTIFICATION_VALUES, TABLE_WIDTH_TYPE_VALUES, TEXT_DIRECTION_VALUES } from "../../../types/documentEnumValues.js";
|
|
3
4
|
import { cssBorderStyle } from "../../../utils/borderCss.js";
|
|
@@ -5,9 +6,12 @@ import { isValidHexColor, resolveColor } from "../../../utils/colorResolver.js";
|
|
|
5
6
|
import { resolveTablePlacementAlignment } from "../../../utils/tablePlacement.js";
|
|
6
7
|
import { textFlowCss } from "../../../utils/textDirectionFlow.js";
|
|
7
8
|
import { expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs } from "../../attrs/index.js";
|
|
9
|
+
import { withCanonicalCellMerge, withCanonicalCellSplit, withCanonicalColumnDeletion, withCanonicalColumnInsertion, withCanonicalRowDeletion, withCanonicalRowInsertion, withCanonicalTableAttributeCommand, withCanonicalTableDeletion, withCanonicalTableInsertion } from "../../canonicalTableCommands.js";
|
|
10
|
+
import { mintRevisionId } from "../../plugins/revisionIds.js";
|
|
8
11
|
import { makeRevisionInfo } from "../../plugins/suggestionMode.js";
|
|
9
12
|
import { pasteTableCells, pastedSliceWithNewTableCells } from "../../tableCellPaste.js";
|
|
10
13
|
import { insertTableColumn, removeTableColumns, removeTableRow } from "../../tableGridMutation.js";
|
|
14
|
+
import { tablePositionedBookmarksPlugin } from "../../tablePositionedBookmarks.js";
|
|
11
15
|
import { createExtension, createNodeExtension } from "../create.js";
|
|
12
16
|
import { panic } from "better-result";
|
|
13
17
|
import { statesNoBorder } from "@stll/docx-core/model";
|
|
@@ -37,9 +41,31 @@ const hasOmittedGridSlots = (table) => {
|
|
|
37
41
|
});
|
|
38
42
|
return found;
|
|
39
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* With Track Changes on, a revision for a structural table edit touching `count`
|
|
46
|
+
* cells or rows. Each takes the next id of a run reserved here, as the document
|
|
47
|
+
* operations do.
|
|
48
|
+
*/
|
|
49
|
+
const trackedTableRevision = (state, count) => {
|
|
50
|
+
const info = makeRevisionInfo(state);
|
|
51
|
+
if (!info) return null;
|
|
52
|
+
for (let reserved = 1; reserved < count; reserved += 1) mintRevisionId();
|
|
53
|
+
return {
|
|
54
|
+
revisionId: info.id,
|
|
55
|
+
author: info.author,
|
|
56
|
+
date: info.date
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* A merged cell cannot run through a position a row omits, nor is that position
|
|
61
|
+
* a cell to split: the file has nothing there to hold either.
|
|
62
|
+
*/
|
|
40
63
|
const preserveOmittedGridSlots = (command) => (state, dispatch, view) => {
|
|
41
64
|
const { table } = getTableContext(state);
|
|
42
|
-
if (table && hasOmittedGridSlots(table))
|
|
65
|
+
if (table && hasOmittedGridSlots(table)) {
|
|
66
|
+
const rect = selectedRect(state);
|
|
67
|
+
if (rect.map.cellsInRect(rect).some((position) => isOmittedGridSlot(expectTableCellAttrs(rect.table.nodeAt(position) ?? table)._omittedGridSlot))) return false;
|
|
68
|
+
}
|
|
43
69
|
return command(state, dispatch, view);
|
|
44
70
|
};
|
|
45
71
|
const preserveSourceCellIdentity = (command) => (state, dispatch, view) => {
|
|
@@ -373,7 +399,7 @@ const statedCellWidth = (value, type) => ({
|
|
|
373
399
|
}
|
|
374
400
|
});
|
|
375
401
|
const tableCellSpec = {
|
|
376
|
-
content: "(paragraph | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary)+",
|
|
402
|
+
content: "(paragraph | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary | blockCommentRangeBoundary)+",
|
|
377
403
|
tableRole: "cell",
|
|
378
404
|
isolating: true,
|
|
379
405
|
attrs: {
|
|
@@ -443,7 +469,7 @@ const tableCellSpec = {
|
|
|
443
469
|
}
|
|
444
470
|
};
|
|
445
471
|
const tableHeaderSpec = {
|
|
446
|
-
content: "(paragraph | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary)+",
|
|
472
|
+
content: "(paragraph | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary | blockCommentRangeBoundary)+",
|
|
447
473
|
tableRole: "header_cell",
|
|
448
474
|
isolating: true,
|
|
449
475
|
attrs: {
|
|
@@ -827,7 +853,7 @@ const TablePluginExtension = createExtension({
|
|
|
827
853
|
*/
|
|
828
854
|
function insertTableRow(state, dispatch, boundaryOffset) {
|
|
829
855
|
const context = getTableContext(state);
|
|
830
|
-
if (!context.isInTable || context.rowIndex === void 0 || !context.table || context.tablePos === void 0
|
|
856
|
+
if (!context.isInTable || context.rowIndex === void 0 || !context.table || context.tablePos === void 0) return false;
|
|
831
857
|
if (!dispatch) return true;
|
|
832
858
|
const { table, tablePos } = context;
|
|
833
859
|
const rect = selectedRect(state);
|
|
@@ -854,9 +880,11 @@ const TablePluginExtension = createExtension({
|
|
|
854
880
|
continue;
|
|
855
881
|
}
|
|
856
882
|
const templatePos = below ?? above;
|
|
857
|
-
|
|
883
|
+
const templateCell = templatePos === void 0 ? null : table.nodeAt(templatePos);
|
|
884
|
+
const omitted = templateCell?.attrs["_omittedGridSlot"] != null;
|
|
885
|
+
if (templatePos === void 0 || !omitted && templatePos === lastTemplatePos) continue;
|
|
858
886
|
lastTemplatePos = templatePos;
|
|
859
|
-
const template =
|
|
887
|
+
const template = omitted ? null : templateCell;
|
|
860
888
|
cells.push((template?.type ?? tableNodeTypes(state.schema).cell).create(buildCellAttrsFromTemplate(template), paragraphType?.create() ?? null));
|
|
861
889
|
}
|
|
862
890
|
const rowNode = table.child(boundaryOffset === 0 ? rect.top : rect.bottom - 1);
|
|
@@ -879,7 +907,6 @@ const TablePluginExtension = createExtension({
|
|
|
879
907
|
function deleteRow(state, dispatch) {
|
|
880
908
|
const context = getTableContext(state);
|
|
881
909
|
if (!context.isInTable || context.rowIndex === void 0 || !context.table || context.tablePos === void 0) return false;
|
|
882
|
-
if (hasOmittedGridSlots(context.table)) return false;
|
|
883
910
|
const tablePos = context.tablePos;
|
|
884
911
|
const table = context.table;
|
|
885
912
|
const rowCount = context.rowCount ?? 0;
|
|
@@ -897,6 +924,30 @@ const TablePluginExtension = createExtension({
|
|
|
897
924
|
const coversAllRows = firstRow === 0 && lastRow >= rowCount - 1;
|
|
898
925
|
if (dispatch) {
|
|
899
926
|
const tr = state.tr;
|
|
927
|
+
const revision = trackedTableRevision(state, lastRow - firstRow + 1);
|
|
928
|
+
if (revision) {
|
|
929
|
+
const rows = [];
|
|
930
|
+
table.forEach((_row, offset, rowIndex) => {
|
|
931
|
+
if (rowIndex >= firstRow && rowIndex <= lastRow) rows.push({
|
|
932
|
+
rowIndex,
|
|
933
|
+
rowPosition: tablePos + 1 + offset
|
|
934
|
+
});
|
|
935
|
+
});
|
|
936
|
+
for (const [index, row] of rows.entries()) applyTableRowDeletion({
|
|
937
|
+
tr,
|
|
938
|
+
deletion: {
|
|
939
|
+
...row,
|
|
940
|
+
tablePosition: tablePos,
|
|
941
|
+
tableStart: tablePos + 1
|
|
942
|
+
},
|
|
943
|
+
revision: {
|
|
944
|
+
...revision,
|
|
945
|
+
revisionId: revision.revisionId + index
|
|
946
|
+
}
|
|
947
|
+
});
|
|
948
|
+
dispatch(tr.scrollIntoView());
|
|
949
|
+
return true;
|
|
950
|
+
}
|
|
900
951
|
if (coversAllRows) {
|
|
901
952
|
const tableEnd = tablePos + table.nodeSize;
|
|
902
953
|
const emptyParagraph = state.doc.resolve(tablePos).parent.childCount === 1 ? state.schema.nodes["paragraph"]?.createAndFill() : null;
|
|
@@ -931,7 +982,22 @@ const TablePluginExtension = createExtension({
|
|
|
931
982
|
*/
|
|
932
983
|
function insertColumnBeside(state, dispatch, side) {
|
|
933
984
|
const context = getTableContext(state);
|
|
934
|
-
if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0
|
|
985
|
+
if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0) return false;
|
|
986
|
+
if (makeRevisionInfo(state) !== null) {
|
|
987
|
+
const rect = selectedRect(state);
|
|
988
|
+
const tr = state.tr;
|
|
989
|
+
if (applyTableColumnInsertion({
|
|
990
|
+
tr,
|
|
991
|
+
insertion: {
|
|
992
|
+
tablePosition: rect.tableStart - 1,
|
|
993
|
+
columnIndex: side === "left" ? rect.left : rect.right
|
|
994
|
+
},
|
|
995
|
+
cellTexts: void 0,
|
|
996
|
+
revision: trackedTableRevision(state, rect.map.height)
|
|
997
|
+
}).type !== "applied") return false;
|
|
998
|
+
if (dispatch) dispatch(tr.scrollIntoView());
|
|
999
|
+
return true;
|
|
1000
|
+
}
|
|
935
1001
|
if (dispatch) {
|
|
936
1002
|
const rect = selectedRect(state);
|
|
937
1003
|
const tr = state.tr;
|
|
@@ -968,9 +1034,23 @@ const TablePluginExtension = createExtension({
|
|
|
968
1034
|
*/
|
|
969
1035
|
function deleteColumn(state, dispatch) {
|
|
970
1036
|
const context = getTableContext(state);
|
|
971
|
-
if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0 || (context.columnCount ?? 0) <= 1
|
|
1037
|
+
if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0 || (context.columnCount ?? 0) <= 1) return false;
|
|
972
1038
|
const rect = selectedRect(state);
|
|
973
1039
|
if (rect.right - rect.left >= rect.map.width) return false;
|
|
1040
|
+
if (makeRevisionInfo(state) !== null) {
|
|
1041
|
+
const tr = state.tr;
|
|
1042
|
+
for (let column = rect.left; column < rect.right; column += 1) if (applyTableColumnDeletion({
|
|
1043
|
+
tr,
|
|
1044
|
+
deletion: {
|
|
1045
|
+
tablePosition: rect.tableStart - 1,
|
|
1046
|
+
columnIndex: column
|
|
1047
|
+
},
|
|
1048
|
+
insertedColumnCount: 0,
|
|
1049
|
+
revision: trackedTableRevision(state, rect.map.height)
|
|
1050
|
+
}).type !== "applied") return false;
|
|
1051
|
+
if (dispatch) dispatch(tr.scrollIntoView());
|
|
1052
|
+
return true;
|
|
1053
|
+
}
|
|
974
1054
|
if (dispatch) {
|
|
975
1055
|
const tr = state.tr;
|
|
976
1056
|
removeTableColumns(tr, rect.tableStart - 1, rect.left, rect.right);
|
|
@@ -1917,6 +1997,7 @@ const TablePluginExtension = createExtension({
|
|
|
1917
1997
|
}),
|
|
1918
1998
|
tableCellPastePlugin,
|
|
1919
1999
|
tableEditing(),
|
|
2000
|
+
tablePositionedBookmarksPlugin(),
|
|
1920
2001
|
activeCellPlugin
|
|
1921
2002
|
],
|
|
1922
2003
|
keyboardShortcuts: {
|
|
@@ -1924,39 +2005,39 @@ const TablePluginExtension = createExtension({
|
|
|
1924
2005
|
Delete: chainCommands(deleteTableIfSelected(), preventTableMergeAtGap())
|
|
1925
2006
|
},
|
|
1926
2007
|
commands: {
|
|
1927
|
-
insertTable: (rows, cols) => insertTable(rows, cols),
|
|
1928
|
-
addRowAbove: () => addRowAbove,
|
|
1929
|
-
addRowBelow: () => addRowBelow,
|
|
1930
|
-
deleteRow: () => deleteRow,
|
|
1931
|
-
addColumnLeft: () => addColumnLeft,
|
|
1932
|
-
addColumnRight: () => addColumnRight,
|
|
1933
|
-
deleteColumn: () => deleteColumn,
|
|
1934
|
-
deleteTable: () => deleteTable,
|
|
2008
|
+
insertTable: (rows, cols) => withCanonicalTableInsertion(insertTable(rows, cols)),
|
|
2009
|
+
addRowAbove: () => withCanonicalRowInsertion(addRowAbove, "above"),
|
|
2010
|
+
addRowBelow: () => withCanonicalRowInsertion(addRowBelow, "below"),
|
|
2011
|
+
deleteRow: () => withCanonicalRowDeletion(deleteRow),
|
|
2012
|
+
addColumnLeft: () => withCanonicalColumnInsertion(addColumnLeft, "left"),
|
|
2013
|
+
addColumnRight: () => withCanonicalColumnInsertion(addColumnRight, "right"),
|
|
2014
|
+
deleteColumn: () => withCanonicalColumnDeletion(deleteColumn),
|
|
2015
|
+
deleteTable: () => withCanonicalTableDeletion(deleteTable),
|
|
1935
2016
|
selectTable: () => selectTable,
|
|
1936
2017
|
selectRow: () => selectRow,
|
|
1937
2018
|
selectColumn: () => selectColumn,
|
|
1938
|
-
mergeCells: () => preserveOmittedGridSlots(mergeCells),
|
|
1939
|
-
splitCell: () => preserveOmittedGridSlots(preserveSourceCellIdentity(splitCell)),
|
|
1940
|
-
setCellBorder: (side, spec, clearOthers) => setCellBorder(side, spec, clearOthers),
|
|
1941
|
-
setTableBorders: (preset, borderSpec) => setTableBorders(preset, borderSpec),
|
|
1942
|
-
setTableBorderPreset: (preset) => setTableBorderPreset(preset),
|
|
1943
|
-
setCellVerticalAlign: (align) => setCellVerticalAlign(align),
|
|
1944
|
-
setCellMargins: (margins) => setCellMargins(margins),
|
|
1945
|
-
setCellTextDirection: (direction) => setCellTextDirection(direction),
|
|
1946
|
-
toggleNoWrap: () => toggleNoWrap(),
|
|
1947
|
-
setRowHeight: (height, rule) => setRowHeight(height, rule),
|
|
1948
|
-
toggleHeaderRow: () => toggleHeaderRow(),
|
|
1949
|
-
distributeColumns: () => distributeColumns(),
|
|
2019
|
+
mergeCells: () => withCanonicalCellMerge(preserveOmittedGridSlots(mergeCells)),
|
|
2020
|
+
splitCell: () => withCanonicalCellSplit(preserveOmittedGridSlots(preserveSourceCellIdentity(splitCell))),
|
|
2021
|
+
setCellBorder: (side, spec, clearOthers) => withCanonicalTableAttributeCommand(setCellBorder(side, spec, clearOthers)),
|
|
2022
|
+
setTableBorders: (preset, borderSpec) => withCanonicalTableAttributeCommand(setTableBorders(preset, borderSpec)),
|
|
2023
|
+
setTableBorderPreset: (preset) => withCanonicalTableAttributeCommand(setTableBorderPreset(preset)),
|
|
2024
|
+
setCellVerticalAlign: (align) => withCanonicalTableAttributeCommand(setCellVerticalAlign(align)),
|
|
2025
|
+
setCellMargins: (margins) => withCanonicalTableAttributeCommand(setCellMargins(margins)),
|
|
2026
|
+
setCellTextDirection: (direction) => withCanonicalTableAttributeCommand(setCellTextDirection(direction)),
|
|
2027
|
+
toggleNoWrap: () => withCanonicalTableAttributeCommand(toggleNoWrap()),
|
|
2028
|
+
setRowHeight: (height, rule) => withCanonicalTableAttributeCommand(setRowHeight(height, rule)),
|
|
2029
|
+
toggleHeaderRow: () => withCanonicalTableAttributeCommand(toggleHeaderRow()),
|
|
2030
|
+
distributeColumns: () => withCanonicalTableAttributeCommand(distributeColumns()),
|
|
1950
2031
|
autoFitContents: () => autoFitContents(),
|
|
1951
|
-
setTableProperties: (props) => setTableProperties(props),
|
|
1952
|
-
applyTableStyle: (styleData) => applyTableStyle(styleData),
|
|
1953
|
-
setCellFillColor: (color) => setCellFillColor(color),
|
|
1954
|
-
setTableBorderColor: (color) => setTableBorderColor(color),
|
|
1955
|
-
setTableBorderWidth: (size) => setTableBorderWidth(size),
|
|
1956
|
-
removeTableBorders: () => setTableBorders("none"),
|
|
1957
|
-
setAllTableBorders: (borderSpec) => setTableBorders("all", borderSpec),
|
|
1958
|
-
setOutsideTableBorders: (borderSpec) => setTableBorders("outside", borderSpec),
|
|
1959
|
-
setInsideTableBorders: (borderSpec) => setTableBorders("inside", borderSpec)
|
|
2032
|
+
setTableProperties: (props) => withCanonicalTableAttributeCommand(setTableProperties(props)),
|
|
2033
|
+
applyTableStyle: (styleData) => withCanonicalTableAttributeCommand(applyTableStyle(styleData)),
|
|
2034
|
+
setCellFillColor: (color) => withCanonicalTableAttributeCommand(setCellFillColor(color)),
|
|
2035
|
+
setTableBorderColor: (color) => withCanonicalTableAttributeCommand(setTableBorderColor(color)),
|
|
2036
|
+
setTableBorderWidth: (size) => withCanonicalTableAttributeCommand(setTableBorderWidth(size)),
|
|
2037
|
+
removeTableBorders: () => withCanonicalTableAttributeCommand(setTableBorders("none")),
|
|
2038
|
+
setAllTableBorders: (borderSpec) => withCanonicalTableAttributeCommand(setTableBorders("all", borderSpec)),
|
|
2039
|
+
setOutsideTableBorders: (borderSpec) => withCanonicalTableAttributeCommand(setTableBorders("outside", borderSpec)),
|
|
2040
|
+
setInsideTableBorders: (borderSpec) => withCanonicalTableAttributeCommand(setTableBorders("inside", borderSpec))
|
|
1960
2041
|
}
|
|
1961
2042
|
};
|
|
1962
2043
|
}
|
|
@@ -71,7 +71,7 @@ const TextBoxExtension = createNodeExtension({
|
|
|
71
71
|
schemaNodeName: "textBox",
|
|
72
72
|
nodeSpec: {
|
|
73
73
|
group: "block",
|
|
74
|
-
content: "(paragraph | table)+",
|
|
74
|
+
content: "(paragraph | table | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary | blockMoveRangeBoundary | blockCommentRangeBoundary)+",
|
|
75
75
|
isolating: true,
|
|
76
76
|
draggable: true,
|
|
77
77
|
attrs: {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
/**
|
|
3
|
+
* How an inline node with no visible content sits in the editor's DOM.
|
|
4
|
+
*
|
|
5
|
+
* It takes no space, but it keeps a box. A browser's editing commands skip what
|
|
6
|
+
* has no box, so replacing the composition text beside a `display: none` element
|
|
7
|
+
* also removed the element, and the next DOM read lost the node it stood for.
|
|
8
|
+
*/
|
|
9
|
+
export declare const INLINE_ANCHOR_DOM_STYLE = "display: inline-block; width: 0; height: 0; overflow: hidden;";
|
|
10
|
+
/** Whether a node is one of those, which the caret passes without stopping. */
|
|
11
|
+
export declare const isInlineAnchor: (node: Node) => boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/prosemirror/extensions/nodes/inlineAnchorDom.ts
|
|
2
|
+
/**
|
|
3
|
+
* How an inline node with no visible content sits in the editor's DOM.
|
|
4
|
+
*
|
|
5
|
+
* It takes no space, but it keeps a box. A browser's editing commands skip what
|
|
6
|
+
* has no box, so replacing the composition text beside a `display: none` element
|
|
7
|
+
* also removed the element, and the next DOM read lost the node it stood for.
|
|
8
|
+
*/
|
|
9
|
+
const INLINE_ANCHOR_DOM_STYLE = "display: inline-block; width: 0; height: 0; overflow: hidden;";
|
|
10
|
+
const INLINE_ANCHOR_NODE_NAMES = /* @__PURE__ */ new Set([
|
|
11
|
+
"bookmarkBoundary",
|
|
12
|
+
"commentRangeBoundary",
|
|
13
|
+
"commentReference",
|
|
14
|
+
"moveRangeBoundary",
|
|
15
|
+
"noteMarker",
|
|
16
|
+
"rangeAnchor",
|
|
17
|
+
"renderedPageBreak"
|
|
18
|
+
]);
|
|
19
|
+
/** Whether a node is one of those, which the caret passes without stopping. */
|
|
20
|
+
const isInlineAnchor = (node) => INLINE_ANCHOR_NODE_NAMES.has(node.type.name);
|
|
21
|
+
export { INLINE_ANCHOR_DOM_STYLE, isInlineAnchor };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { FontFamilyAttrs, FontSizeAttrs, HyperlinkAttrs, TextColorAttrs, UnderlineAttrs } from "./schema/marks.js";
|
|
2
2
|
import { ImageAttrs, ParagraphAttrs } from "./schema/nodes.js";
|
|
3
3
|
import { ResolvedParagraphStyle, StyleResolver, createStyleResolver } from "./styles/styleResolver.js";
|
|
4
|
+
import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
|
|
5
|
+
import { ToProseDocOptions, createEmptyDoc, toProseDoc } from "./conversion/toProseDoc.js";
|
|
4
6
|
import { schema, singletonManager } from "./schema/index.js";
|
|
5
7
|
import { getParagraphAlignment, getParagraphBidi, getStyleId } from "./extensions/core/ParagraphExtension.js";
|
|
6
8
|
import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
|
|
7
9
|
import { TableBorderCommandSpec, TableCellBorderCommandSpec } from "./extensions/types.js";
|
|
8
10
|
import { ListNumberingMenuState, NO_LIST_NUMBERING_MENU, listNumberingMenuState } from "./listNumbering.js";
|
|
9
11
|
import { CapturedTextFormatting, PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./commands/formatPainter.js";
|
|
10
|
-
import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
|
|
11
12
|
import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensions/marks/HyperlinkExtension.js";
|
|
12
13
|
import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./commands/formatting.js";
|
|
13
14
|
import { insertImageFromFile } from "./commands/image.js";
|
|
@@ -17,7 +18,6 @@ import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyl
|
|
|
17
18
|
import { insertPageBreak } from "./commands/pageBreak.js";
|
|
18
19
|
import "./commands/index.js";
|
|
19
20
|
import { FromProseDocOptions, ProjectionReuse, fromProseDoc, updateDocumentContent } from "./conversion/fromProseDoc.js";
|
|
20
|
-
import { ToProseDocOptions, createEmptyDoc, toProseDoc } from "./conversion/toProseDoc.js";
|
|
21
21
|
import { ProseMirrorDocumentValidationIssue, ValidateProseMirrorDocumentResult, assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument } from "./validation.js";
|
|
22
22
|
import "./conversion/index.js";
|
|
23
23
|
import { ActiveListState, ListState, ListType, NO_LIST_STATE, isInListState, listStateLevel, resolveListState, sameListState } from "./listState.js";
|
|
@@ -134,11 +134,12 @@ const createListLabelCounter = (numberingOrStreams = null, suppliedStreams) => {
|
|
|
134
134
|
numPrFromStyle: counterAttrs.numPrFromStyle
|
|
135
135
|
});
|
|
136
136
|
const countedNumbering = effectiveParagraphNumberingReference(countedSources);
|
|
137
|
-
const revisionSelectedRendering = counterInput._propertyChanges?.length && counterAttrs !== counterInput && numbering === null ? listRenderingFromAttrs({
|
|
137
|
+
const revisionSelectedRendering = counterInput._propertyChanges?.length && counterAttrs !== counterInput && numbering === null && countedNumbering !== void 0 ? listRenderingFromAttrs({
|
|
138
138
|
attrs: counterAttrs,
|
|
139
139
|
numId: countedNumbering?.numId ?? 1
|
|
140
140
|
}) : void 0;
|
|
141
|
-
const
|
|
141
|
+
const revisionSelected = counterInput._propertyChanges?.length && counterAttrs !== counterInput && numbering === null;
|
|
142
|
+
const countedList = resolveParagraphList(countedSources, numbering, revisionSelected ? revisionSelectedRendering : revisionSelectedRendering ?? projectedRendering);
|
|
142
143
|
switch (countedList.kind) {
|
|
143
144
|
case "none": return {
|
|
144
145
|
kind: "none",
|
|
@@ -29,6 +29,12 @@ type ResolveListTargetOptions = {
|
|
|
29
29
|
/** Candidate requests, most likely first (see `listRequestsForMarker`). */
|
|
30
30
|
requests: readonly ListRequest[];
|
|
31
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* The instance the package already defines for `request` that no paragraph
|
|
34
|
+
* of the story refers to (`referenced`): a new list takes it before one is
|
|
35
|
+
* minted. One rule for both engines.
|
|
36
|
+
*/
|
|
37
|
+
export declare const unusedListInstanceFor: (numbering: NumberingMap, referenced: ReadonlySet<number>, request: ListRequest) => number | undefined;
|
|
32
38
|
/**
|
|
33
39
|
* The list a paragraph range joins: the list directly above it, else the one
|
|
34
40
|
* directly below it, when it matches one of `requests`; otherwise a new list:
|
|
@@ -149,14 +149,17 @@ const referencedNumIds = (doc) => {
|
|
|
149
149
|
* naming a `w:pStyle`, or a style link) belongs to that style and is never
|
|
150
150
|
* offered.
|
|
151
151
|
*/
|
|
152
|
-
const unusedInstanceFor = (numbering, doc, request) =>
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
152
|
+
const unusedInstanceFor = (numbering, doc, request) => unusedListInstanceFor(numbering, referencedNumIds(doc), request);
|
|
153
|
+
/**
|
|
154
|
+
* The instance the package already defines for `request` that no paragraph
|
|
155
|
+
* of the story refers to (`referenced`): a new list takes it before one is
|
|
156
|
+
* minted. One rule for both engines.
|
|
157
|
+
*/
|
|
158
|
+
const unusedListInstanceFor = (numbering, referenced, request) => numbering.definitions.nums.find(({ numId, abstractNumId }) => {
|
|
159
|
+
const abstract = numbering.getAbstract(abstractNumId);
|
|
160
|
+
const level = numbering.getLevel(numId, 0);
|
|
161
|
+
return !referenced.has(numId) && abstract !== null && abstract.styleLink === void 0 && abstract.numStyleLink === void 0 && abstract.levels.every(({ pStyle }) => pStyle === void 0) && level !== null && levelMatches(level, request) && (level.start ?? 1) === (request.start ?? level.start ?? 1);
|
|
162
|
+
})?.numId;
|
|
160
163
|
/**
|
|
161
164
|
* The list a paragraph range joins: the list directly above it, else the one
|
|
162
165
|
* directly below it, when it matches one of `requests`; otherwise a new list:
|
|
@@ -348,4 +351,4 @@ const listNumberingMenuState = (state) => restartNumbering(state) ? {
|
|
|
348
351
|
type: "listItem",
|
|
349
352
|
canContinue: continueNumbering(state)
|
|
350
353
|
} : NO_LIST_NUMBERING_MENU;
|
|
351
|
-
export { NO_LIST_NUMBERING_MENU, applyParagraphUpdates, continueNumbering, listItemAttrs, listNumberingMenuState, resolveListTarget, restartNumbering, setNumberingValue };
|
|
354
|
+
export { NO_LIST_NUMBERING_MENU, applyParagraphUpdates, continueNumbering, listItemAttrs, listNumberingMenuState, resolveListTarget, restartNumbering, setNumberingValue, unusedListInstanceFor };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
import { LockedControlSpan, LockedControlTouch, LockedControlViolation } from "@stll/docx-core/model";
|
|
3
|
+
import { Transform } from "prosemirror-transform";
|
|
4
|
+
export declare const lockedControlSpans: (doc: Node) => readonly LockedControlSpan[];
|
|
5
|
+
/** What the locks of `doc` say about `touches`: `null` when they permit them all. */
|
|
6
|
+
export declare const lockedControlViolationIn: (doc: Node, touches: readonly LockedControlTouch[]) => LockedControlViolation | null;
|
|
7
|
+
/**
|
|
8
|
+
* What the locks of `transform`'s starting document say about its result: a
|
|
9
|
+
* control whose content is locked must come through with the same content,
|
|
10
|
+
* and one locked against removal must come through at all. Read from the
|
|
11
|
+
* result rather than the steps, so it holds for any step a command takes.
|
|
12
|
+
*/
|
|
13
|
+
export declare const lockedControlViolationOfTransform: (transform: Transform) => LockedControlViolation | null;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { contentControlLockAllows, firstLockedControlViolation } from "@stll/docx-core/model";
|
|
2
|
+
// src/prosemirror/lockedControls.ts
|
|
3
|
+
/** The node types that carry a content control's `w:lock`. */
|
|
4
|
+
const CONTROL_NODE_NAMES = /* @__PURE__ */ new Set(["sdt", "blockSdt"]);
|
|
5
|
+
const lockOf = (node) => {
|
|
6
|
+
if (!CONTROL_NODE_NAMES.has(node.type.name)) return null;
|
|
7
|
+
const lock = node.attrs["lock"];
|
|
8
|
+
switch (lock) {
|
|
9
|
+
case "contentLocked":
|
|
10
|
+
case "sdtContentLocked":
|
|
11
|
+
case "sdtLocked": return lock;
|
|
12
|
+
default: return null;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
/** Every control of `doc` whose lock forbids something, outermost first. */
|
|
16
|
+
const spansByDoc = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
const lockedControlSpans = (doc) => {
|
|
18
|
+
const known = spansByDoc.get(doc);
|
|
19
|
+
if (known !== void 0) return known;
|
|
20
|
+
const spans = [];
|
|
21
|
+
doc.descendants((node, pos) => {
|
|
22
|
+
const lock = lockOf(node);
|
|
23
|
+
if (lock !== null) spans.push({
|
|
24
|
+
lock,
|
|
25
|
+
from: pos,
|
|
26
|
+
to: pos + node.nodeSize,
|
|
27
|
+
contentFrom: pos + 1,
|
|
28
|
+
contentTo: pos + node.nodeSize - 1
|
|
29
|
+
});
|
|
30
|
+
return true;
|
|
31
|
+
});
|
|
32
|
+
spansByDoc.set(doc, spans);
|
|
33
|
+
return spans;
|
|
34
|
+
};
|
|
35
|
+
/** What the locks of `doc` say about `touches`: `null` when they permit them all. */
|
|
36
|
+
const lockedControlViolationIn = (doc, touches) => touches.length === 0 ? null : firstLockedControlViolation(lockedControlSpans(doc), touches);
|
|
37
|
+
/** Marks that annotate content without being part of it. */
|
|
38
|
+
const ANNOTATION_MARKS = /* @__PURE__ */ new Set(["comment", "runIdentity"]);
|
|
39
|
+
/** Attributes that identify a node without being part of its content. */
|
|
40
|
+
const IDENTITY_ATTRS = /* @__PURE__ */ new Set(["paraId", "textId"]);
|
|
41
|
+
const sameAttrs = (left, right) => {
|
|
42
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(left.attrs), ...Object.keys(right.attrs)]);
|
|
43
|
+
for (const key of keys) {
|
|
44
|
+
if (IDENTITY_ATTRS.has(key)) continue;
|
|
45
|
+
if (JSON.stringify(left.attrs[key]) !== JSON.stringify(right.attrs[key])) return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
const contentMarks = (node) => node.marks.filter((mark) => !ANNOTATION_MARKS.has(mark.type.name));
|
|
50
|
+
/** Whether two nodes hold the same content, annotations and identities aside. */
|
|
51
|
+
const sameLockedContent = (left, right) => {
|
|
52
|
+
if (left.type !== right.type) return false;
|
|
53
|
+
if (left.isText && left.text !== right.text) return false;
|
|
54
|
+
if (!sameAttrs(left, right)) return false;
|
|
55
|
+
const leftMarks = contentMarks(left);
|
|
56
|
+
const rightMarks = contentMarks(right);
|
|
57
|
+
if (leftMarks.length !== rightMarks.length || leftMarks.some((mark, index) => {
|
|
58
|
+
const other = rightMarks[index];
|
|
59
|
+
return other === void 0 || !mark.eq(other);
|
|
60
|
+
})) return false;
|
|
61
|
+
return sameLockedChildren(left, right);
|
|
62
|
+
};
|
|
63
|
+
/** Whether two nodes' children hold the same content (their own attributes aside). */
|
|
64
|
+
function sameLockedChildren(left, right) {
|
|
65
|
+
if (left.childCount !== right.childCount) return false;
|
|
66
|
+
for (let index = 0; index < left.childCount; index += 1) if (!sameLockedContent(left.child(index), right.child(index))) return false;
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The node `span`'s control is in `transform`'s result, or `null` when it is
|
|
71
|
+
* gone. A step may rewrite the stretch around a control with a copy of it, so
|
|
72
|
+
* the control is looked for at either side of where its ends map to.
|
|
73
|
+
*/
|
|
74
|
+
const survivorOf = (transform, span, before) => {
|
|
75
|
+
const { mapping, doc } = transform;
|
|
76
|
+
for (const startSide of [1, -1]) for (const endSide of [-1, 1]) {
|
|
77
|
+
const start = mapping.map(span.from, startSide);
|
|
78
|
+
const end = mapping.map(span.to, endSide);
|
|
79
|
+
const after = doc.nodeAt(start);
|
|
80
|
+
if (after?.type === before.type && start + after.nodeSize === end) return after;
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* What the locks of `transform`'s starting document say about its result: a
|
|
86
|
+
* control whose content is locked must come through with the same content,
|
|
87
|
+
* and one locked against removal must come through at all. Read from the
|
|
88
|
+
* result rather than the steps, so it holds for any step a command takes.
|
|
89
|
+
*/
|
|
90
|
+
const lockedControlViolationOfTransform = (transform) => {
|
|
91
|
+
if (!transform.docChanged) return null;
|
|
92
|
+
for (const span of lockedControlSpans(transform.before)) {
|
|
93
|
+
const before = transform.before.nodeAt(span.from);
|
|
94
|
+
if (before === null) continue;
|
|
95
|
+
const after = survivorOf(transform, span, before);
|
|
96
|
+
let change = null;
|
|
97
|
+
if (after === null) change = "removeControl";
|
|
98
|
+
else if (!sameLockedChildren(before, after)) change = "editContent";
|
|
99
|
+
if (change !== null && !contentControlLockAllows(span.lock, change)) return {
|
|
100
|
+
lock: span.lock,
|
|
101
|
+
change
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
};
|
|
106
|
+
export { lockedControlSpans, lockedControlViolationIn, lockedControlViolationOfTransform };
|
|
@@ -93,7 +93,7 @@ const projectStoryMarkupView = ({ doc, markupView, styles, numbering }) => {
|
|
|
93
93
|
if (cached && cached.styles === styles && cached.numbering === numbering) return projectMarkupView(cached.state, markupView);
|
|
94
94
|
const state = EditorState.create({
|
|
95
95
|
doc,
|
|
96
|
-
plugins: [
|
|
96
|
+
plugins: [createDocumentNumberingPlugin(numbering), createDocumentStyleContextPlugin(styles)]
|
|
97
97
|
});
|
|
98
98
|
storyProjectionStates.set(doc, {
|
|
99
99
|
styles,
|
|
@@ -75,9 +75,9 @@ const restoredNote = (note, document, reference) => {
|
|
|
75
75
|
schema,
|
|
76
76
|
doc,
|
|
77
77
|
plugins: [
|
|
78
|
+
createDocumentNumberingPlugin(numbering),
|
|
78
79
|
...pluginsForHeadlessRevisionResolution(singletonManager.getPlugins()),
|
|
79
|
-
createDocumentStylesPlugin(styles)
|
|
80
|
-
createDocumentNumberingPlugin(numbering)
|
|
80
|
+
createDocumentStylesPlugin(styles)
|
|
81
81
|
]
|
|
82
82
|
});
|
|
83
83
|
rejectAIEditRevision(revisions)(state, (transaction) => {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { getCachedNumberingMap } from "../../docx/numberingParser.js";
|
|
2
2
|
import { completeNumberingForDoc, paragraphListReferences } from "../listInstanceReferences.js";
|
|
3
3
|
import { createPluginKeyOwner } from "../pluginKeyOwner.js";
|
|
4
|
+
import { panic } from "better-result";
|
|
4
5
|
import { AddMarkStep, DocAttrStep, RemoveMarkStep, ReplaceAroundStep, ReplaceStep } from "prosemirror-transform";
|
|
5
6
|
import { Plugin } from "prosemirror-state";
|
|
6
7
|
// src/prosemirror/plugins/documentNumbering.ts
|
|
8
|
+
/** Document-scoped numbering definitions for list-editing commands. */
|
|
7
9
|
const documentNumberingKey = createPluginKeyOwner("documentNumbering");
|
|
8
10
|
const completedState = (definitions, doc) => {
|
|
9
11
|
const completed = completeNumberingForDoc(definitions ?? void 0, doc);
|
|
@@ -73,6 +75,7 @@ const getDocumentNumberingForDoc = (doc) => {
|
|
|
73
75
|
const getDocumentNumbering = (state) => {
|
|
74
76
|
const tracked = documentNumberingKey.getState(state);
|
|
75
77
|
if (tracked) return tracked.map;
|
|
78
|
+
if (documentNumberingKey.get(state) !== void 0) panic("Document numbering was read before its plugin applied: place the numbering plugin before the plugins that read it.");
|
|
76
79
|
return getDocumentNumberingForDoc(state.doc);
|
|
77
80
|
};
|
|
78
81
|
/** The package's own definitions, without the instances the document defines. */
|
|
@@ -106,6 +109,6 @@ const getDocumentNumberingInstanceIds = (state) => {
|
|
|
106
109
|
const withDocumentNumbering = (state, definitions) => {
|
|
107
110
|
const previous = documentNumberingKey.get(state);
|
|
108
111
|
const retained = state.plugins.filter((plugin) => plugin !== previous);
|
|
109
|
-
return state.reconfigure({ plugins: retained }).reconfigure({ plugins: [
|
|
112
|
+
return state.reconfigure({ plugins: retained }).reconfigure({ plugins: [createDocumentNumberingPlugin(definitions), ...retained] });
|
|
110
113
|
};
|
|
111
114
|
export { createDocumentNumberingPlugin, getDocumentNumbering, getDocumentNumberingForDoc, getDocumentNumberingInstanceIds, getPackageNumberingDefinitions, getStatedDocumentNumbering, hasDocumentNumbering, withDocumentNumbering };
|
|
@@ -35,14 +35,6 @@ export declare function makeRevisionInfo(state: EditorState): {
|
|
|
35
35
|
* (eigenpal/docx-editor#784).
|
|
36
36
|
*/
|
|
37
37
|
export declare function handleSuggestionPaste(view: Pick<EditorView, "dispatch" | "state">, slice: Slice, pluginState: SuggestionModeState): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* With track changes on, a paste into a table's cells (a cell selection, or a
|
|
40
|
-
* block of copied cells) replaces each cell's content the way a paste over a
|
|
41
|
-
* text selection does: the old content struck through, the pasted content
|
|
42
|
-
* after it as an insertion. When the pasted content is whole paragraphs, the
|
|
43
|
-
* last one ends the cell, so its paragraph mark is tracked as added too:
|
|
44
|
-
* rejecting then drops it and accepting joins the struck paragraphs into it.
|
|
45
|
-
*/
|
|
46
38
|
export declare function handleSuggestionTableCellPaste(view: EditorView, slice: Slice, pluginState: SuggestionModeState): boolean;
|
|
47
39
|
/**
|
|
48
40
|
* Remove `from`..`to` of `tr.doc` as a suggestion: text the current author
|