@huawei-ide/codearts 0.0.5 → 0.0.6
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/README.md +3 -4
- package/index.js +11 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,12 +10,11 @@
|
|
|
10
10
|
`const ide = require('@huawei-ide/codearts');`
|
|
11
11
|
|
|
12
12
|
3. 预加载IDE
|
|
13
|
-
|
|
14
|
-
`ide.preload().then(() => {});`
|
|
13
|
+
其中id参数为挂载节点id,返回Promise:
|
|
14
|
+
`ide.preload(id: string).then(() => {});`
|
|
15
15
|
|
|
16
16
|
4. 展示IDE
|
|
17
|
-
|
|
18
|
-
`ide.show(id: string, {width:string,height: string});`
|
|
17
|
+
`ide.show({width:string,height: string});`
|
|
19
18
|
|
|
20
19
|
5. 打开文件
|
|
21
20
|
参数content为文件内容,类型为string,path是工程内文件的唯一路径,例如'src', 'src/tool', name为带后缀的文件名:
|
package/index.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
var iframe = document.createElement('iframe');
|
|
2
2
|
iframe.id = 'codeartside';
|
|
3
|
-
iframe.src = 'https://res.hc-cdn.com/codearts-core-web-static/1.0.
|
|
3
|
+
iframe.src = 'https://res.hc-cdn.com/codearts-core-web-static/1.0.11/resources/server/gitcode.html';
|
|
4
4
|
iframe.width = '1px';
|
|
5
5
|
iframe.height = '1px';
|
|
6
6
|
iframe.style.opacity = 0;
|
|
7
7
|
iframe.style.zIndex = -1;
|
|
8
8
|
|
|
9
|
-
export function preload() {
|
|
10
|
-
document.
|
|
9
|
+
export function preload(id) {
|
|
10
|
+
var targetNode = document.getElementById(id);
|
|
11
|
+
targetNode.appendChild(iframe);
|
|
11
12
|
return new Promise((resolve) => {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
window.addEventListener('message', function(event) {
|
|
14
|
+
console.log('-gitcode--receive message---', event.data);
|
|
15
|
+
if (event.data === 'ide-loaded') {
|
|
16
|
+
console.log('====Message received from iframe:', event.data);
|
|
17
|
+
resolve();
|
|
18
|
+
}
|
|
14
19
|
});
|
|
15
20
|
});
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
// style: { width: string, height: string }
|
|
19
|
-
export function show(
|
|
20
|
-
var targetNode = document.getElementById(id);
|
|
21
|
-
targetNode.appendChild(iframe);
|
|
24
|
+
export function show(style) {
|
|
22
25
|
const {width, height} = style;
|
|
23
26
|
iframe.width = width;
|
|
24
27
|
iframe.height = height;
|