tiptap-rusty-parser 0.2.0 → 0.2.2

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
@@ -53,6 +53,7 @@ boundary. `path` arguments are plain `number[]` index paths (root = `[]`).
53
53
  | Text | `textContent()`, `charCount()`, `wordCount()` |
54
54
  | Validate | `validate(schema)`, `isValid(schema)` |
55
55
  | Diff | `diff(other)` → `Change[]`; `applyChanges(changes)`; `invert(changes)` → reverse `Change[]` (undo) |
56
+ | Render | `toHTML()` → HTML string; `toHTMLWith(options)` (node/mark tag maps, unknown-policy, `selfClosing`, `spreadAttrs`, `textAlign`) |
56
57
 
57
58
  Methods throw on malformed input or a missing path target.
58
59
 
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.2.0",
5
+ "version": "0.2.2",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -72,6 +72,14 @@ export class TiptapDoc {
72
72
  * The node at `path`, or `undefined`.
73
73
  */
74
74
  nodeAt(path: any): any;
75
+ /**
76
+ * Normalize the document tree in place (merge adjacent text, drop empties).
77
+ */
78
+ normalize(): void;
79
+ /**
80
+ * Normalize with an options object (see `NormalizeOptions`).
81
+ */
82
+ normalizeWith(options: any): void;
75
83
  /**
76
84
  * Index paths of every node whose attribute `key` equals `value`.
77
85
  */
@@ -112,6 +120,14 @@ export class TiptapDoc {
112
120
  * Concatenated text of all descendant text nodes.
113
121
  */
114
122
  textContent(): string;
123
+ /**
124
+ * Render the document to an HTML string (Tiptap-default mapping).
125
+ */
126
+ toHTML(): string;
127
+ /**
128
+ * Render to HTML with an options object (see `HtmlOptions`).
129
+ */
130
+ toHTMLWith(options: any): string;
115
131
  /**
116
132
  * Serialize the document to a JS `JSONContent` object.
117
133
  */
@@ -212,6 +212,22 @@ export class TiptapDoc {
212
212
  }
213
213
  return takeFromExternrefTable0(ret[0]);
214
214
  }
215
+ /**
216
+ * Normalize the document tree in place (merge adjacent text, drop empties).
217
+ */
218
+ normalize() {
219
+ wasm.tiptapdoc_normalize(this.__wbg_ptr);
220
+ }
221
+ /**
222
+ * Normalize with an options object (see `NormalizeOptions`).
223
+ * @param {any} options
224
+ */
225
+ normalizeWith(options) {
226
+ const ret = wasm.tiptapdoc_normalizeWith(this.__wbg_ptr, options);
227
+ if (ret[1]) {
228
+ throw takeFromExternrefTable0(ret[0]);
229
+ }
230
+ }
215
231
  /**
216
232
  * Index paths of every node whose attribute `key` equals `value`.
217
233
  * @param {string} key
@@ -352,6 +368,45 @@ export class TiptapDoc {
352
368
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
353
369
  }
354
370
  }
371
+ /**
372
+ * Render the document to an HTML string (Tiptap-default mapping).
373
+ * @returns {string}
374
+ */
375
+ toHTML() {
376
+ let deferred1_0;
377
+ let deferred1_1;
378
+ try {
379
+ const ret = wasm.tiptapdoc_toHTML(this.__wbg_ptr);
380
+ deferred1_0 = ret[0];
381
+ deferred1_1 = ret[1];
382
+ return getStringFromWasm0(ret[0], ret[1]);
383
+ } finally {
384
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
385
+ }
386
+ }
387
+ /**
388
+ * Render to HTML with an options object (see `HtmlOptions`).
389
+ * @param {any} options
390
+ * @returns {string}
391
+ */
392
+ toHTMLWith(options) {
393
+ let deferred2_0;
394
+ let deferred2_1;
395
+ try {
396
+ const ret = wasm.tiptapdoc_toHTMLWith(this.__wbg_ptr, options);
397
+ var ptr1 = ret[0];
398
+ var len1 = ret[1];
399
+ if (ret[3]) {
400
+ ptr1 = 0; len1 = 0;
401
+ throw takeFromExternrefTable0(ret[2]);
402
+ }
403
+ deferred2_0 = ptr1;
404
+ deferred2_1 = len1;
405
+ return getStringFromWasm0(ptr1, len1);
406
+ } finally {
407
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
408
+ }
409
+ }
355
410
  /**
356
411
  * Serialize the document to a JS `JSONContent` object.
357
412
  * @returns {any}
Binary file