Skip to content

Commit

Permalink
Including schema in reader/editor
Browse files Browse the repository at this point in the history
  • Loading branch information
cohitre committed Feb 15, 2024
1 parent 3a9e7c7 commit a046f43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/builders/buildDocumentEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import buildBlockConfigurationByIdSchema from './buildBlockConfigurationByIdSche
/**
* @typedef {Object} DocumentEditor
* @property DocumentEditorProvider - Entry point to the DocumentEditor
* @property DocumentConfigurationSchema - zod schema compatible with the value that DocumentReaderProvider expects
* @property Block - Component to render a block given an id
* @property useDocumentState - Hook that returns the current DocumentState and a setter
* @property useBlockState - Hook that returns the Block value and setter given an id
Expand Down Expand Up @@ -50,6 +51,7 @@ export default function buildDocumentEditor<T extends BaseZodDictionary>(blocks:
return {
useDocumentState,
useBlockState,
DocumentConfigurationSchema: schema,
Block: ({ id }: { id: string }) => {
const state = useBlockState(id);
if (state === null || !state[0]) {
Expand Down
2 changes: 2 additions & 0 deletions src/builders/buildDocumentReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import buildBlockConfigurationByIdSchema from './buildBlockConfigurationByIdSche
/**
* @typedef {Object} DocumentReader
* @property DocumentReaderProvider - Entry point to the DocumentReader
* @property DocumentConfigurationSchema - zod schema compatible with the value that DocumentReaderProvider expects
* @property Block - Component to render a block given an id
* @property useDocument - Hook that returns the current Document
* @property useBlock - Hook that returns the block given an id
Expand Down Expand Up @@ -38,6 +39,7 @@ export default function buildDocumentReader<T extends BaseZodDictionary>(blocks:
return {
useDocument,
useBlock,
DocumentConfigurationSchema: schema,
Block: ({ id }: { id: string }) => {
const block = useBlock(id);
if (!block) {
Expand Down

0 comments on commit a046f43

Please sign in to comment.