I am running a script from WebView2 to complete an online form - works great for the standard textarea using...
document.getElementById('fname').value = 'SomeName';
But will not work with the bootstap editor - sooo, I moved to copy and paste (and given the data is a Word document that would be better). I have tried...
let text = navigator.clipboard.readText(); text.then(txt => { document.getElementById('syn').value = txt; });
But that doesn't work either.
Any pointers would be appreciated.
=====================UPDATE========
I have also tried this...
const paste = document.getElementById('syn'); navigator.clipboard.readText().then((clipText) => (paste.innerText = clipText));
...and that too doesn't work.
I checked to see if clipboard access is supported in WebView2 and apparently it has been since July 2020. Perhaps I need to find a way to enable it? Did try pasting to an ordinary textarea that works by just setting the value, but not with pasting.
Turns out the editor is from Froala.
Access is view the textarea ID, so setting the value is
$('#TextAreaID').froalaEditor('html.set', 'The text I want to add');
Hope this helps someone else.