Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
bf8171fd
Commit
bf8171fd
authored
Aug 07, 2017
by
Alexander Zobnin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code-editor: initial autocomplete
parent
b74fe05f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
public/app/core/components/code_editor/code_editor.ts
+18
-5
No files found.
public/app/core/components/code_editor/code_editor.ts
View file @
bf8171fd
...
@@ -9,22 +9,27 @@ const ACE_SRC_BASE = "public/vendor/npm/ace-builds/src-noconflict/";
...
@@ -9,22 +9,27 @@ const ACE_SRC_BASE = "public/vendor/npm/ace-builds/src-noconflict/";
// Trick for loading additional modules
// Trick for loading additional modules
function
fixModuleUrl
(
moduleType
,
name
)
{
function
fixModuleUrl
(
moduleType
,
name
)
{
let
aceModeName
=
`ace/
${
moduleType
}
/
${
name
}
`
;
let
aceModeName
=
`ace/
${
moduleType
}
/
${
name
}
`
;
ace
.
config
.
setModuleUrl
(
aceModeName
,
ACE_SRC_BASE
+
`
${
moduleType
}
-
${
name
}
.js`
);
let
componentName
=
`
${
moduleType
}
-
${
name
}
.js`
;
if
(
moduleType
===
'snippets'
)
{
componentName
=
`
${
moduleType
}
/
${
name
}
.js`
;
}
ace
.
config
.
setModuleUrl
(
aceModeName
,
ACE_SRC_BASE
+
componentName
);
}
}
fixModuleUrl
(
"theme"
,
"solarized_dark"
);
fixModuleUrl
(
"theme"
,
"solarized_dark"
);
fixModuleUrl
(
"ext"
,
"language_tools"
);
let
editorTemplate
=
`
let
editorTemplate
=
`<div></div>`
;
<div class="gf-code-editor"></div>
`
;
function
link
(
scope
,
elem
,
attrs
)
{
function
link
(
scope
,
elem
,
attrs
)
{
let
aceElem
=
elem
.
get
(
0
);
let
aceElem
=
elem
.
get
(
0
);
let
codeEditor
=
ace
.
edit
(
aceElem
);
let
codeEditor
=
ace
.
edit
(
aceElem
);
let
editorSession
=
codeEditor
.
getSession
();
let
editorSession
=
codeEditor
.
getSession
();
codeEditor
.
setTheme
(
"ace/theme/solarized_dark"
);
codeEditor
.
setTheme
(
"ace/theme/solarized_dark"
);
codeEditor
.
setHighlightActiveLine
(
false
);
codeEditor
.
setHighlightActiveLine
(
false
);
codeEditor
.
setShowPrintMargin
(
false
);
codeEditor
.
setShowPrintMargin
(
false
);
// disable depreacation warning
codeEditor
.
$blockScrolling
=
Infinity
;
codeEditor
.
$blockScrolling
=
Infinity
;
setLangMode
();
setLangMode
();
...
@@ -36,7 +41,7 @@ function link(scope, elem, attrs) {
...
@@ -36,7 +41,7 @@ function link(scope, elem, attrs) {
textarea
.
addClass
(
'gf-form-input width-25'
);
textarea
.
addClass
(
'gf-form-input width-25'
);
textarea
.
attr
(
"rows"
,
"4"
);
textarea
.
attr
(
"rows"
,
"4"
);
editorSession
.
on
(
'change'
,
e
=>
{
editorSession
.
on
(
'change'
,
(
e
)
=>
{
scope
.
$apply
(()
=>
{
scope
.
$apply
(()
=>
{
let
newValue
=
codeEditor
.
getValue
();
let
newValue
=
codeEditor
.
getValue
();
scope
.
content
=
newValue
;
scope
.
content
=
newValue
;
...
@@ -47,7 +52,15 @@ function link(scope, elem, attrs) {
...
@@ -47,7 +52,15 @@ function link(scope, elem, attrs) {
let
lang
=
attrs
.
mode
||
'text'
;
let
lang
=
attrs
.
mode
||
'text'
;
let
aceModeName
=
`ace/mode/
${
lang
}
`
;
let
aceModeName
=
`ace/mode/
${
lang
}
`
;
fixModuleUrl
(
"mode"
,
lang
);
fixModuleUrl
(
"mode"
,
lang
);
fixModuleUrl
(
"snippets"
,
lang
);
editorSession
.
setMode
(
aceModeName
);
editorSession
.
setMode
(
aceModeName
);
ace
.
config
.
loadModule
(
"ace/ext/language_tools"
,
(
language_tools
)
=>
{
codeEditor
.
setOptions
({
enableBasicAutocompletion
:
true
,
enableLiveAutocompletion
:
true
,
enableSnippets
:
true
});
});
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment