@retikolo/drag-drop-content-types-strapi 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -0
- package/dist/_chunks/Settings-BUJ6OWyE.js +3632 -0
- package/dist/_chunks/Settings-Cx22s5Bk.mjs +3615 -0
- package/dist/_chunks/en-I3-CH3Sy.js +31 -0
- package/dist/_chunks/en-bxpER_P-.mjs +31 -0
- package/dist/_chunks/fr-C8Qw4iPZ.js +4 -0
- package/dist/_chunks/fr-hkSxFuzl.mjs +4 -0
- package/dist/_chunks/index-CxWC49Ye.mjs +477 -0
- package/dist/_chunks/index-D5Ne-GrP.js +478 -0
- package/dist/admin/index.js +3 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/admin/src/components/Initializer.d.ts +5 -0
- package/dist/admin/src/components/PluginIcon.d.ts +2 -0
- package/dist/admin/src/components/SettingsTextField.d.ts +14 -0
- package/dist/admin/src/components/SettingsToggleField.d.ts +13 -0
- package/dist/admin/src/components/SortModal/CustomItem.d.ts +12 -0
- package/dist/admin/src/components/SortModal/SortMenu.d.ts +3 -0
- package/dist/admin/src/components/SortModal/SortableList.d.ts +3 -0
- package/dist/admin/src/components/SortModal/SortableListItem.d.ts +7 -0
- package/dist/admin/src/components/SortModal/index.d.ts +2 -0
- package/dist/admin/src/components/SortModal/utils.d.ts +2 -0
- package/dist/admin/src/components/TooltipIconButton.d.ts +11 -0
- package/dist/admin/src/index.d.ts +13 -0
- package/dist/admin/src/pages/App.d.ts +2 -0
- package/dist/admin/src/pages/HomePage.d.ts +2 -0
- package/dist/admin/src/pages/Settings.d.ts +2 -0
- package/dist/admin/src/permissions.d.ts +7 -0
- package/dist/admin/src/pluginId.d.ts +1 -0
- package/dist/admin/src/utils/getTranslation.d.ts +2 -0
- package/dist/admin/src/utils/strapi.d.ts +13 -0
- package/dist/admin/src/utils/useQueryParams.d.ts +7 -0
- package/dist/server/index.js +266 -0
- package/dist/server/index.mjs +267 -0
- package/dist/server/src/bootstrap.d.ts +5 -0
- package/dist/server/src/config/index.d.ts +5 -0
- package/dist/server/src/content-types/index.d.ts +2 -0
- package/dist/server/src/controllers/dragdrop.d.ts +9 -0
- package/dist/server/src/controllers/index.d.ts +16 -0
- package/dist/server/src/controllers/settings.d.ts +8 -0
- package/dist/server/src/destroy.d.ts +5 -0
- package/dist/server/src/index.d.ts +79 -0
- package/dist/server/src/middlewares/index.d.ts +2 -0
- package/dist/server/src/policies/index.d.ts +2 -0
- package/dist/server/src/register.d.ts +5 -0
- package/dist/server/src/routes/dragdrop.d.ts +13 -0
- package/dist/server/src/routes/index.d.ts +26 -0
- package/dist/server/src/routes/settings.d.ts +12 -0
- package/dist/server/src/services/dragdrop.d.ts +21 -0
- package/dist/server/src/services/index.d.ts +21 -0
- package/dist/server/src/services/settings.d.ts +8 -0
- package/package.json +98 -0
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://user-images.githubusercontent.com/37687705/192227260-db082018-947a-4166-a3f4-983e1024dd59.png" width="20%">
|
|
3
|
+
<h1>Strapi plugin drag-drop-content-types</h1>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
Inspired by the [Drag-Drop-Content-Type Strapi 4 plugin](https://github.com/plantagoIT/strapi-drag-drop-content-type-plugin).
|
|
9
|
+
Drag-drop feature completely rewritten to use dndkit because react-sortable-hoc is deprecated and not compatible with React 18.
|
|
10
|
+
|
|
11
|
+
## 🔄 Strapi 5 Compatibility
|
|
12
|
+
|
|
13
|
+
This version (2.0.0) has been updated for **Strapi 5** compatibility with the following changes:
|
|
14
|
+
|
|
15
|
+
### Key Updates
|
|
16
|
+
- **Removed Redux dependency**: Strapi 5 changed its internal architecture, so the Redux-based list view refresh has been replaced with a page reload mechanism that triggers when closing the sort modal after making changes
|
|
17
|
+
- **Updated @dnd-kit**: Migrated from react-sortable-hoc to @dnd-kit for drag-and-drop functionality (React 18 compatible)
|
|
18
|
+
- **Strapi 5 Admin API**: Updated to use new Strapi 5 admin hooks (`useFetchClient`, `useNotification`, `useAPIErrorHandler`)
|
|
19
|
+
- **Improved UX**: You can now drag and reorder multiple items in one session - the page only refreshes once when you close the modal, preserving your changes
|
|
20
|
+
|
|
21
|
+
### Known Considerations
|
|
22
|
+
- After sorting items, the content manager list view refreshes when you close the sort modal to display the updated order
|
|
23
|
+
- Uses Strapi 5's new Popover component with controlled state for better stability
|
|
24
|
+
|
|
25
|
+
### Strapi 4 Compatibility
|
|
26
|
+
If you are still using Strapi 4, you can use version 1.7.1 of this plugin, which is available on the `strapi4` branch.
|
|
27
|
+
|
|
28
|
+
## ⏳ Installation
|
|
29
|
+
|
|
30
|
+
Install with NPM.
|
|
31
|
+
```bash
|
|
32
|
+
npm i @retikolo/drag-drop-content-types-strapi
|
|
33
|
+
```
|
|
34
|
+
Install with Yarn.
|
|
35
|
+
```bash
|
|
36
|
+
yarn add @retikolo/drag-drop-content-types-strapi
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 🔧 Configuration
|
|
40
|
+
|
|
41
|
+
### In your config
|
|
42
|
+
1. Add the following to your `config/plugins.ts` file. Create the file, if it doesn't exist.
|
|
43
|
+
```js
|
|
44
|
+
export default () => ({
|
|
45
|
+
// ...
|
|
46
|
+
'drag-drop-content-types': {
|
|
47
|
+
enabled: true
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
```
|
|
51
|
+
2. Run `npm run build` and restart the app using `npm run develop`.
|
|
52
|
+
|
|
53
|
+
### In the app
|
|
54
|
+
1. Go to `Settings` → `Drag Drop Content Type` → `Configuration`.
|
|
55
|
+
2. Specify the `Rank Field Name` used for sorting or leave the default field name `rank`.
|
|
56
|
+
3. Add a `Number` field with `Name: myRankFieldName` and `Number format: integer` to the sortable _ContentType_.
|
|
57
|
+
4. Configure the view of your _ContentType_ by adding `Default sort attribute → rank` and `Default sort order → ASC` to update the view after dragging.
|
|
58
|
+
5. If needed: grant permissions for the `rank` field to your roles.
|
|
59
|
+
|
|
60
|
+
#### Hints
|
|
61
|
+
* You can set a `title` value that will be displayed in the menu instead of the default field.
|
|
62
|
+
* A second field can be displayed in the menu via the `subtitle` setting. It can be either a string-like field or an object such as a relation, that has a `title` field as configured in the settings.
|
|
63
|
+
* You can enable webhooks to trigger something after updating the order.
|
|
64
|
+
|
|
65
|
+
### In your frontend
|
|
66
|
+
You can make a request in the frontend to get the ordered items. In this example the _ContentType_ is called `Foo` and ordered via the `rank` field.
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
http://localhost:1337/api/foo?sort=rank:asc
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 🤝 Contribute
|
|
73
|
+
Feel free to fork and make pull requests to this plugin. All input is welcome - thanks for all contributions so far!
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## ⭐️ Support
|
|
77
|
+
I you like this project, please give it a star ⭐️. Maybe this will help it getting integrated to strapi's core some day 😊.
|