You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example, */vue-web-terminal/beifengtz* in the current input line `$ /vue-web-terminal/beifengtz > ` is the context, and the context text can be freely set by the developer, but you need to use `.sync` to bind a variable.
`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.
370
341
342
+
For more information on how to use text editors, see [Text Editor](#TextEditor).
343
+
371
344
### textEditorClose()
372
345
373
346
This method is used to close the currently opened text editor. After calling, it will trigger the `onClose` callback when it is opened.
@@ -723,8 +696,8 @@ In the `execCmd` event callback of [Events](#Events), the `success` callback fun
723
696
Create a new ask object through `new Terminal.$Ask()` and pass it into the success callback. The ask object provides two methods:
724
697
725
698
*`ask(options)`: Initiate a user to ask for input, options is an object, and its properties are explained as follows (* indicates required):
726
-
**`question`: string, The question to ask, or a prefix string that can be understood as user input
727
-
**`callback`: function, The callback when the user types an enter key, the parameter value is the content entered by the user
699
+
*`question`: string, The question to ask, or a prefix string that can be understood as user input
700
+
*`callback`: function, The callback when the user types an enter key, the parameter value is the content entered by the user
728
701
*`autoReview`: bool, Whether to automatically append the current display content when the user types an enter key
729
702
*`isPassword`: bool, Whether it is a password input
When you want to edit multi-line text, you can use the API: `textEditorOpen()`, `textEditorClose()`. For details, please refer to the [API](#Api) section. The following is a simple example:
734
+
735
+
```js
736
+
Terminal.$api.textEditorOpen(this.name, {
737
+
content:'Please edit this file',
738
+
onClose: (value) => {
739
+
console.log("User edit completed, text result:", value)
740
+
}
741
+
})
742
+
```
743
+
744
+
#### Slot custom style
745
+
746
+
If you don't like the default style, you can use Slot to customize the style of the editor (such as changing to Codemirror or VS Code ?), the parameter is `data`, and data has three attributes that you need to care about:
747
+
748
+
*`value`: The edited text content, you need to bind it with `v-model` in the editor you implement.
749
+
*`onFoucs`: Get the focus event, you need to bind the `@focus` event in the editor you implement.
750
+
*`onBlur`: Lost focus event, you need to bind the `@blur` event in the editor you implement.
751
+
752
+
**Custom Shortcuts**
753
+
754
+
The plugin provides an `onKeydown` event, which is the best way for you to control the shortcut keys of the Terminal in **active state**, here we take the text editor as an example, set the user to press the shortcut key `Ctrl + S` to indicate Finish editing and save.
0 commit comments