feat: refresh data client-side on preview updates
Types of changes
- [ ] Chore (a non-breaking change which is related to package maintenance)
- [ ] Bug fix (a non-breaking change which fixes an issue)
- [x] New feature (a non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Description
This PR allows a page to refresh its preview content without reloading the whole page. This happens when a document is edited + saved while a preview session is open.
When a document is published, the page will continue to perform a full refresh as it did before this PR. A full refresh is currently the only way to hide/reset the Prismic toolbar.
The changes in this PR should result in slightly quicker preview updates and a less jarring preview experience.
Checklist:
- [ ] My change requires an update to the official documentation.
- [x] All TSDoc comments are up-to-date and new ones have been added where necessary.
- [ ] All new and existing tests are passing.
🪸
Codecov Report
Merging #29 (b37ab54) into main (9527e85) will increase coverage by
0.00%. The diff coverage is100.00%.
@@ Coverage Diff @@
## main #29 +/- ##
=======================================
Coverage 99.84% 99.85%
=======================================
Files 11 11
Lines 661 668 +7
Branches 31 31
=======================================
+ Hits 660 667 +7
Partials 1 1
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/PrismicPreview.tsx | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 9527e85...b37ab54. Read the comment docs.
size-limit report 📦
| Path | Size |
|---|---|
| ./dist/index.cjs | 5.93 KB (+0.27% 🔺) |
| ./dist/index.js | 2.76 KB (+0.57% 🔺) |
This functionality has been built into PR #63.