From c71851e14c3b5eb4a8a2ad423f5a36fec98d5320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Tue, 17 Nov 2020 14:38:42 +0100 Subject: [PATCH] add a command command --- packages/core/src/commands/command.ts | 5 +++++ packages/core/src/extensions/commands.ts | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 packages/core/src/commands/command.ts 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. */