Skip to content

Commit 05938a5

Browse files
committed
Updated including ace editor javascripts.
1 parent 87a93ae commit 05938a5

File tree

492 files changed

+271330
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

492 files changed

+271330
-13
lines changed

DependencyInjection/Configuration.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1515
use Symfony\Component\Config\Definition\ConfigurationInterface;
1616

17+
/**
18+
* @author Norbert Orzechowicz <[email protected]>
19+
*/
1720
class Configuration implements ConfigurationInterface
1821
{
1922
/**
@@ -24,9 +27,14 @@ public function getConfigTreeBuilder()
2427
$treeBuilder = new TreeBuilder();
2528
$rootNode = $treeBuilder->root('norzechowicz_ace_editor');
2629

27-
// Here you should define the parameters that are allowed to
28-
// configure your bundle. See the documentation linked above for
29-
// more information on that topic.
30+
$rootNode
31+
->children()
32+
->booleanNode('autoinclude')->defaultTrue()->end()
33+
->scalarNode('base_path')->defaultValue('bundles/norzechowiczaceeditor/ace')->end()
34+
->booleanNode('debug')->defaultFalse()->end()
35+
->booleanNode('noconflict')->defaultTrue()->end()
36+
->end()
37+
->end();
3038

3139
return $treeBuilder;
3240
}

DependencyInjection/NorzechowiczAceEditorExtension.php

+15
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
1717
use Symfony\Component\DependencyInjection\Loader;
1818

19+
/**
20+
* @author Norbert Orzechowicz <[email protected]>
21+
*/
1922
class NorzechowiczAceEditorExtension extends Extension
2023
{
2124
/**
@@ -26,7 +29,19 @@ public function load(array $configs, ContainerBuilder $container)
2629
$configuration = new Configuration();
2730
$config = $this->processConfiguration($configuration, $configs);
2831

32+
$this->registerAceEditorParameters($config, $container);
33+
2934
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
3035
$loader->load('form.xml');
36+
$loader->load('twig.xml');
37+
}
38+
39+
private function registerAceEditorParameters($config, ContainerBuilder $container)
40+
{
41+
$mode = 'src' . (($config['debug']) ? '' : '-min') . (($config['noconflict']) ? '-noconflict' : '') . '/ace.js';
42+
43+
$container->setParameter('norzechowicz_ace_editor.options.autoinclude', !$config['autoinclude']);
44+
$container->setParameter('norzechowicz_ace_editor.options.base_path', $config['base_path']);
45+
$container->setParameter('norzechowicz_ace_editor.options.mode', $mode);
3146
}
3247
}

Form/Extension/AceEditor/Type/AceEditorType.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
4545
};
4646

4747
$resolver->setDefaults(array(
48+
'required' => false,
4849
'wrapper_attr' => array(),
4950
'width' => 200,
5051
'height' => 200,
@@ -114,6 +115,6 @@ public function getParent()
114115
*/
115116
public function getName()
116117
{
117-
return 'aceeditor';
118+
return 'ace_editor';
118119
}
119120
}

README.md

+27-4
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ $ php composer.phar update
4040
```php
4141
/* @var $builder \Symfony\Component\Form\FormBuilderInterface */
4242

43-
$builder->add('description', 'aceeditor', array(
43+
$builder->add('description', 'ace_editor', array(
4444
'wrapper_attr' => array(), // aceeditor wrapper html attributes.
4545
'width' => 200,
4646
'height' => 200,
4747
'font_size' => 12,
48-
'mode' => 'ace/mode/html',
49-
'theme' => 'ace/theme/monokai',
48+
'mode' => 'ace/mode/html', // every single default mode must have ace/mode/* prefix
49+
'theme' => 'ace/theme/monokai', // every single default theme must have ace/theme/* prefix
5050
'tab_size' => null,
5151
'read_only' => null,
5252
'use_soft_tabs' => null,
@@ -57,4 +57,27 @@ $builder->add('description', 'aceeditor', array(
5757
```
5858

5959
Above code will create textarea element that will be replaced with ace editor instance.
60-
Textarea value is updated on every single change in ace editor.
60+
Textarea value is updated on every single change in ace editor.
61+
62+
# Configuration #
63+
64+
> This section is optional, you dont need to configure anything and your ace_editor form type will still work perfectly fine
65+
66+
There are also few options that alows you to manipulate including ace editor javascript sdk.
67+
68+
```
69+
# app/config/config.yml
70+
71+
norzechowicz_ace_editor:
72+
base_path: "bundles/norzechowiczaceeditor/ace"
73+
autoinclude: true
74+
debug: false # sources not minified with uglify.js
75+
noconflict: true # uses ace.require instead of require
76+
```
77+
78+
You can also include ace editor directly from github, all you need to do is setting ``base_path`` option
79+
80+
```
81+
norzechowicz_ace_editor:
82+
base_path: "http://rawgithub.com/ajaxorg/ace-builds/master"
83+
```

Resources/config/form.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</parameters>
1010

1111
<services>
12-
<service id="norzechowicz_ace_editor.form.type.aceeditor" class="%norzechowicz_ace_editor.form.type.aceeditor.class%" scope="request">
13-
<tag name="form.type" alias="aceeditor" />
12+
<service id="norzechowicz_ace_editor.form.type.ace_editor" class="%norzechowicz_ace_editor.form.type.aceeditor.class%" scope="request">
13+
<tag name="form.type" alias="ace_editor" />
1414
</service>
1515
</services>
1616
</container>

Resources/config/twig.xml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" ?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6+
<services>
7+
<!-- Twig Extensions -->
8+
<service id="norzechowicz_ace_editor.twig.form_extension" class="Norzechowicz\AceEditorBundle\Twig\Extension\AceEditorExtension">
9+
<tag name="twig.extension" />
10+
<argument>%norzechowicz_ace_editor.options.autoinclude%</argument>
11+
<argument>%norzechowicz_ace_editor.options.base_path%</argument>
12+
<argument>%norzechowicz_ace_editor.options.mode%</argument>
13+
</service>
14+
</services>
15+
</container>

Resources/public/ace/src-min-noconflict/ace.js

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Resources/public/ace/src-min-noconflict/ext-elastic_tabstops_lite.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Resources/public/ace/src-min-noconflict/ext-emmet.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)