mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Improve switching of wysiwyg/plain composer
This commit is contained in:
parent
cd2b3ace89
commit
90ee39b114
7 changed files with 103 additions and 135 deletions
2
dev/External/CKEditor.js
vendored
2
dev/External/CKEditor.js
vendored
|
|
@ -85,7 +85,7 @@ export function createCKEditor(element)
|
|||
reader.onloadend = () => {
|
||||
if (reader.result && 'wysiwyg' === editor.mode) {
|
||||
try {
|
||||
editor.setData(editor.getData().replace(imageId, `<img src="${reader.result}" />`));
|
||||
editor.setData(editor.getData().replace(imageId, `<img src="${reader.result}"/>`));
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
}
|
||||
};
|
||||
|
|
|
|||
27
dev/External/SquireUI.js
vendored
27
dev/External/SquireUI.js
vendored
|
|
@ -491,20 +491,20 @@ class SquireUI
|
|||
}
|
||||
|
||||
setMode(mode) {
|
||||
let cl = this.container.classList;
|
||||
cl.remove('squire-mode-'+this.mode);
|
||||
if ('plain' == mode) {
|
||||
let html = this.squire.getHTML();
|
||||
this.plain.value = rl.Utils.htmlToPlain(html, true).trim();
|
||||
} else {
|
||||
let plain = this.plain.value;
|
||||
this.setData(rl.Utils.plainToHtml(plain, true));
|
||||
mode = 'wysiwyg';
|
||||
if (this.mode != mode) {
|
||||
let cl = this.container.classList;
|
||||
cl.remove('squire-mode-'+this.mode);
|
||||
if ('plain' == mode) {
|
||||
this.plain.value = rl.Utils.htmlToPlain(this.squire.getHTML(), true).trim();
|
||||
} else {
|
||||
this.setData(rl.Utils.plainToHtml(this.plain.value, true));
|
||||
mode = 'wysiwyg';
|
||||
}
|
||||
this.mode = mode; // 'wysiwyg' or 'plain'
|
||||
cl.add('squire-mode-'+mode);
|
||||
this.onModeChange && this.onModeChange();
|
||||
setTimeout(()=>this.focus(),1);
|
||||
}
|
||||
this.mode = mode; // 'wysiwyg' or 'plain'
|
||||
cl.add('squire-mode-'+mode);
|
||||
this.onModeChange && this.onModeChange();
|
||||
setTimeout(()=>this.focus(),1);
|
||||
}
|
||||
|
||||
// CKeditor gimmicks used by HtmlEditor
|
||||
|
|
@ -551,6 +551,7 @@ class SquireUI
|
|||
}
|
||||
|
||||
setData(html) {
|
||||
// this.plain.value = html;
|
||||
this.squire.setHTML(trimLines(html));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue