From 9a315c241c10836e1906d0872c78d5a58b8c12eb Mon Sep 17 00:00:00 2001 From: cutls Date: Mon, 14 Oct 2019 00:52:33 +0900 Subject: [PATCH] about #141 clipboard --- app/js/platform/end.js | 7 ++----- app/js/platform/preload.js | 2 ++ app/main/system.js | 5 +++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/js/platform/end.js b/app/js/platform/end.js index 56ef9756..765abec7 100644 --- a/app/js/platform/end.js +++ b/app/js/platform/end.js @@ -81,11 +81,8 @@ $(document).on('click', 'a', e => { //コピー function execCopy(string) { - var temp = $("#copy"); - temp.val(string); - temp.select(); - var result = document.execCommand('copy'); - return result; + postMessage(["copy", string], "*") + return true; } function progshow(e) { if (e.lengthComputable) { diff --git a/app/js/platform/preload.js b/app/js/platform/preload.js index 1b277dd5..21270cef 100644 --- a/app/js/platform/preload.js +++ b/app/js/platform/preload.js @@ -59,6 +59,8 @@ onmessage = function (e) { ipc.send('nano', null); } else if (e.data[0] == "asReadComp") { ipc.send('sendMarkersComplete', null); + } else if (e.data[0] == "copy") { + ipc.send('copy', e.data[1]); } } //version.js diff --git a/app/main/system.js b/app/main/system.js index 739d6423..927c7b74 100644 --- a/app/main/system.js +++ b/app/main/system.js @@ -6,6 +6,7 @@ function system(mainWindow, dir, lang, dirname) { const fs = require("fs"); var JSON5 = require('json5'); var ipc = electron.ipcMain; + const clipboard = electron.clipboard; var tmp_img = join(app.getPath("userData"), "tmp.png"); var ha_path = join(app.getPath("userData"), "hardwareAcceleration"); var lang_path = join(app.getPath("userData"), "language"); @@ -209,5 +210,9 @@ function system(mainWindow, dir, lang, dirname) { e.sender.webContents.send('font-list', fonts_sorted); }); }); + //コピー + ipc.on('copy', (e, arg) => { + clipboard.writeText(arg) + }); } exports.system = system; \ No newline at end of file