How to add custom config or JS for post editor?

If you want to allow some custom tags in the TinyMCE editor - since Publii v.0.38.0 you can do it under site settings.

In Publii 0.18.2 we have added a new feature - you can add custom config and JS to the post editor directly from your theme.

In you theme config.json file, please add the following section:

"extensions": {
        "postEditorConfigOverride": true,
        "postEditorCustomScript": true

Then please add in the theme root directory the following files:

  • tinymce.override.json - it will allow you to override default TinyMCE configuration,
  • tinymce.script.js - it will run your JS code after post editor initialization.

Please remember that you can also override TinyMCE config globally by placing tinymce.override.json file in the Publii config directory - this override is overridden by the theme override if it exists.

You can modify both toolbars of the editor by adding or removing the available options. By default the toolbars include the following options:

toolbar1: "bold italic underline strikethrough link unlink blockquote alignleft aligncenter alignright bullist numlist image gallery media table toc"

toolbar2: "styleselect formatselect searchreplace hr readmore removeformat undo redo restoredraft sourcecode "

E.g., you can remove the second toolbar of the editor by placing in TinyMCE.override.json file the following code:

   "toolbar2": ""

A list of all available TinyMCE editor options can be found here. We do not guarantee that all of them will work with Publii.