mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
use 'Utils.cleanHtml' as pasteSanitizer + minor tweaks
This commit is contained in:
parent
0a4cea5e4c
commit
48b0519cb4
2 changed files with 8 additions and 20 deletions
|
|
@ -1,3 +1,8 @@
|
||||||
|
/* Prevent collapse of empty elements so that the caret can be placed in there */
|
||||||
|
.CompactComposer *:empty::before {
|
||||||
|
content: "\200B";
|
||||||
|
}
|
||||||
|
|
||||||
.CompactComposer .squire-toolbar {
|
.CompactComposer .squire-toolbar {
|
||||||
padding-top: 4px;
|
padding-top: 4px;
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,6 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const
|
const
|
||||||
removeElements = 'HEAD,LINK,META,NOSCRIPT,SCRIPT,TEMPLATE,TITLE',
|
|
||||||
allowedElements = 'A,B,BLOCKQUOTE,BR,DIV,EM,FONT,H1,H2,H3,H4,H5,H6,HR,I,IMG,LI,OL,P,SPAN,STRONG,TABLE,TD,TH,TR,U,UL',
|
|
||||||
allowedAttributes = 'abbr,align,background,bgcolor,border,cellpadding,cellspacing,class,color,colspan,dir,face,frame,height,href,hspace,id,lang,rowspan,rules,scope,size,src,style,target,type,usemap,valign,vspace,width'.split(','),
|
|
||||||
|
|
||||||
// TODO: labels translations
|
// TODO: labels translations
|
||||||
i18n = (str, def) => rl.i18n(str) || def,
|
i18n = (str, def) => rl.i18n(str) || def,
|
||||||
|
|
||||||
|
|
@ -105,21 +101,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
pasteSanitizer = (event) => {
|
pasteSanitizer = (event) => {
|
||||||
const frag = event.detail.fragment;
|
return rl.Utils.cleanHtml(event.detail.html).html;
|
||||||
frag.querySelectorAll('a:empty,span:empty').forEach(el => el.remove());
|
|
||||||
frag.querySelectorAll(removeElements).forEach(el => el.remove());
|
|
||||||
frag.querySelectorAll('*').forEach(el => {
|
|
||||||
if (!el.matches(allowedElements)) {
|
|
||||||
el.replaceWith(getFragmentOfChildren(el));
|
|
||||||
} else if (el.hasAttributes()) {
|
|
||||||
[...el.attributes].forEach(attr => {
|
|
||||||
let name = attr.name.toLowerCase();
|
|
||||||
if (!allowedAttributes.includes(name)) {
|
|
||||||
el.removeAttribute(name);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
pasteImageHandler = (e, squire) => {
|
pasteImageHandler = (e, squire) => {
|
||||||
|
|
@ -327,7 +309,8 @@
|
||||||
clr.style.left = (input.offsetLeft + input.parentNode.offsetLeft) + 'px';
|
clr.style.left = (input.offsetLeft + input.parentNode.offsetLeft) + 'px';
|
||||||
clr.style.width = input.offsetWidth + 'px';
|
clr.style.width = input.offsetWidth + 'px';
|
||||||
|
|
||||||
clr.value = '';
|
// firefox does not call "onchange" for #000 if we use clr.value=''
|
||||||
|
clr.value = '#00ff0c';
|
||||||
clr.onchange = () => {
|
clr.onchange = () => {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'color':
|
case 'color':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue