mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 12:39:20 +03:00
Cleanup more CSS and JS
and merge/cleanup/redesign composer attachments
This commit is contained in:
parent
fe45179847
commit
e52b9abc61
23 changed files with 156 additions and 293 deletions
145
dev/External/CKEditor.js
vendored
145
dev/External/CKEditor.js
vendored
|
|
@ -1,102 +1,79 @@
|
|||
const config = {
|
||||
title: false,
|
||||
stylesSet: false,
|
||||
customConfig: '',
|
||||
contentsCss: '',
|
||||
toolbarGroups: [
|
||||
{ name: 'spec' },
|
||||
{ name: 'styles' },
|
||||
{ name: 'basicstyles', groups: ['basicstyles', 'cleanup', 'bidi'] },
|
||||
{ name: 'colors' },
|
||||
{ name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align'] },
|
||||
{ name: 'links' },
|
||||
{ name: 'insert' },
|
||||
{ name: 'document', groups: ['mode', 'document', 'doctools'] },
|
||||
{ name: 'others' }
|
||||
],
|
||||
|
||||
removePlugins: 'liststyle',
|
||||
removeButtons: 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll',
|
||||
removeDialogTabs: 'link:advanced;link:target;image:advanced;images:advanced',
|
||||
|
||||
extraPlugins: 'plain,signature',
|
||||
|
||||
allowedContent: true,
|
||||
extraAllowedContent: true,
|
||||
|
||||
fillEmptyBlocks: false,
|
||||
ignoreEmptyParagraph: true,
|
||||
disableNativeSpellChecker: false,
|
||||
|
||||
colorButton_enableAutomatic: false,
|
||||
colorButton_enableMore: true,
|
||||
|
||||
font_defaultLabel: 'Arial',
|
||||
fontSize_defaultLabel: '13',
|
||||
fontSize_sizes: '10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px'
|
||||
},
|
||||
|
||||
htmlEditorLangsMap = {
|
||||
'ar_sa': 'ar-sa',
|
||||
'pt_br': 'pt-br',
|
||||
'zh_cn': 'zh-cn',
|
||||
};
|
||||
|
||||
export function createCKEditor(element)
|
||||
{
|
||||
const language = (rl.settings.get('Language') || 'en').toLowerCase(),
|
||||
noSource = !rl.settings.app('allowHtmlEditorSourceButton'),
|
||||
noBidi = !rl.settings.app('allowHtmlEditorBitiButtons');
|
||||
|
||||
if (!config.__cfgInited) {
|
||||
config.__cfgInited = true;
|
||||
htmlEditorLangsMap = {
|
||||
'ar_sa': 'ar-sa',
|
||||
'pt_br': 'pt-br',
|
||||
'zh_cn': 'zh-cn',
|
||||
};
|
||||
|
||||
if (noSource) {
|
||||
config.removeButtons += ',Source';
|
||||
}
|
||||
const editor = CKEDITOR.appendTo(element, {
|
||||
title: false,
|
||||
stylesSet: false,
|
||||
// customConfig: '',
|
||||
// contentsCss: '',
|
||||
toolbarGroups: [
|
||||
{ name: 'spec' },
|
||||
{ name: 'styles' },
|
||||
{ name: 'basicstyles', groups: ['basicstyles', 'cleanup', 'bidi'] },
|
||||
{ name: 'colors' },
|
||||
{ name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align'] },
|
||||
{ name: 'links' },
|
||||
{ name: 'insert' },
|
||||
{ name: 'document', groups: ['mode', 'document', 'doctools'] },
|
||||
{ name: 'others' }
|
||||
],
|
||||
|
||||
if (noBidi) {
|
||||
config.removePlugins += ',bidi';
|
||||
}
|
||||
}
|
||||
removePlugins: 'liststyle' + (rl.settings.app('allowHtmlEditorBitiButtons') ? '' : ',bidi'),
|
||||
removeButtons: 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll'
|
||||
+ (rl.settings.app('allowHtmlEditorSourceButton') ? '' : ',Source'),
|
||||
removeDialogTabs: 'link:advanced;link:target;image:advanced;images:advanced',
|
||||
|
||||
config.enterMode = CKEDITOR.ENTER_BR;
|
||||
config.shiftEnterMode = CKEDITOR.ENTER_P;
|
||||
extraPlugins: 'plain,signature',
|
||||
|
||||
config.language = htmlEditorLangsMap[language] || language.substr(0,2);
|
||||
allowedContent: true,
|
||||
extraAllowedContent: true,
|
||||
|
||||
if (CKEDITOR.env) {
|
||||
CKEDITOR.env.isCompatible = true;
|
||||
}
|
||||
fillEmptyBlocks: false,
|
||||
// ignoreEmptyParagraph: true,
|
||||
disableNativeSpellChecker: false,
|
||||
|
||||
const editor = CKEDITOR.appendTo(element, config);
|
||||
colorButton_enableAutomatic: false,
|
||||
// colorButton_enableMore: true,
|
||||
|
||||
font_defaultLabel: 'Arial',
|
||||
fontSize_defaultLabel: '13',
|
||||
fontSize_sizes: '10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px',
|
||||
|
||||
enterMode: CKEDITOR.ENTER_BR,
|
||||
shiftEnterMode: CKEDITOR.ENTER_P,
|
||||
language: htmlEditorLangsMap[language] || language.substr(0,2)
|
||||
});
|
||||
|
||||
editor.on('key', event => !(event && event.data && 'Tab' == event.data.key));
|
||||
|
||||
if (window.FileReader) {
|
||||
editor.on('drop', event => {
|
||||
if (0 < event.data.dataTransfer.getFilesCount()) {
|
||||
const file = event.data.dataTransfer.getFile(0);
|
||||
if (file && event.data.dataTransfer.id && file.type && file.type.match(/^image/i)) {
|
||||
const id = event.data.dataTransfer.id,
|
||||
imageId = `[img=${id}]`,
|
||||
reader = new FileReader();
|
||||
editor.on('drop', event => {
|
||||
const dt = event.data.dataTransfer,
|
||||
id = dt.id,
|
||||
file = dt.getFilesCount() ? dt.getFile(0) : 0;
|
||||
if (file && id && file.type && file.type.match(/^image/i)) {
|
||||
const imageId = `[img=${id}]`,
|
||||
reader = new FileReader();
|
||||
|
||||
reader.onloadend = () => {
|
||||
if (reader.result && 'wysiwyg' === editor.mode) {
|
||||
try {
|
||||
editor.setData(editor.getData().replace(imageId, `<img src="${reader.result}"/>`));
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
}
|
||||
};
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
|
||||
event.data.dataTransfer.setData('text/html', imageId);
|
||||
reader.onloadend = () => {
|
||||
if (reader.result && 'wysiwyg' === editor.mode) {
|
||||
try {
|
||||
editor.setData(editor.getData().replace(imageId, `<img src="${reader.result}"/>`));
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
|
||||
dt.setData('text/html', imageId);
|
||||
}
|
||||
});
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue