fix: Enable user selection for math static elements - #3061
tsuji-riya wants to merge 4 commits into
Conversation
|
Thank you for this PR, and for the clear description. Making the content of I tested the change in Chrome with
A narrower approach would give you what you need without these side effects:
Would you be willing to update the PR in this direction? A Playwright test for Thanks again for the contribution. |
- Restore `user-select: none` on `.ML__latex` so that the mathfield, `renderMathInElement()` and the static CSS are unchanged - Enable selection only for `[part="render"] .ML__latex` in the shadow root of `<math-span>` and `<math-div>` - Add a `copy` handler that puts the LaTeX source on the clipboard, wrapped in `$...$` / `$$...$$` when copied with surrounding text - Leave the copy behavior unchanged when the selection includes a `<math-field>` - Add Playwright tests and a CHANGELOG entry
|
Thanks for the detailed review! 😃
Let me know if you'd like any changes. |
I would like to enable user selection on
<math-span />and<math-div />elements.To do this, I removed
user-select: nonefrom the.ML__latexCSS class in core.less, so users can now select and copy the math content.But this had a side effect: the
_mathMLContainer(a hidden MathML element used for screen readers/accessibility) also became selectable, causing the same math expression to be duplicated when copied. To fix this, I addeduser-select: nonedirectly on_mathMLContainerin math-static-elements.ts, so only that element is excluded from selection/copy while the visible math stays selectable.