GithubHelp home page GithubHelp logo

Comments (7)

rangav avatar rangav commented on June 2, 2024 1

Thanks @FMorschel for reporting the bug, I will look into it.

from thunder-client-support.

rangav avatar rangav commented on June 2, 2024 1

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);

from thunder-client-support.

FMorschel avatar FMorschel commented on June 2, 2024 1

Done that!

from thunder-client-support.

FMorschel avatar FMorschel commented on June 2, 2024

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:
Failed to copy textNotAllowedError: Write permission denied.

from thunder-client-support.

FMorschel avatar FMorschel commented on June 2, 2024

It worked! Thanks! Could this be mentioned in the docs? I think this could be a great help for the extension users.

from thunder-client-support.

rangav avatar rangav commented on June 2, 2024

Sure, also feel free to submit PR

https://docs.thunderclient.com/testing/chart-view

from thunder-client-support.

rangav avatar rangav commented on June 2, 2024

Thanks for the PR

from thunder-client-support.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.