From 5b56f46b69627807ef5490b55b7e9a8219608fd1 Mon Sep 17 00:00:00 2001 From: Henning Leutz <leutz@pcsg.de> Date: Tue, 28 Oct 2014 16:43:18 +0100 Subject: [PATCH] package dir + event destroy fix --- bin/Editor.js | 56 ++++++++++++++++++++++++++++++++++----------------- wysiwyg.xml | 2 +- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/bin/Editor.js b/bin/Editor.js index 2c79bfc..3e166cf 100644 --- a/bin/Editor.js +++ b/bin/Editor.js @@ -13,7 +13,7 @@ define([ 'controls/editors/Editor', 'Locale', - 'css!URL_OPT_DIR/quiqqer/ckeditor4/bin/Editor.css' + 'css!package/quiqqer/ckeditor4/bin/Editor.css' ], function(require, Editor, Locale) { @@ -22,14 +22,15 @@ define([ return new Class({ Extends : Editor, - Type : 'URL_OPT_DIR/quiqqer/ckeditor4/bin/Editor', + Type : 'package/quiqqer/ckeditor4/bin/Editor', Binds : [ '$onDestroy', '$onDraw', '$onSetContent', '$onGetContent', - '$onDrop' + '$onDrop', + '$onInstanceReadyListener' ], initialize : function(Manager, options) @@ -161,8 +162,21 @@ define([ { var Instance = Editor.getInstance(); - if ( window.CKEDITOR.instances[ Instance.name ] ) { - window.CKEDITOR.instances[ Instance.name ].destroy( true ); + if ( window.CKEDITOR.instances[ Instance.name ] ) + { + try + { + window.CKEDITOR.instances[ Instance.name ].destroy( true ); + + } catch ( e ) { + + } + + window.CKEDITOR.instances[ Instance.name ] = null; + delete window.CKEDITOR.instances[ Instance.name ]; + + + window.CKEDITOR.removeListener( 'instanceReady', this.$onInstanceReadyListener ); } }, @@ -216,26 +230,30 @@ define([ CKEDITOR_NEXGAM_BODY_CLASS = 'content left content-inner-container wysiwyg'; */ - window.CKEDITOR.on('instanceReady', function(instance) - { - if ( typeof instance.editor === 'undefined' || - typeof instance.editor.name === 'undefined' || - instance.editor.name !== Editor.getAttribute( 'instancename' ) ) - { - return; - } + window.CKEDITOR.on('instanceReady', self.$onInstanceReadyListener ); - Editor.setInstance( instance.editor ); - Editor.fireEvent( 'loaded', [ Editor, instance.editor ] ); + Editor.loadInstance( Container, Editor ); + }); + }, - instance.editor.focus(); - }); + $onInstanceReadyListener : function(instance) + { + if ( typeof instance.editor === 'undefined' || + typeof instance.editor.name === 'undefined' || + instance.editor.name !== this.getAttribute( 'instancename' ) ) + { + console.error( '#' ); + return; + } - Editor.loadInstance( Container, Editor ); - }); + this.setInstance( instance.editor ); + this.fireEvent( 'loaded', [ this, instance.editor ] ); + + instance.editor.focus(); }, + /** * Editor onSetContent Event * diff --git a/wysiwyg.xml b/wysiwyg.xml index 1b646d9..4479b01 100644 --- a/wysiwyg.xml +++ b/wysiwyg.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <editors> - <editor package="URL_OPT_DIR/quiqqer/ckeditor4/bin/Editor"> + <editor package="package/quiqqer/ckeditor4/bin/Editor"> ckeditor4 </editor> </editors> -- GitLab