@huawei-ide/codearts 1.0.51 → 1.0.52
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 +25 -1
- package/index.js +29 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -138,5 +138,29 @@
|
|
|
138
138
|
event.dispose();
|
|
139
139
|
```
|
|
140
140
|
|
|
141
|
-
18.
|
|
141
|
+
18. 设置代码高亮行(若只需高亮一行,则将IHightlightConfig.start与IHightlightConfig.end设置为同行)
|
|
142
|
+
`ide.setHighlightLineNumber(config: IHightlightConfig);`
|
|
143
|
+
```typescript
|
|
144
|
+
export interface IHightlightConfig {
|
|
145
|
+
/**
|
|
146
|
+
* Controls the starting line number to highlight.
|
|
147
|
+
*/
|
|
148
|
+
start: number;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Controls the ending line number to highlight.
|
|
152
|
+
*/
|
|
153
|
+
end: number
|
|
154
|
+
};
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
19. 监听当前点击行号后高亮的区间
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
const event = ide.onDidClickLineNumber(listener: (content: IHightlightConfig) => {});
|
|
161
|
+
// 销毁监听
|
|
162
|
+
event.dispose();
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
20. 销毁 IDE
|
|
142
166
|
`ide.dispose();`
|
package/index.js
CHANGED
|
@@ -8,12 +8,13 @@ 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.
|
|
11
|
+
iframe.src = hcOrigin + '/codearts-core-web-static/1.0.86/resources/server/gitcode.html';
|
|
12
12
|
|
|
13
13
|
const OS = getOS();
|
|
14
14
|
const ON_DID_CHANGE = 'onDidChange';
|
|
15
15
|
const ON_DID_SEND_CODE = 'onDidSendCode';
|
|
16
16
|
const ON_DID_CLICK_LINK = 'onDidClickLink';
|
|
17
|
+
const ON_DID_CLICK_LINE_NUMBER = 'onDidClickLineNumber';
|
|
17
18
|
const eventEmitter = new EventEmitter();
|
|
18
19
|
|
|
19
20
|
function ideLoading() {
|
|
@@ -61,6 +62,9 @@ function onDidRecieveMessage(event) {
|
|
|
61
62
|
if (type === 'ide-on-did-click-link') {
|
|
62
63
|
eventEmitter.emit(ON_DID_CLICK_LINK, data);
|
|
63
64
|
}
|
|
65
|
+
if (type === 'ide-on-did-click-line-number') {
|
|
66
|
+
eventEmitter.emit(ON_DID_CLICK_LINE_NUMBER, data);
|
|
67
|
+
}
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
export function preload() {
|
|
@@ -199,6 +203,14 @@ export function blockClickedLink(block) {
|
|
|
199
203
|
postMessage(message);
|
|
200
204
|
}
|
|
201
205
|
|
|
206
|
+
export function setHighlightLineNumber(config) {
|
|
207
|
+
const message = {
|
|
208
|
+
type: 'setHighlightLineNumber',
|
|
209
|
+
data: config
|
|
210
|
+
};
|
|
211
|
+
postMessage(message);
|
|
212
|
+
}
|
|
213
|
+
|
|
202
214
|
function postMessage(message) {
|
|
203
215
|
iframe.contentWindow.postMessage(message, hcOrigin);
|
|
204
216
|
}
|
|
@@ -250,3 +262,19 @@ export function onDidClickLink(listener) {
|
|
|
250
262
|
}
|
|
251
263
|
}
|
|
252
264
|
}
|
|
265
|
+
|
|
266
|
+
let isRegisteredClickLineNumberListener = false;
|
|
267
|
+
export function onDidClickLineNumber(listener) {
|
|
268
|
+
if (!isRegisteredClickLineNumberListener) {
|
|
269
|
+
window.addEventListener('message', onDidRecieveMessage);
|
|
270
|
+
isRegisteredClickLineNumberListener = true;
|
|
271
|
+
}
|
|
272
|
+
eventEmitter.on(ON_DID_CLICK_LINE_NUMBER, listener);
|
|
273
|
+
return {
|
|
274
|
+
dispose: () => {
|
|
275
|
+
eventEmitter.off(ON_DID_CLICK_LINE_NUMBER, listener);
|
|
276
|
+
window.removeEventListener('message', onDidRecieveMessage);
|
|
277
|
+
isRegisteredClickLineNumberListener = false;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|