You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently working on a React app where I need to implement paste detection in an MDXEditor component. However, MDXEditor does not provide a native onPaste event, so I tried a workaround.
I subscribed to currentSelection$ to track selection changes inside the editor and used addEventListener("paste", ...) to detect when a paste event occurs anywhere on the page. Inside handlePaste, I checked if the currentSelection was active and called the onPaste callback.
Despite these efforts, currentSelection is always undefined, and the detection isn't working as expected. Since this is my first time using this library, I’m unsure if there's a more efficient way to implement paste detection.
Here is my code:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am currently working on a React app where I need to implement paste detection in an MDXEditor component. However, MDXEditor does not provide a native onPaste event, so I tried a workaround.
I subscribed to currentSelection$ to track selection changes inside the editor and used addEventListener("paste", ...) to detect when a paste event occurs anywhere on the page. Inside handlePaste, I checked if the currentSelection was active and called the onPaste callback.
Despite these efforts, currentSelection is always undefined, and the detection isn't working as expected. Since this is my first time using this library, I’m unsure if there's a more efficient way to implement paste detection.
Here is my code:
Beta Was this translation helpful? Give feedback.
All reactions