tiptap-rusty-parser 0.1.4 → 0.2.0

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,7 +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
+ | Diff | `diff(other)` → `Change[]`; `applyChanges(changes)`; `invert(changes)` → reverse `Change[]` (undo) |
56
56
 
57
57
  Methods throw on malformed input or a missing path target.
58
58
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "tiptap-rusty-parser",
3
3
  "type": "module",
4
4
  "description": "Fast WASM parser/manipulator for Tiptap/ProseMirror JSONContent",
5
- "version": "0.1.4",
5
+ "version": "0.2.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -59,6 +59,11 @@ export class TiptapDoc {
59
59
  * Insert `child` at `index` under the node at `path` (index clamped).
60
60
  */
61
61
  insertChild(path: any, index: number, child: any): void;
62
+ /**
63
+ * Invert a change array relative to this document (the pre-image); returns
64
+ * the reverse change array for undo. See `applyChanges`.
65
+ */
66
+ invert(changes: any): any;
62
67
  /**
63
68
  * True if the document has no schema violations.
64
69
  */
@@ -175,6 +175,19 @@ export class TiptapDoc {
175
175
  throw takeFromExternrefTable0(ret[0]);
176
176
  }
177
177
  }
178
+ /**
179
+ * Invert a change array relative to this document (the pre-image); returns
180
+ * the reverse change array for undo. See `applyChanges`.
181
+ * @param {any} changes
182
+ * @returns {any}
183
+ */
184
+ invert(changes) {
185
+ const ret = wasm.tiptapdoc_invert(this.__wbg_ptr, changes);
186
+ if (ret[2]) {
187
+ throw takeFromExternrefTable0(ret[1]);
188
+ }
189
+ return takeFromExternrefTable0(ret[0]);
190
+ }
178
191
  /**
179
192
  * True if the document has no schema violations.
180
193
  * @param {any} schema
Binary file