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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
4653820d
Commit
4653820d
authored
Jun 08, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor monaco-editor import and stop storing as class property within editor
parent
204d78e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
17 deletions
+16
-17
app/assets/javascripts/ide/lib/editor.js
app/assets/javascripts/ide/lib/editor.js
+11
-13
spec/javascripts/ide/lib/editor_spec.js
spec/javascripts/ide/lib/editor_spec.js
+5
-4
No files found.
app/assets/javascripts/ide/lib/editor.js
View file @
4653820d
import
_
from
'
underscore
'
;
import
*
as
monaco
from
'
monaco-editor
'
;
import
{
editor
as
monacoEditor
,
KeyCode
,
KeyMod
}
from
'
monaco-editor
'
;
import
store
from
'
../stores
'
;
import
DecorationsController
from
'
./decorations/controller
'
;
import
DirtyDiffController
from
'
./diff/controller
'
;
...
...
@@ -9,6 +9,11 @@ import editorOptions, { defaultEditorOptions } from './editor_options';
import
gitlabTheme
from
'
./themes/gl_theme
'
;
import
keymap
from
'
./keymap.json
'
;
function
setupMonacoTheme
()
{
monacoEditor
.
defineTheme
(
gitlabTheme
.
themeName
,
gitlabTheme
.
monacoTheme
);
monacoEditor
.
setTheme
(
'
gitlab
'
);
}
export
const
clearDomElement
=
el
=>
{
if
(
!
el
||
!
el
.
firstChild
)
return
;
...
...
@@ -26,7 +31,6 @@ export default class Editor {
}
constructor
()
{
this
.
monaco
=
monaco
;
this
.
currentModel
=
null
;
this
.
instance
=
null
;
this
.
dirtyDiffController
=
null
;
...
...
@@ -34,7 +38,7 @@ export default class Editor {
this
.
modelManager
=
new
ModelManager
();
this
.
decorationsController
=
new
DecorationsController
(
this
);
this
.
setupMonacoTheme
();
setupMonacoTheme
();
this
.
debouncedUpdate
=
_
.
debounce
(()
=>
{
this
.
updateDimensions
();
...
...
@@ -46,7 +50,7 @@ export default class Editor {
clearDomElement
(
domElement
);
this
.
disposable
.
add
(
(
this
.
instance
=
this
.
monaco
.
e
ditor
.
create
(
domElement
,
{
(
this
.
instance
=
monacoE
ditor
.
create
(
domElement
,
{
...
defaultEditorOptions
,
})),
(
this
.
dirtyDiffController
=
new
DirtyDiffController
(
...
...
@@ -66,7 +70,7 @@ export default class Editor {
clearDomElement
(
domElement
);
this
.
disposable
.
add
(
(
this
.
instance
=
this
.
monaco
.
e
ditor
.
createDiffEditor
(
domElement
,
{
(
this
.
instance
=
monacoE
ditor
.
createDiffEditor
(
domElement
,
{
...
defaultEditorOptions
,
quickSuggestions
:
false
,
occurrencesHighlight
:
false
,
...
...
@@ -122,17 +126,11 @@ export default class Editor {
modified
:
model
.
getModel
(),
});
this
.
monaco
.
e
ditor
.
createDiffNavigator
(
this
.
instance
,
{
monacoE
ditor
.
createDiffNavigator
(
this
.
instance
,
{
alwaysRevealFirst
:
true
,
});
}
setupMonacoTheme
()
{
this
.
monaco
.
editor
.
defineTheme
(
gitlabTheme
.
themeName
,
gitlabTheme
.
monacoTheme
);
this
.
monaco
.
editor
.
setTheme
(
'
gitlab
'
);
}
clearEditor
()
{
if
(
this
.
instance
)
{
this
.
instance
.
setModel
(
null
);
...
...
@@ -200,7 +198,7 @@ export default class Editor {
const
getKeyCode
=
key
=>
{
const
monacoKeyMod
=
key
.
indexOf
(
'
KEY_
'
)
===
0
;
return
monacoKeyMod
?
this
.
monaco
.
KeyCode
[
key
]
:
this
.
monaco
.
KeyMod
[
key
];
return
monacoKeyMod
?
KeyCode
[
key
]
:
KeyMod
[
key
];
};
keymap
.
forEach
(
command
=>
{
...
...
spec/javascripts/ide/lib/editor_spec.js
View file @
4653820d
import
{
editor
as
monacoEditor
}
from
'
monaco-editor
'
;
import
Editor
from
'
~/ide/lib/editor
'
;
import
{
file
}
from
'
../helpers
'
;
...
...
@@ -32,11 +33,11 @@ describe('Multi-file editor library', () => {
describe
(
'
createInstance
'
,
()
=>
{
it
(
'
creates editor instance
'
,
()
=>
{
spyOn
(
instance
.
monaco
.
e
ditor
,
'
create
'
).
and
.
callThrough
();
spyOn
(
monacoE
ditor
,
'
create
'
).
and
.
callThrough
();
instance
.
createInstance
(
holder
);
expect
(
instance
.
monaco
.
e
ditor
.
create
).
toHaveBeenCalled
();
expect
(
monacoE
ditor
.
create
).
toHaveBeenCalled
();
});
it
(
'
creates dirty diff controller
'
,
()
=>
{
...
...
@@ -54,11 +55,11 @@ describe('Multi-file editor library', () => {
describe
(
'
createDiffInstance
'
,
()
=>
{
it
(
'
creates editor instance
'
,
()
=>
{
spyOn
(
instance
.
monaco
.
e
ditor
,
'
createDiffEditor
'
).
and
.
callThrough
();
spyOn
(
monacoE
ditor
,
'
createDiffEditor
'
).
and
.
callThrough
();
instance
.
createDiffInstance
(
holder
);
expect
(
instance
.
monaco
.
e
ditor
.
createDiffEditor
).
toHaveBeenCalledWith
(
holder
,
{
expect
(
monacoE
ditor
.
createDiffEditor
).
toHaveBeenCalledWith
(
holder
,
{
model
:
null
,
contextmenu
:
true
,
minimap
:
{
...
...
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