Page 1 of 1

Problem with java script - customizing Oxygen Web author !

Posted: Wed Nov 25, 2020 6:06 pm
by mu258770
Hi team,

We are using Oxygen Xml Web Author 20.1.1 and doing some customization. We are implementing a new feature in the Author mode which needs to read clipboard content and store in a variable using javascript. We tried different approaches but its failing for few browsers because of vulnerability issue.


1.) Compatible with MSIE browser but not working in others:
window.clipboardData.getData('Text');

2.) Compatible with Chrome and Edge( version 87.0 ) but not working in others:
navigator.clipboard.readText().then(text => {
console.log('Pasted content: ', text);
})
.catch(err => {
console.error('Failed to read clipboard contents: ', err);
});

3.) Compatible with Chrome and Edge( Version 44+ ) but not working in others:
document.addEventListener("paste", function(){
var clipText = event.clipboardData.getData('Text');
});

Could you please suggest any solution regarding this which can support all the browsers.

Regards,
Shabeer

Re: Problem with java script - customizing Oxygen Web author !

Posted: Wed Nov 25, 2020 11:17 pm
by cristi_talau
You are right - due to security restrictions imposed by the browser, JS code is usually not allowed to read clipboard content. An exception is during the user "paste" event.

If you manage to find different solutions that work on different browsers, you can link them together using some platform detection. Our built-in paste functionality leaves the user to paste the content and read it afterward. I am not sure if this applies in your case.

Anyway, we would be interested in what feature you are trying to implement. Maybe we can make the bulitin paste functionality customizable to cover that use-case.