ckeditor5-dropdownui

1.0.1 • Public • Published

CKEditor 5 generic dropdown UI feature

This package implements generic dropdown UI feature for CKEditor 5.

Disclaimer

It's an early release: No tests and no much documentation at the moment.

Feel free to contribute !

Demo

dropdown-for-anything

Documentation

Installation

npm i ckeditor5-dropdownui

Usage

The plugin has two methods to call from the config.

  • DropdownCreator creates a command from the plugins section
  • dropdownUI populate its config directly from a toolbar section and returns the dropdown command.

It doesn't create subcommand on the fly, but use command already existing in the build.

The name of the dropdown can be seen as a prefix for commands, here, the 'alignLeft' option in the 'imageStyle' dropdown will call 'imageStyle:alignLeft'. But you can put a ':' in the option name, and the name of the command will be used as is.

Implem looks like this :

import {DropdownCreator, dropdownUI} from 'ckeditor5-dropdownui/src/dropdownui'
 
export default {
 
    plugins: [
        ...
        DropdownCreator('imageStyle'),
        DropdownCreator('mediaWidth'),
        DropdownCreator('allIWant')
        ...
    ],
 
    toolbar: [
        ...
        dropdownUI('imageStyle').set({
            title: 'Select image alignment',
            icon: alignOptionsIcon,
            options: [
                'alignLeft',
                'alignCenter',
                'alignRight'
            ]
        }),
        dropdownUI('mediaWidth').set({
            title: 'Select media width',
            icon: widthOptionsIcon,
            dynamicIcon: false,
            options: [
               'full',
               'threeQuarters',
               'twoThirds',
               'half',
               'third',
               'quarter'
            ]
        }),
        dropdownUI('allIWant').set({
            title: 'Select media width',
            icon: widthOptionsIcon,
            dynamicIcon: false,
            isVertical: false,
            options: [
                'imageStyle:alignLeft',
                'imageStyle:alignCenter',
                'imageStyle:alignRight'
                'mediaWidth:full',
                'mediaWidth:threeQuarters',
                'mediaWidth:twoThirds',
                'mediaWidth:half',
                'mediaWidth:third',
                'mediaWidth:quarter'
            ]
        }),
        ...
    ],

License

Licensed under the terms of GNU General Public License Version 2 or later. For full details about the license, please check the LICENSE.md file.

Package Sidebar

Install

npm i ckeditor5-dropdownui

Weekly Downloads

3

Version

1.0.1

License

GPL-2.0-or-later

Unpacked Size

8.93 kB

Total Files

9

Last publish

Collaborators

  • didask-dev