Skip to content

Commit

Permalink
refactor(structure): move DocumentPaneContext to singletons
Browse files Browse the repository at this point in the history
  • Loading branch information
binoy14 committed Apr 29, 2024
1 parent bef2ba2 commit 73cbcd1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/sanity/src/_singletons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export * from './presence/FormFieldPresenceContext'
export * from './router/RouterContext'
export * from './store/_legacy/ResourceCacheContext'
export * from './structure/components/pane/PaneContext'
export * from './structure/panes/document/DocumentPaneContext'
export * from './structure/StructureToolContext'
export * from './studio/activeWorkspaceMatcher/ActiveWorkspaceMatcherContext'
export * from './studio/addonDataset/AddonDatasetContext'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {createContext} from 'react'

import type {DocumentPaneContextValue} from '../../../../structure/panes/document/DocumentPaneContext'

/** @internal */
export const DocumentPaneContext = createContext<DocumentPaneContextValue | null>(null)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
type SanityDocumentLike,
type ValidationMarker,
} from '@sanity/types'
import {createContext} from 'react'
import {
type DocumentActionComponent,
type DocumentBadgeComponent,
Expand Down Expand Up @@ -85,6 +84,3 @@ export interface DocumentPaneContextValue {
footerAction: React.ReactNode
}
}

/** @internal */
export const DocumentPaneContext = createContext<DocumentPaneContextValue | null>(null)
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
useUnique,
useValidationStatus,
} from 'sanity'
import {DocumentPaneContext} from 'sanity/_singletons'

import {usePaneRouter} from '../../components'
import {structureLocaleNamespace} from '../../i18n'
Expand All @@ -51,7 +52,7 @@ import {
HISTORY_INSPECTOR_NAME,
INSPECT_ACTION_PREFIX,
} from './constants'
import {DocumentPaneContext, type DocumentPaneContextValue} from './DocumentPaneContext'
import {type DocumentPaneContextValue} from './DocumentPaneContext'
import {getInitialValueTemplateOpts} from './getInitialValueTemplateOpts'
import {type DocumentPaneProviderProps} from './types'
import {usePreviewUrl} from './usePreviewUrl'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {useContext} from 'react'
import {DocumentPaneContext} from 'sanity/_singletons'

import {DocumentPaneContext, type DocumentPaneContextValue} from './DocumentPaneContext'
import {type DocumentPaneContextValue} from './DocumentPaneContext'

/** @internal */
export function useDocumentPane(): DocumentPaneContextValue {
Expand Down

0 comments on commit 73cbcd1

Please sign in to comment.