diff --git a/editors/ace.inc b/editors/ace.inc index 4ce7b8e..9130b94 100644 --- a/editors/ace.inc +++ b/editors/ace.inc @@ -105,8 +105,9 @@ function wysiwyg_ace_themes($editor, $profile) { */ function wysiwyg_ace_settings($editor, $config, $theme) { $settings = array( - 'theme' => 'ace/theme/' . $theme, 'mode' => 'ace/mode/' . ((!empty($config['mode'])) ? $config['mode'] : 'html'), + 'tab_size' => (!empty($config['tab_size'])) ? $config['tab_size'] : 2, + 'theme' => 'ace/theme/' . $theme, ); if (!empty($config['buttons']['default'])) { foreach ($config['buttons']['default'] as $setting => $value) { @@ -121,12 +122,10 @@ function wysiwyg_ace_settings($editor, $config, $theme) { */ function wysiwyg_ace_settings_form(&$form, &$form_state) { // These settings don't make sense for ACE. - $form['appearance']['toolbar_loc']['#access'] = FALSE; - $form['appearance']['toolbar_align']['#access'] = FALSE; - $form['appearance']['path_loc']['#access'] = FALSE; - $form['appearance']['resizing']['#access'] = FALSE; + $form['appearance']['#access'] = FALSE; $form['output']['#access'] = FALSE; $form['css']['#access'] = FALSE; + $form['basic']['language']['#access'] = FALSE; $profile = $form_state['wysiwyg_profile']; $themes = wysiwyg_ace_themes($form_state['wysiwyg']['editor'], $profile); @@ -137,7 +136,6 @@ function wysiwyg_ace_settings_form(&$form, &$form_state) { '#options' => drupal_map_assoc($themes, '_wysiwyg_ace_make_friendly_name'), '#default_value' => $profile->settings['theme'], ); - $form['basic']['language']['#weight'] = 5; $form['basic']['mode'] = array( '#type' => 'select', '#title' => t('Language mode'), @@ -145,6 +143,12 @@ function wysiwyg_ace_settings_form(&$form, &$form_state) { '#options' => wysiwyg_ace_modes(), '#default_value' => (!empty($profile->settings['mode'])) ? $profile->settings['mode'] : 'html', ); + $form['basic']['tab_size'] = array( + '#type' => 'select', + '#title' => t('Tab size'), + '#options' => drupal_map_assoc(array(2, 4, 6, 8)), + '#default_value' => (!empty($profile->settings['tab_size'])) ? $profile->settings['tab_size'] : 2, + ); } /** @@ -210,11 +214,13 @@ function wysiwyg_ace_plugins($editor) { return array( 'default' => array( 'buttons' => array( - 'highlight_active_line' => ('Highlight active line'), + 'highlight_active_line' => t('Highlight active line'), 'highlight_selected_word' => t('Highlight selected word'), 'show_fold_widgets' => t('Show fold widgets'), 'show_invisibles' => t('Show invisible characters'), 'show_print_margin' => t('Show print margin'), + 'use_soft_tabs' => t('Use soft tabs'), + 'use_wrap_mode' => t('Use word wrap mode'), ), 'internal' => TRUE, ), diff --git a/editors/js/ace.js b/editors/js/ace.js index 40993d4..975cacb 100644 --- a/editors/js/ace.js +++ b/editors/js/ace.js @@ -14,8 +14,6 @@ Drupal.wysiwyg.editor.attach.ace = function (context, params, settings) { .after('
'); // Attach the editor. var editor = Drupal.wysiwyg.editor.instances[params.field] = ace.edit(params.field + '-ace'); - // Apply hardcoded settings. - editor.getSession().setTabSize(2); // Apply user configured settings. editor.setTheme(settings.theme); editor.getSession().setMode(settings.mode); @@ -24,6 +22,9 @@ Drupal.wysiwyg.editor.attach.ace = function (context, params, settings) { editor.setShowFoldWidgets(settings.hasOwnProperty('show_fold_widgets')); editor.setShowInvisibles(settings.hasOwnProperty('show_invisibles')); editor.setShowPrintMargin(settings.hasOwnProperty('show_print_margin')); + editor.getSession().setTabSize(settings.tab_size); + editor.getSession().setUseSoftTabs(settings.hasOwnProperty('use_soft_tabs')); + editor.getSession().setUseWrapMode(settings.hasOwnProperty('use_wrap_mode')); // Populate the editor from the TEXTAREA. editor.getSession().setValue(textarea.val()); };