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

Add onPaste prop on web #238

Open
tomekzaw opened this issue Mar 20, 2024 · 0 comments
Open

Add onPaste prop on web #238

tomekzaw opened this issue Mar 20, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@tomekzaw
Copy link
Collaborator

Refactor these lines:

const originalAddEventListener = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function (eventName, callback) {
if (eventName === 'paste' && typeof callback === 'function') {
originalAddEventListener.call(this, eventName, function (event) {
if (divRef.current && divRef.current.contains(event.target as Node)) {
// pasting returns styled span elements as event.target instead of the contentEditable div. We want to keep the div as the target
Object.defineProperty(event, 'target', {writable: false, value: divRef.current});
}
callback(event);
});
} else {
originalAddEventListener.call(this, eventName, callback);
}
};

@tomekzaw tomekzaw added the enhancement New feature or request label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant