GitHub Download

How to add custom config or JS for post editor?

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.

Subscribe

Get the latest Publii news, updates and more delivered directly to your email inbox

You can change your mind at any time by clicking the unsubscribe link in the footer of any email you receive from us, or by contacting us at contact@tidycustoms.net. By clicking below, you agree that we may process your information in accordance with our Privacy Policy.