I'm trying to write a plugin to use TinyMCE's rich text editor with Puck, heavily based on the puck-rich-text package (which uses Lexicon). I'm stuck at the implementation of the useSelected hook, which in puck-rich-text is being used to make sure the Rich Text Editor is actually selected before dispatching the onChange event.
I can add my editor and add content to it, but when I save my page (or rather, when the page is normally loaded), an error is thrown:
TypeError: Cannot read properties of undefined (reading 'hasPast')
It seems that history is undefined when returned from useAppContext().
as i remember this error happens when u call usePuck hook outside of <Puck/> since this component returns the context provider so you can't consume the context outside of it
I'm trying to write a plugin to use TinyMCE's rich text editor with Puck, heavily based on the
puck-rich-text
package (which uses Lexicon). I'm stuck at the implementation of theuseSelected
hook, which inpuck-rich-text
is being used to make sure the Rich Text Editor is actually selected before dispatching theonChange
event.I can add my editor and add content to it, but when I save my page (or rather, when the page is normally loaded), an error is thrown:
It seems that
history
is undefined when returned fromuseAppContext()
.I've created a reproduction here that you can run. The instructions are in the README.