Skip to content

Edit OMML equations directly on the slide - #1

Open
hajdukste wants to merge 1 commit into
shuff57:equation-editorfrom
hajdukste:codex/equation-inline-on-pr55
Open

hajdukste wants to merge 1 commit into
shuff57:equation-editorfrom
hajdukste:codex/equation-inline-on-pr55

Conversation

@hajdukste

Copy link
Copy Markdown

Problem and behavior

Follow-up to storytold/deckcraft#55, based on its current equation-editor head (b40a893). This PR targets that branch so the diff contains only the additional interaction work.

Insert → Equation now creates an active field directly on the slide: at the current text caret, or in a new text box. The field shows Type equation here until typing begins. For example, typing \alpha leaves the command visible; Space converts it to α. Fractions, roots and scripts continue to use the existing structured editor.

  • Clicking an equation edits it on the slide, including clicks into fraction/exponent slots and table cells.
  • The active field has temporary gray shading and an empty contextual Equation ribbon tab. Leaving restores the previous tab; manual tab choices while editing are respected.
  • Right Arrow at the end of the root math row returns to surrounding text without adding a character. Left Arrow can reenter. Prose formatting is restored, including intentionally italic surrounding text.
  • Selection, clipboard edits and document undo/redo share the existing math editor. The dialog and its template palette remain available.

Integration

This reuses storytold#55's deckcraft-math::Editor, OMML RunKind::Math, layout and PPTX support. It does not add the separate equation-run format from storytold/deckcraft#771. That PR is being retained as a draft interaction prototype, not a competing implementation.

The engine owns the math caret and edits; text layout exposes the placed math geometry used by pointer hit testing and UI overlays. Empty fields are empty native equations; the prompt and shading are editor-only. Existing populated insert.equation calls keep their behavior; an empty parameter object starts the new editing flow. Original storytold#55 commits and authorship remain intact.

Validation

On macOS with Rust 1.95.0:

  • Math/model/text/native-format/PPTX/engine tests: 337 passed.
  • Full egui UI suite: 32 passed, including real ribbon clicks, immediate typing, command completion, exit, tab restoration and click reentry.
  • Eight new engine regressions cover structured editing, selection/copy/cut/paste, undo/redo, native and PPTX round-trips, rotated/RTL text, table-cell hit testing and prose formatting.
  • Rendered and visually inspected synthetic on-slide prompt, fraction, active and exited states.
  • Formatting, asset attribution, layering and all WebAssembly checks pass. Targeted Clippy completes with only existing warnings.

Full cargo xtask ci stops at existing Rust 1.95 Clippy diagnostics in math, matroska, isobmff and xtask; baseline and final logs were checked against unchanged source at those diagnostics. The subsequent test, asset, layering and wasm checks were run separately.

Remaining scope

This depends on storytold#55 and does not resolve its current conflicts with upstream main. Equation ribbon controls, full LaTeX coverage, math-font refinements and validation in native PowerPoint remain separate work. No PowerPoint assets or documents are included.

@shuff57

shuff57 commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Thanks for this, @hajdukste. It's a clear piece of work, and the caret-travels-through-the-equation model is the part I most want to keep.

Direction. The editing here is built on storytold#55's deckcraft-math crate. That crate is being replaced by equaSHion in storytold#192, which sits on current main with no conflicts. storytold#55 stays open for the maintainers to choose, but storytold#192 is the version I expect to carry forward, so this PR can't be merged on top of it as it stands.

Why equaSHion. It is one equation engine shared by WordCraft (storytold/wordcraft#801) and DeckCraft (storytold#192), so equations behave the same in both apps and the editing work (OMML/MathML/LaTeX, the structured editor, the galleries) is done once instead of per app. storytold#192 is also based on current main with no conflicts, whereas storytold#55 has fallen about 800 commits behind.

Why a new PR instead of continuing storytold#55. Moving storytold#55 to equaSHion would replace its deckcraft-math crate wholesale, which is a different change from the one storytold#55's reviewers looked at. Rather than rewrite that PR under them, storytold#192 is separate, and storytold#55 stays open until the maintainers choose.

What I took from your commit. equaSHion main now has what a host needs to run an equation inside the text caret (3d3b840):

  • exit_at_edges(true) reports Left at the start or Right at the end of the root row as EditorResponse::exit, instead of ignoring it. Shift-arrows, an active selection and a caret inside a slot do not exit.
  • EquationEditor::caret_to(Edge) and Editor::move_to_start()/move_to_end(), so a host can enter from either side of the surrounding text.
  • placeholder(&str), for the empty field's prompt.

All three are opt-in; existing callers behave as before. The \alpha-until-Space behaviour was already in equaSHion.

What is still deckcraft-side and not done in storytold#192 yet, all from your commit:

  • arrowing in and out of an equation in the slide's text caret (wiring the exit signal and caret_to)
  • prose formatting restored after exit (prose_props)
  • hit testing and placement in rotated text, RTL text and table cells
  • your regression tests, ported to the equaSHion types

storytold#192 doesn't use the new equaSHion revision yet; its pin is still the one before these changes. If you're happy to port the pieces above against storytold#192 once it's bumped, that would be very welcome, with your authorship kept. If you'd rather not, I'll carry them over myself and credit this PR. Either way I'd rather say so here than leave it ambiguous.

Your note that full CI stops at the Rust 1.95 Clippy diagnostics in math, matroska, isobmff and xtask is useful too; I'll check whether storytold#192 hits the same ones.

@hajdukste

hajdukste commented Oct 15, 2026 •

Copy link
Copy Markdown
Author

Thanks for explaining the direction and for carrying the caret-navigation ideas into equaSHion.

While #192 was still a draft, I put together a combined proposal in storytold#778. It builds on the version of your equaSHion integration available at the time, preserves your commits and authorship, and adds my inline insertion/navigation, formatting and document-history integration, and regression tests. It also now supports equation font selection, including Latin Modern Math.

I see that you’ve since updated #192 further, so #778 doesn’t yet include those latest changes. Before doing another port, could you take a look at #778 as a possible combined basis? That would help us decide which PR to carry forward and avoid duplicating the integration work.

And please feel free to port, adapt, or reuse any of my work however you think best! I’m completely fine with you carrying it into #192 or taking another approach. I’m open to whatever works best for the project, and I’m happy to coordinate.

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.

2 participants