strapi-dz-component-duplicator 0.1.4 → 0.1.6
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.
|
@@ -780,7 +780,27 @@ const DynamicZoneActionInjector = () => {
|
|
|
780
780
|
throw new Error('Invalid dynamic zone clone');
|
|
781
781
|
}
|
|
782
782
|
|
|
783
|
-
|
|
783
|
+
const currentZone = getIn(valuesRef.current, dynamicZonePath);
|
|
784
|
+
|
|
785
|
+
if (!Array.isArray(currentZone)) {
|
|
786
|
+
throw new Error('Dynamic zone not found');
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// Strapi 5.0.0–5.8.0 had a bug where addFieldRow(field, value, addAtIndex)
|
|
790
|
+
// overwrote the item at `addAtIndex` instead of inserting before it
|
|
791
|
+
// (fixed upstream in PR #22656, shipped in 5.8.1). Append-then-move avoids
|
|
792
|
+
// that codepath entirely so the plugin works on every Strapi 5.
|
|
793
|
+
const targetIndex = index + 1;
|
|
794
|
+
const appendedIndex = currentZone.length;
|
|
795
|
+
|
|
796
|
+
form.addFieldRow(dynamicZonePath, cloned);
|
|
797
|
+
|
|
798
|
+
if (
|
|
799
|
+
appendedIndex !== targetIndex &&
|
|
800
|
+
typeof form.moveFieldRow === 'function'
|
|
801
|
+
) {
|
|
802
|
+
form.moveFieldRow(dynamicZonePath, appendedIndex, targetIndex);
|
|
803
|
+
}
|
|
784
804
|
} catch {
|
|
785
805
|
toggleNotification({
|
|
786
806
|
type: 'danger',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-dz-component-duplicator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Duplicate dynamic zone components directly from Strapi 5 edit view.",
|
|
5
5
|
"author": "Djordje Savanovic",
|
|
6
6
|
"keywords": [
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@strapi/strapi": "^5.0.0",
|
|
48
48
|
"react": "^18.0.0",
|
|
49
49
|
"react-dom": "^18.0.0",
|
|
50
|
-
"react-intl": "^7.0.0"
|
|
50
|
+
"react-intl": "^6.0.0 || ^7.0.0"
|
|
51
51
|
},
|
|
52
52
|
"strapi": {
|
|
53
53
|
"name": "strapi-dz-component-duplicator",
|