@huawei-ide/codearts 1.0.21 → 1.0.23

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 +11 -2
  2. package/index.js +15 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -50,7 +50,16 @@
50
50
  `ide.setFilePrefix(prefix: string);`
51
51
 
52
52
  11. 设置Mardown文件中iframe的source:
53
- `ide.setIframeOrigin(origin: string);`
53
+ `ide.setIframeOrigin(origin: string);`
54
54
 
55
- 12. 销毁 IDE
55
+ 12. 设置深色/浅色主题:
56
+ `ide.setColorTheme(theme: string);`
57
+ ```
58
+ // 深色
59
+ ide.setColorTheme('dark');
60
+ // 浅色
61
+ ide.setColorTheme('light');
62
+ ```
63
+
64
+ 13. 销毁 IDE
56
65
  `ide.dispose();`
package/index.js CHANGED
@@ -1,9 +1,14 @@
1
1
  import { EventEmitter } from './util'
2
2
 
3
- const hcOrigin = 'https://idea.gitcode.net';
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.38/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.21",
3
+ "version": "1.0.23",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {