Skip to content

Commit 9d26cfe

Browse files
committed
update README
1 parent 15a73ec commit 9d26cfe

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,29 @@ The following image clearly describes what these values mean:
342342

343343
![ele-info.png](public/ele-info.png)
344344

345+
### textEditorOpen()
346+
347+
A text editor will open after this API call
348+
349+
```js
350+
Terminal.$api.textEditorOpen('my-terminal', {
351+
content: 'This is the preset content',
352+
onClose: value => {
353+
console.log('Final content: ', value)
354+
}
355+
})
356+
```
357+
358+
`content` is the preset content when opening the editor. If you don’t want to preset any content, you can leave this parameter blank. When the user clicks Close or actively calls the `textEditorClose()` method, the `onClose` callback will be triggered, and the parameter `value` is the text content in the current editor.
359+
360+
### textEditorClose()
361+
362+
This method is used to close the currently opened text editor. After calling, it will trigger the `onClose` callback when it is opened.
363+
364+
```js
365+
Terminal.$api.textEditorClose('my-terminal')
366+
```
367+
345368
## Message
346369

347370
This plugin defines a message object. Any information that needs to be displayed on the Terminal in the form of a record is a message object. It is used by the `success()` callback of the `execCmd` event and the `pushMessage` api.

README_ZH.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# vue-web-terminal
44

5-
<a href="https://github.com/tzfun/vue-web-terminal"><img src="https://shields.io/github/package-json/v/tzfun/vue-web-terminal/master"></a>
5+
<a href="https://github.com/tzfun/vue-web-terminal/tree/vue2"><img src="https://shields.io/github/package-json/v/tzfun/vue-web-terminal/vue2"></a>
66
<a href="https://github.com/tzfun/vue-web-terminal/tree/vue3"><img src="https://shields.io/github/package-json/v/tzfun/vue-web-terminal/vue3"></a>
77
<a href="https://www.npmjs.com/package/vue-web-terminal"><img src="https://shields.io/bundlephobia/minzip/vue-web-terminal"></a>
88
<a href="https://npmcharts.com/compare/vue-web-terminal?minimal=true"><img src="https://img.shields.io/npm/dt/vue-web-terminal.svg" alt="Downloads"></a>
@@ -20,6 +20,7 @@
2020
* 支持 ↑ ↓ 键历史命令切换
2121
* 支持Fullscreen全屏显示
2222
* 支持窗口拖拽
23+
* 支持多行文本编辑
2324
* 支持自定义命令库和命令搜索提示,Tab键快捷填充
2425
* 支持用户输入过滤
2526
* 提供方便的API方法:执行命令、推送消息、模拟拖拽、获取DOM信息、全屏、修改上下文等
@@ -339,6 +340,29 @@ info数据结构如下:
339340

340341
![ele-info.png](public/ele-info.png)
341342

343+
### textEditorOpen()
344+
345+
此API调用后将会打开文本编辑器,使用示例:
346+
347+
```js
348+
Terminal.$api.textEditorOpen('my-terminal', {
349+
content: 'This is the preset content',
350+
onClose: value => {
351+
console.log('Final content: ', value)
352+
}
353+
})
354+
```
355+
356+
content是打开编辑器时预置的内容,如果你不想预置任何内容可以不填此参数,当用户点击Close或主动调用`textEditorClose()`方法时会触发`onClose`回调,参数value为当前编辑器内的文本内容。
357+
358+
### textEditorClose()
359+
360+
此方法用于关闭当前打开的文本编辑器,调用后会触发打开时的`onClose`回调。
361+
362+
```js
363+
Terminal.$api.textEditorClose('my-terminal')
364+
```
365+
342366
## 消息对象
343367

344368
本插件定义了消息对象,任何一个需要被以记录的形式显示在Terminal上的信息都是一个消息对象,`execCmd`事件的`success()`回调和`pushMessage`api都会用到它。

0 commit comments

Comments
 (0)