-
I have: when I try to override gfm plugin in crepe with this on ( + insertTaskListCommand) import { gfm } from '@milkdown/preset-gfm';
import { $command } from '@milkdown/utils';
import {
useNodeViewFactory,
usePluginViewFactory,
useWidgetViewFactory
} from '@prosemirror-adapter/react';
import { useMemo } from 'react';
import type { MilkdownPlugin } from '@milkdown/ctx';
import { listItemSchema } from '@milkdown/preset-commonmark';
/// A command to insert taskList.
export const insertTaskListCommand = $command(
'InsertTaskList',
ctx => () => (state, dispatch) => {
if (!dispatch) return true;
const { tr } = state;
const node = listItemSchema.type(ctx).createAndFill({ checked: false });
if (!node) return true;
dispatch(tr.replaceSelectionWith(node, true));
return true;
}
);
export const useGfmPlugin = () => {
const pluginViewFactory = usePluginViewFactory();
const nodeViewFactory = useNodeViewFactory();
const widgetViewFactory = useWidgetViewFactory();
const gfmPlugins: MilkdownPlugin[] = useMemo(() => {
return [gfm, insertTaskListCommand].flat();
}, [nodeViewFactory, pluginViewFactory, widgetViewFactory]);
return gfmPlugins;
}; Or is it possible to separate import type { FC } from 'react';
import { Crepe } from '@milkdown/crepe';
import { Milkdown, useEditor } from '@milkdown/react';
import '@milkdown/crepe/theme/common/style.css';
import '@milkdown/crepe/theme/frame.css';
import { useGfmPlugin } from '../src';
const markdown = `# Milkdown React Crepe`;
export const MilkdownEditor: FC = () => {
const gfmPlugin = useGfmPlugin();
useEditor(root => {
const crepe = new Crepe({
root,
defaultValue: markdown
});
crepe.editor.use(gfmPlugin);
return crepe;
}, []);
return <Milkdown />;
}; |
Beta Was this translation helpful? Give feedback.
Answered by
sytolk
Mar 11, 2025
Replies: 1 comment
-
I have found ToDo list command here: https://github.com/Milkdown/milkdown/blob/main/packages/crepe/src/feature/block-edit/menu/config.ts#L206 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
sytolk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have found ToDo list command here: https://github.com/Milkdown/milkdown/blob/main/packages/crepe/src/feature/block-edit/menu/config.ts#L206