diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e00c7694..ea70651db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +* **Build 19x** (2015-02-xx) + - Added "Auto close tags and special characters" to Code editor preferences. + * **Build 190** (2015-02-14) - For security reasons a vague error message is shown when a user tries to sign in unsuccessfully and the setting `app.debug` is disabled. diff --git a/modules/backend/formwidgets/CodeEditor.php b/modules/backend/formwidgets/CodeEditor.php index 701f837c3..697beb3e7 100644 --- a/modules/backend/formwidgets/CodeEditor.php +++ b/modules/backend/formwidgets/CodeEditor.php @@ -23,37 +23,48 @@ class CodeEditor extends FormWidgetBase public $language = 'php'; /** - * @var boolean Determines whether the gutter is visible + * @var boolean Determines whether the gutter is visible. */ public $showGutter = true; /** - * @var boolean Indicates whether the the word wrapping is enabled + * @var boolean Indicates whether the the word wrapping is enabled. */ public $wordWrap = true; /** - * @var boolean Indicates whether the the editor uses spaces for indentation + * @var string Cold folding mode: manual, markbegin, markbeginend. + */ + public $codeFolding = 'manual'; + + /** + * @var boolean Automatically close tags and special characters, + * like quotation marks, parenthesis, or brackets. + */ + public $autoClosing = true; + + /** + * @var boolean Indicates whether the the editor uses spaces for indentation. */ public $useSoftTabs = true; /** - * @var boolean Sets the size of the indentation + * @var boolean Sets the size of the indentation. */ public $tabSize = 4; /** - * @var integer Sets the font size + * @var integer Sets the font size. */ public $fontSize = 12; /** - * @var integer Sets the editor margin size + * @var integer Sets the editor margin size. */ public $margin = 10; /** - * @var $theme Ace Editor theme to use + * @var $theme Ace Editor theme to use. */ public $theme = 'twilight'; @@ -68,6 +79,7 @@ class CodeEditor extends FormWidgetBase $this->fontSize = $this->getConfig('fontSize', $editorSettings->font_size); $this->wordWrap = $this->getConfig('wordWrap', $editorSettings->word_wrap); $this->codeFolding = $this->getConfig('codeFolding', $editorSettings->code_folding); + $this->autoClosing = $this->getConfig('autoClosing', $editorSettings->auto_closing); $this->tabSize = $this->getConfig('tabSize', $editorSettings->tab_size); $this->theme = $this->getConfig('theme', $editorSettings->theme); $this->showInvisibles = $this->getConfig('showInvisibles', $editorSettings->show_invisibles); @@ -95,6 +107,7 @@ class CodeEditor extends FormWidgetBase $this->vars['fontSize'] = $this->fontSize; $this->vars['wordWrap'] = $this->wordWrap; $this->vars['codeFolding'] = $this->codeFolding; + $this->vars['autoClosing'] = $this->autoClosing; $this->vars['tabSize'] = $this->tabSize; $this->vars['theme'] = $this->theme; $this->vars['showInvisibles'] = $this->showInvisibles; diff --git a/modules/backend/formwidgets/codeeditor/assets/js/codeeditor.js b/modules/backend/formwidgets/codeeditor/assets/js/codeeditor.js index 78ee0615a..20ad531df 100644 --- a/modules/backend/formwidgets/codeeditor/assets/js/codeeditor.js +++ b/modules/backend/formwidgets/codeeditor/assets/js/codeeditor.js @@ -44,6 +44,7 @@ showInvisibles: true, highlightActiveLine: true, useSoftTabs: true, + autoCloseTags: true, showGutter: true, language: 'php', margin: 0, @@ -122,6 +123,7 @@ */ editor.wrapper = this editor.setShowInvisibles(options.showInvisibles) + editor.setBehavioursEnabled(options.autoCloseTags) editor.setHighlightActiveLine(options.highlightActiveLine) editor.renderer.setShowGutter(options.showGutter) editor.renderer.setShowPrintMargin(options.showPrintMargin) diff --git a/modules/backend/formwidgets/codeeditor/partials/_codeeditor.htm b/modules/backend/formwidgets/codeeditor/partials/_codeeditor.htm index 51c6e3c02..155f08e40 100644 --- a/modules/backend/formwidgets/codeeditor/partials/_codeeditor.htm +++ b/modules/backend/formwidgets/codeeditor/partials/_codeeditor.htm @@ -8,6 +8,7 @@ data-font-size="= $fontSize ?>" data-word-wrap="= $wordWrap ?>" data-code-folding="= $codeFolding ?>" + data-auto-close-tags="= $autoClosing ?>" data-tab-size="= $tabSize ?>" data-theme="= $theme ?>" data-show-invisibles="= $showInvisibles ?>" diff --git a/modules/backend/models/EditorPreferences.php b/modules/backend/models/EditorPreferences.php index 6ba12eafe..faa5f6537 100644 --- a/modules/backend/models/EditorPreferences.php +++ b/modules/backend/models/EditorPreferences.php @@ -30,6 +30,7 @@ class EditorPreferences extends Model $this->highlight_active_line = $config->get('editor.highlight_active_line', true); $this->use_hard_tabs = $config->get('editor.use_hard_tabs', false); $this->show_gutter = $config->get('editor.show_gutter', true); + $this->auto_closing = $config->get('editor.auto_closing', true); } public static function applyConfigValues() @@ -45,6 +46,7 @@ class EditorPreferences extends Model $config->set('editor.highlight_active_line', $settings->highlight_active_line); $config->set('editor.use_hard_tabs', $settings->use_hard_tabs); $config->set('editor.show_gutter', $settings->show_gutter); + $config->set('editor.auto_closing', $settings->auto_closing); } public function getThemeOptions() diff --git a/modules/backend/models/editorpreferences/fields.yaml b/modules/backend/models/editorpreferences/fields.yaml index fa7c3e124..09108286e 100644 --- a/modules/backend/models/editorpreferences/fields.yaml +++ b/modules/backend/models/editorpreferences/fields.yaml @@ -4,66 +4,70 @@ fields: - font_size: - label: backend::lang.editor.font_size - span: auto - type: dropdown - options: - 11: 11px - 12: 12px - 13: 13px - 14: 14px - 15: 15px - 16: 16px + font_size: + label: backend::lang.editor.font_size + span: auto + type: dropdown + options: + 11: 11px + 12: 12px + 13: 13px + 14: 14px + 15: 15px + 16: 16px - word_wrap: - label: backend::lang.editor.word_wrap - type: dropdown - span: auto - options: - off: Off - 40: 40 Characters - 80: 80 Characters - fluid: Fluid + word_wrap: + label: backend::lang.editor.word_wrap + type: dropdown + span: auto + options: + off: Off + 40: 40 Characters + 80: 80 Characters + fluid: Fluid - code_folding: - label: backend::lang.editor.code_folding - type: dropdown - span: auto - options: - manual: Off - markbegin: Mark begin - markbeginend: Mark begin and end + code_folding: + label: backend::lang.editor.code_folding + type: dropdown + span: auto + options: + manual: Off + markbegin: Mark begin + markbeginend: Mark begin and end - tab_size: - label: backend::lang.editor.tab_size - span: auto - type: dropdown - options: - 2: 2 - 3: 3 - 4: 4 - 5: 5 - 6: 6 - 7: 7 - 8: 8 + tab_size: + label: backend::lang.editor.tab_size + span: auto + type: dropdown + options: + 2: 2 + 3: 3 + 4: 4 + 5: 5 + 6: 6 + 7: 7 + 8: 8 - theme: - label: backend::lang.editor.theme - type: dropdown + theme: + label: backend::lang.editor.theme + type: dropdown - show_invisibles: - label: backend::lang.editor.show_invisibles - type: checkbox + auto_closing: + label: Auto close tags and special characters + type: checkbox - highlight_active_line: - label: backend::lang.editor.highlight_active_line - type: checkbox + show_invisibles: + label: backend::lang.editor.show_invisibles + type: checkbox - use_hard_tabs: - label: backend::lang.editor.use_hard_tabs - type: checkbox + highlight_active_line: + label: backend::lang.editor.highlight_active_line + type: checkbox - show_gutter: - label: backend::lang.editor.show_gutter - type: checkbox + use_hard_tabs: + label: backend::lang.editor.use_hard_tabs + type: checkbox + + show_gutter: + label: backend::lang.editor.show_gutter + type: checkbox diff --git a/modules/system/controllers/settings/mysettings.htm b/modules/system/controllers/settings/mysettings.htm index cb63249ad..a83448b62 100644 --- a/modules/system/controllers/settings/mysettings.htm +++ b/modules/system/controllers/settings/mysettings.htm @@ -9,7 +9,7 @@