I have this code for paste:
navigator.clipboard.readText().then(
clipText => document.querySelector("#Note").innerText += clipText);
But it returns this error:
Uncaught TypeError: navigator.clipboard.readText is not a function
Reading clipboard on Firefox (version 94, nov 2021) doesn't seem to work and throws an error:
var promise = navigator.clipboard.readText();
// Uncaught TypeError: navigator.clipboard.readText is not a function
Documentation on MDN Web Docs suggests to grant permission via Permission API:
The "clipboard-read" permission of the Permissions API must be granted before you can read data from the clipboard.
But clipboard-read
doesnt seem to be supported:
navigator.permissions.query({ name: "clipboard-read" });
// Uncaught TypeError: 'clipboard-read' is not a valid value for enumeration PermissionName.
The only way to enable clipboard reading (and writing) is to enable dom.events.testing.asyncClipboard
on Firefox client:
about:config
in navigation bardom.events.testing.asyncClipboard
and set true