tiptap-rusty-parser 0.1.3 → 0.1.4
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/README.md
CHANGED
|
@@ -52,6 +52,7 @@ boundary. `path` arguments are plain `number[]` index paths (root = `[]`).
|
|
|
52
52
|
| Mutate (by path) | `setAttr`, `removeAttr`, `setText`, `addMark`, `removeMark`, `pushChild`, `insertChild`, `removeChild` |
|
|
53
53
|
| Text | `textContent()`, `charCount()`, `wordCount()` |
|
|
54
54
|
| Validate | `validate(schema)`, `isValid(schema)` |
|
|
55
|
+
| Diff | `diff(other)` → `Change[]`; `applyChanges(changes)` |
|
|
55
56
|
|
|
56
57
|
Methods throw on malformed input or a missing path target.
|
|
57
58
|
|
package/package.json
CHANGED
|
@@ -14,6 +14,10 @@ export class TiptapDoc {
|
|
|
14
14
|
* returns whether it was newly added.
|
|
15
15
|
*/
|
|
16
16
|
addMark(path: any, mark_type: string, attrs: any): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Apply a change array (as produced by [`diff`](Self::diff)) in place.
|
|
19
|
+
*/
|
|
20
|
+
applyChanges(changes: any): void;
|
|
17
21
|
/**
|
|
18
22
|
* All nodes whose attribute `key` equals `value`.
|
|
19
23
|
*/
|
|
@@ -34,6 +38,11 @@ export class TiptapDoc {
|
|
|
34
38
|
* Child count of the node at `path`, or `undefined` if no such node.
|
|
35
39
|
*/
|
|
36
40
|
childCount(path: any): number | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Structural diff from this document to `other`; returns an array of
|
|
43
|
+
* change objects (each tagged with an `op`).
|
|
44
|
+
*/
|
|
45
|
+
diff(other: TiptapDoc): any;
|
|
37
46
|
/**
|
|
38
47
|
* The first node of `node_type`, or `undefined`.
|
|
39
48
|
*/
|
|
@@ -36,6 +36,16 @@ export class TiptapDoc {
|
|
|
36
36
|
}
|
|
37
37
|
return ret[0] !== 0;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Apply a change array (as produced by [`diff`](Self::diff)) in place.
|
|
41
|
+
* @param {any} changes
|
|
42
|
+
*/
|
|
43
|
+
applyChanges(changes) {
|
|
44
|
+
const ret = wasm.tiptapdoc_applyChanges(this.__wbg_ptr, changes);
|
|
45
|
+
if (ret[1]) {
|
|
46
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
39
49
|
/**
|
|
40
50
|
* All nodes whose attribute `key` equals `value`.
|
|
41
51
|
* @param {string} key
|
|
@@ -99,6 +109,20 @@ export class TiptapDoc {
|
|
|
99
109
|
}
|
|
100
110
|
return ret[0] === Number.MAX_SAFE_INTEGER ? undefined : ret[0];
|
|
101
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Structural diff from this document to `other`; returns an array of
|
|
114
|
+
* change objects (each tagged with an `op`).
|
|
115
|
+
* @param {TiptapDoc} other
|
|
116
|
+
* @returns {any}
|
|
117
|
+
*/
|
|
118
|
+
diff(other) {
|
|
119
|
+
_assertClass(other, TiptapDoc);
|
|
120
|
+
const ret = wasm.tiptapdoc_diff(this.__wbg_ptr, other.__wbg_ptr);
|
|
121
|
+
if (ret[2]) {
|
|
122
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
123
|
+
}
|
|
124
|
+
return takeFromExternrefTable0(ret[0]);
|
|
125
|
+
}
|
|
102
126
|
/**
|
|
103
127
|
* The first node of `node_type`, or `undefined`.
|
|
104
128
|
* @param {string} node_type
|
|
@@ -616,6 +640,12 @@ function addToExternrefTable0(obj) {
|
|
|
616
640
|
return idx;
|
|
617
641
|
}
|
|
618
642
|
|
|
643
|
+
function _assertClass(instance, klass) {
|
|
644
|
+
if (!(instance instanceof klass)) {
|
|
645
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
619
649
|
function debugString(val) {
|
|
620
650
|
// primitive types
|
|
621
651
|
const type = typeof val;
|
|
Binary file
|