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

Bug: solve code and quote break/return #244

Merged
merged 3 commits into from
Jul 24, 2023
Merged

Conversation

juliopavila
Copy link
Collaborator

Closes #231 #233

Description:

This PR introduces updates to the Draft.js editor for better handling of return key presses and pasted text blocks.

Changes:

  1. Handle Return Key: We have updated the way the return key is handled. Now, when the user presses shift + return, a soft line break is inserted, allowing them to continue in the same block. If only the return key is pressed without shift, a new paragraph block is created. This was achieved by creating a custom useHandleReturn hook.

  2. Handle Pasted Text: We've added a new feature that treats pasted multi-line text as a single block, rather than creating a new block for each new line. This ensures that large blocks of code or quotes pasted from an external source are kept intact as a single block. This was implemented with the useHandlePastedText hook.

How to Test:

  • For Return Key:

    • Press shift + return in the editor, it should insert a soft line break, keeping you in the same block.
    • Press return without shift, it should create a new paragraph block.
  • For Pasted Text:

    • Paste a multi-line text block into the editor, it should be treated as a single block.

Test

Screen.Recording.2023-07-24.at.11.53.20.AM.mov

These enhancements improve the user experience by allowing more control over the text formatting and structure.

@vercel
Copy link

vercel bot commented Jul 24, 2023

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

Name Status Preview Comments Updated (UTC)
tabula 🔄 Building (Inspect) Visit Preview Jul 24, 2023 6:10pm

Copy link
Collaborator

@cedricwaxwing cedricwaxwing left a comment

Choose a reason for hiding this comment

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

Nice work! A couple things I'm noticing though:

  1. When clicking hard return (just the return key, not with shift), the new block should always default to "paragraph" instead of the last active block (IE: quote, code snippet, etc).

  2. To make the code snippets fit a little better in the space and feel more consistent with their inline style relative, I think the code snippet styles can be modified a bit to be more similar to the inline snippet:

  • reduce outer padding from 1rem to 0.5rem
  • reduce font-size to 13px

Copy link
Collaborator

@cedricwaxwing cedricwaxwing 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, the only thing I'd say is that we should try to remove the 8px margin top property here since it's offsetting the text:
image

@juliopavila juliopavila merged commit b568f5b into tabula-v.2.1 Jul 24, 2023
3 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jul 24, 2023
@juliopavila juliopavila deleted the issue-#231-#233 branch May 28, 2024 20:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants