fix: ensure listItem and taskItem always start with paragraph + schema validation#3663
Open
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Open
fix: ensure listItem and taskItem always start with paragraph + schema validation#3663devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Conversation
This fixes issue #3640 where the Tiptap schema validation fails with 'Invalid content for node listItem' error. The ProseMirror schema requires listItem content to be 'paragraph block*', meaning it must start with a paragraph. The previous implementation could produce listItems that started with nested lists (bulletList, orderedList) which violates the schema. Changes: - Add ensure_starts_with_paragraph() helper function - Apply to convert_list_item() and convert_task_item() - Add test cases to verify the fix Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
✅ Deploy Preview for hyprnote-storybook canceled.
|
✅ Deploy Preview for hyprnote ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Encodes ProseMirror content rules (doc: block+, listItem: paragraph block*, taskItem: paragraph block*, blockquote: block+, etc.) in a Rust validate_tiptap_json() function. Adds 20+ tests that run diverse markdown inputs through md_to_tiptap_json and validate the output against these rules, catching any schema violation automatically. Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3640 - "Invalid content for node listItem" error.
The ProseMirror schema requires
listItemcontent to beparagraph block*(must start with a paragraph, followed by zero or more blocks). The previous markdown-to-tiptap conversion could producelistItemnodes that started with nested lists (bulletList,orderedList), which violates the schema and causes validation errors.Changes:
ensure_starts_with_paragraph()helper incrates/tiptap/src/from_md.rsconvert_list_item()andconvert_task_item()Updates since last revision
Added a Rust-side schema validation module (
crates/tiptap/src/validate.rs) to be fundamentally safer against this class of bugs. Instead of only patching individual cases, thevalidate_tiptap_json()function encodes ProseMirror content rules for all node types:docblock+listItem/taskItemparagraph block*bulletList/orderedListlistItem+taskListtaskItem+blockquoteblock+paragraph/headinginline*codeBlocktext*Added 20+ schema validation tests that run diverse markdown inputs (nested lists, empty list items, blockquotes with lists, deeply nested structures, etc.) through
md_to_tiptap_jsonand validate the output. Any future converter change that produces schema-invalid JSON will be caught by these tests.Review & Testing Checklist for Human
is_block_type/is_inline_typelists match your actual tiptap extensions — these are hardcoded invalidate.rsand won't auto-update if you add new node types to the editor.imageintentionally appears in both lists (tiptap treats it as block and inline depending on context).Recommended test plan:
Notes
list-item.ts,task-item.ts, etc.)validate_tiptap_jsonis exported publicly for potential runtime use, but currently only used in tests