strapi-plugin-dynamic-zone-tools 1.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/CHANGELOG.md +12 -0
- package/CONTRIBUTING.md +38 -0
- package/LICENSE +21 -0
- package/README.md +186 -0
- package/admin/custom.d.ts +2 -0
- package/admin/src/components/DynamicZoneComponentDuplicateInjector.tsx +604 -0
- package/admin/src/components/DynamicZoneEditViewExtensions.tsx +7 -0
- package/admin/src/components/DynamicZoneToolsPanel.tsx +1027 -0
- package/admin/src/components/FillFromRecord.tsx +36 -0
- package/admin/src/components/Initializer.tsx +19 -0
- package/admin/src/components/PluginIcon.tsx +5 -0
- package/admin/src/index.ts +61 -0
- package/admin/src/pages/App.tsx +15 -0
- package/admin/src/pages/HomePage.tsx +16 -0
- package/admin/src/pluginId.ts +1 -0
- package/admin/src/translations/en.json +51 -0
- package/admin/src/utils/createRowActionButton.ts +57 -0
- package/admin/src/utils/createRowActionMenu.ts +276 -0
- package/admin/src/utils/dynamicZoneClipboard.ts +134 -0
- package/admin/src/utils/dynamicZonePaths.ts +236 -0
- package/admin/src/utils/getTranslation.ts +5 -0
- package/admin/src/utils/prepareDynamicZoneData.ts +625 -0
- package/admin/src/utils/relationQueryParams.ts +19 -0
- package/admin/tsconfig.build.json +10 -0
- package/admin/tsconfig.json +12 -0
- package/dist/admin/en-Ce0ZP0MJ.js +54 -0
- package/dist/admin/en-DrSdJbJW.mjs +54 -0
- package/dist/admin/index.js +2161 -0
- package/dist/admin/index.mjs +2159 -0
- package/dist/admin/src/index.d.ts +12 -0
- package/dist/server/index.js +137 -0
- package/dist/server/index.mjs +137 -0
- package/dist/server/src/index.d.ts +55 -0
- package/package.json +112 -0
- package/server/src/bootstrap.ts +18 -0
- package/server/src/config/index.ts +4 -0
- package/server/src/content-types/index.ts +1 -0
- package/server/src/controllers/controller.ts +85 -0
- package/server/src/controllers/index.ts +5 -0
- package/server/src/destroy.ts +7 -0
- package/server/src/index.ts +30 -0
- package/server/src/middlewares/index.ts +1 -0
- package/server/src/policies/index.ts +1 -0
- package/server/src/register.ts +7 -0
- package/server/src/routes/admin-api.ts +18 -0
- package/server/src/routes/content-api.ts +1 -0
- package/server/src/routes/index.ts +15 -0
- package/server/src/services/index.ts +5 -0
- package/server/src/services/service.ts +9 -0
- package/server/tsconfig.build.json +10 -0
- package/server/tsconfig.json +11 -0
- package/strapi-admin.js +3 -0
- package/strapi-server.js +3 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## 1.0.0
|
|
6
|
+
|
|
7
|
+
- Initial public release for Strapi 5.
|
|
8
|
+
- Added header action for copying dynamic zone content from another record.
|
|
9
|
+
- Added replace and append copy modes.
|
|
10
|
+
- Added source block selection and target schema filtering.
|
|
11
|
+
- Added inline duplicate, copy, and insert actions for dynamic zone blocks.
|
|
12
|
+
- Added role-based admin permission for dynamic zone tools.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for taking the time to improve `strapi-plugin-dynamic-zone-tools`.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
1. Clone the repository.
|
|
8
|
+
2. Install dependencies with `npm install`.
|
|
9
|
+
3. Link or resolve the plugin from a Strapi 5 application:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export default {
|
|
13
|
+
"dynamic-zone-tools": {
|
|
14
|
+
enabled: true,
|
|
15
|
+
resolve: "./src/plugins/strapi-plugin-dynamic-zone-tools",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
4. Rebuild and run the Strapi application.
|
|
21
|
+
|
|
22
|
+
## Checks
|
|
23
|
+
|
|
24
|
+
Run these commands before opening a pull request:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm run build
|
|
28
|
+
npm run verify
|
|
29
|
+
npm run test:ts:front
|
|
30
|
+
npm run test:ts:back
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Pull Requests
|
|
34
|
+
|
|
35
|
+
- Keep changes focused.
|
|
36
|
+
- Include reproduction steps for bug fixes.
|
|
37
|
+
- Mention the Strapi version used for testing.
|
|
38
|
+
- Add screenshots or short screen recordings for admin UI changes when useful.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dimitris Ganotis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Strapi Dynamic Zone Tools Plugin
|
|
2
|
+
|
|
3
|
+
A productivity plugin for **Strapi 5** that makes dynamic zones faster to work with in the Content Manager.
|
|
4
|
+
|
|
5
|
+
Copy full page sections from another entry, append selected blocks, duplicate existing blocks, or copy and insert individual components without leaving the edit view. It is especially useful for page builders, landing pages, reusable content sections, campaign pages, and any Strapi setup where editors work with large dynamic zones.
|
|
6
|
+
|
|
7
|
+
> ⚠️ **Version Compatibility**
|
|
8
|
+
>
|
|
9
|
+
> - **v1.x**: Supports Strapi v5.41.0 and newer
|
|
10
|
+
|
|
11
|
+
## ✨ Features
|
|
12
|
+
|
|
13
|
+
- 🎯 **Copy Dynamic Zones Between Entries**: Fill a dynamic zone from another record in the Content Manager
|
|
14
|
+
- ➕ **Replace or Append Modes**: Replace the current zone or append selected blocks to the end
|
|
15
|
+
- ✅ **Block-Level Selection**: Choose exactly which source blocks should be copied
|
|
16
|
+
- 🧩 **Duplicate Individual Blocks**: Duplicate a dynamic zone component directly in the current entry
|
|
17
|
+
- 📋 **Copy and Insert Blocks**: Copy a block and paste it above or below another compatible block
|
|
18
|
+
- 🛡️ **Schema-Aware Copying**: Automatically skips components that are not allowed in the target dynamic zone
|
|
19
|
+
- 🔗 **Nested Data Support**: Preserves nested components, media, and relation references when preparing copied data
|
|
20
|
+
- 🌍 **i18n and Draft/Publish Aware**: Works with localized content and draft or published source records
|
|
21
|
+
- 🔐 **Permission-Protected Source Fetching**: Protects the source-document lookup endpoint with a dedicated admin permission
|
|
22
|
+
- ✍️ **No Auto-Save**: Applies changes to the form only, so editors can review before saving
|
|
23
|
+
|
|
24
|
+
## 🚀 Installation
|
|
25
|
+
|
|
26
|
+
### Using npm
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install strapi-plugin-dynamic-zone-tools
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Using yarn
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
yarn add strapi-plugin-dynamic-zone-tools
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## ⚙️ Configuration
|
|
39
|
+
|
|
40
|
+
Enable the plugin in `config/plugins.js`:
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
module.exports = {
|
|
44
|
+
"dynamic-zone-tools": {
|
|
45
|
+
enabled: true,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For TypeScript projects, use `config/plugins.ts`:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
export default {
|
|
54
|
+
"dynamic-zone-tools": {
|
|
55
|
+
enabled: true,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
After installation, rebuild and restart Strapi:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm run build
|
|
64
|
+
npm run develop
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 🔧 Setup
|
|
68
|
+
|
|
69
|
+
1. Install and enable the plugin.
|
|
70
|
+
2. Rebuild and restart your Strapi application.
|
|
71
|
+
3. Go to **Settings** -> **Roles**.
|
|
72
|
+
4. Select the role that should use the plugin.
|
|
73
|
+
5. Under **Plugins** -> **Dynamic Zone Tools**, enable **Fill Dynamic Zone**.
|
|
74
|
+
6. Save the role.
|
|
75
|
+
|
|
76
|
+
The fill-from-record workflow uses this permission for its source-document lookup. Inline duplicate/copy/insert actions run inside the Content Manager form and are ultimately governed by the editor's normal Content Manager save permissions.
|
|
77
|
+
|
|
78
|
+
## 🎯 Usage
|
|
79
|
+
|
|
80
|
+
### Copy a dynamic zone from another record
|
|
81
|
+
|
|
82
|
+
Use this when an editor wants to reuse an existing page layout, campaign structure, FAQ section, landing page blocks, or any dynamic zone content from another entry.
|
|
83
|
+
|
|
84
|
+
1. Open a Content Manager entry that has at least one dynamic zone field.
|
|
85
|
+
2. Click the **Copy dynamic zone data** header action.
|
|
86
|
+
3. Select the target dynamic zone in the current entry.
|
|
87
|
+
4. Choose **Replace current zone** or **Append to current zone**.
|
|
88
|
+
5. Select the source collection type.
|
|
89
|
+
6. Select the source dynamic zone field.
|
|
90
|
+
7. Select the source record.
|
|
91
|
+
8. If relevant, choose the source locale and draft/published version.
|
|
92
|
+
9. Select the source blocks you want to copy.
|
|
93
|
+
10. Confirm the action, review the edited form, and save when ready.
|
|
94
|
+
|
|
95
|
+
When copying between different dynamic zones, components that are not allowed by the target schema are skipped automatically.
|
|
96
|
+
|
|
97
|
+
### Duplicate, copy, or insert individual blocks
|
|
98
|
+
|
|
99
|
+
Use this when an editor wants to quickly create a similar section inside the same entry or move a reusable block pattern into another compatible dynamic zone.
|
|
100
|
+
|
|
101
|
+
1. Open a Content Manager entry with a dynamic zone.
|
|
102
|
+
2. Use the block row actions inside the dynamic zone field.
|
|
103
|
+
3. Click **Duplicate component** to duplicate the current block.
|
|
104
|
+
4. Click **Copy block** to copy a block.
|
|
105
|
+
5. Use **Insert** on another block row to paste the copied block above or below.
|
|
106
|
+
6. Save the entry when the form looks correct.
|
|
107
|
+
|
|
108
|
+
Copied blocks can only be inserted into compatible dynamic zones.
|
|
109
|
+
|
|
110
|
+
## 🔐 Permissions
|
|
111
|
+
|
|
112
|
+
The plugin uses Strapi's admin role permission system for source-document lookup.
|
|
113
|
+
|
|
114
|
+
| Permission | Description |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| `Fill Dynamic Zone` | Allows users to fetch source document data for the fill-from-record workflow. |
|
|
117
|
+
|
|
118
|
+
Current behavior:
|
|
119
|
+
|
|
120
|
+
- The **fill-from-record** workflow calls the plugin admin API, so it requires an authenticated admin user with the **Fill Dynamic Zone** permission.
|
|
121
|
+
- The **duplicate/copy/insert block** actions are client-side Content Manager form actions. They do not call the plugin API; the resulting changes are saved only if the user has normal Content Manager permissions to save the entry.
|
|
122
|
+
|
|
123
|
+
## 🔌 API Endpoint
|
|
124
|
+
|
|
125
|
+
The plugin uses an admin-authenticated endpoint for source document lookup:
|
|
126
|
+
|
|
127
|
+
| Method | Endpoint | Description |
|
|
128
|
+
| --- | --- | --- |
|
|
129
|
+
| `GET` | `/dynamic-zone-tools/source-document/:contentType/:id` | Fetch a source record with deeply populated dynamic zone data. |
|
|
130
|
+
|
|
131
|
+
This endpoint is intended for the plugin UI, not for public API access. Content type and record list data is read through Strapi's authenticated Content Manager APIs.
|
|
132
|
+
|
|
133
|
+
## 🧠 How It Handles Copied Data
|
|
134
|
+
|
|
135
|
+
Dynamic zones can contain nested components, media fields, relations, localized content, and draft/published versions. The plugin prepares copied data before inserting it into the edit form:
|
|
136
|
+
|
|
137
|
+
- Removes transient identifiers that should not be reused in a new block
|
|
138
|
+
- Preserves component structure and allowed relation references
|
|
139
|
+
- Filters out component types that are not allowed by the target dynamic zone
|
|
140
|
+
- Keeps changes in the unsaved form state until the editor saves the entry
|
|
141
|
+
|
|
142
|
+
## 🛠️ Troubleshooting
|
|
143
|
+
|
|
144
|
+
### Plugin action is not visible
|
|
145
|
+
|
|
146
|
+
1. Confirm the content type has at least one dynamic zone field.
|
|
147
|
+
2. Confirm your admin role has the **Fill Dynamic Zone** permission.
|
|
148
|
+
3. Rebuild and restart Strapi after installing or changing plugin configuration.
|
|
149
|
+
|
|
150
|
+
### A copied block is skipped or cannot be pasted
|
|
151
|
+
|
|
152
|
+
The block's component type is probably not allowed in the target dynamic zone. Update the target dynamic zone schema or copy into a compatible field.
|
|
153
|
+
|
|
154
|
+
### Source records are missing
|
|
155
|
+
|
|
156
|
+
Check whether the source content type uses draft/publish or i18n. The plugin scopes source records by the selected version and locale.
|
|
157
|
+
|
|
158
|
+
## 🧑💻 Development
|
|
159
|
+
|
|
160
|
+
From the plugin directory:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
npm run build
|
|
164
|
+
npm run verify
|
|
165
|
+
npm run test:ts:front
|
|
166
|
+
npm run test:ts:back
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
For local Strapi testing, enable the plugin with `resolve` in the parent Strapi application, then run the parent app build/develop commands.
|
|
170
|
+
|
|
171
|
+
## 📦 Package Contents
|
|
172
|
+
|
|
173
|
+
The npm package includes:
|
|
174
|
+
|
|
175
|
+
- Built admin and server output in `dist/`
|
|
176
|
+
- Source folders used by Strapi plugin development workflows
|
|
177
|
+
- `strapi-admin.js` and `strapi-server.js` entry files
|
|
178
|
+
- README, changelog, contributing guide, and license
|
|
179
|
+
|
|
180
|
+
## 🤝 Contributing
|
|
181
|
+
|
|
182
|
+
Issues and pull requests are welcome. Please include your Strapi version, reproduction steps, and any relevant content type schema details.
|
|
183
|
+
|
|
184
|
+
## 📄 License
|
|
185
|
+
|
|
186
|
+
MIT
|