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(pte): create new text blocks if needed #6560

Merged
merged 2 commits into from
May 6, 2024
Merged

feat(pte): create new text blocks if needed #6560

merged 2 commits into from
May 6, 2024

Conversation

pedrobonamin
Copy link
Contributor

Description

This changes improve the editor experience by adding empty text blocks into PTE when needed.

A new block is added if the user is focused on the last block which is void, and clicks in the editor.

Adds.new.block.at.the.end.mov

A new block is added if the user is focused on the last block which is void, and presses arrow down.

Screen.Recording.2024-05-03.at.12.47.05.mov

A new block is added at the top, when pressing arrow up, because first block is void, the new block can be deleted with backspace.

Screen.Recording.2024-05-03.at.12.43.48.mov

What to review

Testing

Notes for release

Copy link

vercel bot commented May 3, 2024

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

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview May 3, 2024 4:58pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 3, 2024 4:58pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 3, 2024 4:58pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview May 3, 2024 4:58pm

Copy link
Contributor

github-actions bot commented May 3, 2024

No changes to documentation

Copy link
Contributor

github-actions bot commented May 3, 2024

Component Testing Report Updated May 3, 2024 5:03 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 37s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 7s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 20s 6 3 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 15s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 35s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 6s 15 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 6s 18 0 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 21s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 15s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 22s 9 0 0

Copy link
Contributor

@jtpetty jtpetty left a comment

Choose a reason for hiding this comment

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

This looks good to me, but would want @skogsmaskin to review as well. Thanks for writing so many tests for this fix.

onClick(event)
}
// Inserts a new block if it's clicking on the editor, focused on the last block and it's a void element
if (slateEditor.selection && event.target === event.currentTarget) {
Copy link
Contributor

Choose a reason for hiding this comment

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

PK will likely be the best person, but I wonder if this could be something that was moved to a normalise function :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Curious to that answer, but I think it's not possible. as this is handling the onClick event.
It tries to solve the action in which the user clicks below the void block and nothing is added, so he can't continue typing.
The first part of the video is current behaviour, second part is with the changes.

Screen.Recording.2024-05-06.at.14.09.42.mov

Copy link
Member

Choose a reason for hiding this comment

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

It's a timely question @RitaDias!

However in this case I think we don't want normalization. We want it to be tied to the UI-event of the user trying to click of move below with the intention of creating a new block.

We don't in all cases want it to always insert a empty block there (that would mean it's impossible to end a editor with an object block).

Copy link
Member

@skogsmaskin skogsmaskin left a comment

Choose a reason for hiding this comment

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

Cool! This is a nice addition to the UI.

@pedrobonamin pedrobonamin added this pull request to the merge queue May 6, 2024
Merged via the queue into next with commit cadd496 May 6, 2024
39 checks passed
@pedrobonamin pedrobonamin deleted the edx-1232 branch May 6, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants