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

Support draft-js editor #11

Open
FSou1 opened this issue May 30, 2020 · 2 comments
Open

Support draft-js editor #11

FSou1 opened this issue May 30, 2020 · 2 comments

Comments

@FSou1
Copy link

FSou1 commented May 30, 2020

Greetings,

I've been using your package for inserting text into default textarea/input components and it works great.

Unfortunately, it doesn't work well at sites that use the draft-js editor (e.g. reddit or facebook).

Here is a workaround that works for draft-js.

Is there a chance to support this editor?

This is the minimum valuable code that inserts a text at cursor with draft-js:

function addTextToDraftJs(element, text) {
    var textEvent = document.createEvent('TextEvent');
    textEvent.initTextEvent ('textInput', true, true, null, text);                    
    element.dispatchEvent(textEvent);
}

addTextToDraftJs(document.activeElement, 'it works');

Thx.

@grassator
Copy link
Owner

Hello and thank you for creating an issue.

I would like to avoid having code that is there to fix compatibility with specific products. If it is possible to detect support for this way of inputting text in a browser, which seems doable, it could be used as the preferred method in those browsers. I'm happy to merge and release a new version if you (or somebody else) can make a corresponding pull request.

@rahulbansal16
Copy link

Is there a way to insert text into the content editable divs?

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

No branches or pull requests

3 participants