Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a3566506
Commit
a3566506
authored
Apr 12, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added keymap to editor to open file finder
clear file finder on close esc closes the file finder
parent
ba4dde7c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
2 deletions
+56
-2
app/assets/javascripts/ide/components/file_finder/index.vue
app/assets/javascripts/ide/components/file_finder/index.vue
+12
-1
app/assets/javascripts/ide/components/ide.vue
app/assets/javascripts/ide/components/ide.vue
+1
-1
app/assets/javascripts/ide/lib/editor.js
app/assets/javascripts/ide/lib/editor.js
+32
-0
app/assets/javascripts/ide/lib/keymap.json
app/assets/javascripts/ide/lib/keymap.json
+11
-0
No files found.
app/assets/javascripts/ide/components/file_finder/index.vue
View file @
a3566506
...
@@ -45,7 +45,14 @@ export default {
...
@@ -45,7 +45,14 @@ export default {
},
},
watch
:
{
watch
:
{
fileFindVisible
()
{
fileFindVisible
()
{
this
.
$nextTick
(()
=>
this
.
$refs
.
searchInput
.
focus
());
this
.
$nextTick
(()
=>
{
if
(
!
this
.
fileFindVisible
)
{
this
.
searchText
=
''
;
this
.
focusedIndex
=
0
;
}
else
{
this
.
$refs
.
searchInput
.
focus
();
}
});
},
},
searchText
()
{
searchText
()
{
if
(
this
.
searchText
.
trim
()
!==
''
)
{
if
(
this
.
searchText
.
trim
()
!==
''
)
{
...
@@ -77,6 +84,10 @@ export default {
...
@@ -77,6 +84,10 @@ export default {
// ENTER
// ENTER
this
.
openFile
(
this
.
filteredBlobs
[
this
.
focusedIndex
]);
this
.
openFile
(
this
.
filteredBlobs
[
this
.
focusedIndex
]);
break
;
break
;
case
27
:
// ESC
this
.
toggleFileFinder
(
false
);
break
;
default
:
default
:
break
;
break
;
}
}
...
...
app/assets/javascripts/ide/components/ide.vue
View file @
a3566506
...
@@ -52,7 +52,7 @@ export default {
...
@@ -52,7 +52,7 @@ export default {
return
returnValue
;
return
returnValue
;
};
};
Mousetrap
.
bind
(
'
t
'
,
e
=>
{
Mousetrap
.
bind
(
[
'
t
'
,
'
command+p
'
,
'
ctrl+p
'
]
,
e
=>
{
e
.
preventDefault
();
e
.
preventDefault
();
this
.
toggleFileFinder
(
true
);
this
.
toggleFileFinder
(
true
);
});
});
...
...
app/assets/javascripts/ide/lib/editor.js
View file @
a3566506
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
store
from
'
../stores
'
;
import
DecorationsController
from
'
./decorations/controller
'
;
import
DecorationsController
from
'
./decorations/controller
'
;
import
DirtyDiffController
from
'
./diff/controller
'
;
import
DirtyDiffController
from
'
./diff/controller
'
;
import
Disposable
from
'
./common/disposable
'
;
import
Disposable
from
'
./common/disposable
'
;
import
ModelManager
from
'
./common/model_manager
'
;
import
ModelManager
from
'
./common/model_manager
'
;
import
editorOptions
,
{
defaultEditorOptions
}
from
'
./editor_options
'
;
import
editorOptions
,
{
defaultEditorOptions
}
from
'
./editor_options
'
;
import
gitlabTheme
from
'
./themes/gl_theme
'
;
import
gitlabTheme
from
'
./themes/gl_theme
'
;
import
keymap
from
'
./keymap.json
'
;
export
const
clearDomElement
=
el
=>
{
export
const
clearDomElement
=
el
=>
{
if
(
!
el
||
!
el
.
firstChild
)
return
;
if
(
!
el
||
!
el
.
firstChild
)
return
;
...
@@ -53,6 +55,8 @@ export default class Editor {
...
@@ -53,6 +55,8 @@ export default class Editor {
)),
)),
);
);
this
.
addCommands
();
window
.
addEventListener
(
'
resize
'
,
this
.
debouncedUpdate
,
false
);
window
.
addEventListener
(
'
resize
'
,
this
.
debouncedUpdate
,
false
);
}
}
}
}
...
@@ -73,6 +77,8 @@ export default class Editor {
...
@@ -73,6 +77,8 @@ export default class Editor {
})),
})),
);
);
this
.
addCommands
();
window
.
addEventListener
(
'
resize
'
,
this
.
debouncedUpdate
,
false
);
window
.
addEventListener
(
'
resize
'
,
this
.
debouncedUpdate
,
false
);
}
}
}
}
...
@@ -189,4 +195,30 @@ export default class Editor {
...
@@ -189,4 +195,30 @@ export default class Editor {
static
renderSideBySide
(
domElement
)
{
static
renderSideBySide
(
domElement
)
{
return
domElement
.
offsetWidth
>=
700
;
return
domElement
.
offsetWidth
>=
700
;
}
}
addCommands
()
{
const
getKeyCode
=
key
=>
{
const
monacoKeyMod
=
key
.
indexOf
(
'
KEY_
'
)
===
0
;
return
monacoKeyMod
?
monaco
.
KeyCode
[
key
]
:
monaco
.
KeyMod
[
key
];
};
keymap
.
forEach
(
command
=>
{
const
keybindings
=
command
.
bindings
.
map
(
binding
=>
{
const
keys
=
binding
.
split
(
'
+
'
);
return
keys
.
length
>
1
?
getKeyCode
(
keys
[
0
])
|
getKeyCode
(
keys
[
1
])
:
getKeyCode
(
keys
[
0
]);
});
this
.
instance
.
addAction
({
id
:
command
.
id
,
label
:
command
.
label
,
keybindings
,
run
()
{
store
.
dispatch
(
command
.
action
.
name
,
command
.
action
.
params
);
return
null
;
},
});
});
}
}
}
app/assets/javascripts/ide/lib/keymap.json
0 → 100644
View file @
a3566506
[
{
"id"
:
"file-finder"
,
"label"
:
"File finder"
,
"bindings"
:
[
"CtrlCmd+KEY_P"
],
"action"
:
{
"name"
:
"toggleFileFinder"
,
"params"
:
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