-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(block-tools): enforce list support in schema #4985
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
No changes to documentation |
Component Testing Report Updated Oct 18, 2023 9:03 AM (UTC)
|
882e4f1
to
1a9f693
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @skogsmaskin – LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Left some small suggestions on code style.
let listStyle | ||
switch (listNodeTagName) { | ||
case 'ul': | ||
listStyle = 'bullet' | ||
if (enabledListTypes.includes('bullet')) { | ||
listStyle = 'bullet' | ||
} | ||
break | ||
case 'ol': | ||
listStyle = 'number' | ||
if (enabledListTypes.includes('number')) { | ||
listStyle = 'number' | ||
} | ||
break | ||
default: | ||
listStyle = 'bullet' | ||
listStyle = undefined | ||
} | ||
return listStyle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function seems a bit cumbersome to me after the conditionals were added, maybe we could simplify it?
if (listNodeTagName === 'ul' && enabledListTypes.includes('bullet')) {
return 'bullet'
}
if (listNodeTagName === 'ol' && enabledListTypes.includes('number')) {
return 'number'
}
return undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better! I've changed it, tnx!
const enabledListItem = resolveListItem(parentTag, options.enabledListTypes) | ||
if (!listItem || !el.parentNode || !HTML_LIST_CONTAINER_TAGS[parentTag]) { | ||
return undefined | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be moved down below the conditional, in order to not do unnecessary work:
const enabledListItem = resolveListItem(parentTag, options.enabledListTypes) | |
if (!listItem || !el.parentNode || !HTML_LIST_CONTAINER_TAGS[parentTag]) { | |
return undefined | |
} | |
if (!listItem || !el.parentNode || !HTML_LIST_CONTAINER_TAGS[parentTag]) { | |
return undefined | |
} | |
const enabledListItem = resolveListItem(parentTag, options.enabledListTypes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, changed this as well!
HTML lists should not be deserialized to list blocks if there is no such support in schema
HTML lists should not be deserialized to list blocks if there is no such support in schema
Description
This will make sure that HTML is not deserialized to list blocks where there is no such support in the given schema.
What to review
That pasting HTML lists into Portable Text will not produce any list blocks with the current schema:
Notes for release