techdivision/ckstyles

Last activity on 1 January 2021
  • 10
  • 5
  • 12514
composer require techdivision/ckstyles

Neos package which enables you adding your custom style classes for the CkEditor with a simple Yaml configuration

v1.1.2

Neos package which enables you adding your custom style classes for the CkEditor with a simple Yaml configuration

Homepage
https://www.techdivision.com
Version
v1.1.2
Type
neos-plugin
Release Date
20.01.2021 10:07:12
Source
git
Distribution
zip
Requires
Requires (dev)
None
Suggest
None
Provides
None
Conflicts
None
Replaces
None
GPL-3.0+
  • #flow
  • #wysiwyg
  • #ckeditor
  • #classes
  • #inline
  • #neos
  • #editing
  • #styling
e87d8d2944e5d2c4da24b45e03656f1e99d95808

TechDivision.CkStyles

This package allows to add different styles based on your css-classes for the CkEditor in Neos.
You can define the classes in you yaml configuration.
Styles can be applied both on block- and element level.

Demo: Applying inline style

Example output:

Example output

<p class="my-class-indent-2">
  This is an 
  <span class="my-class-size-large">awesome</span> 
  inline editable 
  <span class="my-class-red">text with some custom</span> 
  styling :)
</p>

Benefits

In most projects there are requirements that you cannot achieve with tags alone and you need classes under editorial control - e.g. if you want to highlight some text with font size but don't use a headline for SEO reasons or want to add an icon, adjust the font color ...

Getting started

Default composer installation

composer require techdivision/ckstyles

Define some global presets for usage in different NodeTypes:

TechDivision:
  CkStyles:
    InlineStyles:
      presets:
        'fontColor':
          label: 'Font color'
          options:
            'primary':
              label: 'Red'
              cssClass: 'my-class-red'
            'secondary':
              label: 'Green'
              cssClass: 'my-class-green'
        'fontSize':
          label: 'Font size'
          options:
            'small':
              label: 'Small'
              cssClass: 'my-class-size-small'
            'big':
              label: 'Large'
              cssClass: 'my-class-size-large'
    BlockStyles:
      presets:
        'indent':
          label: 'Indentation'
          options:
            'primary':
              label: '2 rem'
              cssClass: 'my-class-indent-2'
            'secondary':
              label: '4 rem'
              cssClass: 'my-class-indent-4'
            '':
              label: 'remove indent'
              cssClass: null

Example: Configuration/Settings.yaml

Note: Using an empty class (cssClass: null) to unset the value might cause errors during rendering in the backend. The select boxes of this package contain an "x" button for resetting the value.

Activate the preset for your inline editable NodeType property:

'Neos.NodeTypes.BaseMixins:TextMixin':
  abstract: true
  properties:
    text:
      ui:
        inline:
          editorOptions:
            inlineStyling:
              fontColor: true
              fontSize: true
            blockStyling:
              indent: true

Example: Configuration/NodeTypes.Override.BaseMixins.yaml

Add the styling for your presets in your scss, less or css:

.my-class-red {
  color: red;
}
.my-class-green {
  color: green;
}
.my-class-size-small {
  font-size: 10px;
}
.my-class-size-large {
  font-size: 25px;
}
.my-class-indent-2 {
  text-indent: 2rem;
}
.my-class-indent-4 {
  text-indent: 4rem;
}

Development

This project works with yarn. The build process given by the neos developers is not very configurable, only the target dir for the buildprocess is adjustable by package.json.

nvm install

If you don't have yarn already installed:

brew install yarn

Build the app:

./build.sh

Contribute

You are very welcome to contribute by merge requests, adding issues etc.

Thank you 🤝 Sebastian Kurfürst for the great workshop which helped us implementing this.

The content of the readme is provided by Github
The same vendor provides 15 package(s).