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

Update: ShadowRoot support #849

Merged
merged 7 commits into from
Jun 24, 2024

Conversation

dcadavez66
Copy link
Contributor

  1. Core package updated to ensure BlockNote can be used in ShadowRoots;
  2. pasteExtension.ts updated to also support image pasting into the editor;
  3. Updated version for the Arabic translation file;

TODO:The changes related to the first point primarily involve replacing the use of document with the root property, which can be either Document or ShadowRoot. This property is accessed from pmView. In files where pmView is not available, the root property should be accessed from _editor.tiptapEditor.view.root.
To ensure consistency and ease for future modifications, there should be a standardized method for accessing this value. This will enable everyone making future changes to use this standard method instead of directly accessing the document.

…s & added arabic translation & updated past extension to support pasting images
Copy link

vercel bot commented Jun 18, 2024

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

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Jun 24, 2024 7:04pm
blocknote-website ✅ Ready (Inspect) Visit Preview Jun 24, 2024 7:04pm

Copy link

vercel bot commented Jun 18, 2024

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

A member of the Team first needs to authorize it.

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! Thanks. Two questions:

  • can you move Arabic translations update and the Paste handler to separate PRs?
  • Can you remove the commented out old code? We don't want the old code as comments in the codebase, and we can just see the differences here on github

After this we'll double check that all references to document have indeed been updated to use view.root instead

// document.body.addEventListener("drop", this.onDrop, true);
this.pmView.root.addEventListener(
"drop",
this.onDrop as EventListener,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we make this work without the cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without the cast no, there is another way where we explicitly type it with the type of the handler. Like so:

this.pmView.root.addEventListener(
"drop",
(event: Event) => this.onDrop(event as DragEvent),
true
);

Let me know the one you prefer to keep as standard and I can do the necessary updates!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we also conditionally add the listeners only if view.root instanceof Document? Since shadow roots don't support listeners anyway

Copy link
Collaborator

@matthewlipski matthewlipski left a comment

Choose a reason for hiding this comment

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

Looks good! Just a few changes that need to be made and we can merge:) Also make sure to check the comment regarding event listener type casting

packages/core/src/api/parsers/utils.ts Outdated Show resolved Hide resolved
packages/core/src/extensions/SideMenu/SideMenuPlugin.ts Outdated Show resolved Hide resolved
// document.body.addEventListener("drop", this.onDrop, true);
this.pmView.root.addEventListener(
"drop",
this.onDrop as EventListener,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we also conditionally add the listeners only if view.root instanceof Document? Since shadow roots don't support listeners anyway

@matthewlipski
Copy link
Collaborator

I added most of the changes mentioned in my review, only thing left is the type casting comment! @dcadavez66 @YousefED

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.

None yet

3 participants