Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect iOS 8 Quicktype suggestion paste

For rich text editing I have a UIWebView where I load a local html content with some contenteditable div. When user is pressing some keys on keyboard I want to detect content changes within that div, resize it accordingly and scroll properly to position cursor above the keyboard.

I'm able to do this using onkeyup event handler:

<div id="contents" onkeyup="keyup()" onpaste="paste()" contenteditable="true">...</div>

In iOS 8 keyboard now has the Quicktype panel with some suggestion words to quickly paste into editable area. How to detect the action of pasting the suggestion text into div?

Event handler like onkeyup doesn't help as the text is pasted without pressing keyboard buttons, onpaste event is not get called. I also tried to implement MutationObserver to detect DOM changes when something is pasted - doesn't help too.

I'm struggling trying to find the working solution. Any advice is appreciated. Thanks!

like image 208
xZenon Avatar asked Oct 31 '22 15:10

xZenon


1 Answers

In Mobile Safari the iOS 8 Quicktype words fire two (maybe identical?) input events.

Try this in the developer console:

$('input[type=text]').on("input", console.log.bind(console, "input!"));

In UIWebView I have not tried...

like image 112
Semmel Avatar answered Nov 13 '22 17:11

Semmel