-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from hemengke1997/context
add context-menu for image copy
- Loading branch information
Showing
43 changed files
with
527 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { castArray } from '@minko-fe/lodash-pro' | ||
import { type CommonOptions, type Options, type SyncOptions, execa, execaSync } from 'execa' | ||
|
||
class UnClipboard { | ||
constructor( | ||
private _binarayPath: string, | ||
private _options?: CommonOptions, | ||
) { | ||
this._options = { | ||
..._options, | ||
stdio: 'inherit', | ||
} | ||
} | ||
async copy(args: string | string[], options?: Options) { | ||
return execa(this._binarayPath, ['copy', ...castArray(args)], { ...options, ...this._options }) | ||
} | ||
async paste(options: Options, args?: string | string[]) { | ||
return await execa(this._binarayPath, ['paste', ...castArray(args)], { | ||
...options, | ||
...this._options, | ||
}) | ||
} | ||
copySycn(args: string | string[], options?: SyncOptions) { | ||
return execaSync(this._binarayPath, ['copy', ...castArray(args)], { ...options, ...this._options }) | ||
} | ||
pasteSync(options: SyncOptions, args?: string | string[]) { | ||
return execaSync(this._binarayPath, ['paste', ...castArray(args)], { ...options, ...this._options }) | ||
} | ||
} | ||
|
||
export default UnClipboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import isWSL from 'is-wsl' | ||
import type UnClipboard from './UnClipboard' | ||
|
||
async function getClipboard(): Promise<UnClipboard> { | ||
switch (process.platform) { | ||
case 'darwin': { | ||
return (await import('./macos')).default | ||
} | ||
case 'win32': { | ||
return (await import('./windows')).default | ||
} | ||
|
||
case 'linux': { | ||
return (await import('./linux')).default | ||
} | ||
default: { | ||
if (isWSL) { | ||
return (await import('./windows')).default | ||
} | ||
|
||
return (await import('./linux')).default | ||
} | ||
} | ||
} | ||
|
||
export { getClipboard } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { $ } from 'execa' | ||
import path from 'node:path' | ||
import UnClipboard from '../UnClipboard' | ||
|
||
const bin = path.join(__dirname, './clipboard/linux/bin/cb') | ||
|
||
$`chmod +x ${bin}` | ||
|
||
export default new UnClipboard(bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { $ } from 'execa' | ||
import path from 'node:path' | ||
import UnClipboard from '../UnClipboard' | ||
|
||
const bin = path.join(__dirname, './clipboard/macos/bin/cb') | ||
|
||
$`chmod +x ${bin}` | ||
|
||
export default new UnClipboard(bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import path from 'node:path' | ||
import UnClipboard from '../UnClipboard' | ||
|
||
const bin = path.join(__dirname, './clipboard/windows/bin/cb.exe') | ||
|
||
export default new UnClipboard(bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.