@huawei-ide/codearts 1.0.67 → 1.0.69

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() {
@@ -73,6 +78,14 @@ function onDidRecieveMessage(event) {
73
78
  }
74
79
  }
75
80
 
81
+ function setDocumentLink() {
82
+ // Post location message to ide.
83
+ postMessage({
84
+ type: 'documentLink',
85
+ data: `${window.location.origin}${window.location.pathname}`
86
+ });
87
+ }
88
+
76
89
  export function preload() {
77
90
  iframe.width = '1px';
78
91
  iframe.height = '1px';
@@ -94,11 +107,14 @@ export function show(id, style) {
94
107
  return ideLoading();
95
108
  }
96
109
 
97
- // file: { content: string, path: string, name: string }
110
+ // file: { content: string, path: string, name: string, customW3cFragmentTextHash?: string }
98
111
  export function openFile(file) {
112
+ // need set document link before open file.
113
+ setDocumentLink();
114
+
99
115
  const message = {
100
116
  type: 'openFile',
101
- data: file
117
+ data: { ...file, customW3cFragmentTextHash: window.location.hash.startsWith(CUSTOM_W3C_FRAGMENT_TEXT_FLAG) ? window.location.hash : undefined }
102
118
  };
103
119
  postMessage(message);
104
120
  }
@@ -225,6 +241,14 @@ export function enableMarkdownPreview(isEnable) {
225
241
  postMessage(message);
226
242
  }
227
243
 
244
+ export function setEditorWordWrap(wordWrap) {
245
+ const message = {
246
+ type: 'setEditorWordWrap',
247
+ data: wordWrap
248
+ };
249
+ postMessage(message);
250
+ }
251
+
228
252
  function postMessage(message) {
229
253
  iframe.contentWindow.postMessage(message, hcOrigin);
230
254
  }
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.69",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {