Problem with java script - customizing Oxygen Web author !

Post here questions and problems related to editing and publishing DITA content.
mu258770
Posts: 157
Joined: Mon Aug 18, 2014 4:11 pm

Problem with java script - customizing Oxygen Web author !

Post 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
cristi_talau
Posts: 494
Joined: Thu Sep 04, 2014 4:22 pm

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

Post 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.
Post Reply