@magic-marker/prosemirror-suggest-changes 0.2.1-block-join.7 → 0.2.1-block-join.9
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.
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { expect } from "@playwright/test";
|
|
2
|
+
export interface TestOptions {
|
|
3
|
+
deletionMarksVisibility: "hidden" | "visible";
|
|
4
|
+
}
|
|
5
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & TestOptions, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
6
|
+
export { expect };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import { type Transaction } from "prosemirror-state";
|
|
2
|
-
export declare function prependDeletionsWithZWSP(transaction: Transaction
|
|
3
|
-
experimental_deletions?: "hidden" | "visible";
|
|
4
|
-
}): Transaction;
|
|
2
|
+
export declare function prependDeletionsWithZWSP(transaction: Transaction): Transaction;
|
|
@@ -7,9 +7,7 @@ function trace(...args) {
|
|
|
7
7
|
if (!TRACE_ENABLED) return;
|
|
8
8
|
console.log("[prependDeletionsWithZWSP]", ...args);
|
|
9
9
|
}
|
|
10
|
-
export function prependDeletionsWithZWSP(transaction
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
12
|
-
if (TRACE_ENABLED) console.groupCollapsed("prepend deletions with zwsp");
|
|
10
|
+
export function prependDeletionsWithZWSP(transaction) {
|
|
13
11
|
const { deletion } = getSuggestionMarks(transaction.doc.type.schema);
|
|
14
12
|
let transform = new Transform(transaction.doc);
|
|
15
13
|
transform.doc.descendants((node, pos)=>{
|
|
@@ -17,22 +15,12 @@ export function prependDeletionsWithZWSP(transaction, opts) {
|
|
|
17
15
|
if (!node.isText || mark == null) return true;
|
|
18
16
|
const mappedPos = transform.mapping.map(pos);
|
|
19
17
|
transform.delete(mappedPos, mappedPos + node.nodeSize);
|
|
20
|
-
trace("found zwsp, deleted", {
|
|
21
|
-
from: mappedPos,
|
|
22
|
-
to: mappedPos + node.nodeSize
|
|
23
|
-
});
|
|
24
18
|
return true;
|
|
25
19
|
});
|
|
26
20
|
transform.steps.forEach((step)=>{
|
|
27
21
|
transaction.step(step);
|
|
28
22
|
});
|
|
29
|
-
trace(`added ${String(transform.steps.length)} remove zwsp steps to tr
|
|
30
|
-
if (opts?.experimental_deletions !== "hidden") {
|
|
31
|
-
trace("deletions are visible, skipping prepend zwsp");
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
33
|
-
if (TRACE_ENABLED) console.groupEnd();
|
|
34
|
-
return transaction;
|
|
35
|
-
}
|
|
23
|
+
if (transform.steps.length > 0) trace(`added ${String(transform.steps.length)} remove zwsp steps to tr`, transform);
|
|
36
24
|
transform = new Transform(transaction.doc);
|
|
37
25
|
transform.doc.descendants((node, pos)=>{
|
|
38
26
|
if (!node.inlineContent) return true;
|
|
@@ -47,17 +35,11 @@ export function prependDeletionsWithZWSP(transaction, opts) {
|
|
|
47
35
|
]);
|
|
48
36
|
const mappedPos = transform.mapping.map(pos);
|
|
49
37
|
transform.insert(mappedPos + 1, zwspNode);
|
|
50
|
-
trace("found first-child-deletion inline content node, inserted zwsp at", {
|
|
51
|
-
pos,
|
|
52
|
-
mappedPos
|
|
53
|
-
});
|
|
54
38
|
return true;
|
|
55
39
|
});
|
|
56
40
|
transform.steps.forEach((step)=>{
|
|
57
41
|
transaction.step(step);
|
|
58
42
|
});
|
|
59
|
-
trace(`added ${String(transform.steps.length)} add zwsp steps to tr
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
61
|
-
if (TRACE_ENABLED) console.groupEnd();
|
|
43
|
+
if (transform.steps.length > 0) trace(`added ${String(transform.steps.length)} add zwsp steps to tr`, transform);
|
|
62
44
|
return transaction;
|
|
63
45
|
}
|
|
@@ -24,6 +24,4 @@ export declare function transformToSuggestionTransaction(originalTransaction: Tr
|
|
|
24
24
|
* applying them, e.g. by marking a range with the deletion mark rather
|
|
25
25
|
* than removing it from the document.
|
|
26
26
|
*/
|
|
27
|
-
export declare function withSuggestChanges(dispatchTransaction?: EditorView["dispatch"], generateId?: (schema: Schema, doc?: Node) => SuggestionId
|
|
28
|
-
experimental_deletions?: "hidden" | "visible";
|
|
29
|
-
}): EditorView["dispatch"];
|
|
27
|
+
export declare function withSuggestChanges(dispatchTransaction?: EditorView["dispatch"], generateId?: (schema: Schema, doc?: Node) => SuggestionId): EditorView["dispatch"];
|
|
@@ -103,7 +103,7 @@ function getStepHandler(step) {
|
|
|
103
103
|
* These modified transactions will suggest changes instead of directly
|
|
104
104
|
* applying them, e.g. by marking a range with the deletion mark rather
|
|
105
105
|
* than removing it from the document.
|
|
106
|
-
*/ export function withSuggestChanges(dispatchTransaction, generateId
|
|
106
|
+
*/ export function withSuggestChanges(dispatchTransaction, generateId) {
|
|
107
107
|
const dispatch = dispatchTransaction ?? function(tr) {
|
|
108
108
|
this.updateState(this.state.apply(tr));
|
|
109
109
|
};
|
|
@@ -111,7 +111,7 @@ function getStepHandler(step) {
|
|
|
111
111
|
const ySyncMeta = tr.getMeta("y-sync$") ?? {};
|
|
112
112
|
const transaction = isSuggestChangesEnabled(this.state) && !tr.getMeta("history$") && !tr.getMeta("collab$") && !ySyncMeta.isUndoRedoOperation && !ySyncMeta.isChangeOrigin && !("skip" in (tr.getMeta(suggestChangesKey) ?? {})) ? transformToSuggestionTransaction(tr, this.state, generateId) : tr;
|
|
113
113
|
if (transaction.docChanged) {
|
|
114
|
-
prependDeletionsWithZWSP(transaction
|
|
114
|
+
prependDeletionsWithZWSP(transaction);
|
|
115
115
|
}
|
|
116
116
|
dispatch.call(this, transaction);
|
|
117
117
|
};
|