diff --git a/package.json b/package.json index 3514dab..98fb583 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,10 @@ "command": "copy-image-size.copyImageBasename", "title": "Copy Basename" }, + { + "command": "copy-image-size.copyImageFilename", + "title": "Copy Filename" + }, { "command": "copy-image-size.copyImageExtname", "title": "Copy Extname" @@ -143,9 +147,14 @@ "group": "z_copy@3" }, { - "command": "copy-image-size.copyImageExtname", + "command": "copy-image-size.copyImageFilename", "when": "webviewId == '1_pineconeViews' && webviewSection == 'imgItem'", "group": "z_copy@4" + }, + { + "command": "copy-image-size.copyImageExtname", + "when": "webviewId == '1_pineconeViews' && webviewSection == 'imgItem'", + "group": "z_copy@5" } ] } diff --git a/src/extension.ts b/src/extension.ts index ff6a0c8..b6d34c9 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -18,8 +18,8 @@ const { activate, deactivate } = defineExtension(() => { commands.executeCommand('setContext', 'copy-image-size.showPineConeGalleryIcon', true); const { postMessage, view } = usePineConeWebviewView() - const currentWorkspaceFolder = workspace.getWorkspaceFolder(urix) + const currentWorkspaceFolder = workspace.getWorkspaceFolder(urix) if (!currentWorkspaceFolder) { commands.executeCommand('setContext', 'copy-image-size.showPineConeGalleryIcon', false); window.showErrorMessage('Get Workspace Folder Fail') @@ -72,7 +72,7 @@ const { activate, deactivate } = defineExtension(() => { if (newVal) { setTimeout(async () => { vscode2Webview('updateImages', urix, view) - }, 500); + }, 300); readyToUpdate.value = false } @@ -195,6 +195,22 @@ const { activate, deactivate } = defineExtension(() => { } }) + // Copy Image Basename + useCommand('copy-image-size.copyImageFilename', async (uri: MaybeUriOrWebviewContext) => { + const { urix } = resolveVscodeOrWebviewUri(uri) + if (!urix) { + return window.showErrorMessage(`urix is undefinded`) + } + + const uriExtname = extname(urix.toString()) + const filename = basename(urix.toString(), uriExtname) + + const [clipboardErr] = await to(Promise.resolve(env.clipboard.writeText(filename))) + if (clipboardErr) { + return logger.error(clipboardErr) + } + }) + // Copy Image Extname useCommand('copy-image-size.copyImageExtname', async (uri: MaybeUriOrWebviewContext) => { const { urix } = resolveVscodeOrWebviewUri(uri) diff --git a/views/src/App.vue b/views/src/App.vue index 9b3c21f..5e9f103 100644 --- a/views/src/App.vue +++ b/views/src/App.vue @@ -5,7 +5,7 @@ import List from './components/List.vue' import SearchBar from './components/SearchBar.vue' import { imageSize, isLandscape } from './state' -// const { window, workspace } = acquireVsCodeApi() +// const { setState, getState } = acquireVsCodeApi() const vscodePostData = ref()