Skip to content

Add execCommand fallback for contenteditable support#7

Open
alecgibson wants to merge 1 commit intodrmmch:masterfrom
alecgibson:contenteditable
Open

Add execCommand fallback for contenteditable support#7
alecgibson wants to merge 1 commit intodrmmch:masterfrom
alecgibson:contenteditable

Conversation

@alecgibson
Copy link
Copy Markdown

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