-
Notifications
You must be signed in to change notification settings - Fork 448
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
refactor(core): replace PortableTextEditor
with EditorProvider
#8040
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
No changes to documentation |
⚡️ Editor Performance ReportUpdated Wed, 18 Dec 2024 15:47:35 GMT
Detailed information🏠 Reference resultThe performance result of
🧪 Experiment resultThe performance result of this branch
📚 Glossary
|
67776c1
to
71409b1
Compare
Component Testing Report Updated Dec 18, 2024 3:44 PM (UTC) ✅ All Tests Passed -- expand for details
|
20ae17c
to
c85201f
Compare
d778000
to
8bb97de
Compare
71409b1
to
7237c8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Love to see different concerns being split into separate blocks like this. Thank you @christianhg!
`EditorProvider` is the new way of setting up the Portable Text Editor. It's going to be the way we document how to use standalone PTE and it's the way Create already uses PTE. It exposes all the new APIs that have been under development, and for now it's also 100% backwards compatible by the fact that: 1. No types or interfaces have been removed. 2. The old `usePortableTextEditor()` and `usePortableTextEditorSelection()` hooks are still exposed. 3. Static methods like `PortableTextEditor.addAnnotation(...)` still work (even though the `PortableTextEditor` React class isn't used to instantiate the editor anymore.) 3. You can hand-roll custom "plugins" to achieve backwards compatible behaviours like listening for a `value` prop change or forwarding a ref to the `PortableTextEditor` instance. This means that this change is a pure refactor that introduces no changes in functionality and no downstream breaking changes for customers configuring PTE.
7237c8d
to
d7c4945
Compare
I'm really happy to hear that! Unfortunately, I had to resolve a merge conflict so I'll need one more approval before this can get merged. |
* next: (68 commits) fix(deps): update dependency @sanity/icons to ^3.5.5 (#8105) fix(deps): update dependency @sanity/ui to ^2.10.12 (#8108) fix(deps): update dependency react-rx to ^4.1.10 (#8109) chore(deps): update dependency @sanity/tsdoc to v1.0.153 (#8107) chore(deps): update typescript-tooling (#8104) fix(deps): update dependency @sanity/icons to ^3.5.5 (#8106) feat(typegen): add support for astro (#8098) chore(deps): update dependency turbo to ^2.3.3 (#8099) fix(deps): Update dev-non-major (#8100) fix: `WebSocket is closed before the connection is established` warning (#8042) v3.68.1 fix(deps): update dependency @sanity/presentation to v1.19.13 (#8102) v3.68.0 fix: use consistent `framer-motion` semver range (#8094) refactor(core): replace `PortableTextEditor` with `EditorProvider` (#8040) fix: improve `SanityDefaultPreview` memoization (#8049) fix: tooltip position in announcements popup (#8092) fix: replace useMemo with useState (#8095) fix: replace unsafe `useMemo` with `useState` (#8047) fix: replace `React.createElement` with jsx runtime (#8043) ...
Description
EditorProvider
is the new way of setting up the Portable Text Editor. It'sgoing to be the way we document how to use standalone PTE and it's the way
Create already uses PTE.
It exposes all the new APIs that have been under development, and for now it's
also 100% backwards compatible by the fact that:
usePortableTextEditor()
andusePortableTextEditorSelection()
hooks are still exposed.
PortableTextEditor.addAnnotation(...)
still work (eventhough the
PortableTextEditor
React class isn't used to instantiate theeditor anymore.)
behaviours like listening for a
value
prop change or forwarding a ref tothe
PortableTextEditor
instance.This means that this change is a pure refactor that introduces no changes in
functionality and no downstream breaking changes for customers configuring PTE.
What to review
Does the code make sense and does everything PTE-related still work 👀
Testing
Existing test suite should be able to verify that things still work.
Notes for release
n/a