feat(next): export default edit and live preview views #12772
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Exports the default
EditView
andLivePreviewView
from@payloadcms/next/views
. This will allow you to import these components into your own project and render them within your custom view.For example, if you wanted to swap live preview with the default edit view, you could do something like this:
Your custom live preview view would look something like this:
Followed by your custom edit view:
Bigger Picture
In the future we plan to make this even easier, as this is such a frequent request. Ideally, the
/preview
route doesn't exist at all, and the default edit view can switch between the two without re-routing to a different page entirely. This would mean that there is no need to wire up custom views to achieve the same functionality, and your selection would save to preferences.This would also completely avoid the
LeaveWithoutSaving
modal from popping up when you attempt to navigate to live preview with unsaved changes, which would be a huge win.