@stll/folio-core 0.73.0 → 0.75.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/clean-text.d.ts +4 -1
- package/dist/ai-edits/clean-text.js +21 -7
- package/dist/ai-edits/headless.d.ts +5 -2
- package/dist/ai-edits/headless.js +20 -14
- package/dist/ai-edits/note-references.d.ts +1 -1
- package/dist/ai-edits/note-references.js +1 -1
- package/dist/ai-edits/pending-suggestions.d.ts +9 -7
- package/dist/ai-edits/pending-suggestions.js +134 -88
- package/dist/ai-edits/pendingJoin.d.ts +5 -1
- package/dist/ai-edits/pendingJoin.js +12 -3
- package/dist/ai-edits/result-validation.js +1 -1
- package/dist/ai-edits/retired-comment-receipts.d.ts +2 -2
- package/dist/ai-edits/retired-comment-receipts.js +3 -18
- package/dist/ai-edits/snapshot.js +1 -1
- package/dist/ai-edits/table-cell-mutations.js +1 -1
- package/dist/ai-edits/tracked-batch-fidelity.d.ts +6 -10
- package/dist/ai-edits/tracked-batch-fidelity.js +3 -182
- package/dist/canonical/canonicalBatchReview.d.ts +4 -1
- package/dist/canonical/canonicalBatchReview.js +32 -14
- package/dist/canonical/canonicalComments.d.ts +6 -2
- package/dist/canonical/canonicalComments.js +8 -4
- package/dist/canonical/canonicalInlineGaps.d.ts +56 -0
- package/dist/canonical/canonicalInlineGaps.js +118 -0
- package/dist/canonical/canonicalInlineProjection.d.ts +4 -13
- package/dist/canonical/canonicalInlineProjection.js +6 -28
- package/dist/canonical/canonicalProjectionBlocks.d.ts +4 -4
- package/dist/canonical/canonicalPublicOperations.js +99 -36
- package/dist/canonical/canonicalRefusalGrounds.d.ts +4 -0
- package/dist/canonical/canonicalRefusalGrounds.js +56 -0
- package/dist/canonical/canonicalSelection.js +1 -1
- package/dist/canonical/canonicalSession.d.ts +12 -6
- package/dist/canonical/canonicalSession.js +129 -141
- package/dist/canonical/canonicalTrackedBatchFidelity.js +3 -3
- package/dist/compare/inline-atoms.d.ts +35 -41
- package/dist/compare/inline-atoms.js +2 -465
- package/dist/compare/section-boundary-properties.d.ts +3 -30
- package/dist/compare/section-boundary-properties.js +4 -72
- package/dist/controller/autocompleteSuggestion.js +1 -1
- package/dist/controller/canonicalClipboard.js +45 -44
- package/dist/controller/canonicalComposition.d.ts +1 -1
- package/dist/controller/canonicalComposition.js +6 -6
- package/dist/controller/canonicalInput.d.ts +4 -2
- package/dist/controller/canonicalInput.js +34 -17
- package/dist/controller/canonicalPresence.js +1 -1
- package/dist/controller/canonicalRoomAuthority.js +1 -1
- package/dist/controller/canonicalRoomWire.js +1 -1
- package/dist/controller/canonicalStoryEditor.d.ts +2 -3
- package/dist/controller/canonicalStoryEditor.js +43 -25
- package/dist/controller/canonicalStructure.d.ts +19 -2
- package/dist/controller/canonicalStructure.js +140 -43
- package/dist/controller/canonicalTabRoom.js +1 -1
- package/dist/controller/canonicalYjsRoom.js +1 -1
- package/dist/controller/deferredDisplayListPainter.d.ts +8 -0
- package/dist/controller/deferredDisplayListPainter.js +34 -0
- package/dist/controller/folioEditor.js +4 -2
- package/dist/controller/headerFooterEditorManager.js +3 -17
- package/dist/controller/hiddenEditorApi.d.ts +24 -3
- package/dist/controller/hiddenEditorApi.js +4 -17
- package/dist/controller/hiddenEditorManager.js +136 -197
- package/dist/controller/layoutPipeline.d.ts +4 -86
- package/dist/controller/layoutPipeline.js +8 -727
- package/dist/controller/layoutPipelineExecution.d.ts +94 -0
- package/dist/controller/layoutPipelineExecution.js +730 -0
- package/dist/controller/noteEditorManager.js +3 -16
- package/dist/document-operations.js +1 -1
- package/dist/docx/blockContentParser.d.ts +1 -3
- package/dist/docx/blockContentParser.js +3 -10
- package/dist/docx/canonicalSave.d.ts +4 -3
- package/dist/docx/canonicalSave.js +4 -3
- package/dist/docx/canonicalSessionInput.js +1 -1
- package/dist/docx/containerChildren.js +1 -1
- package/dist/docx/createDocx.d.ts +4 -0
- package/dist/docx/createDocx.js +6 -0
- package/dist/docx/listMarkerComputation.d.ts +24 -17
- package/dist/docx/listMarkerComputation.js +31 -60
- package/dist/docx/listModelNormalization.js +8 -15
- package/dist/docx/modelValidation.js +1 -1
- package/dist/docx/parser.js +1 -1
- package/dist/docx/reviewResolutionProvenance.js +1 -1
- package/dist/docx/rezip.d.ts +16 -3
- package/dist/docx/rezip.js +36 -10
- package/dist/docx/selectiveSave.js +13 -5
- package/dist/docx/serializer/borderSerializer.js +1 -1
- package/dist/docx/serializer/commentSerializer.js +1 -1
- package/dist/docx/serializer/documentSerializer.js +1 -1
- package/dist/docx/serializer/paragraphSerializer.js +3 -3
- package/dist/docx/serializer/runSerializer.js +1 -1
- package/dist/docx/serializer/sectionPropertiesSerializer.js +1 -1
- package/dist/docx/serializer/tableSerializer.js +1 -1
- package/dist/docx/serializer/textFormattingSerializer.js +1 -1
- package/dist/docx/serializer/trackedChangeAttributes.js +1 -1
- package/dist/docx/server/templatePlan/apply.js +107 -14
- package/dist/docx/server/templatePlan/blocks.d.ts +16 -1
- package/dist/docx/server/templatePlan/blocks.js +93 -7
- package/dist/docx/server/templatePlan/builders.d.ts +37 -2
- package/dist/docx/server/templatePlan/builders.js +196 -5
- package/dist/docx/server/templatePlan/emit.d.ts +2 -0
- package/dist/docx/server/templatePlan/emit.js +2 -0
- package/dist/docx/server/templatePlan/inspect.js +81 -61
- package/dist/docx/server/templatePlan/labels.d.ts +16 -2
- package/dist/docx/server/templatePlan/labels.js +131 -20
- package/dist/docx/server/templatePlan/plan.d.ts +15 -1
- package/dist/docx/server/templatePlan/plan.js +62 -13
- package/dist/docx/server/templatePlan/planShape.js +52 -4
- package/dist/docx/server/templatePlan/story.d.ts +8 -0
- package/dist/docx/server/templatePlan/story.js +11 -1
- package/dist/docx/server/templatePlan/types.d.ts +176 -18
- package/dist/docx/server/templatePlan/types.js +1 -0
- package/dist/docx/server/templatePlan/verify.js +60 -11
- package/dist/docx/server/templatePlan/xml.d.ts +5 -0
- package/dist/docx/server/templatePlan/xml.js +7 -1
- package/dist/docx/storyBlockReplay.js +1 -1
- package/dist/docx/xmlParser.js +1 -1
- package/dist/i18n/loadMessages.d.ts +5 -0
- package/dist/i18n/loadMessages.js +46 -0
- package/dist/i18n/locales.d.ts +3 -0
- package/dist/i18n/locales.js +17 -0
- package/dist/i18n/messages/ar.gen.js +1 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +17 -0
- package/dist/i18n/messages/catalogs.gen.js +17 -0
- package/dist/i18n/messages/cs.gen.js +1 -0
- package/dist/i18n/messages/de.gen.js +1 -0
- package/dist/i18n/messages/en.gen.js +1 -0
- package/dist/i18n/messages/es.gen.js +1 -0
- package/dist/i18n/messages/et.gen.js +1 -0
- package/dist/i18n/messages/fr.gen.js +1 -0
- package/dist/i18n/messages/he.gen.js +1 -0
- package/dist/i18n/messages/hi.gen.js +1 -0
- package/dist/i18n/messages/hu.gen.js +1 -0
- package/dist/i18n/messages/lt.gen.js +1 -0
- package/dist/i18n/messages/lv.gen.js +1 -0
- package/dist/i18n/messages/messages.gen.d.ts +1 -0
- package/dist/i18n/messages/pl.gen.js +1 -0
- package/dist/i18n/messages/pt-BR.gen.js +1 -0
- package/dist/i18n/messages/sk.gen.js +1 -0
- package/dist/i18n/messages/tr.gen.js +1 -0
- package/dist/i18n/messages/zh-CN.gen.js +1 -0
- package/dist/i18n/messages.d.ts +3 -2
- package/dist/i18n/messages.js +4 -16
- package/dist/internal/clipboardTransformPlugin.d.ts +3 -0
- package/dist/internal/clipboardTransformPlugin.js +13 -0
- package/dist/internal/extensionRuntime.d.ts +7 -0
- package/dist/internal/extensionRuntime.js +28 -0
- package/dist/internal/paragraphFormattingSerialization.js +1 -1
- package/dist/internal/starterKitExtensions.d.ts +20 -0
- package/dist/internal/starterKitExtensions.js +123 -0
- package/dist/internal/wholeStoryRevisionResolution.js +2 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +0 -12
- package/dist/layout-bridge/convert/topLevelConversion.js +1 -10
- package/dist/prosemirror/attrs/index.js +1 -1
- package/dist/prosemirror/canonicalSelectionRange.js +1 -1
- package/dist/prosemirror/canonicalTableCommands.js +1 -1
- package/dist/prosemirror/commands/comments.js +3 -3
- package/dist/prosemirror/commands/contentControls.js +1 -1
- package/dist/prosemirror/commands/pastePlainText.js +2 -3
- package/dist/prosemirror/commands/replaceRangeText.js +1 -1
- package/dist/prosemirror/commentRecords.js +2 -2
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +0 -5
- package/dist/prosemirror/conversion/fromProseDoc.js +2 -9
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/index.js +2 -2
- package/dist/prosemirror/extensions/ExtensionManager.js +4 -22
- package/dist/prosemirror/extensions/StarterKit.d.ts +4 -27
- package/dist/prosemirror/extensions/StarterKit.js +29 -115
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +2 -2
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +7 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
- package/dist/prosemirror/extensions/index.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +8 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +7 -40
- package/dist/prosemirror/hyperlinkRemoval.js +7 -2
- package/dist/prosemirror/index.d.ts +2 -2
- package/dist/prosemirror/index.js +2 -2
- package/dist/prosemirror/keptRangeBoundaries.js +1 -1
- package/dist/prosemirror/listMarker.d.ts +1 -6
- package/dist/prosemirror/listMarker.js +4 -56
- package/dist/prosemirror/listNumbering.js +1 -1
- package/dist/prosemirror/noteReferenceOccurrences.js +1 -1
- package/dist/prosemirror/noteReferenceReview.d.ts +2 -56
- package/dist/prosemirror/noteReferenceReview.js +2 -243
- package/dist/prosemirror/pastedCommentCopies.js +1 -1
- package/dist/prosemirror/plugins/documentNumbering.js +1 -1
- package/dist/prosemirror/plugins/documentStyles.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -1
- package/dist/prosemirror/suggestionCommands.d.ts +47 -0
- package/dist/prosemirror/suggestionCommands.js +31 -0
- package/dist/prosemirror/tableCellPaste.js +1 -1
- package/dist/prosemirror/tableRunIn.js +1 -1
- package/dist/prosemirror/textInput.js +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/types/canonicalCapabilities.d.ts +42 -93
- package/dist/types/canonicalCapabilities.js +53 -91
- package/dist/types/canonicalComments.d.ts +2 -2
- package/dist/types/canonicalSections.d.ts +2 -2
- package/dist/utils/clipboard.d.ts +2 -28
- package/dist/utils/clipboard.js +1 -96
- package/dist/utils/clipboardFiles.d.ts +27 -0
- package/dist/utils/clipboardFiles.js +98 -0
- package/dist/utils/rulerControl.d.ts +1 -0
- package/dist/utils/rulerControl.js +2 -1
- package/package.json +2 -2
- package/dist/ai-edits/apply.d.ts +0 -94
- package/dist/ai-edits/apply.js +0 -6637
- package/dist/ai-edits/note-story-inventory.d.ts +0 -5
- package/dist/ai-edits/note-story-inventory.js +0 -10
- package/dist/ai-edits/revisionStretches.d.ts +0 -32
- package/dist/ai-edits/revisionStretches.js +0 -147
- package/dist/document-operations-apply.d.ts +0 -15
- package/dist/document-operations-apply.js +0 -280
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +0 -12
- package/dist/prosemirror/extensions/core/HistoryExtension.js +0 -114
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +0 -23
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +0 -270
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +0 -51
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +0 -411
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -92
- package/dist/prosemirror/plugins/suggestionMode.js +0 -1515
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +0 -8
- package/dist/prosemirror/tablePositionedBookmarks.js +0 -80
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { document_d_exports } from "../types/document.js";
|
|
2
|
-
type NoteStories = Pick<document_d_exports.Document["package"], "footnotes" | "endnotes">;
|
|
3
|
-
/** The note collections visible to a reviewer or its captured save state. */
|
|
4
|
-
export declare const noteStoryInventory: (source: NoteStories, removed: Pick<ReadonlySet<string>, "has" | "size">) => NoteStories;
|
|
5
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// src/ai-edits/note-story-inventory.ts
|
|
2
|
-
/** The note collections visible to a reviewer or its captured save state. */
|
|
3
|
-
const noteStoryInventory = (source, removed) => {
|
|
4
|
-
if (removed.size === 0) return source;
|
|
5
|
-
return {
|
|
6
|
-
...source.footnotes && { footnotes: source.footnotes.filter((note) => !removed.has(`footnote:${note.id}`)) },
|
|
7
|
-
...source.endnotes && { endnotes: source.endnotes.filter((note) => !removed.has(`endnote:${note.id}`)) }
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export { noteStoryInventory };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One id per stretch of an inline revision.
|
|
3
|
-
*
|
|
4
|
-
* An edit inside a pending insertion (or a replacement whose words differ in
|
|
5
|
-
* several places) leaves one revision in stretches with other content between
|
|
6
|
-
* them. A saved package writes each stretch as a wrapper of its own, and
|
|
7
|
-
* `w:id` is unique per wrapper, so the save would give every stretch after the
|
|
8
|
-
* first a fresh id: once reopened they are separate changes, each accepted or
|
|
9
|
-
* rejected alone. The batch gives them those ids when it makes them, so the
|
|
10
|
-
* reviewer lists, resolves, saves and reopens the same changes.
|
|
11
|
-
*
|
|
12
|
-
* A stretch is what the reader lists as one change: the revision's content in
|
|
13
|
-
* one paragraph, uninterrupted but for comment references.
|
|
14
|
-
* A formatting revision instead belongs to one serialized run carrier. A
|
|
15
|
-
* later edit can split that carrier without changing its property mark, so
|
|
16
|
-
* each resulting carrier gets its own id through the same allocator.
|
|
17
|
-
*/
|
|
18
|
-
import { Transaction } from "prosemirror-state";
|
|
19
|
-
type SeparateRevisionStretchesOptions = {
|
|
20
|
-
tr: Transaction;
|
|
21
|
-
revisionSeed: number;
|
|
22
|
-
};
|
|
23
|
-
export type SeparatedRevisionStretches = {
|
|
24
|
-
nextRevisionId: number;
|
|
25
|
-
/** Each fresh id, with the revision whose stretch it now names. */
|
|
26
|
-
minted: {
|
|
27
|
-
revisionId: number;
|
|
28
|
-
from: number;
|
|
29
|
-
}[];
|
|
30
|
-
};
|
|
31
|
-
export declare const separateRevisionStretches: ({ tr, revisionSeed }: SeparateRevisionStretchesOptions) => SeparatedRevisionStretches;
|
|
32
|
-
export {};
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { expectRunPropertyChangeMarkAttrs, expectTrackedChangeMarkAttrs } from "../prosemirror/attrs/index.js";
|
|
2
|
-
import { applyMarksToRunFormattingRepresentation, expandRunFormattingCarrier } from "../prosemirror/runFormattingInlineCarriers.js";
|
|
3
|
-
import { panic } from "better-result";
|
|
4
|
-
// src/ai-edits/revisionStretches.ts
|
|
5
|
-
/**
|
|
6
|
-
* One id per stretch of an inline revision.
|
|
7
|
-
*
|
|
8
|
-
* An edit inside a pending insertion (or a replacement whose words differ in
|
|
9
|
-
* several places) leaves one revision in stretches with other content between
|
|
10
|
-
* them. A saved package writes each stretch as a wrapper of its own, and
|
|
11
|
-
* `w:id` is unique per wrapper, so the save would give every stretch after the
|
|
12
|
-
* first a fresh id: once reopened they are separate changes, each accepted or
|
|
13
|
-
* rejected alone. The batch gives them those ids when it makes them, so the
|
|
14
|
-
* reviewer lists, resolves, saves and reopens the same changes.
|
|
15
|
-
*
|
|
16
|
-
* A stretch is what the reader lists as one change: the revision's content in
|
|
17
|
-
* one paragraph, uninterrupted but for comment references.
|
|
18
|
-
* A formatting revision instead belongs to one serialized run carrier. A
|
|
19
|
-
* later edit can split that carrier without changing its property mark, so
|
|
20
|
-
* each resulting carrier gets its own id through the same allocator.
|
|
21
|
-
*/
|
|
22
|
-
const INLINE_REVISION_MARKS = /* @__PURE__ */ new Set(["insertion", "deletion"]);
|
|
23
|
-
const separateRevisionStretches = ({ tr, revisionSeed }) => {
|
|
24
|
-
let nextRevisionId = revisionSeed;
|
|
25
|
-
const minted = [];
|
|
26
|
-
const retargets = [];
|
|
27
|
-
const formattingRetargets = [];
|
|
28
|
-
const formattingIds = /* @__PURE__ */ new Set();
|
|
29
|
-
const formattingRepresentations = /* @__PURE__ */ new Set();
|
|
30
|
-
let stretches = /* @__PURE__ */ new Map();
|
|
31
|
-
tr.doc.descendants((node, pos) => {
|
|
32
|
-
if (node.isTextblock) {
|
|
33
|
-
stretches = /* @__PURE__ */ new Map();
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
const carrier = node.marks.some(({ type }) => type.name === "runPropertyChange") ? expandRunFormattingCarrier(node, pos) : null;
|
|
37
|
-
for (const representation of carrier?.representations ?? []) {
|
|
38
|
-
if (carrier?.disposition === "structured-field" && representation.role === "owner") continue;
|
|
39
|
-
const mark = representation.node.marks.find(({ type }) => type.name === "runPropertyChange");
|
|
40
|
-
if (!mark) continue;
|
|
41
|
-
if (formattingRepresentations.has(representation.position)) continue;
|
|
42
|
-
formattingRepresentations.add(representation.position);
|
|
43
|
-
const ids = /* @__PURE__ */ new Map();
|
|
44
|
-
for (const { info } of expectRunPropertyChangeMarkAttrs(mark).changes) {
|
|
45
|
-
if (!formattingIds.has(info.id)) {
|
|
46
|
-
formattingIds.add(info.id);
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
const fresh = nextRevisionId++;
|
|
50
|
-
minted.push({
|
|
51
|
-
revisionId: fresh,
|
|
52
|
-
from: info.id
|
|
53
|
-
});
|
|
54
|
-
ids.set(info.id, fresh);
|
|
55
|
-
}
|
|
56
|
-
if (ids.size > 0) formattingRetargets.push({
|
|
57
|
-
representation,
|
|
58
|
-
mark,
|
|
59
|
-
ids
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
if (!node.isInline || !(node.isLeaf || node.isText)) return true;
|
|
63
|
-
const layersOf = (mark) => {
|
|
64
|
-
const attrs = expectTrackedChangeMarkAttrs(mark);
|
|
65
|
-
return [...(attrs._docxRevisionAncestors ?? []).flatMap((ancestor) => ancestor.type === "insertion" || ancestor.type === "deletion" ? [{
|
|
66
|
-
kind: ancestor.type,
|
|
67
|
-
revisionId: ancestor.revisionId
|
|
68
|
-
}] : []), {
|
|
69
|
-
kind: mark.type.name,
|
|
70
|
-
revisionId: attrs.revisionId
|
|
71
|
-
}];
|
|
72
|
-
};
|
|
73
|
-
const revisionMarks = node.marks.filter((mark) => INLINE_REVISION_MARKS.has(mark.type.name) && expectTrackedChangeMarkAttrs(mark).moveKind === void 0);
|
|
74
|
-
const carried = new Set(revisionMarks.flatMap((mark) => layersOf(mark).map(({ kind, revisionId }) => `${kind}:${String(revisionId)}`)));
|
|
75
|
-
if (node.type.name !== "commentReference") {
|
|
76
|
-
for (const [key, stretch] of stretches) if (!carried.has(key)) stretch.interrupted = true;
|
|
77
|
-
}
|
|
78
|
-
for (const mark of revisionMarks) {
|
|
79
|
-
const ids = /* @__PURE__ */ new Map();
|
|
80
|
-
for (const { kind, revisionId } of layersOf(mark)) {
|
|
81
|
-
const key = `${kind}:${String(revisionId)}`;
|
|
82
|
-
let stretch = stretches.get(key);
|
|
83
|
-
if (!stretch) {
|
|
84
|
-
stretch = {
|
|
85
|
-
id: revisionId,
|
|
86
|
-
interrupted: false
|
|
87
|
-
};
|
|
88
|
-
stretches.set(key, stretch);
|
|
89
|
-
} else if (stretch.interrupted) {
|
|
90
|
-
const fresh = nextRevisionId++;
|
|
91
|
-
minted.push({
|
|
92
|
-
revisionId: fresh,
|
|
93
|
-
from: revisionId
|
|
94
|
-
});
|
|
95
|
-
stretch = {
|
|
96
|
-
id: fresh,
|
|
97
|
-
interrupted: false
|
|
98
|
-
};
|
|
99
|
-
stretches.set(key, stretch);
|
|
100
|
-
}
|
|
101
|
-
if (stretch.id !== revisionId) ids.set(revisionId, stretch.id);
|
|
102
|
-
}
|
|
103
|
-
if (ids.size > 0) retargets.push({
|
|
104
|
-
from: pos,
|
|
105
|
-
to: pos + node.nodeSize,
|
|
106
|
-
mark,
|
|
107
|
-
ids
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
return true;
|
|
111
|
-
});
|
|
112
|
-
for (const { from, to, mark, ids } of retargets) {
|
|
113
|
-
const attrs = expectTrackedChangeMarkAttrs(mark);
|
|
114
|
-
const ancestors = attrs._docxRevisionAncestors;
|
|
115
|
-
tr.removeMark(from, to, mark);
|
|
116
|
-
tr.addMark(from, to, mark.type.create({
|
|
117
|
-
...mark.attrs,
|
|
118
|
-
revisionId: ids.get(attrs.revisionId) ?? attrs.revisionId,
|
|
119
|
-
...ancestors && { _docxRevisionAncestors: ancestors.map((ancestor) => Object.assign(structuredClone(ancestor), { revisionId: ids.get(ancestor.revisionId) ?? ancestor.revisionId })) }
|
|
120
|
-
}));
|
|
121
|
-
}
|
|
122
|
-
for (const { representation, mark, ids } of formattingRetargets) {
|
|
123
|
-
const live = tr.doc.nodeAt(representation.position);
|
|
124
|
-
if (!live) panic("A formatting revision carrier vanished during normalization");
|
|
125
|
-
const changes = expectRunPropertyChangeMarkAttrs(mark).changes.map((change) => Object.assign({}, change, { info: Object.assign({}, change.info, { id: ids.get(change.info.id) ?? change.info.id }) }));
|
|
126
|
-
const replacement = mark.type.create({
|
|
127
|
-
...mark.attrs,
|
|
128
|
-
changes
|
|
129
|
-
});
|
|
130
|
-
applyMarksToRunFormattingRepresentation({
|
|
131
|
-
tr,
|
|
132
|
-
representation: {
|
|
133
|
-
node: live,
|
|
134
|
-
position: representation.position,
|
|
135
|
-
role: representation.role,
|
|
136
|
-
from: representation.position,
|
|
137
|
-
to: representation.position + representation.node.nodeSize
|
|
138
|
-
},
|
|
139
|
-
marks: replacement.addToSet(live.marks)
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
return {
|
|
143
|
-
nextRevisionId,
|
|
144
|
-
minted
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
export { separateRevisionStretches };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ApplyFolioDocumentOperationsOptions, FolioDocumentOperationResult } from "./document-operations.js";
|
|
2
|
-
import { NumberingIdsInUse } from "./docx/numberingIds.js";
|
|
3
|
-
export declare const applyFolioDocumentOperations: (input: ApplyFolioDocumentOperationsOptions) => FolioDocumentOperationResult;
|
|
4
|
-
/**
|
|
5
|
-
* Options of a caller that holds every story of the package: the numbering
|
|
6
|
-
* ids (`w:num`, `w:abstractNum`) the other stories define. A list the batch
|
|
7
|
-
* starts takes none of them, so its id names it in every story and survives a
|
|
8
|
-
* save.
|
|
9
|
-
*/
|
|
10
|
-
type ApplyFolioDocumentOperationsInPackageOptions = ApplyFolioDocumentOperationsOptions & {
|
|
11
|
-
numberingIdsElsewhere: NumberingIdsInUse;
|
|
12
|
-
};
|
|
13
|
-
/** {@link applyFolioDocumentOperations} for a caller holding every story. Internal. */
|
|
14
|
-
export declare const applyFolioDocumentOperationsInPackage: ({ view, snapshot, batch, story, author, createCommentId, createUndoHandle, revisionStamp, wordDiff, tableTemplates, replacementBackground, undefinedReferences, pendingSuggestionIds, numberingIdsElsewhere, restagesSuggestions }: ApplyFolioDocumentOperationsInPackageOptions) => FolioDocumentOperationResult;
|
|
15
|
-
export {};
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import { applyFolioAIEditOperationsInPackage, previewFolioAIEditOperationsWithResult } from "./ai-edits/apply.js";
|
|
2
|
-
import { describeModelError, findIntroducedModelErrors } from "./ai-edits/result-validation.js";
|
|
3
|
-
import { trackedBatchFidelityError } from "./ai-edits/tracked-batch-fidelity.js";
|
|
4
|
-
import { getFolioDocumentOperationIssues, getFolioDocumentOperationReceiptsForStory, parseFolioDocumentOperationBatch, withDistinctSuggestionIds } from "./document-operations.js";
|
|
5
|
-
import { NO_NUMBERING_IDS_IN_USE } from "./docx/numberingIds.js";
|
|
6
|
-
import { getSuggestions } from "./prosemirror/commands/comments.js";
|
|
7
|
-
import { completeNumberingForDoc } from "./prosemirror/listInstanceReferences.js";
|
|
8
|
-
import { getStatedDocumentNumbering } from "./prosemirror/plugins/documentNumbering.js";
|
|
9
|
-
// src/document-operations-apply.ts
|
|
10
|
-
const NO_COMMIT = () => {};
|
|
11
|
-
/** Skips reported in the order of the operations they belong to. */
|
|
12
|
-
const inOperationOrder = (operations, skipped) => {
|
|
13
|
-
const indexById = new Map(operations.map(({ id }, index) => [id, index]));
|
|
14
|
-
return [...skipped].sort((left, right) => (indexById.get(left.id) ?? -1) - (indexById.get(right.id) ?? -1));
|
|
15
|
-
};
|
|
16
|
-
const applyFolioDocumentOperations = (input) => applyFolioDocumentOperationsInPackage({
|
|
17
|
-
...input,
|
|
18
|
-
numberingIdsElsewhere: NO_NUMBERING_IDS_IN_USE
|
|
19
|
-
});
|
|
20
|
-
/** {@link applyFolioDocumentOperations} for a caller holding every story. Internal. */
|
|
21
|
-
const applyFolioDocumentOperationsInPackage = ({ view, snapshot, batch, story = "main", author, createCommentId, createUndoHandle, revisionStamp, wordDiff, tableTemplates, replacementBackground, undefinedReferences, pendingSuggestionIds, numberingIdsElsewhere, restagesSuggestions }) => {
|
|
22
|
-
const validatedBatch = parseFolioDocumentOperationBatch(batch);
|
|
23
|
-
const parsedBatch = restagesSuggestions === true ? validatedBatch : withDistinctSuggestionIds(validatedBatch, /* @__PURE__ */ new Set([...getSuggestions(view.state).map(({ suggestionId }) => suggestionId), ...pendingSuggestionIds ?? []]));
|
|
24
|
-
const isAtomic = parsedBatch.atomic === true;
|
|
25
|
-
const beforeDoc = view.state.doc;
|
|
26
|
-
const packageNumbering = getStatedDocumentNumbering(view.state);
|
|
27
|
-
const attempt = (operations, preview) => {
|
|
28
|
-
const common = {
|
|
29
|
-
snapshot,
|
|
30
|
-
operations,
|
|
31
|
-
mode: parsedBatch.mode ?? "tracked-changes",
|
|
32
|
-
...parsedBatch.existingRevisions === "refuse-cross-author" && { refuseCrossAuthorRevisions: true },
|
|
33
|
-
...author !== void 0 && { author },
|
|
34
|
-
...revisionStamp !== void 0 && { revisionStamp },
|
|
35
|
-
...wordDiff !== void 0 && { wordDiff },
|
|
36
|
-
...tableTemplates !== void 0 && { tableTemplates },
|
|
37
|
-
...replacementBackground !== void 0 && { replacementBackground },
|
|
38
|
-
numberingIdsElsewhere,
|
|
39
|
-
undefinedReferences
|
|
40
|
-
};
|
|
41
|
-
if (preview) return {
|
|
42
|
-
...previewFolioAIEditOperationsWithResult({
|
|
43
|
-
...common,
|
|
44
|
-
view,
|
|
45
|
-
...createCommentId !== void 0 && { createCommentId }
|
|
46
|
-
}, parsedBatch.dryRun && common.mode === "tracked-changes" ? "bounded" : "coarse"),
|
|
47
|
-
commit: NO_COMMIT
|
|
48
|
-
};
|
|
49
|
-
const held = {};
|
|
50
|
-
const commentIds = [];
|
|
51
|
-
return {
|
|
52
|
-
outcome: applyFolioAIEditOperationsInPackage({
|
|
53
|
-
...common,
|
|
54
|
-
view: {
|
|
55
|
-
state: view.state,
|
|
56
|
-
dispatch: (transaction) => {
|
|
57
|
-
held.transaction = transaction;
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
...createCommentId !== void 0 && { createCommentId: (text) => {
|
|
61
|
-
const id = createCommentId(text);
|
|
62
|
-
commentIds.push(id);
|
|
63
|
-
return id;
|
|
64
|
-
} }
|
|
65
|
-
}),
|
|
66
|
-
doc: held.transaction?.doc ?? null,
|
|
67
|
-
commentIds,
|
|
68
|
-
commit: () => {
|
|
69
|
-
if (held.transaction !== void 0) view.dispatch(held.transaction);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
const introducedErrors = (run) => {
|
|
74
|
-
if (run.doc === null || run.outcome.applied.length === 0) return [];
|
|
75
|
-
const numbering = packageNumbering === void 0 ? void 0 : completeNumberingForDoc(packageNumbering ?? void 0, run.doc) ?? null;
|
|
76
|
-
return findIntroducedModelErrors(beforeDoc, run.doc, {
|
|
77
|
-
numbering,
|
|
78
|
-
createdCommentIds: run.commentIds,
|
|
79
|
-
...author !== void 0 && { commentAuthor: author }
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* An attempt on the refusal path, where the applier runs on subsets of the
|
|
84
|
-
* batch it was not asked to apply: a throw there is one more reason to
|
|
85
|
-
* refuse, never a reason to fail a batch the first run could apply.
|
|
86
|
-
*/
|
|
87
|
-
const checkedAttempt = (operations, preview) => {
|
|
88
|
-
try {
|
|
89
|
-
const run = attempt(operations, preview);
|
|
90
|
-
return {
|
|
91
|
-
run,
|
|
92
|
-
error: introducedErrors(run)[0]
|
|
93
|
-
};
|
|
94
|
-
} catch (error) {
|
|
95
|
-
return {
|
|
96
|
-
run: null,
|
|
97
|
-
error: {
|
|
98
|
-
path: "package.document",
|
|
99
|
-
message: `the operation could not be applied (${error instanceof Error ? error.message : String(error)}).`,
|
|
100
|
-
severity: "error"
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Which applied operations produced the unsaveable result: each one is
|
|
107
|
-
* previewed alone against the unchanged story. When none fails alone, the
|
|
108
|
-
* failure is their combination, and every one of them is refused.
|
|
109
|
-
*/
|
|
110
|
-
const refuseInvalidResult = (run, firstError) => {
|
|
111
|
-
const operationsById = new Map(parsedBatch.operations.map((operation) => [operation.id, operation]));
|
|
112
|
-
const refused = [];
|
|
113
|
-
for (const { id } of run.outcome.applied) {
|
|
114
|
-
const operation = operationsById.get(id);
|
|
115
|
-
if (operation === void 0) continue;
|
|
116
|
-
const alone = checkedAttempt([operation], true).error;
|
|
117
|
-
if (alone !== void 0) refused.push({
|
|
118
|
-
id,
|
|
119
|
-
reason: "invalidResult",
|
|
120
|
-
message: describeModelError(alone)
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
if (refused.length > 0) return refused;
|
|
124
|
-
return run.outcome.applied.map(({ id }) => ({
|
|
125
|
-
id,
|
|
126
|
-
reason: "invalidResult",
|
|
127
|
-
message: describeModelError(firstError)
|
|
128
|
-
}));
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* A fidelity failure invalidates the batch. Preserve the refusal details
|
|
132
|
-
* for operations already skipped by the applier or save-time validator.
|
|
133
|
-
*/
|
|
134
|
-
const refuseFidelityLoss = (run, skipped = []) => {
|
|
135
|
-
if (run.doc === null || parsedBatch.mode === "direct" || parsedBatch.mode === "suggested") return null;
|
|
136
|
-
const message = trackedBatchFidelityError({
|
|
137
|
-
before: view.state,
|
|
138
|
-
after: run.doc,
|
|
139
|
-
createdCommentIds: run.commentIds,
|
|
140
|
-
retiredCommentIds: run.outcome.applied.flatMap(({ retiredCommentIds }) => retiredCommentIds ?? [])
|
|
141
|
-
});
|
|
142
|
-
if (message === null) return null;
|
|
143
|
-
return {
|
|
144
|
-
fidelityRefused: true,
|
|
145
|
-
outcome: {
|
|
146
|
-
...run.outcome,
|
|
147
|
-
applied: [],
|
|
148
|
-
skipped: inOperationOrder(parsedBatch.operations, [
|
|
149
|
-
...run.outcome.skipped,
|
|
150
|
-
...skipped,
|
|
151
|
-
...run.outcome.applied.map(({ id }) => ({
|
|
152
|
-
id,
|
|
153
|
-
reason: "invalidResult",
|
|
154
|
-
message
|
|
155
|
-
}))
|
|
156
|
-
])
|
|
157
|
-
},
|
|
158
|
-
commit: NO_COMMIT
|
|
159
|
-
};
|
|
160
|
-
};
|
|
161
|
-
/** Check the held result before dispatching any operation to the caller. */
|
|
162
|
-
const guardedAttempt = (preview) => {
|
|
163
|
-
const first = attempt(parsedBatch.operations, preview);
|
|
164
|
-
const [firstError] = introducedErrors(first);
|
|
165
|
-
if (firstError === void 0) {
|
|
166
|
-
const fidelity = preview && !parsedBatch.dryRun ? null : refuseFidelityLoss(first);
|
|
167
|
-
if (fidelity !== null) return fidelity;
|
|
168
|
-
return {
|
|
169
|
-
outcome: {
|
|
170
|
-
...first.outcome,
|
|
171
|
-
skipped: inOperationOrder(parsedBatch.operations, first.outcome.skipped)
|
|
172
|
-
},
|
|
173
|
-
commit: first.commit
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
const refused = refuseInvalidResult(first, firstError);
|
|
177
|
-
const refusedIds = new Set(refused.map(({ id }) => id));
|
|
178
|
-
if (isAtomic) return {
|
|
179
|
-
outcome: {
|
|
180
|
-
...first.outcome,
|
|
181
|
-
applied: [],
|
|
182
|
-
skipped: inOperationOrder(parsedBatch.operations, [...first.outcome.skipped, ...refused])
|
|
183
|
-
},
|
|
184
|
-
commit: NO_COMMIT
|
|
185
|
-
};
|
|
186
|
-
const second = checkedAttempt(parsedBatch.operations.filter(({ id }) => !refusedIds.has(id)), preview);
|
|
187
|
-
if (second.run === null || second.error !== void 0) {
|
|
188
|
-
const reported = second.run?.outcome ?? first.outcome;
|
|
189
|
-
return {
|
|
190
|
-
outcome: {
|
|
191
|
-
...reported,
|
|
192
|
-
applied: [],
|
|
193
|
-
skipped: inOperationOrder(parsedBatch.operations, [
|
|
194
|
-
...reported.skipped.filter(({ id }) => !refusedIds.has(id)),
|
|
195
|
-
...refused,
|
|
196
|
-
...reported.applied.filter(({ id }) => !refusedIds.has(id)).map(({ id }) => ({
|
|
197
|
-
id,
|
|
198
|
-
reason: "invalidResult",
|
|
199
|
-
message: describeModelError(second.error ?? firstError)
|
|
200
|
-
}))
|
|
201
|
-
])
|
|
202
|
-
},
|
|
203
|
-
commit: NO_COMMIT
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
const fidelity = refuseFidelityLoss(second.run, refused);
|
|
207
|
-
if (fidelity !== null) return fidelity;
|
|
208
|
-
return {
|
|
209
|
-
outcome: {
|
|
210
|
-
...second.run.outcome,
|
|
211
|
-
skipped: inOperationOrder(parsedBatch.operations, [...second.run.outcome.skipped, ...refused])
|
|
212
|
-
},
|
|
213
|
-
commit: second.run.commit
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
|
-
const preview = () => guardedAttempt(true).outcome;
|
|
217
|
-
const atomicResult = (previewResult, status) => {
|
|
218
|
-
const skippedById = new Map(previewResult.skipped.map((operation) => [operation.id, operation]));
|
|
219
|
-
const skipped = parsedBatch.operations.map(({ id }) => skippedById.get(id) ?? {
|
|
220
|
-
id,
|
|
221
|
-
reason: "atomicBatchRejected"
|
|
222
|
-
});
|
|
223
|
-
return {
|
|
224
|
-
version: 1,
|
|
225
|
-
status,
|
|
226
|
-
applied: [],
|
|
227
|
-
skipped,
|
|
228
|
-
issues: getFolioDocumentOperationIssues(parsedBatch.operations, skipped),
|
|
229
|
-
receipts: [],
|
|
230
|
-
...previewResult.normalizations !== void 0 && { normalizations: previewResult.normalizations },
|
|
231
|
-
undoHandle: null,
|
|
232
|
-
nextRevisionId: previewResult.nextRevisionId
|
|
233
|
-
};
|
|
234
|
-
};
|
|
235
|
-
if (parsedBatch.dryRun === true) {
|
|
236
|
-
const previewResult = preview();
|
|
237
|
-
if (isAtomic && previewResult.skipped.length > 0) return atomicResult(previewResult, "previewed");
|
|
238
|
-
return {
|
|
239
|
-
version: 1,
|
|
240
|
-
status: "previewed",
|
|
241
|
-
applied: previewResult.applied.map(({ id, paragraphIdentity, retiredCommentIds }) => ({
|
|
242
|
-
id,
|
|
243
|
-
...paragraphIdentity === void 0 ? {} : { paragraphIdentity },
|
|
244
|
-
...retiredCommentIds === void 0 ? {} : { retiredCommentIds }
|
|
245
|
-
})),
|
|
246
|
-
skipped: previewResult.skipped,
|
|
247
|
-
issues: getFolioDocumentOperationIssues(parsedBatch.operations, previewResult.skipped),
|
|
248
|
-
receipts: getFolioDocumentOperationReceiptsForStory({
|
|
249
|
-
operations: parsedBatch.operations,
|
|
250
|
-
applied: previewResult.applied,
|
|
251
|
-
story
|
|
252
|
-
}),
|
|
253
|
-
...previewResult.normalizations !== void 0 && { normalizations: previewResult.normalizations },
|
|
254
|
-
undoHandle: null,
|
|
255
|
-
nextRevisionId: previewResult.nextRevisionId
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
if (isAtomic) {
|
|
259
|
-
const previewResult = preview();
|
|
260
|
-
if (previewResult.skipped.length > 0) return atomicResult(previewResult, "rejected");
|
|
261
|
-
}
|
|
262
|
-
const guarded = guardedAttempt(false);
|
|
263
|
-
const { heldRevisionConflict, ...result } = guarded.outcome;
|
|
264
|
-
if (heldRevisionConflict) return atomicResult(result, "rejected");
|
|
265
|
-
if (guarded.fidelityRefused === true || isAtomic && result.skipped.some(({ reason }) => reason === "invalidResult")) return atomicResult(result, "rejected");
|
|
266
|
-
guarded.commit();
|
|
267
|
-
return {
|
|
268
|
-
version: 1,
|
|
269
|
-
status: "committed",
|
|
270
|
-
...result,
|
|
271
|
-
issues: getFolioDocumentOperationIssues(parsedBatch.operations, result.skipped),
|
|
272
|
-
receipts: getFolioDocumentOperationReceiptsForStory({
|
|
273
|
-
operations: parsedBatch.operations,
|
|
274
|
-
applied: result.applied,
|
|
275
|
-
story
|
|
276
|
-
}),
|
|
277
|
-
undoHandle: result.applied.length > 0 && createUndoHandle !== void 0 ? createUndoHandle() : null
|
|
278
|
-
};
|
|
279
|
-
};
|
|
280
|
-
export { applyFolioDocumentOperations, applyFolioDocumentOperationsInPackage };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* History Extension — undo/redo via prosemirror-history
|
|
3
|
-
*/
|
|
4
|
-
import { Extension } from "../types.js";
|
|
5
|
-
import { HistoryShortcutOwner } from "./historyCommands.js";
|
|
6
|
-
type HistoryOptions = {
|
|
7
|
-
depth: number;
|
|
8
|
-
newGroupDelay: number;
|
|
9
|
-
shortcuts: HistoryShortcutOwner;
|
|
10
|
-
};
|
|
11
|
-
export declare const HistoryExtension: (options?: Partial<HistoryOptions> | undefined) => Extension;
|
|
12
|
-
export {};
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { createExtension } from "../create.js";
|
|
2
|
-
import { historyKeyboardShortcuts, redoCommand, undoCommand } from "./historyCommands.js";
|
|
3
|
-
import { Plugin } from "prosemirror-state";
|
|
4
|
-
import { closeHistory, history, isHistoryTransaction } from "prosemirror-history";
|
|
5
|
-
// src/prosemirror/extensions/core/HistoryExtension.ts
|
|
6
|
-
/**
|
|
7
|
-
* History Extension — undo/redo via prosemirror-history
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* History adjacency is based on step maps, which differ for physical deletions
|
|
11
|
-
* and suggestion marks. Group continuous typing and same-direction deletions explicitly; each
|
|
12
|
-
* structural edit, paste, drop, or composition starts its own undo event.
|
|
13
|
-
* Capture DOM input before the shared input router or a keymap handles it.
|
|
14
|
-
*/
|
|
15
|
-
const inputBoundaryPlugin = (newGroupDelay) => {
|
|
16
|
-
let previousKind;
|
|
17
|
-
let deletionGroup = 0;
|
|
18
|
-
let previousInputTime = 0;
|
|
19
|
-
let pendingDeletionGroup = null;
|
|
20
|
-
return new Plugin({
|
|
21
|
-
filterTransaction(tr) {
|
|
22
|
-
const pendingGroup = pendingDeletionGroup;
|
|
23
|
-
pendingDeletionGroup = null;
|
|
24
|
-
if (isHistoryTransaction(tr) || !tr.docChanged && tr.selectionSet) {
|
|
25
|
-
previousKind = void 0;
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
if (tr.docChanged && (previousKind === "deleteBackward" || previousKind === "deleteForward" || previousKind === "deletion")) {
|
|
29
|
-
if (pendingGroup !== null) tr.setMeta("composition", pendingGroup);
|
|
30
|
-
else if (!tr.getMeta("appendedTransaction")) previousKind = void 0;
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
},
|
|
34
|
-
view(view) {
|
|
35
|
-
const startInput = (kind) => {
|
|
36
|
-
const now = Date.now();
|
|
37
|
-
if (kind !== previousKind || kind === "structure" || kind === "paste" || kind === "drop" || now - previousInputTime > newGroupDelay) {
|
|
38
|
-
deletionGroup--;
|
|
39
|
-
view.dispatch(closeHistory(view.state.tr));
|
|
40
|
-
}
|
|
41
|
-
previousInputTime = now;
|
|
42
|
-
previousKind = kind;
|
|
43
|
-
pendingDeletionGroup = kind === "deleteBackward" || kind === "deleteForward" || kind === "deletion" ? deletionGroup : null;
|
|
44
|
-
};
|
|
45
|
-
const keydown = (event) => {
|
|
46
|
-
if (event.isComposing) return;
|
|
47
|
-
if (event.key === "Backspace" || event.key === "Delete") {
|
|
48
|
-
startInput(event.key === "Backspace" ? "deleteBackward" : "deleteForward");
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (event.key === "Enter") {
|
|
52
|
-
startInput("structure");
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (event.key.length === 1 && !event.metaKey && !event.ctrlKey) startInput("typing");
|
|
56
|
-
};
|
|
57
|
-
const beforeinput = (event) => {
|
|
58
|
-
if (event.inputType === "insertCompositionText" || event.isComposing) {
|
|
59
|
-
startInput("composition");
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (event.inputType === "insertText" || event.inputType === "insertReplacementText") {
|
|
63
|
-
startInput("typing");
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (event.inputType.startsWith("delete")) {
|
|
67
|
-
if (event.inputType.endsWith("Backward")) startInput("deleteBackward");
|
|
68
|
-
else if (event.inputType.endsWith("Forward")) startInput("deleteForward");
|
|
69
|
-
else startInput("deletion");
|
|
70
|
-
} else if (event.inputType === "insertParagraph" || event.inputType === "insertLineBreak") startInput("structure");
|
|
71
|
-
};
|
|
72
|
-
const paste = () => startInput("paste");
|
|
73
|
-
const drop = () => startInput("drop");
|
|
74
|
-
const compositionstart = () => {
|
|
75
|
-
view.dispatch(closeHistory(view.state.tr));
|
|
76
|
-
previousKind = "composition";
|
|
77
|
-
};
|
|
78
|
-
view.dom.addEventListener("keydown", keydown, true);
|
|
79
|
-
view.dom.addEventListener("beforeinput", beforeinput, true);
|
|
80
|
-
view.dom.addEventListener("paste", paste, true);
|
|
81
|
-
view.dom.addEventListener("drop", drop, true);
|
|
82
|
-
view.dom.addEventListener("compositionstart", compositionstart, true);
|
|
83
|
-
return { destroy() {
|
|
84
|
-
view.dom.removeEventListener("keydown", keydown, true);
|
|
85
|
-
view.dom.removeEventListener("beforeinput", beforeinput, true);
|
|
86
|
-
view.dom.removeEventListener("paste", paste, true);
|
|
87
|
-
view.dom.removeEventListener("drop", drop, true);
|
|
88
|
-
view.dom.removeEventListener("compositionstart", compositionstart, true);
|
|
89
|
-
} };
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
const HistoryExtension = createExtension({
|
|
94
|
-
name: "history",
|
|
95
|
-
defaultOptions: {
|
|
96
|
-
depth: 100,
|
|
97
|
-
newGroupDelay: 500,
|
|
98
|
-
shortcuts: "editor"
|
|
99
|
-
},
|
|
100
|
-
onSchemaReady(_ctx, options) {
|
|
101
|
-
return {
|
|
102
|
-
plugins: [history({
|
|
103
|
-
depth: options.depth,
|
|
104
|
-
newGroupDelay: options.newGroupDelay
|
|
105
|
-
}), inputBoundaryPlugin(options.newGroupDelay)],
|
|
106
|
-
commands: {
|
|
107
|
-
undo: undoCommand,
|
|
108
|
-
redo: redoCommand
|
|
109
|
-
},
|
|
110
|
-
...options.shortcuts === "editor" && { keyboardShortcuts: historyKeyboardShortcuts }
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
export { HistoryExtension };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ParagraphPropertySourceSeed } from "../../paraIds.js";
|
|
2
|
-
import { Extension } from "../types.js";
|
|
3
|
-
import { Transaction } from "prosemirror-state";
|
|
4
|
-
import { Node } from "prosemirror-model";
|
|
5
|
-
type ParagraphPropertySourceKeeper = {
|
|
6
|
-
status: "ambiguous";
|
|
7
|
-
} | {
|
|
8
|
-
pos: number;
|
|
9
|
-
status: "deleted" | "mapped";
|
|
10
|
-
};
|
|
11
|
-
type MappedParagraphKeepers = {
|
|
12
|
-
paraIds: Map<string, number>;
|
|
13
|
-
sourceTokens: Map<string, ParagraphPropertySourceKeeper>;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Where each id's and each seeded source token's owner went: the first
|
|
17
|
-
* occurrence that survives the batch keeps an id.
|
|
18
|
-
*
|
|
19
|
-
* @internal Exported for the per-step equivalence test.
|
|
20
|
-
*/
|
|
21
|
-
export declare const mapParagraphKeepers: (oldDoc: Node, transactions: readonly Transaction[], sourceSeed: ParagraphPropertySourceSeed) => MappedParagraphKeepers;
|
|
22
|
-
export declare const ParaIdAllocatorExtension: (options?: Partial<Record<never, never>> | undefined) => Extension;
|
|
23
|
-
export {};
|