@stll/folio-core 0.67.0 → 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 +94 -8
- 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/snapshot.d.ts +6 -0
- package/dist/ai-edits/snapshot.js +8 -3
- 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.js +1 -1
- package/dist/controller/canonicalInlineProjection.d.ts +35 -10
- package/dist/controller/canonicalInlineProjection.js +192 -28
- package/dist/controller/canonicalInput.d.ts +2 -1
- package/dist/controller/canonicalInput.js +28 -1
- 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 +327 -73
- 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 +4 -3
- package/dist/controller/hiddenEditorManager.js +91 -37
- package/dist/controller/layoutPipeline.js +48 -15
- 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.js +23 -4
- 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/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/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/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/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 +38 -21
- 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/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/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 +2 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +34 -0
- package/dist/i18n/messages/catalogs.gen.js +34 -0
- package/dist/i18n/messages/cs.gen.js +2 -0
- package/dist/i18n/messages/de.gen.js +2 -0
- package/dist/i18n/messages/en.gen.js +2 -0
- package/dist/i18n/messages/es.gen.js +2 -0
- package/dist/i18n/messages/et.gen.js +2 -0
- package/dist/i18n/messages/fr.gen.js +2 -0
- package/dist/i18n/messages/he.gen.js +2 -0
- package/dist/i18n/messages/hi.gen.js +2 -0
- package/dist/i18n/messages/hu.gen.js +2 -0
- package/dist/i18n/messages/lt.gen.js +2 -0
- package/dist/i18n/messages/lv.gen.js +2 -0
- package/dist/i18n/messages/messages.gen.d.ts +2 -0
- package/dist/i18n/messages/pl.gen.js +2 -0
- package/dist/i18n/messages/pt-BR.gen.js +2 -0
- package/dist/i18n/messages/sk.gen.js +2 -0
- package/dist/i18n/messages/tr.gen.js +2 -0
- package/dist/i18n/messages/zh-CN.gen.js +2 -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/layout-bridge/convert/tableConversion.js +19 -8
- package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
- package/dist/layout-bridge/engine/blockIndex.js +12 -0
- 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/tableLayout.js +29 -5
- package/dist/layout-engine/tableRowBreak.d.ts +36 -0
- package/dist/layout-engine/tableRowBreak.js +43 -1
- package/dist/layout-engine/types.d.ts +36 -1
- package/dist/layout-painter/renderPage.d.ts +4 -4
- package/dist/layout-painter/renderPage.js +46 -17
- package/dist/layout-painter/renderTable.js +7 -4
- 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/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 +102 -11
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +1 -1
- 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.js +3 -4
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +76 -31
- package/dist/prosemirror/conversion/index.d.ts +1 -1
- package/dist/prosemirror/conversion/toProseDoc.d.ts +128 -1
- package/dist/prosemirror/conversion/toProseDoc.js +319 -51
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -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/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +32 -31
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
- 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.js +20 -9
- 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/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/validation.js +1 -0
- 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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
|
|
2
2
|
import { HiddenEditorApi } from "./hiddenEditorApi.js";
|
|
3
3
|
import { Transaction } from "prosemirror-state";
|
|
4
4
|
import { EditorView } from "prosemirror-view";
|
|
@@ -9,7 +9,7 @@ type CanonicalStoryEditorOptions = {
|
|
|
9
9
|
getApi: () => HiddenEditorApi | null;
|
|
10
10
|
enabled: () => boolean;
|
|
11
11
|
onSelectionChange: () => void;
|
|
12
|
-
onRefusal: ((reason: string,
|
|
12
|
+
onRefusal: ((reason: string, ground: CanonicalRefusalGround) => void) | undefined;
|
|
13
13
|
};
|
|
14
14
|
/** Secondary views compile classified native input into the shared Document journal. */
|
|
15
15
|
export declare const createCanonicalStoryEditor: ({ story, getView, getApi, enabled, onRefusal, onSelectionChange }: CanonicalStoryEditorOptions) => {
|
|
@@ -17,6 +17,7 @@ export declare const createCanonicalStoryEditor: ({ story, getView, getApi, enab
|
|
|
17
17
|
props: {
|
|
18
18
|
handleKeyDown: (view: EditorView, event: KeyboardEvent) => boolean;
|
|
19
19
|
handleTextInput: (view: EditorView, from: number, to: number, text: string) => boolean;
|
|
20
|
+
handleKeyPress: (view: EditorView, event: KeyboardEvent) => boolean;
|
|
20
21
|
handleDOMEvents: {
|
|
21
22
|
keydown: (view: EditorView, event: KeyboardEvent) => boolean;
|
|
22
23
|
keyup: (view: EditorView, event: KeyboardEvent) => boolean;
|
|
@@ -6,11 +6,11 @@ import { AllSelection, TextSelection } from "prosemirror-state";
|
|
|
6
6
|
/** Secondary views compile classified native input into the shared Document journal. */
|
|
7
7
|
const createCanonicalStoryEditor = ({ story, getView, getApi, enabled, onRefusal, onSelectionChange }) => {
|
|
8
8
|
const refuse = (reason) => {
|
|
9
|
-
const
|
|
9
|
+
const ground = { gap: CANONICAL_GAP.dispatch };
|
|
10
10
|
const message = reason;
|
|
11
|
-
if (onRefusal) onRefusal(message,
|
|
11
|
+
if (onRefusal) onRefusal(message, ground);
|
|
12
12
|
else throw new CanonicalSessionError({
|
|
13
|
-
|
|
13
|
+
ground,
|
|
14
14
|
message,
|
|
15
15
|
reason: "refused"
|
|
16
16
|
});
|
|
@@ -80,6 +80,7 @@ const createCanonicalStoryEditor = ({ story, getView, getApi, enabled, onRefusal
|
|
|
80
80
|
props: {
|
|
81
81
|
handleKeyDown: (view, event) => enabled() && boundary.handleKeyDown(view, event),
|
|
82
82
|
handleTextInput: (view, from, to, text) => enabled() && boundary.handleTextInput(view, from, to, text),
|
|
83
|
+
handleKeyPress: (view, event) => enabled() && boundary.handleKeyPress(view, event),
|
|
83
84
|
handleDOMEvents: {
|
|
84
85
|
keydown: (view, event) => enabled() && boundary.handleDOMEvents.keydown(view, event),
|
|
85
86
|
keyup: (view, event) => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { CanonicalCommit, CanonicalSession, CanonicalSessionError } from "./canonicalSession.js";
|
|
2
1
|
import { CanonicalCommandIntent } from "../prosemirror/canonicalCommands.js";
|
|
2
|
+
import { CanonicalCommit, CanonicalSession, CanonicalSessionError } from "./canonicalSession.js";
|
|
3
3
|
import { EditorState } from "prosemirror-state";
|
|
4
4
|
import { Result } from "better-result";
|
|
5
|
+
export declare const CELL_SELECTION_PLACEMENT_REFUSAL = "A note or table of contents goes at a caret, not over selected cells.";
|
|
5
6
|
/** Toolbar meanings enter the same operation journal as native input. */
|
|
6
7
|
export declare const prepareCanonicalCommands: (session: CanonicalSession, state: EditorState, commands: readonly CanonicalCommandIntent[]) => Result<CanonicalCommit, CanonicalSessionError>;
|
|
7
8
|
type CanonicalAutoformatInput = {
|
|
@@ -2,13 +2,16 @@ import { BUILT_IN_STYLE_NAME, createBuiltInStyleIndex } from "../docx/builtInSty
|
|
|
2
2
|
import { createNote } from "../docx/noteReferenceMark.js";
|
|
3
3
|
import { getCachedNumberingMap, numberingLevelUsesBulletMarker } from "../docx/numberingParser.js";
|
|
4
4
|
import { cloneParagraphWithoutPropertySource } from "../docx/paragraphPropertySource.js";
|
|
5
|
+
import { visitDocxParagraphs } from "../docx/paragraphTraversal.js";
|
|
5
6
|
import { listRequestsForMarker } from "../prosemirror/listAutoformatMarkers.js";
|
|
7
|
+
import { unusedListInstanceFor } from "../prosemirror/listNumbering.js";
|
|
6
8
|
import { effectiveParagraphNumbering, paragraphNumberingSourcesFromBoundary } from "../prosemirror/numberingAttr.js";
|
|
7
9
|
import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
|
|
8
10
|
import { collectHeadings } from "../utils/headingCollector.js";
|
|
9
11
|
import { CanonicalSessionError } from "./canonicalSession.js";
|
|
10
12
|
import { Result, panic } from "better-result";
|
|
11
13
|
import { headingOutlineLevel, paragraphNumberingReference } from "@stll/docx-core/model";
|
|
14
|
+
import { CellSelection } from "prosemirror-tables";
|
|
12
15
|
import { DOCUMENT_OP_TYPES, OP_STORIES, editorParagraphGroups, editorPositionAtPhysicalPosition, physicalPositionAtEditorOffset } from "@stll/docx-core/ops";
|
|
13
16
|
// src/controller/canonicalStructure.ts
|
|
14
17
|
const DEFAULT_TOC_PAGE_WIDTH_TWIPS = 12240;
|
|
@@ -23,13 +26,14 @@ const currentSectionEndpoint = (paragraph) => {
|
|
|
23
26
|
if (Object.hasOwn(paragraph, "sectionProperties")) return { type: "undefined" };
|
|
24
27
|
return { type: "omitted" };
|
|
25
28
|
};
|
|
29
|
+
const CELL_SELECTION_PLACEMENT_REFUSAL = "A note or table of contents goes at a caret, not over selected cells.";
|
|
26
30
|
const refuse = (message) => Result.err(new CanonicalSessionError({
|
|
27
|
-
gap: CANONICAL_GAP.commands,
|
|
31
|
+
ground: { gap: CANONICAL_GAP.commands },
|
|
28
32
|
message,
|
|
29
33
|
reason: "refused"
|
|
30
34
|
}));
|
|
31
35
|
const noChange = (message) => Result.err(new CanonicalSessionError({
|
|
32
|
-
gap: CANONICAL_GAP.commands,
|
|
36
|
+
ground: { gap: CANONICAL_GAP.commands },
|
|
33
37
|
message,
|
|
34
38
|
reason: "noChange"
|
|
35
39
|
}));
|
|
@@ -51,7 +55,7 @@ const effectiveNumbering = (paragraph) => effectiveParagraphNumbering(paragraphN
|
|
|
51
55
|
numPr: paragraph?.formatting?.numPr,
|
|
52
56
|
numPrFromStyle: paragraph?.formatting?.numPrFromStyle
|
|
53
57
|
}));
|
|
54
|
-
/**
|
|
58
|
+
/** Each selected paragraph with the block container that owns it. A list may run through several containers, such as table cells, as the editor applies it. */
|
|
55
59
|
const paragraphPositions = (session, paragraphs) => {
|
|
56
60
|
if (paragraphs.length === 0) return noChange("List changes require a paragraph selection.");
|
|
57
61
|
const positions = [];
|
|
@@ -66,10 +70,38 @@ const paragraphPositions = (session, paragraphs) => {
|
|
|
66
70
|
paragraph
|
|
67
71
|
});
|
|
68
72
|
}
|
|
69
|
-
const container = positions.at(0)?.container;
|
|
70
|
-
if (positions.some((position) => position.container !== container)) return refuse("A list command cannot span multiple block containers.");
|
|
71
73
|
return Result.ok(positions);
|
|
72
74
|
};
|
|
75
|
+
/** Content a paragraph keeps no trace of once its pending changes are accepted. */
|
|
76
|
+
const GONE_ON_ACCEPT = /* @__PURE__ */ new Set([
|
|
77
|
+
"deletion",
|
|
78
|
+
"moveFrom",
|
|
79
|
+
"bookmarkStart",
|
|
80
|
+
"bookmarkEnd",
|
|
81
|
+
"commentRangeStart",
|
|
82
|
+
"commentRangeEnd",
|
|
83
|
+
"moveFromRangeStart",
|
|
84
|
+
"moveFromRangeEnd",
|
|
85
|
+
"moveToRangeStart",
|
|
86
|
+
"moveToRangeEnd"
|
|
87
|
+
]);
|
|
88
|
+
/** A paragraph accepting removes: its mark and every character are going. */
|
|
89
|
+
const goesOnAccept = (paragraph) => (paragraph.pPrMark?.kind === "del" || paragraph.pPrMark?.kind === "moveFrom") && paragraph.content.every(({ type }) => GONE_ON_ACCEPT.has(type));
|
|
90
|
+
/**
|
|
91
|
+
* Every list instance a paragraph of the main story refers to once its pending
|
|
92
|
+
* changes are accepted: directly, through its style, or in a pending property
|
|
93
|
+
* change. A paragraph on its way out refers to nothing, so typing a list
|
|
94
|
+
* marker over a struck list takes the instance editing would.
|
|
95
|
+
*/
|
|
96
|
+
const referencedNumIds = (document) => {
|
|
97
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
98
|
+
visitDocxParagraphs({ documentBody: document.package.document }, (paragraph) => {
|
|
99
|
+
if (goesOnAccept(paragraph)) return;
|
|
100
|
+
for (const numPr of [paragraph.formatting?.numPr, paragraph.formatting?.numPrFromStyle]) if (numPr?.kind === "reference") referenced.add(numPr.numId);
|
|
101
|
+
for (const change of paragraph.propertyChanges ?? []) if (change.previousFormatting?.numPr?.kind === "reference") referenced.add(change.previousFormatting.numPr.numId);
|
|
102
|
+
});
|
|
103
|
+
return referenced;
|
|
104
|
+
};
|
|
73
105
|
const numberingIntent = (session, positions, request) => {
|
|
74
106
|
const definitions = session.document.package.numbering;
|
|
75
107
|
const map = definitions === void 0 ? void 0 : getCachedNumberingMap(definitions);
|
|
@@ -77,7 +109,7 @@ const numberingIntent = (session, positions, request) => {
|
|
|
77
109
|
const first = positions.at(0)?.index ?? 0;
|
|
78
110
|
const last = positions.at(-1)?.index ?? first;
|
|
79
111
|
const neighbor = [first > 0 ? container.at(first - 1) : void 0, container.at(last + 1)].find((item) => {
|
|
80
|
-
if (item?.type !== "paragraph" || item.formatting?.numPr?.kind !== "reference" || item.formatting.numPrFromStyle !== void 0) return false;
|
|
112
|
+
if (item?.type !== "paragraph" || goesOnAccept(item) || item.formatting?.numPr?.kind !== "reference" || item.formatting.numPrFromStyle !== void 0) return false;
|
|
81
113
|
const level = map?.getLevel(item.formatting.numPr.numId, item.formatting.numPr.ilvl ?? 0);
|
|
82
114
|
if (level == null || numberingLevelUsesBulletMarker(level) !== (request.kind === "bullet")) return false;
|
|
83
115
|
return request.format === void 0 || level.numFmt === request.format.numFmt && level.lvlText === request.format.lvlText;
|
|
@@ -85,6 +117,7 @@ const numberingIntent = (session, positions, request) => {
|
|
|
85
117
|
let numId;
|
|
86
118
|
let ilvl = 0;
|
|
87
119
|
let target;
|
|
120
|
+
const unused = map === void 0 ? void 0 : unusedListInstanceFor(map, referencedNumIds(session.document), request);
|
|
88
121
|
if (neighbor?.type === "paragraph" && neighbor.formatting?.numPr?.kind === "reference") {
|
|
89
122
|
numId = neighbor.formatting.numPr.numId;
|
|
90
123
|
ilvl = neighbor.formatting.numPr.ilvl ?? 0;
|
|
@@ -92,6 +125,12 @@ const numberingIntent = (session, positions, request) => {
|
|
|
92
125
|
type: "existing",
|
|
93
126
|
numId
|
|
94
127
|
};
|
|
128
|
+
} else if (unused !== void 0) {
|
|
129
|
+
numId = unused;
|
|
130
|
+
target = {
|
|
131
|
+
type: "existing",
|
|
132
|
+
numId
|
|
133
|
+
};
|
|
95
134
|
} else {
|
|
96
135
|
numId = Math.max(0, ...definitions?.nums.map((num) => num.numId) ?? []) + 1;
|
|
97
136
|
const abstractNumId = Math.max(-1, ...definitions?.abstractNums.map((num) => num.abstractNumId) ?? []) + 1;
|
|
@@ -135,6 +174,7 @@ const numberingIntent = (session, positions, request) => {
|
|
|
135
174
|
};
|
|
136
175
|
/** Toolbar meanings enter the same operation journal as native input. */
|
|
137
176
|
const prepareCanonicalCommands = (session, state, commands) => {
|
|
177
|
+
if (state.selection instanceof CellSelection && commands.some(({ type }) => type === "generateTOC" || type === "insertNote" || type === "deleteNote")) return refuse(CELL_SELECTION_PLACEMENT_REFUSAL);
|
|
138
178
|
const intents = [];
|
|
139
179
|
const sectionCommands = commands.filter((command) => command.type === "setSectionBreak" || command.type === "removeSectionBreak");
|
|
140
180
|
if (sectionCommands.length > 0) {
|
|
@@ -248,6 +288,88 @@ const prepareCanonicalCommands = (session, state, commands) => {
|
|
|
248
288
|
});
|
|
249
289
|
break;
|
|
250
290
|
}
|
|
291
|
+
case "formatTable":
|
|
292
|
+
for (const target of command.targets) {
|
|
293
|
+
const at = session.projection.addressAt(target.at);
|
|
294
|
+
if (at.isErr()) return at;
|
|
295
|
+
const address = {
|
|
296
|
+
story: at.value.story,
|
|
297
|
+
blockId: at.value.blockId
|
|
298
|
+
};
|
|
299
|
+
switch (target.scope) {
|
|
300
|
+
case "table":
|
|
301
|
+
intents.push({
|
|
302
|
+
type: "table",
|
|
303
|
+
operation: {
|
|
304
|
+
type: DOCUMENT_OP_TYPES.SET_TABLE_PROPS,
|
|
305
|
+
...address,
|
|
306
|
+
patch: target.patch
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
break;
|
|
310
|
+
case "row":
|
|
311
|
+
intents.push({
|
|
312
|
+
type: "table",
|
|
313
|
+
operation: {
|
|
314
|
+
type: DOCUMENT_OP_TYPES.SET_ROW_PROPS,
|
|
315
|
+
...address,
|
|
316
|
+
patch: target.patch
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
break;
|
|
320
|
+
case "cell":
|
|
321
|
+
intents.push({
|
|
322
|
+
type: "table",
|
|
323
|
+
operation: {
|
|
324
|
+
type: DOCUMENT_OP_TYPES.SET_CELL_PROPS,
|
|
325
|
+
...address,
|
|
326
|
+
patch: target.patch
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
break;
|
|
330
|
+
default: return target;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
break;
|
|
334
|
+
case "editTableBlock": {
|
|
335
|
+
const at = session.projection.addressAt(command.at);
|
|
336
|
+
if (at.isErr()) return at;
|
|
337
|
+
intents.push({
|
|
338
|
+
type: "tableBlock",
|
|
339
|
+
operation: {
|
|
340
|
+
...command.edit,
|
|
341
|
+
story: at.value.story,
|
|
342
|
+
blockId: at.value.blockId
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
case "editTableRow": {
|
|
348
|
+
const at = session.projection.addressAt(command.at);
|
|
349
|
+
if (at.isErr()) return at;
|
|
350
|
+
intents.push({
|
|
351
|
+
type: "tableRow",
|
|
352
|
+
operation: {
|
|
353
|
+
...command.edit,
|
|
354
|
+
story: at.value.story,
|
|
355
|
+
blockId: at.value.blockId
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
case "editTable": {
|
|
361
|
+
const at = session.projection.addressAt(command.at);
|
|
362
|
+
if (at.isErr()) return at;
|
|
363
|
+
intents.push({
|
|
364
|
+
type: "table",
|
|
365
|
+
operation: {
|
|
366
|
+
...command.edit,
|
|
367
|
+
story: at.value.story,
|
|
368
|
+
blockId: at.value.blockId
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
251
373
|
case "insertBreak": {
|
|
252
374
|
const from = session.projection.addressAt(command.from);
|
|
253
375
|
if (from.isErr()) return from;
|
|
@@ -473,4 +595,4 @@ const prepareCanonicalAutoformat = (session, state, { from, to, text }) => {
|
|
|
473
595
|
text: ""
|
|
474
596
|
}, paragraphIntent] });
|
|
475
597
|
};
|
|
476
|
-
export { prepareCanonicalAutoformat, prepareCanonicalCommands };
|
|
598
|
+
export { CELL_SELECTION_PLACEMENT_REFUSAL, prepareCanonicalAutoformat, prepareCanonicalCommands };
|
|
@@ -27,6 +27,11 @@ export type ContentControlWidgetControllerOptions = {
|
|
|
27
27
|
kind: "refused";
|
|
28
28
|
}>) => void) | undefined;
|
|
29
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* The picker's choices: one per stored value, the first item that has it. A
|
|
32
|
+
* pick is applied by value, and the value names its first item, so a later
|
|
33
|
+
* item sharing that value would show one label and write another.
|
|
34
|
+
*/
|
|
30
35
|
export declare const parseContentControlListItems: (raw: string | undefined) => ContentControlListItem[];
|
|
31
36
|
export declare class ContentControlWidgetController extends Subscribable<ContentControlWidgetSnapshot> {
|
|
32
37
|
private readonly options;
|
|
@@ -8,6 +8,11 @@ const isListItem = (value) => {
|
|
|
8
8
|
if (!("displayText" in value) || !("value" in value)) return false;
|
|
9
9
|
return typeof value.displayText === "string" && typeof value.value === "string";
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* The picker's choices: one per stored value, the first item that has it. A
|
|
13
|
+
* pick is applied by value, and the value names its first item, so a later
|
|
14
|
+
* item sharing that value would show one label and write another.
|
|
15
|
+
*/
|
|
11
16
|
const parseContentControlListItems = (raw) => {
|
|
12
17
|
if (!raw) return [];
|
|
13
18
|
let parsed;
|
|
@@ -17,7 +22,14 @@ const parseContentControlListItems = (raw) => {
|
|
|
17
22
|
return [];
|
|
18
23
|
}
|
|
19
24
|
if (!Array.isArray(parsed)) return [];
|
|
20
|
-
|
|
25
|
+
const values = /* @__PURE__ */ new Set();
|
|
26
|
+
const items = [];
|
|
27
|
+
for (const item of parsed) {
|
|
28
|
+
if (!isListItem(item) || values.has(item.value)) continue;
|
|
29
|
+
values.add(item.value);
|
|
30
|
+
items.push(item);
|
|
31
|
+
}
|
|
32
|
+
return items;
|
|
21
33
|
};
|
|
22
34
|
const pickerPosition = (event) => {
|
|
23
35
|
const rect = event.anchor.getBoundingClientRect();
|
|
@@ -38,6 +38,7 @@ const createFolioEditor = (deps) => {
|
|
|
38
38
|
getCanonicalDocument: () => deps.getEditorApi()?.getCanonicalDocument() ?? null,
|
|
39
39
|
setCanonicalMode: (mode) => deps.getEditorApi()?.setCanonicalMode(mode) ?? false,
|
|
40
40
|
resolveCanonicalRevisions: (revisionIds, resolution) => deps.getEditorApi()?.resolveCanonicalRevisions(revisionIds, resolution) ?? false,
|
|
41
|
+
resolveCanonicalSuggestion: (suggestionId, resolution, author) => deps.getEditorApi()?.resolveCanonicalSuggestion(suggestionId, resolution, author) ?? false,
|
|
41
42
|
focus: () => deps.getEditorApi()?.focus(),
|
|
42
43
|
blur: () => deps.getEditorApi()?.blur(),
|
|
43
44
|
isFocused: () => deps.getEditorApi()?.isFocused() ?? false,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
|
|
3
3
|
import { HiddenEditorApi } from "./hiddenEditorApi.js";
|
|
4
4
|
import { DirectEditorProps, EditorView } from "prosemirror-view";
|
|
5
5
|
export type HeaderFooterPartKind = "header" | "footer";
|
|
@@ -20,7 +20,7 @@ export type HeaderFooterEditorManagerDeps = {
|
|
|
20
20
|
getReadOnly?: (() => boolean) | undefined;
|
|
21
21
|
getCanonicalApi?: (() => HiddenEditorApi | null) | undefined;
|
|
22
22
|
getExperimentalSession?: (() => "canonical" | undefined) | undefined;
|
|
23
|
-
onSessionRefusal?: ((reason: string,
|
|
23
|
+
onSessionRefusal?: ((reason: string, ground: CanonicalRefusalGround, error?: Error) => void) | undefined;
|
|
24
24
|
getHost: () => HTMLElement | null;
|
|
25
25
|
getStyles: () => document_d_exports.StyleDefinitions | null | undefined;
|
|
26
26
|
getTheme: () => document_d_exports.Theme | null | undefined;
|
|
@@ -39,9 +39,9 @@ const buildInitialState = (headerFooter, styles, theme, numbering, manager) => {
|
|
|
39
39
|
doc: document,
|
|
40
40
|
schema,
|
|
41
41
|
plugins: [
|
|
42
|
+
createDocumentNumberingPlugin(numbering),
|
|
42
43
|
...manager.getPlugins(),
|
|
43
|
-
createDocumentStylesPlugin(styles)
|
|
44
|
-
createDocumentNumberingPlugin(numbering)
|
|
44
|
+
createDocumentStylesPlugin(styles)
|
|
45
45
|
]
|
|
46
46
|
})));
|
|
47
47
|
};
|
|
@@ -184,7 +184,7 @@ const createHeaderFooterEditorManager = (deps) => {
|
|
|
184
184
|
editable: () => !(deps.getReadOnly?.() ?? false),
|
|
185
185
|
state: canonicalProjection ? EditorState.create({
|
|
186
186
|
doc: canonicalProjection,
|
|
187
|
-
plugins: [
|
|
187
|
+
plugins: [createDocumentNumberingPlugin(numbering), createDocumentStyleContextPlugin(styles)]
|
|
188
188
|
}) : buildInitialState(headerFooter, styles, theme, numbering, manager),
|
|
189
189
|
dispatchTransaction(transaction) {
|
|
190
190
|
if ((deps.getReadOnly?.() ?? false) && transaction.docChanged) return;
|
|
@@ -192,7 +192,7 @@ const createHeaderFooterEditorManager = (deps) => {
|
|
|
192
192
|
const nextState = view.state.apply(transaction);
|
|
193
193
|
const docChanged = !nextState.doc.eq(view.state.doc);
|
|
194
194
|
const noteIssue = noteReferenceTransactionIssue(transaction);
|
|
195
|
-
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, CANONICAL_GAP.dispatch, noteIssue);
|
|
195
|
+
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, { gap: CANONICAL_GAP.dispatch }, noteIssue);
|
|
196
196
|
view.updateState(nextState);
|
|
197
197
|
const mountedPart = mounted.get(part.rId);
|
|
198
198
|
if (mountedPart && docChanged) mountedPart.dirty = true;
|
|
@@ -232,7 +232,7 @@ const createHeaderFooterEditorManager = (deps) => {
|
|
|
232
232
|
const canonical = deps.getCanonicalApi?.()?.getCanonicalDocument();
|
|
233
233
|
if (canonical) return canonical;
|
|
234
234
|
throw new CanonicalSessionError({
|
|
235
|
-
gap: CANONICAL_GAP.authorityRouting,
|
|
235
|
+
ground: { gap: CANONICAL_GAP.authorityRouting },
|
|
236
236
|
reason: "refused",
|
|
237
237
|
message: "Canonical story snapshot is unavailable."
|
|
238
238
|
});
|
|
@@ -44,6 +44,11 @@ export type HiddenEditorApi = {
|
|
|
44
44
|
setCanonicalMode: (mode: CanonicalSessionMode) => boolean;
|
|
45
45
|
/** Resolve canonical revisions as one batch and journal its exact inverse. */
|
|
46
46
|
resolveCanonicalRevisions: (revisionIds: readonly number[], resolution: "accept" | "reject") => boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Accept a pending suggestion as ordinary tracked changes by `author`, or
|
|
49
|
+
* reject it, as one journalled change.
|
|
50
|
+
*/
|
|
51
|
+
resolveCanonicalSuggestion: (suggestionId: string, resolution: "accept" | "reject", author: string) => boolean;
|
|
47
52
|
updateCanonicalInputLifecycle: (action: "beginComposition" | "endComposition" | "breakUndoGroup") => boolean;
|
|
48
53
|
applyCanonicalStoryHistory: (options: CanonicalStoryHistoryOptions) => boolean;
|
|
49
54
|
applyCanonicalOperations: (ops: readonly DocumentOp[]) => boolean;
|
|
@@ -95,6 +100,7 @@ export type HiddenEditorApiDeps = {
|
|
|
95
100
|
isCanonicalSaveCurrent?: HiddenEditorApi["isCanonicalSaveCurrent"];
|
|
96
101
|
setCanonicalMode?: HiddenEditorApi["setCanonicalMode"];
|
|
97
102
|
resolveCanonicalRevisions?: HiddenEditorApi["resolveCanonicalRevisions"];
|
|
103
|
+
resolveCanonicalSuggestion?: HiddenEditorApi["resolveCanonicalSuggestion"];
|
|
98
104
|
executeCanonicalCommand?: (command: Command) => boolean | undefined;
|
|
99
105
|
getCanonicalHistory?: () => Pick<HiddenEditorApi, "undo" | "redo" | "canUndo" | "canRedo"> | null;
|
|
100
106
|
canonicalOperations?: Pick<HiddenEditorApi, "updateCanonicalInputLifecycle" | "applyCanonicalOperations" | "applyCanonicalComment" | "applyCanonicalSectionProperties" | "getCanonicalStoryProjection" | "replaceCanonicalStoryText" | "applyCanonicalStoryHistory" | "getCanonicalStorySelection" | "applyCanonicalDocumentOperations" | "undoCanonicalDocumentOperations">;
|
|
@@ -34,6 +34,7 @@ const createHiddenEditorApi = (deps) => {
|
|
|
34
34
|
getView: () => deps.getView() ?? null,
|
|
35
35
|
setCanonicalMode: (mode) => !deps.isDestroying() && (deps.setCanonicalMode?.(mode) ?? false),
|
|
36
36
|
resolveCanonicalRevisions: (revisionIds, resolution) => !deps.isDestroying() && (deps.resolveCanonicalRevisions?.(revisionIds, resolution) ?? false),
|
|
37
|
+
resolveCanonicalSuggestion: (suggestionId, resolution, author) => !deps.isDestroying() && (deps.resolveCanonicalSuggestion?.(suggestionId, resolution, author) ?? false),
|
|
37
38
|
getCanonicalComments: () => deps.getCanonicalComments?.() ?? null,
|
|
38
39
|
getCanonicalCommittedVersion: () => deps.getCanonicalCommittedVersion?.() ?? null,
|
|
39
40
|
captureCanonicalSave: () => deps.captureCanonicalSave?.() ?? null,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
|
|
3
3
|
import { EditorMode } from "../managers/EditorModeManager.js";
|
|
4
4
|
import { HiddenEditorApi } from "./hiddenEditorApi.js";
|
|
5
5
|
import { HiddenEditorStateReason } from "../layout-engine/layoutInstrumentation.js";
|
|
@@ -12,8 +12,9 @@ import * as Yjs from "yjs";
|
|
|
12
12
|
import { XmlFragment } from "yjs";
|
|
13
13
|
import * as YProseMirror from "y-prosemirror";
|
|
14
14
|
declare const CanonicalSessionRefusalErrorBase: TaggedErrorClass<"CanonicalSessionRefusalError">;
|
|
15
|
+
/** A refused input, with whether the session lacks the capability or the document forbids it. */
|
|
15
16
|
export declare class CanonicalSessionRefusalError extends CanonicalSessionRefusalErrorBase<{
|
|
16
|
-
|
|
17
|
+
ground: CanonicalRefusalGround;
|
|
17
18
|
message: string;
|
|
18
19
|
}> {}
|
|
19
20
|
type YProseMirrorModule = typeof YProseMirror;
|
|
@@ -65,7 +66,7 @@ export type HiddenEditorManagerDeps = {
|
|
|
65
66
|
getExperimentalSession?: () => "canonical" | undefined;
|
|
66
67
|
getEditingMode?: () => EditorMode;
|
|
67
68
|
getSuggestionAuthor?: () => string;
|
|
68
|
-
onSessionRefusal?: (reason: string,
|
|
69
|
+
onSessionRefusal?: (reason: string, ground: CanonicalRefusalGround, error?: Error) => void;
|
|
69
70
|
/**
|
|
70
71
|
* Identity of the loaded document as tracked by the adapter's loader: the
|
|
71
72
|
* same value across internal edits (so typing does not trigger an external
|