Skip to content

(Action Text) Does't display content in the editor #33

@Civil21

Description

@Civil21

Dependencies:

- Rails (7.0.3)
- Ruby (3.1)
- activeadmin_quill_editor (1.0.0)

Situation:
If used with Action Text there is a problem. When editing, the editor is empty because it is not possible to read the input content due to <div class="trix-content">some html content</div>

Of course, this is not a problem of the gem, but since it is recommended to use it when you need to work with Action Text in the active admin, it is worth offering a solution.

My solution (hardcode):

project/app/models/some_model.rb

has_rich_text :text

def some_text=(body)
 text.body = body
end

def some_text
   text.to_s.gsub(/\A<div class="trix-content">(.*)<\/div>\z/m, '\1').strip.html_safe
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions