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

feat: migrate editor to prosekit #4855

Merged
merged 48 commits into from May 5, 2024
Merged

Conversation

ocavue
Copy link
Contributor

@ocavue ocavue commented Apr 21, 2024

What does this PR do?

Migrate the text editor from Lexical to ProseKit.

This is a draft PR and not all features are finished. See the list below for details.

Feature list

In this section I listed all features that I implemented in the PR. Each feature has a screen recording to show its behavior. Currently I show both the new ProseKit editor and the old Lexical editor for debugging and testing purpose. I will remove the Lexical editor once this PR is good enough.

Style text by keyboard shortcut (e.g. Command B)

Video
feature-inline-keyboard-shortcut.mp4

Style text by input rule (e.g. **bold**)

You can see a bug in the Lexical editor when typing ~~delete~~. This migration fixes it.

Video
feature-input-rule.mp4

Show a floating inline menu when text is selected

This is a new feature.

Video
feature-inline-menu.mp4

Mention picker

Video
feature-mention-menu.mp4

Emoji picker

Video
feature-emoji-menu.mp4

Link matching

Video

(HTTP links)

feature-link-matching.mp4

(Email links)

feature-email.mp4

There are various improvements for link matching compared to the previous Lexical editor. Now the link matching is more robust and it has similar behavior as Twitter's link matching.

Hashtag and Cashtag

Video
feature-hashtag.mp4

Cashtag was never implemented in the Lexical editor, so this would be a new feature.

Drag and drop to insert images

Video
feature-dnd-image.mp4

Related issues

Fixes # (issue)

HEY-106

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Enhancement (non-breaking small changes to existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Explanation of the changes

Copy link

vercel bot commented Apr 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
og 🛑 Canceled (Inspect) May 5, 2024 0:32am
web ✅ Ready (Inspect) Visit Preview May 5, 2024 0:32am

Copy link

vercel bot commented Apr 21, 2024

@ocavue is attempting to deploy a commit to the Hey Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

@bigint
Copy link
Member

bigint commented May 5, 2024

Screen.Recording.2024-05-05.at.11.24.26.AM.mov

Getting this now 🙇🏼

Try commenting on this post https://web-git-fork-ocavue-ocavue-prosekit-heyxyz.vercel.app/posts/0x05-0x0c-DA-c5acc0cc

@ocavue
Copy link
Contributor Author

ocavue commented May 5, 2024

Getting this now 🙇🏼

If the document is large, the serialization (editor data structure => HTML string => Markdown string) could be slow. That's why I added a 500ms debounce for serialization (code link).

However, because of this debounce, if you type something very fast and click the submit button immediately, the Markdown string is not ready yet. That's why you saw this error.

Let me think what's the best way to resolve it. Also let me know if you have any suggestions that fit your coding pattern.

Update: I removed the delay when the document is small. This should improve such cases. (Git commit link)

@bigint
Copy link
Member

bigint commented May 5, 2024

@ocavue One last thing i found is the mention dropdown not autoselecting the 0th index

Screen.Recording.2024-05-05.at.12.57.59.PM.mov

@bigint
Copy link
Member

bigint commented May 5, 2024

Screen.Recording.2024-05-05.at.12.59.47.PM.mov

The avatar in the composer causing some CLS

@ocavue
Copy link
Contributor Author

ocavue commented May 5, 2024

The avatar in the composer causing some CLS

Fixed. This issue is caused by the overflowing when there is a long word (like a long link) in the editor.

Before

Screenshot 2024-05-05 at 17 39 38

After

Screenshot 2024-05-05 at 17 43 43

@bigint
Copy link
Member

bigint commented May 5, 2024

Also for mention, lets not limit to first 3 chars, we can start searching from the first character similar to twitter or github

@bigint
Copy link
Member

bigint commented May 5, 2024

Hovering profile on mention dropdown should show cursor-pointer, RN it shows text selection cursor

@bigint
Copy link
Member

bigint commented May 5, 2024

Screen.Recording.2024-05-05.at.1.20.22.PM.mov

it should show the username and not the profile name 🙇🏼

@bigint
Copy link
Member

bigint commented May 5, 2024

LGTM so far :shipit:

LGTM

@bigint bigint merged commit 484abca into heyxyz:prosekit May 5, 2024
6 of 8 checks passed
@ocavue
Copy link
Contributor Author

ocavue commented May 5, 2024

One last thing i found is the mention dropdown not autoselecting the 0th index

Fixed.

image

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants