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

Feature: Use markdown plugin without bundling Prismjs #5763

Open
canastro opened this issue Mar 26, 2024 · 1 comment
Open

Feature: Use markdown plugin without bundling Prismjs #5763

canastro opened this issue Mar 26, 2024 · 1 comment
Labels
enhancement Improvement over existing feature

Comments

@canastro
Copy link

Right now if you use the markdown plugin, even if you don't want to support "Code" blocks, you'll still endup with prismjs in your bundle.

Ideally this would be optional.

@canastro canastro added the enhancement Improvement over existing feature label Mar 26, 2024
@non25
Copy link

non25 commented Apr 10, 2024

Thanks for bringing this up! 👍

I see two problems here:

1️⃣
We can't provide our own stripped down nodes, since plugins like MarkdownShortcutsPlugin internally hard-depend on default nodes due to using node-related functions like $isCodeNode, or by adding transformers which we can't dependency-inject in the userland like we can inject nodes to the editor config.

So if we want pick some rich text functionality, we need to copypaste and strip down all rich text related plugins and their deps, which is really sadge.

2️⃣
Lexical packages are bundled and minified for production usage, making it really hard to use patch-package on CodeNode for example to strip down language-related code and thus prismjs.

I have a feeling that MarkdownShortcutsPlugin is the most common path for building editor variants users expect, so in the long run I think it makes sense to make it as barebones as possible in the base package and add the ability to extend it if needed.

Is there a way to monkey-patch prismjs in CodeNode in the userland in case user wants it, otherwise strip CodeNode of it by default?
That would probably be the easiest solution to implement.

...

Here's a dumb stripdown of CodeNode, because I don't understand what this does and why it requires stuff from CodeHighlightNode which is even more dependent on prismjs.

And here's the attempt to extract prismjs stuff outside CodeNode and add a function to dynamically inject it back in the userland if needed.

I didn't test it and it feels pretty dumb, but might give some inspiration to someone.

@trueadm sorry for tagging you directly, but I'm really curious how does this look from your pov and wanted to start a conversation somehow, which might not start at all if I don't tag. 😅

I don't see how we could improve tree-shaking and customizability of markdown plugin, in a sense that we might only want to add bold, italic, lists and that's it, without thinking how to dynamically inject all those things from the userland, and whether maintainers want to go that route at all. 🤷‍♂️

What I miss from lexical after working with it for two weeks+ is the ability to import more low-level stuff as functions instead of copy-pasting them from playground or lexical repo. 😁

Fx. I needed to add a toolbar, and basically what I had to do is to copy-paste considerable amount of playground code and patch it a bit with chatgpt so fx. clear formatting clears more things that it initially did. 😅

Thanks to everyone who works on lexical, you guys rock! 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement over existing feature
Projects
None yet
Development

No branches or pull requests

2 participants