@huawei-ide/codearts 1.0.22 → 1.0.24

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 +12 -2
  2. package/index.js +15 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -27,6 +27,7 @@
27
27
  name: 'README.md'
28
28
  });
29
29
  ```
30
+ 如果需要传入pdf文件,content需要设置为空,path为pdf资源链接,name为pdf文件名。
30
31
 
31
32
  6. 设置文件是否为预览(只读)状态
32
33
  `ide.setPreview(preview: boolean)`
@@ -50,7 +51,16 @@
50
51
  `ide.setFilePrefix(prefix: string);`
51
52
 
52
53
  11. 设置Mardown文件中iframe的source:
53
- `ide.setIframeOrigin(origin: string);`
54
+ `ide.setIframeOrigin(origin: string);`
54
55
 
55
- 12. 销毁 IDE
56
+ 12. 设置深色/浅色主题:
57
+ `ide.setColorTheme(theme: string);`
58
+ ```
59
+ // 深色
60
+ ide.setColorTheme('dark');
61
+ // 浅色
62
+ ide.setColorTheme('light');
63
+ ```
64
+
65
+ 13. 销毁 IDE
56
66
  `ide.dispose();`
package/index.js CHANGED
@@ -1,9 +1,14 @@
1
1
  import { EventEmitter } from './util'
2
2
 
3
- const hcOrigin = 'https://idea.gitcode.com';
3
+ let hcOrigin = '';
4
+ if (window.location.origin.endsWith('.net')) {
5
+ hcOrigin = 'https://idea.gitcode.net';
6
+ } else {
7
+ hcOrigin = 'https://idea.gitcode.com';
8
+ }
4
9
  const iframe = document.createElement('iframe');
5
10
  iframe.id = 'codeartside';
6
- iframe.src = hcOrigin + '/codearts-core-web-static/1.0.37/resources/server/gitcode.html';
11
+ iframe.src = hcOrigin + '/codearts-core-web-static/1.0.40/resources/server/gitcode.html';
7
12
 
8
13
  const ON_DID_CHANGE = 'onDidChange';
9
14
  const eventEmitter = new EventEmitter();
@@ -133,6 +138,14 @@ export function setIframeOrigin(origin) {
133
138
  postMessage(message);
134
139
  }
135
140
 
141
+ export function setColorTheme(theme) {
142
+ const message = {
143
+ type: 'setColorTheme',
144
+ data: theme
145
+ };
146
+ postMessage(message);
147
+ }
148
+
136
149
  function postMessage(message) {
137
150
  iframe.contentWindow.postMessage(message, hcOrigin);
138
151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huawei-ide/codearts",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {