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 execCommand fallback for contenteditable support #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alecgibson
Copy link

At the moment, the plugin checks if the selected element has a value
property (eg is an <input>, <textarea> or similar).

However, many sites these days use contenteditable, which doesn't
necessarily have a value property.

This change adds a fallback: if the selected element doesn't have a
value property, we use execCommand to just insert some text,
which works with contenteditable.

At the moment, the plugin checks if the selected element has a `value`
property (eg is an `<input>`, `<textarea>` or similar).

However, many sites these days use [`contenteditable`][1], which doesn't
necessarily have a `value` property.

This change adds a fallback: if the selected element doesn't have a
`value` property, we use [`execCommand`][2] to just insert some text,
which works with `contenteditable`.

[1]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contenteditable
[2]: https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
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.

1 participant