Skip to content

Commit 9776675

Browse files
authored
DOC-3189: Add new options for preserving MathML elements and attributes in the Math plugin (#3681)
* DOC-3189: Add new options for preserving MathML elements and attributes in the Math plugin. * Update modules/ROOT/pages/7.8.0-release-notes.adoc * Update modules/ROOT/pages/7.8.0-release-notes.adoc * Update modules/ROOT/pages/7.8.0-release-notes.adoc * Update modules/ROOT/pages/7.8.0-release-notes.adoc
1 parent fd276f7 commit 9776675

File tree

4 files changed

+157
-0
lines changed

4 files changed

+157
-0
lines changed

modules/ROOT/pages/7.8.0-release-notes.adoc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,54 @@ Previously, deleting a comment reply did not dispatch a `change` event, which pr
101101

102102
For information on the **Comments** plugin, see: xref:introduction-to-tiny-comments.adoc[Introduction to {companyname} Comments].
103103

104+
=== Math
105+
106+
The {productname} {release-version} release includes an accompanying release of the **Math** premium plugin.
107+
108+
**Math** includes the following addition.
109+
110+
==== New `extended_mathml_attributes` and `extended_mathml_elements` options.
111+
// #TINY-11756
112+
113+
To improve flexibility when working with MathML content, especially in cases where new attributes or elements are not yet supported by DOMPurify, two new configuration options have been introduced: xref:math.adoc#extended-mathml-elements[extended_mathml_elements] and xref:math.adoc#extended-mathml-attributes[extended_mathml_attributes].
114+
115+
Prior to {release-version}, MathML elements and attributes were treated the same as all other content, with no special handling for MathML-specific structures. As a result, unsupported elements and attributes were either retained without validation or stripped without regard to their MathML context.
116+
117+
In {productname} {release-version}, MathML content is now filtered separately from general HTML using DOMPurify. As part of this change, support has been added to selectively allow specific elements and attributes *within* a `<math>` element using the new configuration options.
118+
119+
The new options allow users to define lists of MathML elements and attributes that should be preserved, even if DOMPurify does not currently recognize them. This enables quicker user-side updates in response to evolving MathML specifications without disabling sanitization or waiting for upstream changes.
120+
121+
* **`+extended_mathml_elements+`**: allows a list of additional MathML elements to be preserved.
122+
* **`+extended_mathml_attributes+`**: allows a list of additional MathML attributes to be preserved.
123+
124+
These options apply only within MathML contexts and do not affect general HTML content. They enable use cases such as preserving `+<mn>+` elements and attributes like `linebreak` in MathML expressions.
125+
126+
.Example of MathML with preserved elements and attributes
127+
[source,js]
128+
----
129+
tinymce.init({
130+
selector: "textarea",
131+
extended_mathml_elements: [ "mn" ],
132+
extended_mathml_attributes: [ "linebreak" ]
133+
});
134+
----
135+
136+
.Example of MathML with preserved elements and attributes
137+
[source,html]
138+
----
139+
<p>
140+
<math xmlns="http://www.w3.org/1998/Math/MathML">
141+
<mrow><mn>0.196</mn></mrow>
142+
<mspace linebreak="newline"></mspace>
143+
<mrow><mo>=</mo></mrow>
144+
<mspace linebreak="newline"></mspace>
145+
<mrow><mn>0.196</mn></mrow>
146+
</math>
147+
</p>
148+
----
149+
150+
For information on the **Math** premium plugin, see: xref:math.adoc[Math].
151+
104152
=== Export to Word
105153

106154
The {productname} {release-version} release includes an accompanying update to the **Export to Word** premium plugin.

modules/ROOT/pages/math.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ include::partial$misc/plugin-toolbar-button-id-boilerplate.adoc[]
7272

7373
include::partial$misc/plugin-menu-item-id-boilerplate.adoc[]
7474

75+
== Options
76+
77+
include::partial$configuration/extended_mathml_elements.adoc[leveloffset=+1]
78+
79+
include::partial$configuration/extended_mathml_attributes.adoc[leveloffset=+1]
80+
7581
== Commands
7682

7783
The {pluginname} plugin provides the following {productname} commands.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[[extended-mathml-attributes]]
2+
== `+extended_mathml_attributes+`
3+
4+
This option allows a specific list of additional MathML attributes to be preserved in the editor content, even if they are not included in the default DOMPurify allowlist. This setting only affects attributes used within MathML markup and has no effect on general HTML content.
5+
6+
*Type:* `+Array+` of `+Strings+`
7+
8+
*Default value:* `+[]+` (empty array)
9+
10+
=== Example: using `+extended_mathml_attributes+`
11+
12+
[source,js]
13+
----
14+
tinymce.init({
15+
selector: 'textarea',
16+
extended_mathml_attributes: [ 'linebreak', 'encoding' ]
17+
});
18+
----
19+
20+
.Example of MathML with preserved attributes
21+
[source,html]
22+
----
23+
<p>
24+
<math xmlns="http://www.w3.org/1998/Math/MathML">
25+
<mrow linebreak="newline" encoding="utf8">
26+
<mi>x</mi>
27+
<mo>=</mo>
28+
<mfrac>
29+
<mrow>
30+
<mo>&#x2212;</mo>
31+
<mi>b</mi>
32+
<mo>&#x00B1;</mo>
33+
<msqrt>
34+
<mrow>
35+
<msup>
36+
<mi>b</mi>
37+
<mn>2</mn>
38+
</msup>
39+
<mo>&#x2212;</mo>
40+
<mn>4</mn>
41+
<mo>&#x2062;</mo>
42+
<mi>a</mi>
43+
<mo>&#x2062;</mo>
44+
<mi>c</mi>
45+
</mrow>
46+
</msqrt>
47+
</mrow>
48+
<mrow>
49+
<mn>2</mn>
50+
<mo>&#x2062;</mo>
51+
<mi>a</mi>
52+
</mrow>
53+
</mfrac>
54+
</mrow>
55+
</math>
56+
</p>
57+
----
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[[extended-mathml-elements]]
2+
== `+extended_mathml_elements+`
3+
4+
This option allows a specific list of additional MathML elements to be preserved in the editor content, even if they are not included in the default DOMPurify allowlist. This setting only affects elements used within MathML markup and has no effect on general HTML content.
5+
6+
*Type:* `+Array+` of `+Strings+`
7+
8+
*Default value:* `+[]+` (empty array)
9+
10+
=== Example: using `+extended_mathml_elements+`
11+
12+
[source,js]
13+
----
14+
tinymce.init({
15+
selector: 'textarea',
16+
extended_mathml_elements: [ 'mn', 'mspace' ]
17+
});
18+
----
19+
20+
.Example of MathML with preserved elements
21+
[source,html]
22+
----
23+
<p>
24+
<math xmlns="http://www.w3.org/1998/Math/MathML">
25+
<mrow>
26+
<mi>a</mi>
27+
<mo>=</mo>
28+
<mfrac>
29+
<mrow>
30+
<mn>1</mn>
31+
<mo>+</mo>
32+
<mn>√2</mn>
33+
</mrow>
34+
<mn>3</mn>
35+
</mfrac>
36+
<mspace width="1em"></mspace>
37+
<mo>&#x222A;</mo>
38+
<mspace width="1em"></mspace>
39+
<msup>
40+
<mn>5</mn>
41+
<mn>2</mn>
42+
</msup>
43+
</mrow>
44+
</math>
45+
</p>
46+
----

0 commit comments

Comments
 (0)