I can't nested code blocks (example, under a bullet point) like I can with some other blocks (like block quotes) #4727
Replies: 3 comments 1 reply
-
|
This happens because Plate's schema and plugin configuration treat code blocks as top-level block elements that can't be nested inside list items, while block quotes are allowed as children of lists. Even though the AI template uses the flexible List plugin (which lets you indent many block types), code blocks are still restricted by default and can't appear inside bullet points like block quotes can. This is due to how Plate's plugins define valid nesting and the use of the isStrictSiblings property, which prevents code blocks from being children of list items, but allows block quotes to nest "List plugin", "Code block", "Plugin rules", "Exit break". There's no built-in option to change this, but Plate's MarkdownPlugin does allow custom conversion rules if you want to experiment with supporting this structure yourself "Markdown plugin". To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
|
yeah but why is it that "Plate's schema and plugin configuration treat code blocks as top-level block elements that can't be nested inside list items" ? fundamentally what is preventing platejs from supporting that? it is very important for our use case that plate offers the flexibility to support cases like this one. |
Beta Was this translation helpful? Give feedback.
-
|
Plate treats code blocks as top-level blocks because of how its plugins and schema are designed. The Code Block plugin marks code blocks with isStrictSiblings: true, which means they can't be nested inside other block types like list items, and normalization logic enforces this structure. This setup is partly for consistency with Markdown/HTML and to support features like syntax highlighting and keyboard shortcuts, which expect code blocks to be independent blocks, not children of lists. The List plugin uses a flat structure where each indented block (including code blocks) is independent, not truly nested inside a list item, which is different from how block quotes are handled. This restriction isn't from Slate itself—it's a Plate design choice. In theory, you could customize Plate's plugins and normalization rules to allow code blocks inside list items, but it would require significant custom plugin work and careful handling of rendering and editing behaviors to avoid breaking existing features. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
in a Plate editor, I can't nest a code block to appear inside a bullet point, like I can with block quotes. why is that?
Reproduction URL
No response
Reproduction steps
render a platejs editor (I'm using the AI template) and try to nest a code block.Plate version
49.2.21
Slate React version
which ever version plate 49.2.21 uses ..
Screenshots
Logs
Browsers
No response
Beta Was this translation helpful? Give feedback.
All reactions