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

fix(@sanity): _regenerateKeys so that the MarkDefs left are only those allowed #6989

Closed
wants to merge 6 commits into from

Conversation

RitaDias
Copy link
Contributor

@RitaDias RitaDias commented Jun 19, 2024

Description

Add fix for when PTE text is pasted from one input to another that it respects the allowed annotations

Before

Screen.Recording.2024-05-21.at.14.mp4

Testing

The added tests should be sufficient

  • Added tests to _regenerateKeys (test before normalization)
  • The normalization tests already test for the "after normalization" -> preserves other marks that apply to the spans

While the original issue was detected on copy paste, I don't think it is necessary to add a test to target that use case in particular. We would have seen this as an issue when creating a doc via the terminal for example.

Notes for release

Fixes issue where when PTE text was copy pasted always kept the original annotations regardless of the receiving PTE customization

Copy link

vercel bot commented Jun 19, 2024

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

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2024 11:22am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2024 11:22am
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2024 11:22am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2024 11:22am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2024 11:22am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Jun 20, 2024 11:22am

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Jun 19, 2024

Component Testing Report Updated Jun 20, 2024 11:30 AM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 44s 14 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 7s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 27s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 32s 11 7 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 9s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 52s 1 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 36s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 15s 20 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 5s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 7s 3 9 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) 1m 4s 21 0 0

@skogsmaskin
Copy link
Member

skogsmaskin commented Jun 20, 2024

@RitaDias - I'm wondering if it makes more sense to build you code into the normalizeBlock function in @sanity/block-tools. It's already doing the same for decorator marks, and I think your code would be a great addition to that function.

It's already being used for the pasted content.

@RitaDias
Copy link
Contributor Author

Member

Just had a chat with @skogsmaskin and it's best to keep it as it is since copy / pasting from PTE to anoter PTE doesn't run the normalizeBlock

@christianhg
Copy link
Contributor

@RitaDias , any chance I could get you to open this PR against https://github.com/portabletext/editor instead? Then we don't have to port these changes to that repo/package after #7001 has been merged.

Sorry for the inconvenience :(

@RitaDias
Copy link
Contributor Author

@RitaDias , any chance I could get you to open this PR against https://github.com/portabletext/editor instead? Then we don't have to port these changes to that repo/package after #7001 has been merged.

Sorry for the inconvenience :(

I'll do that :)

@RitaDias
Copy link
Contributor Author

Closing this, re-opened it on portabletext/editor#19 :)

@RitaDias RitaDias closed this Jun 20, 2024
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

3 participants