W.I.P. implementing TinyMCE editor and deprecating CKEditor:

- Implement vfs file selector
- Add/remove more actions from toolbar
This commit is contained in:
Hadi Nategh 2018-10-23 13:04:20 +02:00
parent 987727f5fa
commit f62c5d8ea5
4 changed files with 41 additions and 10 deletions

View File

@ -340,7 +340,7 @@ jQuery.extend(et2_ckeditor,
button_caption:"Link", button_caption:"Link",
button_label:"Link", button_label:"Link",
dialog_title: "Link file", dialog_title: "Link file",
method: "ckeditor" method: "download"
}, et2); }, et2);
jQuery(vfsSelect.getDOMNode()).on('change', function (){ jQuery(vfsSelect.getDOMNode()).on('change', function (){
CKEDITOR.tools.callFunction(_data.funcNum, vfsSelect.get_value()); CKEDITOR.tools.callFunction(_data.funcNum, vfsSelect.get_value());

View File

@ -118,11 +118,11 @@ var et2_htmlarea = (function(){ "use strict"; return et2_inputWidget.extend([et2
images_upload_handler: jQuery.proxy(this._images_upload_handler, this), images_upload_handler: jQuery.proxy(this._images_upload_handler, this),
init_instance_callback : jQuery.proxy(this._instanceIsReady, this), init_instance_callback : jQuery.proxy(this._instanceIsReady, this),
plugins: [ plugins: [
"print preview fullpage searchreplace autolink directionality "+ "print fullpage searchreplace autolink directionality "+
"visualblocks visualchars fullscreen image link media template "+ "visualblocks visualchars image link media template "+
"codesample table charmap hr pagebreak nonbreaking anchor toc "+ "codesample table charmap hr pagebreak nonbreaking anchor toc "+
"insertdatetime advlist lists textcolor wordcount imagetools "+ "insertdatetime advlist lists textcolor wordcount imagetools "+
"colorpicker textpattern help paste code" "colorpicker textpattern help paste code searchreplace"
], ],
toolbar: "formatselect | fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | "+ toolbar: "formatselect | fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | "+
"link | alignleft aligncenter alignright alignjustify | numlist "+ "link | alignleft aligncenter alignright alignjustify | numlist "+
@ -147,6 +147,7 @@ var et2_htmlarea = (function(){ "use strict"; return et2_inputWidget.extend([et2
}, },
/** /**
* Callback function runs when the filepicker in image dialog is clicked
* *
* @param {type} _callback * @param {type} _callback
* @param {type} _value * @param {type} _value
@ -155,7 +156,37 @@ var et2_htmlarea = (function(){ "use strict"; return et2_inputWidget.extend([et2
*/ */
_file_picker_callback: function(_callback, _value, _meta) { _file_picker_callback: function(_callback, _value, _meta) {
if (typeof this.file_picker_callback == 'function') return this.file_picker_callback.call(arguments, this); if (typeof this.file_picker_callback == 'function') return this.file_picker_callback.call(arguments, this);
var callback = _callback;
// Don't rely only on app_name to fetch et2 object as app_name may not
// always represent current app of the window, e.g.: mail admin account.
// Try to fetch et2 from its template name.
var etemplate = jQuery('form').data('etemplate');
var et2 = {};
if (etemplate && etemplate.name && !app[egw(window).app_name()])
{
et2 = etemplate2.getByTemplate(etemplate.name)[0]['widgetContainer'];
}
else
{
et2 = app[egw(window).app_name()].et2;
}
var vfsSelect = et2_createWidget('vfs-select', {
id:'upload',
mode: 'open',
name: '',
button_caption:"Link",
button_label:"Link",
dialog_title: "Link file",
method: "download"
}, et2);
jQuery(vfsSelect.getDOMNode()).on('change', function (){
callback(vfsSelect.get_value(), {alt:vfsSelect.get_value()});
});
// start the file selector dialog
vfsSelect.click();
}, },
/** /**
@ -208,9 +239,9 @@ var et2_htmlarea = (function(){ "use strict"; return et2_inputWidget.extend([et2
"bullist outdent indent | removeformat | image" "bullist outdent indent | removeformat | image"
break; break;
case 'advanced': case 'advanced':
settings.toolbar = "formatselect | fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | "+ settings.toolbar = "undo redo| formatselect | fontselect fontsizeselect | bold italic strikethrough forecolor backcolor | "+
"link | alignleft aligncenter alignright alignjustify | numlist "+ "link | alignleft aligncenter alignright alignjustify | numlist "+
"bullist outdent indent | removeformat code| image" "bullist outdent indent ltr rtl | removeformat code| image | searchreplace"
break; break;
} }
return settings; return settings;

View File

@ -933,7 +933,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
type: "string", type: "string",
description: "Server side callback to process selected value(s) in \n\ description: "Server side callback to process selected value(s) in \n\
app.class.method or class::method format. The first parameter will \n\ app.class.method or class::method format. The first parameter will \n\
be Method ID, the second the file list. 'ckeditor' is reserved and it \n\ be Method ID, the second the file list. 'download' is reserved and it \n\
means it should use download_baseUrl instead of path in value (no method\n\ means it should use download_baseUrl instead of path in value (no method\n\
will be actually executed)." will be actually executed)."
}, },
@ -1116,12 +1116,12 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
files = _value.path; files = _value.path;
break; break;
default: default:
if (self.options.method === 'ckeditor') _value.path = _data.content.download_baseUrl; if (self.options.method === 'download') _value.path = _data.content.download_baseUrl;
files = _value.path+'/'+_value.name; files = _value.path+'/'+_value.name;
break; break;
} }
self.value = files; self.value = files;
if (self.options.method && self.options.method !== 'ckeditor') if (self.options.method && self.options.method !== 'download')
{ {
egw(window).json( egw(window).json(
self.options.method, self.options.method,

View File

@ -526,7 +526,7 @@ class Vfs extends File
'app' => self::get_apps() 'app' => self::get_apps()
)); ));
if ($content['method'] === 'ckeditor') if ($content['method'] === 'download')
{ {
$download_baseUrl = \EGroupware\Api\Vfs::download_url($content['path']); $download_baseUrl = \EGroupware\Api\Vfs::download_url($content['path']);
if ($download_baseUrl[0] == '/') $download_baseUrl = \EGroupware\Api\Egw::link($download_baseUrl); if ($download_baseUrl[0] == '/') $download_baseUrl = \EGroupware\Api\Egw::link($download_baseUrl);