Skip to content

Commit

Permalink
Merge pull request #232 from stfalcon/master
Browse files Browse the repository at this point in the history
Merge master back to 2.x
  • Loading branch information
fre5h authored Dec 9, 2019
2 parents fc86c99 + 3455d81 commit 28f42d5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public function getConfigTreeBuilder()
{
$defaults = $this->getTinymceDefaults();

$treeBuilder = new TreeBuilder();
$treeBuilder = new TreeBuilder('stfalcon_tinymce');

return $treeBuilder
->root('stfalcon_tinymce', 'array')
->getRootNode()
->children()
// Include jQuery (true) library or not (false)
->booleanNode('include_jquery')->defaultFalse()->end()
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ This bundle makes it very easy to add the TinyMCE WYSIWYG editor to your Symfony

| Bundle Version (X.Y) | PHP | Symfony | Comment |
|:--------------------:|:-------:|:------------------:|------------------------------------------|
| 2.0 | >= 5.4 | >= 3.0 | Actual version |
| 2.3 | >= 7.1 | >= 3.4 | Actual version |
| 2.0 | >= 5.4 | >= 3.0 | |
| 1.0 | >= 5.4 | >= 2.1 and <= 2.8 | |

> NOTE! To upgrade your configuration, please read UPGRADE.md
Expand Down
1 change: 1 addition & 0 deletions Resources/config/service.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<!-- T W I G H E L P E R S -->
<service id="twig.extension.stfalcon_tinymce" class="%stfalcon_tinymce.twig.extension.class%">
<argument type="service" id="service_container" />
<argument type="service" id="assets.packages" />
<tag name="twig.extension" alias="stfalcon_tinymce" />
</service>
</services>
Expand Down
2 changes: 1 addition & 1 deletion Resources/public/js/init.standard.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function initTinyMCE(options) {
if (_t) textareas.push(_t);
break;
case ".":
textareas = getElementsByClassName(options.selector.substring(1), 'textarea');
textareas = document.getElementsByClassName(options.selector.substring(1));
break;
default :
textareas = document.getElementsByTagName('textarea');
Expand Down
23 changes: 17 additions & 6 deletions Twig/Extension/StfalconTinymceExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Stfalcon\Bundle\TinymceBundle\Twig\Extension;

use Stfalcon\Bundle\TinymceBundle\Helper\LocaleHelper;
use Symfony\Component\Asset\Packages;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand All @@ -25,14 +26,20 @@ class StfalconTinymceExtension extends \Twig_Extension
*/
protected $baseUrl;

/**
* @var Packages
*/
private $packages;

/**
* Initialize tinymce helper
*
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
public function __construct(ContainerInterface $container, Packages $packages)
{
$this->container = $container;
$this->packages = $packages;
}

/**
Expand Down Expand Up @@ -94,7 +101,7 @@ public function tinymceInit($options = array())
unset($config['asset_package_name']);

/** @var $assets \Symfony\Component\Templating\Helper\CoreAssetsHelper */
$assets = $this->getService('assets.packages');
$assets = $this->packages;

// Get path to tinymce script for the jQuery version of the editor
if ($config['tinymce_jquery']) {
Expand Down Expand Up @@ -151,7 +158,10 @@ public function tinymceInit($options = array())
foreach ($config['theme'] as $themeName => $themeOptions) {
if (isset($themeOptions['content_css'])) {
// As there may be multiple CSS Files specified we need to parse each of them individually
$cssFiles = explode(',', $themeOptions['content_css']);
$cssFiles = $themeOptions['content_css'];
if (!is_array($themeOptions['content_css'])) {
$cssFiles = explode(',', $themeOptions['content_css']);
}

foreach ($cssFiles as $idx => $file) {
$cssFiles[$idx] = $this->getAssetsUrl(trim($file)); // we trim to be sure we get the file without spaces.
Expand All @@ -166,16 +176,18 @@ public function tinymceInit($options = array())
$tinymceConfiguration = preg_replace(
array(
'/"file_browser_callback":"([^"]+)"\s*/',
'/"file_picker_callback":"([^"]+)"\s*/',
'/"paste_preprocess":"([^"]+)"\s*/',
),
array(
'file_browser_callback:$1',
'file_picker_callback:$1',
'"paste_preprocess":$1',
),
json_encode($config)
);

return $this->getService('templating')->render('StfalconTinymceBundle:Script:init.html.twig', array(
return $this->getService('twig')->render('@StfalconTinymce/Script/init.html.twig', array(
'tinymce_config' => $tinymceConfiguration,
'include_jquery' => $config['include_jquery'],
'tinymce_jquery' => $config['tinymce_jquery'],
Expand Down Expand Up @@ -203,8 +215,7 @@ public function getName()
*/
protected function getAssetsUrl($inputUrl)
{
/** @var $assets \Symfony\Component\Templating\Helper\CoreAssetsHelper */
$assets = $this->getService('assets.packages');
$assets = $this->packages;

$url = preg_replace('/^asset\[(.+)\]$/i', '$1', $inputUrl);

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"issues": "https://github.com/stfalcon/TinymceBundle/issues"
},
"require": {
"php": ">=5.4.0",
"symfony/symfony": ">=2.1"
"php": "^7.1.3",
"symfony/framework-bundle": "^3.4||^4.0||^5.0"
},
"autoload": {
"psr-0": {
Expand Down

0 comments on commit 28f42d5

Please sign in to comment.