mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
Add path copy functionality
This commit is contained in:
parent
329599e672
commit
c36b5dd500
|
@ -3,6 +3,7 @@
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
import { AnimatePresence, motion } from 'framer-motion';
|
||||||
import { useCallback, useLayoutEffect, useMemo, useState } from 'react';
|
import { useCallback, useLayoutEffect, useMemo, useState } from 'react';
|
||||||
|
import { toast } from 'react-toastify';
|
||||||
|
|
||||||
import { IconFolder, IconFolderClosed, IconFolderEmpty, IconFolderOpened, IconFolderTree } from '@/components/Icons';
|
import { IconFolder, IconFolderClosed, IconFolderEmpty, IconFolderOpened, IconFolderTree } from '@/components/Icons';
|
||||||
import BadgeHelp from '@/components/info/BadgeHelp';
|
import BadgeHelp from '@/components/info/BadgeHelp';
|
||||||
|
@ -12,7 +13,7 @@ import { FolderNode, FolderTree } from '@/models/FolderTree';
|
||||||
import { HelpTopic } from '@/models/miscellaneous';
|
import { HelpTopic } from '@/models/miscellaneous';
|
||||||
import { animateSideAppear, animateSideView } from '@/styling/animations';
|
import { animateSideAppear, animateSideView } from '@/styling/animations';
|
||||||
import { globals, PARAMETER, prefixes } from '@/utils/constants';
|
import { globals, PARAMETER, prefixes } from '@/utils/constants';
|
||||||
import { describeFolderNode, labelFolderNode } from '@/utils/labels';
|
import { describeFolderNode, information, labelFolderNode } from '@/utils/labels';
|
||||||
|
|
||||||
interface LibraryTableProps {
|
interface LibraryTableProps {
|
||||||
folders: FolderTree;
|
folders: FolderTree;
|
||||||
|
@ -49,11 +50,18 @@ function LibraryFolders({ folders, currentFolder, setFolder, toggleFolderMode }:
|
||||||
[items]
|
[items]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleSetValue = useCallback(
|
const handleClickFolder = useCallback(
|
||||||
(event: CProps.EventMouse, target: FolderNode) => {
|
(event: CProps.EventMouse, target: FolderNode) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
if (event.ctrlKey) {
|
||||||
|
navigator.clipboard
|
||||||
|
.writeText(target.getPath())
|
||||||
|
.then(() => toast.success(information.pathReady))
|
||||||
|
.catch(console.error);
|
||||||
|
} else {
|
||||||
setFolder(target.getPath());
|
setFolder(target.getPath());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[setFolder]
|
[setFolder]
|
||||||
);
|
);
|
||||||
|
@ -69,7 +77,7 @@ function LibraryFolders({ folders, currentFolder, setFolder, toggleFolderMode }:
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
className='flex flex-col text:xs sm:text-sm'
|
className='flex flex-col select-none text:xs sm:text-sm'
|
||||||
initial={{ ...animateSideView.initial }}
|
initial={{ ...animateSideView.initial }}
|
||||||
animate={{ ...animateSideView.animate }}
|
animate={{ ...animateSideView.animate }}
|
||||||
exit={{ ...animateSideView.exit }}
|
exit={{ ...animateSideView.exit }}
|
||||||
|
@ -111,7 +119,7 @@ function LibraryFolders({ folders, currentFolder, setFolder, toggleFolderMode }:
|
||||||
style={{ paddingLeft: `${(item.rank > 5 ? 5 : item.rank) * 0.5 + 0.5}rem` }}
|
style={{ paddingLeft: `${(item.rank > 5 ? 5 : item.rank) * 0.5 + 0.5}rem` }}
|
||||||
data-tooltip-id={globals.tooltip}
|
data-tooltip-id={globals.tooltip}
|
||||||
data-tooltip-html={describeFolderNode(item)}
|
data-tooltip-html={describeFolderNode(item)}
|
||||||
onClick={event => handleSetValue(event, item)}
|
onClick={event => handleClickFolder(event, item)}
|
||||||
initial={{ ...animateSideAppear.initial }}
|
initial={{ ...animateSideAppear.initial }}
|
||||||
animate={{ ...animateSideAppear.animate }}
|
animate={{ ...animateSideAppear.animate }}
|
||||||
exit={{ ...animateSideAppear.exit }}
|
exit={{ ...animateSideAppear.exit }}
|
||||||
|
|
|
@ -34,6 +34,7 @@ function HelpLibrary() {
|
||||||
|
|
||||||
<h2>Проводник</h2>
|
<h2>Проводник</h2>
|
||||||
<li>клик по папке отображает справа файлы в ней</li>
|
<li>клик по папке отображает справа файлы в ней</li>
|
||||||
|
<li>Ctrl + клик по папке копирует путь в буфер обмена</li>
|
||||||
<li>клик по иконке сворачивает/разворачивает вложенные</li>
|
<li>клик по иконке сворачивает/разворачивает вложенные</li>
|
||||||
<li>
|
<li>
|
||||||
<IconFolderTree size='1rem' className='inline-icon' /> переключение между Проводник и Поиск
|
<IconFolderTree size='1rem' className='inline-icon' /> переключение между Проводник и Поиск
|
||||||
|
|
|
@ -898,6 +898,7 @@ export const information = {
|
||||||
subscribed: 'Отслеживание отключено',
|
subscribed: 'Отслеживание отключено',
|
||||||
unsubscribed: 'Отслеживание выключено',
|
unsubscribed: 'Отслеживание выключено',
|
||||||
|
|
||||||
|
pathReady: 'Путь скопирован',
|
||||||
substituteSingle: 'Отождествление завершено',
|
substituteSingle: 'Отождествление завершено',
|
||||||
reorderComplete: 'Упорядочение завершено',
|
reorderComplete: 'Упорядочение завершено',
|
||||||
reindexComplete: 'Имена конституент обновлены',
|
reindexComplete: 'Имена конституент обновлены',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user