Skip to content

Commit

Permalink
refactor(schema): allow for .components in block schema + ensure that…
Browse files Browse the repository at this point in the history
… the result has a name
  • Loading branch information
skogsmaskin committed Dec 20, 2022
1 parent 7aa1404 commit 5b5e878
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/@sanity/schema/src/sanity/validation/types/block.ts
Expand Up @@ -6,6 +6,7 @@ import {isJSONTypeOf} from '../utils/isJSONTypeOf'
const getTypeOf = (thing) => (Array.isArray(thing) ? 'array' : typeof thing)
const quote = (str) => `"${str}"`
const allowedKeys = [
'components',
'lists',
'marks',
'name',
Expand All @@ -17,8 +18,8 @@ const allowedKeys = [
'validation',
]
const allowedMarkKeys = ['decorators', 'annotations']
const allowedStyleKeys = ['title', 'value', 'blockEditor']
const allowedDecoratorKeys = ['title', 'value', 'blockEditor', 'icon']
const allowedStyleKeys = ['title', 'value', 'components']
const allowedDecoratorKeys = ['title', 'value', 'icon', 'components']

export default function validateBlockType(typeDef, visitorContext) {
const problems = []
Expand Down Expand Up @@ -49,11 +50,11 @@ export default function validateBlockType(typeDef, visitorContext) {
if (members) {
members = validateMembers(members, visitorContext, problems)
}

return {
...omit(typeDef, disallowedKeys),
marks,
styles,
name: typeDef.name || typeDef.type,
of: members,
_problems: problems,
}
Expand Down

0 comments on commit 5b5e878

Please sign in to comment.