raffaelj/cockpit-cms-editorformats

Fork of pauloamgomes/cockpit-editorformats - Cockpit CMS v1 addon that extends core functionality by introducing the possibility to define editor format modes to the WYSIWYG field (based on tinymce editor).

1.0.0 2023-11-24 17:09 UTC

This package is auto-updated.

Last update: 2024-11-24 19:16:04 UTC


README

Fork of Paulo Gomes' EditorFormats addon for Cockpit CMS v1, which is not maintained anymore.

Links to original source and author:

This addon is not compatible with Cockpit CMS v2.

See also Cockpit CMS v1 docs, Cockpit CMS v1 repo and Cockpit CMS v2 docs, Cockpit CMS v2 repo.

This addon extends Cockpit CMS v1 core functionality by introducing the possibility to define editor format modes to the WYSIWYG field (based on tinymce editor). When configuring a WYSIWYG field, cockpit already provides the possiblity to extend the default settings on the field definition:

{
  "editor": {
    "height": 500,
    "menubar": "edit insert view format",
    "plugins": [
        "link lists preview hr anchor",
        "code fullscreen",
    ]
  }
}

that is quite interesting, but can be painful and confusing when dealing with many fields, so that's where this addon can help, you just need to configure your formats (e.g. Basic, Advanced, etc..) and use the format name on your field instead of the configuration:

{
  "editor": {
    "format": "Basic",
  }
}

Installation

Copy this repository into /addons and name it EditorFormats or use the cli.

via git

cd path/to/cockpit
git clone https://codeberg.org/raffaelj/cockpit-cms-EditorFormats.git addons/EditorFormats

via cp cli

cd path/to/cockpit
./cp install/addon --name EditorFormats --url https://codeberg.org/raffaelj/cockpit-cms-EditorFormats/archive/main.zip

via composer

Make sure, that the path to cockpit addons is defined in your projects' composer.json file.

{
    "name": "my/cockpit-project",
    "extra": {
        "installer-paths": {
            "addons/{$name}": ["type:cockpit-module"]
        }
    }
}
cd path/to/cockpit-root
composer create-project --ignore-platform-reqs raffaelj/cockpit .
composer config extra.installer-paths.addons/{\$name} "type:cockpit-module"

composer require --ignore-platform-reqs raffaelj/cockpit-cms-editorformats

Configuration

The Addon doesn't require any extra configuration. When enabled, it will be available to the admin with all features.

Permissions

There are two permissions

  • manage - that can be used to manage the formats
  • access - is used to use the editor, if you are using the editor as non admin user you need to add that permission

example configuration in config/config.php:

<?php
return [
    // cockpit user groups settings
    'groups' => [
        'manager' => [
            'editorformats' => [
                'manage' => true,
                'access' => true,
            ],
        ],
        'author' => [
            'editorformats' => [
                'access' => true,
            ],
        ],
    ],

Usage

Create the formats you need, in most of the cases you only need a Basic format with minimum features:

TODO: add screenshot or text description of broken/linked image

Edit your YYSIWYG fields and set the format:

{
  "editor": {
    "format": "Basic",
  }
}

And when editing a collection that is using that field your editor should look like below:

TODO: add screenshot or text description of broken/linked image

However if you need more features from the editor create a new format (e.g. Advanced):

TODO: add screenshot or text description of broken/linked image

Edit your YYSIWYG fields and set the format:

{
  "editor": {
    "format": "Advanced",
  }
}

And when editing a collection that is using that field your editor should look like below:

TODO: add screenshot or text description of broken/linked image

Demo

http://www.youtube.com/watch?v=ZKx8KztgCIE

Copyright and license

Copyright 2018 pauloamgomes under the MIT license.