Skip to content

feat(wasm): edit and save a sheet from the example - #866

Merged
andiwand merged 2 commits into
mainfrom
feat/sheet-edit-example
Sep 8, 2026
Merged

feat(wasm): edit and save a sheet from the example#866
andiwand merged 2 commits into
mainfrom
feat/sheet-edit-example

Conversation

@andiwand

@andiwand andiwand commented Sep 8, 2026

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Step 1.5 of docs/design/spreadsheet-editing.md, which closes step 1. Stacked on #865.

The example gains an edit and a save button. It assigns the three callbacks on the frame's contentWindow once it has loaded — the same moment droid and ios go in through evaluateJavascript — lights the save button off onEditChange (with the op count on it), and puts a refusal in the status line, which is where an app would raise a snackbar in its own string catalogue.

A view holds its own log (decision 6), so the example writes the log into the document when the view goes away as well as before a save; a cell op is idempotent, so doing both is safe, and re-rendering the view shows what was written.

edit.test.mjs writes a cell by position through the bindings and reopens what was saved, on an .ods built in memory beside the .odt — the binding-level pin for setCell.

Verified by hand: drop ods/file_example_ODS_10.ods into the example, type 777 into B2, save, drop the saved bytes back in — the reopened sheet shows 777, and the save button falls back to save… when committed() runs. ctest --test-dir build-wasm/wasm is green (43 tests).

@andiwand
andiwand force-pushed the feat/sheet-edit-log branch from 427dc31 to 782dd82 Compare September 8, 2026 20:15
@andiwand
andiwand force-pushed the feat/sheet-edit-example branch from 2167f4c to bee64f2 Compare September 8, 2026 20:15
@andiwand
andiwand force-pushed the feat/sheet-edit-log branch from 782dd82 to 2df7282 Compare September 8, 2026 20:24
@andiwand
andiwand force-pushed the feat/sheet-edit-example branch from bee64f2 to 359462c Compare September 8, 2026 20:27
@andiwand
andiwand force-pushed the feat/sheet-edit-log branch from 2df7282 to e370f6e Compare September 8, 2026 20:28
@andiwand
andiwand force-pushed the feat/sheet-edit-example branch from 359462c to 0f430c2 Compare September 8, 2026 20:28
Base automatically changed from feat/sheet-edit-log to main September 8, 2026 20:31
@andiwand
andiwand force-pushed the feat/sheet-edit-example branch from 0f430c2 to c209153 Compare September 8, 2026 20:37
@andiwand

andiwand commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

Reviewed and force-pushed.

A refused op was swallowed, and the file downloaded anyway. The page has no lock for a position the engine cannot write yet — an .xlsx cell with no <c>, an .ods one with no element — so doc.edit throws where the page took the edit happily. collect() catches it, puts the message in the status line and returns false, and the save stops there rather than handing over a file without the edits; the log is kept, so nothing typed is lost. Verified live: typing into A11 of xlsx/file_example_XLSX_10.xlsx now says UnsupportedOperation — unsupported operation, downloads nothing and keeps its op, while the .ods round trip still saves and reopens with the edit in it. Noted in the design doc's complications, since it goes away with step 2.

Conciseness:

  • the changelog entry is gone — an example page is not API, formats, rendering, behaviour or packaging, which is what the file says an entry is for;
  • minimalOdt and minimalOds were the same package with a different content.xml, so the mimetype, manifest and zip call sit in one odf() wrapper — 30 lines shorter than the copy this PR started with;
  • the wasm test dropped the two markup assertions (html_test.cpp pins those) for the assertion it was missing: the edit renders before it is saved;
  • #edit[hidden], #save[hidden] { display: none } was dead — only #drop needs it, having a display of its own;
  • let name shadowed window.name; it is filename.

andiwand and others added 2 commits September 8, 2026 22:40
The example turns `odr.editing` on, lights its save button off `onEditChange`
and says a refusal in the status line - the three callbacks a host assigns, here
on the frame's `contentWindow` once it has loaded, where droid and ios go in
through `evaluateJavascript`. A view holds its own log, so the log is written
into the document when the view goes away as well as before a save, which a
cell op being idempotent makes safe.

`edit.test.mjs` writes a cell by position through the bindings and reopens what
was saved, on an `.ods` built in memory beside the `.odt`.

Step 1.5 of `docs/design/spreadsheet-editing.md`, which closes step 1.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012eNBvra2NSxLjUvVKzuXSY
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012eNBvra2NSxLjUvVKzuXSY
@andiwand
andiwand force-pushed the feat/sheet-edit-example branch from c209153 to eb8fa4d Compare September 8, 2026 20:40
@andiwand
andiwand merged commit f227f42 into main Sep 8, 2026
13 checks passed
@andiwand
andiwand deleted the feat/sheet-edit-example branch September 8, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant