From 634ca8f3de74174593e21f6755a8741c4024ae41 Mon Sep 17 00:00:00 2001 From: Karl Kemister-Sheppard Date: Tue, 21 Jul 2026 15:51:26 +1000 Subject: [PATCH 1/3] Docs: TINYDOC-3494 - Add guidance for disabling or stripping HTML formatting --- modules/ROOT/pages/content-filtering.adoc | 43 ++++++++++++++++++++++ modules/ROOT/pages/content-formatting.adoc | 2 + 2 files changed, 45 insertions(+) diff --git a/modules/ROOT/pages/content-filtering.adoc b/modules/ROOT/pages/content-filtering.adoc index 6a4378fe3c..9d3a21b2fc 100644 --- a/modules/ROOT/pages/content-filtering.adoc +++ b/modules/ROOT/pages/content-filtering.adoc @@ -6,6 +6,49 @@ Use `+valid_elements+` to define which elements and attributes are allowed, `+invalid_elements+` to block specific elements, and `+extended_valid_elements+` to add or modify rules. For paste-time filtering, use the `+PastePreProcess+` and `+PastePostProcess+` events or the xref:introduction-to-powerpaste.adoc[PowerPaste] plugin options. +[[disabling-or-stripping-html-formatting]] +== Disabling or stripping HTML formatting + +{productname} validates and cleans content against a schema whenever content is set, pasted, or retrieved. The schema is represented by the xref:apis/tinymce.html.schema.adoc[Schema] API, and content is parsed against it by the xref:apis/tinymce.html.domparser.adoc[DomParser] API, which removes any element or attribute that the schema does not allow. The content filtering options on this page configure that schema: + +* `+valid_elements+` replaces the set of allowed elements and attributes. Internally this calls `+schema.setValidElements()+`. +* `+extended_valid_elements+` adds to the existing set rather than replacing it. Internally this calls `+schema.addValidElements()+`. +* `+invalid_elements+` removes specific elements from the content, keeping their text. + +To restrict content to a limited subset of formatting, set `+valid_elements+` to only the elements and attributes that should be kept. Any element outside the list is removed and its text content is preserved. + +[source,js] +---- +tinymce.init({ + selector: 'textarea', // change this value according to your HTML + valid_elements: 'p,br,a[href],strong/b,em/i' +}); +---- + +This configuration keeps paragraphs, line breaks, links (with their `+href+` attribute), and bold and italic text, converting `+b+` to `+strong+` and `+i+` to `+em+`. All other elements, such as headings, tables, and inline styles, are stripped and their text is retained. + +To remove only specific formatting while keeping everything else, use `+invalid_elements+`. + +[source,js] +---- +tinymce.init({ + selector: 'textarea', // change this value according to your HTML + invalid_elements: 'strong,b,em,i,u,span' +}); +---- + +To remove all formatting from pasted content so that only plain text is inserted, set xref:copy-and-paste.adoc#paste_as_text[paste_as_text] to `+true+`. + +[source,js] +---- +tinymce.init({ + selector: 'textarea', // change this value according to your HTML + paste_as_text: true +}); +---- + +For a complete reference of the element and attribute syntax used by `+valid_elements+`, `+extended_valid_elements+`, and `+invalid_elements+`, see the option descriptions below. To customize how content is styled and defined rather than restricted, see xref:content-formatting.adoc[Content formats]. + include::partial$configuration/allow_conditional_comments.adoc[] include::partial$configuration/allow_html_in_comments.adoc[] diff --git a/modules/ROOT/pages/content-formatting.adoc b/modules/ROOT/pages/content-formatting.adoc index bd4f7fd81b..6e91fe1ffa 100644 --- a/modules/ROOT/pages/content-formatting.adoc +++ b/modules/ROOT/pages/content-formatting.adoc @@ -2,6 +2,8 @@ :navtitle: Content formats :description: These options change the way the editor handles the input and output of content. This will help you to create clean, maintainable and readable content. +The options on this page define and customize the text formats available in the editor. To restrict, disable, or strip HTML formatting from content, such as limiting the allowed elements or removing formatting from pasted text, see xref:content-filtering.adoc#disabling-or-stripping-html-formatting[Disabling or stripping HTML formatting]. + include::partial$configuration/formats.adoc[] include::partial$configuration/format_empty_lines.adoc[] From a97f6c9f8333d02264a56e226e0efed557df6ae0 Mon Sep 17 00:00:00 2001 From: Karl Kemister-Sheppard Date: Wed, 22 Jul 2026 09:02:53 +1000 Subject: [PATCH 2/3] Docs: TINYDOC-3494 - Remove internal function references from filtering guidance --- modules/ROOT/pages/content-filtering.adoc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/ROOT/pages/content-filtering.adoc b/modules/ROOT/pages/content-filtering.adoc index 9d3a21b2fc..16079d7ba3 100644 --- a/modules/ROOT/pages/content-filtering.adoc +++ b/modules/ROOT/pages/content-filtering.adoc @@ -9,12 +9,14 @@ Use `+valid_elements+` to define which elements and attributes are allowed, `+in [[disabling-or-stripping-html-formatting]] == Disabling or stripping HTML formatting -{productname} validates and cleans content against a schema whenever content is set, pasted, or retrieved. The schema is represented by the xref:apis/tinymce.html.schema.adoc[Schema] API, and content is parsed against it by the xref:apis/tinymce.html.domparser.adoc[DomParser] API, which removes any element or attribute that the schema does not allow. The content filtering options on this page configure that schema: +{productname} validates and cleans content against a schema whenever content is set, pasted, or retrieved. The schema defines which elements and attributes are allowed, and any element or attribute outside the schema is removed when the content is parsed. The content filtering options on this page configure that schema: -* `+valid_elements+` replaces the set of allowed elements and attributes. Internally this calls `+schema.setValidElements()+`. -* `+extended_valid_elements+` adds to the existing set rather than replacing it. Internally this calls `+schema.addValidElements()+`. +* `+valid_elements+` replaces the set of allowed elements and attributes. +* `+extended_valid_elements+` adds to the existing set rather than replacing it. * `+invalid_elements+` removes specific elements from the content, keeping their text. +For a reference of the underlying validation and parsing mechanism, see the xref:apis/tinymce.html.schema.adoc[Schema] and xref:apis/tinymce.html.domparser.adoc[DomParser] API documentation. + To restrict content to a limited subset of formatting, set `+valid_elements+` to only the elements and attributes that should be kept. Any element outside the list is removed and its text content is preserved. [source,js] From d2f9d8b6aee8e20dc106a80f1e3f815592556eab Mon Sep 17 00:00:00 2001 From: Karl Kemister-Sheppard Date: Wed, 22 Jul 2026 09:07:34 +1000 Subject: [PATCH 3/3] Docs: TINYDOC-3494 - Link option mentions to their section anchors --- modules/ROOT/pages/content-filtering.adoc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/ROOT/pages/content-filtering.adoc b/modules/ROOT/pages/content-filtering.adoc index 16079d7ba3..8b7a003ae3 100644 --- a/modules/ROOT/pages/content-filtering.adoc +++ b/modules/ROOT/pages/content-filtering.adoc @@ -11,13 +11,13 @@ Use `+valid_elements+` to define which elements and attributes are allowed, `+in {productname} validates and cleans content against a schema whenever content is set, pasted, or retrieved. The schema defines which elements and attributes are allowed, and any element or attribute outside the schema is removed when the content is parsed. The content filtering options on this page configure that schema: -* `+valid_elements+` replaces the set of allowed elements and attributes. -* `+extended_valid_elements+` adds to the existing set rather than replacing it. -* `+invalid_elements+` removes specific elements from the content, keeping their text. +* xref:#valid_elements[`+valid_elements+`] replaces the set of allowed elements and attributes. +* xref:#extended_valid_elements[`+extended_valid_elements+`] adds to the existing set rather than replacing it. +* xref:#invalid_elements[`+invalid_elements+`] removes specific elements from the content, keeping their text. For a reference of the underlying validation and parsing mechanism, see the xref:apis/tinymce.html.schema.adoc[Schema] and xref:apis/tinymce.html.domparser.adoc[DomParser] API documentation. -To restrict content to a limited subset of formatting, set `+valid_elements+` to only the elements and attributes that should be kept. Any element outside the list is removed and its text content is preserved. +To restrict content to a limited subset of formatting, set xref:#valid_elements[`+valid_elements+`] to only the elements and attributes that should be kept. Any element outside the list is removed and its text content is preserved. [source,js] ---- @@ -29,7 +29,7 @@ tinymce.init({ This configuration keeps paragraphs, line breaks, links (with their `+href+` attribute), and bold and italic text, converting `+b+` to `+strong+` and `+i+` to `+em+`. All other elements, such as headings, tables, and inline styles, are stripped and their text is retained. -To remove only specific formatting while keeping everything else, use `+invalid_elements+`. +To remove only specific formatting while keeping everything else, use xref:#invalid_elements[`+invalid_elements+`]. [source,js] ---- @@ -49,7 +49,7 @@ tinymce.init({ }); ---- -For a complete reference of the element and attribute syntax used by `+valid_elements+`, `+extended_valid_elements+`, and `+invalid_elements+`, see the option descriptions below. To customize how content is styled and defined rather than restricted, see xref:content-formatting.adoc[Content formats]. +For a complete reference of the element and attribute syntax used by xref:#valid_elements[`+valid_elements+`], xref:#extended_valid_elements[`+extended_valid_elements+`], and xref:#invalid_elements[`+invalid_elements+`], see the option descriptions below. To customize how content is styled and defined rather than restricted, see xref:content-formatting.adoc[Content formats]. include::partial$configuration/allow_conditional_comments.adoc[]