mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-03 19:24:48 +08:00
Fix rendering of RTE images for shareable links [SCI-8970] (#5913)
This commit is contained in:
parent
f3bef4ae25
commit
7a6886b895
5 changed files with 13 additions and 5 deletions
|
@ -47,6 +47,10 @@ module TinyMceImages
|
|||
TinyMceAsset.generate_url(self[field], self)
|
||||
end
|
||||
|
||||
def shareable_tinymce_render(field)
|
||||
TinyMceAsset.generate_url(self[field], self, is_shared_object: true)
|
||||
end
|
||||
|
||||
# Takes array of old/new TinyMCE asset ID pairs
|
||||
# and updates references in assosiated object's description
|
||||
def reassign_tiny_mce_image_references(images = [])
|
||||
|
|
|
@ -58,7 +58,7 @@ class TinyMceAsset < ApplicationRecord
|
|||
Rails.logger.error e.backtrace.join("\n")
|
||||
end
|
||||
|
||||
def self.generate_url(description, obj = nil)
|
||||
def self.generate_url(description, obj = nil, is_shared_object: false)
|
||||
# Check tinymce for old format
|
||||
description = update_old_tinymce(description, obj)
|
||||
|
||||
|
@ -75,7 +75,11 @@ class TinyMceAsset < ApplicationRecord
|
|||
asset_id = tm_asset.attr('data-mce-token')
|
||||
new_asset = obj.tiny_mce_assets.find_by(id: Base62.decode(asset_id))
|
||||
if new_asset&.image&.attached?
|
||||
tm_asset.attributes['src'].value = Rails.application.routes.url_helpers.url_for(new_asset.image)
|
||||
tm_asset.attributes['src'].value = if is_shared_object
|
||||
new_asset.image.url(expires_in: Constants::URL_SHORT_EXPIRE_TIME.minutes)
|
||||
else
|
||||
Rails.application.routes.url_helpers.url_for(new_asset.image)
|
||||
end
|
||||
tm_asset['class'] = 'img-responsive'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<div class="task-notes">
|
||||
<div class="task-notes-content">
|
||||
<% if @my_module.description.present? %>
|
||||
<%= smart_annotation_text(@my_module.tinymce_render(:description)) %>
|
||||
<%= smart_annotation_text(@my_module.shareable_tinymce_render(:description)) %>
|
||||
<% else %>
|
||||
<span class="no-description"><%= t('my_modules.notes.no_description') %></span>
|
||||
<% end %>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<div id="protocol-description-container" >
|
||||
<% if protocol.description.present? %>
|
||||
<div>
|
||||
<%= smart_annotation_text(protocol.tinymce_render(:description)) %>
|
||||
<%= smart_annotation_text(protocol.shareable_tinymce_render(:description)) %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="empty-protocol-description">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div class="step-element-grip-placeholder"></div>
|
||||
<% if element.text.present? %>
|
||||
<div class="view-text-element">
|
||||
<%= smart_annotation_text(element.tinymce_render(:text)) %>
|
||||
<%= smart_annotation_text(element.shareable_tinymce_render(:text)) %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="empty-text-element">
|
||||
|
|
Loading…
Reference in a new issue