Replies: 4 comments 2 replies
-
You can instantiate a new Crepe instance within the useEditor(
(root) =>
new Crepe({root}).editor); Something like the above should work in this case. |
Beta Was this translation helpful? Give feedback.
-
You can use crepe according to the way of milkdown website using it. Link In short, initiate the import { Crepe } from "@milkdown/crepe";
import { FC, useLayoutEffect, useRef } from "react";
const HomeEditor: FC<{ value: string }> = ({ value }) => {
const divRef = useRef<HTMLDivElement>(null);
const loading = useRef(false);
useLayoutEffect(() => {
if (!divRef.current) return;
loading.current = true;
const crepe = new Crepe({
root: divRef.current,
defaultValue: value,
features: {
[Crepe.Feature.CodeMirror]: false,
[Crepe.Feature.BlockEdit]: false,
},
});
crepe.create().then(() => {
loading.current = false;
});
return () => {
crepe.destroy();
};
}, [ value]);
return (
<div
ref={divRef}
className="crepe !h-80 overflow-auto rounded-2xl border border-nord-outline shadow dark:border-nord-outline-dark md:!h-[480px]"
/>
);
};
export default HomeEditor; |
Beta Was this translation helpful? Give feedback.
-
There is PR for this but it's not ready for merge yet: #1561 (comment) |
Beta Was this translation helpful? Give feedback.
-
Please follow https://milkdown.dev/docs/recipes/react#using-crepe |
Beta Was this translation helpful? Give feedback.
-
maybe useCrepe() hook is missing? https://milkdown.dev/docs/recipes/react
Beta Was this translation helpful? Give feedback.
All reactions