How to use clipboard - 10 common examples

To help you get started, we’ve selected a few clipboard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / testpilot / testpilot / frontend / static-src / app / main.js View on Github external
initialize() {
    app.webChannel = webChannel;
    app.me = new Me();
    app.clipboard = new Clipboard('button');
    app.experiments = new ExperimentsCollection();

    app.pageManager = new PageManager({
      pageContainer: document.querySelector('[data-hook=page-container]')
    });

    app.experiments.fetch().then(() => app.me.fetch()).then(() => {
      app.me.updateEnabledExperiments(app.experiments);
      app.startRouter();
    }).catch((err) => {
      console && console.error(err); // eslint-disable-line no-console
      app.startRouter();
      app.router.redirectTo('error');
    });
  },
github Jam3 / hihat / test / fixtures / test-electron-builtins.js View on Github external
var clipboard = require('clipboard')
process.stdout.write(clipboard.readText() + '\n')

window.close()

// var clipboard = require('clipboard')

// var image = clipboard.readImage()
// var buffer = image.toPng()
// process.stdout.write(buffer)

// // close window
// window.close()
github ongaeshi / firelink / tests / test-commands.js View on Github external
exports.test_commands = function(test) {
  test.pass("Test Commands .....");

  // 先頭に戻す
  commands.setLinkFormIndex(0);

  // 前回の値でリンク生成
  commands.redoLink("redo test", {text: "TEXT", title: "TITLE", url: "http://www.example.jp"});
  test.assertEqual("TEXT\nhttp://www.example.jp", clipboard.get());

  // 全てのタブをリンク
  commands.allTabs("DUMMY", "%text%\\n%url%");
  test.assertEqual("\nabout:blank\n", clipboard.get());
  
  commands.allTabsSpace("DUMMY", "%text%\\n%url%");
  test.assertEqual("\nabout:blank\n\n", clipboard.get());

  // リンク種類を直接設定
  commands.setLinkFormIndex(0);
  test.assertEqual(0, fl.currentIndex());
  commands.setLinkFormIndex(1);
  test.assertEqual(1, fl.currentIndex());
  commands.setLinkFormIndex(2);
  test.assertEqual(2, fl.currentIndex());
  commands.setLinkFormIndex(3);
  test.assertEqual(3, fl.currentIndex());
  commands.setLinkFormIndex(500);
  test.assertEqual(3, fl.currentIndex());

  // Export
  commands.exportFromClipboard();
  // let text =
github peterflynn / xd-copy-css-code / main.js View on Github external
} else if (blur.brightnessAmount < 0) {
                css += `background-color: rgba(0, 0, 0, ${-num(blur.brightnessAmount / 100)});\n`;
            }

            // Fill opacity
            if (blur.fillOpacity > 0) {
                // This blends the shape's fill on top of the blurred background (fill itself is unblurred).
                // TODO: support this for solid & gradient fills by baking alpha (& brightnessAmount color) into fill!
                css += `/* (plus shape's fill blended on top as a separate layer with ${num(blur.fillOpacity * 100)}% opacity) */\n`;
            }
        } else {
            css += `filter: ${blur.blurAmount}px;\n`;
        }
    }

    clipboard.copyText(css);
//    console.log(css);
}
github kphillpotts / XDtoXF / src / main.js View on Github external
function handleSubmit(e, dialog, resources) {

    var clipText = resources.value;

    let clipboard = require("clipboard");
    clipboard.copyText(clipText);

    // Close the dialog, passing back data
    dialog.close(resources.value);
    // Prevent further automatic close handlers
    e.preventDefault();
  }
github vuejs-tips / compiler / src / index.js View on Github external
// Throw error message as Exception, so I can catch Vue compilation errors
console.error = function (msg) {throw msg}

// Vue.config.devtools = true
// Vue.config.debug = true

import './app'
import './style.css'

import Clipboard from 'clipboard/dist/clipboard'
new Clipboard('.copy')
github TevinLi / amWiki / lib / richPaste.js View on Github external
}
        //读取数据
        let imgbuffer = null;
        let ext = 'png';
        if (type === 'file') {
            filePath = filePath.substr(8);   //截去 file:/// 协议头
            try {
                imgbuffer = fs.readFileSync(filePath, 'binary');
                ext = filePath.split(/[?#]/)[0].match(/\.([^\.\/]*?)$/);
                ext = ext ? ext[1] : 'png';
            } catch (e) {
                callback && callback(false);
                return;
            }
        } else if (type === 'clip') {
            const img = clipboard.readImage();
            if (img.isEmpty()) {
                callback && callback(false);
                return;
            }
            imgbuffer = img.toPng();
        }
        //计算路径
        const [assetsDirPath, createDirPath, insertText] = this.getPastePaths();
        if (!assetsDirPath) {
            callback && callback(false);
            return;
        }
        //计算文件名
        let filename = '';
        //按天区分文件
        const date = new Date();
github WPTT / theme-sniffer / assets / dev / scripts / theme-sniffer.js View on Github external
setupClipboards() {
		let clipboards = document.querySelectorAll( this.reportItemBtn );

		// Create clipboard instance.
		this.clipboardInstance = new Clipboard( clipboards, {
			target: trigger => {
				return trigger.lastElementChild;
			}
		});

		// Clear selection after copy.
		this.clipboardInstance.on( 'success', event => {

			// Store current label.
			let currentLabel = event.trigger.parentElement.getAttribute( 'aria-label' );

			// Set copy success message.
			event.trigger.parentElement.setAttribute( 'aria-label', themeSnifferLocalization.copySuccess );

			// Restore label.
			$( event.trigger.parentElement ).mouseleave( () => {
github johannesjo / super-productivity / src / app / features / worklog / worklog-export / worklog-export.component.ts View on Github external
case 'TIME_STR':
            case 'TIME_CLOCK':
              return 'Worked';
            case 'ESTIMATE_MS':
            case 'ESTIMATE_STR':
            case 'ESTIMATE_CLOCK':
              return 'Estimate';
          }
        });

        this.txt = this._formatText(this.headlineCols, this.formattedRows);
      }
    }));

    // dirty but good enough for now
    const clipboard = new Clipboard('#clipboard-btn');
    clipboard.on('success', (e: any) => {
      this._snackService.open({
        msg: T.GLOBAL_SNACK.COPY_TO_CLIPPBOARD,
        type: 'SUCCESS'
      });
      e.clearSelection();
    });
  }
github ant-design / ant-design-mobile / site / common / clip.js View on Github external
componentDidMount() {
    // Support old API by trying to assign this.props.options first;
    let options = this.props.options || this.propsWith(/^option-/, true);
    this.clipboard = new Clipboard(`#${this.id}`, options);

    let callbacks = this.propsWith(/^on/, true);
    Object.keys(callbacks).forEach(function (callback) {
      this.clipboard.on(callback.toLowerCase(), this.props[`on${callback}`]);
    }, this);
  }