Skip to content

Commit 91e4fd8

Browse files
committed
publish 2.1.10
1 parent 618f5c1 commit 91e4fd8

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-23
lines changed

README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ example:
212212
<textarea name="editor" class="t-text-editor" v-model="data.value"
213213
@focus="data.onFocus" @blur="data.onBlur"></textarea>
214214
<div class="t-text-editor-floor" align="center">
215-
<button class="t-text-editor-floor-btn" @click="_textEditorClose">Save & Close(Ctrl + S)</button>
215+
<button class="t-text-editor-floor-btn" @click="_textEditorClose(false)">Cancel</button>
216+
<button class="t-text-editor-floor-btn" @click="_textEditorClose(true)">Save & Close(Ctrl + S)</button>
216217
</div>
217218
</template>
218219
</terminal>
@@ -371,13 +372,16 @@ A text editor will open after this API call.
371372
```js
372373
TerminalApi.textEditorOpen('my-terminal', {
373374
content: 'This is the preset content',
374-
onClose: value => {
375-
console.log('Final content: ', value)
375+
onClose: (value, options) => {
376+
console.log('Final content: ', value, "options:", options)
376377
}
377378
})
378379
```
379380

380-
`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.
381+
`content` is the preset content when opening the editor. If you don’t want to preset any content, you can leave this
382+
parameter blank. When the user clicks Close or actively calls the `textEditorClose()` method, the `onClose` callback
383+
will be triggered, and the parameter `value` is the text content in the current editor,
384+
`options` is the parameter passed in when closing.
381385

382386
For more information on how to use text editors, see [Text Editor](#TextEditor).
383387

@@ -386,7 +390,9 @@ For more information on how to use text editors, see [Text Editor](#TextEditor).
386390
This method is used to close the currently opened text editor. After calling, it will trigger the `onClose` callback when it is opened.
387391

388392
```js
389-
TerminalApi.textEditorClose('my-terminal')
393+
TerminalApi.textEditorClose('my-terminal', true)
394+
395+
TerminalApi.textEditorClose('my-terminal', false)
390396
```
391397

392398
## Message
@@ -798,8 +804,8 @@ When you want to edit multi-line text, you can use the API: `textEditorOpen()`,
798804
```js
799805
TerminalApi.textEditorOpen('my-terminal', {
800806
content: 'Please edit this file',
801-
onClose: (value) => {
802-
console.log("User edit completed, text result:", value)
807+
onClose: (value, options) => {
808+
console.log("User edit completed, text result:", value, "options:", options)
803809
}
804810
})
805811
```
@@ -827,7 +833,8 @@ The plugin provides an `onKeydown` event, which is the best way for you to contr
827833
@blur="data.onBlur"></textarea>
828834
829835
<div class="t-text-editor-floor" align="center">
830-
<button class="t-text-editor-floor-btn" @click="_textEditorClose">Save & Close</button>
836+
<button class="t-text-editor-floor-btn" @click="_textEditorClose(false)">Cancel</button>
837+
<button class="t-text-editor-floor-btn" @click="_textEditorClose(true)">Save & Close</button>
831838
</div>
832839
833840
</template>
@@ -864,12 +871,12 @@ export default {
864871
},
865872
onKeydown(event) {
866873
if (this.enableTextEditor && event.key === 's' && event.ctrlKey) {
867-
this._textEditorClose()
874+
this._textEditorClose(true)
868875
event.preventDefault()
869876
}
870877
},
871-
_textEditorClose() {
872-
TerminalApi.textEditorClose(this.name)
878+
_textEditorClose(option) {
879+
TerminalApi.textEditorClose(this.name, option)
873880
}
874881
}
875882
}

README_ZH.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ example:
209209
<textarea name="editor" class="t-text-editor" v-model="data.value"
210210
@focus="data.onFocus" @blur="data.onBlur"></textarea>
211211
<div class="t-text-editor-floor" align="center">
212-
<button class="t-text-editor-floor-btn" @click="_textEditorClose">Save & Close(Ctrl + S)</button>
212+
<button class="t-text-editor-floor-btn" @click="_textEditorClose(false)">Cancel</button>
213+
<button class="t-text-editor-floor-btn" @click="_textEditorClose(true)">Save & Close(Ctrl + S)</button>
213214
</div>
214215
</template>
215216
</terminal>
@@ -370,13 +371,13 @@ info数据结构如下:
370371
```js
371372
TerminalApi.textEditorOpen('my-terminal', {
372373
content: 'This is the preset content',
373-
onClose: value => {
374-
console.log('Final content: ', value)
374+
onClose: (value, options) => {
375+
console.log('Final content: ', value, "options:", options)
375376
}
376377
})
377378
```
378379

379-
content是打开编辑器时预置的内容,如果你不想预置任何内容可以不填此参数,当用户点击Close或主动调用`textEditorClose()`方法时会触发`onClose`回调,参数value为当前编辑器内的文本内容
380+
content是打开编辑器时预置的内容,如果你不想预置任何内容可以不填此参数,当用户点击Close或主动调用`textEditorClose()`方法时会触发`onClose`回调,参数value为当前编辑器内的文本内容和传入参数选项
380381

381382
更多关于文本编辑器的使用方法见[文本编辑器](#文本编辑器)
382383

@@ -385,7 +386,9 @@ content是打开编辑器时预置的内容,如果你不想预置任何内容
385386
此方法用于关闭当前打开的文本编辑器,调用后会触发打开时的`onClose`回调。
386387

387388
```js
388-
TerminalApi.textEditorClose('my-terminal')
389+
TerminalApi.textEditorClose('my-terminal', true)
390+
391+
TerminalApi.textEditorClose('my-terminal', false)
389392
```
390393

391394
## 消息对象
@@ -797,8 +800,8 @@ asker.ask({
797800
```js
798801
TerminalApi.textEditorOpen('my-terminal', {
799802
content: 'Please edit this file',
800-
onClose: (value) => {
801-
console.log("用户编辑完成,文本结果:", value)
803+
onClose: (value, options) => {
804+
console.log("用户编辑完成,文本结果:", value, "options:", options)
802805
}
803806
})
804807
```
@@ -826,7 +829,8 @@ TerminalApi.textEditorOpen('my-terminal', {
826829
@blur="data.onBlur"></textarea>
827830
828831
<div class="t-text-editor-floor" align="center">
829-
<button class="t-text-editor-floor-btn" @click="_textEditorClose">Save & Close</button>
832+
<button class="t-text-editor-floor-btn" @click="_textEditorClose(false)">Cancel</button>
833+
<button class="t-text-editor-floor-btn" @click="_textEditorClose(true)">Save & Close</button>
830834
</div>
831835
832836
</template>
@@ -863,12 +867,12 @@ export default {
863867
},
864868
onKeydown(event) {
865869
if (this.enableTextEditor && event.key === 's' && event.ctrlKey) {
866-
this._textEditorClose()
870+
this._textEditorClose(true)
867871
event.preventDefault()
868872
}
869873
},
870-
_textEditorClose() {
871-
TerminalApi.textEditorClose(this.name)
874+
_textEditorClose(option) {
875+
TerminalApi.textEditorClose(this.name, option)
872876
}
873877
}
874878
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-web-terminal",
3-
"version": "2.1.9",
3+
"version": "2.1.10",
44
"description": "A lightweight and powerful web terminal plugin, suitable for vue3. 轻量、功能强大的网页端Terminal插件,适配vue3",
55
"license": "Apache-2.0",
66
"private": false,

0 commit comments

Comments
 (0)