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
9e86809a
Commit
9e86809a
authored
Sep 20, 2018
by
David Kaltschmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explore: remove closing brace with opening brace
parent
0e173918
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
public/app/containers/Explore/slate-plugins/braces.test.ts
+18
-0
public/app/containers/Explore/slate-plugins/braces.ts
+16
-0
No files found.
public/app/containers/Explore/slate-plugins/braces.test.ts
View file @
9e86809a
...
...
@@ -53,4 +53,22 @@ describe('braces', () => {
handler
(
event
,
change
);
expect
(
Plain
.
serialize
(
change
.
value
)).
toEqual
(
'sum(rate(metric{namespace="dev", cluster="c1"}[2m]))'
);
});
it
(
'removes closing brace when opening brace is removed'
,
()
=>
{
const
change
=
Plain
.
deserialize
(
'time()'
).
change
();
let
event
;
change
.
move
(
5
);
event
=
new
window
.
KeyboardEvent
(
'keydown'
,
{
key
:
'Backspace'
});
handler
(
event
,
change
);
expect
(
Plain
.
serialize
(
change
.
value
)).
toEqual
(
'time'
);
});
it
(
'keeps closing brace when opening brace is removed and inner values exist'
,
()
=>
{
const
change
=
Plain
.
deserialize
(
'time(value)'
).
change
();
let
event
;
change
.
move
(
5
);
event
=
new
window
.
KeyboardEvent
(
'keydown'
,
{
key
:
'Backspace'
});
const
handled
=
handler
(
event
,
change
);
expect
(
handled
).
toBeFalsy
();
});
});
public/app/containers/Explore/slate-plugins/braces.ts
View file @
9e86809a
...
...
@@ -43,6 +43,22 @@ export default function BracesPlugin() {
return
true
;
}
case
'Backspace'
:
{
const
text
=
value
.
anchorText
.
text
;
const
offset
=
value
.
anchorOffset
;
const
previousChar
=
text
[
offset
-
1
];
const
nextChar
=
text
[
offset
];
if
(
BRACES
[
previousChar
]
&&
BRACES
[
previousChar
]
===
nextChar
)
{
event
.
preventDefault
();
// Remove closing brace if directly following
change
.
deleteBackward
()
.
deleteForward
()
.
focus
();
return
true
;
}
}
default
:
{
break
;
}
...
...
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