@huawei-ide/codearts 1.0.41 → 1.0.43

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 +66 -1
  2. package/index.js +37 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -62,5 +62,70 @@
62
62
  ide.setColorTheme('light');
63
63
  ```
64
64
 
65
- 13. 销毁 IDE
65
+ 13. 设置编辑器内文字字体大小:
66
+ `ide.setEditorFontSize(fontSize: number);`
67
+
68
+ 14. 设置是否开启代码操作气泡:
69
+ 发送信息命令:gitcode.send.message
70
+ `ide.registerCodeOperation(options: CodeOperationOptions);`
71
+ ```typescript
72
+ export interface CodeOperationOptions {
73
+ /**
74
+ * The icon of the code operation toolbox, if not set, use default.
75
+ */
76
+ icon?: string;
77
+
78
+ /**
79
+ * The title of the code operation tool div
80
+ */
81
+ title?: string;
82
+
83
+ /**
84
+ * The opertion list.
85
+ */
86
+ operations: CodeOperation[];
87
+ }
88
+
89
+ export interface CodeOperation {
90
+ /**
91
+ * The label of the operation
92
+ */
93
+ label: string;
94
+
95
+ /**
96
+ * The option of the command which will be executed when click the operation button
97
+ */
98
+ command: {
99
+ /**
100
+ * The title of the command
101
+ */
102
+ title?: string;
103
+
104
+ /**
105
+ * Command id
106
+ */
107
+ id: string;
108
+
109
+ /**
110
+ * The arguments of the command
111
+ */
112
+ args?: any[];
113
+
114
+ /**
115
+ * whether the keybinding shortcuts will be displayed, default to be true
116
+ */
117
+ showKeybinding?: boolean;
118
+ };
119
+ }
120
+ ```
121
+
122
+ 15. 监听当前点击发送代码片段
123
+
124
+ ```
125
+ const event = ide.onDidSendCode(listener: (content: string) => {});
126
+ // 销毁监听
127
+ event.dispose();
128
+ ```
129
+
130
+ 16. 销毁 IDE
66
131
  `ide.dispose();`
package/index.js CHANGED
@@ -8,10 +8,11 @@ if (window.location.origin.endsWith('.net')) {
8
8
  }
9
9
  const iframe = document.createElement('iframe');
10
10
  iframe.id = 'codeartside';
11
- iframe.src = hcOrigin + '/codearts-core-web-static/1.0.71/resources/server/gitcode.html';
11
+ iframe.src = hcOrigin + '/codearts-core-web-static/1.0.75/resources/server/gitcode.html';
12
12
 
13
13
  const OS = getOS();
14
14
  const ON_DID_CHANGE = 'onDidChange';
15
+ const ON_DID_SEND_CODE = 'onDidSendCode';
15
16
  const eventEmitter = new EventEmitter();
16
17
 
17
18
  function ideLoading() {
@@ -53,6 +54,9 @@ function onDidRecieveMessage(event) {
53
54
  if (type === 'ide-on-did-change-file') {
54
55
  eventEmitter.emit(ON_DID_CHANGE, data);
55
56
  }
57
+ if (type === 'ide-on-did-send-code') {
58
+ eventEmitter.emit(ON_DID_SEND_CODE, data);
59
+ }
56
60
  }
57
61
 
58
62
  export function preload() {
@@ -167,6 +171,22 @@ export function setColorTheme(theme) {
167
171
  postMessage(message);
168
172
  }
169
173
 
174
+ export function setEditorFontSize(fontSize) {
175
+ const message = {
176
+ type: 'setEditorFontSize',
177
+ data: fontSize
178
+ };
179
+ postMessage(message);
180
+ }
181
+
182
+ export function registerCodeOperation(options) {
183
+ const message = {
184
+ type: 'registerCodeOperation',
185
+ data: options
186
+ };
187
+ postMessage(message);
188
+ }
189
+
170
190
  function postMessage(message) {
171
191
  iframe.contentWindow.postMessage(message, hcOrigin);
172
192
  }
@@ -186,3 +206,19 @@ export function onDidChange(listener) {
186
206
  }
187
207
  }
188
208
  }
209
+
210
+ let isRegisteredSendCodeListener = false;
211
+ export function onDidSendCode(listener) {
212
+ if (!isRegisteredSendCodeListener) {
213
+ window.addEventListener('message', onDidRecieveMessage);
214
+ isRegisteredSendCodeListener = true;
215
+ }
216
+ eventEmitter.on(ON_DID_SEND_CODE, listener);
217
+ return {
218
+ dispose: () => {
219
+ eventEmitter.off(ON_DID_SEND_CODE, listener);
220
+ window.removeEventListener('message', onDidRecieveMessage);
221
+ isRegisteredSendCodeListener = false;
222
+ }
223
+ }
224
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huawei-ide/codearts",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {