mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 11:39:21 +03:00
Fix html editor
This commit is contained in:
parent
17f6204d2a
commit
987fe4c2b7
15 changed files with 322 additions and 226 deletions
|
|
@ -59,7 +59,7 @@ HtmlEditorWrapper.prototype.blurTrigger = function ()
|
|||
var self = this;
|
||||
window.clearTimeout(self.iBlurTimer);
|
||||
self.iBlurTimer = window.setTimeout(function () {
|
||||
self.fOnBlur();
|
||||
self.fOnBlur();
|
||||
}, 200);
|
||||
}
|
||||
};
|
||||
|
|
@ -72,6 +72,14 @@ HtmlEditorWrapper.prototype.focusTrigger = function ()
|
|||
}
|
||||
};
|
||||
|
||||
HtmlEditorWrapper.prototype.hideEditorToolbar = function ()
|
||||
{
|
||||
if (this.editor)
|
||||
{
|
||||
$('.cke.cke_float').hide();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sHtml
|
||||
* @return {string}
|
||||
|
|
@ -86,7 +94,7 @@ HtmlEditorWrapper.prototype.htmlToPlain = function (sHtml)
|
|||
if (arguments && 1 < arguments.length)
|
||||
{
|
||||
var sText = $.trim(arguments[1])
|
||||
.replace(/__bq__start__([\s\S\n\r]*)__bq__end__/gm, convertBlockquote)
|
||||
.replace(/__bq__start__(.|[\s\S\n\r]*)__bq__end__/gm, convertBlockquote)
|
||||
;
|
||||
|
||||
sText = '\n' + sQuoteChar + $.trim(sText).replace(/\n/gm, '\n' + sQuoteChar) + '\n>\n';
|
||||
|
|
@ -105,7 +113,7 @@ HtmlEditorWrapper.prototype.htmlToPlain = function (sHtml)
|
|||
var sText = $.trim(arguments[1]);
|
||||
if (0 < sText.length)
|
||||
{
|
||||
sText = sText.replace(/<div[^>]*>([\s\S]*)<\/div>/gmi, convertDivs);
|
||||
sText = sText.replace(/<div[^>]*>(.|[\s\S\r\n]*)<\/div>/gmi, convertDivs);
|
||||
sText = '\n' + $.trim(sText) + '\n';
|
||||
}
|
||||
return sText;
|
||||
|
|
@ -113,6 +121,15 @@ HtmlEditorWrapper.prototype.htmlToPlain = function (sHtml)
|
|||
return '';
|
||||
},
|
||||
|
||||
fixAttibuteValue = function () {
|
||||
if (arguments && 1 < arguments.length)
|
||||
{
|
||||
return '' + arguments[1] + arguments[2].replace(/</g, '<').replace(/>/g, '>');
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
|
||||
convertLinks = function () {
|
||||
if (arguments && 1 < arguments.length)
|
||||
{
|
||||
|
|
@ -135,6 +152,7 @@ HtmlEditorWrapper.prototype.htmlToPlain = function (sHtml)
|
|||
|
||||
sText = sHtml
|
||||
.replace(/[\s]+/gm, ' ')
|
||||
.replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue)
|
||||
.replace(/<br\s?\/?>/gmi, '\n')
|
||||
.replace(/<\/h\d>/gi, '\n')
|
||||
.replace(/<\/p>/gi, '\n\n')
|
||||
|
|
@ -143,10 +161,10 @@ HtmlEditorWrapper.prototype.htmlToPlain = function (sHtml)
|
|||
.replace(/<\/tr>/gi, '\n')
|
||||
.replace(/<hr[^>]*>/gmi, '\n_______________________________\n\n')
|
||||
.replace(/<img [^>]*>/gmi, '')
|
||||
.replace(/<div[^>]*>([\s\S]*)<\/div>/gmi, convertDivs)
|
||||
.replace(/<div[^>]*>(.|[\s\S\r\n]*)<\/div>/gmi, convertDivs)
|
||||
.replace(/<blockquote[^>]*>/gmi, '\n__bq__start__\n')
|
||||
.replace(/<\/blockquote>/gmi, '\n__bq__end__\n')
|
||||
.replace(/<a [^>]*>([\s\S]*?)<\/a>/gmi, convertLinks)
|
||||
.replace(/<a [^>]*>(.|[\s\S\r\n]*)<\/a>/gmi, convertLinks)
|
||||
.replace(/ /gi, ' ')
|
||||
.replace(/<[^>]*>/gm, '')
|
||||
.replace(/>/gi, '>')
|
||||
|
|
@ -158,7 +176,7 @@ HtmlEditorWrapper.prototype.htmlToPlain = function (sHtml)
|
|||
return sText
|
||||
.replace(/\n[ \t]+/gm, '\n')
|
||||
.replace(/[\n]{3,}/gm, '\n\n')
|
||||
.replace(/__bq__start__([\s\S]*)__bq__end__/gm, convertBlockquote)
|
||||
.replace(/__bq__start__(.|[\s\S\r\n]*)__bq__end__/gm, convertBlockquote)
|
||||
.replace(/__bq__start__/gm, '')
|
||||
.replace(/__bq__end__/gm, '')
|
||||
;
|
||||
|
|
@ -397,6 +415,4 @@ HtmlEditorWrapper.prototype.modeToggle = function (bFocus)
|
|||
{
|
||||
this.focus();
|
||||
}
|
||||
|
||||
this.blurTrigger();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -81,6 +81,14 @@ SettingsIdentities.prototype.deleteIdentity = function (oIdentityToRemove)
|
|||
}
|
||||
};
|
||||
|
||||
SettingsIdentities.prototype.onHide = function ()
|
||||
{
|
||||
if (this.editor)
|
||||
{
|
||||
this.editor.hideEditorToolbar();
|
||||
}
|
||||
};
|
||||
|
||||
SettingsIdentities.prototype.onFocus = function ()
|
||||
{
|
||||
if (!this.editor && this.signatureDom())
|
||||
|
|
|
|||
|
|
@ -21,6 +21,14 @@ function SettingsIdentity()
|
|||
|
||||
Utils.addSettingsViewModel(SettingsIdentity, 'SettingsIdentity', 'SETTINGS_LABELS/LABEL_IDENTITY_NAME', 'identity');
|
||||
|
||||
SettingsIdentity.prototype.onHide = function ()
|
||||
{
|
||||
if (this.editor)
|
||||
{
|
||||
this.editor.hideEditorToolbar();
|
||||
}
|
||||
};
|
||||
|
||||
SettingsIdentity.prototype.onFocus = function ()
|
||||
{
|
||||
if (!this.editor && this.signatureDom())
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ html.html-editor-wrapper-fullscreen .html-editor-wrapper {
|
|||
border: 0;
|
||||
|
||||
padding: 10px;
|
||||
padding-right: 0;
|
||||
font-family: arial,sans-serif;
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,17 @@
|
|||
standard-user-select: none;
|
||||
}
|
||||
|
||||
.g-ui-user-select-allow {
|
||||
-webkit-user-select: inherit;
|
||||
-webkit-touch-callout: inherit;
|
||||
-khtml-user-select: inherit;
|
||||
-moz-user-select: inherit;
|
||||
-ms-user-select: inherit;
|
||||
-o-user-select: inherit;
|
||||
user-select: inherit;
|
||||
standard-user-select: inherit;
|
||||
}
|
||||
|
||||
.g-ui-clearfix {
|
||||
.clearfix();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -557,6 +557,11 @@ PopupsComposeViewModel.prototype.onHide = function ()
|
|||
{
|
||||
this.reset();
|
||||
kn.routeOn();
|
||||
|
||||
if (this.oEditor)
|
||||
{
|
||||
this.oEditor.hideEditorToolbar();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue