-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rich text/raw handling: add support for MathML #35005
base: trunk
Are you sure you want to change the base?
Conversation
Size Change: +310 B (0%) Total Size: 1.06 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you need on Core's PHP side to support this? I thought that the last time I checked, Core would mangle MathML. Maybe not?
@@ -134,6 +134,8 @@ export default function cleanNodeList( nodeList, doc, schema, inline ) { | |||
} else if ( | |||
node.parentNode && | |||
node.parentNode.nodeName === 'BODY' && | |||
// To do: figure out why this is needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the TODO "figure out why this cleans/prunes MathML sub-trees by default" or is it something else?
mn: { children: { '#text': {} } }, // Numeric literal. | ||
mo: { children: { '#text': {} }, attributes: [ 'stretchy' ] }, // Operator. | ||
ms: { children: { '#text': {} } }, // String literal. | ||
mtext: { children: { '#text': {} } }, // Arbitrary text. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we missing annotation-xml
here?
Description
Currently it's not possible to paste MathML into Gutenberg. Tags will get stripped.
It is possible to insert it in HTML mode, but in visual mode the tags are not protected from editing.
This PR adds a schema for MathML to the raw handler and protects the
math
element in rich text.MathML rendering is supported in Safari and Firefox, but unfortunately Chrome and other browsers don't render it properly (it's just rendered as inline text). The user can add the MathJax script on the front-end, which renders it properly across all browsers. The MathJax scripts detects the
math
elements and transforms them. In the future we could consider adding the script to core and load it if amath
element is detected on the page.Also worth nothing that the work being done here could also enable support for ruby elements, which are quite similar for rich text to handle.
How has this been tested?
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).