From ce5e15df6ea37ffc2c43476ecc2ddbb757343c68 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Wed, 16 Aug 2017 15:56:20 +1200 Subject: [PATCH] BUG Fix issue with multiple editors breaking plugins --- .../HTMLEditor/TinyMCECombinedGenerator.php | 38 +++++++++++++++---- .../Forms/HTMLEditor/HTMLEditorFieldTest.php | 10 ++++- .../TinyMCECombinedGeneratorTest.php | 11 ++++-- .../tinymce/{tinymce.js => tinymce.min.js} | 0 4 files changed, 47 insertions(+), 12 deletions(-) rename tests/php/Forms/HTMLEditor/TinyMCECombinedGeneratorTest/tinymce/{tinymce.js => tinymce.min.js} (100%) diff --git a/src/Forms/HTMLEditor/TinyMCECombinedGenerator.php b/src/Forms/HTMLEditor/TinyMCECombinedGenerator.php index 90fb5c116..72c384cd8 100644 --- a/src/Forms/HTMLEditor/TinyMCECombinedGenerator.php +++ b/src/Forms/HTMLEditor/TinyMCECombinedGenerator.php @@ -78,8 +78,7 @@ class TinyMCECombinedGenerator implements TinyMCEScriptGenerator, Flushable { $tinymceDir = $config->getTinyMCEPath(); - // Core JS file - $files = [ $tinymceDir . '/tinymce' ]; + $files = [ ]; // Add core languages $language = $config->getOption('language'); @@ -137,18 +136,43 @@ class TinyMCECombinedGenerator implements TinyMCEScriptGenerator, Flushable return null; }, $files)); - // Set base URL for where tinymce is loaded from - $buffer = "var tinyMCEPreInit={base:'" . Convert::raw2js($tinymceDir) . "',suffix:'.min'};\n"; + $libContent = $this->getFileContents(Director::baseFolder() . '/' . $tinymceDir . '/tinymce.min.js'); + + // Register vars for config + $baseDirJS = Convert::raw2js(Director::absoluteBaseURL()); + $buffer = []; + $buffer[] = <<