Skip to content

TagSpaces is an offline, open source, document manager with tagging support

feat: making add tag to multiple files dialog draggable

Ilian Sapundshiev20a2229e10e3
diff --git a/app/components/dialogs/AddRemoveTagsDialog.tsx b/app/components/dialogs/AddRemoveTagsDialog.tsx
index 532923c03..f9cca028d 100644
--- a/app/components/dialogs/AddRemoveTagsDialog.tsx
+++ b/app/components/dialogs/AddRemoveTagsDialog.tsx
@@ -17,8 +17,10 @@
*/
import React, { useState } from 'react';
+import Draggable from 'react-draggable';
import withMobileDialog from '@material-ui/core/withMobileDialog';
import Button from '@material-ui/core/Button';
+import Paper, { PaperProps } from '@material-ui/core/Paper';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';
@@ -46,6 +48,17 @@ interface Props {
removeAllTags: (paths: Array<string>) => void;
}
+function PaperComponent(props: PaperProps) {
+ return (
+ <Draggable
+ handle="#draggable-dialog-title"
+ cancel={'[class*="MuiDialogContent-root"]'}
+ >
+ <Paper {...props} />
+ </Draggable>
+ );
+}
+
const AddRemoveTagsDialog = (props: Props) => {
const [newlyAddedTags, setNewlyAddedTags] = useState<Array<TS.Tag>>([]);
@@ -109,8 +122,9 @@ const AddRemoveTagsDialog = (props: Props) => {
onClose={onClose}
keepMounted
scroll="paper"
+ PaperComponent={fullScreen ? Paper : PaperComponent}
>
- <DialogTitle>
+ <DialogTitle id="draggable-dialog-title">
{i18n.t('core:tagOperationTitle')}
<DialogCloseButton onClose={onClose} />
</DialogTitle>
diff --git a/package.json b/package.json
index 5cd13aeb2..89c1d64cf 100644
--- a/package.json
+++ b/package.json
@@ -196,6 +196,7 @@
"react-dnd": "^14.0.2",
"react-dnd-html5-backend": "^14.0.0",
"react-dom": "^16.8.2",
+ "react-draggable": "^4.4.4",
"react-hot-loader": "^4.8.2",
"react-hotkeys": "^2.0.0",
"react-i18next": "^4.6.1",
diff --git a/yarn.lock b/yarn.lock
index db8a6e5b5..3387e1d99 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5999,7 +5999,7 @@ clone@^2.1.1, clone@^2.1.2:
resolved "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz"
integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=
-clsx@^1.0.2, clsx@^1.0.4:
+clsx@^1.0.2, clsx@^1.0.4, clsx@^1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/clsx/-/clsx-1.1.1.tgz"
integrity sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==
@@ -16211,6 +16211,14 @@ react-dom@^16.8.2:
prop-types "^15.6.2"
scheduler "^0.19.1"
+react-draggable@^4.4.4:
+ version "4.4.4"
+ resolved "https://registry.yarnpkg.com/react-draggable/-/react-draggable-4.4.4.tgz#5b26d9996be63d32d285a426f41055de87e59b2f"
+ integrity sha512-6e0WdcNLwpBx/YIDpoyd2Xb04PB0elrDrulKUgdrIlwuYvxh5Ok9M+F8cljm8kPXXs43PmMzek9RrB1b7mLMqA==
+ dependencies:
+ clsx "^1.1.1"
+ prop-types "^15.6.0"
+
react-event-listener@^0.6.0:
version "0.6.6"
resolved "https://registry.npmjs.org/react-event-listener/-/react-event-listener-0.6.6.tgz"