@manuscripts/track-changes-plugin 2.0.10 → 2.0.12

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.
Files changed (39) hide show
  1. package/dist/cjs/ChangeSet.js +17 -0
  2. package/dist/cjs/actions.js +2 -0
  3. package/dist/cjs/change-steps/processChangeSteps.js +16 -9
  4. package/dist/cjs/changes/applyChanges.js +56 -12
  5. package/dist/cjs/changes/updateChangeAttrs.js +7 -0
  6. package/dist/cjs/changes/updateChangesStatus.js +2 -2
  7. package/dist/cjs/compute/setFragmentAsInserted.js +2 -2
  8. package/dist/cjs/index.js +3 -1
  9. package/dist/cjs/mutate/deleteNode.js +20 -2
  10. package/dist/cjs/mutate/dropStructureChange.js +106 -0
  11. package/dist/cjs/steps/trackReplaceStep.js +13 -8
  12. package/dist/cjs/steps/trackTransaction.js +30 -7
  13. package/dist/cjs/types/change.js +1 -0
  14. package/dist/cjs/utils/track-utils.js +35 -4
  15. package/dist/es/ChangeSet.js +17 -0
  16. package/dist/es/actions.js +2 -0
  17. package/dist/es/change-steps/processChangeSteps.js +16 -9
  18. package/dist/es/changes/applyChanges.js +58 -14
  19. package/dist/es/changes/updateChangeAttrs.js +6 -0
  20. package/dist/es/changes/updateChangesStatus.js +2 -2
  21. package/dist/es/compute/setFragmentAsInserted.js +2 -2
  22. package/dist/es/index.js +1 -1
  23. package/dist/es/mutate/deleteNode.js +18 -2
  24. package/dist/es/mutate/dropStructureChange.js +100 -0
  25. package/dist/es/steps/trackReplaceStep.js +14 -9
  26. package/dist/es/steps/trackTransaction.js +31 -8
  27. package/dist/es/types/change.js +1 -0
  28. package/dist/es/utils/track-utils.js +31 -3
  29. package/dist/types/ChangeSet.d.ts +2 -1
  30. package/dist/types/actions.d.ts +8 -2
  31. package/dist/types/changes/updateChangeAttrs.d.ts +1 -0
  32. package/dist/types/compute/setFragmentAsInserted.d.ts +2 -2
  33. package/dist/types/index.d.ts +1 -1
  34. package/dist/types/mutate/deleteNode.d.ts +1 -0
  35. package/dist/types/mutate/dropStructureChange.d.ts +6 -0
  36. package/dist/types/types/change.d.ts +8 -2
  37. package/dist/types/types/track.d.ts +6 -2
  38. package/dist/types/utils/track-utils.d.ts +6 -3
  39. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import { NodeSelection as NodeSelectionClass, TextSelection, } from 'prosemirror-state';
2
2
  import { AddMarkStep, AttrStep, Mapping, ReplaceAroundStep, ReplaceStep, } from 'prosemirror-transform';
3
+ import { getAction, TrackChangesAction } from '../actions';
3
4
  import { diffChangeSteps } from '../change-steps/diffChangeSteps';
4
5
  import { processChangeSteps } from '../change-steps/processChangeSteps';
5
6
  import { updateChangeAttrs } from '../changes/updateChangeAttrs';
@@ -7,7 +8,7 @@ import { getNodeTrackedData } from '../compute/nodeHelpers';
7
8
  import { CHANGE_STATUS } from '../types/change';
8
9
  import { log } from '../utils/logger';
9
10
  import { mapChangeSteps } from '../utils/mapChangeStep';
10
- import { filterMeaninglessMoveSteps, handleDirectPendingMoveDeletions, HasMoveOperations, } from '../utils/track-utils';
11
+ import { filterMeaninglessMoveSteps, handleDirectPendingMoveDeletions, HasMoveOperations, isStructureSteps, } from '../utils/track-utils';
11
12
  import { uuidv4 } from '../utils/uuidv4';
12
13
  import trackAttrsChange from './trackAttrsChange';
13
14
  import { trackReplaceAroundStep } from './trackReplaceAroundStep';
