-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fixes #3 Support multiple editor instances * Add typescribe library support * Use theme if set initially
- Loading branch information
1 parent
bd6c398
commit 3fd6ece
Showing
5 changed files
with
269 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes"> | ||
|
||
<title>monaco-editor demo</title> | ||
|
||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script> | ||
|
||
<link rel="import" href="../../polymer/lib/elements/dom-bind.html"> | ||
<link rel="import" href="../../polymer/lib/utils/import-href.html"> | ||
<link rel="import" href="../../polymer/lib/elements/custom-style.html"> | ||
<link rel="import" href="../../iron-flex-layout/iron-flex-layout-classes.html"> | ||
|
||
<link rel="import" href="multiple-editors.html"> | ||
|
||
<custom-style> | ||
<style is="custom-style" include="iron-flex iron-flex-alignment"> | ||
body { | ||
padding: 5px; | ||
margin: 0px; | ||
font-family: verdana; | ||
} | ||
|
||
monaco-editor { | ||
height: 90vh; | ||
width: 100%; | ||
min-width: 520px; | ||
min-height: 400px; | ||
} | ||
|
||
.error { | ||
font-size: 0.7em; | ||
color: #E91E63; | ||
} | ||
|
||
button { | ||
background-color: #4CAF50; | ||
border: none; | ||
color: white; | ||
margin: 3px; | ||
padding: 5px 15px; | ||
text-align: center; | ||
text-decoration: none; | ||
display: inline-block; | ||
font-size: 12px; | ||
} | ||
button.off { | ||
background-color: #888; | ||
} | ||
|
||
</style> | ||
</custom-style> | ||
</head> | ||
|
||
<body> | ||
|
||
<dom-bind id="demo"> | ||
<template> | ||
<multiple-editors></multiple-editors> | ||
</template> | ||
</dom-bind> | ||
|
||
<script> | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<link rel="import" href="../../polymer/polymer-element.html"> | ||
<link rel="import" href="../../paper-button/paper-button.html"> | ||
<link rel="import" href="../monaco-editor.html"> | ||
<link rel="import" href="../monaco-schemas.html"> | ||
<dom-module id="multiple-editors"> | ||
<template> | ||
<monaco-editor | ||
folding | ||
minimap | ||
id="monacoeditor1" | ||
name="editor" | ||
theme="vs-dark" | ||
language="typescript" | ||
value="{{_content1}}"></monaco-editor> | ||
<monaco-editor | ||
id="monacoeditor2" | ||
folding | ||
minimap | ||
name="editor" | ||
theme="vs-dark" | ||
language="typescript" | ||
value="{{_content2}}"></monaco-editor> | ||
</template> | ||
|
||
<script> | ||
class MultipleEditors extends Polymer.Element { | ||
|
||
static get is() { | ||
return 'multiple-editors'; | ||
} | ||
|
||
static get properties() { | ||
return { | ||
_content1: { | ||
type: String, | ||
value: 'Hello World', | ||
observer: '_onContent1Changed' | ||
}, | ||
|
||
_content2: { | ||
type: String, | ||
value: 'Hello Moon', | ||
observer: '_onContent2Changed' | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Called every time the element is inserted into the DOM. Useful for | ||
* running setup code, such as fetching resources or rendering. | ||
* Generally, you should try to delay work until this time. | ||
*/ | ||
connectedCallback() { | ||
super.connectedCallback(); | ||
setTimeout(()=> { | ||
this.$.monacoeditor2.monaco.editor.addTypeScriptLibs([ | ||
{url : 'https://cdn.rawgit.com/Microsoft/TypeScript/64b3086f/lib/lib.es6.d.ts', name : 'es6.d.ts'} | ||
]) | ||
}, 100) | ||
} | ||
|
||
_onContent1Changed() { | ||
console.log(`Content 1 changed: ${this._content1}`); | ||
} | ||
|
||
_onContent2Changed() { | ||
console.log(`Content 2 changed: ${this._content2}`); | ||
} | ||
} | ||
|
||
customElements.define(MultipleEditors.is, MultipleEditors); | ||
</script> | ||
</dom-module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,9 @@ | |
width: 100%; | ||
height: 100%; | ||
} | ||
html,body { | ||
margin : 0px; | ||
} | ||
</style> | ||
</head> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters