123456789_123456789_123456789_123456789_123456789_

Class: ActionText::Editor::TrixEditor

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

Class Method Summary

Instance Attribute Summary

Instance Method Summary

::ActionText::Editor - Inherited

#as_canonical

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

#as_editable

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

#editor_name, #editor_tag

Constructor Details

This class inherits a constructor from ActionText::Editor

Instance Method Details

#as_canonical(editable_fragment)

[ GitHub ]

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

def as_canonical(editable_fragment)
  editable_fragment.replace(TrixAttachment::SELECTOR, &method(:from_trix_attachment))
end

#as_editable(canonical_fragment)

[ GitHub ]

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

def as_editable(canonical_fragment)
  canonical_fragment.replace(Attachment.tag_name, &method(:to_trix_attachment))
end

#editor_tag

[ GitHub ]

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

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

#from_trix_attachment(node) (private)

[ GitHub ]

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

def from_trix_attachment(node)
  trix_attachment = TrixAttachment.new(node)
  Attachment.from_attributes(trix_attachment.attributes)
end

#to_trix_attachment(node) (private)

[ GitHub ]

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

def to_trix_attachment(node)
  attachment_attributes = node.attributes
  TrixAttachment.from_attributes(attachment_attributes)
end