Math format: seed LaTeX input from the current selection#79052
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +68 B (0%) Total Size: 8.46 MB 📦 View Changed
|
|
Interesting case, it took me a moment to figure out how to paste LaTex without creating a block 😄 UX, question: What should happen if you click the toolbar button when an active math format is selected? Currently, clears the format, though that's not apparent from the label button. Should we be doing that, or should we just let the user remove the format via a popover? |
I guess it should revert to the LaTeX representation so that if you click the button twice, you end up in exactly the same state. |
|
Currently, it will remove the active format, which can be unexpected. I think ScreencastCleanShot.2026-06-09.at.20.01.01.mp4 |
The Math inline format previously ignored the current selection and opened an empty popover. Like other inline formats, it should act on a selection: when text is selected, use it as the initial LaTeX, render it immediately, and replace the selection with the math object. Invalid expressions are inserted unrendered with the text prefilled so they can be corrected in the popover. Fixes #73035. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Clicking the toolbar button while a math object is active now reverts it to the LaTeX text it was created from, so clicking twice round-trips to the original state. Previously the active object was replaced unexpectedly. Co-Authored-By: Claude Opus 4.8 <[email protected]>
ee77716 to
e3ad6a2
Compare
|
Looks good! Should we keep the text selected after removing the format? |
When clicking the button reverts an active math object to its LaTeX source, keep that text selected rather than collapsing to a caret, so it can be edited or re-marked as math right away. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Flaky tests detected in bd0e902. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/27259980168
|
|
Looks good to me, go for it 🙂 |
|
Sorry, I was experimenting with something, but didn't make it in time. Here's a small follow-up - #79081. |


What?
Fixes #73035.
The Math inline format previously ignored the current selection and opened an empty popover. This PR changes it so a selection transfers.
Why?
It's a small fix that feels nice and less destructive.
Testing Instructions
Type out latex in a paragraph, select it, then choose the inline math format. The formula should transfer.
Use of AI Tools
Claude Opus 4.8.