am-editor11212/docs/plugin/plugin-link.md

98 lines
1.9 KiB
Markdown
Raw Normal View History

2021-11-03 19:58:08 +08:00
# @aomao/plugin-link
Link plugin
## Installation
```bash
$ yarn add @aomao/plugin-link
```
`Vue3` use
```bash
$ yarn add @aomao/plugin-link-vue
```
`Vue2` use
```bash
$ yarn add am-editor-link-vue2
```
Add to engine
```ts
import Engine, {EngineInterface} from'@aomao/engine';
import Link from'@aomao/plugin-link';
new Engine(...,{ plugins:[Link] })
```
## Optional
### hot key
The default shortcut key is `mod+k`, and the default parameter is ["_blank"]
```ts
//Shortcut keys, key combination keys, args, execution parameters, [target?:string,href?:string,text?:string] Open mode: optional, default link: optional, default text: optional
hotkey?:string | {key:string,args:Array<string>};
//Use configuration
new Engine(...,{
config:{
"link":{
//Modify shortcut keys
hotkey:{
key:"mod+k",
2021-12-05 00:37:05 +08:00
args:["_balnk_","https://www.aomao.com","ITELLYOU"]
2021-11-03 19:58:08 +08:00
}
}
}
})
```
### Markdown
Support markdown by default, pass in `false` to close
Link plug-in markdown syntax is `[text](link address)` and it is triggered after pressing enter
```ts
markdown?: boolean;//enabled by default, false off
//Use configuration
new Engine(...,{
config:{
"link":{
//Close markdown
markdown:false
}
}
})
```
### onConfirm
The url or text to be modified can be modified
Confirm execution after editing text and url
```ts
onConfirm?: (
text: string,
link: string,
) => Promise<{ text: string; link: string }>;
```
## Command
Three parameters can be passed in [target?:string,href?:string,text?:string] Open mode: optional, default link: optional, default text: optional
```ts
//target:'_blank','_parent','_top','_self', href: link, text: text
2021-12-05 00:37:05 +08:00
engine.command.execute('link', '_blank', 'https://www.aomao.com', 'ITELLYOU');
2021-11-03 19:58:08 +08:00
//Use command to execute query current status, return boolean | undefined
engine.command.queryState('link');
```