Skip to content

Commit fdc2fd9

Browse files
save file
1 parent bb775b2 commit fdc2fd9

File tree

1 file changed

+36
-86
lines changed

1 file changed

+36
-86
lines changed

blog/25-08-25/monaco-editor-setup/monaco-editor-setup.html

Lines changed: 36 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
<title>monaco editor setup</title>
1111

12-
<base href='https://javascript-2020.github.io/blog/25-08-25/monaco-editor-setup/monaco-editor-setup.html'>
12+
<base href='https://javascript-2020.github.io/blog/25-08-25/monaco-editor-setup/'>
13+
1314
<link rel=canonical href='https://ext-code.com/blog/25-08-25/monaco-editor-setup/monaco-editor-setup.html'>
1415

1516
<meta name=viewport content='width=device-width, initial-scale=1'>
@@ -19,6 +20,8 @@
1920
<script src='https://ajaxorg.github.io/ace-builds/src-noconflict/ace.js'></script>
2021

2122

23+
<script src='https://libs.ext-code.com/js/dom/component/component.js'></script>
24+
2225
<script init>
2326
console.clear();
2427
console.json=v=>console.log(JSON.stringify(v,null,4));
@@ -32,125 +35,72 @@
3235
var datatype;
3336
var menumod;
3437
var code;
38+
3539

36-
var mod = {};
37-
38-
40+
var snippet;
3941

4042
//:
4143

44+
45+
mod.stack.add = init;
4246

4347
async function init(){
4448
//debug('init',version);
4549
menu = menumod();
4650

51+
52+
snippet = mod['snippet-html-console'];
53+
54+
snippet.initmod({ext,$,menu,ace});
55+
56+
await snippet.init();
57+
58+
59+
4760
await initdom(document.body);
4861

4962

50-
init.complete();
51-
5263
}//init
5364

5465

5566
//:
5667

5768

58-
init.stack = [init];
59-
init.stack.ct = 0;
60-
init.stack.total = 1;
61-
init.stack.mode = '';
62-
init.stack.complete = false;
63-
Object.defineProperty(init.stack,'add',{get:()=>{
64-
init.stack.total++;
65-
if(init.stack.mode){
66-
console[init.stack.mode]('add',init.stack.ct,init.stack.total);
67-
//console.trace();
68-
}
69-
}});
70-
Object.defineProperty(init.stack,'complete',{get:()=>{
71-
init.stack.ct++;
72-
if(init.stack.mode){
73-
console[init.stack.mode]('complete',init.stack.ct,init.stack.total);
74-
//console.trace();
75-
}
76-
if(init.stack.ct>=init.stack.total){
77-
//console.log('*** complete');
78-
init.stack.ct = 0;
79-
init.stack.total = 0;
80-
var list = [...init.stack];
81-
init.stack.length = 0;
82-
list.forEach(fn=>fn());
83-
}
84-
}});
85-
86-
// (typeof init!='undefined' && init?.stack && init.stack.add)
87-
// (typeof init!='undefined' && init?.stack && init.stack.complete)
88-
89-
90-
init.complete = function(){
91-
92-
init.complete.stack.forEach(fn=>fn());
93-
94-
95-
}//complete
96-
97-
init.complete.stack = [];
98-
init.complete.add = fn=>init.complete.stack.push(fn);
99-
100-
101-
10269
(async()=>{
103-
104-
init.stack.add;
10570

71+
mod.stack.add;
10672

107-
var url;
108-
var headers;
109-
var token = localStorage['github-token'];
110-
if(token){
111-
url = 'https://api.github.com/repos/javascript-2020/ext-code/contents/ext-loader.js';
112-
headers = {accept:'application/vnd.github.raw',authorization:`bearer ${token}`};
113-
}else{
114-
url = 'https://raw.githubusercontent.com/javascript-2020/ext-code/main/ext-loader.js';
115-
}
116-
117-
var res = await fetch(url,{headers});
118-
var txt = await res.text();
119-
120-
if(res.headers.get('content-type').includes('json')){
121-
console.log('*** ext : json');
122-
var json = JSON.parse(txt);
123-
var b64 = json.content;
124-
txt = atob(b64);
125-
}else{
126-
console.log('*** ext : text');
127-
}
128-
129-
ext = eval(txt);
130-
131-
73+
({ext} = await import('https://libs.ext-code.com/js/io/ext-loader/ext-loader.m.js'));
74+
13275
var promise = ext.load.libs(
133-
'js/dom/$.js.api',
76+
'js/dom/$.js',
13477
'js/core/datatype.js',
13578
'js/dom/menumod/menumod.js',
136-
'js/dom/code/code.js.api',
79+
'js/dom/keydown/keydown.js',
80+
'js/dom/code/v2.0/code-v2.0.js.api',
13781
);
138-
[$,datatype,menumod,code] = await promise;
139-
82+
[$,datatype,menumod,keydown,code] = await promise;
83+
14084
code.initmod({ext,$,datatype,menumod});
141-
14285

143-
init.stack.complete;
144-
86+
mod.stack.complete;
87+
14588
})();
14689

90+
14791
</script init>
14892

14993

15094

15195

15296
<link rel=stylesheet href='/blog/css/blog.css'>
15397

98+
<style>
99+
100+
html
101+
{font-family:arial}
102+
103+
</style>
154104

155105
</head>
156106

@@ -171,8 +121,8 @@ <h3>
171121
</div>
172122

173123

174-
<code-block src='ex/ex1.html' api>
175-
</code-block>
124+
<snippet-html-console component v2.0 src='ex/ex1.html'>
125+
</snippet-html-console>
176126

177127

178128

0 commit comments

Comments
 (0)