Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/expose-value-sync-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@portabletext/plugin-sdk-value": patch
---

feat(sdk-value): expose `ValueSyncPlugin`
2 changes: 1 addition & 1 deletion packages/plugin-sdk-value/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {SDKValuePlugin} from './plugin.sdk-value'
export {SDKValuePlugin, ValueSyncPlugin} from './plugin.sdk-value'
13 changes: 13 additions & 0 deletions packages/plugin-sdk-value/src/plugin.sdk-value.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,25 @@ export function SDKValuePlugin(props: SDKValuePluginProps) {
)
}

/**
* @internal
*/
type ValueSyncConfig = {
getRemoteValue: () => PortableTextBlock[] | null | undefined
pushValue: (value: PortableTextBlock[]) => void
onRemoteValueChange: (callback: () => void) => () => void
}

/**
* NOTE: You are probably looking for SDKValuePlugin instead of this.
* This is a lower-level plugin that only handles syncing the value
* between the editor and a remote source. It does not know anything
* about Sanity documents or how to fetch/update them.
*
* May be removed in the future, do not rely on this directly.
*
* @internal
*/
export function ValueSyncPlugin(props: ValueSyncConfig) {
const {getRemoteValue, pushValue, onRemoteValueChange} = props
const editor = useEditor()
Expand Down
Loading