@manuscripts/track-changes-plugin 0.3.0 → 0.4.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/ChangeSet.d.ts +3 -1
- package/dist/change-steps/diffChangeSteps.d.ts +21 -0
- package/dist/change-steps/processChangeSteps.d.ts +21 -0
- package/dist/{track → changes}/applyChanges.d.ts +0 -0
- package/dist/{track → changes}/findChanges.d.ts +0 -0
- package/dist/{track → changes}/fixInconsistentChanges.d.ts +0 -0
- package/dist/{track → changes}/updateChangeAttrs.d.ts +0 -0
- package/dist/commands.d.ts +1 -1
- package/dist/{track/node-utils.d.ts → compute/nodeHelpers.d.ts} +0 -0
- package/dist/{track/steps → compute}/setFragmentAsInserted.d.ts +1 -1
- package/dist/compute/splitSliceIntoMergedParts.d.ts +41 -0
- package/dist/index.cjs +532 -298
- package/dist/index.js +532 -298
- package/dist/{track/steps → mutate}/deleteAndMergeSplitNodes.d.ts +4 -3
- package/dist/{track → mutate}/deleteNode.d.ts +9 -0
- package/dist/mutate/deleteText.d.ts +32 -0
- package/dist/{track → mutate}/mergeNode.d.ts +0 -0
- package/dist/{track/steps → mutate}/mergeTrackedMarks.d.ts +0 -0
- package/dist/{track/steps → steps}/trackReplaceAroundStep.d.ts +3 -2
- package/dist/{track/steps → steps}/trackReplaceStep.d.ts +3 -2
- package/dist/{track → steps}/trackTransaction.d.ts +0 -0
- package/dist/types/change.d.ts +18 -10
- package/dist/types/step.d.ts +52 -0
- package/dist/{track/steps → utils}/track-utils.d.ts +1 -1
- package/package.json +2 -2
- package/dist/index.es.js +0 -1547
- package/dist/types/editor.d.ts +0 -23
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
import { Fragment, Node as PMNode, Schema } from 'prosemirror-model';
|
|
17
17
|
import type { Transaction } from 'prosemirror-state';
|
|
18
18
|
import { Mapping } from 'prosemirror-transform';
|
|
19
|
-
import { ExposedSlice } from '
|
|
20
|
-
import { NewEmptyAttrs } from '
|
|
19
|
+
import { ExposedSlice } from '../types/pm';
|
|
20
|
+
import { NewEmptyAttrs } from '../types/track';
|
|
21
|
+
import { ChangeStep } from '../types/step';
|
|
21
22
|
/**
|
|
22
23
|
* Applies deletion to the doc without actually deleting nodes that have not been inserted
|
|
23
24
|
*
|
|
@@ -48,6 +49,6 @@ export declare function deleteAndMergeSplitNodes(from: number, to: number, gap:
|
|
|
48
49
|
end: number;
|
|
49
50
|
} | undefined, startDoc: PMNode, newTr: Transaction, schema: Schema, trackAttrs: NewEmptyAttrs, insertSlice: ExposedSlice): {
|
|
50
51
|
deleteMap: Mapping;
|
|
51
|
-
mergedInsertPos: undefined;
|
|
52
52
|
newSliceContent: Fragment;
|
|
53
|
+
steps: ChangeStep[];
|
|
53
54
|
};
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Node as PMNode } from 'prosemirror-model';
|
|
17
17
|
import { Transaction } from 'prosemirror-state';
|
|
18
|
+
import { NewDeleteAttrs } from '../types/track';
|
|
18
19
|
/**
|
|
19
20
|
* Deletes node but tries to leave its content intact by trying to unwrap it first
|
|
20
21
|
*
|
|
@@ -25,3 +26,11 @@ import { Transaction } from 'prosemirror-state';
|
|
|
25
26
|
* @returns
|
|
26
27
|
*/
|
|
27
28
|
export declare function deleteNode(node: PMNode, pos: number, tr: Transaction): Transaction;
|
|
29
|
+
/**
|
|
30
|
+
* Deletes inserted block or inline node, otherwise adds `dataTracked` object with CHANGE_STATUS 'deleted'
|
|
31
|
+
* @param node
|
|
32
|
+
* @param pos
|
|
33
|
+
* @param newTr
|
|
34
|
+
* @param deleteAttrs
|
|
35
|
+
*/
|
|
36
|
+
export declare function deleteOrSetNodeDeleted(node: PMNode, pos: number, newTr: Transaction, deleteAttrs: NewDeleteAttrs): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2021 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Node as PMNode, Schema } from 'prosemirror-model';
|
|
17
|
+
import type { Transaction } from 'prosemirror-state';
|
|
18
|
+
import { NewDeleteAttrs } from '../types/track';
|
|
19
|
+
/**
|
|
20
|
+
* Deletes inserted text directly, otherwise wraps it with tracked_delete mark
|
|
21
|
+
*
|
|
22
|
+
* This would work for general inline nodes too, but since node marks don't work properly
|
|
23
|
+
* with Yjs, attributes are used instead.
|
|
24
|
+
* @param node
|
|
25
|
+
* @param pos
|
|
26
|
+
* @param newTr
|
|
27
|
+
* @param schema
|
|
28
|
+
* @param deleteAttrs
|
|
29
|
+
* @param from
|
|
30
|
+
* @param to
|
|
31
|
+
*/
|
|
32
|
+
export declare function deleteTextIfInserted(node: PMNode, pos: number, newTr: Transaction, schema: Schema, deleteAttrs: NewDeleteAttrs, from?: number, to?: number): number;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
2
2
|
import { ReplaceAroundStep } from 'prosemirror-transform';
|
|
3
|
-
import { NewEmptyAttrs } from '
|
|
4
|
-
|
|
3
|
+
import { NewEmptyAttrs } from '../types/track';
|
|
4
|
+
import { ChangeStep } from '../types/step';
|
|
5
|
+
export declare function trackReplaceAroundStep(step: ReplaceAroundStep, oldState: EditorState, newTr: Transaction, attrs: NewEmptyAttrs): ChangeStep[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
2
2
|
import { ReplaceStep } from 'prosemirror-transform';
|
|
3
|
-
import { NewEmptyAttrs } from '
|
|
4
|
-
|
|
3
|
+
import { NewEmptyAttrs } from '../types/track';
|
|
4
|
+
import { ChangeStep } from '../types/step';
|
|
5
|
+
export declare function trackReplaceStep(step: ReplaceStep, oldState: EditorState, newTr: Transaction, attrs: NewEmptyAttrs): [ChangeStep[], number];
|
|
File without changes
|
package/dist/types/change.d.ts
CHANGED
|
@@ -16,27 +16,28 @@
|
|
|
16
16
|
export declare enum CHANGE_OPERATION {
|
|
17
17
|
insert = "insert",
|
|
18
18
|
delete = "delete",
|
|
19
|
-
set_node_attributes = "
|
|
20
|
-
wrap_with_node = "wrap_with_node",
|
|
21
|
-
unwrap_from_node = "unwrap_from_node",
|
|
22
|
-
add_mark = "add_mark",
|
|
23
|
-
remove_mark = "remove_mark"
|
|
19
|
+
set_node_attributes = "set_attrs"
|
|
24
20
|
}
|
|
25
21
|
export declare enum CHANGE_STATUS {
|
|
26
22
|
accepted = "accepted",
|
|
27
23
|
rejected = "rejected",
|
|
28
24
|
pending = "pending"
|
|
29
25
|
}
|
|
30
|
-
|
|
26
|
+
declare type InsertDeleteAttrs = {
|
|
31
27
|
id: string;
|
|
32
28
|
authorID: string;
|
|
33
29
|
reviewedByID: string | null;
|
|
34
|
-
operation: CHANGE_OPERATION;
|
|
30
|
+
operation: CHANGE_OPERATION.insert | CHANGE_OPERATION.delete;
|
|
35
31
|
status: CHANGE_STATUS;
|
|
36
32
|
createdAt: number;
|
|
37
33
|
updatedAt: number;
|
|
38
|
-
}
|
|
39
|
-
|
|
34
|
+
};
|
|
35
|
+
declare type UpdateAttrs = Omit<InsertDeleteAttrs, 'operation'> & {
|
|
36
|
+
operation: CHANGE_OPERATION.set_node_attributes;
|
|
37
|
+
oldAttrs: Record<string, any>;
|
|
38
|
+
};
|
|
39
|
+
export declare type TrackedAttrs = InsertDeleteAttrs | UpdateAttrs;
|
|
40
|
+
declare type Change = {
|
|
40
41
|
id: string;
|
|
41
42
|
from: number;
|
|
42
43
|
to: number;
|
|
@@ -51,6 +52,12 @@ export declare type NodeChange = Change & {
|
|
|
51
52
|
nodeType: string;
|
|
52
53
|
children: TrackedChange[];
|
|
53
54
|
};
|
|
55
|
+
export declare type NodeAttrChange = Change & {
|
|
56
|
+
type: 'node-attr-change';
|
|
57
|
+
nodeType: string;
|
|
58
|
+
oldAttrs: Record<string, any>;
|
|
59
|
+
newAttrs: Record<string, any>;
|
|
60
|
+
};
|
|
54
61
|
export declare type WrapChange = Change & {
|
|
55
62
|
type: 'wrap-change';
|
|
56
63
|
wrapperNode: string;
|
|
@@ -58,7 +65,7 @@ export declare type WrapChange = Change & {
|
|
|
58
65
|
export declare type MarkChange = Change & {
|
|
59
66
|
type: 'mark-change';
|
|
60
67
|
};
|
|
61
|
-
export declare type TrackedChange = TextChange | NodeChange | WrapChange | MarkChange;
|
|
68
|
+
export declare type TrackedChange = TextChange | NodeChange | NodeAttrChange | WrapChange | MarkChange;
|
|
62
69
|
export declare type PartialChange<T extends TrackedChange> = Omit<T, 'attrs'> & {
|
|
63
70
|
attrs: Partial<TrackedAttrs>;
|
|
64
71
|
};
|
|
@@ -66,3 +73,4 @@ export declare type IncompleteChange = Omit<TrackedChange, 'attrs'> & {
|
|
|
66
73
|
attrs: Partial<TrackedAttrs>;
|
|
67
74
|
};
|
|
68
75
|
export declare type ChangeType = TrackedChange['type'];
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2021 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Node as PMNode } from 'prosemirror-model';
|
|
17
|
+
import { ExposedFragment, ExposedSlice } from './pm';
|
|
18
|
+
export interface DeleteNodeStep {
|
|
19
|
+
pos: number;
|
|
20
|
+
nodeEnd: number;
|
|
21
|
+
type: 'delete-node';
|
|
22
|
+
node: PMNode;
|
|
23
|
+
}
|
|
24
|
+
export interface DeleteTextStep {
|
|
25
|
+
pos: number;
|
|
26
|
+
from: number;
|
|
27
|
+
to: number;
|
|
28
|
+
type: 'delete-text';
|
|
29
|
+
node: PMNode;
|
|
30
|
+
}
|
|
31
|
+
export interface MergeFragmentStep {
|
|
32
|
+
pos: number;
|
|
33
|
+
mergePos: number;
|
|
34
|
+
from: number;
|
|
35
|
+
to: number;
|
|
36
|
+
type: 'merge-fragment';
|
|
37
|
+
node: PMNode;
|
|
38
|
+
fragment: ExposedFragment;
|
|
39
|
+
}
|
|
40
|
+
export interface InsertSliceStep {
|
|
41
|
+
from: number;
|
|
42
|
+
to: number;
|
|
43
|
+
type: 'insert-slice';
|
|
44
|
+
slice: ExposedSlice;
|
|
45
|
+
}
|
|
46
|
+
export interface UpdateNodeAttrsStep {
|
|
47
|
+
pos: number;
|
|
48
|
+
type: 'update-node-attrs';
|
|
49
|
+
oldAttrs: Record<string, any>;
|
|
50
|
+
newAttrs: Record<string, any>;
|
|
51
|
+
}
|
|
52
|
+
export declare type ChangeStep = DeleteNodeStep | DeleteTextStep | MergeFragmentStep | InsertSliceStep | UpdateNodeAttrsStep;
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { NewDeleteAttrs, NewEmptyAttrs, NewInsertAttrs } from '
|
|
16
|
+
import { NewDeleteAttrs, NewEmptyAttrs, NewInsertAttrs } from '../types/track';
|
|
17
17
|
export declare function createNewInsertAttrs(attrs: NewEmptyAttrs): NewInsertAttrs;
|
|
18
18
|
export declare function createNewDeleteAttrs(attrs: NewEmptyAttrs): NewDeleteAttrs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/track-changes-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"author": "Atypon Systems LLC",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/Atypon-OpenSource/manuscripts-quarterback/tree/main/quarterback-packages/track-changes-plugin",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"prosemirror-schema-list": "^1.2.0",
|
|
37
37
|
"prosemirror-state": "^1.4.1",
|
|
38
38
|
"prosemirror-transform": "^1.6.0",
|
|
39
|
-
"prosemirror-view": "^1.
|
|
39
|
+
"prosemirror-view": "^1.27.0",
|
|
40
40
|
"rollup": "^2.74.0",
|
|
41
41
|
"rollup-plugin-typescript2": "^0.31.2",
|
|
42
42
|
"ts-jest": "27.1.4",
|