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

Refactor Decorator ref system #1120

Merged
merged 4 commits into from
Jan 20, 2022
Merged

Refactor Decorator ref system #1120

merged 4 commits into from
Jan 20, 2022

Conversation

trueadm
Copy link
Collaborator

@trueadm trueadm commented Jan 19, 2022

This removes the current ref system for Decorators and replaces it with a DecoratorState system. Specifically, (for now at least), we have two types of DecoratorState - DecoratorEditor and DecoratorMap. This integrates these data structures into the existing implementations, both locally and for collaboration.

A follow up PR could introduce the DecoratorList data structure.

@vercel
Copy link

vercel bot commented Jan 19, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/fbopensource/lexical/9C3xWbjF2LF9B5ZY2QDC2mNmnRAB
✅ Preview: https://lexical-git-refactor-decorator-ref-system-fbopensource.vercel.app

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 19, 2022
@zurfyx
Copy link
Member

zurfyx commented Jan 20, 2022

I think I understand the idea. I would appreciate it if you could do us a walkthrough the code, especially around the NestedEditor and CollaborationPlugin bits to be able to properly review this

@trueadm trueadm requested a review from ryanisaacg January 20, 2022 12:17
Copy link
Contributor

@ryanisaacg ryanisaacg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me but obv would like someone with more experience to actually approve. Had a bunch of questions as I read through

.flowconfig Show resolved Hide resolved
packages/lexical-playground/craco.config.js Show resolved Hide resolved
Comment on lines +418 to +425
<MentionsPlugin />
<TablesPlugin />
<TableCellActionMenuPlugin />
<ImagesPlugin />
<LinkPlugin />
<EmojisPlugin />
<HashtagsPlugin />
<KeywordsPlugin />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we 'inherit' plugins from the outer editor? (is that desirable, is it possible, etc). Just thinking about divergence in plugin support between the 'main' editor and the caption editor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that's too desirable as it makes things less explicit and more magical. It should be clear what plugins are being used and which ones are not. Inheriting plugins blurs that someone.

packages/lexical-react/src/useLexicalDecoratorMap.js Outdated Show resolved Hide resolved
packages/lexical-react/src/useLexicalDecoratorMap.js Outdated Show resolved Hide resolved
@fantactuka
Copy link
Contributor

General question regarding decoratorMap: are values can only be primitives or it can be a nested map/array but it just won't be resolved granularly (recursively) between clients, and latest update will rewrite whole value?

@acywatson
Copy link
Contributor

I think I understand the idea. I would appreciate it if you could do us a walkthrough the code, especially around the NestedEditor and CollaborationPlugin bits to be able to properly review this

I had the same thought - I think a walkthrough would be great. I think I get the intent, overall, though.

@trueadm
Copy link
Collaborator Author

trueadm commented Jan 20, 2022

@fantactuka only primitive values because of JSON/collab. You can nest DecoratorMap inside DecoratorMap, and once I add DecoratorList, that too. I'll need to wire up the parts more for collab, so you can look at this PR to not be definitive. More PRs to go!

@trueadm
Copy link
Collaborator Author

trueadm commented Jan 20, 2022

If anyone would like me to walk through this with them (I already did with Gerard) please schedule some time in my calendar to do so :)

@fantactuka
Copy link
Contributor

If anyone would like me to walk through this with them (I already did with Gerard) please schedule some time in my calendar to do so :)

Scheduled some time tomorrow morning, if anyone else is interested - lmk I'll add to the invite

@trueadm trueadm merged commit 10582e3 into main Jan 20, 2022
@trueadm trueadm deleted the refactor-decorator-ref-system branch January 20, 2022 18:12
@ryanisaacg
Copy link
Contributor

@fantactuka would appreciate being added to that invite!

acywatson pushed a commit that referenced this pull request Apr 9, 2022
* Refactor Decorator ref system

* Fix typo

* Address feedback

* Address feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants