ace-local-commands
v1.0.0
Published
Add/remove session specific command in Ace Editor
Readme
ace-local-commands
Add/remove session specific command in Ace Editor.
- Global commands: Commands that are bound to an editor and apply to all sessions (these are the standard "commands" in Ace Editor).
- Local commands: Commands that are bound to individual sessions. When the session changes, the commands for the new session are activated, and the ones bound to the previous session are deactivated.
Local commands can override global commands. If the session changes, overridden global commands that do not conflict with the new session's local commands may be reactivated.
api
init(editor: ace.Editor)- Initializes the handler for local events.
- This is called automatically when
addGlobalCommandsoraddLocalCommandsis used on theeditor.
addGlobalCommands(editor: ace.Editor, commands: Record<string, ace.CommandLike>)- Adds global
commandsto theeditor. - This works similarly to
editor.addCommands, but must be used when commands may be overridden by local commands of sessions — to ensure they are reactivated properly.
- Adds global
addLocalCommands(editor: ace.Editor, commands: Record<string, ace.CommandLike>)- Adds
commandsto the current session of theeditor.
- Adds
addCommandsToSession(session: ace.EditSession, commands: Record<string, ace.CommandLike>)- Adds local
commandsto a specificsession. - Note: You must call
init(editor)if no global/local commands have been set for theeditor, That is, eitheraddGlobalCommandsoraddLocalCommandsfor theeditoris never called.
- Adds local
