Skip to content

fix(markdown-shortcut): respect plugin order for shortcuts - #1000

Open
HawkForge wants to merge 1 commit into
mdx-editor:mainfrom
HawkForge:fix/markdown-shortcut-plugin-order
Open

HawkForge wants to merge 1 commit into
mdx-editor:mainfrom
HawkForge:fix/markdown-shortcut-plugin-order

Conversation

@HawkForge

Copy link
Copy Markdown

Fixes #620. Thanks to @MichielvanBeers for the report and the clear repro.

markdownShortcutPlugin read activePlugins$ once, inside init(). RealmWithPlugins runs init in array order, so plugins listed after it (quotePlugin, headingsPlugin, ...) had not registered yet, and their shortcuts were missing from the transformers.

MarkdownShortcuts now reads activePlugins$ with useCellValue and rebuilds its memoised transformers when the value changes, so plugin order no longer matters.

The new test in src/test/markdown-shortcut.test.tsx initializes markdownShortcutPlugin before quotePlugin and headingsPlugin and asserts that the quote and heading transformers are present. It fails without the change. npx vitest --run passes, and npm run typecheck, eslint and prettier are clean on the changed files.

@MichielvanBeers

Copy link
Copy Markdown

Thank you @HawkForge!

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

[BUG] Quote shortcode '>' only works if quotePlugin is initialized before markdownShortcutPlugin()

2 participants