mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 01:44:34 +08:00
08c6210f7c
Closes SCI-691.
17 lines
554 B
Ruby
17 lines
554 B
Ruby
module QuillJsHelper
|
|
def sanitize_quill_js_input(input)
|
|
require "#{Rails.root}/app/utilities/scrubbers/quill_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!(QuillJsScrubber.new)
|
|
.to_html(save_with: disable_formatting)
|
|
end
|
|
end
|