@magic-marker/prosemirror-suggest-changes 0.3.3-wrap-unwrap.16 → 0.3.3-wrap-unwrap.18
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/dist/__tests__/playwrightPage.d.ts +4 -2
- package/dist/ensureSelectionPlugin.js +2 -2
- package/dist/features/wrapUnwrap/__tests__/buildMaterializedPaths.test.d.ts +1 -0
- package/dist/features/wrapUnwrap/buildMaterializedPaths.js +1 -1
- package/dist/features/wrapUnwrap/structureChangesPlugin.js +11 -6
- package/dist/features/wrapUnwrap/types.d.ts +5 -0
- package/dist/features/wrapUnwrap/types.js +6 -0
- package/dist/testing/e2eTestSchema.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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:
|
|
21
|
-
expectedDoc:
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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.
|
|
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:
|
|
244
|
-
//
|
|
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
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
|
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
|
|
@@ -37,4 +37,9 @@ export type MaterializedPaths = Map<string, {
|
|
|
37
37
|
}>;
|
|
38
38
|
export declare function guardDocParent(parent: Parent | undefined): parent is DocParent;
|
|
39
39
|
export declare function guardStructureMarkAttrs(attrs: Attrs): attrs is StructureMarkAttrs;
|
|
40
|
+
export interface StructureMark {
|
|
41
|
+
type: "structure";
|
|
42
|
+
attrs: StructureMarkAttrs;
|
|
43
|
+
}
|
|
44
|
+
export declare function isStructureMark(mark: unknown): mark is StructureMark;
|
|
40
45
|
export {};
|
|
@@ -9,3 +9,9 @@ export function guardStructureMarkAttrs(attrs) {
|
|
|
9
9
|
if (!("op" in data)) return false;
|
|
10
10
|
return true;
|
|
11
11
|
}
|
|
12
|
+
export function isStructureMark(mark) {
|
|
13
|
+
if (mark === null || typeof mark !== "object") return false;
|
|
14
|
+
if (!("type" in mark) || mark.type !== "structure") return false;
|
|
15
|
+
if (!("attrs" in mark)) return false;
|
|
16
|
+
return guardStructureMarkAttrs(mark.attrs);
|
|
17
|
+
}
|
|
@@ -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">;
|