mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-05 20:23:16 +08:00
Add custom scrubber for QuillJs
This commit is contained in:
parent
26d04b1f3c
commit
fc32aa8606
2 changed files with 16 additions and 1 deletions
|
@ -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,
|
||||
|
|
11
app/utilities/scrubbers/quill_js_scrubber.rb
Normal file
11
app/utilities/scrubbers/quill_js_scrubber.rb
Normal 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
|
Loading…
Reference in a new issue