mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-29 19:51:01 +08:00
Merge pull request #438 from okriuchykhin/ok_SCI_921
Remove unneeded HTML scrubber in protocol importer [SCI-921]
This commit is contained in:
commit
7fa1f3d966
3 changed files with 3 additions and 34 deletions
|
@ -1,17 +0,0 @@
|
|||
module TinyMceJsHelper
|
||||
def sanitize_tiny_mce_js_input(input)
|
||||
require "#{Rails.root}/app/utilities/scrubbers/tiny_mce_js_scrubber"
|
||||
|
||||
# We need to disable formatting to prevent unwanted \n
|
||||
# symbols from creeping into sanitized HTML (which
|
||||
# cause unwanted new lines when rendered in Quill.js)
|
||||
disable_formatting =
|
||||
Nokogiri::XML::Node::SaveOptions::DEFAULT_HTML ^
|
||||
Nokogiri::XML::Node::SaveOptions::FORMAT
|
||||
|
||||
Loofah
|
||||
.fragment(input)
|
||||
.scrub!(TinyMceJsScrubber.new)
|
||||
.to_html(save_with: disable_formatting)
|
||||
end
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
module ProtocolsImporter
|
||||
include RenamingUtil, TinyMceJsHelper
|
||||
include RenamingUtil
|
||||
|
||||
def import_new_protocol(protocol_json, organization, type, user)
|
||||
remove_empty_inputs(protocol_json)
|
||||
|
@ -52,11 +52,8 @@ module ProtocolsImporter
|
|||
if protocol_json['steps']
|
||||
protocol_json['steps'].values.each do |step_json|
|
||||
step = Step.create!(
|
||||
name: step_json["name"],
|
||||
description: # Sanitize description HTML
|
||||
sanitize_tiny_mce_js_input(
|
||||
step_json['description']
|
||||
),
|
||||
name: step_json['name'],
|
||||
description: step_json['description'],
|
||||
position: step_pos,
|
||||
completed: false,
|
||||
user: user,
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
class QuillJsScrubber < Rails::Html::PermitScrubber
|
||||
def initialize
|
||||
super
|
||||
self.tags = %w(h1 span p br pre ul li strong em u sub sup s a blockquote ol)
|
||||
self.attributes = %w(style class spellcheck href target)
|
||||
end
|
||||
|
||||
def skip_node?(node)
|
||||
node.text?
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue