@huawei-ide/codearts 1.0.68 → 1.0.70

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 +3 -0
  2. package/index.js +20 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -170,3 +170,6 @@
170
170
 
171
171
  22. 设置编辑区文本是否自动换行,默认关闭
172
172
  `ide.setEditorWordWrap(wordWrap: boolean)`
173
+
174
+ 23. 搜索编辑区文本
175
+ `ide.searchText(text: string)`
package/index.js CHANGED
@@ -14,7 +14,7 @@ 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.102/resources/server/gitcode.html';
17
+ iframe.src = hcOrigin + '/codearts-core-web-static/1.0.103/resources/server/gitcode.html';
18
18
 
19
19
  const OS = getOS();
20
20
  const ON_DID_CHANGE = 'onDidChange';
@@ -35,12 +35,6 @@ function ideLoading() {
35
35
  return;
36
36
  }
37
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
-
44
38
  resolve();
45
39
  window.removeEventListener('message', handleMessage);
46
40
  }
@@ -84,6 +78,14 @@ function onDidRecieveMessage(event) {
84
78
  }
85
79
  }
86
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
+
87
89
  export function preload() {
88
90
  iframe.width = '1px';
89
91
  iframe.height = '1px';
@@ -107,6 +109,9 @@ export function show(id, style) {
107
109
 
108
110
  // file: { content: string, path: string, name: string, customW3cFragmentTextHash?: string }
109
111
  export function openFile(file) {
112
+ // need set document link before open file.
113
+ setDocumentLink();
114
+
110
115
  const message = {
111
116
  type: 'openFile',
112
117
  data: { ...file, customW3cFragmentTextHash: window.location.hash.startsWith(CUSTOM_W3C_FRAGMENT_TEXT_FLAG) ? window.location.hash : undefined }
@@ -244,6 +249,14 @@ export function setEditorWordWrap(wordWrap) {
244
249
  postMessage(message);
245
250
  }
246
251
 
252
+ export function searchText(text) {
253
+ const message = {
254
+ type: 'searchText',
255
+ data: text
256
+ };
257
+ postMessage(message);
258
+ }
259
+
247
260
  function postMessage(message) {
248
261
  iframe.contentWindow.postMessage(message, hcOrigin);
249
262
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huawei-ide/codearts",
3
- "version": "1.0.68",
3
+ "version": "1.0.70",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {