From bc492f540da36d8a58b1fafa2182f463d3c35fc6 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sun, 30 Aug 2026 09:52:58 +0200 Subject: [PATCH] docs(wasm): hand the diff to edit as generateDiff returns it `odr.generateDiff()` returns the json already stringified, so the README's `JSON.stringify` around it handed `edit` a json string where it parses an object: `json["modifiedText"]` then throws `[json.exception.type_error.305] cannot use operator[] with a string argument with string`. Checked against 6.12.0 both ways. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01P4A5LwMDmeD3sxJ3MaTr5Q --- wasm/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wasm/README.md b/wasm/README.md index b2d6b5906..a6d7a4b31 100644 --- a/wasm/README.md +++ b/wasm/README.md @@ -65,7 +65,9 @@ Editing is a round trip through the rendered page: const doc = odr.open(bytes, { editable: true }); const { html } = doc.render(0); // ... the reader edits the page in the iframe ... -doc.edit(JSON.stringify(iframe.contentWindow.odr.generateDiff())); +// `generateDiff()` returns the json already; stringifying it again is a string +// where `edit` wants an object, and it throws. +doc.edit(iframe.contentWindow.odr.generateDiff()); const saved = doc.save(); // the document, not the html download(new Blob([saved]));