improve(plugin): user types

This commit is contained in:
charlie
2021-05-28 19:51:45 +08:00
parent 213630f277
commit 430c00f8e7
2 changed files with 14 additions and 6 deletions

View File

@@ -4,7 +4,10 @@ import {
IAppProxy, IDBProxy,
IEditorProxy,
ILSPluginUser,
LSPluginBaseInfo, LSPluginUserEvents, SlashCommandAction,
LSPluginBaseInfo,
LSPluginUserEvents,
SlashCommandAction,
BlockCommandCallback,
StyleString,
ThemeOptions,
UIOptions
@@ -31,10 +34,14 @@ const editor: Partial<IEditorProxy> = {
registerSlashCommand (
this: LSPluginUser,
tag: string,
actions: Array<SlashCommandAction>
actions: BlockCommandCallback | Array<SlashCommandAction>
) {
debug('Register slash command #', this.baseInfo.id, tag, actions)
if (typeof actions === 'function') {
actions = [['editor/clear-current-slash'], ['editor/hook', actions]]
}
actions = actions.map((it) => {
const [tag, ...args] = it
@@ -73,7 +80,7 @@ const editor: Partial<IEditorProxy> = {
registerBlockContextMenu (
this: LSPluginUser,
tag: string,
action: () => void
action: BlockCommandCallback
): boolean {
if (typeof action !== 'function') {
return false