module CKEditor5::Rails::Editor::Helpers
def build_editor_props(config:, type:, context:)
def build_editor_props(config:, type:, context:) Editor::Props.new(context, type, config) end
def ckeditor5_editable(name, **kwargs, &block)
def ckeditor5_editable(name, **kwargs, &block) tag.send(:'ckeditor-editable-component', name: name, **kwargs, &block) end
def ckeditor5_editor(
def ckeditor5_editor( config: nil, extra_config: {}, type: nil, preset: :default, **html_attributes, &block ) context = validate_and_get_editor_context! preset = fetch_editor_preset(preset) config ||= preset.config type ||= preset.type editor_props = build_editor_props( config: config.deep_merge(extra_config), type: type, context: context ) render_editor_component(editor_props, html_attributes, &(type == :multiroot ? block : nil)) end
def ckeditor5_toolbar(**kwargs)
def ckeditor5_toolbar(**kwargs) tag.send(:'ckeditor-toolbar-component', **kwargs) end
def fetch_editor_preset(preset)
def fetch_editor_preset(preset) Engine.base.presets[preset] or raise PresetNotFoundError, "Preset #{preset} is not defined." end
def render_editor_component(props, html_attributes, &block)
def render_editor_component(props, html_attributes, &block) tag.send(:'ckeditor-component', **props.to_attributes, **html_attributes, &block) end
def validate_and_get_editor_context!
def validate_and_get_editor_context! unless defined?(@__ckeditor_context) raise EditorContextError, 'CKEditor installation context is not defined. ' \ 'Ensure ckeditor5_assets is called in the head section.' end @__ckeditor_context end