123456789_123456789_123456789_123456789_123456789_

Class: ActionText::Editor

Do not use. This class is for internal use only.
Relationships & Source Files
Namespace Children
Classes:
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Inherits: Object
Defined in: actiontext/lib/action_text/editor.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(options = {}) ⇒ Editor

[ GitHub ]

  
# File 'actiontext/lib/action_text/editor.rb', line 12

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#options (readonly)

[ GitHub ]

  
# File 'actiontext/lib/action_text/editor.rb', line 10

attr_reader :options

Instance Method Details

#as_canonical(editable_fragment)

Convert fragments served by the editor into the canonical form that Action Text stores.

def as_canonical(editable_fragment)
  editable_fragment.replace "my-editor-attachment" do |editor_attachment|
    ActionText::Attachment.from_attributes(
      "sgid" => editor_attachment["sgid"],
      "content-type" => editor_attachment["content-type"]
    )
  end
end
[ GitHub ]

  
# File 'actiontext/lib/action_text/editor.rb', line 26

def as_canonical(editable_fragment)
  editable_fragment
end

#as_editable(canonical_fragment)

Convert fragments from the canonical form that Action Text stores into a format that is supported by the editor.

def as_editable(canonical_fragment)
  canonical_fragment.replace ActionText::Attachment.tag_name do |action_text_attachment|
    attachment_attributes = {
      "sgid" => action_text_attachment["sgid"],
      "content-type" => action_text_attachment["content-type"]
    }

    ActionText::HtmlConversion.create_element("my-editor-attachment", attachment_attributes)
  end
end
[ GitHub ]

  
# File 'actiontext/lib/action_text/editor.rb', line 42

def as_editable(canonical_fragment)
  canonical_fragment
end

#editor_name

[ GitHub ]

  
# File 'actiontext/lib/action_text/editor.rb', line 46

def editor_name
  self.class.name.demodulize.delete_suffix("Editor").underscore
end

#editor_tag

[ GitHub ]

  
# File 'actiontext/lib/action_text/editor.rb', line 50

def editor_tag(...)
  Tag.new(editor_name, ...)
end