@manuscripts/track-changes-plugin 1.7.2 → 1.7.3-LEAN-2832-v3
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/cjs/ChangeSet.js +155 -0
- package/dist/cjs/actions.js +23 -0
- package/dist/cjs/change-steps/diffChangeSteps.js +63 -0
- package/dist/cjs/change-steps/matchInserted.js +70 -0
- package/dist/cjs/change-steps/processChangeSteps.js +141 -0
- package/dist/cjs/changes/applyChanges.js +81 -0
- package/dist/cjs/changes/findChanges.js +72 -0
- package/dist/cjs/changes/fixInconsistentChanges.js +21 -0
- package/dist/cjs/changes/updateChangeAttrs.js +65 -0
- package/dist/cjs/commands.js +47 -0
- package/dist/cjs/compute/nodeHelpers.js +77 -0
- package/dist/cjs/compute/setFragmentAsInserted.js +53 -0
- package/dist/cjs/compute/splitSliceIntoMergedParts.js +57 -0
- package/dist/cjs/index.js +41 -0
- package/dist/cjs/mutate/deleteAndMergeSplitNodes.js +105 -0
- package/dist/cjs/mutate/deleteNode.js +51 -0
- package/dist/cjs/mutate/deleteText.js +29 -0
- package/dist/cjs/mutate/mergeNode.js +21 -0
- package/dist/cjs/mutate/mergeTrackedMarks.js +25 -0
- package/dist/cjs/plugin.js +118 -0
- package/dist/cjs/steps/trackReplaceAroundStep.js +72 -0
- package/dist/cjs/steps/trackReplaceStep.js +79 -0
- package/dist/cjs/steps/trackTransaction.js +88 -0
- package/dist/cjs/types/change.js +15 -0
- package/dist/cjs/types/pm.js +2 -0
- package/dist/cjs/types/step.js +2 -0
- package/dist/cjs/types/track.js +9 -0
- package/dist/cjs/utils/logger.js +43 -0
- package/dist/cjs/utils/track-utils.js +28 -0
- package/dist/cjs/utils/uuidv4.js +10 -0
- package/dist/es/ChangeSet.js +151 -0
- package/dist/es/actions.js +17 -0
- package/dist/es/change-steps/diffChangeSteps.js +59 -0
- package/dist/es/change-steps/matchInserted.js +66 -0
- package/dist/es/change-steps/processChangeSteps.js +114 -0
- package/dist/es/changes/applyChanges.js +77 -0
- package/dist/es/changes/findChanges.js +68 -0
- package/dist/es/changes/fixInconsistentChanges.js +17 -0
- package/dist/es/changes/updateChangeAttrs.js +60 -0
- package/dist/es/commands.js +39 -0
- package/dist/es/compute/nodeHelpers.js +67 -0
- package/dist/es/compute/setFragmentAsInserted.js +49 -0
- package/dist/es/compute/splitSliceIntoMergedParts.js +53 -0
- package/dist/es/index.js +7 -0
- package/dist/es/mutate/deleteAndMergeSplitNodes.js +78 -0
- package/dist/es/mutate/deleteNode.js +46 -0
- package/dist/es/mutate/deleteText.js +25 -0
- package/dist/es/mutate/mergeNode.js +17 -0
- package/dist/es/mutate/mergeTrackedMarks.js +21 -0
- package/dist/es/plugin.js +114 -0
- package/dist/es/steps/trackReplaceAroundStep.js +45 -0
- package/dist/es/steps/trackReplaceStep.js +52 -0
- package/dist/es/steps/trackTransaction.js +84 -0
- package/dist/es/types/change.js +12 -0
- package/dist/es/types/pm.js +1 -0
- package/dist/es/types/step.js +1 -0
- package/dist/es/types/track.js +6 -0
- package/dist/es/utils/logger.js +36 -0
- package/dist/es/utils/track-utils.js +22 -0
- package/dist/es/utils/uuidv4.js +6 -0
- package/dist/types/ChangeSet.d.ts +28 -0
- package/dist/{actions.d.ts → types/actions.d.ts} +27 -60
- package/dist/{change-steps → types/change-steps}/diffChangeSteps.d.ts +2 -2
- package/dist/types/change-steps/matchInserted.d.ts +3 -0
- package/dist/types/change-steps/processChangeSteps.d.ts +6 -0
- package/dist/types/changes/applyChanges.d.ts +5 -0
- package/dist/types/changes/findChanges.d.ts +3 -0
- package/dist/types/changes/fixInconsistentChanges.d.ts +4 -0
- package/dist/types/changes/updateChangeAttrs.d.ts +6 -0
- package/dist/types/commands.d.ts +8 -0
- package/dist/{compute → types/compute}/nodeHelpers.d.ts +13 -28
- package/dist/types/compute/setFragmentAsInserted.d.ts +3 -0
- package/dist/types/compute/splitSliceIntoMergedParts.d.ts +13 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/mutate/deleteAndMergeSplitNodes.d.ts +13 -0
- package/dist/types/mutate/deleteNode.d.ts +5 -0
- package/dist/types/mutate/deleteText.d.ts +4 -0
- package/dist/types/mutate/mergeNode.d.ts +3 -0
- package/dist/types/mutate/mergeTrackedMarks.d.ts +3 -0
- package/dist/types/plugin.d.ts +4 -0
- package/dist/{steps → types/steps}/trackReplaceAroundStep.d.ts +5 -5
- package/dist/types/steps/trackReplaceStep.d.ts +6 -0
- package/dist/types/steps/trackTransaction.d.ts +2 -0
- package/dist/types/types/change.d.ts +61 -0
- package/dist/types/types/pm.d.ts +12 -0
- package/dist/types/{step.d.ts → types/step.d.ts} +38 -53
- package/dist/types/types/track.d.ts +30 -0
- package/dist/types/utils/logger.d.ts +8 -0
- package/dist/{utils → types/utils}/track-utils.d.ts +4 -4
- package/dist/types/utils/uuidv4.d.ts +1 -0
- package/package.json +18 -39
- package/LICENSE +0 -201
- package/dist/ChangeSet.d.ts +0 -71
- package/dist/change-steps/matchInserted.d.ts +0 -13
- package/dist/change-steps/processChangeSteps.d.ts +0 -21
- package/dist/changes/applyChanges.d.ts +0 -28
- package/dist/changes/findChanges.d.ts +0 -27
- package/dist/changes/fixInconsistentChanges.d.ts +0 -29
- package/dist/changes/updateChangeAttrs.d.ts +0 -21
- package/dist/commands.d.ts +0 -47
- package/dist/compute/setFragmentAsInserted.d.ts +0 -18
- package/dist/compute/splitSliceIntoMergedParts.d.ts +0 -41
- package/dist/index.cjs +0 -2026
- package/dist/index.d.ts +0 -22
- package/dist/index.js +0 -2013
- package/dist/mutate/deleteAndMergeSplitNodes.d.ts +0 -53
- package/dist/mutate/deleteNode.d.ts +0 -36
- package/dist/mutate/deleteText.d.ts +0 -33
- package/dist/mutate/mergeNode.d.ts +0 -25
- package/dist/mutate/mergeTrackedMarks.d.ts +0 -29
- package/dist/plugin.d.ts +0 -25
- package/dist/steps/trackReplaceStep.d.ts +0 -21
- package/dist/steps/trackTransaction.d.ts +0 -17
- package/dist/types/change.d.ts +0 -76
- package/dist/types/pm.d.ts +0 -27
- package/dist/types/track.d.ts +0 -45
- package/dist/utils/logger.d.ts +0 -27
- package/dist/utils/uuidv4.d.ts +0 -16
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { NodeChange, IncompleteChange, TextChange, TrackedAttrs, TrackedChange, NodeAttrChange } from './types/change';
|
|
2
|
+
export declare class ChangeSet {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(changes?: (TrackedChange | IncompleteChange)[]);
|
|
5
|
+
get changes(): TrackedChange[];
|
|
6
|
+
get invalidChanges(): (TrackedChange | IncompleteChange)[];
|
|
7
|
+
get changeTree(): TrackedChange[];
|
|
8
|
+
get pending(): TrackedChange[];
|
|
9
|
+
get accepted(): TrackedChange[];
|
|
10
|
+
get rejected(): TrackedChange[];
|
|
11
|
+
get textChanges(): TrackedChange[];
|
|
12
|
+
get nodeChanges(): TrackedChange[];
|
|
13
|
+
get nodeAttrChanges(): TrackedChange[];
|
|
14
|
+
get bothNodeChanges(): TrackedChange[];
|
|
15
|
+
get isEmpty(): boolean;
|
|
16
|
+
get hasInconsistentData(): boolean;
|
|
17
|
+
get hasDuplicateIds(): boolean;
|
|
18
|
+
get hasIncompleteAttrs(): boolean;
|
|
19
|
+
get(id: string): TrackedChange | IncompleteChange | undefined;
|
|
20
|
+
getIn(ids: string[]): (TrackedChange | IncompleteChange)[];
|
|
21
|
+
getNotIn(ids: string[]): (TrackedChange | IncompleteChange)[];
|
|
22
|
+
static flattenTreeToIds(changes: TrackedChange[]): string[];
|
|
23
|
+
static shouldDeleteChange(change: TrackedChange): boolean;
|
|
24
|
+
static isValidDataTracked(dataTracked?: Partial<TrackedAttrs>): boolean;
|
|
25
|
+
static isTextChange(change: TrackedChange): change is TextChange;
|
|
26
|
+
static isNodeChange(change: TrackedChange): change is NodeChange;
|
|
27
|
+
static isNodeAttrChange(change: TrackedChange): change is NodeAttrChange;
|
|
28
|
+
}
|
|
@@ -1,60 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export declare type TrackChangesActionParams = {
|
|
29
|
-
[TrackChangesAction.skipTrack]: boolean;
|
|
30
|
-
[TrackChangesAction.setUserID]: string;
|
|
31
|
-
[TrackChangesAction.setPluginStatus]: TrackChangesStatus;
|
|
32
|
-
[TrackChangesAction.setChangeStatuses]: {
|
|
33
|
-
status: CHANGE_STATUS;
|
|
34
|
-
ids: string[];
|
|
35
|
-
};
|
|
36
|
-
[TrackChangesAction.refreshChanges]: boolean;
|
|
37
|
-
[TrackChangesAction.applyAndRemoveChanges]: boolean;
|
|
38
|
-
[TrackChangesAction.updateMetaNode]: boolean;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Gets the value of a meta field, action payload, of a defined track-changes action.
|
|
42
|
-
* @param tr
|
|
43
|
-
* @param action
|
|
44
|
-
*/
|
|
45
|
-
export declare function getAction<K extends keyof TrackChangesActionParams>(tr: Transaction, action: K): TrackChangesActionParams[K] | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* Use this function to set meta keys to transactions that are consumed by the track-changes-plugin.
|
|
48
|
-
* For example, you can skip tracking of a transaction with setAction(tr, TrackChangesAction.skipTrack, true)
|
|
49
|
-
* @param tr
|
|
50
|
-
* @param action
|
|
51
|
-
* @param payload
|
|
52
|
-
*/
|
|
53
|
-
export declare function setAction<K extends keyof TrackChangesActionParams>(tr: Transaction, action: K, payload: TrackChangesActionParams[K]): Transaction;
|
|
54
|
-
/**
|
|
55
|
-
* Skip tracking for a transaction, use this with caution to avoid race-conditions or just to otherwise
|
|
56
|
-
* omitting applying of track attributes or marks.
|
|
57
|
-
* @param tr
|
|
58
|
-
* @returns
|
|
59
|
-
*/
|
|
60
|
-
export declare const skipTracking: (tr: Transaction) => Transaction;
|
|
1
|
+
import { Transaction } from 'prosemirror-state';
|
|
2
|
+
import { CHANGE_STATUS } from './types/change';
|
|
3
|
+
import { TrackChangesStatus } from './types/track';
|
|
4
|
+
export declare enum TrackChangesAction {
|
|
5
|
+
skipTrack = "track-changes-skip-tracking",
|
|
6
|
+
setUserID = "track-changes-set-user-id",
|
|
7
|
+
setPluginStatus = "track-changes-set-track-status",
|
|
8
|
+
setChangeStatuses = "track-changes-set-change-statuses",
|
|
9
|
+
refreshChanges = "track-changes-refresh-changes",
|
|
10
|
+
applyAndRemoveChanges = "track-changes-apply-remove-changes",
|
|
11
|
+
updateMetaNode = "track-changes-update-meta-node"
|
|
12
|
+
}
|
|
13
|
+
export type TrackChangesActionParams = {
|
|
14
|
+
[TrackChangesAction.skipTrack]: boolean;
|
|
15
|
+
[TrackChangesAction.setUserID]: string;
|
|
16
|
+
[TrackChangesAction.setPluginStatus]: TrackChangesStatus;
|
|
17
|
+
[TrackChangesAction.setChangeStatuses]: {
|
|
18
|
+
status: CHANGE_STATUS;
|
|
19
|
+
ids: string[];
|
|
20
|
+
};
|
|
21
|
+
[TrackChangesAction.refreshChanges]: boolean;
|
|
22
|
+
[TrackChangesAction.applyAndRemoveChanges]: boolean;
|
|
23
|
+
[TrackChangesAction.updateMetaNode]: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare function getAction<K extends keyof TrackChangesActionParams>(tr: Transaction, action: K): TrackChangesActionParams[K] | undefined;
|
|
26
|
+
export declare function setAction<K extends keyof TrackChangesActionParams>(tr: Transaction, action: K, payload: TrackChangesActionParams[K]): Transaction;
|
|
27
|
+
export declare const skipTracking: (tr: Transaction) => Transaction;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ChangeStep, InsertSliceStep } from '../types/step';
|
|
2
|
-
export declare function diffChangeSteps(deleted: ChangeStep[], inserted: InsertSliceStep[]): ChangeStep[];
|
|
1
|
+
import { ChangeStep, InsertSliceStep } from '../types/step';
|
|
2
|
+
export declare function diffChangeSteps(deleted: ChangeStep[], inserted: InsertSliceStep[]): ChangeStep[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Schema } from 'prosemirror-model';
|
|
2
|
+
import type { Transaction } from 'prosemirror-state';
|
|
3
|
+
import { Mapping } from 'prosemirror-transform';
|
|
4
|
+
import { ChangeStep } from '../types/step';
|
|
5
|
+
import { NewEmptyAttrs } from '../types/track';
|
|
6
|
+
export declare function processChangeSteps(changes: ChangeStep[], startPos: number, newTr: Transaction, emptyAttrs: NewEmptyAttrs, schema: Schema): [Mapping, number];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Schema } from 'prosemirror-model';
|
|
2
|
+
import { Transaction } from 'prosemirror-state';
|
|
3
|
+
import { Mapping } from 'prosemirror-transform';
|
|
4
|
+
import { TrackedChange } from '../types/change';
|
|
5
|
+
export declare function applyAcceptedRejectedChanges(tr: Transaction, schema: Schema, changes: TrackedChange[], deleteMap?: Mapping): Mapping;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Schema } from 'prosemirror-model';
|
|
2
|
+
import { Transaction } from 'prosemirror-state';
|
|
3
|
+
import { ChangeSet } from '../ChangeSet';
|
|
4
|
+
export declare function fixInconsistentChanges(changeSet: ChangeSet, currentUserID: string, newTr: Transaction, schema: Schema): boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Schema } from 'prosemirror-model';
|
|
2
|
+
import { Transaction } from 'prosemirror-state';
|
|
3
|
+
import { Mapping } from 'prosemirror-transform';
|
|
4
|
+
import { IncompleteChange, TrackedAttrs, TrackedChange } from '../types/change';
|
|
5
|
+
export declare function updateChangeAttrs(tr: Transaction, change: IncompleteChange, trackedAttrs: Partial<TrackedAttrs>, schema: Schema): Transaction;
|
|
6
|
+
export declare function updateChangeChildrenAttributes(changes: TrackedChange[], tr: Transaction, mapping: Mapping): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Command } from 'prosemirror-state';
|
|
2
|
+
import { CHANGE_STATUS } from './types/change';
|
|
3
|
+
import { TrackChangesStatus } from './types/track';
|
|
4
|
+
export declare const setTrackingStatus: (status?: TrackChangesStatus) => Command;
|
|
5
|
+
export declare const setChangeStatuses: (status: CHANGE_STATUS, ids: string[]) => Command;
|
|
6
|
+
export declare const setUserID: (userID: string) => Command;
|
|
7
|
+
export declare const applyAndRemoveChanges: () => Command;
|
|
8
|
+
export declare const refreshChanges: () => Command;
|
|
@@ -1,28 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { Node as PMNode, Schema } from 'prosemirror-model';
|
|
17
|
-
import { CHANGE_OPERATION, TrackedAttrs } from '../types/change';
|
|
18
|
-
export declare function addTrackIdIfDoesntExist(attrs: Partial<TrackedAttrs>): Partial<TrackedAttrs>;
|
|
19
|
-
export declare function getTextNodeTrackedMarkData(node: PMNode | undefined | null, schema: Schema): (Omit<Partial<TrackedAttrs>, "operation"> & {
|
|
20
|
-
operation: CHANGE_OPERATION;
|
|
21
|
-
}) | undefined;
|
|
22
|
-
export declare function getBlockInlineTrackedData(node: PMNode): Partial<TrackedAttrs>[] | undefined;
|
|
23
|
-
export declare function getNodeTrackedData(node: PMNode | undefined | null, schema: Schema): Partial<TrackedAttrs>[] | undefined;
|
|
24
|
-
export declare function equalMarks(n1: PMNode, n2: PMNode): boolean;
|
|
25
|
-
export declare function shouldMergeTrackedAttributes(left?: Partial<TrackedAttrs>, right?: Partial<TrackedAttrs>): boolean;
|
|
26
|
-
export declare function getMergeableMarkTrackedAttrs(node: PMNode | undefined | null, attrs: Partial<TrackedAttrs>, schema: Schema): (Omit<Partial<TrackedAttrs>, "operation"> & {
|
|
27
|
-
operation: CHANGE_OPERATION;
|
|
28
|
-
}) | null;
|
|
1
|
+
import { Node as PMNode, Schema } from 'prosemirror-model';
|
|
2
|
+
import { CHANGE_OPERATION, TrackedAttrs } from '../types/change';
|
|
3
|
+
export declare function addTrackIdIfDoesntExist(attrs: Partial<TrackedAttrs>): Partial<TrackedAttrs>;
|
|
4
|
+
export declare function getTextNodeTrackedMarkData(node: PMNode | undefined | null, schema: Schema): (Omit<Partial<TrackedAttrs>, "operation"> & {
|
|
5
|
+
operation: CHANGE_OPERATION;
|
|
6
|
+
}) | undefined;
|
|
7
|
+
export declare function getBlockInlineTrackedData(node: PMNode): Partial<TrackedAttrs>[] | undefined;
|
|
8
|
+
export declare function getNodeTrackedData(node: PMNode | undefined | null, schema: Schema): Partial<TrackedAttrs>[] | undefined;
|
|
9
|
+
export declare function equalMarks(n1: PMNode, n2: PMNode): boolean;
|
|
10
|
+
export declare function shouldMergeTrackedAttributes(left?: Partial<TrackedAttrs>, right?: Partial<TrackedAttrs>): boolean;
|
|
11
|
+
export declare function getMergeableMarkTrackedAttrs(node: PMNode | undefined | null, attrs: Partial<TrackedAttrs>, schema: Schema): (Omit<Partial<TrackedAttrs>, "operation"> & {
|
|
12
|
+
operation: CHANGE_OPERATION;
|
|
13
|
+
}) | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
2
|
+
import { ExposedFragment, ExposedSlice } from '../types/pm';
|
|
3
|
+
export declare function splitSliceIntoMergedParts(insertSlice: ExposedSlice, mergeEqualSides?: boolean): {
|
|
4
|
+
updatedSliceNodes: PMNode[];
|
|
5
|
+
firstMergedNode: {
|
|
6
|
+
mergedNodeContent: ExposedFragment;
|
|
7
|
+
unmergedContent: ExposedFragment | undefined;
|
|
8
|
+
} | undefined;
|
|
9
|
+
lastMergedNode: {
|
|
10
|
+
mergedNodeContent: ExposedFragment;
|
|
11
|
+
unmergedContent: ExposedFragment | undefined;
|
|
12
|
+
} | undefined;
|
|
13
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { trackChangesPluginKey, trackChangesPlugin } from './plugin';
|
|
2
|
+
export { skipTracking } from './actions';
|
|
3
|
+
export * as trackCommands from './commands';
|
|
4
|
+
export { enableDebug } from './utils/logger';
|
|
5
|
+
export { ChangeSet } from './ChangeSet';
|
|
6
|
+
export * from './types/change';
|
|
7
|
+
export * from './types/track';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Fragment, Node as PMNode, Schema } from 'prosemirror-model';
|
|
2
|
+
import type { Transaction } from 'prosemirror-state';
|
|
3
|
+
import { ExposedSlice } from '../types/pm';
|
|
4
|
+
import { NewEmptyAttrs } from '../types/track';
|
|
5
|
+
import { ChangeStep } from '../types/step';
|
|
6
|
+
export declare function deleteAndMergeSplitNodes(from: number, to: number, gap: {
|
|
7
|
+
start: number;
|
|
8
|
+
end: number;
|
|
9
|
+
} | undefined, startDoc: PMNode, newTr: Transaction, schema: Schema, trackAttrs: NewEmptyAttrs, insertSlice: ExposedSlice): {
|
|
10
|
+
sliceWasSplit: boolean;
|
|
11
|
+
newSliceContent: Fragment;
|
|
12
|
+
steps: ChangeStep[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
2
|
+
import { Transaction } from 'prosemirror-state';
|
|
3
|
+
import { NewDeleteAttrs } from '../types/track';
|
|
4
|
+
export declare function deleteNode(node: PMNode, pos: number, tr: Transaction): Transaction;
|
|
5
|
+
export declare function deleteOrSetNodeDeleted(node: PMNode, pos: number, newTr: Transaction, deleteAttrs: NewDeleteAttrs): Transaction | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Node as PMNode, Schema } from 'prosemirror-model';
|
|
2
|
+
import type { Transaction } from 'prosemirror-state';
|
|
3
|
+
import { NewDeleteAttrs } from '../types/track';
|
|
4
|
+
export declare function deleteTextIfInserted(node: PMNode, pos: number, newTr: Transaction, schema: Schema, deleteAttrs: NewDeleteAttrs, from?: number, to?: number): number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
|
+
import { TrackChangesOptions, TrackChangesState } from './types/track';
|
|
3
|
+
export declare const trackChangesPluginKey: PluginKey<TrackChangesState>;
|
|
4
|
+
export declare const trackChangesPlugin: (opts?: TrackChangesOptions) => Plugin<TrackChangesState>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { ReplaceAroundStep } from 'prosemirror-transform';
|
|
3
|
-
import { NewEmptyAttrs } from '../types/track';
|
|
4
|
-
import { ChangeStep } from '../types/step';
|
|
5
|
-
export declare function trackReplaceAroundStep(step: ReplaceAroundStep, oldState: EditorState, tr: Transaction, newTr: Transaction, attrs: NewEmptyAttrs): ChangeStep[];
|
|
1
|
+
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
+
import { ReplaceAroundStep } from 'prosemirror-transform';
|
|
3
|
+
import { NewEmptyAttrs } from '../types/track';
|
|
4
|
+
import { ChangeStep } from '../types/step';
|
|
5
|
+
export declare function trackReplaceAroundStep(step: ReplaceAroundStep, oldState: EditorState, tr: Transaction, newTr: Transaction, attrs: NewEmptyAttrs): ChangeStep[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
2
|
+
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
3
|
+
import { ReplaceStep, StepResult } from 'prosemirror-transform';
|
|
4
|
+
import { NewEmptyAttrs } from '../types/track';
|
|
5
|
+
import { ChangeStep } from '../types/step';
|
|
6
|
+
export declare function trackReplaceStep(step: ReplaceStep, oldState: EditorState, newTr: Transaction, attrs: NewEmptyAttrs, stepResult: StepResult, currentStepDoc: PMNode): [ChangeStep[], number];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export declare enum CHANGE_OPERATION {
|
|
2
|
+
insert = "insert",
|
|
3
|
+
delete = "delete",
|
|
4
|
+
set_node_attributes = "set_attrs"
|
|
5
|
+
}
|
|
6
|
+
export declare enum CHANGE_STATUS {
|
|
7
|
+
accepted = "accepted",
|
|
8
|
+
rejected = "rejected",
|
|
9
|
+
pending = "pending"
|
|
10
|
+
}
|
|
11
|
+
type InsertDeleteAttrs = {
|
|
12
|
+
id: string;
|
|
13
|
+
authorID: string;
|
|
14
|
+
reviewedByID: string | null;
|
|
15
|
+
operation: CHANGE_OPERATION.insert | CHANGE_OPERATION.delete;
|
|
16
|
+
status: CHANGE_STATUS;
|
|
17
|
+
createdAt: number;
|
|
18
|
+
updatedAt: number;
|
|
19
|
+
};
|
|
20
|
+
export type UpdateAttrs = Omit<InsertDeleteAttrs, 'operation'> & {
|
|
21
|
+
operation: CHANGE_OPERATION.set_node_attributes;
|
|
22
|
+
oldAttrs: Record<string, any>;
|
|
23
|
+
};
|
|
24
|
+
export type TrackedAttrs = InsertDeleteAttrs | UpdateAttrs;
|
|
25
|
+
type Change = {
|
|
26
|
+
id: string;
|
|
27
|
+
from: number;
|
|
28
|
+
to: number;
|
|
29
|
+
dataTracked: TrackedAttrs;
|
|
30
|
+
};
|
|
31
|
+
export type TextChange = Change & {
|
|
32
|
+
type: 'text-change';
|
|
33
|
+
text: string;
|
|
34
|
+
};
|
|
35
|
+
export type NodeChange = Change & {
|
|
36
|
+
type: 'node-change';
|
|
37
|
+
nodeType: string;
|
|
38
|
+
children: TrackedChange[];
|
|
39
|
+
};
|
|
40
|
+
export type NodeAttrChange = Change & {
|
|
41
|
+
type: 'node-attr-change';
|
|
42
|
+
nodeType: string;
|
|
43
|
+
oldAttrs: Record<string, any>;
|
|
44
|
+
newAttrs: Record<string, any>;
|
|
45
|
+
};
|
|
46
|
+
export type WrapChange = Change & {
|
|
47
|
+
type: 'wrap-change';
|
|
48
|
+
wrapperNode: string;
|
|
49
|
+
};
|
|
50
|
+
export type MarkChange = Change & {
|
|
51
|
+
type: 'mark-change';
|
|
52
|
+
};
|
|
53
|
+
export type TrackedChange = TextChange | NodeChange | NodeAttrChange | WrapChange | MarkChange;
|
|
54
|
+
export type PartialChange<T extends TrackedChange> = Omit<T, 'dataTracked'> & {
|
|
55
|
+
dataTracked: Partial<TrackedAttrs>;
|
|
56
|
+
};
|
|
57
|
+
export type IncompleteChange = Omit<TrackedChange, 'dataTracked'> & {
|
|
58
|
+
dataTracked: Partial<TrackedAttrs>;
|
|
59
|
+
};
|
|
60
|
+
export type ChangeType = TrackedChange['type'];
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fragment, Node as PMNode, Slice } from 'prosemirror-model';
|
|
2
|
+
import { ReplaceStep } from 'prosemirror-transform';
|
|
3
|
+
export type ExposedReplaceStep = ReplaceStep & {
|
|
4
|
+
slice: ExposedSlice;
|
|
5
|
+
};
|
|
6
|
+
export type ExposedSlice = Slice & {
|
|
7
|
+
content: ExposedFragment;
|
|
8
|
+
insertAt(pos: number, fragment: Fragment | ExposedFragment): ExposedSlice;
|
|
9
|
+
};
|
|
10
|
+
export type ExposedFragment = Fragment & {
|
|
11
|
+
content: PMNode[];
|
|
12
|
+
};
|
|
@@ -1,53 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
type: '
|
|
22
|
-
node: PMNode;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
from: number;
|
|
27
|
-
to: number;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
export interface InsertSliceStep {
|
|
41
|
-
from: number;
|
|
42
|
-
to: number;
|
|
43
|
-
sliceWasSplit: boolean;
|
|
44
|
-
type: 'insert-slice';
|
|
45
|
-
slice: ExposedSlice;
|
|
46
|
-
}
|
|
47
|
-
export interface UpdateNodeAttrsStep {
|
|
48
|
-
pos: number;
|
|
49
|
-
type: 'update-node-attrs';
|
|
50
|
-
node: PMNode;
|
|
51
|
-
newAttrs: Record<string, any>;
|
|
52
|
-
}
|
|
53
|
-
export declare type ChangeStep = DeleteNodeStep | DeleteTextStep | MergeFragmentStep | InsertSliceStep | UpdateNodeAttrsStep;
|
|
1
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
2
|
+
import { ExposedFragment, ExposedSlice } from './pm';
|
|
3
|
+
export interface DeleteNodeStep {
|
|
4
|
+
pos: number;
|
|
5
|
+
nodeEnd: number;
|
|
6
|
+
type: 'delete-node';
|
|
7
|
+
node: PMNode;
|
|
8
|
+
}
|
|
9
|
+
export interface DeleteTextStep {
|
|
10
|
+
pos: number;
|
|
11
|
+
from: number;
|
|
12
|
+
to: number;
|
|
13
|
+
type: 'delete-text';
|
|
14
|
+
node: PMNode;
|
|
15
|
+
}
|
|
16
|
+
export interface MergeFragmentStep {
|
|
17
|
+
pos: number;
|
|
18
|
+
mergePos: number;
|
|
19
|
+
from: number;
|
|
20
|
+
to: number;
|
|
21
|
+
type: 'merge-fragment';
|
|
22
|
+
node: PMNode;
|
|
23
|
+
fragment: ExposedFragment;
|
|
24
|
+
}
|
|
25
|
+
export interface InsertSliceStep {
|
|
26
|
+
from: number;
|
|
27
|
+
to: number;
|
|
28
|
+
sliceWasSplit: boolean;
|
|
29
|
+
type: 'insert-slice';
|
|
30
|
+
slice: ExposedSlice;
|
|
31
|
+
}
|
|
32
|
+
export interface UpdateNodeAttrsStep {
|
|
33
|
+
pos: number;
|
|
34
|
+
type: 'update-node-attrs';
|
|
35
|
+
node: PMNode;
|
|
36
|
+
newAttrs: Record<string, any>;
|
|
37
|
+
}
|
|
38
|
+
export type ChangeStep = DeleteNodeStep | DeleteTextStep | MergeFragmentStep | InsertSliceStep | UpdateNodeAttrsStep;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PluginKey } from 'prosemirror-state';
|
|
2
|
+
import { ChangeSet } from '../ChangeSet';
|
|
3
|
+
import { CHANGE_OPERATION, TrackedAttrs } from './change';
|
|
4
|
+
export interface TrackChangesOptions {
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
userID: string;
|
|
7
|
+
skipTrsWithMetas?: (PluginKey | string)[];
|
|
8
|
+
}
|
|
9
|
+
export interface TrackChangesState {
|
|
10
|
+
status: TrackChangesStatus;
|
|
11
|
+
userID: string;
|
|
12
|
+
changeSet: ChangeSet;
|
|
13
|
+
}
|
|
14
|
+
export type NewEmptyAttrs = Omit<TrackedAttrs, 'id' | 'operation'>;
|
|
15
|
+
export type NewInsertAttrs = Omit<TrackedAttrs, 'id' | 'operation'> & {
|
|
16
|
+
operation: CHANGE_OPERATION.insert;
|
|
17
|
+
};
|
|
18
|
+
export type NewDeleteAttrs = Omit<TrackedAttrs, 'id' | 'operation'> & {
|
|
19
|
+
operation: CHANGE_OPERATION.delete;
|
|
20
|
+
};
|
|
21
|
+
export type NewUpdateAttrs = Omit<TrackedAttrs, 'id' | 'operation'> & {
|
|
22
|
+
operation: CHANGE_OPERATION.set_node_attributes;
|
|
23
|
+
oldAttrs: Record<string, any>;
|
|
24
|
+
};
|
|
25
|
+
export type NewTrackedAttrs = NewInsertAttrs | NewDeleteAttrs | NewUpdateAttrs;
|
|
26
|
+
export declare enum TrackChangesStatus {
|
|
27
|
+
enabled = "enabled",
|
|
28
|
+
viewSnapshots = "view-snapshots",
|
|
29
|
+
disabled = "disabled"
|
|
30
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
export declare const logger: debug.Debugger;
|
|
3
|
+
export declare const log: {
|
|
4
|
+
info(str: string, obj?: any): void;
|
|
5
|
+
warn(str: string, obj?: any): void;
|
|
6
|
+
error(str: string, obj?: any): void;
|
|
7
|
+
};
|
|
8
|
+
export declare const enableDebug: (enabled: boolean) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NewDeleteAttrs, NewEmptyAttrs, NewInsertAttrs, NewUpdateAttrs } from '../types/track';
|
|
2
|
-
export declare function createNewInsertAttrs(attrs: NewEmptyAttrs): NewInsertAttrs;
|
|
3
|
-
export declare function createNewDeleteAttrs(attrs: NewEmptyAttrs): NewDeleteAttrs;
|
|
4
|
-
export declare function createNewUpdateAttrs(attrs: NewEmptyAttrs, oldAttrs: Record<string, any>): NewUpdateAttrs;
|
|
1
|
+
import { NewDeleteAttrs, NewEmptyAttrs, NewInsertAttrs, NewUpdateAttrs } from '../types/track';
|
|
2
|
+
export declare function createNewInsertAttrs(attrs: NewEmptyAttrs): NewInsertAttrs;
|
|
3
|
+
export declare function createNewDeleteAttrs(attrs: NewEmptyAttrs): NewDeleteAttrs;
|
|
4
|
+
export declare function createNewUpdateAttrs(attrs: NewEmptyAttrs, oldAttrs: Record<string, any>): NewUpdateAttrs;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function uuidv4(): string;
|
package/package.json
CHANGED
|
@@ -1,51 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/track-changes-plugin",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3-LEAN-2832-v3",
|
|
4
4
|
"author": "Atypon Systems LLC",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"homepage": "https://github.com/Atypon-OpenSource/manuscripts-
|
|
7
|
-
"main": "dist/
|
|
8
|
-
"module": "dist/
|
|
9
|
-
"
|
|
10
|
-
"types": "dist/index.d.ts",
|
|
11
|
-
"exports": {
|
|
12
|
-
"./package.json": "./package.json",
|
|
13
|
-
"./src/styles.css": "./src/styles.css",
|
|
14
|
-
".": {
|
|
15
|
-
"import": "./dist/index.js",
|
|
16
|
-
"require": "./dist/index.cjs"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
6
|
+
"homepage": "https://github.com/Atypon-OpenSource/manuscripts-track-changes-plugin",
|
|
7
|
+
"main": "dist/cjs",
|
|
8
|
+
"module": "dist/es",
|
|
9
|
+
"types": "dist/types",
|
|
19
10
|
"files": [
|
|
20
11
|
"dist",
|
|
21
12
|
"src/styles.css"
|
|
22
13
|
],
|
|
23
|
-
"
|
|
24
|
-
"
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "npm-run-all --parallel 'build:* --project tsconfig.json'",
|
|
16
|
+
"build:cjs": "tsc --outDir dist/cjs --module commonjs",
|
|
17
|
+
"build:es": "tsc --outDir dist/es --declarationDir dist/types --declaration",
|
|
18
|
+
"dev": "npm-run-all --parallel 'build:* --project tsconfig.build.json --watch'",
|
|
19
|
+
"test": "jest --runInBand",
|
|
20
|
+
"format": "prettier --write \"*.+(js|json|yml|yaml|ts|md|graphql|mdx)\" src/ test/",
|
|
21
|
+
"typecheck": "tsc --project tsconfig.test.json --noEmit",
|
|
22
|
+
"lint": "eslint --cache --ext .js,.ts, ./src ./test",
|
|
23
|
+
"lint:fix": "eslint --fix --ext .js,.ts, ./src ./test"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
|
-
"@manuscripts/
|
|
28
|
-
"@manuscripts/json-schema": "^2.0.2",
|
|
29
|
-
"@manuscripts/transform": "^1.2.5",
|
|
30
|
-
"@rollup/plugin-commonjs": "^22.0.2",
|
|
26
|
+
"@manuscripts/transform": "^1.5.1",
|
|
31
27
|
"@types/debug": "^4.1.7",
|
|
32
28
|
"@types/jest": "27.5.1",
|
|
33
29
|
"@types/node": "^18.7.18",
|
|
34
30
|
"jest": "27.5.1",
|
|
35
31
|
"jest-environment-jsdom": "27.5.1",
|
|
36
32
|
"jsdom": "^20.0.0",
|
|
37
|
-
"
|
|
38
|
-
"rollup-plugin-typescript2": "^0.34.0",
|
|
33
|
+
"npm-run-all": "^4.1.5",
|
|
39
34
|
"ts-jest": "27.1.4",
|
|
40
35
|
"tslib": "^2.4.0",
|
|
41
36
|
"typescript": "^4.8.3"
|
|
42
37
|
},
|
|
43
|
-
"peerDependencies": {
|
|
44
|
-
"prosemirror-model": ">=1.14.0",
|
|
45
|
-
"prosemirror-state": ">=1.3.0",
|
|
46
|
-
"prosemirror-transform": ">=1.3.0",
|
|
47
|
-
"prosemirror-view": ">=1.18.0"
|
|
48
|
-
},
|
|
49
38
|
"dependencies": {
|
|
50
39
|
"prosemirror-commands": "^1.5.0",
|
|
51
40
|
"prosemirror-example-setup": "^1.2.1",
|
|
@@ -57,15 +46,5 @@
|
|
|
57
46
|
"prosemirror-transform": "^1.7.0",
|
|
58
47
|
"prosemirror-view": "^1.29.1",
|
|
59
48
|
"debug": "^4.3.4"
|
|
60
|
-
},
|
|
61
|
-
"scripts": {
|
|
62
|
-
"build": "rollup -c",
|
|
63
|
-
"watch": "rollup -cw",
|
|
64
|
-
"dev": "yarn run watch",
|
|
65
|
-
"test": "jest --runInBand",
|
|
66
|
-
"format": "prettier --write \"*.+(js|json|yml|yaml|ts|md|graphql|mdx)\" src/ test/",
|
|
67
|
-
"typecheck": "tsc --project tsconfig.test.json --noEmit",
|
|
68
|
-
"lint": "eslint --cache --ext .js,.ts, ./src ./test",
|
|
69
|
-
"lint:fix": "eslint --fix --ext .js,.ts, ./src ./test"
|
|
70
49
|
}
|
|
71
|
-
}
|
|
50
|
+
}
|