tiptap
tiptap copied to clipboard
Support lowlight v2 in code block extension
What’s the bug you are facing?
Looks like lowlight changed module exports and extension-code-block-lowlight can't find listLanguages function
How can we reproduce the bug on our side?
Just install lowlight at least v2.4.0 Use official example
Can you provide a CodeSandbox?
https://codesandbox.io/s/elastic-goldwasser-7pkjp?file=/src/CodeBlockComponent.tsx
What did you expect to happen?
It should work
Anything to add? (optional)
No response
Did you update your dependencies?
- [X] Yes, I’ve updated my dependencies to use the latest version of all packages.
Are you sponsoring us?
- [ ] Yes, I’m a sponsor. 💖
This is how you have to import lowlight v2.x:
import { lowlight } from "lowlight";
Here is the updated codesandbox: https://codesandbox.io/s/trusting-lake-22hls
@cadars Any thoughts on why does the sandbox show Module '"lowlight"' has no exported member 'lowlight'.
Not really, but it looks like the error (hint?) disappears when importing this way instead:
import { lowlight } from "lowlight/lib/all.js";
Personally I only import the most common languages:
import { lowlight } from "lowlight/lib/common.js";
I think the solution to this problem is to register languages by installing highlight.js first.
@cadars I think that solves it, thanks!
i just ran into a similar problem. lowlight languages didn't show up in my "electron" build. (without any error messages and it did work in the test environment)
so i used @cadars way to import lowlight
import { lowlight } from "lowlight/lib/common.js";
and it worked.
thx!
Looking into the usage, there doesn't seem to be any compelling reason not to upgrade. This is an inconvenience for users to be sure in both extra code to override the lowlight version and in bundling to assert that only one version is packaged. For a light lift like this, could the maintainers comment on what is holding this upgrade up?
@cadars Any thoughts on why does the sandbox show
Module '"lowlight"' has no exported member 'lowlight'.
It's because its using an outdated type-declaration from @types/lowlight
instead of from lowlight
itself (lowlight declares its own types).
Currently @types/lowlight
is required by @tiptap/extension-code-block-lowlight
package, and definitely needs to be removed from the extension's dependency, else it can't be uninstalled.
This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 7 days