Closed BOBONA closed 7 months ago
I figured out a solution, although it is extremely hacky.
The issue here is that I find myself needing to construct new Deltas throughout my code. While Quill.import enables this, it seems to be at the cost of SSR (specifically the import { Quill }).
The solution is to simply not construct new Deltas. If you want a new Delta, use a function like this
export const makeEmptyDelta = (editor: ReactQuill | null) => {
return editor?.getEditor().clipboard.convert("");
};
Now you can get away with using Deltas fully and only importing the type.
I've seen many issues discussing the problems that arise when using react-quill with NextJS, however none of them seem to address more involved situations.
The most basic issue, "document is not defined," can be solved in NextJS with dynamic imports.
Notice that I import from my own file "quill-dynamic" instead of "react-quill." This appears to be necessary to use forwardRefs.
// Incredibly hacky but necessary to allow for forward refs afaik export default function QuillForwardRefWrapper({ forwardRef, ...props }: React.ComponentProps & { forwardRef: React.RefObject }) {
return <ReactQuill ref={forwardRef} {...props} />
}
I would really appreciate some help figuring this out. I've seen issues mentioning Deltas and SSR separately but none together. I've tried a lot of random things but cannot get this working.
Here's my full simplified example: