From ad8bc9cd533e837ce91d5291cdf93e78601cd0e3 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Tue, 16 May 2023 14:58:45 +0200 Subject: [PATCH] =?UTF-8?q?Issue=20#982=20d=C3=A9sactivation=20du=20nettoy?= =?UTF-8?q?age=20HTML=20qui=20merde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/plugins/summernote-paste.js | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/app/assets/javascripts/application/plugins/summernote-paste.js b/app/assets/javascripts/application/plugins/summernote-paste.js index 7b964dd17..accc40aa5 100644 --- a/app/assets/javascripts/application/plugins/summernote-paste.js +++ b/app/assets/javascripts/application/plugins/summernote-paste.js @@ -13,44 +13,44 @@ } }(function ($) { 'use strict'; - $.extend($.summernote.options, { - stripTags: ['section', 'div', 'span', 'o', 'xml', 'font', 'style', 'embed', 'param', 'script', 'html', 'body', 'head', 'meta', 'title', 'link', 'iframe', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'noframes', 'noscript', 'form', 'input', 'select', 'option', 'colgroup', 'col', 'std', 'xml:', 'st1:', 'o:', 'w:', 'v:'], - onCleanHtml: function (html) { - var htmlModified = html.replace(/<!\[if !supportLists[\s\S]*?endif\]>/g, '') - .replace(/<!--[\s\S]*?-->/g, '') - .replace(/( class=(")?Mso[a-zA-Z]+(")?)/g, ' ') - .replace(/[\t ]+</g, '<') - .replace(/>[\t ]+</g, '><') - .replace(/>[\t ]+$/g, '>') - .replace(/[\u2018\u2019\u201A]/g, '\'') - .replace(/[\u201C\u201D\u201E]/g, '"') - .replace(/\u2026/g, '...') - .replace(/[\u2013\u2014]/g, '-'); - return htmlModified; - } - }); + // $.extend($.summernote.options, { + // stripTags: ['section', 'div', 'span', 'o', 'xml', 'font', 'style', 'embed', 'param', 'script', 'html', 'body', 'head', 'meta', 'title', 'link', 'iframe', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'noframes', 'noscript', 'form', 'input', 'select', 'option', 'colgroup', 'col', 'std', 'xml:', 'st1:', 'o:', 'w:', 'v:'], + // onCleanHtml: function (html) { + // var htmlModified = html.replace(/<!\[if !supportLists[\s\S]*?endif\]>/g, '') + // .replace(/<!--[\s\S]*?-->/g, '') + // .replace(/( class=(")?Mso[a-zA-Z]+(")?)/g, ' ') + // .replace(/[\t ]+</g, '<') + // .replace(/>[\t ]+</g, '><') + // .replace(/>[\t ]+$/g, '>') + // .replace(/[\u2018\u2019\u201A]/g, '\'') + // .replace(/[\u201C\u201D\u201E]/g, '"') + // .replace(/\u2026/g, '...') + // .replace(/[\u2013\u2014]/g, '-'); + // return htmlModified; + // } + // }); - $.extend($.summernote.plugins, { - 'striptags': function (context) { - var $note = context.layoutInfo.note, - $options = context.options; - $note.on('summernote.paste', function (e, evt) { - var text = evt.originalEvent.clipboardData.getData('text/plain'), - html = evt.originalEvent.clipboardData.getData('text/html'), - tagStripper = new RegExp('<[ /]*(' + $options.stripTags.join('|') + ')[^>]*>', 'gi'), - attributeStripper = /<(?!a)(\w+)[^>]*>/gi; - evt.preventDefault(); - if (html) { - html = html.toString(); - html = $options.onCleanHtml(html); - html = html.replace(attributeStripper, '<$1>'); - html = html.replace(tagStripper, ''); - document.execCommand('insertHTML', false, html); - } else { - document.execCommand('insertHTML', false, text); - } - return false; - }); - } - }); + // $.extend($.summernote.plugins, { + // 'striptags': function (context) { + // var $note = context.layoutInfo.note, + // $options = context.options; + // $note.on('summernote.paste', function (e, evt) { + // var text = evt.originalEvent.clipboardData.getData('text/plain'), + // html = evt.originalEvent.clipboardData.getData('text/html'), + // tagStripper = new RegExp('<[ /]*(' + $options.stripTags.join('|') + ')[^>]*>', 'gi'), + // attributeStripper = /<(?!a)(\w+)[^>]*>/gi; + // evt.preventDefault(); + // if (html) { + // html = html.toString(); + // html = $options.onCleanHtml(html); + // html = html.replace(attributeStripper, '<$1>'); + // html = html.replace(tagStripper, ''); + // document.execCommand('insertHTML', false, html); + // } else { + // document.execCommand('insertHTML', false, text); + // } + // return false; + // }); + // } + // }); })); -- GitLab