Skip to content

Improve error handling for initialContent in BlockNoteEditor - #349

Closed
marwan37 wants to merge 1 commit into
TypeCellOS:mainfrom
marwan37:issue-342/initialContent-error-handling
Closed

Improve error handling for initialContent in BlockNoteEditor#349
marwan37 wants to merge 1 commit into
TypeCellOS:mainfrom
marwan37:issue-342/initialContent-error-handling

Conversation

@marwan37

Copy link
Copy Markdown

Description

The current implementation of BlockNoteEditor does not provide clear error messages when invalid initialContent is passed. This PR improves the error handling by adding more descriptive error messages and checks for required keys in block objects.

fixes: #342

Changes

  • Enhanced error messages in BlockNoteEditor.ts for invalid initialContent.
  • Introduced defaultInitialContent; initialContent defaults to this if checks fail.
  • Changed initialContent from const to let for reassignment (further guidance is appreciated if undesirable).

Testing

  1. When passing a string, e.g. initialContent = "abc":
initialContent-string

  1. When passing an array with non-object elements, e.g. initialContent = ["abc"]:
initialContent-notObject

  1. When passing an array of objects but keys are invalid, e.g. [{ someKey: "abc", id: "123123" }]:
initialContent-invalidKeys

@vercel

vercel Bot commented Sep 26, 2023

Copy link
Copy Markdown

@marwan37 is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better error handling for useBlockNote

1 participant