Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vue-monaco
Project
Project
Details
Activity
Releases
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
vue-monaco
Commits
13de23ce
Commit
13de23ce
authored
Feb 19, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prebuild
parent
9f0d5174
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
301 additions
and
1 deletion
+301
-1
.gitignore
.gitignore
+1
-1
vue-monaco.es.js
dist/vue-monaco.es.js
+138
-0
vue-monaco.js
dist/vue-monaco.js
+162
-0
No files found.
.gitignore
View file @
13de23ce
node_modules
dist/
#
dist/
dist/vue-monaco.es.js
0 → 100644
View file @
13de23ce
import
assign
from
'nano-assign'
;
var
MonacoEditor
=
{
name
:
'MonacoEditor'
,
props
:
{
original
:
String
,
value
:
{
type
:
String
,
required
:
true
},
theme
:
{
type
:
String
,
"default"
:
'vs'
},
language
:
String
,
options
:
Object
,
amdRequire
:
{
type
:
Function
},
diffEditor
:
{
type
:
Boolean
,
"default"
:
false
}
},
model
:
{
event
:
'change'
},
watch
:
{
options
:
{
deep
:
true
,
handler
:
function
handler
(
options
)
{
if
(
this
.
editor
)
{
var
editor
=
this
.
getModifiedEditor
();
editor
.
updateOptions
(
options
);
}
}
},
value
:
function
value
(
newValue
)
{
if
(
this
.
editor
)
{
var
editor
=
this
.
getModifiedEditor
();
if
(
newValue
!==
editor
.
getValue
())
{
editor
.
setValue
(
newValue
);
}
}
},
language
:
function
language
(
newVal
)
{
if
(
this
.
editor
)
{
var
editor
=
this
.
getModifiedEditor
();
this
.
monaco
.
editor
.
setModelLanguage
(
editor
.
getModel
(),
newVal
);
}
},
theme
:
function
theme
(
newVal
)
{
if
(
this
.
editor
)
{
this
.
monaco
.
editor
.
setTheme
(
newVal
);
}
}
},
mounted
:
function
mounted
()
{
var
_this
=
this
;
if
(
this
.
amdRequire
)
{
this
.
amdRequire
([
'vs/editor/editor.main'
],
function
()
{
_this
.
monaco
=
window
.
monaco
;
_this
.
initMonaco
(
window
.
monaco
);
});
}
else
{
// ESM format so it can't be resolved by commonjs `require` in eslint
// eslint-disable-next-line import/no-unresolved
var
monaco
=
require
(
'monaco-editor'
);
this
.
monaco
=
monaco
;
this
.
initMonaco
(
monaco
);
}
},
beforeDestroy
:
function
beforeDestroy
()
{
this
.
editor
&&
this
.
editor
.
dispose
();
},
methods
:
{
initMonaco
:
function
initMonaco
(
monaco
)
{
var
_this2
=
this
;
this
.
$emit
(
'editorWillMount'
,
this
.
monaco
);
var
options
=
assign
({
value
:
this
.
value
,
theme
:
this
.
theme
,
language
:
this
.
language
},
this
.
options
);
if
(
this
.
diffEditor
)
{
this
.
editor
=
monaco
.
editor
.
createDiffEditor
(
this
.
$el
,
options
);
var
originalModel
=
monaco
.
editor
.
createModel
(
this
.
original
,
this
.
language
);
var
modifiedModel
=
monaco
.
editor
.
createModel
(
this
.
value
,
this
.
language
);
this
.
editor
.
setModel
({
original
:
originalModel
,
modified
:
modifiedModel
});
}
else
{
this
.
editor
=
monaco
.
editor
.
create
(
this
.
$el
,
options
);
}
// @event `change`
var
editor
=
this
.
getModifiedEditor
();
editor
.
onDidChangeModelContent
(
function
(
event
)
{
var
value
=
editor
.
getValue
();
if
(
_this2
.
value
!==
value
)
{
_this2
.
$emit
(
'change'
,
value
,
event
);
}
});
this
.
$emit
(
'editorDidMount'
,
this
.
editor
);
},
/** @deprecated */
getMonaco
:
function
getMonaco
()
{
return
this
.
editor
;
},
getEditor
:
function
getEditor
()
{
return
this
.
editor
;
},
getModifiedEditor
:
function
getModifiedEditor
()
{
return
this
.
diffEditor
?
this
.
editor
.
getModifiedEditor
()
:
this
.
editor
;
},
focus
:
function
focus
()
{
this
.
editor
.
focus
();
}
},
render
:
function
render
(
h
)
{
return
h
(
'div'
);
}
};
if
(
typeof
window
!==
'undefined'
&&
window
.
Vue
)
{
window
.
Vue
.
component
(
MonacoEditor
.
name
,
MonacoEditor
);
}
export
default
MonacoEditor
;
dist/vue-monaco.js
0 → 100644
View file @
13de23ce
(
function
(
global
,
factory
)
{
typeof
exports
===
'object'
&&
typeof
module
!==
'undefined'
?
module
.
exports
=
factory
()
:
typeof
define
===
'function'
&&
define
.
amd
?
define
(
factory
)
:
(
global
=
global
||
self
,
global
.
VueMonaco
=
factory
());
}(
this
,
function
()
{
'use strict'
;
/*!
* nano-assign v1.0.1
* (c) 2018-present egoist <0x142857@gmail.com>
* Released under the MIT License.
*/
var
index
=
function
(
obj
)
{
var
arguments
$1
=
arguments
;
for
(
var
i
=
1
;
i
<
arguments
.
length
;
i
++
)
{
// eslint-disable-next-line guard-for-in, prefer-rest-params
for
(
var
p
in
arguments
[
i
])
{
obj
[
p
]
=
arguments
$1
[
i
][
p
];
}
}
return
obj
};
var
nanoAssign_common
=
index
;
var
MonacoEditor
=
{
name
:
'MonacoEditor'
,
props
:
{
original
:
String
,
value
:
{
type
:
String
,
required
:
true
},
theme
:
{
type
:
String
,
"default"
:
'vs'
},
language
:
String
,
options
:
Object
,
amdRequire
:
{
type
:
Function
},
diffEditor
:
{
type
:
Boolean
,
"default"
:
false
}
},
model
:
{
event
:
'change'
},
watch
:
{
options
:
{
deep
:
true
,
handler
:
function
handler
(
options
)
{
if
(
this
.
editor
)
{
var
editor
=
this
.
getModifiedEditor
();
editor
.
updateOptions
(
options
);
}
}
},
value
:
function
value
(
newValue
)
{
if
(
this
.
editor
)
{
var
editor
=
this
.
getModifiedEditor
();
if
(
newValue
!==
editor
.
getValue
())
{
editor
.
setValue
(
newValue
);
}
}
},
language
:
function
language
(
newVal
)
{
if
(
this
.
editor
)
{
var
editor
=
this
.
getModifiedEditor
();
this
.
monaco
.
editor
.
setModelLanguage
(
editor
.
getModel
(),
newVal
);
}
},
theme
:
function
theme
(
newVal
)
{
if
(
this
.
editor
)
{
this
.
monaco
.
editor
.
setTheme
(
newVal
);
}
}
},
mounted
:
function
mounted
()
{
var
_this
=
this
;
if
(
this
.
amdRequire
)
{
this
.
amdRequire
([
'vs/editor/editor.main'
],
function
()
{
_this
.
monaco
=
window
.
monaco
;
_this
.
initMonaco
(
window
.
monaco
);
});
}
else
{
// ESM format so it can't be resolved by commonjs `require` in eslint
// eslint-disable-next-line import/no-unresolved
var
monaco
=
require
(
'monaco-editor'
);
this
.
monaco
=
monaco
;
this
.
initMonaco
(
monaco
);
}
},
beforeDestroy
:
function
beforeDestroy
()
{
this
.
editor
&&
this
.
editor
.
dispose
();
},
methods
:
{
initMonaco
:
function
initMonaco
(
monaco
)
{
var
_this2
=
this
;
this
.
$emit
(
'editorWillMount'
,
this
.
monaco
);
var
options
=
nanoAssign_common
({
value
:
this
.
value
,
theme
:
this
.
theme
,
language
:
this
.
language
},
this
.
options
);
if
(
this
.
diffEditor
)
{
this
.
editor
=
monaco
.
editor
.
createDiffEditor
(
this
.
$el
,
options
);
var
originalModel
=
monaco
.
editor
.
createModel
(
this
.
original
,
this
.
language
);
var
modifiedModel
=
monaco
.
editor
.
createModel
(
this
.
value
,
this
.
language
);
this
.
editor
.
setModel
({
original
:
originalModel
,
modified
:
modifiedModel
});
}
else
{
this
.
editor
=
monaco
.
editor
.
create
(
this
.
$el
,
options
);
}
// @event `change`
var
editor
=
this
.
getModifiedEditor
();
editor
.
onDidChangeModelContent
(
function
(
event
)
{
var
value
=
editor
.
getValue
();
if
(
_this2
.
value
!==
value
)
{
_this2
.
$emit
(
'change'
,
value
,
event
);
}
});
this
.
$emit
(
'editorDidMount'
,
this
.
editor
);
},
/** @deprecated */
getMonaco
:
function
getMonaco
()
{
return
this
.
editor
;
},
getEditor
:
function
getEditor
()
{
return
this
.
editor
;
},
getModifiedEditor
:
function
getModifiedEditor
()
{
return
this
.
diffEditor
?
this
.
editor
.
getModifiedEditor
()
:
this
.
editor
;
},
focus
:
function
focus
()
{
this
.
editor
.
focus
();
}
},
render
:
function
render
(
h
)
{
return
h
(
'div'
);
}
};
if
(
typeof
window
!==
'undefined'
&&
window
.
Vue
)
{
window
.
Vue
.
component
(
MonacoEditor
.
name
,
MonacoEditor
);
}
return
MonacoEditor
;
}));
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