Fix html editor

This commit is contained in:
RayMan 2014-02-10 20:14:25 +04:00
parent 17f6204d2a
commit 987fe4c2b7
15 changed files with 322 additions and 226 deletions

View file

@ -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, '&lt;').replace(/>/g, '&gt;');
}
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(/&nbsp;/gi, ' ')
.replace(/<[^>]*>/gm, '')
.replace(/&gt;/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();
};

View file

@ -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())

View file

@ -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())

View file

@ -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;

View file

@ -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();
}

View file

@ -557,6 +557,11 @@ PopupsComposeViewModel.prototype.onHide = function ()
{
this.reset();
kn.routeOn();
if (this.oEditor)
{
this.oEditor.hideEditorToolbar();
}
};
/**

View file

@ -1,9 +1,9 @@
<div class="b-settings-identities g-ui-user-select-none">
<div class="b-settings-identities">
<div class="form-horizontal">
<div class="legend">
<div class="legend g-ui-user-select-none">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/LEGEND_IDENTITY"></span>
</div>
<div class="control-group">
<div class="control-group g-ui-user-select-none">
<label class="control-label">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/LABEL_DISPLAY_NAME"></span>
</label>
@ -12,7 +12,7 @@
<div data-bind="saveTrigger: displayNameTrigger"></div>
</div>
</div>
<div class="control-group" style="display: none">
<div class="control-group g-ui-user-select-none" style="display: none">
<label class="control-label">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/LABEL_REPLY_TO"></span>
</label>
@ -21,7 +21,7 @@
</div>
</div>
<div class="control-group">
<label class="control-label">
<label class="control-label g-ui-user-select-none">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/LABEL_SIGNATURE"></span>
</label>
<div class="controls">
@ -29,7 +29,7 @@
<div style="vertical-align: top;" data-bind="saveTrigger: signatureTrigger"></div>
</div>
</div>
<div class="control-group">
<div class="control-group g-ui-user-select-none">
<div class="controls">
<label data-bind="click: function () { signatureToAll(!signatureToAll()); }">
<i data-bind="css: signatureToAll() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
@ -40,22 +40,22 @@
</div>
</div>
<br />
<div class="form-horizontal">
<div class="form-horizontal g-ui-user-select-none">
<div class="legend">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/LEGEND_IDENTITIES"></span>
</div>
</div>
<a class="btn" data-bind="click: addNewIdentity">
<a class="btn g-ui-user-select-none" data-bind="click: addNewIdentity">
<i class="icon-user-add"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/BUTTON_ADD_IDENTITY"></span>
</a>
<div class="process-place" data-bind="style: {'visibility': visibility }">
<div class="process-place g-ui-user-select-none" data-bind="style: {'visibility': visibility }">
<i class="icon-spinner animated"></i>
&nbsp;&nbsp;
<span data-bind="text: processText"></span>
</div>
<table class="table table-hover list-table" data-bind="i18nUpdate: identities">
<table class="table table-hover list-table g-ui-user-select-none" data-bind="i18nUpdate: identities">
<colgroup>
<col />
<col style="width: 140px" />

View file

@ -1,9 +1,9 @@
<div class="b-settings-identity">
<div class="form-horizontal">
<div class="legend">
<div class="legend g-ui-user-select-none">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITY/LEGEND_IDENTITY"></span>
</div>
<div class="control-group">
<div class="control-group g-ui-user-select-none">
<label class="control-label">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITY/LABEL_DISPLAY_NAME"></span>
</label>
@ -12,7 +12,7 @@
<div data-bind="saveTrigger: displayNameTrigger"></div>
</div>
</div>
<div class="control-group" style="display: none">
<div class="control-group g-ui-user-select-none" style="display: none">
<label class="control-label">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITY/LABEL_REPLY_TO"></span>
</label>
@ -21,7 +21,7 @@
</div>
</div>
<div class="control-group">
<label class="control-label">
<label class="control-label g-ui-user-select-none">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITY/LABEL_SIGNATURE"></span>
</label>
<div class="controls">
@ -29,7 +29,7 @@
<div style="vertical-align: top;" data-bind="saveTrigger: signatureTrigger"></div>
</div>
</div>
<div class="control-group">
<div class="control-group g-ui-user-select-none">
<div class="controls">
<label data-bind="click: function () { signatureToAll(!signatureToAll()); }">
<i data-bind="css: signatureToAll() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>

View file

@ -28,16 +28,15 @@ CKEDITOR.editorConfig = function( config ) {
config.removeButtons = 'Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,Indent,Outdent';
// Let's have it basic on dialogs as well.
config.removeDialogTabs = 'link:advanced;link:target';
config.removeDialogTabs = 'link:advanced;link:target;image:advanced';
config.stylesSet = false;
config.allowedContent = true;
config.autoParagraph = false;
config.enterMode = CKEDITOR.ENTER_BR;
config.shiftEnterMode = CKEDITOR.ENTER_P;
// config.uiColor = '#eeeeee';
config.font_defaultLabel = 'Arial';
config.fontSize_defaultLabel = '12px';
};

View file

@ -5690,6 +5690,16 @@ html.no-rgba .modal {
user-select: none;
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 {
*zoom: 1;
}
@ -8580,6 +8590,7 @@ html.html-editor-wrapper-fullscreen .html-editor-wrapper {
margin: 0;
border: 0;
padding: 10px;
padding-right: 0;
font-family: arial, sans-serif;
font-size: 12px;
line-height: 16px;

File diff suppressed because one or more lines are too long

View file

@ -3452,6 +3452,14 @@ HtmlEditorWrapper.prototype.focusTrigger = function ()
}
};
HtmlEditorWrapper.prototype.hideEditorToolbar = function ()
{
if (this.editor)
{
$('.cke.cke_float').hide();
}
};
/**
* @param {string} sHtml
* @return {string}
@ -3466,7 +3474,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';
@ -3485,7 +3493,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;
@ -3493,6 +3501,15 @@ HtmlEditorWrapper.prototype.htmlToPlain = function (sHtml)
return '';
},
fixAttibuteValue = function () {
if (arguments && 1 < arguments.length)
{
return '' + arguments[1] + arguments[2].replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
return '';
},
convertLinks = function () {
if (arguments && 1 < arguments.length)
{
@ -3515,6 +3532,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')
@ -3523,10 +3541,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(/&nbsp;/gi, ' ')
.replace(/<[^>]*>/gm, '')
.replace(/&gt;/gi, '>')
@ -3538,7 +3556,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, '')
;
@ -3777,8 +3795,6 @@ HtmlEditorWrapper.prototype.modeToggle = function (bFocus)
{
this.focus();
}
this.blurTrigger();
};
/**
@ -8133,6 +8149,11 @@ PopupsComposeViewModel.prototype.onHide = function ()
{
this.reset();
kn.routeOn();
if (this.oEditor)
{
this.oEditor.hideEditorToolbar();
}
};
/**
@ -12536,6 +12557,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())
@ -12691,6 +12720,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())

File diff suppressed because one or more lines are too long