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

Pasting issues #260

Closed
bjhess opened this issue Feb 7, 2025 · 7 comments · Fixed by #268
Closed

Pasting issues #260

bjhess opened this issue Feb 7, 2025 · 7 comments · Fixed by #268

Comments

@bjhess
Copy link
Contributor

bjhess commented Feb 7, 2025

With the recent improvements and bugfixes on pasting, it seems a new bug has appeared. On 0.16.3 I noticed weird behavior pasting with the TipTap YouTube extension (a paste leads to both the link and the embed appearing) and some odd behavior with our custom Markdown processing paste extension.

So I wondered if regular text pasted as expect? It appears not. You'll notice that the text in my example here gets pasted twice, and the duplicate version of the paste seems to have newlines stripped or something of that nature.

CleanShot.2025-02-06.at.19.25.33.mp4

I'm guessing if the text-pasting bug is fixed it will also resolve the bugs with pasting extensions.

Thank you!

@KonnorRogers
Copy link
Owner

🤔 perhaps these 2 need to return true, ill take a look.

@KonnorRogers
Copy link
Owner

Doh. never linked the lines, but i think i found the issue regardless.

Fix here:

#261

@bjhess
Copy link
Contributor Author

bjhess commented Feb 7, 2025

Unfortunately while now the double-paste of regular text is fixed, my paste-based extensions are now not functioning again. Is there anything I can provide to help troubleshoot the paste-based extension interruption?

@KonnorRogers
Copy link
Owner

KonnorRogers commented Feb 7, 2025

@bjhess ideally one of the failing extensions would help tremendously

@KonnorRogers KonnorRogers reopened this Feb 7, 2025
@bjhess
Copy link
Contributor Author

bjhess commented Feb 7, 2025

The failing extensions are:

If you need me to try to bring one or more of those into a Rhino branch, I can, but I might not be able to get to it until next week. Thank you!

@bjhess
Copy link
Contributor Author

bjhess commented Feb 11, 2025

I did try to add the YouTube extension to my fork of rhino-editor tonight, but I couldn't quite crack it. No errors, but the extension didn't seem to be doing anything, so I probably did it wrong.

@KonnorRogers
Copy link
Owner

@bjhess I think I know the problem now. I think I know whats happening.

https://prosemirror.net/docs/ref/#view.EditorProps.handlePaste

Can be used to override the behavior of pasting. slice is the pasted content parsed by the editor, but you can directly access the event to get at the raw content.

It seems like dispatching a custom event like im currently doing isn't the greatest way since the function is synchronous so no way to check defaultPrevented on events that are checked higher in the bubbling. So I think handlePaste is really bad for being compatible with other editors.

I think I need to move all the transforming code into a transformPastedHTML hook, and make sure it always runs last to allow plugins to override. In addition, rhino-paste can not be relied upon to actually handle paste operations like it does today in rhino, but rather, is just a way to know if a user pasted something. I think I have a clear path forward to fix this.

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 a pull request may close this issue.

2 participants