@huawei-ide/codearts 0.0.4 → 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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/index.js +9 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -10,8 +10,8 @@
10
10
  `const ide = require('@huawei-ide/codearts');`
11
11
 
12
12
  3. 预加载IDE
13
- 其中id参数为挂载节点id,返回Promise:
14
- `ide.preload(idstring).then(() => {});`
13
+ 其中id参数为挂载节点id,返回Promise:
14
+ `ide.preload(id: string).then(() => {});`
15
15
 
16
16
  4. 展示IDE
17
17
  `ide.show({width:string,height: string});`
package/index.js CHANGED
@@ -1,17 +1,21 @@
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.9/resources/server/gitcode.html';
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
9
  export function preload(id) {
10
+ var targetNode = document.getElementById(id);
11
+ targetNode.appendChild(iframe);
10
12
  return new Promise((resolve) => {
11
- var targetNode = document.getElementById(id);
12
- targetNode.appendChild(iframe);
13
- iframe.addEventListener('load', () => {
14
- resolve();
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
+ }
15
19
  });
16
20
  });
17
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huawei-ide/codearts",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {