@manuscripts/track-changes-plugin 0.4.0 → 0.4.1
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 +2 -7
- package/dist/change-steps/diffChangeSteps.d.ts +1 -1
- package/dist/changes/fixInconsistentChanges.d.ts +1 -1
- package/dist/compute/nodeHelpers.d.ts +3 -2
- package/dist/index.cjs +337 -224
- package/dist/index.es.js +1547 -0
- package/dist/index.js +337 -224
- package/dist/mutate/deleteAndMergeSplitNodes.d.ts +1 -2
- package/dist/mutate/deleteNode.d.ts +1 -1
- package/dist/track/applyChanges.d.ts +28 -0
- package/dist/track/deleteNode.d.ts +27 -0
- package/dist/track/findChanges.d.ts +27 -0
- package/dist/track/fixInconsistentChanges.d.ts +29 -0
- package/dist/track/mergeNode.d.ts +25 -0
- package/dist/track/node-utils.d.ts +27 -0
- package/dist/track/steps/deleteAndMergeSplitNodes.d.ts +53 -0
- package/dist/track/steps/mergeTrackedMarks.d.ts +29 -0
- package/dist/track/steps/setFragmentAsInserted.d.ts +18 -0
- package/dist/track/steps/track-utils.d.ts +18 -0
- package/dist/track/steps/trackReplaceAroundStep.d.ts +4 -0
- package/dist/track/steps/trackReplaceStep.d.ts +4 -0
- package/dist/track/trackTransaction.d.ts +17 -0
- package/dist/track/updateChangeAttrs.d.ts +21 -0
- package/dist/types/change.d.ts +5 -5
- package/dist/types/editor.d.ts +23 -0
- package/dist/types/step.d.ts +2 -1
- package/dist/types/track.d.ts +5 -1
- package/dist/utils/track-utils.d.ts +2 -16
- package/package.json +2 -1
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Fragment, Node as PMNode, Schema } from 'prosemirror-model';
|
|
17
17
|
import type { Transaction } from 'prosemirror-state';
|
|
18
|
-
import { Mapping } from 'prosemirror-transform';
|
|
19
18
|
import { ExposedSlice } from '../types/pm';
|
|
20
19
|
import { NewEmptyAttrs } from '../types/track';
|
|
21
20
|
import { ChangeStep } from '../types/step';
|
|
@@ -48,7 +47,7 @@ export declare function deleteAndMergeSplitNodes(from: number, to: number, gap:
|
|
|
48
47
|
start: number;
|
|
49
48
|
end: number;
|
|
50
49
|
} | undefined, startDoc: PMNode, newTr: Transaction, schema: Schema, trackAttrs: NewEmptyAttrs, insertSlice: ExposedSlice): {
|
|
51
|
-
|
|
50
|
+
sliceWasSplit: boolean;
|
|
52
51
|
newSliceContent: Fragment;
|
|
53
52
|
steps: ChangeStep[];
|
|
54
53
|
};
|
|
@@ -33,4 +33,4 @@ export declare function deleteNode(node: PMNode, pos: number, tr: Transaction):
|
|
|
33
33
|
* @param newTr
|
|
34
34
|
* @param deleteAttrs
|
|
35
35
|
*/
|
|
36
|
-
export declare function deleteOrSetNodeDeleted(node: PMNode, pos: number, newTr: Transaction, deleteAttrs: NewDeleteAttrs):
|
|
36
|
+
export declare function deleteOrSetNodeDeleted(node: PMNode, pos: number, newTr: Transaction, deleteAttrs: NewDeleteAttrs): Transaction | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { Schema } from 'prosemirror-model';
|
|
17
|
+
import { Transaction } from 'prosemirror-state';
|
|
18
|
+
import { Mapping } from 'prosemirror-transform';
|
|
19
|
+
import { TrackedChange } from '../types/change';
|
|
20
|
+
/**
|
|
21
|
+
* Applies the accepted/rejected changes in the current document and sets them untracked
|
|
22
|
+
*
|
|
23
|
+
* @param tr
|
|
24
|
+
* @param schema
|
|
25
|
+
* @param changes
|
|
26
|
+
* @param deleteMap
|
|
27
|
+
*/
|
|
28
|
+
export declare function applyAcceptedRejectedChanges(tr: Transaction, schema: Schema, changes: TrackedChange[], deleteMap?: Mapping): Mapping;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { Transaction } from 'prosemirror-state';
|
|
18
|
+
/**
|
|
19
|
+
* Deletes node but tries to leave its content intact by trying to unwrap it first
|
|
20
|
+
*
|
|
21
|
+
* Incase unwrapping doesn't work deletes the whole node.
|
|
22
|
+
* @param node
|
|
23
|
+
* @param pos
|
|
24
|
+
* @param tr
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export declare function deleteNode(node: PMNode, pos: number, tr: Transaction): Transaction;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { EditorState } from 'prosemirror-state';
|
|
17
|
+
import { ChangeSet } from '../ChangeSet';
|
|
18
|
+
/**
|
|
19
|
+
* Finds all changes (basically text marks or node attributes) from document
|
|
20
|
+
*
|
|
21
|
+
* This could be possibly made more efficient by only iterating the sections of doc
|
|
22
|
+
* where changes have been applied. This could attempted with eg findDiffStart
|
|
23
|
+
* but it might be less robust than just using doc.descendants
|
|
24
|
+
* @param state
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export declare function findChanges(state: EditorState): ChangeSet;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { Schema } from 'prosemirror-model';
|
|
17
|
+
import { Transaction } from 'prosemirror-state';
|
|
18
|
+
import { ChangeSet } from '../ChangeSet';
|
|
19
|
+
/**
|
|
20
|
+
* Iterates over a ChangeSet to check all changes have their required attributes
|
|
21
|
+
*
|
|
22
|
+
* This inconsistency might happen due to a bug in the track changes implementation or by a user somehow applying an empty insert/delete mark that doesn't contain proper data. Also this checks the track IDs for duplicates.
|
|
23
|
+
* @param changeSet
|
|
24
|
+
* @param currentUser
|
|
25
|
+
* @param newTr
|
|
26
|
+
* @param schema
|
|
27
|
+
* @return docWasChanged, a boolean
|
|
28
|
+
*/
|
|
29
|
+
export declare function fixInconsistentChanges(changeSet: ChangeSet, trackUserID: string, newTr: Transaction, schema: Schema): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { Transaction } from 'prosemirror-state';
|
|
18
|
+
/**
|
|
19
|
+
* Deletes node but tries to leave its content intact by moving/wrapping it to a node before or after
|
|
20
|
+
* @param node
|
|
21
|
+
* @param pos
|
|
22
|
+
* @param tr
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare function mergeNode(node: PMNode, pos: number, tr: Transaction): Transaction | undefined;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { CHANGE_OPERATION, TrackedAttrs } from '../types/change';
|
|
18
|
+
export declare function addTrackIdIfDoesntExist(attrs: Partial<TrackedAttrs>): Partial<TrackedAttrs>;
|
|
19
|
+
export declare function getInlineNodeTrackedMarkData(node: PMNode | undefined | null, schema: Schema): (Omit<Partial<TrackedAttrs>, "operation"> & {
|
|
20
|
+
operation: CHANGE_OPERATION;
|
|
21
|
+
}) | undefined;
|
|
22
|
+
export declare function getNodeTrackedData(node: PMNode | undefined | null, schema: Schema): Partial<TrackedAttrs> | undefined;
|
|
23
|
+
export declare function equalMarks(n1: PMNode, n2: PMNode): boolean;
|
|
24
|
+
export declare function shouldMergeTrackedAttributes(left?: Partial<TrackedAttrs>, right?: Partial<TrackedAttrs>): boolean;
|
|
25
|
+
export declare function getMergeableMarkTrackedAttrs(node: PMNode | undefined | null, attrs: Partial<TrackedAttrs>, schema: Schema): (Omit<Partial<TrackedAttrs>, "operation"> & {
|
|
26
|
+
operation: CHANGE_OPERATION;
|
|
27
|
+
}) | null;
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { Fragment, Node as PMNode, Schema } from 'prosemirror-model';
|
|
17
|
+
import type { Transaction } from 'prosemirror-state';
|
|
18
|
+
import { Mapping } from 'prosemirror-transform';
|
|
19
|
+
import { ExposedSlice } from '../../types/pm';
|
|
20
|
+
import { NewEmptyAttrs } from '../../types/track';
|
|
21
|
+
/**
|
|
22
|
+
* Applies deletion to the doc without actually deleting nodes that have not been inserted
|
|
23
|
+
*
|
|
24
|
+
* The hairiest part of this whole library which does a fair bit of magic to split the inserted slice
|
|
25
|
+
* into pieces that can be inserted without deleting nodes in the doc. Basically we first split the
|
|
26
|
+
* inserted slice into merged pieces _if_ the slice was open on either end. Then, we iterate over the deleted
|
|
27
|
+
* range and see if the node in question was completely wrapped in the range (therefore fully deleted)
|
|
28
|
+
* or only partially deleted by the slice. In that case, we merge the content from the inserted slice
|
|
29
|
+
* and keep the original nodes if they do not contain insert attributes.
|
|
30
|
+
*
|
|
31
|
+
* It is definitely a messy function but so far this seems to have been the best approach to prevent
|
|
32
|
+
* deletion of nodes with open slices. Other option would be to allow the deletions to take place but that
|
|
33
|
+
* requires then inserting the deleted nodes back to the doc if their deletion should be prevented, which does
|
|
34
|
+
* not seem trivial either.
|
|
35
|
+
*
|
|
36
|
+
* @param from start of the deleted range
|
|
37
|
+
* @param to end of the deleted range
|
|
38
|
+
* @param gap retained content in a ReplaceAroundStep, not deleted
|
|
39
|
+
* @param startDoc doc before the deletion
|
|
40
|
+
* @param newTr the new track transaction
|
|
41
|
+
* @param schema ProseMirror schema
|
|
42
|
+
* @param deleteAttrs attributes for the dataTracked object
|
|
43
|
+
* @param insertSlice the inserted slice from ReplaceStep
|
|
44
|
+
* @returns mapping adjusted by the applied operations & modified insert slice
|
|
45
|
+
*/
|
|
46
|
+
export declare function deleteAndMergeSplitNodes(from: number, to: number, gap: {
|
|
47
|
+
start: number;
|
|
48
|
+
end: number;
|
|
49
|
+
} | undefined, startDoc: PMNode, newTr: Transaction, schema: Schema, trackAttrs: NewEmptyAttrs, insertSlice: ExposedSlice): {
|
|
50
|
+
deleteMap: Mapping;
|
|
51
|
+
mergedInsertPos: undefined;
|
|
52
|
+
newSliceContent: Fragment;
|
|
53
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* Merges tracked marks between text nodes at a position
|
|
20
|
+
*
|
|
21
|
+
* Will work for any nodes that use tracked_insert or tracked_delete marks which may not be preferrable
|
|
22
|
+
* if used for block nodes (since we possibly want to show the individual changed nodes).
|
|
23
|
+
* Merging is done based on the userID, operation type and status.
|
|
24
|
+
* @param pos
|
|
25
|
+
* @param doc
|
|
26
|
+
* @param newTr
|
|
27
|
+
* @param schema
|
|
28
|
+
*/
|
|
29
|
+
export declare function mergeTrackedMarks(pos: number, doc: PMNode, newTr: Transaction, schema: Schema): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { Fragment, Schema } from 'prosemirror-model';
|
|
17
|
+
import { NewInsertAttrs } from '../../types/track';
|
|
18
|
+
export declare function setFragmentAsInserted(inserted: Fragment, insertAttrs: NewInsertAttrs, schema: Schema): Fragment;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { NewDeleteAttrs, NewEmptyAttrs, NewInsertAttrs } from '../../types/track';
|
|
17
|
+
export declare function createNewInsertAttrs(attrs: NewEmptyAttrs): NewInsertAttrs;
|
|
18
|
+
export declare function createNewDeleteAttrs(attrs: NewEmptyAttrs): NewDeleteAttrs;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
+
import { ReplaceAroundStep } from 'prosemirror-transform';
|
|
3
|
+
import { NewEmptyAttrs } from '../../types/track';
|
|
4
|
+
export declare function trackReplaceAroundStep(step: ReplaceAroundStep, oldState: EditorState, newTr: Transaction, attrs: NewEmptyAttrs): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
+
import { ReplaceStep } from 'prosemirror-transform';
|
|
3
|
+
import { NewEmptyAttrs } from '../../types/track';
|
|
4
|
+
export declare function trackReplaceStep(step: ReplaceStep, oldState: EditorState, newTr: Transaction, attrs: NewEmptyAttrs): number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
+
/**
|
|
3
|
+
* Inverts transactions to wrap their contents/operations with track data instead
|
|
4
|
+
*
|
|
5
|
+
* The main function of track changes that holds the most complex parts of this whole library.
|
|
6
|
+
* Takes in as arguments the data from appendTransaction to reapply it with the track marks/attributes.
|
|
7
|
+
* We could prevent the initial transaction from being applied all together but since invert works just
|
|
8
|
+
* as well and we can use the intermediate doc for checking which nodes are changed, it's not prevented.
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* @param tr Original transaction
|
|
12
|
+
* @param oldState State before transaction
|
|
13
|
+
* @param newTr Transaction created from the new editor state
|
|
14
|
+
* @param authorID User id
|
|
15
|
+
* @returns newTr that inverts the initial tr and applies track attributes/marks
|
|
16
|
+
*/
|
|
17
|
+
export declare function trackTransaction(tr: Transaction, oldState: EditorState, newTr: Transaction, authorID: string): Transaction;
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { Schema } from 'prosemirror-model';
|
|
17
|
+
import { Transaction } from 'prosemirror-state';
|
|
18
|
+
import { Mapping } from 'prosemirror-transform';
|
|
19
|
+
import { IncompleteChange, TrackedAttrs, TrackedChange } from '../types/change';
|
|
20
|
+
export declare function updateChangeAttrs(tr: Transaction, change: IncompleteChange, trackedAttrs: Partial<TrackedAttrs>, schema: Schema): Transaction;
|
|
21
|
+
export declare function updateChangeChildrenAttributes(changes: TrackedChange[], tr: Transaction, mapping: Mapping): void;
|
package/dist/types/change.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ declare type Change = {
|
|
|
41
41
|
id: string;
|
|
42
42
|
from: number;
|
|
43
43
|
to: number;
|
|
44
|
-
|
|
44
|
+
dataTracked: TrackedAttrs;
|
|
45
45
|
};
|
|
46
46
|
export declare type TextChange = Change & {
|
|
47
47
|
type: 'text-change';
|
|
@@ -66,11 +66,11 @@ export declare type MarkChange = Change & {
|
|
|
66
66
|
type: 'mark-change';
|
|
67
67
|
};
|
|
68
68
|
export declare type TrackedChange = TextChange | NodeChange | NodeAttrChange | WrapChange | MarkChange;
|
|
69
|
-
export declare type PartialChange<T extends TrackedChange> = Omit<T, '
|
|
70
|
-
|
|
69
|
+
export declare type PartialChange<T extends TrackedChange> = Omit<T, 'dataTracked'> & {
|
|
70
|
+
dataTracked: Partial<TrackedAttrs>;
|
|
71
71
|
};
|
|
72
|
-
export declare type IncompleteChange = Omit<TrackedChange, '
|
|
73
|
-
|
|
72
|
+
export declare type IncompleteChange = Omit<TrackedChange, 'dataTracked'> & {
|
|
73
|
+
dataTracked: Partial<TrackedAttrs>;
|
|
74
74
|
};
|
|
75
75
|
export declare type ChangeType = TrackedChange['type'];
|
|
76
76
|
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
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 { EditorState, Transaction } from 'prosemirror-state';
|
|
17
|
+
import { EditorView } from 'prosemirror-view';
|
|
18
|
+
export declare type Commands = {
|
|
19
|
+
[name: string]: (...args: any[]) => Command;
|
|
20
|
+
};
|
|
21
|
+
export declare type CommandDispatch = (tr: Transaction) => void;
|
|
22
|
+
export declare type Command = (state: EditorState, dispatch?: CommandDispatch, view?: EditorView) => boolean;
|
|
23
|
+
export declare type HigherOrderCommand = (command: Command) => Command;
|
package/dist/types/step.d.ts
CHANGED
|
@@ -40,13 +40,14 @@ export interface MergeFragmentStep {
|
|
|
40
40
|
export interface InsertSliceStep {
|
|
41
41
|
from: number;
|
|
42
42
|
to: number;
|
|
43
|
+
sliceWasSplit: boolean;
|
|
43
44
|
type: 'insert-slice';
|
|
44
45
|
slice: ExposedSlice;
|
|
45
46
|
}
|
|
46
47
|
export interface UpdateNodeAttrsStep {
|
|
47
48
|
pos: number;
|
|
48
49
|
type: 'update-node-attrs';
|
|
49
|
-
|
|
50
|
+
node: PMNode;
|
|
50
51
|
newAttrs: Record<string, any>;
|
|
51
52
|
}
|
|
52
53
|
export declare type ChangeStep = DeleteNodeStep | DeleteTextStep | MergeFragmentStep | InsertSliceStep | UpdateNodeAttrsStep;
|
package/dist/types/track.d.ts
CHANGED
|
@@ -33,7 +33,11 @@ export declare type NewInsertAttrs = Omit<TrackedAttrs, 'id' | 'operation'> & {
|
|
|
33
33
|
export declare type NewDeleteAttrs = Omit<TrackedAttrs, 'id' | 'operation'> & {
|
|
34
34
|
operation: CHANGE_OPERATION.delete;
|
|
35
35
|
};
|
|
36
|
-
export declare type
|
|
36
|
+
export declare type NewUpdateAttrs = Omit<TrackedAttrs, 'id' | 'operation'> & {
|
|
37
|
+
operation: CHANGE_OPERATION.set_node_attributes;
|
|
38
|
+
oldAttrs: Record<string, any>;
|
|
39
|
+
};
|
|
40
|
+
export declare type NewTrackedAttrs = NewInsertAttrs | NewDeleteAttrs | NewUpdateAttrs;
|
|
37
41
|
export declare enum TrackChangesStatus {
|
|
38
42
|
enabled = "enabled",
|
|
39
43
|
viewSnapshots = "view-snapshots",
|
|
@@ -1,18 +1,4 @@
|
|
|
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 { NewDeleteAttrs, NewEmptyAttrs, NewInsertAttrs } from '../types/track';
|
|
1
|
+
import { NewDeleteAttrs, NewEmptyAttrs, NewInsertAttrs, NewUpdateAttrs } from '../types/track';
|
|
17
2
|
export declare function createNewInsertAttrs(attrs: NewEmptyAttrs): NewInsertAttrs;
|
|
18
3
|
export declare function createNewDeleteAttrs(attrs: NewEmptyAttrs): NewDeleteAttrs;
|
|
4
|
+
export declare function createNewUpdateAttrs(attrs: NewEmptyAttrs, oldAttrs: Record<string, any>): NewUpdateAttrs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/track-changes-plugin",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
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",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"jsdom": "^19.0.0",
|
|
32
32
|
"prosemirror-commands": "^1.3.0",
|
|
33
33
|
"prosemirror-example-setup": "^1.2.1",
|
|
34
|
+
"prosemirror-history": "^1.3.0",
|
|
34
35
|
"prosemirror-keymap": "^1.2.0",
|
|
35
36
|
"prosemirror-model": "^1.18.1",
|
|
36
37
|
"prosemirror-schema-list": "^1.2.0",
|