From 926d7192d85472f9636c87131d5f9179213136e8 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 10 Sep 2026 16:21:31 +0200 Subject: [PATCH] fix(html): the envelope states the version the library takes `odr.editing.getOperations()` and `odr.generateDiff()` stated `"version": 1` while `Document::edit` has taken 2 since #872, so every save the browser produced was refused with "unsupported edit version". Nothing caught it: the check pages read the operations and never the version, and the wasm and gtest suites write their own envelope by hand. So a check on each page that produces one now asserts it. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01KKFKbUVCYF2VhujdmjhhPW --- CHANGELOG.md | 4 ++++ src/odr/internal/html/frontend/editing.js | 6 ++++-- test/browser/text/tests.html | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70089f267..21614cd70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ The release run heads these entries with the version and opens a fresh ## Unreleased +- **Fix**: `odr.editing.getOperations()` and `odr.generateDiff()` stated + `"version": 1` while `Document::edit` takes 2, so every save the browser + produced was refused. A check page now asserts the version. + - A `.pptx` can be edited and saved: every text operation a `.docx` takes, and a save that writes the slide parts back into the package. Its `FileTypeCapabilities` now states `edit` and `save`. diff --git a/src/odr/internal/html/frontend/editing.js b/src/odr/internal/html/frontend/editing.js index 4d9b9e859..df36c9099 100644 --- a/src/odr/internal/html/frontend/editing.js +++ b/src/odr/internal/html/frontend/editing.js @@ -162,9 +162,11 @@ }); }, - /// The envelope a host hands to `Document::edit` before saving. + /// The envelope a host hands to `Document::edit` before saving. The + /// version is what the library takes; a check page asserts it, because + /// nothing else here would notice the two drifting apart. getOperations: function () { - return JSON.stringify({ version: 1, ops: operations() }); + return JSON.stringify({ version: 2, ops: operations() }); }, /// False where no editor has an edit to take back. diff --git a/test/browser/text/tests.html b/test/browser/text/tests.html index 3513a8bb2..afddeb9c0 100644 --- a/test/browser/text/tests.html +++ b/test/browser/text/tests.html @@ -451,6 +451,11 @@ odr.resetSearch(); check("as does clearing it", ops().length === 1); + check( + "the envelope states the version the library takes", + JSON.parse(odr.editing.getOperations()).version === 2 + ); + odr.editing.committed(); check("committing clears the log", ops().length === 0); check("and undo with it", odr.editing.undo() === false);