Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rehypePlugins不支持异步插件 #662

Open
Ryan2018-js opened this issue Sep 23, 2024 · 1 comment
Open

rehypePlugins不支持异步插件 #662

Ryan2018-js opened this issue Sep 23, 2024 · 1 comment

Comments

@Ryan2018-js
Copy link

当使用rehype-pretty-code提示Uncaught Error: runSync finished async. Use run instead

@jaywcjlove
Copy link
Member

@Ryan2018-js 无法帮助到您

vishwamartur added a commit to vishwamartur/react-md-editor that referenced this issue Nov 1, 2024
Related to uiwjs#662

Refactor `Markdown` component to support asynchronous plugins.

* **Markdown Component (`core/src/components/TextArea/Markdown.tsx`)**
  - Import `useState` from React.
  - Add `mdStr` state to manage the processed markdown string.
  - Refactor `useEffect` to handle asynchronous processing of markdown using `rehype().process`.
  - Update the return statement to use `mdStr` state.

* **Example Component (`www/src/Example.tsx`)**
  - Import `rehypePrettyCode`.
  - Add `rehypePrettyCode` to `previewOptions.rehypePlugins`.

* **Tests (`test/editor.test.tsx`)**
  - Add a test to verify that `MDEditor` supports asynchronous plugins.
  - Use an example async plugin that adds a class to the first node.
  - Verify that the class is added to the preview node after processing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants