Module: CKEditor5::Rails::Context::Helpers

Includes:
CKEditor5::Rails::Cdn::Concerns::InlinePluginsTagsBuilder
Included in:
Helpers
Defined in:
lib/ckeditor5/rails/context/helpers.rb

Instance Method Summary collapse

Methods included from CKEditor5::Rails::Cdn::Concerns::InlinePluginsTagsBuilder

#ckeditor5_inline_plugins_tags

Instance Method Details

#ckeditor5_context(preset = nil) { ... } ⇒ Object

Creates a CKEditor context component that can be shared between multiple editors. This allows you to define common plugins that will be available to all editors within the context.

Examples:

Basic usage with shared plugins

<% preset = ckeditor5_context_preset do
  plugins :Mention, :Emoji  # These plugins will be shared across all editors
end %>

<%= ckeditor5_context(preset) do %>
  <%= ckeditor5_editor preset: :content %>
  <%= ckeditor5_editor preset: :description %>
<% end %>

Parameters:

  • preset (PresetBuilder) (defaults to: nil)

    The preset object containing shared plugins configuration

Yields:

  • The block where editor instances should be defined



28
29
30
31
32
33
34
35
36
37
# File 'lib/ckeditor5/rails/context/helpers.rb', line 28

def ckeditor5_context(preset = nil, &block)
  preset ||= PresetBuilder.new
  context_props = PresetSerializer.new(preset)

  tags = []
  tags << ckeditor5_inline_plugins_tags(preset)
  tags << tag.public_send(:'ckeditor-context-component', **context_props.to_attributes, &block)

  safe_join(tags)
end

#ckeditor5_context_preset { ... } ⇒ PresetBuilder

Creates a new preset builder object for use with ckeditor5_context. Used to define shared plugins that will be available to all editors within the context. Note: Only plugins configuration is relevant for context, other settings like toolbar should be configured at the editor level.

Examples:

Creating a context with shared plugins

<% preset = ckeditor5_context_preset do
  plugins :Comments, :TrackChanges, :Collaboration  # Shared functionality plugins
end %>

Yields:

  • Block for configuring the shared plugins

Returns:



51
52
53
# File 'lib/ckeditor5/rails/context/helpers.rb', line 51

def ckeditor5_context_preset(&block)
  PresetBuilder.new(&block)
end