Skip to content

Commit

Permalink
[js:extras:editors] enable CKEditor editor options with `commandsOpti…
Browse files Browse the repository at this point in the history
…ons.edit.extraOptions`
  • Loading branch information
nao-pon committed Feb 4, 2019
1 parent 306df9d commit 11a297d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
9 changes: 7 additions & 2 deletions js/elFinder.options.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,13 @@ elFinder.prototype._options = {
// Uses self location with the empty value or not defined.
//managerUrl : 'elfinder.html'
managerUrl : null,
// CKEditor5' builds mode - 'classic', 'inline' or 'balloon'
ckeditor5Mode : 'inline',
// CKEditor editor options
ckeditor: {},
// CKEditor 5 editor options
ckeditor5: {
// builds mode - 'classic', 'inline' or 'balloon'
mode: 'inline'
},
// TinyMCE editor options
tinymce : {},
// Setting for Online-Convert.com
Expand Down
45 changes: 26 additions & 19 deletions js/extras/editors.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,6 @@
fm.destroy();
window.close();
};
} else if (getfile === 'tinymce') {
elFinder.prototype._options.getFileCallback = function(file, fm) {
// pass selected file data to TinyMCE
parent.tinymce.activeEditor.windowManager.getParams().oninsert(file, fm);
// close popup window
parent.tinymce.activeEditor.windowManager.close();
};
}
}

Expand Down Expand Up @@ -1724,11 +1717,16 @@
},
exts : ['htm', 'html', 'xhtml'],
setup : function(opts, fm) {
var confObj = this;
if (!fm.options.cdns.ckeditor) {
this.disabled = true;
confObj.disabled = true;
} else {
if (opts.extraOptions && opts.extraOptions.managerUrl) {
this.managerUrl = opts.extraOptions.managerUrl;
confObj.ckeOpts = {};
if (opts.extraOptions) {
confObj.ckeOpts = Object.assign({}, opts.extraOptions.ckeditor || {});
if (opts.extraOptions.managerUrl) {
confObj.managerUrl = opts.extraOptions.managerUrl;
}
}
}
},
Expand Down Expand Up @@ -1791,7 +1789,7 @@
});

// CKEditor configure
CKEDITOR.replace(textarea.id, opts);
CKEDITOR.replace(textarea.id, Object.assign(opts, self.confObj.ckeOpts));
CKEDITOR.on('dialogDefinition', function(e) {
var dlg = e.data.definition.dialog;
dlg.on('show', function(e) {
Expand Down Expand Up @@ -1844,14 +1842,21 @@
var confObj = this;
// check cdn and ES6 support
if (!fm.options.cdns.ckeditor5 || typeof window.Symbol !== 'function' || typeof Symbol() !== 'symbol') {
this.disabled = true;
confObj.disabled = true;
} else {
confObj.ckeOpts = {};
if (opts.extraOptions) {
// @deprecated option extraOptions.ckeditor5Mode
if (opts.extraOptions.ckeditor5Mode) {
this.ckeditor5Mode = opts.extraOptions.ckeditor5Mode;
confObj.ckeditor5Mode = opts.extraOptions.ckeditor5Mode;
}
confObj.ckeOpts = Object.assign({}, opts.extraOptions.ckeditor5 || {});
if (confObj.ckeOpts.mode) {
confObj.ckeditor5Mode = confObj.ckeOpts.mode;
delete confObj.ckeOpts.mode;
}
if (opts.extraOptions.managerUrl) {
this.managerUrl = opts.extraOptions.managerUrl;
confObj.managerUrl = opts.extraOptions.managerUrl;
}
}
}
Expand Down Expand Up @@ -1920,7 +1925,7 @@
});

cEditor
.create(editnode, opts)
.create(editnode, Object.assign(opts, self.confObj.ckeOpts))
.then(function(editor) {
var ckf = editor.commands.get('ckfinder'),
fileRepo = editor.plugins.get('FileRepository'),
Expand Down Expand Up @@ -2111,14 +2116,16 @@
},
exts : ['htm', 'html', 'xhtml'],
setup : function(opts, fm) {
var confObj = this;
if (!fm.options.cdns.tinymce) {
this.disabled = true;
confObj.disabled = true;
} else {
confObj.mceOpts = {};
if (opts.extraOptions) {
this.uploadOpts = Object.assign({}, opts.extraOptions.uploadOpts || {});
this.mceOpts = Object.assign({}, opts.extraOptions.tinymce || {});
confObj.uploadOpts = Object.assign({}, opts.extraOptions.uploadOpts || {});
confObj.mceOpts = Object.assign({}, opts.extraOptions.tinymce || {});
} else {
this.uploadOpts = {};
confObj.uploadOpts = {};
}
}
},
Expand Down

0 comments on commit 11a297d

Please sign in to comment.