BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

refactor: zod for props

Open YousefED opened this issue 4 months ago • 3 comments

Summary

This PR drops our custom schema for Block and Inline Content Props and uses Zod instead.

Rationale

  • Less "non-standard" code to maintain
  • Easier to explain in docs / to LLMs

Changes

Impact

Consumers using custom blocks would need to migrate

  • [ ] TODO: Determine if we want to accept old style props for backwards compatibility

Testing

Mostly by existing unit tests. TODO:

  • [x] build of examples doesn't pass. couldn't figure out the build errors for withMultiColumn and withPageBreak examples. Playing around with BlockNoteSchema vs CustomBlockNoteSchema. Perhaps @nperez0111 can help here?
  • [ ] Manual testing + code review. @matthewlipski can you help with this (after build + tests pass), and specifically the file blocks and anywhere where block type guards are used
  • [ ] add tests / example for more complex schemas (e.g.: a prop with a nested object). @matthewlipski can you help?
  • [ ] check compatibility with yjs, does it break with https://github.com/yjs/y-prosemirror/issues/116? (cc @nperez0111)
  • [ ] heading props / customization (marked as TODO)

Screenshots/Video

N/A

Checklist

  • [x] Code follows the project's coding standards.
  • [ ] Unit tests covering the new feature have been added.
  • [x] All existing tests pass.
  • [ ] Y: The documentation has been updated to reflect the new feature
  • [ ] Y: Review and add comments + followup work
  • [ ] All: validate this doesn't make typescript / IDE significantly slower when developing
  • [ ] All: Decide on zod as a dep or as a peer dep. Can we use standard schema?
  • [ ] Check remaining comments in https://github.com/TypeCellOS/BlockNote/pull/2111

Additional Notes

Future work:

  • [ ] Migrate style props as well?
  • [x] Refactor File Blocks / File Props?
  • [x] Remove / refactor "Partial" blocks as much as possible

YousefED avatar Oct 13 '25 04:10 YousefED