-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[design-studio] Configure structure and document views
- Loading branch information
1 parent
521c9d9
commit 9bbcdd3
Showing
5 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {useEditState} from '@sanity/react-hooks' | ||
import React from 'react' | ||
|
||
export function JSONPreviewDocumentView(props: any) { | ||
const editState: any = useEditState(props.documentId, props.schemaType.name) | ||
|
||
return <pre>{JSON.stringify(editState.draft || editState.published, null, 2)}</pre> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import S from '@sanity/desk-tool/structure-builder' | ||
import {JSONPreviewDocumentView} from '../documentViews/jsonPreview' | ||
|
||
export const getDefaultDocumentNode = ({schemaType}) => { | ||
// Conditionally return a different configuration based on the schema type | ||
if (schemaType === 'author') { | ||
return S.document().views([ | ||
S.view.form(), | ||
S.view.component(JSONPreviewDocumentView).title('JSON') | ||
]) | ||
} | ||
|
||
return undefined | ||
} | ||
|
||
export default S.defaults() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare module 'part:*' | ||
declare module 'all:part:*' |