Ich versuche CKEditor
in Angular App zu integrieren. In CKEditor
versuche ich uploadimage zu verwenden. In Run-Methode meiner App habe ich folgenden Code geschrieben, um die Ereignisse von CKEditor
zu hören.CKEDITOR Bild hochladen - fileUploadResponse Ereignis wird nicht ausgelöst
CKEDITOR.on('instanceCreated', function(event) {
console.log("CKEditor instance created");
});
CKEDITOR.on('fileUploadResponse', function(evt) {
// Prevent the default response handler.
console.log("Image Uploaded");
evt.stop();
// Ger XHR and response.
var data = evt.data,
xhr = data.fileLoader.xhr,
response = xhr.responseText.split('|');
if (response[ 1 ]) {
// Error occurred during upload.
data.message = response[ 1 ];
evt.cancel();
} else {
data.url = response[ 0 ];
}
console.log("Image Uploaded");
});
In Konsole wird es Druck CKEditor instance created
, aber nicht Image Uploaded
Druck. Irgendwie hört es nicht fileUploadResponse
Ereignis.
Meine Konfigurationsdatei von CKEditor ist wie folgt:
CKEDITOR.editorConfig = function(config) {
// Define changes to default configuration here.
// For complete reference see:
// http://docs.ckeditor.com/#!/api/CKEDITOR.config
// The toolbar groups arrangement, optimized for two toolbar rows.
config.toolbarGroups = [
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ] },
{ name: 'links' },
{ name: 'insert' },
{ name: 'forms' },
{ name: 'tools' },
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
{ name: 'others' },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
{ name: 'styles' },
{ name: 'colors' },
{ name: 'about' }
];
// Remove some buttons provided by the standard plugins, which are
// not needed in the Standard(s) toolbar.
config.removeButtons = 'Underline,Subscript,Superscript';
// Set the most common block elements.
config.format_tags = 'p;h1;h2;h3;pre';
// Simplify the dialog windows.
config.removeDialogTabs = 'image:advanced;link:advanced';
config.extraPlugins = 'uploadimage';
config.uploadUrl = '/notice/fileupload';
};
Alles funktioniert gut und mein Image-Datei auch erfolgreich und ich erhalte folgende JSON-Antwort ist das Hochladen:
{
"uploaded": 1,
"fileName": "checkout.PNG",
"url": "/img/syllabus/checkout.PNG",
"error": null
}
Aber fileUploadResponse
ist nach so vielen Versuchen nicht feuern. Ich bin mir nicht sicher, welchen Teil ich vermisse.
Danke @Benjamin Schüller für die Hervorhebung meines Fehlers. Basierend darauf kann ich das Problem mithilfe der ng-ckeditor-Bibliothek lösen. Ich habe den Code in Antwort hinzugefügt. – hemu