[BUGFIX] Attach CKEditor instance to RteLinkBrowser Modal, so it can be found 55/53555/3
authorJohannes Schlier <johannes.schlier@b13.de>
Thu, 20 Jul 2017 13:07:26 +0000 (15:07 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Tue, 25 Jul 2017 14:24:53 +0000 (16:24 +0200)
Previously if the RteLinkBrowser was called from a CKEditor instance that
is within an extra iframe, the CKEditor instance could not be found.
Attaching it directly to the Modal fixes this.

Resolves: #81929
Releases: master, 8.7
Change-Id: I384fc946ed671c12b1e82732f0418a347ee9f01e
Reviewed-on: https://review.typo3.org/53555
Tested-by: TYPO3com <no-reply@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/Plugins/typo3link.js
typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/RteLinkBrowser.js

index bf71ede..0c338bb 100644 (file)
                                content: url,
                                size: Modal.sizes.large,
                                callback: function(currentModal) {
+                                       // Add the instance to the iframe itself
+                                       currentModal.data('ckeditor', editor);
                                        currentModal.find('.t3js-modal-body')
                                                .addClass('rte-ckeditor-window')
                                                .attr('id', editor.id);
index e59c571..23bcca2 100644 (file)
@@ -33,18 +33,23 @@ define(['jquery', 'TYPO3/CMS/Recordlist/LinkBrowser', 'TYPO3/CMS/Backend/Modal']
         * @param {String} editorId Id of CKEditor
         */
        RteLinkBrowser.initialize = function (editorId) {
-               var callerWindow;
-               if (typeof top.TYPO3.Backend !== 'undefined' && typeof top.TYPO3.Backend.ContentContainer.get() !== 'undefined') {
-                       callerWindow = top.TYPO3.Backend.ContentContainer.get();
+               var editor = Modal.currentModal.data('ckeditor');
+               if (typeof editor !== 'undefined') {
+                       RteLinkBrowser.CKEditor = editor;
                } else {
-                       callerWindow = window.parent;
-               }
-
-               $.each(callerWindow.CKEDITOR.instances, function (name, editor) {
-                       if (editor.id === editorId) {
-                               RteLinkBrowser.CKEditor = editor;
+                       var callerWindow;
+                       if (typeof top.TYPO3.Backend !== 'undefined' && typeof top.TYPO3.Backend.ContentContainer.get() !== 'undefined') {
+                               callerWindow = top.TYPO3.Backend.ContentContainer.get();
+                       } else {
+                               callerWindow = window.parent;
                        }
-               });
+
+                       $.each(callerWindow.CKEDITOR.instances, function (name, editor) {
+                               if (editor.id === editorId) {
+                                       RteLinkBrowser.CKEditor = editor;
+                               }
+                       });
+               }
 
                // siteUrl etc are added as data attributes to the body tag
                $.extend(RteLinkBrowser, $('body').data());