Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
4653820d
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
4653820d
编写于
6月 08, 2018
作者:
M
Mike Greiling
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor monaco-editor import and stop storing as class property within editor
上级
204d78e7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
17 deletion
+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
未找到文件。
app/assets/javascripts/ide/lib/editor.js
浏览文件 @
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
浏览文件 @
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
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录