@manuscripts/track-changes-plugin 0.4.1 → 0.4.3

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.
@@ -1,28 +0,0 @@
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;
@@ -1,27 +0,0 @@
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;
@@ -1,27 +0,0 @@
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;
@@ -1,29 +0,0 @@
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;
@@ -1,25 +0,0 @@
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;
@@ -1,27 +0,0 @@
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;
@@ -1,53 +0,0 @@
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
- };
@@ -1,29 +0,0 @@
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;
@@ -1,18 +0,0 @@
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;
@@ -1,18 +0,0 @@
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;
@@ -1,4 +0,0 @@
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;
@@ -1,4 +0,0 @@
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;
@@ -1,17 +0,0 @@
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;
@@ -1,21 +0,0 @@
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;
@@ -1,23 +0,0 @@
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;