@@ -15,7 +16,7 @@ import { trackReplaceStep } from './trackReplaceStep';
15
16
  const getSelectionStaticConstructor = (sel) => Object.getPrototypeOf(sel).constructor;
16
17
  const isHighlightMarkerNode = (node) => node && node.type === node.type.schema.nodes.highlight_marker;
17
18
  export function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
18
- var _a, _b, _c, _d, _e;
19
+ var _a, _b, _c, _d, _e, _f;
19
20
  const emptyAttrs = {
20
21
  authorID,
21
22
  reviewedByID: null,
@@ -24,13 +25,23 @@ export function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
24
25
  statusUpdateAt: 0,
25
26
  status: CHANGE_STATUS.pending,
26
27
  };
28
+ const action = (_a = getAction(tr, TrackChangesAction.indentationAction)) === null || _a === void 0 ? void 0 : _a.action;
29
+ const isIndentation = action === 'indent' || action === 'unindent';
27
30
  const wasNodeSelection = tr.selection instanceof NodeSelectionClass;
28
31
  const setsNewSelection = tr.selectionSet;
29
32
  const deletedNodeMapping = new Mapping();
30
33
  let iters = 0;
31
34
  log.info('ORIGINAL transaction', tr);
32
35
  let trContext = {};
33
- const movingStepsAssociated = HasMoveOperations(tr);
36
+ let movingStepsAssociated = HasMoveOperations(tr);
37
+ if (isIndentation) {
38
+ const moveId = uuidv4();
39
+ tr.steps.forEach((step) => {
40
+ if (step instanceof ReplaceStep) {
41
+ movingStepsAssociated.set(step, moveId);
42
+ }
43
+ });
44
+ }
34
45
  handleDirectPendingMoveDeletions(tr, newTr, movingStepsAssociated);
35
46
  const cleanSteps = filterMeaninglessMoveSteps(tr, movingStepsAssociated);
36
47
  for (let i = cleanSteps.length - 1; i >= 0; i--) {
@@ -51,13 +62,13 @@ export function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
51
62
  }
