@magic-marker/prosemirror-suggest-changes 0.3.3-wrap-unwrap.16 → 0.3.3-wrap-unwrap.17

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,3 +1,4 @@
1
+ import { type Node } from "prosemirror-model";
1
2
  import { type Locator, type Page } from "@playwright/test";
2
3
  export declare class EditorPage {
3
4
  readonly page: Page;
@@ -16,9 +17,10 @@ export declare class EditorPage {
16
17
  }>;
17
18
  getDOMTextContentOfChildAtIndex(index: number): Promise<string>;
18
19
  getDocJSON(): Promise<object>;
20
+ getCurrentDoc(): Promise<Node>;
19
21
  getCurrentAndExpectedDoc(expectedDocJSON: object): Promise<{
20
- currentDoc: import("prosemirror-model").Node;
21
- expectedDoc: import("prosemirror-model").Node;
22
+ currentDoc: Node;
23
+ expectedDoc: Node;
22
24
  }>;
23
25
  revertAll(): Promise<void>;
24
26
  applyAll(): Promise<void>;
@@ -147,8 +147,8 @@ function isPosValid($pos) {
147
147
  const insertionBefore = insertion.isInSet($pos.nodeBefore?.marks ?? []);
148
148
  const insertionAfter = insertion.isInSet($pos.nodeAfter?.marks ?? []);
149
149
  const ZWSP_REGEXP = new RegExp(ZWSP, "g");
150
- const isZWSPBefore = $pos.nodeBefore && $pos.nodeBefore.textContent.replace(ZWSP_REGEXP, "") === "";
151
- const isZWSPAfter = $pos.nodeAfter && $pos.nodeAfter.textContent.replace(ZWSP_REGEXP, "") === "";
150
+ const isZWSPBefore = $pos.nodeBefore && $pos.nodeBefore.isText && $pos.nodeBefore.textContent.replace(ZWSP_REGEXP, "") === "";
151
+ const isZWSPAfter = $pos.nodeAfter && $pos.nodeAfter.isText && $pos.nodeAfter.textContent.replace(ZWSP_REGEXP, "") === "";
152
152
  if (insertionBefore && insertionAfter && isZWSPBefore && isZWSPAfter) {
153
153
  trace("isPosValid", $pos.pos, "pos invalid", "reason: between two ZWSP insertions", {
154
154
  $pos
@@ -38,7 +38,7 @@ export function buildMaterializedPaths(doc) {
38
38
  });
39
39
  // now add the rest of the nodes
40
40
  doc.descendants((node, _pos, parent, childIndex)=>{
41
- if (node.isText) return false;
41
+ if (node.isInline) return false;
42
42
  const nodeId = getNodeId(node);
43
43
  if (nodeId == null) return true;
44
44
  // this is to avoid processing direct doc children twice
@@ -240,15 +240,20 @@ function chainHasStructuralContext(chain, structuralContextPaths) {
240
240
  ].reverse().filter((parent)=>parent.nodeType !== DOC_NODE_ID).map((parent)=>parent.nodeType);
241
241
  return structuralContextPaths.some((path)=>containsContiguousPath(topDownChain, path));
242
242
  }
243
- // does a chain like: __doc__->nodeTypeA->nodeTypeB->nodeTypeC->nodeTypeD
244
- // contain a structural context path (a "sub chain") like nodeTypeB->nodeTypeC ?
243
+ // does a chain like: nodeTypeA->nodeTypeB->nodeTypeC
244
+ // end with a structural context path like nodeTypeB->nodeTypeC ?
245
245
  function containsContiguousPath(chainNodeTypes, structuralContextPath) {
246
246
  if (structuralContextPath.length > chainNodeTypes.length) return false;
247
- for(let start = 0; start <= chainNodeTypes.length - structuralContextPath.length; start++){
248
- const matches = structuralContextPath.every((nodeType, index)=>chainNodeTypes[start + index] === nodeType);
249
- if (matches) return true;
247
+ let structuralPathPointer = structuralContextPath.length - 1;
248
+ let chainPointer = chainNodeTypes.length - 1;
249
+ while(structuralPathPointer >= 0){
250
+ if (structuralContextPath[structuralPathPointer] !== chainNodeTypes[chainPointer]) {
251
+ return false;
252
+ }
253
+ structuralPathPointer--;
254
+ chainPointer--;
250
255
  }
251
- return false;
256
+ return true;
252
257
  }
253
258
  // detect block split - try to look at the node above, concatenate two text contents,
254
259
  // and see if it combines into a single node in the old document
@@ -1,2 +1,2 @@
1
1
  import { Schema } from "prosemirror-model";
2
- export declare function createSchema(deletionMarksVisibility?: "hidden" | "visible"): Schema<"blockquote" | "text" | "doc" | "paragraph" | "horizontal_rule" | "heading" | "code_block" | "image" | "hard_break" | "orderedList" | "bulletList" | "listItem", "insertion" | "deletion" | "modification" | "structure" | "code" | "em" | "link" | "strong">;
2
+ export declare function createSchema(deletionMarksVisibility?: "hidden" | "visible"): Schema<"blockquote" | "text" | "doc" | "paragraph" | "horizontal_rule" | "heading" | "code_block" | "image" | "hard_break" | "orderedList" | "bulletList" | "listItem" | "hardBreak", "insertion" | "deletion" | "modification" | "structure" | "code" | "em" | "link" | "strong">;
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.16",
3
+ "version": "0.3.3-wrap-unwrap.17",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",