Skip to content
Snippets Groups Projects
Unverified Commit 3c3a6d82 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

summernote embeds

parent c4c35ec4
No related branches found
No related tags found
No related merge requests found
GIT
remote: https://github.com/noesya/summernote-rails.git
revision: e60b3a9e84ea8670ab6cbc5eaef33451ac588ca4
revision: 7463656df2b81ff434c8fa8786453b55be129054
branch: activestorage
specs:
summernote-rails (0.8.20.1)
......
......@@ -13,20 +13,25 @@ module WithBlobs
blobs_with_ids inherited_blob_ids
end
def summernote_embeds
summernote_embeds_reflection_names.map { |summernote_reflection_name|
public_send(summernote_reflection_name)
}.flatten
end
protected
def explicit_blob_ids
[rich_text_blob_ids]
[summernote_blob_ids]
end
def inherited_blob_ids
[]
end
def rich_text_blob_ids
rich_text_reflection_names.map { |rich_text_reflection_name|
rich_text = public_send(rich_text_reflection_name)
rich_text.present? ? rich_text.embeds.blobs.pluck(:id) : []
def summernote_blob_ids
summernote_embeds_reflection_names.map { |summernote_reflection_name|
public_send(summernote_reflection_name).pluck(:blob_id)
}.flatten
end
......@@ -34,7 +39,7 @@ module WithBlobs
university.active_storage_blobs.where(id: ids.flatten.compact)
end
def rich_text_reflection_names
@rich_text_reflection_names ||= _reflections.select { |name, reflection| reflection.class_name == "ActionText::RichText" }.keys
def summernote_embeds_reflection_names
@summernote_embeds_reflection_names ||= _reflections.keys.select { |name| name.ends_with?('_summernote_embeds_attachments') }
end
end
......@@ -10,7 +10,7 @@
<div class="card-body">
<%= render 'admin/application/property/text', object: @post, property: :description %>
<%= render 'admin/application/property/text', object: @post, property: :text %>
<%#= render 'admin/application/property/summernote_embeds', object: @post, property: :medias %>
<%= render 'admin/application/property/summernote_embeds', object: @post, property: :medias %>
<hr>
<pre><%= @post.text_new.to_html %></pre>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment