Add custom scrubber for QuillJs

This commit is contained in:
Luka Murn 2016-11-17 13:12:36 +01:00
parent 26d04b1f3c
commit fc32aa8606
2 changed files with 16 additions and 1 deletions

View file

@ -1,4 +1,5 @@
module ProtocolsImporter
require 'scrubbers/quill_js_scrubber'
include RenamingUtil
def import_new_protocol(protocol_json, organization, type, user)
@ -54,7 +55,10 @@ module ProtocolsImporter
step = Step.create!(
name: step_json["name"],
description: # Sanitize description HTML
ActionController::Base.helpers.sanitize(step_json['description']),
ActionController::Base.helpers.sanitize(
step_json['description'],
scrubber: QuillJsScrubber.new
),
position: step_pos,
completed: false,
user: user,

View file

@ -0,0 +1,11 @@
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