portive / wysimark

The Wysiwyg Editor for Markdown: 100% CommonMark + GFM with Uploads and Image Resizing
Other
239 stars 41 forks source link

Plain JS version requires react? #62

Open DR-SzczepanKrol opened 8 months ago

DR-SzczepanKrol commented 8 months ago

Description Is the Plain JS (standalone) version workable at this moment?

When I try to run it I get the following error in the browser console:

Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
    at resolveDispatcher (react.development.js:1465:1)
    at useContext (react.development.js:1473:1)
    at emotion-element-43c6fea0.browser.esm.js:37:27 
    ...

Steps

  1. I installed the latest version of Wysimark ("@wysimark/standalone": "^3.0.20") with pnpm
  2. Added it to my script:
import { createWysimark } from "@wysimark/standalone"
...
createWysimark(myElement, {
  initialMarkdown: "# Hello World",
})

Expectation I would expect the plugin to run in it's most basic form

Environment

This library looks like an awesome solution for us (if it works), thanks for your work!

kyr0 commented 7 months ago

I needed this as well and did a "quick fix" using a re-packaging. The bundled version is not bundled correctly. I might PR here once I find a bit more time. Here is my temporary "hot fix" solution:

https://stackoverflow.com/questions/77578526/wysimark-on-plain-js/78225889#78225889