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
Boxiang Sun
gitlab-ce
Commits
2729205b
Commit
2729205b
authored
Jun 07, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove monacoLoader and import monaco directly within Editor class
parent
fd400b3b
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
42 additions
and
106 deletions
+42
-106
app/assets/javascripts/ide/components/repo_editor.vue
app/assets/javascripts/ide/components/repo_editor.vue
+3
-6
app/assets/javascripts/ide/lib/diff/controller.js
app/assets/javascripts/ide/lib/diff/controller.js
+2
-2
app/assets/javascripts/ide/lib/editor.js
app/assets/javascripts/ide/lib/editor.js
+6
-6
app/assets/javascripts/ide/monaco_loader.js
app/assets/javascripts/ide/monaco_loader.js
+0
-16
spec/javascripts/ide/components/repo_editor_spec.js
spec/javascripts/ide/components/repo_editor_spec.js
+1
-5
spec/javascripts/ide/lib/common/model_manager_spec.js
spec/javascripts/ide/lib/common/model_manager_spec.js
+3
-8
spec/javascripts/ide/lib/common/model_spec.js
spec/javascripts/ide/lib/common/model_spec.js
+6
-11
spec/javascripts/ide/lib/decorations/controller_spec.js
spec/javascripts/ide/lib/decorations/controller_spec.js
+7
-12
spec/javascripts/ide/lib/diff/controller_spec.js
spec/javascripts/ide/lib/diff/controller_spec.js
+9
-14
spec/javascripts/ide/lib/editor_spec.js
spec/javascripts/ide/lib/editor_spec.js
+5
-11
spec/javascripts/ide/monaco_loader_spec.js
spec/javascripts/ide/monaco_loader_spec.js
+0
-15
No files found.
app/assets/javascripts/ide/components/repo_editor.vue
View file @
2729205b
<
script
>
<
script
>
import
{
mapState
,
mapGetters
,
mapActions
}
from
'
vuex
'
;
import
{
mapState
,
mapGetters
,
mapActions
}
from
'
vuex
'
;
import
*
as
monaco
from
'
monaco-editor
'
;
import
flash
from
'
~/flash
'
;
import
flash
from
'
~/flash
'
;
import
ContentViewer
from
'
~/vue_shared/components/content_viewer/content_viewer.vue
'
;
import
ContentViewer
from
'
~/vue_shared/components/content_viewer/content_viewer.vue
'
;
import
{
activityBarViews
,
viewerTypes
}
from
'
../constants
'
;
import
{
activityBarViews
,
viewerTypes
}
from
'
../constants
'
;
...
@@ -83,12 +82,10 @@ export default {
...
@@ -83,12 +82,10 @@ export default {
this
.
editor
.
dispose
();
this
.
editor
.
dispose
();
},
},
mounted
()
{
mounted
()
{
if
(
this
.
editor
&&
monaco
)
{
if
(
!
this
.
editor
)
{
this
.
initMonaco
();
this
.
editor
=
Editor
.
create
();
}
else
{
this
.
editor
=
Editor
.
create
(
monaco
);
this
.
initMonaco
();
}
}
this
.
initMonaco
();
},
},
methods
:
{
methods
:
{
...
mapActions
([
...
mapActions
([
...
...
app/assets/javascripts/ide/lib/diff/controller.js
View file @
2729205b
/* global monaco */
import
{
Range
}
from
'
monaco-editor
'
;
import
{
throttle
}
from
'
underscore
'
;
import
{
throttle
}
from
'
underscore
'
;
import
DirtyDiffWorker
from
'
./diff_worker
'
;
import
DirtyDiffWorker
from
'
./diff_worker
'
;
import
Disposable
from
'
../common/disposable
'
;
import
Disposable
from
'
../common/disposable
'
;
...
@@ -16,7 +16,7 @@ export const getDiffChangeType = change => {
...
@@ -16,7 +16,7 @@ export const getDiffChangeType = change => {
};
};
export
const
getDecorator
=
change
=>
({
export
const
getDecorator
=
change
=>
({
range
:
new
monaco
.
Range
(
change
.
lineNumber
,
1
,
change
.
endLineNumber
,
1
),
range
:
new
Range
(
change
.
lineNumber
,
1
,
change
.
endLineNumber
,
1
),
options
:
{
options
:
{
isWholeLine
:
true
,
isWholeLine
:
true
,
linesDecorationsClassName
:
`dirty-diff dirty-diff-
${
getDiffChangeType
(
change
)}
`
,
linesDecorationsClassName
:
`dirty-diff dirty-diff-
${
getDiffChangeType
(
change
)}
`
,
...
...
app/assets/javascripts/ide/lib/editor.js
View file @
2729205b
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
*
as
monaco
from
'
monaco-editor
'
;
import
store
from
'
../stores
'
;
import
store
from
'
../stores
'
;
import
DecorationsController
from
'
./decorations/controller
'
;
import
DecorationsController
from
'
./decorations/controller
'
;
import
DirtyDiffController
from
'
./diff/controller
'
;
import
DirtyDiffController
from
'
./diff/controller
'
;
...
@@ -17,15 +18,14 @@ export const clearDomElement = el => {
...
@@ -17,15 +18,14 @@ export const clearDomElement = el => {
};
};
export
default
class
Editor
{
export
default
class
Editor
{
static
create
(
monaco
)
{
static
create
()
{
if
(
this
.
editorInstance
)
return
this
.
editorInstance
;
if
(
!
this
.
editorInstance
)
{
this
.
editorInstance
=
new
Editor
();
this
.
editorInstance
=
new
Editor
(
monaco
);
}
return
this
.
editorInstance
;
return
this
.
editorInstance
;
}
}
constructor
(
monaco
)
{
constructor
()
{
this
.
monaco
=
monaco
;
this
.
monaco
=
monaco
;
this
.
currentModel
=
null
;
this
.
currentModel
=
null
;
this
.
instance
=
null
;
this
.
instance
=
null
;
...
...
app/assets/javascripts/ide/monaco_loader.js
deleted
100644 → 0
View file @
fd400b3b
import
monacoContext
from
'
monaco-editor/dev/vs/loader
'
;
monacoContext
.
require
.
config
({
paths
:
{
vs
:
`
${
__webpack_public_path__
}
monaco-editor/vs`
,
// eslint-disable-line camelcase
},
});
// ignore CDN config and use local assets path for service worker which cannot be cross-domain
const
relativeRootPath
=
(
gon
&&
gon
.
relative_url_root
)
||
''
;
const
monacoPath
=
`
${
relativeRootPath
}
/assets/webpack/monaco-editor/vs`
;
window
.
MonacoEnvironment
=
{
getWorkerUrl
:
()
=>
`
${
monacoPath
}
/base/worker/workerMain.js`
};
// eslint-disable-next-line no-underscore-dangle
window
.
__monaco_context__
=
monacoContext
;
export
default
monacoContext
.
require
;
spec/javascripts/ide/components/repo_editor_spec.js
View file @
2729205b
...
@@ -3,7 +3,6 @@ import MockAdapter from 'axios-mock-adapter';
...
@@ -3,7 +3,6 @@ import MockAdapter from 'axios-mock-adapter';
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
store
from
'
~/ide/stores
'
;
import
store
from
'
~/ide/stores
'
;
import
repoEditor
from
'
~/ide/components/repo_editor.vue
'
;
import
repoEditor
from
'
~/ide/components/repo_editor.vue
'
;
import
monacoLoader
from
'
~/ide/monaco_loader
'
;
import
Editor
from
'
~/ide/lib/editor
'
;
import
Editor
from
'
~/ide/lib/editor
'
;
import
{
activityBarViews
}
from
'
~/ide/constants
'
;
import
{
activityBarViews
}
from
'
~/ide/constants
'
;
import
{
createComponentWithStore
}
from
'
../../helpers/vue_mount_component_helper
'
;
import
{
createComponentWithStore
}
from
'
../../helpers/vue_mount_component_helper
'
;
...
@@ -25,13 +24,10 @@ describe('RepoEditor', () => {
...
@@ -25,13 +24,10 @@ describe('RepoEditor', () => {
f
.
tempFile
=
true
;
f
.
tempFile
=
true
;
vm
.
$store
.
state
.
openFiles
.
push
(
f
);
vm
.
$store
.
state
.
openFiles
.
push
(
f
);
Vue
.
set
(
vm
.
$store
.
state
.
entries
,
f
.
path
,
f
);
Vue
.
set
(
vm
.
$store
.
state
.
entries
,
f
.
path
,
f
);
vm
.
monaco
=
true
;
vm
.
$mount
();
vm
.
$mount
();
monacoLoader
([
'
vs/editor/editor.main
'
],
()
=>
{
Vue
.
nextTick
(()
=>
setTimeout
(
done
));
setTimeout
(
done
,
0
);
});
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
...
spec/javascripts/ide/lib/common/model_manager_spec.js
View file @
2729205b
/* global monaco */
import
*
as
monaco
from
'
monaco-editor
'
;
import
eventHub
from
'
~/ide/eventhub
'
;
import
eventHub
from
'
~/ide/eventhub
'
;
import
monacoLoader
from
'
~/ide/monaco_loader
'
;
import
ModelManager
from
'
~/ide/lib/common/model_manager
'
;
import
ModelManager
from
'
~/ide/lib/common/model_manager
'
;
import
{
file
}
from
'
../../helpers
'
;
import
{
file
}
from
'
../../helpers
'
;
describe
(
'
Multi-file editor library model manager
'
,
()
=>
{
describe
(
'
Multi-file editor library model manager
'
,
()
=>
{
let
instance
;
let
instance
;
beforeEach
(
done
=>
{
beforeEach
(()
=>
{
monacoLoader
([
'
vs/editor/editor.main
'
],
()
=>
{
instance
=
new
ModelManager
(
monaco
);
instance
=
new
ModelManager
(
monaco
);
done
();
});
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
...
spec/javascripts/ide/lib/common/model_spec.js
View file @
2729205b
/* global monaco */
import
*
as
monaco
from
'
monaco-editor
'
;
import
eventHub
from
'
~/ide/eventhub
'
;
import
eventHub
from
'
~/ide/eventhub
'
;
import
monacoLoader
from
'
~/ide/monaco_loader
'
;
import
Model
from
'
~/ide/lib/common/model
'
;
import
Model
from
'
~/ide/lib/common/model
'
;
import
{
file
}
from
'
../../helpers
'
;
import
{
file
}
from
'
../../helpers
'
;
describe
(
'
Multi-file editor library model
'
,
()
=>
{
describe
(
'
Multi-file editor library model
'
,
()
=>
{
let
model
;
let
model
;
beforeEach
(
done
=>
{
beforeEach
(
()
=>
{
spyOn
(
eventHub
,
'
$on
'
).
and
.
callThrough
();
spyOn
(
eventHub
,
'
$on
'
).
and
.
callThrough
();
monacoLoader
([
'
vs/editor/editor.main
'
],
()
=>
{
const
f
=
file
(
'
path
'
);
const
f
=
file
(
'
path
'
);
f
.
mrChange
=
{
diff
:
'
ABC
'
};
f
.
mrChange
=
{
diff
:
'
ABC
'
};
f
.
baseRaw
=
'
test
'
;
f
.
baseRaw
=
'
test
'
;
model
=
new
Model
(
monaco
,
f
);
model
=
new
Model
(
monaco
,
f
);
done
();
});
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
...
spec/javascripts/ide/lib/decorations/controller_spec.js
View file @
2729205b
/* global monaco */
import
*
as
monaco
from
'
monaco-editor
'
;
import
monacoLoader
from
'
~/ide/monaco_loader
'
;
import
Editor
from
'
~/ide/lib/editor
'
;
import
editor
from
'
~/ide/lib/editor
'
;
import
DecorationsController
from
'
~/ide/lib/decorations/controller
'
;
import
DecorationsController
from
'
~/ide/lib/decorations/controller
'
;
import
Model
from
'
~/ide/lib/common/model
'
;
import
Model
from
'
~/ide/lib/common/model
'
;
import
{
file
}
from
'
../../helpers
'
;
import
{
file
}
from
'
../../helpers
'
;
...
@@ -10,16 +9,12 @@ describe('Multi-file editor library decorations controller', () => {
...
@@ -10,16 +9,12 @@ describe('Multi-file editor library decorations controller', () => {
let
controller
;
let
controller
;
let
model
;
let
model
;
beforeEach
(
done
=>
{
beforeEach
(()
=>
{
monacoLoader
([
'
vs/editor/editor.main
'
],
()
=>
{
editorInstance
=
Editor
.
create
();
editorInstance
=
editor
.
create
(
monaco
);
editorInstance
.
createInstance
(
document
.
createElement
(
'
div
'
));
editorInstance
.
createInstance
(
document
.
createElement
(
'
div
'
));
controller
=
new
DecorationsController
(
editorInstance
);
controller
=
new
DecorationsController
(
editorInstance
);
model
=
new
Model
(
monaco
,
file
(
'
path
'
));
model
=
new
Model
(
monaco
,
file
(
'
path
'
));
done
();
});
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
...
spec/javascripts/ide/lib/diff/controller_spec.js
View file @
2729205b
/* global monaco */
import
*
as
monaco
from
'
monaco-editor
'
;
import
monacoLoader
from
'
~/ide/monaco_loader
'
;
import
Editor
from
'
~/ide/lib/editor
'
;
import
editor
from
'
~/ide/lib/editor
'
;
import
ModelManager
from
'
~/ide/lib/common/model_manager
'
;
import
ModelManager
from
'
~/ide/lib/common/model_manager
'
;
import
DecorationsController
from
'
~/ide/lib/decorations/controller
'
;
import
DecorationsController
from
'
~/ide/lib/decorations/controller
'
;
import
DirtyDiffController
,
{
getDiffChangeType
,
getDecorator
}
from
'
~/ide/lib/diff/controller
'
;
import
DirtyDiffController
,
{
getDiffChangeType
,
getDecorator
}
from
'
~/ide/lib/diff/controller
'
;
...
@@ -14,20 +13,16 @@ describe('Multi-file editor library dirty diff controller', () => {
...
@@ -14,20 +13,16 @@ describe('Multi-file editor library dirty diff controller', () => {
let
decorationsController
;
let
decorationsController
;
let
model
;
let
model
;
beforeEach
(
done
=>
{
beforeEach
(()
=>
{
monacoLoader
([
'
vs/editor/editor.main
'
],
()
=>
{
editorInstance
=
Editor
.
create
();
editorInstance
=
editor
.
create
(
monaco
);
editorInstance
.
createInstance
(
document
.
createElement
(
'
div
'
));
editorInstance
.
createInstance
(
document
.
createElement
(
'
div
'
));
modelManager
=
new
ModelManager
(
monaco
);
modelManager
=
new
ModelManager
(
monaco
);
decorationsController
=
new
DecorationsController
(
editorInstance
);
decorationsController
=
new
DecorationsController
(
editorInstance
);
model
=
modelManager
.
addModel
(
file
(
'
path
'
));
model
=
modelManager
.
addModel
(
file
(
'
path
'
));
controller
=
new
DirtyDiffController
(
modelManager
,
decorationsController
);
controller
=
new
DirtyDiffController
(
modelManager
,
decorationsController
);
done
();
});
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
...
spec/javascripts/ide/lib/editor_spec.js
View file @
2729205b
/* global monaco */
import
Editor
from
'
~/ide/lib/editor
'
;
import
monacoLoader
from
'
~/ide/monaco_loader
'
;
import
editor
from
'
~/ide/lib/editor
'
;
import
{
file
}
from
'
../helpers
'
;
import
{
file
}
from
'
../helpers
'
;
describe
(
'
Multi-file editor library
'
,
()
=>
{
describe
(
'
Multi-file editor library
'
,
()
=>
{
...
@@ -8,18 +6,14 @@ describe('Multi-file editor library', () => {
...
@@ -8,18 +6,14 @@ describe('Multi-file editor library', () => {
let
el
;
let
el
;
let
holder
;
let
holder
;
beforeEach
(
done
=>
{
beforeEach
(
()
=>
{
el
=
document
.
createElement
(
'
div
'
);
el
=
document
.
createElement
(
'
div
'
);
holder
=
document
.
createElement
(
'
div
'
);
holder
=
document
.
createElement
(
'
div
'
);
el
.
appendChild
(
holder
);
el
.
appendChild
(
holder
);
document
.
body
.
appendChild
(
el
);
document
.
body
.
appendChild
(
el
);
monacoLoader
([
'
vs/editor/editor.main
'
],
()
=>
{
instance
=
Editor
.
create
();
instance
=
editor
.
create
(
monaco
);
done
();
});
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
@@ -29,11 +23,11 @@ describe('Multi-file editor library', () => {
...
@@ -29,11 +23,11 @@ describe('Multi-file editor library', () => {
});
});
it
(
'
creates instance of editor
'
,
()
=>
{
it
(
'
creates instance of editor
'
,
()
=>
{
expect
(
e
ditor
.
editorInstance
).
not
.
toBeNull
();
expect
(
E
ditor
.
editorInstance
).
not
.
toBeNull
();
});
});
it
(
'
creates instance returns cached instance
'
,
()
=>
{
it
(
'
creates instance returns cached instance
'
,
()
=>
{
expect
(
editor
.
create
(
monaco
)).
toEqual
(
instance
);
expect
(
Editor
.
create
(
)).
toEqual
(
instance
);
});
});
describe
(
'
createInstance
'
,
()
=>
{
describe
(
'
createInstance
'
,
()
=>
{
...
...
spec/javascripts/ide/monaco_loader_spec.js
deleted
100644 → 0
View file @
fd400b3b
import
monacoContext
from
'
monaco-editor/dev/vs/loader
'
;
import
monacoLoader
from
'
~/ide/monaco_loader
'
;
describe
(
'
MonacoLoader
'
,
()
=>
{
it
(
'
calls require.config and exports require
'
,
()
=>
{
expect
(
monacoContext
.
require
.
getConfig
()).
toEqual
(
jasmine
.
objectContaining
({
paths
:
{
vs
:
`
${
__webpack_public_path__
}
monaco-editor/vs`
,
// eslint-disable-line camelcase
},
}),
);
expect
(
monacoLoader
).
toBe
(
monacoContext
.
require
);
});
});
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