public function AceEditor::getForm in Ace Code Editor 8
Returns a settings form to configure this text editor.
Parameters
array $settings: An array containing form configuration.
Return value
array A primary render array for the settings form.
1 call to AceEditor::getForm()
- AceEditor::buildConfigurationForm in src/
Plugin/ Editor/ AceEditor.php - Form constructor.
File
- src/
Plugin/ Editor/ AceEditor.php, line 42
Class
- AceEditor
- Defines AceEditor as an Editor plugin.
Namespace
Drupal\ace_editor\Plugin\EditorCode
public function getForm(array $settings) {
$config = \Drupal::config('ace_editor.settings');
return [
'theme' => [
'#type' => 'select',
'#title' => t('Theme'),
'#options' => $config
->get('theme_list'),
'#attributes' => [
'style' => 'width: 150px;',
],
'#default_value' => $settings['theme'],
],
'syntax' => [
'#type' => 'select',
'#title' => t('Syntax'),
'#description' => t('The syntax that will be highlighted.'),
'#options' => $config
->get('syntax_list'),
'#attributes' => [
'style' => 'width: 150px;',
],
'#default_value' => $settings['syntax'],
],
'height' => [
'#type' => 'textfield',
'#title' => t('Height'),
'#description' => t('The height of the editor in either pixels or percents.'),
'#attributes' => [
'style' => 'width: 100px;',
],
'#default_value' => $settings['height'],
],
'width' => [
'#type' => 'textfield',
'#title' => t('Width'),
'#description' => t('The width of the editor in either pixels or percents.'),
'#attributes' => [
'style' => 'width: 100px;',
],
'#default_value' => $settings['width'],
],
'font_size' => [
'#type' => 'textfield',
'#title' => t('Font size'),
'#description' => t('The font size used in the editor.'),
'#attributes' => [
'style' => 'width: 100px;',
],
'#default_value' => $settings['font_size'],
],
'line_numbers' => [
'#type' => 'checkbox',
'#title' => t('Show line numbers'),
'#default_value' => $settings['line_numbers'],
],
'print_margins' => [
'#type' => 'checkbox',
'#title' => t('Show print margin (80 chars)'),
'#default_value' => $settings['print_margins'],
],
'show_invisibles' => [
'#type' => 'checkbox',
'#title' => t('Show invisible characters (whitespaces, EOL...)'),
'#default_value' => $settings['show_invisibles'],
],
'use_wrap_mode' => [
'#type' => 'checkbox',
'#title' => t('Toggle word wrapping'),
'#default_value' => $settings['use_wrap_mode'],
],
'auto_complete' => [
'#type' => 'checkbox',
'#title' => t('Enable Autocomplete (Ctrl+Space'),
'#default_value' => isset($settings['auto_complete']) ? $settings['auto_complete'] : TRUE,
],
];
}