Skip to content

Commit 60d87d9

Browse files
committed
DOC-3189: Add new options for preserving MathML elements and attributes in the Math plugin.
1 parent 0421cfb commit 60d87d9

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
@@ -69,6 +69,54 @@ The {productname} {release-version} release includes an accompanying release of
6969

7070
For information on the **<Premium plugin name 1>** plugin, see: xref:<plugincode>.adoc[<Premium plugin name 1>].
7171

72+
=== Math
73+
74+
The {productname} {release-version} release includes an accompanying release of the **Math** premium plugin.
75+
76+
**Math** includes the following fix.
77+
78+
==== New `extended_mathml_attributes` and `extended_mathml_elements` options.
79+
// #TINY-11756
80+
81+
== New options for customizing allowed MathML elements and attributes
82+
83+
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].
84+
85+
Prior to {release-version}, MathML elements and attributes could be configured informally, but were not officially supported. With enhanced security measures introduced in {productname} {release-version}, MathML content is now filtered separately from HTML using DOMPurify, and any unsupported elements or attributes are stripped from the editor content. This change increased security but removed the ability to allow certain MathML-specific content.
86+
87+
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.
88+
89+
**`+extended_mathml_elements+`**: allows a list of additional MathML elements to be preserved.
90+
**`+extended_mathml_attributes+`**: allows a list of additional MathML attributes to be preserved.
91+
92+
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.
93+
94+
.Example of MathML with preserved elements and attributes
95+
[source,js]
96+
----
97+
tinymce.init({
98+
selector: "textarea",
99+
extended_mathml_elements: [ "mn" ],
100+
extended_mathml_attributes: [ "linebreak" ]
101+
});
102+
----
103+
104+
.Example of MathML with preserved elements and attributes
105+
[source,html]
106+
----
107+
<p>
108+
<math xmlns="http://www.w3.org/1998/Math/MathML">
109+
<mrow><mn>0.196</mn></mrow>
110+
<mspace linebreak="newline"></mspace>
111+
<mrow><mo>=</mo></mrow>
112+
<mspace linebreak="newline"></mspace>
113+
<mrow><mn>0.196</mn></mrow>
114+
</math>
115+
</p>
116+
----
117+
118+
For information on the **Math** premium plugin, see: xref:math.adoc[Math].
119+
72120

73121
[[accompanying-premium-plugin-end-of-life-announcement]]
74122
== Accompanying Premium plugin end-of-life announcement

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)