Class: CKEditor5::Rails::Plugins::SpecialCharactersBootstrap

Inherits:
Editor::PropsInlinePlugin show all
Defined in:
lib/ckeditor5/rails/plugins/special_characters_bootstrap.rb

Constant Summary collapse

PLUGIN_CODE =
<<~JS
  const { Plugin } = await import( 'ckeditor5' );

  return class SpecialCharactersBootstrap extends Plugin {
    static get pluginName() {
      return 'SpecialCharactersBootstrap';
    }

    get bootstrapConfig() {
      return this.editor.config.get('specialCharactersBootstrap');
    }

    async init() {
      const { editor, bootstrapConfig } = this;
      const currentConfig = editor.config.get('specialCharacters');

      if (!bootstrapConfig) {
        return;
      }

      editor.config.define('specialCharacters', {
        ...currentConfig,
        order: bootstrapConfig.order || currentConfig.order,
      } );
    }

    async afterInit() {
      const { editor, bootstrapConfig } = this;
      const specialCharacters = editor.plugins.get('SpecialCharacters');

      if (!specialCharacters || !bootstrapConfig) {
        return;
      }

      const groups = bootstrapConfig.groups || [];

      for (const { name, items, options } of groups) {
        specialCharacters.addItems(name, items, {
          label: name,
          ...options
        });
      }
    }
  }
JS

Instance Attribute Summary

Attributes inherited from Editor::PropsInlinePlugin

#code

Attributes inherited from Editor::PropsBasePlugin

#assets_bundle, #name

Instance Method Summary collapse

Methods inherited from Editor::PropsInlinePlugin

#compress!, #to_h

Methods inherited from Editor::PropsBasePlugin

normalize, #preload_assets_bundle, #to_h

Constructor Details

#initializeSpecialCharactersBootstrap

Returns a new instance of SpecialCharactersBootstrap.



53
54
55
56
# File 'lib/ckeditor5/rails/plugins/special_characters_bootstrap.rb', line 53

def initialize
  super(:SpecialCharactersBootstrap, PLUGIN_CODE)
  compress!
end