base64 file content

Aniket-Engg-patch-1
aniket-engg 10 months ago committed by Aniket
parent 5ba21573d7
commit 43d88ad051
  1. 13
      libs/remix-ui/workspace/src/lib/actions/index.ts
  2. 2
      libs/remix-ui/workspace/src/lib/components/file-explorer-context-menu.tsx
  3. 1
      libs/remix-ui/workspace/src/lib/contexts/index.ts
  4. 6
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
  5. 6
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  6. 1
      libs/remix-ui/workspace/src/lib/types/index.ts

@ -376,6 +376,19 @@ export const copyFile = async (src: string, dest: string) => {
}
}
export const copyShareURL = async (path: string) => {
const fileManager = plugin.fileManager
try {
const fileContent = await fileManager.readFile(path)
console.log('fileContent------>', fileContent)
const base64Content = btoa(fileContent)
console.log('base64Content------>', base64Content)
} catch (error) {
dispatch(displayPopUp('Oops! An error ocurred while performing copyFile operation.' + error))
}
}
export const copyFolder = async (src: string, dest: string) => {
const fileManager = plugin.fileManager

@ -213,7 +213,7 @@ export const FileExplorerContextMenu = (props: FileExplorerContextMenuProps) =>
copyPath(path, type)
_paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'copyPath'])
break
case 'Copy Share URL':
case 'Copy share URL':
copyShareURL(path, type)
_paq.push(['trackEvent', 'fileExplorer', 'contextMenu', 'copyShareURL'])
break

@ -27,6 +27,7 @@ export const FileSystemContext = createContext<{
dispatchRenamePath: (oldPath: string, newPath: string) => Promise<void>,
dispatchDownloadPath: (path:string) => Promise<void>,
dispatchCopyFile: (src: string, dest: string) => Promise<void>,
dispatchCopyShareURL: (path: string) => Promise<void>,
dispatchCopyFolder: (src: string, dest: string) => Promise<void>,
dispatchRunScript: (path: string) => Promise<void>,
dispatchEmitContextMenuEvent: (cmd: customAction) => Promise<void>,

@ -20,6 +20,7 @@ import {
renamePath,
downloadPath,
copyFile,
copyShareURL,
copyFolder,
runScript,
emitContextMenuEvent,
@ -156,6 +157,10 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
await copyFile(src, dest)
}
const dispatchCopyShareURL = async (path: string) => {
await copyShareURL(path)
}
const dispatchCopyFolder = async (src: string, dest: string) => {
await copyFolder(src, dest)
}
@ -352,6 +357,7 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
dispatchRenamePath,
dispatchDownloadPath,
dispatchCopyFile,
dispatchCopyShareURL,
dispatchCopyFolder,
dispatchRunScript,
dispatchEmitContextMenuEvent,

@ -536,8 +536,8 @@ export function Workspace() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const handleCopyShareURLClick = (path: string, _type: string) => {
const fileName = extractNameFromKey(path)
console.log('handleCopyShareURLClick---->', fileName)
console.log('path---->', path)
global.dispatchCopyShareURL(path)
// navigator.clipboard.writeText(fileName)
}
@ -1105,6 +1105,7 @@ export function Workspace() {
dispatchUploadFile={global.dispatchUploadFile}
dispatchUploadFolder={global.dispatchUploadFolder}
dispatchCopyFile={global.dispatchCopyFile}
dispatchCopyShareURL={global.dispatchCopyShareURL}
dispatchCopyFolder={global.dispatchCopyFolder}
dispatchPublishToGist={global.dispatchPublishToGist}
dispatchRunScript={global.dispatchRunScript}
@ -1164,6 +1165,7 @@ export function Workspace() {
dispatchUploadFile={global.dispatchUploadFile}
dispatchUploadFolder={global.dispatchUploadFolder}
dispatchCopyFile={global.dispatchCopyFile}
dispatchCopyShareURL={global.dispatchCopyShareURL}
dispatchCopyFolder={global.dispatchCopyFolder}
dispatchPublishToGist={global.dispatchPublishToGist}
dispatchRunScript={global.dispatchRunScript}

@ -105,6 +105,7 @@ export interface FileExplorerProps {
dispatchUploadFile: (target?: React.SyntheticEvent, targetFolder?: string) => Promise<void>,
dispatchUploadFolder: (target?: React.SyntheticEvent, targetFolder?: string) => Promise<void>,
dispatchCopyFile: (src: string, dest: string) => Promise<void>,
dispatchCopyShareURL: (path:string) => Promise<void>,
dispatchCopyFolder: (src: string, dest: string) => Promise<void>,
dispatchRunScript: (path: string) => Promise<void>,
dispatchPublishToGist: (path?: string, type?: string) => Promise<void>,

Loading…
Cancel
Save