Skip to content
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

refactor: contentRef prop into useContent hook #789

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

matthewlipski
Copy link
Collaborator

@matthewlipski matthewlipski commented May 31, 2024

This PR removes the hacky fix used for the contentRef prop by refactoring it into a useContent prop. Now setting the editable element in a React block is done via this hook instead of the contentRef prop.

Closes #659

TODO: There are currently a pretty big problem in that because this uses a hook which runs asynchronously, exporting to HTML does not properly serialize the content.

Copy link

vercel bot commented May 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview May 31, 2024 4:30pm
blocknote-website ✅ Ready (Inspect) Visit Preview May 31, 2024 4:30pm

Copy link
Collaborator

@YousefED YousefED left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of questions (I think we should leave this improvement for a later cycle regardless though):

  • wdym with contentRef feels hacky? A hook is a different API but I wouldn't consider one to be more "hacky" than the other? Especially since the hook just returns a ref, so practically it comes down to the same thing right?
  • I suppose the benefit of this approach is that we can return more props (style and data-node-view-content) to the element?
  • Why do we need the data-node-view-content again / why didn't we need this before?
  • "hooks run async" -> this isn't the case. A hook is just the same as a regular function call. So the bug must be somewhere else

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.

Bug: Cannot add space at the end of a custom block's content
2 participants