summaryrefslogtreecommitdiff
path: root/program/js/editor.js
diff options
context:
space:
mode:
Diffstat (limited to 'program/js/editor.js')
-rw-r--r--program/js/editor.js30
1 files changed, 23 insertions, 7 deletions
diff --git a/program/js/editor.js b/program/js/editor.js
index b2e96d180..0facfd948 100644
--- a/program/js/editor.js
+++ b/program/js/editor.js
@@ -194,7 +194,7 @@ function rcube_text_editor(config, id)
};
// switch html/plain mode
- this.toggle = function(ishtml)
+ this.toggle = function(ishtml, noconvert)
{
var curr, content, result,
// these non-printable chars are not removed on text2html and html2text
@@ -214,8 +214,7 @@ function rcube_text_editor(config, id)
if (is_sig)
content = content.replace(signature.text, sig_mark);
- // convert to html
- result = rcmail.plain2html(content, function(data) {
+ var init_editor = function(data) {
// replace signature mark with html version of the signature
if (is_sig)
data = data.replace(sig_mark, '<div id="_rc_sig">' + signature.html + '</div>');
@@ -231,7 +230,16 @@ function rcube_text_editor(config, id)
ref.tabindex(true);
}
}, 500);
- });
+ };
+
+ // convert to html
+ if (!noconvert) {
+ result = rcmail.plain2html(content, init_editor);
+ }
+ else {
+ init_editor(content);
+ result = true;
+ }
}
else if (this.editor) {
if (is_sig) {
@@ -250,8 +258,7 @@ function rcube_text_editor(config, id)
// get html content
content = this.editor.getContent();
- // convert html to text
- result = rcmail.html2plain(content, function(data) {
+ var init_plaintext = function(data) {
tinymce.execCommand('mceRemoveEditor', false, ref.id);
ref.editor = null;
@@ -260,7 +267,16 @@ function rcube_text_editor(config, id)
data = data.replace(sig_mark, "\n" + signature.text);
input.val(data).focus();
- });
+ };
+
+ // convert html to text
+ if (!noconvert) {
+ result = rcmail.html2plain(content, init_plaintext);
+ }
+ else {
+ init_plaintext(input.val());
+ result = true;
+ }
// bring back current signature
if (!result && curr)