@huawei-ide/codearts 1.0.67 → 1.0.68

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.
@@ -0,0 +1,5 @@
1
+ {
2
+ "mcpServers": {
3
+
4
+ }
5
+ }
package/README.md CHANGED
@@ -167,3 +167,6 @@
167
167
 
168
168
  21. 销毁 IDE
169
169
  `ide.dispose();`
170
+
171
+ 22. 设置编辑区文本是否自动换行,默认关闭
172
+ `ide.setEditorWordWrap(wordWrap: boolean)`
package/index.js CHANGED
@@ -6,7 +6,7 @@ const atomgitOriginSuffix = window.location.origin.match(/(?:\w+\.)*?atomgit((?:
6
6
  if (gitcodeOriginSuffix) {
7
7
  const suffix = gitcodeOriginSuffix[1];
8
8
  hcOrigin = `https://idea.gitcode${suffix}`; // Adapter for gitcode multiple domains
9
- } else if(atomgitOriginSuffix) {
9
+ } else if (atomgitOriginSuffix) {
10
10
  const suffix = atomgitOriginSuffix[1];
11
11
  hcOrigin = `https://idea.atomgit${suffix}`; // Adapter for atomgit multiple domains
12
12
  } else {
@@ -14,13 +14,18 @@ if (gitcodeOriginSuffix) {
14
14
  }
15
15
  const iframe = document.createElement('iframe');
16
16
  iframe.id = 'codeartside';
17
- iframe.src = hcOrigin + '/codearts-core-web-static/1.0.101/resources/server/gitcode.html';
17
+ iframe.src = hcOrigin + '/codearts-core-web-static/1.0.102/resources/server/gitcode.html';
18
18
 
19
19
  const OS = getOS();
20
20
  const ON_DID_CHANGE = 'onDidChange';
21
21
  const ON_DID_SEND_CODE = 'onDidSendCode';
22
22
  const ON_DID_CLICK_LINK = 'onDidClickLink';
23
23
  const ON_DID_CLICK_LINE_NUMBER = 'onDidClickLineNumber';
24
+
25
+ // Used to get the location hash, different from the standard W3C fragment text flag '#:~:text=',
26
+ // which will be handled by the browser and removed then. We cannot get the location hash if use '#:~:text='.
27
+ const CUSTOM_W3C_FRAGMENT_TEXT_FLAG = '#:~text=';
28
+
24
29
  const eventEmitter = new EventEmitter();
25
30
 
26
31
  function ideLoading() {
@@ -30,6 +35,12 @@ function ideLoading() {
30
35
  return;
31
36
  }
32
37
  if (event.data === 'ide-loaded') {
38
+ // Post location message to ide.
39
+ postMessage({
40
+ type: 'documentLink',
41
+ data: `${window.location.origin}${window.location.pathname}`
42
+ });
43
+
33
44
  resolve();
34
45
  window.removeEventListener('message', handleMessage);
35
46
  }
@@ -94,11 +105,11 @@ export function show(id, style) {
94
105
  return ideLoading();
95
106
  }
96
107
 
97
- // file: { content: string, path: string, name: string }
108
+ // file: { content: string, path: string, name: string, customW3cFragmentTextHash?: string }
98
109
  export function openFile(file) {
99
110
  const message = {
100
111
  type: 'openFile',
101
- data: file
112
+ data: { ...file, customW3cFragmentTextHash: window.location.hash.startsWith(CUSTOM_W3C_FRAGMENT_TEXT_FLAG) ? window.location.hash : undefined }
102
113
  };
103
114
  postMessage(message);
104
115
  }
@@ -225,6 +236,14 @@ export function enableMarkdownPreview(isEnable) {
225
236
  postMessage(message);
226
237
  }
227
238
 
239
+ export function setEditorWordWrap(wordWrap) {
240
+ const message = {
241
+ type: 'setEditorWordWrap',
242
+ data: wordWrap
243
+ };
244
+ postMessage(message);
245
+ }
246
+
228
247
  function postMessage(message) {
229
248
  iframe.contentWindow.postMessage(message, hcOrigin);
230
249
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huawei-ide/codearts",
3
- "version": "1.0.67",
3
+ "version": "1.0.68",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {