@stll/folio-core 0.52.0 → 0.53.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/README.md +23 -0
- package/dist/ai-edits/apply.d.ts +26 -1
- package/dist/ai-edits/apply.js +1519 -105
- package/dist/ai-edits/batch-claims.d.ts +130 -0
- package/dist/ai-edits/batch-claims.js +244 -0
- package/dist/ai-edits/blockRange.js +9 -3
- package/dist/ai-edits/character-boundaries.d.ts +43 -0
- package/dist/ai-edits/character-boundaries.js +95 -0
- package/dist/ai-edits/clean-text.d.ts +33 -3
- package/dist/ai-edits/clean-text.js +52 -6
- package/dist/ai-edits/comment-lifecycle.d.ts +18 -0
- package/dist/ai-edits/comment-lifecycle.js +52 -0
- package/dist/ai-edits/headless.d.ts +71 -7
- package/dist/ai-edits/headless.js +381 -41
- package/dist/ai-edits/index.d.ts +2 -1
- package/dist/ai-edits/index.js +2 -1
- package/dist/ai-edits/minimal-replacement.d.ts +21 -6
- package/dist/ai-edits/minimal-replacement.js +134 -15
- package/dist/ai-edits/newListNumbering.d.ts +23 -0
- package/dist/ai-edits/newListNumbering.js +94 -0
- package/dist/ai-edits/note-references.d.ts +96 -0
- package/dist/ai-edits/note-references.js +139 -0
- package/dist/ai-edits/pending-suggestions.d.ts +79 -0
- package/dist/ai-edits/pending-suggestions.js +306 -0
- package/dist/ai-edits/read.d.ts +1 -1
- package/dist/ai-edits/read.js +56 -43
- package/dist/ai-edits/result-validation.d.ts +29 -0
- package/dist/ai-edits/result-validation.js +164 -0
- package/dist/ai-edits/snapshot.d.ts +36 -3
- package/dist/ai-edits/snapshot.js +177 -23
- package/dist/ai-edits/table-cell-mutations.d.ts +1 -1
- package/dist/ai-edits/table-cell-mutations.js +4 -1
- package/dist/ai-edits/table-geometry.d.ts +1 -1
- package/dist/ai-edits/table-row-column-mutations.d.ts +38 -16
- package/dist/ai-edits/table-row-column-mutations.js +61 -26
- package/dist/ai-edits/types.d.ts +155 -16
- package/dist/compare/compare.d.ts +1 -1
- package/dist/compare/compare.js +65 -16
- package/dist/compare/content-alignment.js +13 -2
- package/dist/compare/content-types.d.ts +7 -0
- package/dist/compare/content.d.ts +4 -1
- package/dist/compare/content.js +6 -1
- package/dist/compare/formatting.js +2 -1
- package/dist/compare/inline-atoms.d.ts +21 -4
- package/dist/compare/inline-atoms.js +138 -16
- package/dist/compare/plan.js +10 -5
- package/dist/compare/scenario.js +14 -3
- package/dist/compare/section-boundary-properties.js +1 -1
- package/dist/compare/types.d.ts +4 -2
- package/dist/compare/types.js +2 -1
- package/dist/compare/verification.d.ts +1 -1
- package/dist/compare/verification.js +15 -3
- package/dist/controller/committedLayoutDiff.d.ts +25 -0
- package/dist/controller/committedLayoutDiff.js +71 -0
- package/dist/controller/contentControlWidgetController.d.ts +1 -1
- package/dist/controller/folioEditor.d.ts +1 -1
- package/dist/controller/fontReadiness.d.ts +70 -3
- package/dist/controller/fontReadiness.js +100 -10
- package/dist/controller/headerFooterEditorManager.js +6 -1
- package/dist/controller/layoutPipeline.d.ts +12 -10
- package/dist/controller/layoutPipeline.js +62 -9
- package/dist/controller/layoutRunOptions.d.ts +24 -0
- package/dist/controller/layoutRunOptions.js +17 -0
- package/dist/controller/layoutScheduler.d.ts +19 -14
- package/dist/controller/layoutScheduler.js +15 -12
- package/dist/controller/layoutSession.d.ts +26 -2
- package/dist/controller/layoutSession.js +1 -1
- package/dist/controller/noteEditorManager.js +8 -3
- package/dist/document-operations.d.ts +11 -2
- package/dist/document-operations.js +230 -21
- package/dist/docx/altChunk.d.ts +8 -0
- package/dist/docx/altChunk.js +17 -0
- package/dist/docx/attributeRemainder.d.ts +1 -1
- package/dist/docx/blockContentParser.d.ts +64 -1
- package/dist/docx/blockContentParser.js +17 -4
- package/dist/docx/blockCustomXmlShell.d.ts +7 -0
- package/dist/docx/blockCustomXmlShell.js +14 -0
- package/dist/docx/blockPlainText.js +7 -0
- package/dist/docx/commentAnchorIndex.js +1 -1
- package/dist/docx/commentRangeIntegrity.js +8 -3
- package/dist/docx/commentReferenceNormalization.js +1 -1
- package/dist/docx/commentReplyMarkers.js +20 -1
- package/dist/docx/compatibility.d.ts +1 -1
- package/dist/docx/compatibility.js +34 -13
- package/dist/docx/containerChildren.gen.d.ts +1 -1
- package/dist/docx/containerChildren.gen.js +1 -0
- package/dist/docx/documentParser.js +12 -12
- package/dist/docx/drawingIdNormalization.d.ts +3 -1
- package/dist/docx/drawingIdNormalization.js +6 -1
- package/dist/docx/ensureParaIds.js +119 -97
- package/dist/docx/footnoteParser.js +8 -4
- package/dist/docx/headerFooterParser.js +3 -3
- package/dist/docx/headerFooterReferenceNormalization.d.ts +20 -1
- package/dist/docx/headerFooterReferenceNormalization.js +52 -27
- package/dist/docx/hyperlinkParser.d.ts +1 -1
- package/dist/docx/index.d.ts +1 -1
- package/dist/docx/listNumberingInstances.d.ts +59 -0
- package/dist/docx/listNumberingInstances.js +249 -0
- package/dist/docx/normalizeBaseDirection.js +2 -1
- package/dist/docx/opaqueCarrier.d.ts +7 -0
- package/dist/docx/opaqueCarrier.js +38 -0
- package/dist/docx/packageParts.js +4 -1
- package/dist/docx/paragraphParser.js +91 -24
- package/dist/docx/paragraphPropertySource.d.ts +4 -2
- package/dist/docx/paragraphPropertySource.js +7 -1
- package/dist/docx/paragraphTraversal.js +1 -0
- package/dist/docx/parseWarningMessage.js +4 -1
- package/dist/docx/parser.js +173 -20
- package/dist/docx/rezip.js +27 -5
- package/dist/docx/sdtProperties.js +1 -1
- package/dist/docx/sdtPropertiesPatch.js +3 -0
- package/dist/docx/selectiveSave.js +16 -9
- package/dist/docx/selectiveXmlPatch.js +106 -37
- package/dist/docx/serializer/blockCustomXmlSerializer.d.ts +5 -0
- package/dist/docx/serializer/blockCustomXmlSerializer.js +4 -0
- package/dist/docx/serializer/documentSerializer.js +2 -0
- package/dist/docx/serializer/headerFooterSerializer.js +2 -0
- package/dist/docx/serializer/noteSerializer.js +3 -1
- package/dist/docx/serializer/paragraphSerializer.js +33 -9
- package/dist/docx/serializer/tableSerializer.js +25 -38
- package/dist/docx/server/createBilingualDocument.js +3 -3
- package/dist/docx/tableParser.d.ts +157 -1
- package/dist/docx/tableParser.js +89 -10
- package/dist/docx/textBoxParser.js +1 -1
- package/dist/docx/unzip.d.ts +2 -1
- package/dist/docx/unzip.js +1 -1
- package/dist/docx/wordprocessingPrefixes.d.ts +78 -0
- package/dist/docx/wordprocessingPrefixes.js +286 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +136 -0
- package/dist/i18n/messages/catalogs.gen.js +153 -17
- package/dist/i18n/messages/messages.gen.d.ts +8 -0
- package/dist/internal/compare/inline-presentation.d.ts +2 -1
- package/dist/internal/compare/inline-presentation.js +11 -10
- package/dist/internal/headlessRevisionResolutionGuard.d.ts +2 -8
- package/dist/internal/headlessRevisionResolutionGuard.js +2 -11
- package/dist/internal/indexedPositionMap.d.ts +11 -0
- package/dist/internal/indexedPositionMap.js +42 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
- package/dist/internal/revisionResolutionEdits.d.ts +13 -0
- package/dist/internal/revisionResolutionEdits.js +19 -0
- package/dist/internal/revisionResolutionInline.d.ts +24 -0
- package/dist/internal/{headlessRevisionResolution.js → revisionResolutionInline.js} +61 -43
- package/dist/internal/revisionResolutionStep.d.ts +34 -0
- package/dist/internal/revisionResolutionStep.js +282 -0
- package/dist/internal/revisionResolutionTracking.d.ts +11 -0
- package/dist/internal/revisionResolutionTracking.js +124 -0
- package/dist/internal/wholeStoryRevisionResolution.d.ts +56 -0
- package/dist/internal/wholeStoryRevisionResolution.js +530 -0
- package/dist/layout-bridge/convert/markupViewFlow.d.ts +20 -0
- package/dist/layout-bridge/convert/markupViewFlow.js +123 -0
- package/dist/layout-bridge/convert/tableConversion.js +1 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +10 -1
- package/dist/layout-engine/layoutInstrumentation.d.ts +9 -1
- package/dist/layout-engine/layoutInstrumentation.js +4 -1
- package/dist/layout-engine/measure/cache.d.ts +18 -1
- package/dist/layout-engine/measure/cache.js +31 -1
- package/dist/layout-engine/measure/font-metrics.worker.js +3 -7
- package/dist/layout-engine/measure/measureContainer.js +7 -47
- package/dist/layout-engine/measure/measureHelpers.d.ts +6 -1
- package/dist/layout-engine/measure/measureHelpers.js +22 -2
- package/dist/layout-engine/measure/measureWorker.js +2 -3
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +6 -7
- package/dist/layout-engine/measure/measureWorkerProtocol.js +1 -2
- package/dist/layout-engine/types.d.ts +6 -0
- package/dist/layout-painter/renderPage.js +1 -0
- package/dist/layout-painter/renderParagraph.js +1 -1
- package/dist/managers/ContextMenuManager.js +5 -2
- package/dist/managers/types.d.ts +3 -0
- package/dist/markdown/fromMarkdown.js +2 -1
- package/dist/markdown/internals.d.ts +11 -1
- package/dist/markdown/internals.js +24 -3
- package/dist/markdown/renderBlock.js +39 -9
- package/dist/markdown/renderParagraph.d.ts +13 -1
- package/dist/markdown/renderParagraph.js +85 -38
- package/dist/markdown/renderRuns.js +3 -10
- package/dist/markdown/renderTable.js +24 -12
- package/dist/markdown/trailers.js +2 -2
- package/dist/markdown/types.d.ts +29 -7
- package/dist/paged-layout/incrementalMeasure.d.ts +1 -2
- package/dist/paged-layout/incrementalMeasure.js +1 -9
- package/dist/paged-layout/transactionDirtyRange.d.ts +1 -3
- package/dist/paged-layout/transactionDirtyRange.js +29 -41
- package/dist/panel-layout.d.ts +83 -0
- package/dist/panel-layout.js +96 -0
- package/dist/prosemirror/anchoredTextBoxes.d.ts +37 -0
- package/dist/prosemirror/anchoredTextBoxes.js +156 -0
- package/dist/prosemirror/attrs/index.d.ts +6 -2
- package/dist/prosemirror/attrs/index.js +172 -1
- package/dist/prosemirror/commands/comments.d.ts +7 -8
- package/dist/prosemirror/commands/comments.js +241 -207
- package/dist/prosemirror/commands/contentControls.d.ts +1 -1
- package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +2 -2
- package/dist/prosemirror/commands/index.js +2 -2
- package/dist/prosemirror/commands/paragraph.d.ts +7 -1
- package/dist/prosemirror/commands/paragraph.js +9 -1
- package/dist/prosemirror/commands/paragraphBookmarkJoin.d.ts +13 -0
- package/dist/prosemirror/commands/paragraphBookmarkJoin.js +22 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
- package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +40 -0
- package/dist/prosemirror/commands/resolveAllTableChanges.js +615 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +15 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +46 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.d.ts +16 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.js +59 -0
- package/dist/prosemirror/commands/sectionBreak.js +2 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +8 -2
- package/dist/prosemirror/commands/tableCellMergeResolution.js +1 -1
- package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +181 -31
- package/dist/prosemirror/conversion/toProseDoc.js +39 -4
- package/dist/prosemirror/emptyFieldResultRuns.d.ts +18 -0
- package/dist/prosemirror/emptyFieldResultRuns.js +33 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
- package/dist/prosemirror/extensions/ExtensionManager.js +3 -1
- package/dist/prosemirror/extensions/StarterKit.js +3 -1
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +12 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +161 -123
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +19 -2
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +33 -20
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +31 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +270 -99
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +3 -2
- package/dist/prosemirror/extensions/features/pasteCleanup.js +2 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.d.ts +12 -0
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +126 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +21 -5
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +21 -18
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +37 -17
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +7 -2
- package/dist/prosemirror/extensions/marks/markUtils.js +8 -2
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.d.ts +10 -0
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +35 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.js +52 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +50 -15
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +4 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +19 -18
- package/dist/prosemirror/extensions/types.d.ts +4 -1
- package/dist/prosemirror/findReplaceSelection.js +1 -1
- package/dist/prosemirror/index.d.ts +3 -2
- package/dist/prosemirror/index.js +3 -2
- package/dist/prosemirror/indexedNodeLookup.d.ts +17 -0
- package/dist/prosemirror/indexedNodeLookup.js +103 -0
- package/dist/prosemirror/listAutoformatMarkers.d.ts +19 -0
- package/dist/prosemirror/listAutoformatMarkers.js +98 -0
- package/dist/prosemirror/listInstanceReferences.d.ts +12 -0
- package/dist/prosemirror/listInstanceReferences.js +72 -0
- package/dist/prosemirror/listLabels.d.ts +24 -0
- package/dist/prosemirror/listLabels.js +111 -0
- package/dist/prosemirror/listNumbering.d.ts +110 -0
- package/dist/prosemirror/listNumbering.js +345 -0
- package/dist/prosemirror/listRenderingAttrs.d.ts +11 -2
- package/dist/prosemirror/listRenderingAttrs.js +8 -1
- package/dist/prosemirror/markupViewProjection.d.ts +95 -0
- package/dist/prosemirror/markupViewProjection.js +83 -0
- package/dist/prosemirror/numberingAttr.d.ts +9 -1
- package/dist/prosemirror/numberingAttr.js +9 -1
- package/dist/prosemirror/outlineLevelAttr.js +1 -1
- package/dist/prosemirror/paragraphIndentation.d.ts +10 -1
- package/dist/prosemirror/paragraphIndentation.js +29 -7
- package/dist/prosemirror/paragraphMarkJoin.d.ts +19 -0
- package/dist/prosemirror/paragraphMarkJoin.js +24 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
- package/dist/prosemirror/plugins/documentNumbering.d.ts +27 -1
- package/dist/prosemirror/plugins/documentNumbering.js +97 -11
- package/dist/prosemirror/plugins/documentStyles.d.ts +10 -1
- package/dist/prosemirror/plugins/documentStyles.js +14 -1
- package/dist/prosemirror/plugins/suggestionMode.d.ts +16 -2
- package/dist/prosemirror/plugins/suggestionMode.js +116 -52
- package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
- package/dist/prosemirror/plugins/transactionInvariants.d.ts +32 -0
- package/dist/prosemirror/plugins/transactionInvariants.js +86 -0
- package/dist/prosemirror/positionSweep.d.ts +24 -0
- package/dist/prosemirror/positionSweep.js +222 -0
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -1
- package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.d.ts +33 -1
- package/dist/prosemirror/replacedAnnotations.js +170 -1
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/index.js +3 -0
- package/dist/prosemirror/schema/nodes.d.ts +42 -11
- package/dist/prosemirror/sectionMarkEdits.d.ts +20 -0
- package/dist/prosemirror/sectionMarkEdits.js +59 -0
- package/dist/prosemirror/storyListNumbering.d.ts +17 -0
- package/dist/prosemirror/storyListNumbering.js +102 -0
- package/dist/prosemirror/tableGridMutation.d.ts +48 -2
- package/dist/prosemirror/tableGridMutation.js +106 -1
- package/dist/prosemirror/validation.js +5 -1
- package/dist/redline.js +93 -9
- package/dist/render-dom/BodySelectionOverlay.d.ts +4 -1
- package/dist/render-dom/BodySelectionOverlay.js +3 -2
- package/dist/utils/findReplace.js +2 -2
- package/dist/utils/mergeDocumentContent.js +1 -1
- package/dist/utils/noteReferenceLabels.d.ts +36 -0
- package/dist/utils/noteReferenceLabels.js +32 -0
- package/dist/utils/replaceText.js +1 -1
- package/dist/version-comparison.d.ts +1 -0
- package/dist/version-comparison.js +1 -0
- package/package.json +3 -2
- package/dist/internal/headlessRevisionResolution.d.ts +0 -23
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { DisplayMode } from "../managers/EditorModeManager.js";
|
|
2
|
+
import { RemovedSectionReference } from "../internal/sectionEndpointResolution.js";
|
|
3
|
+
import { indexedPositionMap } from "../internal/indexedPositionMap.js";
|
|
4
|
+
import { RevisionResolutionMode } from "../internal/revisionResolutionInline.js";
|
|
5
|
+
import { Node } from "prosemirror-model";
|
|
6
|
+
import { EditorState } from "prosemirror-state";
|
|
7
|
+
import { StepMap } from "prosemirror-transform";
|
|
8
|
+
//#region src/prosemirror/markupViewProjection.d.ts
|
|
9
|
+
/** Resolve every revision in the state's story with the state's own styles and numbering. */
|
|
10
|
+
declare const resolveStateStory: (state: EditorState, mode: RevisionResolutionMode) => {
|
|
11
|
+
resolved: Node;
|
|
12
|
+
mapping: import("prosemirror-transform").Mapping;
|
|
13
|
+
positionMap: StepMap;
|
|
14
|
+
steps: import("prosemirror-transform").Step[];
|
|
15
|
+
changedRanges: {
|
|
16
|
+
from: number;
|
|
17
|
+
to: number;
|
|
18
|
+
}[];
|
|
19
|
+
inlineMap: StepMap;
|
|
20
|
+
tableRanges: {
|
|
21
|
+
node: Node;
|
|
22
|
+
inputNode: Node;
|
|
23
|
+
sourceNodeSize: number;
|
|
24
|
+
position: number;
|
|
25
|
+
inputMap: StepMap;
|
|
26
|
+
positionMap: StepMap;
|
|
27
|
+
ranges: readonly {
|
|
28
|
+
from: number;
|
|
29
|
+
to: number;
|
|
30
|
+
}[];
|
|
31
|
+
paragraphOffsets: readonly {
|
|
32
|
+
source: number;
|
|
33
|
+
final: number;
|
|
34
|
+
}[];
|
|
35
|
+
}[];
|
|
36
|
+
transfers: {
|
|
37
|
+
displacedToken: string | null;
|
|
38
|
+
selectedToken: string | null;
|
|
39
|
+
}[];
|
|
40
|
+
structuralRanges: {
|
|
41
|
+
from: number;
|
|
42
|
+
to: number;
|
|
43
|
+
}[];
|
|
44
|
+
structuralMap: StepMap;
|
|
45
|
+
structural: boolean;
|
|
46
|
+
failed: boolean;
|
|
47
|
+
removedEndpointCount: number;
|
|
48
|
+
removedReferences: RemovedSectionReference[];
|
|
49
|
+
};
|
|
50
|
+
type PositionRange = {
|
|
51
|
+
from: number;
|
|
52
|
+
to: number;
|
|
53
|
+
};
|
|
54
|
+
type MarkupViewProjection =
|
|
55
|
+
/** The view lays the authored document out as it stands. */
|
|
56
|
+
{
|
|
57
|
+
type: "authored";
|
|
58
|
+
} | {
|
|
59
|
+
type: "resolved";
|
|
60
|
+
/** The document as the view reads it. */
|
|
61
|
+
doc: Node;
|
|
62
|
+
/** Authored (editor) positions to `doc` positions. */
|
|
63
|
+
positionMap: StepMap;
|
|
64
|
+
/** `positionMap`, indexed for lookups. */
|
|
65
|
+
toView: ReturnType<typeof indexedPositionMap>;
|
|
66
|
+
/** `positionMap` inverted and indexed: `doc` positions to editor positions. */
|
|
67
|
+
toEditor: ReturnType<typeof indexedPositionMap>;
|
|
68
|
+
/**
|
|
69
|
+
* Ranges of `doc` whose paragraphs carry a change indicator (Simple
|
|
70
|
+
* Markup's change bar); empty for a view without indicators.
|
|
71
|
+
*/
|
|
72
|
+
changeBarRanges: readonly PositionRange[];
|
|
73
|
+
/**
|
|
74
|
+
* Whether the resolver left part of the story as authored (a table
|
|
75
|
+
* revision it cannot resolve). The projection still shows every revision
|
|
76
|
+
* it could resolve; the caller reports the rest.
|
|
77
|
+
*/
|
|
78
|
+
completeness: "complete" | "partial";
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* The document a markup view lays out, for the state's current document.
|
|
82
|
+
* Cached per editor state: the resolver also reads its styles and numbering
|
|
83
|
+
* plugins, which may change while the document node stays the same.
|
|
84
|
+
*/
|
|
85
|
+
declare const projectMarkupView: (state: EditorState, view: DisplayMode) => MarkupViewProjection;
|
|
86
|
+
/**
|
|
87
|
+
* Where a caret at editor `position` is painted in a view. A position the view
|
|
88
|
+
* shows is its own; one inside text the view does not show (a deletion in No
|
|
89
|
+
* Markup, an insertion in Original, typed there with tracking on) moves to the
|
|
90
|
+
* nearest place the view shows before it, the way the caret sits at the edge
|
|
91
|
+
* of text it cannot enter.
|
|
92
|
+
*/
|
|
93
|
+
declare const visibleCaretPosition: (projection: MarkupViewProjection, position: number) => number;
|
|
94
|
+
//#endregion
|
|
95
|
+
export { MarkupViewProjection, projectMarkupView, resolveStateStory, visibleCaretPosition };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { indexedPositionMap } from "../internal/indexedPositionMap.js";
|
|
2
|
+
import { finalRevisionParagraphRanges } from "../internal/revisionResolutionTracking.js";
|
|
3
|
+
import { resolveWholeStory } from "../internal/wholeStoryRevisionResolution.js";
|
|
4
|
+
import { getDocumentNumbering } from "./plugins/documentNumbering.js";
|
|
5
|
+
import { getDocumentStyleResolver } from "./plugins/documentStyles.js";
|
|
6
|
+
import { Selection } from "prosemirror-state";
|
|
7
|
+
//#region src/prosemirror/markupViewProjection.ts
|
|
8
|
+
/** Resolve every revision in the state's story with the state's own styles and numbering. */
|
|
9
|
+
const resolveStateStory = (state, mode) => resolveWholeStory({
|
|
10
|
+
doc: state.doc,
|
|
11
|
+
mode,
|
|
12
|
+
styleResolver: getDocumentStyleResolver(state),
|
|
13
|
+
numbering: getDocumentNumbering(state)
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Every view's reading of the document. Total over `DisplayMode`, so a new view
|
|
17
|
+
* cannot ship without a decision about what it lays out.
|
|
18
|
+
*/
|
|
19
|
+
const MARKUP_VIEW_RESOLUTIONS = {
|
|
20
|
+
"all-markup": { type: "authored" },
|
|
21
|
+
"simple-markup": {
|
|
22
|
+
type: "resolved",
|
|
23
|
+
mode: "accept",
|
|
24
|
+
indicators: "change-bars"
|
|
25
|
+
},
|
|
26
|
+
"no-markup": {
|
|
27
|
+
type: "resolved",
|
|
28
|
+
mode: "accept",
|
|
29
|
+
indicators: "none"
|
|
30
|
+
},
|
|
31
|
+
original: {
|
|
32
|
+
type: "resolved",
|
|
33
|
+
mode: "reject",
|
|
34
|
+
indicators: "none"
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const AUTHORED = { type: "authored" };
|
|
38
|
+
const projectionCache = /* @__PURE__ */ new WeakMap();
|
|
39
|
+
/**
|
|
40
|
+
* The document a markup view lays out, for the state's current document.
|
|
41
|
+
* Cached per editor state: the resolver also reads its styles and numbering
|
|
42
|
+
* plugins, which may change while the document node stays the same.
|
|
43
|
+
*/
|
|
44
|
+
const projectMarkupView = (state, view) => {
|
|
45
|
+
const resolution = MARKUP_VIEW_RESOLUTIONS[view];
|
|
46
|
+
if (resolution.type === "authored") return AUTHORED;
|
|
47
|
+
let byView = projectionCache.get(state);
|
|
48
|
+
const cached = byView?.get(view);
|
|
49
|
+
if (cached) return cached;
|
|
50
|
+
const result = resolveStateStory(state, resolution.mode);
|
|
51
|
+
const projection = result.resolved.eq(state.doc) ? AUTHORED : {
|
|
52
|
+
type: "resolved",
|
|
53
|
+
doc: result.resolved,
|
|
54
|
+
positionMap: result.positionMap,
|
|
55
|
+
toView: indexedPositionMap(result.positionMap),
|
|
56
|
+
toEditor: indexedPositionMap(result.positionMap.invert()),
|
|
57
|
+
changeBarRanges: resolution.indicators === "change-bars" ? finalRevisionParagraphRanges(result) : [],
|
|
58
|
+
completeness: result.failed ? "partial" : "complete"
|
|
59
|
+
};
|
|
60
|
+
if (!byView) {
|
|
61
|
+
byView = /* @__PURE__ */ new Map();
|
|
62
|
+
projectionCache.set(state, byView);
|
|
63
|
+
}
|
|
64
|
+
byView.set(view, projection);
|
|
65
|
+
return projection;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Where a caret at editor `position` is painted in a view. A position the view
|
|
69
|
+
* shows is its own; one inside text the view does not show (a deletion in No
|
|
70
|
+
* Markup, an insertion in Original, typed there with tracking on) moves to the
|
|
71
|
+
* nearest place the view shows before it, the way the caret sits at the edge
|
|
72
|
+
* of text it cannot enter.
|
|
73
|
+
*/
|
|
74
|
+
const visibleCaretPosition = (projection, position) => {
|
|
75
|
+
if (projection.type === "authored") return position;
|
|
76
|
+
const { pos: viewPosition, deletedAcross } = projection.toView.mapResult(position, -1);
|
|
77
|
+
if (!deletedAcross) return position;
|
|
78
|
+
const bounded = Math.max(0, Math.min(viewPosition, projection.doc.content.size));
|
|
79
|
+
const near = Selection.near(projection.doc.resolve(bounded), -1);
|
|
80
|
+
return projection.toEditor(near.head, -1);
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
export { projectMarkupView, resolveStateStory, visibleCaretPosition };
|
|
@@ -22,6 +22,14 @@ type ParagraphNumberingAttr = ParagraphNumberingOverride & {
|
|
|
22
22
|
};
|
|
23
23
|
/** Mint the attr value for a stated override: the one model-to-attr crossing. */
|
|
24
24
|
declare const paragraphNumberingAttr: (numbering: ParagraphNumberingOverride) => ParagraphNumberingAttr;
|
|
25
|
+
/**
|
|
26
|
+
* The `numPr` that takes a paragraph out of its list. When its style supplies
|
|
27
|
+
* the numbering, the paragraph has to state the cancellation (`w:numId="0"`):
|
|
28
|
+
* clearing the attr would uncover the style tier, and the next save hands the
|
|
29
|
+
* numbering straight back. A cancellation states no level (17.9.18: there is
|
|
30
|
+
* no id left for a level to belong to).
|
|
31
|
+
*/
|
|
32
|
+
declare const removedNumberingAttr: (numPrFromStyle: ParagraphNumberingOverride | null | undefined) => ParagraphNumberingAttr | null;
|
|
25
33
|
/**
|
|
26
34
|
* The one shape check over a persisted `numPr` attr.
|
|
27
35
|
*
|
|
@@ -52,4 +60,4 @@ declare const paragraphNumberingFromAttrValue: (value: unknown) => ParagraphNumb
|
|
|
52
60
|
*/
|
|
53
61
|
declare const readParagraphNumberingAttr: (value: unknown) => ParagraphNumberingAttr | null;
|
|
54
62
|
//#endregion
|
|
55
|
-
export { ParagraphNumberingAttr, paragraphNumberingAttr, paragraphNumberingFromAttrValue, readParagraphNumberingAttr };
|
|
63
|
+
export { ParagraphNumberingAttr, paragraphNumberingAttr, paragraphNumberingFromAttrValue, readParagraphNumberingAttr, removedNumberingAttr };
|
|
@@ -17,6 +17,14 @@ const paragraphNumberingAttr = (numbering) => {
|
|
|
17
17
|
default: return panic(`Unhandled paragraph numbering ${JSON.stringify(numbering)}`);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* The `numPr` that takes a paragraph out of its list. When its style supplies
|
|
22
|
+
* the numbering, the paragraph has to state the cancellation (`w:numId="0"`):
|
|
23
|
+
* clearing the attr would uncover the style tier, and the next save hands the
|
|
24
|
+
* numbering straight back. A cancellation states no level (17.9.18: there is
|
|
25
|
+
* no id left for a level to belong to).
|
|
26
|
+
*/
|
|
27
|
+
const removedNumberingAttr = (numPrFromStyle) => numPrFromStyle?.kind === "reference" ? paragraphNumberingAttr(NO_PARAGRAPH_NUMBERING) : null;
|
|
20
28
|
/** A `<w:numPr>` slot value: an ordinal, so a non-integer or a negative is not one. */
|
|
21
29
|
const isNumberingSlot = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
22
30
|
/**
|
|
@@ -71,4 +79,4 @@ const readParagraphNumberingAttr = (value) => {
|
|
|
71
79
|
return numbering;
|
|
72
80
|
};
|
|
73
81
|
//#endregion
|
|
74
|
-
export { paragraphNumberingAttr, paragraphNumberingFromAttrValue, readParagraphNumberingAttr };
|
|
82
|
+
export { paragraphNumberingAttr, paragraphNumberingFromAttrValue, readParagraphNumberingAttr, removedNumberingAttr };
|
|
@@ -17,7 +17,7 @@ import { headingOutlineLevel } from "@stll/docx-core/model";
|
|
|
17
17
|
const outlineLevelFromAttrValue = (value) => {
|
|
18
18
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
19
19
|
const kind = Reflect.get(value, "kind");
|
|
20
|
-
if (kind === "bodyText") return { kind: "bodyText" };
|
|
20
|
+
if (kind === "bodyText") return Reflect.has(value, "level") ? null : { kind: "bodyText" };
|
|
21
21
|
if (kind !== "heading") return null;
|
|
22
22
|
const level = Reflect.get(value, "level");
|
|
23
23
|
return typeof level === "number" ? headingOutlineLevel(level) ?? null : null;
|
|
@@ -6,7 +6,16 @@ import { ParagraphAttrs } from "./schema/nodes.js";
|
|
|
6
6
|
type DirectParagraphIndentation = FolioContentParagraphIndentation;
|
|
7
7
|
/** Project only authored `w:ind` attributes, preserving zero and false. */
|
|
8
8
|
declare const paragraphIndentationFromFormatting: (formatting: document_d_exports.ParagraphFormatting | null | undefined) => DirectParagraphIndentation | undefined;
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Read direct indentation without materializing values inherited from a style:
|
|
11
|
+
* the `w:ind` a save writes for the paragraph.
|
|
12
|
+
*
|
|
13
|
+
* A field the source stated reads at its current value. A field it did not
|
|
14
|
+
* reads only when an edit set it to something the style cascade does not
|
|
15
|
+
* supply — reading `_originalFormatting` alone missed every indentation a
|
|
16
|
+
* command set on a paragraph whose source stated none. A hanging indent reads
|
|
17
|
+
* with a negative `indentFirstLine`, as the model states it.
|
|
18
|
+
*/
|
|
10
19
|
declare const directParagraphIndentation: (attrs: ParagraphAttrs) => DirectParagraphIndentation | undefined;
|
|
11
20
|
declare const paragraphIndentationEqual: (left: DirectParagraphIndentation | null | undefined, right: DirectParagraphIndentation | null | undefined) => boolean;
|
|
12
21
|
/** Replace the complete direct `w:ind` cluster in canonical formatting. */
|
|
@@ -31,19 +31,41 @@ const paragraphIndentationFromFormatting = (formatting) => {
|
|
|
31
31
|
if (indentation.indentFirstLine !== void 0 && indentation.hangingIndent === void 0) indentation.hangingIndent = false;
|
|
32
32
|
return Object.keys(indentation).length > 0 ? indentation : void 0;
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
const PARAGRAPH_INDENTATION_VALUE_KEYS = [
|
|
35
|
+
"indentLeft",
|
|
36
|
+
"indentRight",
|
|
37
|
+
"indentFirstLine"
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* Read direct indentation without materializing values inherited from a style:
|
|
41
|
+
* the `w:ind` a save writes for the paragraph.
|
|
42
|
+
*
|
|
43
|
+
* A field the source stated reads at its current value. A field it did not
|
|
44
|
+
* reads only when an edit set it to something the style cascade does not
|
|
45
|
+
* supply — reading `_originalFormatting` alone missed every indentation a
|
|
46
|
+
* command set on a paragraph whose source stated none. A hanging indent reads
|
|
47
|
+
* with a negative `indentFirstLine`, as the model states it.
|
|
48
|
+
*/
|
|
35
49
|
const directParagraphIndentation = (attrs) => {
|
|
36
|
-
const original =
|
|
37
|
-
|
|
50
|
+
const original = attrs._originalFormatting ?? void 0;
|
|
51
|
+
const resolved = attrs._resolvedFormatting;
|
|
38
52
|
const indentation = {};
|
|
39
|
-
for (const key of
|
|
40
|
-
|
|
41
|
-
|
|
53
|
+
for (const key of PARAGRAPH_INDENTATION_VALUE_KEYS) {
|
|
54
|
+
const value = attrs[key];
|
|
55
|
+
if (typeof value !== "number") continue;
|
|
56
|
+
const stated = original?.[key] !== void 0;
|
|
57
|
+
const inherited = resolved?.[key] === value || original === void 0 && value === 0;
|
|
58
|
+
if (stated || !inherited) copyIndentationValue({
|
|
42
59
|
target: indentation,
|
|
43
60
|
key,
|
|
44
|
-
value
|
|
61
|
+
value
|
|
45
62
|
});
|
|
46
63
|
}
|
|
64
|
+
if (indentation.indentFirstLine !== void 0) {
|
|
65
|
+
const hanging = attrs.hangingIndent === true;
|
|
66
|
+
indentation.hangingIndent = hanging;
|
|
67
|
+
if (hanging) indentation.indentFirstLine = -Math.abs(indentation.indentFirstLine);
|
|
68
|
+
} else if (original?.hangingIndent !== void 0 && typeof attrs.hangingIndent === "boolean") indentation.hangingIndent = attrs.hangingIndent;
|
|
47
69
|
return Object.keys(indentation).length > 0 ? indentation : void 0;
|
|
48
70
|
};
|
|
49
71
|
const paragraphIndentationEqual = (left, right) => DIRECT_PARAGRAPH_INDENTATION_KEYS.every((key) => left?.[key] === right?.[key]);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
import { Transaction } from "prosemirror-state";
|
|
3
|
+
//#region src/prosemirror/paragraphMarkJoin.d.ts
|
|
4
|
+
type JoinAtParagraphMarkOptions = {
|
|
5
|
+
tr: Transaction;
|
|
6
|
+
/** Position of the paragraph whose mark goes. */
|
|
7
|
+
paragraphPos: number;
|
|
8
|
+
paragraph: Node;
|
|
9
|
+
/** The paragraph directly after it, which the join runs into. */
|
|
10
|
+
next: Node;
|
|
11
|
+
/**
|
|
12
|
+
* The first paragraph's content is going too (a deleted paragraph), so
|
|
13
|
+
* only the join survives of it, as when it is already empty.
|
|
14
|
+
*/
|
|
15
|
+
firstIsGoing?: boolean;
|
|
16
|
+
};
|
|
17
|
+
declare const joinAtParagraphMark: ({ tr, paragraphPos, paragraph, next, firstIsGoing }: JoinAtParagraphMarkOptions) => void;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { joinAtParagraphMark };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { joinProseParagraphsWithRightPropertySource } from "../docx/paragraphPropertySource.js";
|
|
2
|
+
import { holdsNoContent } from "./zeroWidthAnchors.js";
|
|
3
|
+
//#region src/prosemirror/paragraphMarkJoin.ts
|
|
4
|
+
const joinAtParagraphMark = ({ tr, paragraphPos, paragraph, next, firstIsGoing = false }) => {
|
|
5
|
+
const joinPos = paragraphPos + paragraph.nodeSize;
|
|
6
|
+
const emptyFirstParagraph = firstIsGoing || holdsNoContent(paragraph);
|
|
7
|
+
const joinedAttrs = {
|
|
8
|
+
...(emptyFirstParagraph ? next : paragraph).attrs,
|
|
9
|
+
pPrMark: next.attrs["pPrMark"],
|
|
10
|
+
_sectionProperties: next.attrs["_sectionProperties"]
|
|
11
|
+
};
|
|
12
|
+
if (emptyFirstParagraph) {
|
|
13
|
+
joinProseParagraphsWithRightPropertySource({
|
|
14
|
+
attrs: joinedAttrs,
|
|
15
|
+
pos: joinPos,
|
|
16
|
+
transaction: tr
|
|
17
|
+
});
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
tr.join(joinPos);
|
|
21
|
+
tr.setNodeMarkup(paragraphPos, void 0, joinedAttrs);
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { joinAtParagraphMark };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EditorState, Plugin, PluginKey } from "prosemirror-state";
|
|
2
1
|
import { Node } from "prosemirror-model";
|
|
2
|
+
import { EditorState, Plugin, PluginKey } from "prosemirror-state";
|
|
3
3
|
//#region src/prosemirror/plugins/createDocScanPlugin.d.ts
|
|
4
4
|
declare const SET_META = "set";
|
|
5
5
|
type DocScanState<TConfig, TRange> = {
|
|
@@ -3,8 +3,34 @@ import { NumberingMap } from "../../docx/numberingParser.js";
|
|
|
3
3
|
import { EditorState, Plugin } from "prosemirror-state";
|
|
4
4
|
//#region src/prosemirror/plugins/documentNumbering.d.ts
|
|
5
5
|
declare const createDocumentNumberingPlugin: (definitions: document_d_exports.NumberingDefinitions | null | undefined) => Plugin;
|
|
6
|
+
/**
|
|
7
|
+
* The numbering the document's paragraphs resolve against: the package's
|
|
8
|
+
* definitions plus every instance a list command defined in this document.
|
|
9
|
+
* An instance whose paragraphs were all deleted may linger until the next
|
|
10
|
+
* completion; the save completes from the document itself.
|
|
11
|
+
*/
|
|
6
12
|
declare const getDocumentNumbering: (state: EditorState) => NumberingMap | null;
|
|
13
|
+
/** The package's own definitions, without the instances the document defines. */
|
|
14
|
+
declare const getPackageNumberingDefinitions: (state: EditorState) => document_d_exports.NumberingDefinitions | null;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the state knows its document's numbering at all. A state without
|
|
17
|
+
* the plugin cannot tell a package with no numbering part from one it was
|
|
18
|
+
* never told about.
|
|
19
|
+
*/
|
|
20
|
+
declare const hasDocumentNumbering: (state: EditorState) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The document's numbering definitions: `null` for a document without a
|
|
23
|
+
* numbering part, `undefined` when the state carries no numbering plugin and
|
|
24
|
+
* so cannot say what the document defines.
|
|
25
|
+
*/
|
|
26
|
+
declare const getStatedDocumentNumbering: (state: EditorState) => document_d_exports.NumberingDefinitions | null | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The numbering instances (`w:num` ids) the document defines, or `null` when
|
|
29
|
+
* the state carries no numbering plugin and so cannot say. A document without
|
|
30
|
+
* a numbering part defines none.
|
|
31
|
+
*/
|
|
32
|
+
declare const getDocumentNumberingInstanceIds: (state: EditorState) => ReadonlySet<number> | null;
|
|
7
33
|
/** Replace numbering state while retaining every unrelated plugin state. */
|
|
8
34
|
declare const withDocumentNumbering: (state: EditorState, definitions: document_d_exports.NumberingDefinitions) => EditorState;
|
|
9
35
|
//#endregion
|
|
10
|
-
export { createDocumentNumberingPlugin, getDocumentNumbering, withDocumentNumbering };
|
|
36
|
+
export { createDocumentNumberingPlugin, getDocumentNumbering, getDocumentNumberingInstanceIds, getPackageNumberingDefinitions, getStatedDocumentNumbering, hasDocumentNumbering, withDocumentNumbering };
|
|
@@ -1,19 +1,105 @@
|
|
|
1
1
|
import { getCachedNumberingMap } from "../../docx/numberingParser.js";
|
|
2
|
+
import { completeNumberingForDoc, paragraphListReferences } from "../listInstanceReferences.js";
|
|
3
|
+
import { AddMarkStep, DocAttrStep, RemoveMarkStep, ReplaceAroundStep, ReplaceStep } from "prosemirror-transform";
|
|
2
4
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
3
5
|
//#region src/prosemirror/plugins/documentNumbering.ts
|
|
4
|
-
/** Document-scoped numbering definitions for list-editing commands. */
|
|
5
6
|
const documentNumberingKey = new PluginKey("documentNumbering");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const completedState = (definitions, doc) => {
|
|
8
|
+
const completed = completeNumberingForDoc(definitions ?? void 0, doc);
|
|
9
|
+
return {
|
|
10
|
+
definitions,
|
|
11
|
+
map: completed ? getCachedNumberingMap(completed) : null
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
/** Steps that can change a paragraph's attrs or bring paragraphs in, by what they replace. */
|
|
15
|
+
const isReplace = (step) => step instanceof ReplaceStep || step instanceof ReplaceAroundStep;
|
|
16
|
+
/** Steps that change nothing a numbering reference lives in. */
|
|
17
|
+
const leavesParagraphAttrs = (step) => step instanceof AddMarkStep || step instanceof RemoveMarkStep || step instanceof DocAttrStep;
|
|
18
|
+
/**
|
|
19
|
+
* Whether `tr` may have introduced a reference `map` does not define. Only the
|
|
20
|
+
* ranges its steps replaced are read, so typing costs one paragraph, not the
|
|
21
|
+
* document. A step that changes attrs in place (not by replacement) is not
|
|
22
|
+
* localised and answers yes.
|
|
23
|
+
*/
|
|
24
|
+
const mayReferenceUnknownInstance = (tr, map) => {
|
|
25
|
+
const ranges = [];
|
|
26
|
+
for (const [index, step] of tr.steps.entries()) {
|
|
27
|
+
if (leavesParagraphAttrs(step)) continue;
|
|
28
|
+
if (!isReplace(step)) return true;
|
|
29
|
+
const later = tr.mapping.slice(index + 1);
|
|
30
|
+
step.getMap().forEach((_oldStart, _oldEnd, newStart, newEnd) => {
|
|
31
|
+
ranges.push({
|
|
32
|
+
from: later.map(newStart, -1),
|
|
33
|
+
to: later.map(newEnd, 1)
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const size = tr.doc.content.size;
|
|
38
|
+
const isUnknown = (numId) => !(map?.hasNumbering(numId) ?? false);
|
|
39
|
+
return ranges.some(({ from, to }) => {
|
|
40
|
+
let unknown = false;
|
|
41
|
+
const start = Math.min(Math.max(0, from), size);
|
|
42
|
+
tr.doc.nodesBetween(start, Math.min(Math.max(start, to), size), (node) => {
|
|
43
|
+
if (unknown) return false;
|
|
44
|
+
if (node.type.name !== "paragraph") return true;
|
|
45
|
+
unknown = paragraphListReferences(node).some(isUnknown);
|
|
46
|
+
return false;
|
|
47
|
+
});
|
|
48
|
+
return unknown;
|
|
14
49
|
});
|
|
15
50
|
};
|
|
16
|
-
const
|
|
51
|
+
const createDocumentNumberingPlugin = (definitions) => new Plugin({
|
|
52
|
+
key: documentNumberingKey,
|
|
53
|
+
state: {
|
|
54
|
+
init: (_config, state) => completedState(definitions ?? null, state.doc),
|
|
55
|
+
apply: (tr, current, _oldState, state) => tr.docChanged && mayReferenceUnknownInstance(tr, current.map) ? completedState(current.definitions, state.doc) : current
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
/** Numbering for states without the plugin, one per document node. */
|
|
59
|
+
const untrackedNumbering = /* @__PURE__ */ new WeakMap();
|
|
60
|
+
/**
|
|
61
|
+
* The numbering the document's paragraphs resolve against: the package's
|
|
62
|
+
* definitions plus every instance a list command defined in this document.
|
|
63
|
+
* An instance whose paragraphs were all deleted may linger until the next
|
|
64
|
+
* completion; the save completes from the document itself.
|
|
65
|
+
*/
|
|
66
|
+
const getDocumentNumbering = (state) => {
|
|
67
|
+
const tracked = documentNumberingKey.getState(state);
|
|
68
|
+
if (tracked) return tracked.map;
|
|
69
|
+
let untracked = untrackedNumbering.get(state.doc);
|
|
70
|
+
if (!untracked) {
|
|
71
|
+
untracked = completedState(null, state.doc);
|
|
72
|
+
untrackedNumbering.set(state.doc, untracked);
|
|
73
|
+
}
|
|
74
|
+
return untracked.map;
|
|
75
|
+
};
|
|
76
|
+
/** The package's own definitions, without the instances the document defines. */
|
|
77
|
+
const getPackageNumberingDefinitions = (state) => documentNumberingKey.getState(state)?.definitions ?? null;
|
|
78
|
+
/**
|
|
79
|
+
* Whether the state knows its document's numbering at all. A state without
|
|
80
|
+
* the plugin cannot tell a package with no numbering part from one it was
|
|
81
|
+
* never told about.
|
|
82
|
+
*/
|
|
83
|
+
const hasDocumentNumbering = (state) => documentNumberingKey.get(state) !== void 0;
|
|
84
|
+
/**
|
|
85
|
+
* The document's numbering definitions: `null` for a document without a
|
|
86
|
+
* numbering part, `undefined` when the state carries no numbering plugin and
|
|
87
|
+
* so cannot say what the document defines.
|
|
88
|
+
*/
|
|
89
|
+
const getStatedDocumentNumbering = (state) => {
|
|
90
|
+
if (documentNumberingKey.get(state) === void 0) return;
|
|
91
|
+
return getDocumentNumbering(state)?.definitions ?? null;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* The numbering instances (`w:num` ids) the document defines, or `null` when
|
|
95
|
+
* the state carries no numbering plugin and so cannot say. A document without
|
|
96
|
+
* a numbering part defines none.
|
|
97
|
+
*/
|
|
98
|
+
const getDocumentNumberingInstanceIds = (state) => {
|
|
99
|
+
const numbering = getStatedDocumentNumbering(state);
|
|
100
|
+
if (numbering === void 0) return null;
|
|
101
|
+
return new Set(numbering?.nums.map(({ numId }) => numId) ?? []);
|
|
102
|
+
};
|
|
17
103
|
/** Replace numbering state while retaining every unrelated plugin state. */
|
|
18
104
|
const withDocumentNumbering = (state, definitions) => {
|
|
19
105
|
const previous = documentNumberingKey.get(state);
|
|
@@ -21,4 +107,4 @@ const withDocumentNumbering = (state, definitions) => {
|
|
|
21
107
|
return state.reconfigure({ plugins: retained }).reconfigure({ plugins: [...retained, createDocumentNumberingPlugin(definitions)] });
|
|
22
108
|
};
|
|
23
109
|
//#endregion
|
|
24
|
-
export { createDocumentNumberingPlugin, getDocumentNumbering, withDocumentNumbering };
|
|
110
|
+
export { createDocumentNumberingPlugin, getDocumentNumbering, getDocumentNumberingInstanceIds, getPackageNumberingDefinitions, getStatedDocumentNumbering, hasDocumentNumbering, withDocumentNumbering };
|
|
@@ -14,6 +14,15 @@ declare const documentStylesKey: PluginKey<StyleResolver | null>;
|
|
|
14
14
|
declare function createDocumentStylesPlugin(styles: document_d_exports.StyleDefinitions | StyleResolver | null | undefined): Plugin;
|
|
15
15
|
/** Read the document's StyleResolver, or null when the plugin isn't installed. */
|
|
16
16
|
declare function getDocumentStyleResolver(state: EditorState): StyleResolver | null;
|
|
17
|
+
/**
|
|
18
|
+
* The document's style definitions by id, or `null` when the state carries no
|
|
19
|
+
* styles plugin and so cannot say what the document defines. A document
|
|
20
|
+
* without a styles part defines none.
|
|
21
|
+
*/
|
|
22
|
+
declare function getDocumentStyleDefinitions(state: EditorState): {
|
|
23
|
+
get: (styleId: string) => document_d_exports.Style | undefined;
|
|
24
|
+
paragraphStyles: () => document_d_exports.Style[];
|
|
25
|
+
} | null;
|
|
17
26
|
/**
|
|
18
27
|
* Read the document's built-in style index, for the callers that classify
|
|
19
28
|
* paragraphs (heading collection, markdown export, the AI snapshot). Without
|
|
@@ -24,4 +33,4 @@ declare function getDocumentBuiltInStyles(state: EditorState): BuiltInStyleIndex
|
|
|
24
33
|
/** Reconfigure so ProseMirror replaces the keyed plugin's resolver state. */
|
|
25
34
|
declare const withDocumentStyles: (state: EditorState, styles: document_d_exports.StyleDefinitions | StyleResolver | null | undefined) => EditorState;
|
|
26
35
|
//#endregion
|
|
27
|
-
export { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver, withDocumentStyles };
|
|
36
|
+
export { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleDefinitions, getDocumentStyleResolver, withDocumentStyles };
|
|
@@ -44,6 +44,19 @@ function getDocumentStyleResolver(state) {
|
|
|
44
44
|
return documentStylesKey.getState(state) ?? null;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
+
* The document's style definitions by id, or `null` when the state carries no
|
|
48
|
+
* styles plugin and so cannot say what the document defines. A document
|
|
49
|
+
* without a styles part defines none.
|
|
50
|
+
*/
|
|
51
|
+
function getDocumentStyleDefinitions(state) {
|
|
52
|
+
if (documentStylesKey.get(state) === void 0) return null;
|
|
53
|
+
const resolver = getDocumentStyleResolver(state);
|
|
54
|
+
return {
|
|
55
|
+
get: (styleId) => resolver?.getStyle(styleId),
|
|
56
|
+
paragraphStyles: () => resolver?.getParagraphStyles() ?? []
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
47
60
|
* Read the document's built-in style index, for the callers that classify
|
|
48
61
|
* paragraphs (heading collection, markdown export, the AI snapshot). Without
|
|
49
62
|
* the plugin every lookup misses, which degrades classification to the
|
|
@@ -59,4 +72,4 @@ const withDocumentStyles = (state, styles) => {
|
|
|
59
72
|
return state.reconfigure({ plugins: retained }).reconfigure({ plugins: [...retained, createDocumentStylesPlugin(styles)] });
|
|
60
73
|
};
|
|
61
74
|
//#endregion
|
|
62
|
-
export { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver, withDocumentStyles };
|
|
75
|
+
export { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleDefinitions, getDocumentStyleResolver, withDocumentStyles };
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { EditorState, Plugin, PluginKey, Transaction } from "prosemirror-state";
|
|
2
1
|
import { Slice } from "prosemirror-model";
|
|
2
|
+
import { EditorState, Plugin, PluginKey, Transaction } from "prosemirror-state";
|
|
3
3
|
import { EditorView } from "prosemirror-view";
|
|
4
4
|
//#region src/prosemirror/plugins/suggestionMode.d.ts
|
|
5
5
|
declare const suggestionModeKey: PluginKey<SuggestionModeState>;
|
|
6
6
|
declare const SUGGESTION_META = "suggestionModeApplied";
|
|
7
7
|
declare const SUGGESTION_BYPASS_META = "suggestionModeBypass";
|
|
8
|
+
/**
|
|
9
|
+
* The text a tracked text-input transaction typed. Rules that react to typing
|
|
10
|
+
* (list autoformat) read it, because this plugin claims text input before any
|
|
11
|
+
* input rule sees it.
|
|
12
|
+
*/
|
|
13
|
+
declare const SUGGESTED_TEXT_INPUT_META = "suggestionModeTextInput";
|
|
8
14
|
type SuggestionModeState = {
|
|
9
15
|
active: boolean;
|
|
10
16
|
author: string;
|
|
@@ -23,6 +29,12 @@ declare function makeRevisionInfo(state: EditorState): {
|
|
|
23
29
|
* (eigenpal/docx-editor#784).
|
|
24
30
|
*/
|
|
25
31
|
declare function handleSuggestionPaste(view: EditorView, slice: Slice, pluginState: SuggestionModeState): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Remove `from`..`to` of `tr.doc` as a suggestion: text the current author
|
|
34
|
+
* inserted is retracted, anything else is marked deleted. `false` when the
|
|
35
|
+
* editor is not suggesting.
|
|
36
|
+
*/
|
|
37
|
+
declare function suggestRangeDeletion(state: EditorState, tr: Transaction, from: number, to: number): boolean;
|
|
26
38
|
/**
|
|
27
39
|
* Track-changes Enter: split the paragraph and stamp `pPrMark = 'ins'` on the
|
|
28
40
|
* FIRST half of the split (the upper paragraph), per ECMA-376 §17.13.5. The
|
|
@@ -48,6 +60,8 @@ declare function handleSuggestionEnter(view: EditorView, pluginState: Suggestion
|
|
|
48
60
|
* is a table). The default merge path then runs unchanged.
|
|
49
61
|
*/
|
|
50
62
|
declare function paragraphBoundaryTarget(state: EditorState, direction: "backward" | "forward"): number | null;
|
|
63
|
+
/** Apply the editor's selected-content deletion path for a host cut action. */
|
|
64
|
+
declare const deleteSelectionAsSuggestion: (state: EditorState, dispatch: (tr: Transaction) => void) => boolean;
|
|
51
65
|
/**
|
|
52
66
|
* Create the suggestion mode plugin.
|
|
53
67
|
* When active, text edits become tracked changes.
|
|
@@ -66,4 +80,4 @@ declare function setSuggestionMode(active: boolean, state: EditorState, dispatch
|
|
|
66
80
|
*/
|
|
67
81
|
declare function isSuggestionModeActive(state: EditorState): boolean;
|
|
68
82
|
//#endregion
|
|
69
|
-
export { SUGGESTION_BYPASS_META, SUGGESTION_META, createSuggestionModePlugin, handleSuggestionEnter, handleSuggestionPaste, isSuggestionModeActive, makeRevisionInfo, paragraphBoundaryTarget, setSuggestionMode, suggestionModeKey, toggleSuggestionMode };
|
|
83
|
+
export { SUGGESTED_TEXT_INPUT_META, SUGGESTION_BYPASS_META, SUGGESTION_META, createSuggestionModePlugin, deleteSelectionAsSuggestion, handleSuggestionEnter, handleSuggestionPaste, isSuggestionModeActive, makeRevisionInfo, paragraphBoundaryTarget, setSuggestionMode, suggestRangeDeletion, suggestionModeKey, toggleSuggestionMode };
|