How to add custom config or JS for post editor?

If you want to allow some custom tags in the WYSIWYG 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:

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

Since Publii 0.48 the WYSIWYG editor uses HugeRTE, a fork of TinyMCE 6, instead of TinyMCE 5. The old file names, tinymce.override.json and tinymce.script.js, still work, but Publii logs a deprecation warning and will stop reading them in a future release. Publii also converts option and toolbar names that HugeRTE renamed, such as styleselect to styles, and skips plugins and options that HugeRTE removed.

Please remember that you can also override the editor config globally by placing wysiwyg.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 forecolor publiilink unlink emoticons blockquote alignleft aligncenter alignright bullist numlist image gallery media table toc"

toolbar2: "styles blocks codesample searchreplace hr readmore undo redo restoredraft removeformat sourcecode"

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

{
   "toolbar2": ""
  }

A list of all available editor options can be found in the HugeRTE documentation. We do not guarantee that all of them will work with Publii.

Create your first website with Publii

Join thousands of creators who chose independence. Create content locally and publish lightning-fast, secure websites on your own terms.

Download Publii

Free and open source. Windows, macOS and Linux.

Read the getting started guide