class CKEditor5::Rails::Presets::SpecialCharactersBuilder
end
order :Text, :Mathematical, :Emoji
end
item ‘smiley’, ‘😊’
group ‘Emoji’, label: ‘Emoticons’ do
special_characters do
@example Basic configuration
Builder class for configuring special characters in CKEditor5
def group(name, items: [], label: nil, &block)
- Example: Define group with block -
Example: Define group with items array -
Returns:
-
(Group)
- Created group instance
Other tags:
- Yield: - Group configuration block
Parameters:
-
label
(String, nil
) -- Optional display label -
items
(Array
) -- Optional array of character items -
name
(String
) -- Name of the group
def group(name, items: [], label: nil, &block) group = Group.new(name, label: label) group.add_characters(items) if items.any? group.instance_eval(&block) if block_given? @groups << group group end
def initialize
- Example: Create new builder -
def initialize @groups = [] @order = [] @packs_plugins = [] end
def order(*categories)
- Example: Set display order -
Parameters:
-
categories
(Array
) -- Category names in desired order
def order(*categories) @order = categories.map(&:to_s) end
def packs(*names)
- Example: Enable essential and extended characters -
Parameters:
-
names
(Array
) -- Pack names to enable
def packs(*names) names.each do |name| plugin_name = "SpecialCharacters#{name.to_s.capitalize}" @packs_plugins << plugin_name end end
def to_h
-
(Hash)
- Complete special characters configuration
def to_h { groups: @groups.map(&:to_h), order: @order, packs: @packs_plugins } end