Replies: 2 comments 5 replies
-
@sytolk
export const useCallEditorCommand = () => {
const [loading, getEditor] = useInstance();
const onCallCommand = useCallback(<T,>(command: CmdKey<T>, payload?: T | undefined) => {
const editor = getEditor();
if (loading || !editor) {
return;
}
editor.action(callCommand(command, payload));
}, [loading, getEditor]);
return { onCallCommand };
} and.. call it: export const Menu: React.FC = () => {
const { onCallCommand } = useCallEditorCommand();
return (
<div>
<button onClick={() => onCallCommand(liftListItemCommand.key)}>Insert Task List</button>
</div>
)
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks @zgrybus but nothing happened if I call |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How can I add insertTaskListCommand here:
https://github.com/Milkdown/website/blob/main/src/components/playground-editor/editor-component/ListItem.tsx#L4
like this for diagram:
milkdown/packages/plugin-diagram/src/node.ts
Line 122 in aabeffa
Beta Was this translation helpful? Give feedback.
All reactions