@stll/folio-core 0.72.0 → 0.74.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 +12 -6
- package/dist/ai-edits/applyTypes.d.ts +85 -0
- package/dist/ai-edits/applyTypes.js +24 -0
- package/dist/ai-edits/clean-text.d.ts +7 -1
- package/dist/ai-edits/clean-text.js +23 -2
- package/dist/ai-edits/finalSectionReview.d.ts +1 -1
- package/dist/ai-edits/headless.d.ts +29 -147
- package/dist/ai-edits/headless.js +215 -1639
- package/dist/ai-edits/index.d.ts +3 -3
- package/dist/ai-edits/index.js +2 -3
- package/dist/ai-edits/pending-suggestions.d.ts +14 -4
- package/dist/ai-edits/pending-suggestions.js +183 -90
- package/dist/ai-edits/pendingJoin.js +6 -1
- package/dist/ai-edits/retired-comment-receipts.d.ts +1 -1
- package/dist/ai-edits/snapshot.js +9 -4
- package/dist/ai-edits/table-cell-mutations.d.ts +1 -1
- package/dist/ai-edits/table-cell-mutations.js +2 -2
- package/dist/ai-edits/table-geometry.d.ts +1 -1
- package/dist/ai-edits/table-geometry.js +1 -1
- package/dist/ai-edits/table-row-column-mutations.d.ts +1 -1
- package/dist/ai-edits/table-row-column-mutations.js +1 -1
- package/dist/ai-edits/tableNodes.d.ts +38 -0
- package/dist/ai-edits/tableNodes.js +86 -0
- package/dist/ai-edits/tracked-batch-fidelity.d.ts +1 -1
- package/dist/ai-edits/tracked-batch-fidelity.js +1 -1
- package/dist/ai-edits/undefinedReferences.d.ts +7 -0
- package/dist/canonical/batchCommentReferences.js +1 -0
- 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 +5 -27
- package/dist/canonical/canonicalProjectionBlocks.d.ts +4 -4
- package/dist/canonical/canonicalPublicOperations.js +282 -75
- package/dist/canonical/canonicalSelection.js +1 -1
- package/dist/canonical/canonicalSession.d.ts +9 -1
- package/dist/canonical/canonicalSession.js +106 -33
- package/dist/compare/compare.d.ts +1 -1
- package/dist/compare/inline-atoms-model.d.ts +1 -1
- package/dist/compare/inline-atoms.d.ts +2 -2
- package/dist/compare/inline-provenance-model.d.ts +1 -1
- package/dist/compare/inline-provenance.d.ts +2 -2
- package/dist/compat/eigenpal.d.ts +3 -3
- package/dist/compat/eigenpal.js +2 -3
- package/dist/controller/autocompleteSuggestion.js +1 -1
- package/dist/controller/canonicalClipboard.d.ts +13 -3
- package/dist/controller/canonicalClipboard.js +186 -50
- package/dist/controller/canonicalClipboardResources.d.ts +9 -1
- package/dist/controller/canonicalClipboardResources.js +22 -2
- package/dist/controller/canonicalComposition.js +1 -1
- package/dist/controller/canonicalInput.js +1 -1
- package/dist/controller/canonicalPresence.js +1 -1
- package/dist/controller/canonicalReview.d.ts +1 -1
- package/dist/controller/canonicalReview.js +1 -1
- package/dist/controller/canonicalRoomAuthority.js +1 -1
- package/dist/controller/canonicalRoomWire.js +1 -1
- package/dist/controller/canonicalStructure.js +1 -1
- package/dist/controller/canonicalTabRoom.js +1 -1
- package/dist/controller/canonicalWatermark.d.ts +10 -0
- package/dist/controller/canonicalWatermark.js +37 -0
- package/dist/controller/canonicalYjsRoom.js +1 -1
- package/dist/controller/hiddenEditorApi.d.ts +1 -1
- package/dist/controller/hiddenEditorApi.js +2 -17
- package/dist/controller/hiddenEditorManager.d.ts +4 -3
- package/dist/controller/hiddenEditorManager.js +79 -23
- package/dist/document-operations.d.ts +1 -14
- package/dist/document-operations.js +1 -278
- package/dist/docx/canonicalSave.d.ts +1 -1
- package/dist/docx/canonicalSave.js +1 -1
- 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/paragraphParser.js +2 -2
- package/dist/docx/paragraphPropertySource.d.ts +1 -1
- package/dist/docx/parser.js +1 -1
- package/dist/docx/reviewResolutionProvenance.d.ts +3 -2
- package/dist/docx/reviewResolutionProvenance.js +31 -8
- package/dist/docx/revisionIdNormalization.js +30 -7
- package/dist/docx/rezip.d.ts +1 -1
- package/dist/docx/rezip.js +1 -1
- package/dist/docx/serializer/tableSerializer.js +4 -36
- package/dist/docx/server/templatePlan/apply.d.ts +15 -0
- package/dist/docx/server/templatePlan/apply.js +658 -0
- package/dist/docx/server/templatePlan/blocks.d.ts +97 -0
- package/dist/docx/server/templatePlan/blocks.js +355 -0
- package/dist/docx/server/templatePlan/builders.d.ts +72 -0
- package/dist/docx/server/templatePlan/builders.js +237 -0
- package/dist/docx/server/templatePlan/emit.d.ts +118 -0
- package/dist/docx/server/templatePlan/emit.js +466 -0
- package/dist/docx/server/templatePlan/emphasis.d.ts +62 -0
- package/dist/docx/server/templatePlan/emphasis.js +173 -0
- package/dist/docx/server/templatePlan/inspect.d.ts +22 -0
- package/dist/docx/server/templatePlan/inspect.js +230 -0
- package/dist/docx/server/templatePlan/labels.d.ts +45 -0
- package/dist/docx/server/templatePlan/labels.js +155 -0
- package/dist/docx/server/templatePlan/package.d.ts +34 -0
- package/dist/docx/server/templatePlan/package.js +99 -0
- package/dist/docx/server/templatePlan/plan.d.ts +145 -0
- package/dist/docx/server/templatePlan/plan.js +875 -0
- package/dist/docx/server/templatePlan/planShape.d.ts +9 -0
- package/dist/docx/server/templatePlan/planShape.js +180 -0
- package/dist/docx/server/templatePlan/resources.d.ts +41 -0
- package/dist/docx/server/templatePlan/resources.js +136 -0
- package/dist/docx/server/templatePlan/story.d.ts +128 -0
- package/dist/docx/server/templatePlan/story.js +440 -0
- package/dist/docx/server/templatePlan/types.d.ts +442 -0
- package/dist/docx/server/templatePlan/types.js +29 -0
- package/dist/docx/server/templatePlan/verify.d.ts +40 -0
- package/dist/docx/server/templatePlan/verify.js +976 -0
- package/dist/docx/server/templatePlan/xml.d.ts +74 -0
- package/dist/docx/server/templatePlan/xml.js +125 -0
- package/dist/docx/settingsHeaderFooterUpdate.d.ts +9 -0
- package/dist/docx/settingsHeaderFooterUpdate.js +45 -10
- package/dist/docx/structuralXmlPatch.js +9 -1
- package/dist/docx/tableGridXml.d.ts +30 -0
- package/dist/docx/tableGridXml.js +54 -0
- package/dist/docx/tableParser.js +7 -0
- 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.d.ts +3 -2
- package/dist/i18n/messages.js +4 -16
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -3
- 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/starterKitExtensions.d.ts +20 -0
- package/dist/internal/starterKitExtensions.js +123 -0
- package/dist/internal/wholeStoryRevisionResolution.js +1 -1
- package/dist/managers/ContextMenuManager.js +2 -1
- package/dist/managers/editorShortcuts.d.ts +1 -1
- package/dist/prosemirror/anchoredTextBoxes.d.ts +1 -1
- package/dist/prosemirror/attrs/index.js +1 -1
- package/dist/prosemirror/canonicalCommands.d.ts +1 -1
- package/dist/prosemirror/canonicalSelectionRange.d.ts +1 -1
- package/dist/prosemirror/canonicalSelectionRange.js +1 -1
- package/dist/prosemirror/canonicalTableCommands.js +3 -3
- package/dist/prosemirror/commands/comments.js +4 -4
- package/dist/prosemirror/commands/contentControls.d.ts +1 -1
- package/dist/prosemirror/commands/contentControls.js +1 -1
- package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
- package/dist/prosemirror/commands/pastePlainText.js +2 -3
- package/dist/prosemirror/commands/replaceRangeText.js +1 -1
- package/dist/prosemirror/commands/sectionBreak.js +1 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +1 -1
- package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +1 -1
- package/dist/prosemirror/commentRecords.d.ts +1 -1
- package/dist/prosemirror/commentRecords.js +2 -2
- package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
- 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/documentStructureCounts.d.ts +24 -0
- package/dist/prosemirror/documentStructureCounts.js +76 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
- 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 +1 -1
- package/dist/prosemirror/extensions/core/historyCommands.d.ts +16 -0
- package/dist/prosemirror/extensions/core/historyCommands.js +19 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +7 -2
- package/dist/prosemirror/extensions/features/pastedCellSections.d.ts +1 -1
- package/dist/prosemirror/extensions/index.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +8 -3
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +8 -41
- package/dist/prosemirror/extensions/types.d.ts +1 -1
- package/dist/prosemirror/findReplaceSelection.d.ts +1 -1
- package/dist/prosemirror/hyperlinkRemoval.d.ts +1 -1
- package/dist/prosemirror/hyperlinkRemoval.js +7 -2
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/index.js +3 -3
- package/dist/prosemirror/insertionGaps.d.ts +1 -1
- package/dist/prosemirror/keptRangeBoundaries.d.ts +1 -1
- package/dist/prosemirror/keptRangeBoundaries.js +1 -1
- package/dist/prosemirror/listNumbering.d.ts +1 -1
- package/dist/prosemirror/listNumbering.js +1 -1
- package/dist/prosemirror/lockedControls.d.ts +1 -1
- package/dist/prosemirror/markupViewProjection.d.ts +1 -1
- package/dist/prosemirror/noteReferenceOccurrences.d.ts +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/{extensions/features/ParaIdAllocatorExtension.d.ts → paraIds.d.ts} +13 -23
- package/dist/prosemirror/paraIds.js +152 -0
- package/dist/prosemirror/paragraphChangeTrackerMeta.d.ts +97 -0
- package/dist/prosemirror/paragraphChangeTrackerMeta.js +87 -0
- package/dist/prosemirror/paragraphMarkJoin.d.ts +1 -1
- package/dist/prosemirror/paragraphPropertyCarry.d.ts +1 -1
- package/dist/prosemirror/pastedCommentCopies.d.ts +1 -1
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
- package/dist/prosemirror/plugins/documentNumbering.d.ts +1 -1
- package/dist/prosemirror/plugins/documentNumbering.js +1 -1
- package/dist/prosemirror/plugins/documentStyles.js +1 -1
- package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -1
- package/dist/prosemirror/rebaseParagraphRuns.d.ts +1 -1
- package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.js +17 -2
- package/dist/prosemirror/revisionCarriers.d.ts +1 -1
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
- package/dist/prosemirror/sectionMarkEdits.d.ts +1 -1
- package/dist/prosemirror/selectionBounds.d.ts +10 -0
- package/dist/prosemirror/selectionBounds.js +22 -0
- package/dist/prosemirror/storyListNumbering.d.ts +1 -1
- package/dist/prosemirror/suggestionCommands.d.ts +47 -0
- package/dist/prosemirror/suggestionCommands.js +31 -0
- package/dist/prosemirror/tableCellPaste.d.ts +1 -1
- package/dist/prosemirror/tableCellPaste.js +1 -1
- package/dist/prosemirror/tableGridMutation.d.ts +1 -1
- package/dist/prosemirror/tableRunIn.js +1 -1
- package/dist/prosemirror/textInput.d.ts +1 -1
- package/dist/prosemirror/textInput.js +1 -1
- package/dist/server.d.ts +7 -2
- package/dist/server.js +6 -1
- package/dist/types/canonicalCapabilities.d.ts +13 -92
- package/dist/types/canonicalCapabilities.js +11 -85
- package/package.json +4 -4
- package/dist/ai-edits/apply.d.ts +0 -202
- package/dist/ai-edits/apply.js +0 -6759
- 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/prosemirror/extensions/core/HistoryExtension.d.ts +0 -18
- package/dist/prosemirror/extensions/core/HistoryExtension.js +0 -122
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +0 -408
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +0 -135
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +0 -566
- 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,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* History Extension — undo/redo via prosemirror-history
|
|
3
|
-
*/
|
|
4
|
-
import { Extension } from "../types.js";
|
|
5
|
-
/**
|
|
6
|
-
* Who answers the undo and redo keys (Mod-z, Mod-y, Mod-Shift-z).
|
|
7
|
-
* - `"editor"`: the extension binds them. Default.
|
|
8
|
-
* - `"host"`: nothing binds them. The host keeps its own undo stack and runs
|
|
9
|
-
* the `undo` / `redo` commands itself, so one press never undoes twice.
|
|
10
|
-
*/
|
|
11
|
-
export type HistoryShortcutOwner = "editor" | "host";
|
|
12
|
-
type HistoryOptions = {
|
|
13
|
-
depth: number;
|
|
14
|
-
newGroupDelay: number;
|
|
15
|
-
shortcuts: HistoryShortcutOwner;
|
|
16
|
-
};
|
|
17
|
-
export declare const HistoryExtension: (options?: Partial<HistoryOptions> | undefined) => Extension;
|
|
18
|
-
export {};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { withCanonicalHistory } from "../../canonicalCommands.js";
|
|
2
|
-
import { createExtension } from "../create.js";
|
|
3
|
-
import { Plugin } from "prosemirror-state";
|
|
4
|
-
import { closeHistory, history, isHistoryTransaction, redo, undo } 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 consumeHistoryShortcut = (command) => (state, dispatch, view) => {
|
|
94
|
-
command(state, dispatch, view);
|
|
95
|
-
return true;
|
|
96
|
-
};
|
|
97
|
-
const HistoryExtension = createExtension({
|
|
98
|
-
name: "history",
|
|
99
|
-
defaultOptions: {
|
|
100
|
-
depth: 100,
|
|
101
|
-
newGroupDelay: 500,
|
|
102
|
-
shortcuts: "editor"
|
|
103
|
-
},
|
|
104
|
-
onSchemaReady(_ctx, options) {
|
|
105
|
-
return {
|
|
106
|
-
plugins: [history({
|
|
107
|
-
depth: options.depth,
|
|
108
|
-
newGroupDelay: options.newGroupDelay
|
|
109
|
-
}), inputBoundaryPlugin(options.newGroupDelay)],
|
|
110
|
-
commands: {
|
|
111
|
-
undo: () => withCanonicalHistory(undo, "undo"),
|
|
112
|
-
redo: () => withCanonicalHistory(redo, "redo")
|
|
113
|
-
},
|
|
114
|
-
...options.shortcuts === "editor" && { keyboardShortcuts: {
|
|
115
|
-
"Mod-z": consumeHistoryShortcut(undo),
|
|
116
|
-
"Mod-y": consumeHistoryShortcut(redo),
|
|
117
|
-
"Mod-Shift-z": consumeHistoryShortcut(redo)
|
|
118
|
-
} }
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
export { HistoryExtension };
|