@manuscripts/track-changes-plugin 0.3.0 → 0.4.2
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 +6 -8
- package/dist/{track/steps/track-utils.d.ts → change-steps/diffChangeSteps.d.ts} +4 -3
- package/dist/change-steps/matchInserted.d.ts +3 -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 +1 -1
- 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} +3 -2
- package/dist/{track/steps → compute}/setFragmentAsInserted.d.ts +1 -1
- package/dist/compute/splitSliceIntoMergedParts.d.ts +41 -0
- package/dist/index.cjs +749 -393
- package/dist/index.js +749 -393
- package/dist/{track/steps → mutate}/deleteAndMergeSplitNodes.d.ts +5 -5
- 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 +23 -15
- package/dist/types/step.d.ts +53 -0
- package/dist/types/track.d.ts +5 -1
- package/dist/utils/track-utils.d.ts +4 -0
- package/package.json +3 -2
- package/dist/index.es.js +0 -1547
- package/dist/types/editor.d.ts +0 -23
package/dist/ChangeSet.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { NodeChange, IncompleteChange, TextChange, TrackedAttrs, TrackedChange } from './types/change';
|
|
16
|
+
import { NodeChange, IncompleteChange, TextChange, TrackedAttrs, TrackedChange, NodeAttrChange } from './types/change';
|
|
17
17
|
/**
|
|
18
18
|
* ChangeSet is a data structure to contain the tracked changes with some utility methods and computed
|
|
19
19
|
* values to allow easier operability.
|
|
@@ -37,6 +37,8 @@ export declare class ChangeSet {
|
|
|
37
37
|
get rejected(): TrackedChange[];
|
|
38
38
|
get textChanges(): TrackedChange[];
|
|
39
39
|
get nodeChanges(): TrackedChange[];
|
|
40
|
+
get nodeAttrChanges(): TrackedChange[];
|
|
41
|
+
get bothNodeChanges(): TrackedChange[];
|
|
40
42
|
get isEmpty(): boolean;
|
|
41
43
|
/**
|
|
42
44
|
* Used to determine whether `fixInconsistentChanges` has to be executed to replace eg duplicate ids or
|
|
@@ -53,11 +55,6 @@ export declare class ChangeSet {
|
|
|
53
55
|
* @param changes
|
|
54
56
|
*/
|
|
55
57
|
static flattenTreeToIds(changes: TrackedChange[]): string[];
|
|
56
|
-
/**
|
|
57
|
-
* Determines whether a change should not be deleted when applying it to the document.
|
|
58
|
-
* @param change
|
|
59
|
-
*/
|
|
60
|
-
static shouldNotDelete(change: TrackedChange): boolean;
|
|
61
58
|
/**
|
|
62
59
|
* Determines whether a change should be deleted when applying it to the document.
|
|
63
60
|
* @param change
|
|
@@ -65,9 +62,10 @@ export declare class ChangeSet {
|
|
|
65
62
|
static shouldDeleteChange(change: TrackedChange): boolean;
|
|
66
63
|
/**
|
|
67
64
|
* Checks whether change attributes contain all TrackedAttrs keys with non-undefined values
|
|
68
|
-
* @param
|
|
65
|
+
* @param dataTracked
|
|
69
66
|
*/
|
|
70
|
-
static
|
|
67
|
+
static isValidDataTracked(dataTracked?: Partial<TrackedAttrs>): boolean;
|
|
71
68
|
static isTextChange(change: TrackedChange): change is TextChange;
|
|
72
69
|
static isNodeChange(change: TrackedChange): change is NodeChange;
|
|
70
|
+
static isNodeAttrChange(change: TrackedChange): change is NodeAttrChange;
|
|
73
71
|
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
import { Schema } from 'prosemirror-model';
|
|
17
|
+
import type { Transaction } from 'prosemirror-state';
|
|
18
|
+
import { ChangeStep, InsertSliceStep } from '../types/step';
|
|
19
|
+
export declare function diffChangeSteps(deleted: ChangeStep[], inserted: InsertSliceStep[], newTr: Transaction, schema: Schema): ChangeStep[];
|
|
@@ -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 type { Transaction } from 'prosemirror-state';
|
|
18
|
+
import { Mapping } from 'prosemirror-transform';
|
|
19
|
+
import { ChangeStep } from '../types/step';
|
|
20
|
+
import { NewEmptyAttrs } from '../types/track';
|
|
21
|
+
export declare function processChangeSteps(changes: ChangeStep[], startPos: number, newTr: Transaction, emptyAttrs: NewEmptyAttrs, schema: Schema): [Mapping, number];
|
|
File without changes
|
|
File without changes
|
|
@@ -26,4 +26,4 @@ import { ChangeSet } from '../ChangeSet';
|
|
|
26
26
|
* @param schema
|
|
27
27
|
* @return docWasChanged, a boolean
|
|
28
28
|
*/
|
|
29
|
-
export declare function fixInconsistentChanges(changeSet: ChangeSet,
|
|
29
|
+
export declare function fixInconsistentChanges(changeSet: ChangeSet, currentUserID: string, newTr: Transaction, schema: Schema): boolean;
|
|
File without changes
|
package/dist/commands.d.ts
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { Command } from 'prosemirror-state';
|
|
16
17
|
import { CHANGE_STATUS } from './types/change';
|
|
17
|
-
import type { Command } from './types/editor';
|
|
18
18
|
import { TrackChangesStatus } from './types/track';
|
|
19
19
|
/**
|
|
20
20
|
* Sets track-changes plugin's status to any of: 'enabled' 'disabled' 'viewSnapshots'. Passing undefined will
|
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
import { Node as PMNode, Schema } from 'prosemirror-model';
|
|
17
17
|
import { CHANGE_OPERATION, TrackedAttrs } from '../types/change';
|
|
18
18
|
export declare function addTrackIdIfDoesntExist(attrs: Partial<TrackedAttrs>): Partial<TrackedAttrs>;
|
|
19
|
-
export declare function
|
|
19
|
+
export declare function getTextNodeTrackedMarkData(node: PMNode | undefined | null, schema: Schema): (Omit<Partial<TrackedAttrs>, "operation"> & {
|
|
20
20
|
operation: CHANGE_OPERATION;
|
|
21
21
|
}) | undefined;
|
|
22
|
-
export declare function
|
|
22
|
+
export declare function getBlockInlineTrackedData(node: PMNode): Partial<TrackedAttrs>[] | undefined;
|
|
23
|
+
export declare function getNodeTrackedData(node: PMNode | undefined | null, schema: Schema): Partial<TrackedAttrs>[] | undefined;
|
|
23
24
|
export declare function equalMarks(n1: PMNode, n2: PMNode): boolean;
|
|
24
25
|
export declare function shouldMergeTrackedAttributes(left?: Partial<TrackedAttrs>, right?: Partial<TrackedAttrs>): boolean;
|
|
25
26
|
export declare function getMergeableMarkTrackedAttrs(node: PMNode | undefined | null, attrs: Partial<TrackedAttrs>, schema: Schema): (Omit<Partial<TrackedAttrs>, "operation"> & {
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { Fragment, Schema } from 'prosemirror-model';
|
|
17
|
-
import { NewInsertAttrs } from '
|
|
17
|
+
import { NewInsertAttrs } from '../types/track';
|
|
18
18
|
export declare function setFragmentAsInserted(inserted: Fragment, insertAttrs: NewInsertAttrs, schema: Schema): Fragment;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 '../types/pm';
|
|
18
|
+
/**
|
|
19
|
+
* Filters merged nodes from an open insertSlice to manually merge them to prevent unwanted deletions
|
|
20
|
+
*
|
|
21
|
+
* So instead of joining the slice by its open sides, possibly deleting previous nodes, we can push the
|
|
22
|
+
* changed content manually inside the merged nodes.
|
|
23
|
+
* Eg. instead of doing `|<p>asdf</p><p>|bye</p>` automatically, we extract the merged nodes first:
|
|
24
|
+
* {
|
|
25
|
+
* updatedSliceNodes: [<p>asdf</p>],
|
|
26
|
+
* firstMergedNode: <p>bye</p>,
|
|
27
|
+
* lastMergedNode: undefined,
|
|
28
|
+
* }
|
|
29
|
+
* @param insertSlice inserted slice
|
|
30
|
+
*/
|
|
31
|
+
export declare function splitSliceIntoMergedParts(insertSlice: ExposedSlice, mergeEqualSides?: boolean): {
|
|
32
|
+
updatedSliceNodes: PMNode[];
|
|
33
|
+
firstMergedNode: {
|
|
34
|
+
mergedNodeContent: ExposedFragment;
|
|
35
|
+
unmergedContent: ExposedFragment | undefined;
|
|
36
|
+
} | undefined;
|
|
37
|
+
lastMergedNode: {
|
|
38
|
+
mergedNodeContent: ExposedFragment;
|
|
39
|
+
unmergedContent: ExposedFragment | undefined;
|
|
40
|
+
} | undefined;
|
|
41
|
+
};
|