@magic-marker/prosemirror-suggest-changes 0.3.3-wrap-unwrap.29 → 0.3.3-wrap-unwrap.31

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.
@@ -9,8 +9,6 @@ export declare class EditorPage {
9
9
  getParagraphText(index: number, childIndexes?: number[]): Promise<string>;
10
10
  getParagraphAt(index: number): Locator;
11
11
  getParagraphCount(): Promise<number>;
12
- getListItems(): Locator;
13
- getParagraphs(): Locator;
14
12
  getListItemCount(): Promise<number>;
15
13
  getProseMirrorMarkCount(name: string): Promise<number>;
16
14
  getProseMirrorMarksJSON(): Promise<unknown[]>;
package/dist/commands.js CHANGED
@@ -370,18 +370,11 @@ export function applySuggestionsToRange(doc, from, to) {
370
370
  suggestionsTransform.steps.forEach((step)=>{
371
371
  structureTransform.step(step);
372
372
  });
373
- if (restoredStructureSuggestionIds.has(suggestionId)) {
373
+ restoredStructureSuggestionIds.forEach((suggestionId)=>{
374
374
  const restoredStructureTransform = revertStructureSuggestion(structureTransform.doc, suggestionId);
375
375
  restoredStructureTransform.steps.forEach((step)=>{
376
376
  structureTransform.step(step);
377
377
  });
378
- }
379
- restoredStructureSuggestionIds.forEach((restoredSuggestionId)=>{
380
- if (restoredSuggestionId === suggestionId) return;
381
- const restoredStructureTransform = revertStructureSuggestion(structureTransform.doc, restoredSuggestionId);
382
- restoredStructureTransform.steps.forEach((step)=>{
383
- structureTransform.step(step);
384
- });
385
378
  });
386
379
  // apply the structure transform to the transaction
387
380
  const transaction = state.tr;
@@ -1,6 +1,5 @@
1
- import { EditorState } from "prosemirror-state";
1
+ import { EditorState, Selection } from "prosemirror-state";
2
2
  import { preserveTransactionData, transformToSuggestionTransaction } from "../../../transformToSuggestionTransaction.js";
3
- import { generateNextNumberId } from "../../../generateId.js";
4
3
  import { suggestStructureChanges } from "../../wrapUnwrap/structureChangesPlugin.js";
5
4
  import { detectSpecialTransactionShape } from "../detectSpecialTransactionShape.js";
6
5
  // handle the specific TipTap pattern when backspacing from a paragraph into a list above
@@ -15,8 +14,6 @@ export function handleTipTapParagraphIntoListJoin(args) {
15
14
  const docBefore = args.transaction.docs[0];
16
15
  if (!docBefore) return null;
17
16
  const trackedTransaction = args.state.tr;
18
- const sharedSuggestionId = args.generateId ? args.generateId(args.state.schema, docBefore) : generateNextNumberId(args.state.schema, docBefore);
19
- const generateSharedSuggestionId = ()=>sharedSuggestionId;
20
17
  try {
21
18
  trackedTransaction.step(shape.deleteStep);
22
19
  trackedTransaction.step(shape.insertStep);
@@ -29,7 +26,7 @@ export function handleTipTapParagraphIntoListJoin(args) {
29
26
  uniqueNodeIdsTransform.steps.forEach((step)=>{
30
27
  trackedTransaction.step(step);
31
28
  });
32
- const structureChangesResult = suggestStructureChanges(docBefore, uniqueNodeIdsTransform.doc, args.structuralContextPaths, generateSharedSuggestionId);
29
+ const structureChangesResult = suggestStructureChanges(docBefore, uniqueNodeIdsTransform.doc, args.structuralContextPaths, args.generateId);
33
30
  if (!structureChangesResult.handled) {
34
31
  return null;
35
32
  }
@@ -46,17 +43,22 @@ export function handleTipTapParagraphIntoListJoin(args) {
46
43
  } catch {
47
44
  return null;
48
45
  }
49
- const trackedJoinTransaction = transformToSuggestionTransaction(joinTransaction, intermediateState, generateSharedSuggestionId);
46
+ const trackedJoinTransaction = transformToSuggestionTransaction(joinTransaction, intermediateState, args.generateId);
50
47
  trackedJoinTransaction.steps.forEach((step)=>{
51
48
  trackedTransaction.step(step);
52
49
  });
53
50
  preserveTransactionData(trackedTransaction, trackedJoinTransaction, {
54
- selection: "currentDocument",
51
+ selection: false,
55
52
  preserveScroll: false,
56
53
  preserveStoredMarks: false,
57
54
  preserveMeta: false
58
55
  });
59
- preserveTransactionData(trackedTransaction, args.transaction);
56
+ preserveTransactionData(trackedTransaction, args.transaction, {
57
+ selection: false
58
+ });
59
+ if (args.transaction.selectionSet) {
60
+ trackedTransaction.setSelection(Selection.fromJSON(trackedTransaction.doc, args.transaction.selection.toJSON()));
61
+ }
60
62
  return trackedTransaction;
61
63
  }
62
64
  function isTipTapParagraphIntoListJoinShape(shape) {
@@ -4,7 +4,6 @@ import { rebasePos } from "./rebasePos.js";
4
4
  import { getSuggestionMarks } from "./utils.js";
5
5
  import { joinBlocks } from "./features/joinBlocks/index.js";
6
6
  import { collapseZWSPNodes, findJoinMark, joinNodesAndMarkJoinPoints, removeZWSPDeletions } from "./features/joinOnDelete/index.js";
7
- import { adjustForStartToStartTextblockDeletion } from "./features/startToStartTextblockDeletion/index.js";
8
7
  /**
9
8
  * Transform a replace step into its equivalent tracked steps.
10
9
  *
@@ -36,18 +35,17 @@ import { adjustForStartToStartTextblockDeletion } from "./features/startToStartT
36
35
  * zero-width spaces will be removed.
37
36
  */ export function suggestReplaceStep(trackedTransaction, state, doc, step, prevSteps, suggestionId) {
38
37
  const { deletion, insertion } = getSuggestionMarks(state.schema);
39
- const semanticStep = adjustForStartToStartTextblockDeletion(state.selection, step, prevSteps);
40
38
  // Check for insertion and deletion marks directly
41
39
  // adjacent to this step's boundaries. If they exist,
42
40
  // we'll use their ids, rather than producing a new one
43
- const nodeBefore = doc.resolve(semanticStep.from).nodeBefore;
41
+ const nodeBefore = doc.resolve(step.from).nodeBefore;
44
42
  const markBefore = nodeBefore?.marks.find((mark)=>mark.type === deletion || mark.type === insertion) ?? null;
45
- const nodeAfter = doc.resolve(semanticStep.to).nodeAfter;
43
+ const nodeAfter = doc.resolve(step.to).nodeAfter;
46
44
  const markAfter = nodeAfter?.marks.find((mark)=>mark.type === deletion || mark.type === insertion) ?? null;
47
45
  let markId = markBefore?.attrs["id"] ?? markAfter?.attrs["id"] ?? suggestionId;
48
46
  // Rebase this step's boundaries onto the newest doc
49
- let stepFrom = rebasePos(semanticStep.from, prevSteps, trackedTransaction.steps);
50
- let stepTo = rebasePos(semanticStep.to, prevSteps, trackedTransaction.steps);
47
+ let stepFrom = rebasePos(step.from, prevSteps, trackedTransaction.steps);
48
+ let stepTo = rebasePos(step.to, prevSteps, trackedTransaction.steps);
51
49
  if (state.selection.empty && stepFrom !== stepTo) {
52
50
  trackedTransaction.setSelection(TextSelection.near(trackedTransaction.doc.resolve(stepFrom)));
53
51
  }
@@ -60,8 +58,8 @@ import { adjustForStartToStartTextblockDeletion } from "./features/startToStartT
60
58
  }
61
59
  // Update the step boundaries, since we may have just changed
62
60
  // the document
63
- stepFrom = rebasePos(semanticStep.from, prevSteps, trackedTransaction.steps);
64
- stepTo = rebasePos(semanticStep.to, prevSteps, trackedTransaction.steps);
61
+ stepFrom = rebasePos(step.from, prevSteps, trackedTransaction.steps);
62
+ stepTo = rebasePos(step.to, prevSteps, trackedTransaction.steps);
65
63
  // Re-resolve nodeAfter and markAfter if we did a block join
66
64
  // The original values are stale after joinBlocks modifies the document
67
65
  let nodeAfterResolved = nodeAfter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magic-marker/prosemirror-suggest-changes",
3
- "version": "0.3.3-wrap-unwrap.29",
3
+ "version": "0.3.3-wrap-unwrap.31",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
@@ -55,17 +55,17 @@
55
55
  "markdown-toc": "^1.2.0",
56
56
  "playwright": "^1.56.0",
57
57
  "prettier": "^3.5.3",
58
- "prosemirror-commands": "1.7.1",
59
- "prosemirror-history": "1.5.0",
60
- "prosemirror-inputrules": "1.5.1",
61
- "prosemirror-keymap": "1.2.3",
62
- "prosemirror-model": "1.25.4",
63
- "prosemirror-schema-basic": "1.2.4",
64
- "prosemirror-schema-list": "1.5.1",
65
- "prosemirror-state": "1.4.4",
66
- "prosemirror-test-builder": "1.1.1",
67
- "prosemirror-transform": "1.12.0",
68
- "prosemirror-view": "1.41.9",
58
+ "prosemirror-commands": "^1.7.0",
59
+ "prosemirror-history": "^1.5.0",
60
+ "prosemirror-inputrules": "^1.4.0",
61
+ "prosemirror-keymap": "^1.2.2",
62
+ "prosemirror-model": "^1.24.1",
63
+ "prosemirror-schema-basic": "^1.2.3",
64
+ "prosemirror-schema-list": "^1.5.0",
65
+ "prosemirror-state": "^1.4.3",
66
+ "prosemirror-test-builder": "^1.1.1",
67
+ "prosemirror-transform": "^1.10.2",
68
+ "prosemirror-view": "^1.38.0",
69
69
  "remark-parse": "^11.0.0",
70
70
  "rimraf": "^6.0.1",
71
71
  "typescript": "^5.8.2",
@@ -79,17 +79,5 @@
79
79
  "prosemirror-state": "^1.0.0",
80
80
  "prosemirror-transform": "^1.0.0",
81
81
  "prosemirror-view": "^1.0.0"
82
- },
83
- "resolutions": {
84
- "prosemirror-model": "1.25.4",
85
- "prosemirror-state": "1.4.4",
86
- "prosemirror-transform": "1.12.0",
87
- "prosemirror-view": "1.41.9",
88
- "prosemirror-keymap": "1.2.3",
89
- "prosemirror-commands": "1.7.1",
90
- "prosemirror-schema-basic": "1.2.4",
91
- "prosemirror-schema-list": "1.5.1",
92
- "prosemirror-history": "1.5.0",
93
- "prosemirror-inputrules": "1.5.1"
94
82
  }
95
83
  }
@@ -1,6 +0,0 @@
1
- import { type Selection } from "prosemirror-state";
2
- import { type ReplaceStep, type Step } from "prosemirror-transform";
3
- export declare function adjustForStartToStartTextblockDeletion(selection: Selection, step: ReplaceStep, prevSteps: Step[]): {
4
- from: number;
5
- to: number;
6
- };
@@ -1,54 +0,0 @@
1
- import { TextSelection } from "prosemirror-state";
2
- export function adjustForStartToStartTextblockDeletion(selection, step, prevSteps) {
3
- if (prevSteps.length > 0) return {
4
- from: step.from,
5
- to: step.to
6
- };
7
- if (!(selection instanceof TextSelection)) {
8
- return {
9
- from: step.from,
10
- to: step.to
11
- };
12
- }
13
- if (selection.empty || step.slice.size !== 0) {
14
- return {
15
- from: step.from,
16
- to: step.to
17
- };
18
- }
19
- const { $from, $to } = selection;
20
- if (!$from.parent.isTextblock || !$to.parent.isTextblock) {
21
- return {
22
- from: step.from,
23
- to: step.to
24
- };
25
- }
26
- if ($from.parentOffset !== 0 || $to.parentOffset !== 0) {
27
- return {
28
- from: step.from,
29
- to: step.to
30
- };
31
- }
32
- if ($from.start() === $to.start()) return {
33
- from: step.from,
34
- to: step.to
35
- };
36
- if (step.from !== $from.before($from.depth)) {
37
- return {
38
- from: step.from,
39
- to: step.to
40
- };
41
- }
42
- if (step.to !== $to.before($to.depth)) {
43
- return {
44
- from: step.from,
45
- to: step.to
46
- };
47
- }
48
- // The step boundary is moved before the right textblock, but the selection
49
- // boundary is the user-visible end of the deleted text range.
50
- return {
51
- from: step.from,
52
- to: selection.to
53
- };
54
- }