mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #11316 from ryantxu/ace-disable-snippets
Expose option to disable snippets in ACE code-editor
This commit is contained in:
@@ -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 = `<div></div>`;
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user