id-Attribut zulassen in h1-Tags / -Elementen

To allow the id attribute in h1 elements (or in any other element), only a few adjustments to the Rich Text Editor configuration files are required. This example refers to customizing the TYPO3 Introduction Package, but the approach can be applied to most other use cases as well.

 

First, we create an override of the base configuration file (in YAML format). In our example:

 

\typo3conf\ext\bootstrap_package\Configuration\RTE\Editor\Base.yaml

 

Here, we extend the property

 

extraAllowedContent

 

with the additional options we want to allow. For example, we change

 

extraAllowedContent:  "*(*)[data-*]"

 

to

 

extraAllowedContent: ["*(*)[data-*]","h1[id]","h2[id]","h3[id]","h4[id]","h5[id]"]

 

We therefore change the entry into an array and allow the id attribute for the h1 through h5 headings. We then include the newly created override in the main configuration, in our case:

 

\typo3conf\ext\bootstrap_package\Configuration\RTE\Default.yaml

 

Under imports:, we add:

 

- { resource: "EXT:bootstrap_package/Configuration/RTE/Editor/Base.yaml" }

 

That's it. And one important point when working with YAML files: never use tabs for indentation. Use regular spaces instead; otherwise, you may encounter errors. Tested with TYPO3 8.7.1.