52
63
  else if (step instanceof ReplaceStep) {
53
64
  const { slice } = step;
54
- if (((_b = (_a = slice === null || slice === void 0 ? void 0 : slice.content) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.length) === 1 && isHighlightMarkerNode(slice.content.content[0])) {
65
+ if (((_c = (_b = slice === null || slice === void 0 ? void 0 : slice.content) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.length) === 1 && isHighlightMarkerNode(slice.content.content[0])) {
55
66
  continue;
56
67
  }
57
68
  const invertedStep = step.invert(tr.docs[i]);
58
69
  const isDelete = step.from !== step.to && step.slice.content.size < invertedStep.slice.content.size;
59
70
  let thisStepMapping = tr.mapping.slice(i + 1, i + 1);
60
- if (isDelete) {
71
+ if (isDelete || isStructureSteps(tr)) {
61
72
  thisStepMapping = deletedNodeMapping;
62
73
  }
63
74
  const newStep = new ReplaceStep(thisStepMapping.map(invertedStep.from), thisStepMapping.map(invertedStep.to), invertedStep.slice);
@@ -65,7 +76,7 @@ export function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
65
76
  let [steps, startPos] = trackReplaceStep(step, oldState, newTr, emptyAttrs, stepResult, tr.docs[i], tr, movingStepsAssociated.get(step));
66
77
  if (steps.length === 1) {
67
78
  const step = steps[0];
68
- if (isHighlightMarkerNode((step === null || step === void 0 ? void 0 : step.node) || ((_d = (_c = step === null || step === void 0 ? void 0 : step.slice) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.content[0]))) {
79
+ if (isHighlightMarkerNode((step === null || step === void 0 ? void 0 : step.node) || ((_e = (_d = step === null || step === void 0 ? void 0 : step.slice) === null || _d === void 0 ? void 0 : _d.content) === null || _e === void 0 ? void 0 : _e.content[0]))) {
69
80
  continue;
70
81
  }
71
82
  }
@@ -98,7 +109,7 @@ export function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
98
109
  const [mapping, selectionPos] = processChangeSteps(changeSteps, tr.selection.from, newTr, emptyAttrs, oldState.schema, deletedNodeMapping);
99
110
  }
100
111
  else if (step instanceof AddMarkStep) {
101
- const dataTracked = (_e = getNodeTrackedData(newTr.doc.nodeAt(step.from), oldState.schema)) === null || _e === void 0 ? void 0 : _e.pop();
112
+ const dataTracked = (_f = getNodeTrackedData(newTr.doc.nodeAt(step.from), oldState.schema)) === null || _f === void 0 ? void 0 : _f.pop();
102
113
  if (dataTracked) {
103
114
  updateChangeAttrs(newTr, { id: dataTracked.id, from: step.from, to: step.to, type: 'text-change', dataTracked }, Object.assign(Object.assign({}, dataTracked), { id: uuidv4() }), oldState.schema);
104
115
  }
@@ -107,7 +118,19 @@ export function trackTransaction(tr, oldState, newTr, authorID, changeSet) {
107
118
  tr.getMeta('uiEvent') && newTr.setMeta('uiEvent', tr.getMeta('uiEvent'));
108
119
  }
109
120
  if (setsNewSelection && tr.selection instanceof TextSelection) {
110
- const newPos = newTr.doc.resolve(tr.selection.from);
121
+ let from = tr.selection.from;
122
+ if (isStructureSteps(tr)) {
123
+ const selectionMapping = new Mapping();
124
+ tr.steps.map((step) => {
125
+ const isDeleteStep = step instanceof ReplaceStep && step.from !== step.to && step.slice.size === 0;
126
+ if (isDeleteStep) {
127
+ selectionMapping.appendMap(step.getMap().invert());
128
+ }
129
+ });
130
+ selectionMapping.appendMapping(deletedNodeMapping);
131
+ from = selectionMapping.map(tr.selection.from);
132
+ }
133
+ const newPos = newTr.doc.resolve(from);
111
134
  newTr.setSelection(new TextSelection(newPos));
112
135
  }
113
136
  if (wasNodeSelection) {
@@ -22,6 +22,7 @@ export var CHANGE_OPERATION;
22
22
  CHANGE_OPERATION["node_split"] = "node_split";
23
23
  CHANGE_OPERATION["reference"] = "reference";
24
24
  CHANGE_OPERATION["move"] = "move";
25
+ CHANGE_OPERATION["structure"] = "structure";
25
26
  })(CHANGE_OPERATION || (CHANGE_OPERATION = {}));
26
27
  export var CHANGE_STATUS;
27
28
  (function (CHANGE_STATUS) {
@@ -9,7 +9,9 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
+ import { Fragment } from 'prosemirror-model';
12
13
  import { ReplaceStep } from 'prosemirror-transform';
14
+ import { TrackChangesAction } from '../actions';
13
15
  import { CHANGE_OPERATION, CHANGE_STATUS } from '../types/change';
14
16
  import { uuidv4 } from './uuidv4';
15
17
  export function createNewInsertAttrs(attrs) {
@@ -27,13 +29,16 @@ export function createNewReferenceAttrs(attrs, id) {
27
29
  export function createNewDeleteAttrs(attrs) {
28
30
  return Object.assign(Object.assign({}, attrs), { operation: CHANGE_OPERATION.delete });
29
31
  }
30
- export function createNewMoveAttrs(attrs) {
31
- return Object.assign(Object.assign({}, attrs), { operation: CHANGE_OPERATION.move });
32
+ export function createNewMoveAttrs(attrs, indentationType) {
33
+ return Object.assign(Object.assign(Object.assign({}, attrs), { operation: CHANGE_OPERATION.move }), (indentationType && { indentationType }));
32
34
  }
33
35
  export function createNewUpdateAttrs(attrs, oldAttrs) {
34
36
  const { dataTracked } = oldAttrs, restAttrs = __rest(oldAttrs, ["dataTracked"]);
35
37
  return Object.assign(Object.assign({}, attrs), { operation: CHANGE_OPERATION.set_node_attributes, oldAttrs: JSON.parse(JSON.stringify(restAttrs)) });
36
38
  }
39
+ export function createNewStructureAttrs(attrs) {
40
+ return Object.assign(Object.assign({}, attrs), { operation: CHANGE_OPERATION.structure });
41
+ }
37
42
  export const isSplitStep = (step, selection, uiEvent) => {
38
43
  var _a, _b, _c, _d;
39
44
  const { from, to, slice } = step;
@@ -75,12 +80,22 @@ export const isLiftStep = (step) => {
75
80
  export function stepIsLift(gap, node, to) {
76
81
  return gap.start < gap.end && gap.insert === 0 && gap.end === to && !node.isText;
77
82
  }
83
+ export const isStructureSteps = (tr) => tr.getMeta(TrackChangesAction.structuralChangeAction) &&
84
+ tr.steps.length === 2 &&
85
+ tr.steps[0] instanceof ReplaceStep &&
86
+ tr.steps[1] instanceof ReplaceStep;
78
87
  export const trFromHistory = (tr) => Object.keys(tr.meta).find((s) => s.startsWith('history$'));
79
88
  export const HasMoveOperations = (tr) => {
80
89
  const movingAssoc = new Map();
81
90
  if (tr.steps.length < 2) {
82
91
  return movingAssoc;
83
92
  }
93
+ if (tr.getMeta(TrackChangesAction.structuralChangeAction)) {
94
+ const commonID = uuidv4();
95
+ movingAssoc.set(tr.steps[0], commonID);
96
+ movingAssoc.set(tr.steps[1], commonID);
97
+ return movingAssoc;
98
+ }
84
99
  const matched = [];
85
100
  for (let i = 0; i < tr.steps.length; i++) {
86
101
  if (matched.includes(i)) {
@@ -191,7 +206,7 @@ export const filterMeaninglessMoveSteps = (tr, movingSteps) => {
191
206
  });
192
207
  continue;
193
208
  }
194
- if (step instanceof ReplaceStep) {
209
+ if (step instanceof ReplaceStep && !tr.getMeta(TrackChangesAction.structuralChangeAction)) {
195
210
  const { slice } = step;
196
211
  if ((_a = slice === null || slice === void 0 ? void 0 : slice.content) === null || _a === void 0 ? void 0 : _a.firstChild) {
197
212
  const insertedNode = slice.content.firstChild;
@@ -208,3 +223,16 @@ export const filterMeaninglessMoveSteps = (tr, movingSteps) => {
208
223
  }
209
224
  return cleanSteps;
210
225
  };
226
+ export const updateBlockNodesAttrs = (fragment, predicate) => {
227
+ const updatedNodes = [];
228
+ fragment.forEach((child) => {
229
+ if (!child.isBlock) {
230
+ updatedNodes.push(child);
231
+ return;
232
+ }
233
+ const newContent = child.content.size ? updateBlockNodesAttrs(child.content, predicate) : child.content;
234
+ const newAttrs = predicate(child.attrs, child);
235
+ updatedNodes.push(child.type.create(newAttrs, newContent, child.marks));
236
+ });
237
+ return Fragment.fromArray(updatedNodes);
238
+ };
@@ -1,4 +1,4 @@
1
- import { IncompleteChange, NodeAttrChange, NodeChange, ReferenceChange, TextChange, TrackedAttrs, TrackedChange } from './types/change';
1
+ import { IncompleteChange, NodeAttrChange, NodeChange, ReferenceChange, RootChanges, TextChange, TrackedAttrs, TrackedChange } from './types/change';
2
2
  export declare class ChangeSet {
3
3
  #private;
4
4
  constructor(changes?: (TrackedChange | IncompleteChange)[]);
@@ -23,6 +23,7 @@ export declare class ChangeSet {
23
23
  root: NodeChange;
24
24
  } | undefined;
25
25
  canJoinAdjacentInlineChanges(change: TrackedChange, index: number): boolean | undefined;
26
+ joinRelatedStructuralChanges(rootNodes: RootChanges, change: TrackedChange): true | undefined;
26
27
  static flattenTreeToIds(changes: TrackedChange[]): string[];
27
28
  static shouldDeleteChange(change: TrackedChange): boolean;
28
29
  static isValidDataTracked(dataTracked?: Partial<TrackedAttrs>): boolean;
@@ -1,5 +1,5 @@
1
1
  import { Transaction } from 'prosemirror-state';
2
- import { CHANGE_STATUS } from './types/change';
2
+ import { CHANGE_STATUS, StructureAttrs } from './types/change';
3
3
  import { TrackChangesStatus } from './types/track';
4
4
  export declare enum TrackChangesAction {
5
5
  skipTrack = "track-changes-skip-tracking",
@@ -7,7 +7,9 @@ export declare enum TrackChangesAction {
7
7
  setPluginStatus = "track-changes-set-track-status",
8
8
  setChangeStatuses = "track-changes-set-change-statuses",
9
9
  refreshChanges = "track-changes-refresh-changes",
10
- updateMetaNode = "track-changes-update-meta-node"
10
+ updateMetaNode = "track-changes-update-meta-node",
11
+ structuralChangeAction = "track-changes-structural-change-action",
12
+ indentationAction = "track-changes-indentation-action"
11
13
  }
12
14
  export type TrackChangesActionParams = {
13
15
  [TrackChangesAction.skipTrack]: boolean;
@@ -19,6 +21,10 @@ export type TrackChangesActionParams = {
19
21
  };
20
22
  [TrackChangesAction.refreshChanges]: boolean;
21
23
  [TrackChangesAction.updateMetaNode]: boolean;
24
+ [TrackChangesAction.structuralChangeAction]: StructureAttrs['action'];
25
+ [TrackChangesAction.indentationAction]: {
26
+ action: 'indent' | 'unindent';
27
+ };
22
28
  };
23
29
  export declare function hasAction(tr: Transaction): boolean;
24
30
  export declare function getAction<K extends keyof TrackChangesActionParams>(tr: Transaction, action: K): TrackChangesActionParams[K] | undefined;
@@ -4,3 +4,4 @@ import { Mapping } from 'prosemirror-transform';
4
4
  import { IncompleteChange, TrackedAttrs, TrackedChange } from '../types/change';
5
5
  export declare function updateChangeAttrs(tr: Transaction, change: IncompleteChange, trackedAttrs: Partial<TrackedAttrs>, schema: Schema): Transaction;
6
6
  export declare function updateChangeChildrenAttributes(changes: TrackedChange[], tr: Transaction, mapping: Mapping): void;
7
+ export declare function restoreNode(tr: Transaction, node: any, pos: number, schema: Schema): void;
@@ -1,7 +1,7 @@
1
1
  import { Fragment, ResolvedPos, Schema } from 'prosemirror-model';
2
2
  import { Transaction } from 'prosemirror-state';
3
- import { NewEmptyAttrs, NewInsertAttrs } from '../types/track';
3
+ import { NewEmptyAttrs, NewInsertAttrs, NewMoveAttrs } from '../types/track';
4
4
  export declare function setFragmentAsInserted(inserted: Fragment, insertAttrs: NewInsertAttrs, schema: Schema): Fragment;
5
5
  export declare function setFragmentAsWrapChange(inserted: Fragment, attrs: NewEmptyAttrs, schema: Schema): Fragment;
6
- export declare function setFragmentAsMoveChange(fragment: Fragment, attrs: NewEmptyAttrs): Fragment;
6
+ export declare function setFragmentAsMoveChange(fragment: Fragment, moveAttrs: NewMoveAttrs): Fragment;
7
7
  export declare function setFragmentAsNodeSplit($pos: ResolvedPos, newTr: Transaction, inserted: Fragment, attrs: NewEmptyAttrs): Fragment;
@@ -1,5 +1,5 @@
1
1
  export { trackChangesPluginKey, trackChangesPlugin } from './plugin';
2
- export { skipTracking } from './actions';
2
+ export { skipTracking, setAction, TrackChangesAction } from './actions';
3
3
  export * as trackCommands from './commands';
4
4
  export { enableDebug } from './utils/logger';
5
5
  export { ChangeSet } from './ChangeSet';
@@ -3,3 +3,4 @@ import { Transaction } from 'prosemirror-state';
3
3
  import { NewDeleteAttrs } from '../types/track';
4
4
  export declare function deleteNode(node: PMNode, pos: number, tr: Transaction): Transaction;
5
5
  export declare function deleteOrSetNodeDeleted(node: PMNode, pos: number, newTr: Transaction, deleteAttrs: NewDeleteAttrs): Transaction | undefined;
6
+ export declare const keepDeleteWithMoveNodeId: (node: PMNode) => Partial<import("../types/change").TrackedAttrs>[] | null;
@@ -0,0 +1,6 @@
1
+ import { Fragment } from 'prosemirror-model';
2
+ import { Transaction } from 'prosemirror-state';
3
+ import { NewEmptyAttrs } from '../types/track';
4
+ export declare const dropStructuralChangeShadow: (moveNodeId: string | undefined, tr: Transaction) => Transaction;
5
+ export declare const dropOrphanChanges: (newTr: Transaction, dropDataTracked?: boolean) => void;
6
+ export declare const joinStructureChanges: (attrs: NewEmptyAttrs, sliceContent: Fragment, content: Fragment, tr: Transaction, newTr: Transaction) => Fragment;
@@ -21,7 +21,8 @@ export declare enum CHANGE_OPERATION {
21
21
  wrap_with_node = "wrap_with_node",
22
22
  node_split = "node_split",
23
23
  reference = "reference",
24
- move = "move"
24
+ move = "move",
25
+ structure = "structure"
25
26
  }
26
27
  export declare enum CHANGE_STATUS {
27
28
  accepted = "accepted",
@@ -55,8 +56,13 @@ export type ReferenceAttrs = Omit<InsertDeleteAttrs, 'operation'> & {
55
56
  };
56
57
  export type NodeMoveAttrs = Omit<InsertDeleteAttrs, 'operation'> & {
57
58
  operation: CHANGE_OPERATION.move;
59
+ indentationType?: 'indent' | 'unindent';
58
60
  };
59
- export type TrackedAttrs = InsertDeleteAttrs | UpdateAttrs | WrapAttrs | NodeSplitAttrs | ReferenceAttrs | NodeMoveAttrs;
61
+ export type StructureAttrs = Omit<InsertDeleteAttrs, 'operation'> & {
62
+ operation: CHANGE_OPERATION.structure;
63
+ action: string;
64
+ };
65
+ export type TrackedAttrs = InsertDeleteAttrs | UpdateAttrs | WrapAttrs | NodeSplitAttrs | ReferenceAttrs | NodeMoveAttrs | StructureAttrs;
60
66
  type Change = {
61
67
  id: string;
62
68
  from: number;
@@ -16,7 +16,7 @@ export interface TrackChangesState {
16
16
  }
17
17
  export type NewEmptyAttrs = Omit<TrackedAttrs, 'id' | 'operation'>;
18
18
  export type NewInsertAttrs = Omit<TrackedAttrs, 'id' | 'operation'> & {
19
- operation: CHANGE_OPERATION.insert | CHANGE_OPERATION.wrap_with_node | CHANGE_OPERATION.move;
19
+ operation: CHANGE_OPERATION.insert | CHANGE_OPERATION.wrap_with_node | CHANGE_OPERATION.structure;
20
20
  };
21
21
  export type NewDeleteAttrs = Omit<TrackedAttrs, 'id' | 'operation'> & {
22
22
  operation: CHANGE_OPERATION.delete;
@@ -28,11 +28,15 @@ export type NewUpdateAttrs = Omit<TrackedAttrs, 'id' | 'operation'> & {
28
28
  export type NewSplitNodeAttrs = Omit<TrackedAttrs, 'id' | 'operation'> & {
29
29
  operation: CHANGE_OPERATION.node_split;
30
30
  };
31
+ export type NewMoveAttrs = Omit<TrackedAttrs, 'id' | 'operation'> & {
32
+ operation: CHANGE_OPERATION.move;
33
+ indentationType?: 'indent' | 'unindent';
34
+ };
31
35
  export type NewReferenceAttrs = Omit<TrackedAttrs, 'id' | 'operation'> & {
32
36
  operation: CHANGE_OPERATION.reference;
33
37
  referenceId: string;
34
38
  };
35
- export type NewTrackedAttrs = NewInsertAttrs | NewDeleteAttrs | NewUpdateAttrs;
39
+ export type NewTrackedAttrs = NewInsertAttrs | NewDeleteAttrs | NewUpdateAttrs | NewMoveAttrs;
36
40
  export declare enum TrackChangesStatus {
37
41
  enabled = "enabled",
38
42
  viewSnapshots = "view-snapshots",
@@ -1,15 +1,16 @@
1
- import { Node as PMNode, Slice } from 'prosemirror-model';
1
+ import { Attrs, Fragment, Node as PMNode, Slice } from 'prosemirror-model';
2
2
  import { Selection, Transaction } from 'prosemirror-state';
3
3
  import { ReplaceAroundStep, ReplaceStep, Step } from 'prosemirror-transform';
4
4
  import { CHANGE_OPERATION, TrackedAttrs } from '../types/change';
5
- import { NewDeleteAttrs, NewEmptyAttrs, NewInsertAttrs, NewReferenceAttrs, NewSplitNodeAttrs, NewUpdateAttrs } from '../types/track';
5
+ import { NewDeleteAttrs, NewEmptyAttrs, NewInsertAttrs, NewMoveAttrs, NewReferenceAttrs, NewSplitNodeAttrs, NewUpdateAttrs } from '../types/track';
6
6
  export declare function createNewInsertAttrs(attrs: NewEmptyAttrs): NewInsertAttrs;
7
7
  export declare function createNewWrapAttrs(attrs: NewEmptyAttrs): NewInsertAttrs;
8
8
  export declare function createNewSplitAttrs(attrs: NewEmptyAttrs): NewSplitNodeAttrs;
9
9
  export declare function createNewReferenceAttrs(attrs: NewEmptyAttrs, id: string): NewReferenceAttrs;
10
10
  export declare function createNewDeleteAttrs(attrs: NewEmptyAttrs): NewDeleteAttrs;
11
- export declare function createNewMoveAttrs(attrs: NewEmptyAttrs): NewInsertAttrs;
11
+ export declare function createNewMoveAttrs(attrs: NewEmptyAttrs, indentationType?: 'indent' | 'unindent'): NewMoveAttrs;
12
12
  export declare function createNewUpdateAttrs(attrs: NewEmptyAttrs, oldAttrs: Record<string, any>): NewUpdateAttrs;
13
+ export declare function createNewStructureAttrs(attrs: NewEmptyAttrs): NewInsertAttrs;
13
14
  export declare const isSplitStep: (step: ReplaceStep, selection: Selection, uiEvent: string) => boolean;
14
15
  export declare const isWrapStep: (step: ReplaceAroundStep) => boolean;
15
16
  export declare const isLiftStep: (step: ReplaceAroundStep) => boolean;
@@ -19,6 +20,7 @@ export declare function stepIsLift(gap: {
19
20
  slice: Slice;
20
21
  insert: number;
21
22
  }, node: PMNode, to: number): boolean;
23
+ export declare const isStructureSteps: (tr: Transaction) => any;
22
24
  export declare const trFromHistory: (tr: Transaction) => string | undefined;
23
25
  export declare const HasMoveOperations: (tr: Transaction) => Map<ReplaceStep, string>;
24
26
  export declare const isPendingChange: (trackedAttrs: TrackedAttrs[] | undefined, operation: CHANGE_OPERATION) => boolean;
@@ -26,3 +28,4 @@ export declare const isDeletingPendingMovedNode: (step: ReplaceStep, doc: PMNode
26
28
  export declare const isDirectPendingMoveDeletion: (step: ReplaceStep, doc: PMNode, movingSteps: Map<ReplaceStep, string>) => boolean;
27
29
  export declare const handleDirectPendingMoveDeletions: (tr: Transaction, newTr: Transaction, movingSteps: Map<ReplaceStep, string>) => void;
28
30
  export declare const filterMeaninglessMoveSteps: (tr: Transaction, movingSteps: Map<ReplaceStep, string>) => Step[];
31
+ export declare const updateBlockNodesAttrs: (fragment: Fragment, predicate: (attrs: Attrs, node: PMNode) => Attrs) => Fragment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manuscripts/track-changes-plugin",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "author": "Atypon Systems LLC",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/Atypon-OpenSource/manuscripts-track-changes-plugin",