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

1.9 KiB

@aomao/plugin-link

Link plugin

Installation

$ yarn add @aomao/plugin-link

Vue3 use

$ yarn add @aomao/plugin-link-vue

Vue2 use

$ yarn add am-editor-link-vue2

Add to engine

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"]

//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",
                args:["_balnk_","https://www.aomao.com","ITELLYOU"]
            }
        }
    }
 })

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

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

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

//target:'_blank','_parent','_top','_self', href: link, text: text
engine.command.execute('link', '_blank', 'https://www.aomao.com', 'ITELLYOU');
//Use command to execute query current status, return boolean | undefined
engine.command.queryState('link');