@manuscripts/track-changes-plugin 0.2.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/README.md +15 -42
- package/dist/ChangeSet.d.ts +5 -8
- package/dist/actions.d.ts +7 -0
- package/dist/change-steps/diffChangeSteps.d.ts +21 -0
- package/dist/change-steps/processChangeSteps.d.ts +21 -0
- package/dist/changes/applyChanges.d.ts +28 -0
- package/dist/changes/findChanges.d.ts +27 -0
- package/dist/changes/fixInconsistentChanges.d.ts +29 -0
- package/dist/changes/updateChangeAttrs.d.ts +21 -0
- package/dist/commands.d.ts +1 -1
- package/dist/compute/nodeHelpers.d.ts +28 -0
- package/dist/compute/setFragmentAsInserted.d.ts +18 -0
- package/dist/compute/splitSliceIntoMergedParts.d.ts +41 -0
- package/dist/index.cjs +791 -415
- package/dist/index.d.ts +1 -1
- package/dist/index.js +774 -397
- package/dist/mutate/deleteAndMergeSplitNodes.d.ts +53 -0
- package/dist/mutate/deleteNode.d.ts +36 -0
- package/dist/mutate/deleteText.d.ts +32 -0
- package/dist/mutate/mergeNode.d.ts +25 -0
- package/dist/mutate/mergeTrackedMarks.d.ts +29 -0
- package/dist/steps/trackReplaceAroundStep.d.ts +5 -0
- package/dist/steps/trackReplaceStep.d.ts +5 -0
- package/dist/steps/trackTransaction.d.ts +17 -0
- package/dist/track/node-utils.d.ts +4 -11
- package/dist/track/steps/track-utils.d.ts +0 -1
- package/dist/track/trackTransaction.d.ts +2 -2
- package/dist/types/change.d.ts +27 -16
- 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/README.md
CHANGED
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
ProseMirror plugin to track inserts/deletes to nodes and text.
|
|
4
4
|
|
|
5
|
-
If you have multiple versions of prosemirror packages, ensure that track-changes' dependencies `prosemirror-model` and `prosemirror-transform` are aliased/deduped to same instance. `prosemirror-state` and `prosemirror-view` are only used at type level. [Example](https://github.com/Atypon-OpenSource/manuscripts-quarterback/blob/main/examples-packages/client/vite.config.js).
|
|
6
|
-
|
|
7
|
-
[More detailed overview](https://github.com/Atypon-OpenSource/manuscripts-quarterback/blob/main/quarterback-packages/track-changes-plugin/OVERVIEW.md)
|
|
8
|
-
|
|
9
5
|
## How to use
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
Requires normal ProseMirror editor dependencies.
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
1. Install the plugin: `npm i @manuscripts/track-changes-plugin`
|
|
10
|
+
2. Add it to ProseMirror plugins:
|
|
14
11
|
|
|
15
12
|
```ts
|
|
16
13
|
import { EditorState } from 'prosemirror-state'
|
|
@@ -34,9 +31,9 @@ const view = new EditorView(document.querySelector('#editor') as HTMLElement, {
|
|
|
34
31
|
})
|
|
35
32
|
```
|
|
36
33
|
|
|
37
|
-
where `schema`
|
|
34
|
+
where `schema` contains `dataTracked` attributes for tracked nodes and `tracked_insert` & `tracked_delete` marks as shown here: https://github.com/Atypon-OpenSource/manuscripts-quarterback/blob/main/quarterback-packages/track-changes-plugin/test/utils/schema.ts
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
3. That should start tracking all transactions. You can use the following commands to enable/disable/enter read-only mode:
|
|
40
37
|
|
|
41
38
|
```ts
|
|
42
39
|
import { trackCommands, TrackChangesStatus } from '@manuscripts/track-changes-plugin'
|
|
@@ -54,7 +51,11 @@ trackCommands.setTrackingStatus(TrackChangesStatus.disabled))(view.state, view.d
|
|
|
54
51
|
trackCommands.setTrackingStatus(TrackChangesStatus.viewSnapshots))(view.state, view.dispatch, view)
|
|
55
52
|
```
|
|
56
53
|
|
|
57
|
-
See an example app at https://github.com/Atypon-OpenSource/manuscripts-quarterback/tree/main/examples-packages/client
|
|
54
|
+
See an example app at https://github.com/Atypon-OpenSource/manuscripts-quarterback/tree/main/examples-packages/client for a more complete boilerplate.
|
|
55
|
+
|
|
56
|
+
**NOTE**: If you have multiple versions of prosemirror packages, ensure that track-changes' dependencies `prosemirror-model` and `prosemirror-transform` are aliased/deduped to same instance. `prosemirror-state` and `prosemirror-view` are only used at type level. [Example](https://github.com/Atypon-OpenSource/manuscripts-quarterback/blob/main/examples-packages/client/vite.config.js).
|
|
57
|
+
|
|
58
|
+
[More detailed overview](https://github.com/Atypon-OpenSource/manuscripts-quarterback/blob/main/quarterback-packages/track-changes-plugin/OVERVIEW.md)
|
|
58
59
|
|
|
59
60
|
## API
|
|
60
61
|
|
|
@@ -130,44 +131,16 @@ export const refreshChanges = () => Command
|
|
|
130
131
|
|
|
131
132
|
### Actions
|
|
132
133
|
|
|
133
|
-
Actions are used to access/set transaction meta fields.
|
|
134
|
+
Actions are used to access/set transaction meta fields internally. `skipTracking` is exposed publicly to set track-changes to skip certain transaction.
|
|
134
135
|
|
|
135
136
|
```ts
|
|
136
|
-
export type TrackChangesActionParams = {
|
|
137
|
-
[TrackChangesAction.skipTrack]: boolean
|
|
138
|
-
[TrackChangesAction.setUserID]: string
|
|
139
|
-
[TrackChangesAction.setPluginStatus]: TrackChangesStatus
|
|
140
|
-
[TrackChangesAction.setChangeStatuses]: {
|
|
141
|
-
status: CHANGE_STATUS
|
|
142
|
-
ids: string[]
|
|
143
|
-
}
|
|
144
|
-
[TrackChangesAction.updateChanges]: string[]
|
|
145
|
-
[TrackChangesAction.refreshChanges]: boolean
|
|
146
|
-
[TrackChangesAction.applyAndRemoveChanges]: boolean
|
|
147
|
-
}
|
|
148
137
|
/**
|
|
149
|
-
*
|
|
138
|
+
* Skip tracking for a transaction, use this with caution to avoid race-conditions or just to otherwise
|
|
139
|
+
* omitting applying of track attributes or marks.
|
|
150
140
|
* @param tr
|
|
151
|
-
* @
|
|
141
|
+
* @returns
|
|
152
142
|
*/
|
|
153
|
-
export
|
|
154
|
-
return tr.getMeta(action) as TrackChangesActionParams[K] | undefined
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Use this function to set meta keys to transactions that are consumed by the track-changes-plugin.
|
|
159
|
-
* For example, you can skip tracking of a transaction with setAction(tr, TrackChangesAction.skipTrack, true)
|
|
160
|
-
* @param tr
|
|
161
|
-
* @param action
|
|
162
|
-
* @param payload
|
|
163
|
-
*/
|
|
164
|
-
export function setAction<K extends keyof TrackChangesActionParams>(
|
|
165
|
-
tr: Transaction,
|
|
166
|
-
action: K,
|
|
167
|
-
payload: TrackChangesActionParams[K]
|
|
168
|
-
) {
|
|
169
|
-
return tr.setMeta(action, payload)
|
|
170
|
-
}
|
|
143
|
+
export const skipTracking = (tr: Transaction) => setAction(tr, TrackChangesAction.skipTrack, true)
|
|
171
144
|
```
|
|
172
145
|
|
|
173
146
|
### Types
|
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,7 @@ export declare class ChangeSet {
|
|
|
37
37
|
get rejected(): TrackedChange[];
|
|
38
38
|
get textChanges(): TrackedChange[];
|
|
39
39
|
get nodeChanges(): TrackedChange[];
|
|
40
|
+
get nodeAttrChanges(): TrackedChange[];
|
|
40
41
|
get isEmpty(): boolean;
|
|
41
42
|
/**
|
|
42
43
|
* Used to determine whether `fixInconsistentChanges` has to be executed to replace eg duplicate ids or
|
|
@@ -53,11 +54,6 @@ export declare class ChangeSet {
|
|
|
53
54
|
* @param changes
|
|
54
55
|
*/
|
|
55
56
|
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
57
|
/**
|
|
62
58
|
* Determines whether a change should be deleted when applying it to the document.
|
|
63
59
|
* @param change
|
|
@@ -65,9 +61,10 @@ export declare class ChangeSet {
|
|
|
65
61
|
static shouldDeleteChange(change: TrackedChange): boolean;
|
|
66
62
|
/**
|
|
67
63
|
* Checks whether change attributes contain all TrackedAttrs keys with non-undefined values
|
|
68
|
-
* @param
|
|
64
|
+
* @param dataTracked
|
|
69
65
|
*/
|
|
70
|
-
static
|
|
66
|
+
static isValidDataTracked(dataTracked?: Partial<TrackedAttrs>): boolean;
|
|
71
67
|
static isTextChange(change: TrackedChange): change is TextChange;
|
|
72
68
|
static isNodeChange(change: TrackedChange): change is NodeChange;
|
|
69
|
+
static isNodeAttrChange(change: TrackedChange): change is NodeAttrChange;
|
|
73
70
|
}
|
package/dist/actions.d.ts
CHANGED
|
@@ -51,3 +51,10 @@ export declare function getAction<K extends keyof TrackChangesActionParams>(tr:
|
|
|
51
51
|
* @param payload
|
|
52
52
|
*/
|
|
53
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;
|
|
@@ -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 { ExposedFragment } from '../types/pm';
|
|
19
|
+
import { ChangeStep, InsertSliceStep } from '../types/step';
|
|
20
|
+
export declare function matchInserted(matchedDeleted: number, deleted: ChangeStep[], inserted: ExposedFragment, newTr: Transaction, schema: Schema): [number, ChangeStep[]];
|
|
21
|
+
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];
|
|
@@ -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 { 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, currentUserID: string, newTr: Transaction, schema: Schema): boolean;
|
|
@@ -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/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
|
|
@@ -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 { 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;
|
|
@@ -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,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
|
+
};
|