GithubHelp home page GithubHelp logo

Comments (2)

ddooley avatar ddooley commented on July 18, 2024

I tried various experiments in adding a "Paste" option in right click menu. Normally Paste menu item is disabled because Handsontable doesn't think there's anything in its clipboard (self.clipboardCache), but that's because that is not directly connected to system clipboard, which has to be read separately
via navigator.clipboard.readText() or navigator.clipboard.read() -> both of which are asynchronous calls which make getting at what system clipboard contains in the moment quite complicated. I set disabled to false just to test various possibilities of getting at system clipboard. Possibly other browser permissions have to be asked for by code as mentioned in https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard

  contextMenu: [
      'copy',
      'cut',
      {
        key: 'paste',
        name: 'Paste',
        disabled: function () {
          /* if (self.clipboardCache.length === 0) {
            var test = navigator.clipboard.readText();
            self.clipboardCache = test;
            console.log("nav1", self.clipboardCache);
            .then((stuff) => self.clipboardCache = ...) navigator.clipboard.readText();
            // try dummy read write text to somewhere? 

          }*/
          return false; //self.clipboardCache.length === 0;
        },
        callback: function () {
          var plugin = this.getPlugin('copyPaste');

          this.listen();
          // BUG: It seems like extra lf is added by sheetclip, causing
          // empty last row to be added and pasted. Exception is pasting
          // of single empty cell
          /*
          if (self.clipboardCache.length === 0) {
            const text = await navigator.clipboard.readText(); //AWAIT isn't allowed here.

            console.log("test", test);
            self.clipboardCache = self.sheetClip.parse(test);
            console.log("nav2", self.clipboardCache);
          };
          */
          if (self.clipboardCache.length > 0)
            self.clipboardCache = self.clipboardCache.slice(0, -1);
          plugin.paste(self.clipboardCache);
        },
      },
      'remove_row',
      'row_above',
      'row_below',
    ],

from dataharmonizer.

ddooley avatar ddooley commented on July 18, 2024

I have a hack solution for this that seems to be working, via date field right-click menu paste option. Only drawback is no ctrl-v for pasting on that particular type of field. Uploading shortly.

from dataharmonizer.

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.