Class: ActionText::Editor
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- actiontext/lib/action_text/editor.rb
Overview
:nodoc:
Direct Known Subclasses
Defined Under Namespace
Classes: Configurator, Registry, Tag, TrixEditor
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#as_canonical(editable_fragment) ⇒ Object
Convert fragments served by the editor into the canonical form that Action Text stores.
-
#as_editable(canonical_fragment) ⇒ Object
Convert fragments from the canonical form that Action Text stores into a format that is supported by the editor.
- #editor_name ⇒ Object
- #editor_tag ⇒ Object
-
#initialize(options = {}) ⇒ Editor
constructor
A new instance of Editor.
Methods included from ActiveSupport::Autoload
autoload, autoload_at, autoload_under, eager_autoload, eager_load!
Constructor Details
#initialize(options = {}) ⇒ Editor
Returns a new instance of Editor.
12 13 14 |
# File 'actiontext/lib/action_text/editor.rb', line 12 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'actiontext/lib/action_text/editor.rb', line 10 def @options end |
Instance Method Details
#as_canonical(editable_fragment) ⇒ Object
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 ||
ActionText::Attachment.from_attributes(
"sgid" => ["sgid"],
"content-type" => ["content-type"]
)
end
end
26 27 28 |
# File 'actiontext/lib/action_text/editor.rb', line 26 def as_canonical(editable_fragment) editable_fragment end |
#as_editable(canonical_fragment) ⇒ Object
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 ||
= {
"sgid" => ["sgid"],
"content-type" => ["content-type"]
}
ActionText::HtmlConversion.create_element("my-editor-attachment", )
end
end
42 43 44 |
# File 'actiontext/lib/action_text/editor.rb', line 42 def as_editable(canonical_fragment) canonical_fragment end |
#editor_name ⇒ Object
46 47 48 |
# File 'actiontext/lib/action_text/editor.rb', line 46 def editor_name self.class.name.demodulize.delete_suffix("Editor").underscore end |