|
|
@ -78,34 +78,6 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
setState(workspaceState) |
|
|
|
setState(workspaceState) |
|
|
|
}, [workspaceState]) |
|
|
|
}, [workspaceState]) |
|
|
|
|
|
|
|
|
|
|
|
// useEffect(() => {
|
|
|
|
|
|
|
|
// if (treeRef.current) {
|
|
|
|
|
|
|
|
// const keyPressHandler = (e: KeyboardEvent) => {
|
|
|
|
|
|
|
|
// if (e.shiftKey) {
|
|
|
|
|
|
|
|
// setState((prevState) => {
|
|
|
|
|
|
|
|
// return { ...prevState, ctrlKey: true }
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const keyUpHandler = (e: KeyboardEvent) => {
|
|
|
|
|
|
|
|
// if (!e.shiftKey) {
|
|
|
|
|
|
|
|
// setState((prevState) => {
|
|
|
|
|
|
|
|
// return { ...prevState, ctrlKey: false }
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// const targetDocument = treeRef.current
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// targetDocument.addEventListener('keydown', keyPressHandler)
|
|
|
|
|
|
|
|
// targetDocument.addEventListener('keyup', keyUpHandler)
|
|
|
|
|
|
|
|
// return () => {
|
|
|
|
|
|
|
|
// targetDocument.removeEventListener('keydown', keyPressHandler)
|
|
|
|
|
|
|
|
// targetDocument.removeEventListener('keyup', keyUpHandler)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }, [treeRef.current])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
const performDeletion = async () => { |
|
|
|
const performDeletion = async () => { |
|
|
|
const path: string[] = [] |
|
|
|
const path: string[] = [] |
|
|
@ -135,7 +107,6 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const performCut = async () => { |
|
|
|
const performCut = async () => { |
|
|
|
console.log('check feTarget', feTarget) |
|
|
|
|
|
|
|
if (feTarget) { |
|
|
|
if (feTarget) { |
|
|
|
if (feTarget.length > 0 && feTarget[0].key.length > 0) { |
|
|
|
if (feTarget.length > 0 && feTarget[0].key.length > 0) { |
|
|
|
handleMultiCopies(feTarget) |
|
|
|
handleMultiCopies(feTarget) |
|
|
@ -148,12 +119,9 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
|
|
|
|
|
|
|
|
const performPaste = async () => { |
|
|
|
const performPaste = async () => { |
|
|
|
if (feTarget.length > 0 && feTarget[0]?.key.length >= 0) { |
|
|
|
if (feTarget.length > 0 && feTarget[0]?.key.length >= 0) { |
|
|
|
console.log('cut-mode has been activated', cutActivated) |
|
|
|
|
|
|
|
if (cutActivated) { |
|
|
|
if (cutActivated) { |
|
|
|
if (state.copyElement.length > 1) { |
|
|
|
if (state.copyElement.length > 1) { |
|
|
|
console.log('more than one item is ready to be cut') |
|
|
|
|
|
|
|
const promisesToKeep = state.copyElement.filter(x => x).map(async (item) => { |
|
|
|
const promisesToKeep = state.copyElement.filter(x => x).map(async (item) => { |
|
|
|
console.log('cutting files now') |
|
|
|
|
|
|
|
if (item.type === 'file') { |
|
|
|
if (item.type === 'file') { |
|
|
|
props.dispatchMoveFile(item.key, feTarget[0].key) |
|
|
|
props.dispatchMoveFile(item.key, feTarget[0].key) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -249,57 +217,60 @@ export const FileExplorer = (props: FileExplorerProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const CopyComboHandler = async (eve: KeyboardEvent) => { |
|
|
|
let CopyComboHandler: (eve: KeyboardEvent) => Promise<void> |
|
|
|
if (eve.metaKey && eve.code === 'KeyC' && (window as any).navigator.userAgentData.platform === 'macOS') { |
|
|
|
let CutHandler: (eve: KeyboardEvent) => Promise<void> |
|
|
|
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath']) |
|
|
|
let pasteHandler: (eve: KeyboardEvent) => Promise<void> |
|
|
|
await performCopy() |
|
|
|
let pcCopyHandler: (eve: KeyboardEvent) => Promise<void> |
|
|
|
console.log('copy performed on a mac') |
|
|
|
let pcCutHandler: (eve: KeyboardEvent) => Promise<void> |
|
|
|
return |
|
|
|
let pcPasteHandler: (eve: KeyboardEvent) => Promise<void> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((window as any).navigator.userAgentData.platform === 'macOS') { |
|
|
|
|
|
|
|
CopyComboHandler = async (eve: KeyboardEvent) => { |
|
|
|
|
|
|
|
if (eve.metaKey && eve.code === 'KeyC') { |
|
|
|
|
|
|
|
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath']) |
|
|
|
|
|
|
|
await performCopy() |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const pcCopyHandler = async (eve: KeyboardEvent) => { |
|
|
|
CutHandler = async (eve: KeyboardEvent) => { |
|
|
|
if (eve.ctrlKey && (eve.key === 'c' || eve.key === 'C') && (window as any).navigator.userAgentData.platform !== 'macOS') { |
|
|
|
if (eve.metaKey && eve.code === 'KeyX') { |
|
|
|
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath']) |
|
|
|
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath']) |
|
|
|
await performCopy() |
|
|
|
await performCut() |
|
|
|
console.log('copy perfomed on a pc') |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const pcCutHandler = async (eve: KeyboardEvent) => { |
|
|
|
pasteHandler = async (eve: KeyboardEvent) => { |
|
|
|
if (eve.ctrlKey && eve.code === 'KeyX' && (window as any).navigator.userAgentData.platform !== 'macOS') { |
|
|
|
if (eve.metaKey && eve.code === 'KeyV') { |
|
|
|
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath']) |
|
|
|
feWindow._paq.push(['trackEvent', 'fileExplorer', 'metaVToPaste', 'PasteCopiedContent']) |
|
|
|
await performCut() |
|
|
|
performPaste() |
|
|
|
console.log('cut performed on a pc') |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
pcCopyHandler = async (eve: KeyboardEvent) => { |
|
|
|
const CutHandler = async (eve: KeyboardEvent) => { |
|
|
|
if (eve.ctrlKey && (eve.key === 'c' || eve.key === 'C')) { |
|
|
|
if (eve.metaKey && eve.code === 'KeyX' && (window as any).navigator.userAgentData.platform === 'macOS') { |
|
|
|
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath']) |
|
|
|
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath']) |
|
|
|
await performCopy() |
|
|
|
await performCut() |
|
|
|
return |
|
|
|
console.log('Cut performed on mac') |
|
|
|
} |
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const pasteHandler = async (eve: KeyboardEvent) => { |
|
|
|
pcCutHandler = async (eve: KeyboardEvent) => { |
|
|
|
if (eve.metaKey && eve.code === 'KeyV' && (window as any).navigator.userAgentData.platform === 'macOS') { |
|
|
|
if (eve.ctrlKey && eve.code === 'KeyX') { |
|
|
|
feWindow._paq.push(['trackEvent', 'fileExplorer', 'metaVToPaste', 'PasteCopiedContent']) |
|
|
|
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath']) |
|
|
|
performPaste() |
|
|
|
await performCut() |
|
|
|
console.log('paste performed on mac') |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const pcPasteHandler = async (eve: KeyboardEvent) => { |
|
|
|
pcPasteHandler = async (eve: KeyboardEvent) => { |
|
|
|
if (eve.key === 'Control' && eve.code === 'KeyV' && (window as any).navigator.userAgentData.platform !== 'macOS') { |
|
|
|
if (eve.key === 'Control' && eve.code === 'KeyV') { |
|
|
|
feWindow._paq.push(['trackEvent', 'fileExplorer', 'ctrlVToPaste', 'PasteCopiedContent']) |
|
|
|
feWindow._paq.push(['trackEvent', 'fileExplorer', 'ctrlVToPaste', 'PasteCopiedContent']) |
|
|
|
performPaste() |
|
|
|
performPaste() |
|
|
|
console.log('paste performed on pc') |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|