diff --git a/packages/core/src/commands/command.ts b/packages/core/src/commands/command.ts new file mode 100644 index 00000000..7f129d42 --- /dev/null +++ b/packages/core/src/commands/command.ts @@ -0,0 +1,5 @@ +import { Command } from '../types' + +export default (fn: (props: Parameters[0]) => boolean): Command => props => { + return fn(props) +} diff --git a/packages/core/src/extensions/commands.ts b/packages/core/src/extensions/commands.ts index 3b82b620..ae0feba2 100644 --- a/packages/core/src/extensions/commands.ts +++ b/packages/core/src/extensions/commands.ts @@ -1,6 +1,7 @@ import { Extension } from '../Extension' import blur from '../commands/blur' import clearContent from '../commands/clearContent' +import command from '../commands/command' import clearNodes from '../commands/clearNodes' import deleteSelection from '../commands/deleteSelection' import extendMarkRange from '../commands/extendMarkRange' @@ -43,6 +44,10 @@ export const Commands = Extension.create({ * Normalize nodes to a simple paragraph. */ clearNodes, + /** + * Define a command inline. + */ + command, /** * Delete the selection, if there is one. */