mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 21:55:20 +08:00
fixes tiny_mce pdf report in filesystem storage mode [fixes SCI-2279]
This commit is contained in:
parent
9751610710
commit
c0cc6c293a
5 changed files with 19 additions and 9 deletions
|
@ -2207,3 +2207,7 @@ th.custom-field .modal-tooltiptext {
|
|||
.linkedin-signin-button {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.tiny-mce-pdf-ready {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ module ReportsHelper
|
|||
end
|
||||
|
||||
# "Hack" to omit file preview URL because of WKHTML issues
|
||||
def report_image_asset_url(asset)
|
||||
def report_image_asset_url(asset, type = :asset, klass = nil)
|
||||
prefix = ''
|
||||
if ENV['PAPERCLIP_STORAGE'].present? &&
|
||||
ENV['MAIL_SERVER_URL'].present? &&
|
||||
|
@ -68,8 +68,9 @@ module ReportsHelper
|
|||
!prefix.include?('https://')
|
||||
prefix = "http://#{prefix}"
|
||||
end
|
||||
url = prefix + asset.url(:medium, timeout: Constants::URL_LONG_EXPIRE_TIME)
|
||||
image_tag(url)
|
||||
size = type == :tiny_mce_asset ? :large : :medium
|
||||
url = prefix + asset.url(size, timeout: Constants::URL_LONG_EXPIRE_TIME)
|
||||
image_tag(url, class: klass)
|
||||
end
|
||||
|
||||
# "Hack" to load Glyphicons css directly from the CDN
|
||||
|
|
|
@ -17,7 +17,8 @@ module TinyMceHelper
|
|||
html
|
||||
end
|
||||
|
||||
def generate_image_tag_from_token(text, obj)
|
||||
# @param pdf_export_ready is needed for wicked_pdf in export report action
|
||||
def generate_image_tag_from_token(text, obj, pdf_export_ready = false)
|
||||
return unless text
|
||||
regex = Constants::TINY_MCE_ASSET_REGEX
|
||||
text.gsub(regex) do |el|
|
||||
|
@ -25,9 +26,13 @@ module TinyMceHelper
|
|||
img = TinyMceAsset.find_by_id(match[1])
|
||||
next unless img && img.team == current_team
|
||||
next unless check_image_permissions(obj, img)
|
||||
image_tag img.url,
|
||||
class: 'img-responsive',
|
||||
data: { token: Base62.encode(img.id) }
|
||||
if pdf_export_ready
|
||||
report_image_asset_url(img, :tiny_mce_asset, 'tiny-mce-pdf-ready')
|
||||
else
|
||||
image_tag img.url,
|
||||
class: 'img-responsive',
|
||||
data: { token: Base62.encode(img.id) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<div class="report-element-body">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 text-container ql-editor">
|
||||
<%= custom_auto_link(generate_image_tag_from_token(result_text.text, result_text),
|
||||
<%= custom_auto_link(generate_image_tag_from_token(result_text.text, result_text, true),
|
||||
simple_format: false,
|
||||
tags: %w(img)) %>
|
||||
</div>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-12 ql-editor">
|
||||
<% if strip_tags(step.description).present? %>
|
||||
<%= custom_auto_link(generate_image_tag_from_token(step.description, step),
|
||||
<%= custom_auto_link(generate_image_tag_from_token(step.description, step, true),
|
||||
simple_format: false,
|
||||
tags: %w(img)) %>
|
||||
<% else %>
|
||||
|
|
Loading…
Add table
Reference in a new issue