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(portable-text-editor): new API method getFragment #5806

Merged
merged 2 commits into from
Feb 21, 2024

Conversation

skogsmaskin
Copy link
Member

@skogsmaskin skogsmaskin commented Feb 20, 2024

Description

This function will get the current selection in the editor as a Portable Text fragment.

See the included test for how it works.

What to review

That the changes look good.

Testing

See test

Notes for release

  • Portable Text Editor can now return a Portable Text fragment for the selected content.

@skogsmaskin skogsmaskin requested review from a team and pedrobonamin and removed request for a team February 20, 2024 20:12
Copy link

vercel bot commented Feb 20, 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 Feb 21, 2024 8:58am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2024 8:58am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Feb 21, 2024 8:58am

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Feb 20, 2024

Component Testing Report Updated Feb 21, 2024 9:03 AM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 38s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 7s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 15s 3 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 15s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 15s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 40s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ❌ Failed (Inspect) 33s 11 0 1
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 18s 18 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 16s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 25s 9 0 0

Copy link
Contributor

@pedrobonamin pedrobonamin left a comment

Choose a reason for hiding this comment

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

Great API! Thanks @skogsmaskin
What happens when we have a selection across multiple blocks? Could we add a test considering that.
Also, does it work across different children in the same block?

@skogsmaskin
Copy link
Member Author

Great API! Thanks @skogsmaskin What happens when we have a selection across multiple blocks? Could we add a test considering that. Also, does it work across different children in the same block?

Yes, it will be able to handle whatever selection is made in the editor and have that extracted to a fragment.

I agree that this would be great to have represented in the tests. I can add it.

This function will get the current selection in the editor as Portable Text fragment.
@skogsmaskin skogsmaskin force-pushed the feat/pte-get-fragment branch from 6c8ac88 to b294421 Compare February 21, 2024 08:53
@skogsmaskin
Copy link
Member Author

@pedrobonamin - I've added a new test that tests across blocks and also with Inline objects among the children.

@skogsmaskin skogsmaskin added this pull request to the merge queue Feb 21, 2024
Merged via the queue into next with commit f210112 Feb 21, 2024
40 checks passed
@skogsmaskin skogsmaskin deleted the feat/pte-get-fragment branch February 21, 2024 11:10
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.

2 participants