Skip to content

Commit

Permalink
keyboard_handler option (#23)
Browse files Browse the repository at this point in the history
* option for keyboard_handler

* option for keyboard_handler
  • Loading branch information
sukovanej authored and norberttech committed Nov 11, 2017
1 parent 40be8ac commit 62d7526
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Form/Extension/AceEditor/Type/AceEditorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function configureOptions(OptionsResolver $resolver)
'options_enable_basic_autocompletion' => true,
'options_enable_live_autocompletion' => true,
'options_enable_snippets' => false,
'keyboard_handler' => null,
]);

$optionAllowedTypes = [
Expand All @@ -83,6 +84,7 @@ public function configureOptions(OptionsResolver $resolver)
'options_enable_basic_autocompletion' => ['bool', 'null'],
'options_enable_live_autocompletion' => ['bool', 'null'],
'options_enable_snippets' => ['bool', 'null'],
'keyboard_handler' => ['null', 'string'],
];
foreach ($optionAllowedTypes as $option => $allowedTypes) {
$resolver->setAllowedTypes($option, $allowedTypes);
Expand Down Expand Up @@ -124,6 +126,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
'options_enable_basic_autocompletion' => $options['options_enable_basic_autocompletion'],
'options_enable_live_autocompletion' => $options['options_enable_live_autocompletion'],
'options_enable_snippets' => $options['options_enable_snippets'],
'keyboard_handler' => $options['keyboard_handler'],
]
);
}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ $builder->add('description', AceEditorType::class, array(
'options_enable_basic_autocompletion' => true,
'options_enable_live_autocompletion' => true,
'options_enable_snippets' => false
'keyboard_handler' => null
));
```

Expand Down
3 changes: 3 additions & 0 deletions Resources/views/Form/div_layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
editorElm.style.marginTop = -(height) + heightUnit;
editor.setTheme("{{ theme }}");
{% if keyboard_handler is not null %}
editor.setKeyboardHandler("{{ keyboard_handler }}");
{% endif %}
editor.getSession().setMode("{{ mode }}");
editor.getSession().setValue(textarea.value);
Expand Down

0 comments on commit 62d7526

Please sign in to comment.