@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.
@@ -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
@@ -70,4 +71,5 @@ export declare class ChangeSet {
70
71
  static isValidTrackedAttrs(attrs?: Partial<TrackedAttrs>): boolean;
71
72
  static isTextChange(change: TrackedChange): change is TextChange;
72
73
  static isNodeChange(change: TrackedChange): change is NodeChange;
74
+ static isNodeAttrChange(change: TrackedChange): change is NodeAttrChange;
73
75
  }
@@ -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(inDeleted: 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];
File without changes
File without changes
File without changes
@@ -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
@@ -14,5 +14,5 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { Fragment, Schema } from 'prosemirror-model';
17
- import { NewInsertAttrs } from '../../types/track';
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
+ };