-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permission Issue with navigator.clipboard.writeText
in Chart
view
#1513
Labels
feature request
New feature or request
Comments
Testing script: var html = `
<div id="container"></div>
<script>
// get the container element
let container = document.getElementById("container");
// Create a new button element
var button = document.createElement('button');
button.innerHTML = 'Copy to clipboard';
// Add an event listener for the click event
button.addEventListener('click', function() {
// Use the Clipboard API to write text
navigator.clipboard.writeText('test').then(function() {
// Create a new paragraph element
var p = document.createElement('p');
p.innerHTML = 'Text copied to clipboard';
// Append the paragraph to the body of the document
document.body.appendChild(p);
}).catch(function(error) {
// Create a new paragraph element
var p = document.createElement('p');
p.innerHTML = 'Failed to copy text' + error;
// Append the paragraph to the body of the document
document.body.appendChild(p);
});
});
// Append the button to the body of the container
container.appendChild(button);
</script>
`
tc.chartHTML(html); Exact error: |
Thanks @FMorschel for reporting the bug, I will look into it. |
In Iframe clipboard is not allowed. Use below code instead. parent.postMessage( {command: 'copy-text', "text": "textdatatocopy"}); Below is updated code var html = `
<div id="container"></div>
<script>
// get the container element
let container = document.getElementById("container");
// Create a new button element
var button = document.createElement('button');
button.innerHTML = 'Copy to clipboard';
// Add an event listener for the click event
button.addEventListener('click', function() {
// Use the Clipboard API to write text
try{
parent.postMessage({command:'copy-text', "text": "textdata"});
// Create a new paragraph element
var p = document.createElement('p');
p.innerHTML = 'Text copied to clipboard';
// Append the paragraph to the body of the document
document.body.appendChild(p);
} catch(error) {
// Create a new paragraph element
var p = document.createElement('p');
p.innerHTML = 'Failed to copy text' + error;
// Append the paragraph to the body of the document
document.body.appendChild(p);
}
});
// Append the button to the body of the container
container.appendChild(button);
</script>
`
tc.chartHTML(html); |
It worked! Thanks! Could this be mentioned in the docs? I think this could be a great help for the extension users. |
Sure, also feel free to submit PR |
Done that! |
Thanks for the PR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please describe feature/problem details and the solution you'd like.
After looking at #511 I've done some testing and it seems that there is a bug where I can not run a
navigator.clipboard.writeText
. It says there is no permission for it. I'd like to be able to create a column in my table with a button for me to copy the data for that specific row in a json format.Describe alternatives you've considered
Adding a new line to the table when clicking that and showing the full text as I want to copy so I can manually select it and copy it with the CTRL+C command.
Are you using the free version/paid version/trial:
I'm using the free version.
The text was updated successfully, but these errors were encountered: