From f9acb4157b515c9dbb9e7f2b77b362dcf491e1fa Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 20 Mar 2018 15:26:41 +0100 Subject: [PATCH] Expose option to disable snippets --- public/app/core/components/code_editor/code_editor.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/app/core/components/code_editor/code_editor.ts b/public/app/core/components/code_editor/code_editor.ts index 8cbd888bb1b..886ae2a6407 100644 --- a/public/app/core/components/code_editor/code_editor.ts +++ b/public/app/core/components/code_editor/code_editor.ts @@ -21,6 +21,8 @@ * data-tab-size - Tab size, default is 2. * data-behaviours-enabled - Specifies whether to use behaviors or not. "Behaviors" in this case is the auto-pairing of * special characters, like quotation marks, parenthesis, or brackets. + * data-snippets-enabled - Specifies whether to use snippets or not. "Snippets" are small pieces of code that can be + * inserted via the completion box. * * Keybindings: * Ctrl-Enter (Command-Enter): run onChange() function @@ -49,6 +51,7 @@ const DEFAULT_MODE = 'text'; const DEFAULT_MAX_LINES = 10; const DEFAULT_TAB_SIZE = 2; const DEFAULT_BEHAVIOURS = true; +const DEFAULT_SNIPPETS = true; let editorTemplate = `
`; @@ -59,6 +62,7 @@ function link(scope, elem, attrs) { let showGutter = attrs.showGutter !== undefined; let tabSize = attrs.tabSize || DEFAULT_TAB_SIZE; let behavioursEnabled = attrs.behavioursEnabled ? attrs.behavioursEnabled === 'true' : DEFAULT_BEHAVIOURS; + let snippetsEnabled = attrs.snippetsEnabled ? attrs.snippetsEnabled === 'true' : DEFAULT_SNIPPETS; // Initialize editor let aceElem = elem.get(0); @@ -143,7 +147,7 @@ function link(scope, elem, attrs) { codeEditor.setOptions({ enableBasicAutocompletion: true, enableLiveAutocompletion: true, - enableSnippets: true, + enableSnippets: snippetsEnabled, }); if (scope.getCompleter()) {