Fix Froala strip empty tags issue (#5126)
Co-authored-by: Ben Thomson <git@alfreido.com>
This commit is contained in:
parent
24f87ae10e
commit
81a11f70c4
|
|
@ -172,10 +172,11 @@ froalaOptions.tableCellStyles=this.options.tableCellStyles?this.options.tableCel
|
|||
froalaOptions.toolbarButtonsMD=froalaOptions.toolbarButtons
|
||||
froalaOptions.toolbarButtonsSM=froalaOptions.toolbarButtons
|
||||
froalaOptions.toolbarButtonsXS=froalaOptions.toolbarButtons
|
||||
if(this.options.htmlAllowedEmptyTags){froalaOptions.allowEmptyTags=this.options.htmlAllowedEmptyTags.split(/[\s,]+/)}
|
||||
if(this.options.allowTags){froalaOptions.htmlAllowedTags=this.options.allowTags.split(/[\s,]+/)}
|
||||
if(this.options.allowEmptyTags){froalaOptions.htmlAllowedEmptyTags=[];this.options.allowEmptyTags.split(/[\s,]+/).forEach(function(selector){var tag=selector.split('.',2)
|
||||
if(froalaOptions.htmlAllowedEmptyTags.indexOf(tag[0])===-1){froalaOptions.htmlAllowedEmptyTags.push(selector)}})}else{froalaOptions.htmlAllowedEmptyTags=['textarea','a','iframe','object','video','style','script','.fa','.fr-emoticon','.fr-inner','path','line','hr','i']}
|
||||
froalaOptions.htmlAllowedTags=this.options.allowTags?this.options.allowTags.split(/[\s,]+/):['a','abbr','address','area','article','aside','audio','b','bdi','bdo','blockquote','br','button','canvas','caption','cite','code','col','colgroup','datalist','dd','del','details','dfn','dialog','div','dl','dt','em','embed','fieldset','figcaption','figure','footer','form','h1','h2','h3','h4','h5','h6','header','hgroup','hr','i','iframe','img','input','ins','kbd','keygen','label','legend','li','link','main','map','mark','menu','menuitem','meter','nav','noscript','object','ol','optgroup','option','output','p','param','pre','progress','queue','rp','rt','ruby','s','samp','script','style','section','select','small','source','span','strike','strong','sub','summary','sup','table','tbody','td','textarea','tfoot','th','thead','time','title','tr','track','u','ul','var','video','wbr']
|
||||
froalaOptions.htmlDoNotWrapTags=this.options.noWrapTags?this.options.noWrapTags.split(/[\s,]+/):['figure','script','style']
|
||||
if(this.options.removeTags){froalaOptions.htmlRemoveTags=this.options.removeTags.split(/[\s,]+/)}
|
||||
froalaOptions.htmlRemoveTags=this.options.removeTags?this.options.removeTags.split(/[\s,]+/):['script','style','base']
|
||||
froalaOptions.lineBreakerTags=this.options.lineBreakerTags?this.options.lineBreakerTags.split(/[\s,]+/):['figure, table, hr, iframe, form, dl']
|
||||
froalaOptions.shortcutsEnabled=['show','bold','italic','underline','indent','outdent','undo','redo']
|
||||
froalaOptions.requestHeaders={'X-CSRF-TOKEN':$('meta[name="csrf-token"]').attr('content'),'X-Requested-With':'XMLHttpRequest'}
|
||||
|
|
|
|||
|
|
@ -95,59 +95,70 @@
|
|||
froalaOptions.imageStyles = this.options.imageStyles
|
||||
? this.options.imageStyles
|
||||
: {
|
||||
'oc-img-rounded': 'Rounded',
|
||||
'oc-img-bordered': 'Bordered'
|
||||
'oc-img-rounded': 'Rounded',
|
||||
'oc-img-bordered': 'Bordered'
|
||||
}
|
||||
|
||||
froalaOptions.linkStyles = this.options.linkStyles
|
||||
? this.options.linkStyles
|
||||
: {
|
||||
'oc-link-green': 'Green',
|
||||
'oc-link-strong': 'Thick'
|
||||
'oc-link-green': 'Green',
|
||||
'oc-link-strong': 'Thick'
|
||||
}
|
||||
|
||||
froalaOptions.paragraphStyles = this.options.paragraphStyles
|
||||
? this.options.paragraphStyles
|
||||
: {
|
||||
'oc-text-gray': 'Gray',
|
||||
'oc-text-bordered': 'Bordered',
|
||||
'oc-text-spaced': 'Spaced',
|
||||
'oc-text-uppercase': 'Uppercase'
|
||||
'oc-text-gray': 'Gray',
|
||||
'oc-text-bordered': 'Bordered',
|
||||
'oc-text-spaced': 'Spaced',
|
||||
'oc-text-uppercase': 'Uppercase'
|
||||
}
|
||||
|
||||
froalaOptions.tableStyles = this.options.tableStyles
|
||||
? this.options.tableStyles
|
||||
: {
|
||||
'oc-dashed-borders': 'Dashed Borders',
|
||||
'oc-alternate-rows': 'Alternate Rows'
|
||||
'oc-dashed-borders': 'Dashed Borders',
|
||||
'oc-alternate-rows': 'Alternate Rows'
|
||||
}
|
||||
|
||||
froalaOptions.tableCellStyles = this.options.tableCellStyles
|
||||
? this.options.tableCellStyles
|
||||
: {
|
||||
'oc-cell-highlighted': 'Highlighted',
|
||||
'oc-cell-thick-border': 'Thick'
|
||||
'oc-cell-highlighted': 'Highlighted',
|
||||
'oc-cell-thick-border': 'Thick'
|
||||
}
|
||||
|
||||
froalaOptions.toolbarButtonsMD = froalaOptions.toolbarButtons
|
||||
froalaOptions.toolbarButtonsSM = froalaOptions.toolbarButtons
|
||||
froalaOptions.toolbarButtonsXS = froalaOptions.toolbarButtons
|
||||
|
||||
if (this.options.htmlAllowedEmptyTags) {
|
||||
froalaOptions.allowEmptyTags = this.options.htmlAllowedEmptyTags.split(/[\s,]+/)
|
||||
if (this.options.allowEmptyTags) {
|
||||
froalaOptions.htmlAllowedEmptyTags = [];
|
||||
|
||||
this.options.allowEmptyTags.split(/[\s,]+/).forEach(
|
||||
function (selector) {
|
||||
var tag = selector.split('.', 2)
|
||||
if (froalaOptions.htmlAllowedEmptyTags.indexOf(tag[0]) === -1) {
|
||||
froalaOptions.htmlAllowedEmptyTags.push(selector)
|
||||
}
|
||||
}
|
||||
)
|
||||
} else {
|
||||
froalaOptions.htmlAllowedEmptyTags = ['textarea', 'a', 'iframe', 'object', 'video', 'style', 'script', '.fa', '.fr-emoticon', '.fr-inner', 'path', 'line', 'hr', 'i']
|
||||
}
|
||||
|
||||
if (this.options.allowTags) {
|
||||
froalaOptions.htmlAllowedTags = this.options.allowTags.split(/[\s,]+/)
|
||||
}
|
||||
froalaOptions.htmlAllowedTags = this.options.allowTags
|
||||
? this.options.allowTags.split(/[\s,]+/)
|
||||
: ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'blockquote', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'menuitem', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'pre', 'progress', 'queue', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'style', 'section', 'select', 'small', 'source', 'span', 'strike', 'strong', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr']
|
||||
|
||||
froalaOptions.htmlDoNotWrapTags = this.options.noWrapTags
|
||||
? this.options.noWrapTags.split(/[\s,]+/)
|
||||
: ['figure', 'script', 'style']
|
||||
|
||||
if (this.options.removeTags) {
|
||||
froalaOptions.htmlRemoveTags = this.options.removeTags.split(/[\s,]+/)
|
||||
}
|
||||
froalaOptions.htmlRemoveTags = this.options.removeTags
|
||||
? this.options.removeTags.split(/[\s,]+/)
|
||||
: ['script', 'style', 'base']
|
||||
|
||||
froalaOptions.lineBreakerTags = this.options.lineBreakerTags
|
||||
? this.options.lineBreakerTags.split(/[\s,]+/)
|
||||
|
|
|
|||
|
|
@ -39,13 +39,13 @@ class EditorSetting extends Model
|
|||
*/
|
||||
public $cacheKey = 'backend::editor.custom_css';
|
||||
|
||||
protected $defaultHtmlAllowEmptyTags = 'textarea, a, iframe, object, video, style, script';
|
||||
protected $defaultHtmlAllowEmptyTags = 'textarea, a, iframe, object, video, style, script, .fa, .fr-emoticon, .fr-inner, path, line, hr, i';
|
||||
|
||||
protected $defaultHtmlAllowTags = 'a, abbr, address, area, article, aside, audio, b, base, bdi, bdo, blockquote, br, button, canvas, caption, cite, code, col, colgroup, datalist, dd, del, details, dfn, dialog, div, dl, dt, em, embed, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, i, iframe, img, input, ins, kbd, keygen, label, legend, li, link, main, map, mark, menu, menuitem, meter, nav, noscript, object, ol, optgroup, option, output, p, param, pre, progress, queue, rp, rt, ruby, s, samp, script, style, section, select, small, source, span, strike, strong, sub, summary, sup, table, tbody, td, textarea, tfoot, th, thead, time, title, tr, track, u, ul, var, video, wbr';
|
||||
protected $defaultHtmlAllowTags = 'a, abbr, address, area, article, aside, audio, b, bdi, bdo, blockquote, br, button, canvas, caption, cite, code, col, colgroup, datalist, dd, del, details, dfn, dialog, div, dl, dt, em, embed, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, i, iframe, img, input, ins, kbd, keygen, label, legend, li, link, main, map, mark, menu, menuitem, meter, nav, noscript, object, ol, optgroup, option, output, p, param, pre, progress, queue, rp, rt, ruby, s, samp, script, style, section, select, small, source, span, strike, strong, sub, summary, sup, table, tbody, td, textarea, tfoot, th, thead, time, title, tr, track, u, ul, var, video, wbr';
|
||||
|
||||
protected $defaultHtmlNoWrapTags = 'figure, script, style';
|
||||
|
||||
protected $defaultHtmlRemoveTags = 'script, style';
|
||||
protected $defaultHtmlRemoveTags = 'script, style, base';
|
||||
|
||||
protected $defaultHtmlLineBreakerTags = 'figure, table, hr, iframe, form, dl';
|
||||
|
||||
|
|
@ -80,13 +80,13 @@ class EditorSetting extends Model
|
|||
* Editor toolbar presets for Froala.
|
||||
*/
|
||||
protected $editorToolbarPresets = [
|
||||
'default' => 'paragraphFormat, paragraphStyle, quote, bold, italic, align, formatOL, formatUL, insertTable,
|
||||
'default' => 'paragraphFormat, paragraphStyle, quote, bold, italic, align, formatOL, formatUL, insertTable,
|
||||
insertLink, insertImage, insertVideo, insertAudio, insertFile, insertHR, html',
|
||||
'minimal' => 'paragraphFormat, bold, italic, underline, |, insertLink, insertImage, |, html',
|
||||
'full' => 'undo, redo, |, bold, italic, underline, |, paragraphFormat, paragraphStyle, inlineStyle, |,
|
||||
strikeThrough, subscript, superscript, clearFormatting, |, fontFamily, fontSize, |, color,
|
||||
emoticons, -, selectAll, |, align, formatOL, formatUL, outdent, indent, quote, |, insertHR,
|
||||
insertLink, insertImage, insertVideo, insertAudio, insertFile, insertTable, |, selectAll,
|
||||
'full' => 'undo, redo, |, bold, italic, underline, |, paragraphFormat, paragraphStyle, inlineStyle, |,
|
||||
strikeThrough, subscript, superscript, clearFormatting, |, fontFamily, fontSize, |, color,
|
||||
emoticons, -, selectAll, |, align, formatOL, formatUL, outdent, indent, quote, |, insertHR,
|
||||
insertLink, insertImage, insertVideo, insertAudio, insertFile, insertTable, |, selectAll,
|
||||
html, fullscreen',
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue