enigmatic 0.9.7 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/elements/monaco-editor.mjs +32 -0
- package/main.js +16 -2
- package/package.json +1 -4
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class MonacoEditor extends HTMLElement {
|
|
2
|
+
async connectedCallback() {
|
|
3
|
+
await load('//unpkg.com/monaco-editor@0.30.1/min/vs/loader.js')
|
|
4
|
+
this.innerHTML = `<div id="m-container" style="${this.getAttribute('estyle')}"></div>`
|
|
5
|
+
require.config({ paths: { vs: 'min/vs' } })
|
|
6
|
+
const id = this.getAttribute('id'), that = this
|
|
7
|
+
require(['vs/editor/editor.main'], function () {
|
|
8
|
+
const editor = monaco.editor.create(document.getElementById('m-container'), {
|
|
9
|
+
value: $(`code[for=${id}]`).innerHTML,
|
|
10
|
+
language: 'javascript'
|
|
11
|
+
})
|
|
12
|
+
that.editor = editor
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
customElements.define('monaco-editor', MonacoEditor)
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
|
|
20
|
+
example..
|
|
21
|
+
|
|
22
|
+
<monaco-editor id='me1' estyle="width: 600px; height: 400px; border: 1px solid gray"></monaco-editor>
|
|
23
|
+
<code for='me1' hidden>
|
|
24
|
+
class HelloWorld extends HTMLElement {
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
this.innerHTML = '<div>Hello World!</div>'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
customElements.define('hello-world', HelloWorld)
|
|
30
|
+
</code>
|
|
31
|
+
|
|
32
|
+
*/
|
package/main.js
CHANGED
|
@@ -2,7 +2,7 @@ window.$ = document.querySelector.bind(document)
|
|
|
2
2
|
window.$$ = document.querySelectorAll.bind(document)
|
|
3
3
|
window.body = document.body
|
|
4
4
|
|
|
5
|
-
window.
|
|
5
|
+
window.loadJS = src => {
|
|
6
6
|
return new Promise((r, j) => {
|
|
7
7
|
const s = document.createElement('script')
|
|
8
8
|
s.src = src
|
|
@@ -11,6 +11,16 @@ window.load = src => {
|
|
|
11
11
|
})
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
window.loadCSS = src => {
|
|
15
|
+
return new Promise((r, j) => {
|
|
16
|
+
const s = document.createElement('link')
|
|
17
|
+
s.rel = 'stylesheet'
|
|
18
|
+
s.href = src
|
|
19
|
+
s.addEventListener('load', r)
|
|
20
|
+
document.head.appendChild(s)
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
14
24
|
class Data {
|
|
15
25
|
_ = {}
|
|
16
26
|
set (name, value) {
|
|
@@ -61,4 +71,8 @@ class EnigmaticElement extends HTMLElement {
|
|
|
61
71
|
}
|
|
62
72
|
}
|
|
63
73
|
|
|
64
|
-
customElements.define ('e-e', EnigmaticElement)
|
|
74
|
+
customElements.define ('e-e', EnigmaticElement)
|
|
75
|
+
|
|
76
|
+
window.addEventListener('DOMContentLoaded', (event) => {
|
|
77
|
+
if(main) main(document)
|
|
78
|
+
})
|
package/package.json
CHANGED
|
@@ -4,12 +4,9 @@
|
|
|
4
4
|
"url": "http://github.com/digplan/enigmatic",
|
|
5
5
|
"author": "<digplan@outlook.com>",
|
|
6
6
|
"main": "main.js",
|
|
7
|
-
"dependencies": {
|
|
8
|
-
"testchrome": "*"
|
|
9
|
-
},
|
|
10
7
|
"repository": {
|
|
11
8
|
"type": "git",
|
|
12
9
|
"url": "git://github.com/digplan/enigmatic.git"
|
|
13
10
|
},
|
|
14
|
-
"version": "0.9.
|
|
11
|
+
"version": "0.9.8"
|
|
15
12
|
}
|