mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Bugfix: Squire setHTML failed with hidden exception
This commit is contained in:
parent
843b186354
commit
996c747e45
3 changed files with 39 additions and 10 deletions
12
dev/External/SquireUI.js
vendored
12
dev/External/SquireUI.js
vendored
|
|
@ -14,6 +14,8 @@ const doc = document,
|
||||||
|
|
||||||
ctrlKey = /Mac OS X/.test( navigator.userAgent ) ? '⌘ + ' : 'Ctrl + ',
|
ctrlKey = /Mac OS X/.test( navigator.userAgent ) ? '⌘ + ' : 'Ctrl + ',
|
||||||
|
|
||||||
|
tpl = doc.createElement('template'),
|
||||||
|
|
||||||
getFragmentOfChildren = parent => {
|
getFragmentOfChildren = parent => {
|
||||||
let frag = doc.createDocumentFragment();
|
let frag = doc.createDocumentFragment();
|
||||||
frag.append(...parent.childNodes);
|
frag.append(...parent.childNodes);
|
||||||
|
|
@ -48,14 +50,16 @@ const doc = document,
|
||||||
addLinks: true // allow_smart_html_links
|
addLinks: true // allow_smart_html_links
|
||||||
*/
|
*/
|
||||||
sanitizeToDOMFragment: (html, isPaste/*, squire*/) => {
|
sanitizeToDOMFragment: (html, isPaste/*, squire*/) => {
|
||||||
let tpl = doc.createElement('div');
|
|
||||||
tpl.innerHTML = html
|
tpl.innerHTML = html
|
||||||
.replace(/<\/?(BODY|HTML)[^>]*>/gi,'')
|
.replace(/<\/?(BODY|HTML)[^>]*>/gi,'')
|
||||||
.replace(/<!--[^>]+-->/g,'')
|
.replace(/<!--[^>]+-->/g,'')
|
||||||
|
.replace(/<span[^>]*>\s*<\/span>/gi,'')
|
||||||
.trim();
|
.trim();
|
||||||
|
tpl.querySelectorAll('a:empty,span:empty').forEach(el => el.remove());
|
||||||
|
tpl.querySelectorAll('[data-x-div-type]').forEach(el => el.replaceWith(getFragmentOfChildren(el)));
|
||||||
if (isPaste) {
|
if (isPaste) {
|
||||||
tpl.querySelectorAll(removeElements).forEach(el => el.remove());
|
tpl.querySelectorAll(removeElements).forEach(el => el.remove());
|
||||||
tpl.querySelectorAll(':not('+allowedElements+',signature)').forEach(el => el.replaceWith(getFragmentOfChildren(el)));
|
tpl.querySelectorAll(':not('+allowedElements+')').forEach(el => el.replaceWith(getFragmentOfChildren(el)));
|
||||||
tpl.querySelectorAll('*').forEach(el => {
|
tpl.querySelectorAll('*').forEach(el => {
|
||||||
if (el.hasAttributes()) {
|
if (el.hasAttributes()) {
|
||||||
[...el.attributes].forEach(attr => {
|
[...el.attributes].forEach(attr => {
|
||||||
|
|
@ -67,7 +71,7 @@ const doc = document,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return getFragmentOfChildren(tpl);
|
return tpl.content;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -518,7 +522,7 @@ squire-raw.js:4089: this.fireEvent( 'willPaste', event );
|
||||||
if (!cfg.isHtml) {
|
if (!cfg.isHtml) {
|
||||||
cfg.signature = rl.Utils.plainToHtml(cfg.signature);
|
cfg.signature = rl.Utils.plainToHtml(cfg.signature);
|
||||||
}
|
}
|
||||||
this.squire.setHTML(rl_signature_replacer(this, this.squire.getHTML(), cfg.signature, true, cfg.insertBefore));
|
this.squire.setHTML(rl_signature_replacer(this, this.getData(), cfg.signature, true, cfg.insertBefore));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
|
||||||
36
vendors/squire/build/squire-raw.js
vendored
36
vendors/squire/build/squire-raw.js
vendored
|
|
@ -304,17 +304,15 @@ const
|
||||||
|
|
||||||
// Recursively examine container nodes and wrap any inline children.
|
// Recursively examine container nodes and wrap any inline children.
|
||||||
fixContainer = ( container, root ) => {
|
fixContainer = ( container, root ) => {
|
||||||
let children = container.childNodes;
|
let children = container.children;
|
||||||
let wrapper = null;
|
let wrapper = null;
|
||||||
let i, l, child, isBR;
|
let i, l, child, isBR;
|
||||||
|
|
||||||
for ( i = 0, l = children.length; i < l; ++i ) {
|
for ( i = 0, l = children.length; i < l; ++i ) {
|
||||||
child = children[i];
|
child = children[i];
|
||||||
isBR = child.nodeName === 'BR';
|
isBR = child.nodeName === 'BR';
|
||||||
if ( !isBR && isInline( child ) && (
|
if ( !isBR && isInline( child )
|
||||||
config.blockTag !== 'DIV' ||
|
&& (this._config.blockTag !== 'DIV' || !child.matches(phrasingElements))
|
||||||
!phrasingContentElements.matches(phrasingElements)
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
if ( !wrapper ) {
|
if ( !wrapper ) {
|
||||||
wrapper = createElement( doc, 'div' );
|
wrapper = createElement( doc, 'div' );
|
||||||
|
|
@ -340,6 +338,34 @@ const
|
||||||
fixContainer( child, root );
|
fixContainer( child, root );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
// Not live
|
||||||
|
[...container.children].forEach(child => {
|
||||||
|
isBR = child.nodeName === 'BR';
|
||||||
|
if ( !isBR && isInline( child )
|
||||||
|
&& (root.__squire__._config.blockTag !== 'DIV' || !child.matches(phrasingElements))
|
||||||
|
) {
|
||||||
|
if ( !wrapper ) {
|
||||||
|
wrapper = createElement( doc, 'div' );
|
||||||
|
}
|
||||||
|
wrapper.append( child );
|
||||||
|
} else if ( isBR || wrapper ) {
|
||||||
|
if ( !wrapper ) {
|
||||||
|
wrapper = createElement( doc, 'div' );
|
||||||
|
}
|
||||||
|
fixCursor( wrapper, root );
|
||||||
|
if ( isBR ) {
|
||||||
|
child.replaceWith( wrapper );
|
||||||
|
} else {
|
||||||
|
child.before( wrapper );
|
||||||
|
}
|
||||||
|
wrapper = null;
|
||||||
|
}
|
||||||
|
if ( isContainer( child ) ) {
|
||||||
|
fixContainer( child, root );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
*/
|
||||||
if ( wrapper ) {
|
if ( wrapper ) {
|
||||||
container.append( fixCursor( wrapper, root ) );
|
container.append( fixCursor( wrapper, root ) );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
vendors/squire/build/squire.js
vendored
1
vendors/squire/build/squire.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue