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: Extract plugins/nodes from playground to a new @lexical/react-plugins package #2791

Open
echarles opened this issue Aug 8, 2022 · 9 comments
Labels
discussion enhancement Improvement over existing feature

Comments

@echarles
Copy link
Contributor

echarles commented Aug 8, 2022

It sounds logical to not expose the playground plugins (mention, equation,...) directly from the Playground. Although it would make sense to have them somewhere so they can be reused. Some of the playground plugins/nodes could be moved into a separated package (@lexical/react-plugins) and reused by the playground, or anyone else.

This would be also a way to address (in a way) developer requests for unstyled components, as those plugins/nodes ready to be consumed should be usable with any widget toolkit/theming solution.

Please add your thumb-up if you think this would benefit to you and to the community.

@echarles echarles added the enhancement Improvement over existing feature label Aug 8, 2022
@GermanJablo
Copy link
Contributor

Before you, I remember that at least one other person has proposed the same thing on Discord.
Consider this comment also a +1 from me.

Also, I really like the idea of what TinyMCE do on their website: a plugin store where the official ones are and the community can also upload their own.

@echarles
Copy link
Contributor Author

echarles commented Aug 8, 2022

Before you, I remember that at least one other person has proposed the same thing on Discord.
Consider this comment also a +1 from me.

Yes, I have been talking about that on Discord today. Did someone else discuss that before?

Also, I really like the idea of what TinyMCE do on their website: a plugin store where the official ones are and the community can also upload their own.

That may be an idea to consider, based also on the Discord discussion where the Meta team can not maintain and support all plugins users will ever need.

@echarles
Copy link
Contributor Author

echarles commented Aug 9, 2022

The @lexical/react package contains already a bunch of plugins (LexicalAutoEmbedPlugin, LexicalAutoFocusPlugin, LexicalAutoLinkPlugin...). I can see reason to not add the playground plugins in that core package, but worth to consider that.

As a user of the lexical library, the place where things are is not always easy to understand, although there are good reasons for that.

@GermanJablo
Copy link
Contributor

Did someone else discuss that before?

yes, https://discord.com/channels/953974421008293909/953974421486436393/983509523958472774

The @lexical/react package contains already a bunch of plugins (LexicalAutoEmbedPlugin, LexicalAutoFocusPlugin, LexicalAutoLinkPlugin...). I can see reason to not add the playground plugins in that core package, but worth to consider that.

In fact, I think that lexical-react should contain only the logic to be able to use lexical with react, and that each plugin should be in npm packages, to have separation of concepts and install only what one needs.

Seeing as how Acy liked the idea when you brought it up yesterday on Discord, I think the only thing missing is the execution.
I would like to have this, although it is not on my priority list. If it's up to me, maybe I can do the PR more at the end of the year.

@echarles
Copy link
Contributor Author

echarles commented Aug 9, 2022

In fact, I think that lexical-react should contain only the logic to be able to use lexical with react, and that each plugin should be in npm packages, to have separation of concepts and install only what one needs.

Agree, ideally @lexical/react would just to have the machinery needed to make lexical work with react. The effective plugins would be extracted from there.

Maybe a npm package per plugin will be overkill, hence the reason for a @lexical/react-plugins package which would contain the ones that are not important/large enough to live in their own separated package.

Seeing as how Acy liked the idea when you brought it up yesterday on Discord, I think the only thing missing is the execution. I would like to have this, although it is not on my priority list. If it's up to me, maybe I can do the PR more at the end of the year.

Same here, but I suspect my bandwidth will be too narrow to tackle it soon.

@ghost
Copy link

ghost commented Aug 14, 2022

I also think it would make sense to extract the plugins into a separate package and maybe even packages, so that users only take what they need, and also easier for updating any said package, I am quite excited to see where lexical goes, but so far it looks good, let's just destructure everything properly for easier maintaining.

@acywatson
Copy link
Contributor

I also think it would make sense to extract the plugins into a separate package and maybe even packages, so that users only take what they need, and also easier for updating any said package, I am quite excited to see where lexical goes, but so far it looks good, let's just destructure everything properly for easier maintaining.

@ninecodes thanks for your comment and support :)

Can't we get most of the benefits of "take what you need" with proper tree-shaking of @lexical/react? Maybe the update story is simpler with more atomic packages. Just trying to to understand more about what people are looking for here.

@GermanJablo
Copy link
Contributor

I update this thread with some features that would allow Lexical to become a more modular library:

@coltisor
Copy link

Hi everyone,

In my recent Lexical RTE project, just as the OP, I found myself frequently copying code from the Lexical Playground, particularly for Toolbar and Link Editor functionalities. Recognizing that many of us might be doing the same, I decided to streamline the process. This led to the creation of the Lexical Toolkit, an open-source library designed to simplify our development workflows.

Check out the toolkit and consider contributing:

Features

  • Hooks: useLexicalToolbar, useHyperlinkEditor
  • Nodes: KeywordNode, $createKeywordNode, $isKeywordNode
  • Plugins: ControlledValuePlugin, DefaultValuePlugin, HyperlinkPlugin, KeywordPlugin, OnChangeContentPlugin, OnFocusOnBlurPlugin

This toolkit embodies the modularity and reusability we've discussed in this thread.

I value your feedback and contributions highly. Instead of copying code from the Lexical Playground, consider integrating it into the Lexical Toolkit and using it via our npm package. Together, we can make Lexical development more streamlined and easy!

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

No branches or pull requests

5 participants