[BUGFIX] Initialize T3editor properly 88/47188/2
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Mon, 15 Feb 2016 17:35:21 +0000 (18:35 +0100)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 11 Mar 2016 09:01:00 +0000 (10:01 +0100)
If a T3editor is instantiated on-the-fly, it is not initialized properly.
Add a callback to the ``Form/Element/T3editorElement`` class and mark
editor instances as initialized to prevent double initialization.

Change-Id: I8c6b692eb2c132180ed0d122b35515276df5acd9
Resolves: #73425
Releases: master, 7.6
Reviewed-on: https://review.typo3.org/47188
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/t3editor/Classes/Form/Element/T3editorElement.php
typo3/sysext/t3editor/Resources/Public/JavaScript/T3editor.js

index a460f05..cb02e03 100644 (file)
@@ -123,6 +123,7 @@ class T3editorElement extends AbstractFormElement
             $this->data['tableName'] . ' > ' . $this->data['fieldName'],
             array('target' => 0)
         );
+        $this->resultArray['additionalJavaScriptPost'][] = 'require(["TYPO3/CMS/T3editor/T3editor"], function(T3editor) {T3editor.findAndInitializeEditors();});';
 
         $this->initJavascriptCode();
         return $this->resultArray;
@@ -158,7 +159,6 @@ class T3editorElement extends AbstractFormElement
     protected function initJavascriptCode()
     {
         $this->resultArray['stylesheetFiles'][] = $this->relExtPath . 'Resources/Public/Css/t3editor.css';
-        $this->resultArray['requireJsModules'][] = 'TYPO3/CMS/T3editor/T3editor';
         if ($this->mode === self::MODE_TYPOSCRIPT) {
             foreach ($this->codeCompletionComponents as $codeCompletionComponent) {
                 $this->resultArray['requireJsModules'][] = 'TYPO3/CMS/T3editor/Plugins/CodeCompletion/' . $codeCompletionComponent;
index 7fe92bf..6a994b5 100644 (file)
@@ -45,6 +45,9 @@ define(['jquery',
         * @param {Number} index
         */
        T3editor.initializeEditor = function($editor, index) {
+               if ($editor.data('initialized')) {
+                       return;
+               }
                var $textarea = $editor.find('textarea'),
                        options = {
                                labels: $textarea.data('labels'),
@@ -76,6 +79,7 @@ define(['jquery',
                                $textarea.hide();
                        }
                });
+               $editor.data('initialized', true);
        };
 
        /**