copy image to clipboard #715

This commit is contained in:
cutls 2022-10-10 15:08:57 +09:00
parent dff544c3d2
commit 49c78d2263
10 changed files with 51 additions and 20 deletions

View File

@ -79,6 +79,8 @@ onmessage = function(e) {
ipc.send('sendMarkersComplete', null)
} else if (e.data[0] == 'copy') {
ipc.send('copy', e.data[1])
} else if (e.data[0] == 'copyBinary') {
ipc.send('copyBinary', e.data[1])
} else if (e.data[0] == 'log') {
ipc.send('log', e.data[1])
} else if (e.data[0] == 'twitterLogin') {

View File

@ -78,7 +78,7 @@ function imgCont(type) {
function imageXhr(id, key, murl) {
let time = 0
var startTime = new Date()
const timer = setInterval(function() {
const timer = setInterval(function () {
time = time + 1
$('#imgsec').text(time)
}, 10)
@ -343,3 +343,13 @@ function copyImgUrl() {
execCopy(murl)
M.toast({ html: lang.lang_img_copyDone, displayLength: 1500 })
}
async function copyImgBinary() {
var murl = $('#imagemodal').attr('data-original')
const blob = await (await fetch(murl)).blob()
const reader = new FileReader()
reader.onloadend = function () {
postMessage(['copyBinary', reader.result], '*')
M.toast({ html: lang.lang_imgBin_copyDone, displayLength: 1500 })
}
reader.readAsDataURL(blob)
}

View File

@ -7,6 +7,7 @@ function system(mainWindow, dir, lang, dirname) {
var JSON5 = require('json5')
var ipc = electron.ipcMain
const clipboard = electron.clipboard
const nativeImage = electron.nativeImage
var tmp_img = join(app.getPath('userData'), 'tmp.png')
var ha_path = join(app.getPath('userData'), 'hardwareAcceleration')
var wv_path = join(app.getPath('userData'), 'webview')
@ -255,6 +256,10 @@ function system(mainWindow, dir, lang, dirname) {
ipc.on('copy', (e, arg) => {
clipboard.writeText(arg)
})
ipc.on('copyBinary', (e, arg) => {
const ni = nativeImage.createFromDataURL(arg)
clipboard.writeImage(ni)
})
//ログ
ipc.on('log', (e, arg) => {
var today = new Date()

View File

@ -14,6 +14,7 @@
<span id="imgprog"></span>% <br />
<span id="imgsec"></span>ms <br /><span id="imgbyte"></span>KB
</div>
<span style="padding: 0.6rem" class="btnsgroup">
<a class="waves-effect white-text" onclick="zoom(2)">
<i class="material-icons">zoom_in</i>
</a>
@ -23,9 +24,16 @@
<a class="waves-effect white-text" onclick="rotate(false)">
<i class="material-icons">rotate_90_degrees_ccw</i>
</a>
<button class="btn waves-effect blue" onclick="copyImgUrl()" title="@@copyURL@@">
</span>
<span style="padding: 0.6rem" class="btnsgroup">
<span style="position: relative; top: -2px;">Copy:</span>
<a class="waves-effect white-text" onclick="copyImgBinary()" title="@@copyBinary@@">
<i class="material-icons">image</i>
</a>
<a class="waves-effect white-text" onclick="copyImgUrl()" title="@@copyURL@@">
<i class="material-icons">link</i>
</button>
</a>
</span>
<button class="btn waves-effect purple" onclick="dlImg()">
<i class="material-icons">file_download</i>
</button>

View File

@ -73,6 +73,7 @@
"favRegist": "Favourite",
"openBrowser": "Open in browser",
"screenshot": "Take a screenshot",
"copyBinary": "Copy raw image",
"copyURL": "Copy the URL",
"copy": "Copy",
"embed": "Embed",

View File

@ -127,6 +127,7 @@
"lang_tl_postmarkers_title": "Process...",
"lang_tl_postmarkers": "POST markers data. Please wait",
"lang_img_DLDone": "Downloaded:",
"lang_imgBin_copyDone": "Copied: raw data of this image",
"lang_img_copyDone": "Copied: URL of this image",
"lang_layout_gotop": "Go top of this column. When icon is red, this column cannot connect straming API. Please reload.",
"lang_layout_thisacct": "{{notf}} of this account",

View File

@ -71,6 +71,7 @@
"favRegist": "お気に入り",
"openBrowser": "ブラウザで開く",
"screenshot": "スクリーンショット",
"copyBinary": "画像をコピー",
"copyURL": "URLをコピー",
"copy": "コピー",
"embed": "埋め込む",

View File

@ -126,6 +126,7 @@
"lang_tl_postmarkers_title": "処理中",
"lang_tl_postmarkers": "未読マーカー送信してるしちょっと待ってな…",
"lang_img_DLDone": "ダウンロード先:",
"lang_imgBin_copyDone": "画像データをコピーしたで。",
"lang_img_copyDone": "画像のURLをコピーしたで",
"lang_layout_gotop": "一番上へ。アイコンが赤のときはストリーミングに接続できてへんしF5で再読込やってみて。",
"lang_layout_thisacct": "このアカウントの{{notf}}",

View File

@ -73,6 +73,7 @@
"favRegist": "お気に入り",
"openBrowser": "ブラウザで開く",
"screenshot": "スクリーンショット",
"copyBinary": "画像をコピー",
"copyURL": "URLをコピー",
"copy": "コピー",
"embed": "埋め込む",

View File

@ -128,6 +128,7 @@
"lang_tl_postmarkers_title": "処理中",
"lang_tl_postmarkers": "未読マーカーを送信しています。3秒以内に閉じられます。",
"lang_img_DLDone": "ダウンロード先:",
"lang_imgBin_copyDone": "画像データをコピーしました。",
"lang_img_copyDone": "画像のURLをコピーしました。",
"lang_layout_gotop": "一番上へ。アイコンが赤のときはストリーミングに接続できていません。F5等で再読込をお試し下さい。",
"lang_layout_thisacct": "このアカウントの{{notf}}",