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

feat: Custom inline equation using the BlockNote API #1022

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jkcs
Copy link
Contributor

@jkcs jkcs commented Aug 22, 2024

API Extension Changes:

  1. Pass the Tiptap node to props for inline content to access node attr, nodeSize, etc.
  2. Allow custom renderHTML implementation for inline content (in this case, to address copying issues)"

Link

Copy link

vercel bot commented Aug 22, 2024

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

Name Status Preview Updated (UTC)
blocknote ❌ Failed (Inspect) Aug 26, 2024 0:03am

Copy link

vercel bot commented Aug 22, 2024

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

A member of the Team first needs to authorize it.

@YousefED
Copy link
Collaborator

Thanks! The UX of this looks great. I hope to dive into the code coming week. I'd like to research what API surface we'd need to add so this can be built using purely the BlockNote API (and not TipTap internals). Will keep you posted, but lmk in case you have suggestions for this!

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.

Great stuff. This example shows where the BN API is lacking and is a great starting point to improve it.

I've implemented an isSelected prop (see 519f34a) and made inline content selectable to make the logic a lot easier. We now don't need to listen for "cursor edge keyboard navigations" anymore, but can let prosemirror handle this.

Let me know what you think @jkcs! Do you see any new bugs popping up with the new approach?

There are a couple of todos left with this new approach:

  • Make sure the formatting toolbar doesn't show
  • Research if there are any other downsides / side effects (for example for other examples) of setting selectable: true. Should we make this configurable or not?
  • Implement remaining APIs (marked as TODO in code)
  • Review RenderHTML (@jkcs see my PR comment about copying)

},
content: "none",
// copy content
renderHTML: (props) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What were the exact issues you were having with copying without the renderHTML?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

copy of image clipboard should be c = \pm\sqrt{a^2 + b^2}

@jkcs
Copy link
Contributor Author

jkcs commented Aug 27, 2024

👍👍👍Extending isSelected is much better than before.

New bug: losing focus on input, need to keep isSelected as true.

Implement BlockNote API to add, remove, and edit inline content. For the tiptapApi, it requires 'pos'. Is there a way to operate based on the node rather than using 'pos' every time?

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.

2 participants