BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
a6a7a0e1
Unverified
Commit
a6a7a0e1
authored
Jul 26, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make RepoEditor an async component to load monaco before mounting
parent
98ad6706
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
25 deletions
+30
-25
index.js
app/assets/javascripts/repo/index.js
+1
-1
repo_editor.js
app/assets/javascripts/repo/repo_editor.js
+27
-23
repo_store.js
app/assets/javascripts/repo/repo_store.js
+1
-0
repo_editor_spec.js
spec/javascripts/repo/repo_editor_spec.js
+1
-1
No files found.
app/assets/javascripts/repo/index.js
View file @
a6a7a0e1
...
...
@@ -9,7 +9,7 @@ import RepoCommitSection from './repo_commit_section.vue';
import
RepoTabs
from
'./repo_tabs.vue'
;
import
RepoFileButtons
from
'./repo_file_buttons.vue'
;
import
RepoBinaryViewer
from
'./repo_binary_viewer.vue'
;
import
RepoEditor
from
'./repo_editor
.vue
'
;
import
RepoEditor
from
'./repo_editor'
;
import
RepoMiniMixin
from
'./repo_mini_mixin'
;
function
initRepo
()
{
...
...
app/assets/javascripts/repo/repo_editor.
vue
→
app/assets/javascripts/repo/repo_editor.
js
View file @
a6a7a0e1
<
script
>
/* global monaco */
import
Store
from
'./repo_store'
;
import
Helper
from
'./repo_helper'
;
...
...
@@ -7,28 +6,28 @@ import monacoLoader from './monaco_loader';
const
RepoEditor
=
{
data
:
()
=>
Store
,
template
:
'<div id="ide"></div>'
,
mounted
()
{
monacoLoader
([
'vs/editor/editor.main'
],
()
=>
{
const
monacoInstance
=
monaco
.
editor
.
create
(
this
.
$el
,
{
model
:
null
,
readOnly
:
true
,
contextmenu
:
false
,
});
const
monacoInstance
=
this
.
monaco
.
editor
.
create
(
this
.
$el
,
{
model
:
null
,
readOnly
:
true
,
contextmenu
:
false
,
});
Store
.
monacoInstance
=
monacoInstance
;
Store
.
monacoInstance
=
monacoInstance
;
this
.
addMonacoEvents
();
this
.
addMonacoEvents
();
Helper
.
getContent
().
then
(()
=>
{
this
.
showHide
();
Helper
.
getContent
().
then
(()
=>
{
this
.
showHide
();
if
(
this
.
blobRaw
===
''
)
return
;
if
(
this
.
blobRaw
===
''
)
return
;
const
newModel
=
monaco
.
editor
.
createModel
(
this
.
blobRaw
,
'plaintext'
);
const
newModel
=
this
.
monaco
.
editor
.
createModel
(
this
.
blobRaw
,
'plaintext'
);
this
.
monacoInstance
.
setModel
(
newModel
);
}).
catch
(
Helper
.
loadingError
);
});
this
.
monacoInstance
.
setModel
(
newModel
);
}).
catch
(
Helper
.
loadingError
);
},
methods
:
{
...
...
@@ -98,18 +97,23 @@ const RepoEditor = {
this
.
monacoInstance
.
setModel
(
null
);
const
languages
=
monaco
.
languages
.
getLanguages
();
const
languages
=
this
.
monaco
.
languages
.
getLanguages
();
const
languageID
=
Helper
.
getLanguageIDForFile
(
this
.
activeFile
,
languages
);
const
newModel
=
monaco
.
editor
.
createModel
(
this
.
blobRaw
,
languageID
);
const
newModel
=
this
.
monaco
.
editor
.
createModel
(
this
.
blobRaw
,
languageID
);
this
.
monacoInstance
.
setModel
(
newModel
);
},
},
};
export
default
RepoEditor
;
</
script
>
function
asyncLoadRepoEditor
()
{
return
new
Promise
((
resolve
)
=>
{
monacoLoader
([
'vs/editor/editor.main'
],
()
=>
{
Store
.
monaco
=
monaco
;
resolve
(
RepoEditor
);
});
});
}
<
template
>
<div
id=
"ide"
></div>
</
template
>
export
default
asyncLoadRepoEditor
;
app/assets/javascripts/repo/repo_store.js
View file @
a6a7a0e1
...
...
@@ -3,6 +3,7 @@ import RepoHelper from './repo_helper';
const
RepoStore
=
{
ideEl
:
{},
monaco
:
{},
monacoInstance
:
{},
service
:
''
,
editor
:
''
,
...
...
spec/javascripts/repo/repo_editor_spec.js
View file @
a6a7a0e1
import
Vue
from
'vue'
;
import
repoEditor
from
'~/repo/repo_editor
.vue
'
;
import
repoEditor
from
'~/repo/repo_editor'
;
describe
(
'RepoEditor'
,
()
=>
{
function
createComponent
()
{
...
...
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