hook_editor_js_settings_alter() I am using hook_editor_js_settings_alter() to disallow HTML tags in Ckeditor. It is only working in node edit form, and Ckeditor is in edit mode. Wen I preview the published page it allows the tags in my disallow custom hook.

The following code was a test to disallow &lt;h1&gt; tags with the class name myHeader2. If I change the class name to myheader, it work in edit mode and published mode. Is the class name the problem?

use Drupal\Core\Form\FormStateInterface;
use Drupal\editor\Entity\Editor;

function mymodule_editor_js_settings_alter(array &amp;$settings) {
  foreach ($settings['editor']['formats'] as $name =&gt; $value) {
    $settings['editor']['formats']['rich_text']['editorSettings']['disallowedContent'] = 'h1(myHeader2)';
  }
}
Navigate to /admin/config/content/formats. For each text format, you can enable the Limit allowed HTML tags and correct faulty HTML filter, which is configurable with the Allowed HTML tags text box at the bottom of the configuration form.

This is how input formats are supposed to be changed.