diff --git a/app/helpers/tiny_mce_helper.rb b/app/helpers/tiny_mce_helper.rb index a58b88b0c..1187411c7 100644 --- a/app/helpers/tiny_mce_helper.rb +++ b/app/helpers/tiny_mce_helper.rb @@ -1,7 +1,7 @@ module TinyMceHelper def parse_tiny_mce_asset_to_token(text, obj) ids = [] - html = Nokogiri::HTML(text) + html = Nokogiri::HTML(remove_pasted_tokens(text)) html.search('img').each do |img| next unless img['data-token'] img_id = Base62.decode(img['data-token']) @@ -66,8 +66,8 @@ module TinyMceHelper end end - def check_parse_token_permissions(obj, img) - return true if obj.class == Step && img.result_text.nil? - return true if obj.class == ResultText && img.step.nil? + def remove_pasted_tokens(text) + regex = Constants::TINY_MCE_ASSET_REGEX + text.gsub(regex, ' ') end end diff --git a/app/views/protocols/index/_protocol_preview_modal_body.html.erb b/app/views/protocols/index/_protocol_preview_modal_body.html.erb index bbb5912b7..7172b7d07 100644 --- a/app/views/protocols/index/_protocol_preview_modal_body.html.erb +++ b/app/views/protocols/index/_protocol_preview_modal_body.html.erb @@ -85,7 +85,7 @@ <%= t("protocols.steps.no_description") %> <% else %>
- <%= sanitize_input(generate_image_tag_from_token(step.description), ['img']) %> + <%= sanitize_input(generate_image_tag_from_token(step.description, step), ['img']) %>
<% end %>