From 4bd962b553c269ad491fdc76c4f834acf9af57a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20Verge=CC=81s=20Solanas?=
 <juanmanuel.vergessolanas@gmail.com>
Date: Mon, 22 Feb 2016 19:53:03 +0100
Subject: [PATCH] [BUGFIX] Fix for multiple TinyMCE in same page. Avoids
 multiple initialization which was breaking the save in TYPO3.

---
 Classes/Loader.php | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/Classes/Loader.php b/Classes/Loader.php
index 9d4db40..6d9a195 100644
--- a/Classes/Loader.php
+++ b/Classes/Loader.php
@@ -299,11 +299,16 @@ class Loader {
 		$configuration .= '
 			var $ = jQuery = window.TYPO3.jQuery;
 			var RTEarea = RTEarea || window.RTEarea;
+
 			define([\'TYPO3/CMS/Tinymce/../../../../typo3conf/ext/tinymce/tinymce_node_modules/tinymce/jquery.tinymce.min.js\'], function () {
-				$(\'.tinymce4_rte\').tinymce({
-					script_url : \'' . $this->getPath($tinymceSource, TRUE) . '\',
-					' . $this->replaceTypo3Paths($this->tinymceConfiguration['configurationData']) . '
-				});
+				if(!$(\'.tinymce4_rte\').data(\'first\')){
+					$(\'.tinymce4_rte\').data(\'first\', true);
+					$(\'.tinymce4_rte\').tinymce({
+						script_url : \'' . $this->getPath($tinymceSource, TRUE) . '\',
+						' . $this->replaceTypo3Paths($this->tinymceConfiguration['configurationData']) . '
+					});
+				}
+
 			});
 		';
 		$configuration .= $this->tinymceConfiguration['postJS'];
@@ -410,4 +415,4 @@ class Loader {
 	}
 }
 
-?>
\ No newline at end of file
+?>
-- 
GitLab