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

1.3 KiB

@aomao/plugin-indent

Indentation plugin

Installation

$ yarn add @aomao/plugin-indent

Add to engine

This plug-in is recommended to be added first to prevent other plug-ins from intercepting the event and making it unable to take effect

import Engine, {EngineInterface} from'@aomao/engine';
import Indent from'@aomao/plugin-indent';

new Engine(...,{ plugins:[Indent] })

Optional

hot key

Default indentation shortcut mod+]

Delete indentation shortcut key mod+[ by default

//hot key,
hotkey?: {
    in?:string //Indentation shortcut key, default mod+]
    out?:string //Delete indentation shortcut key, default mod+[
};

//Use configuration
new Engine(...,{
    config:{
        "indent":{
            //Modify shortcut keys
            hotkey:{
                "in":"shortcut key",
                "out": "shortcut key"
            }
        }
    }
 })

Maximum padding

Maximum padding, each indentation is 2

maxPadding?:number

Command

One parameter defaults to in, optional value is in to increase indentation, and out to decrease indentation

engine.command.execute('indent');
//Use command to execute query current status, return numbber, current indentation value
engine.command.queryState('indent');