@plone/volto 18.0.0-alpha.33 → 18.0.0-alpha.34
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 +18 -0
- package/locales/ca/LC_MESSAGES/volto.po +5 -0
- package/locales/ca.json +1 -1
- package/locales/de/LC_MESSAGES/volto.po +5 -0
- package/locales/de.json +1 -1
- package/locales/en/LC_MESSAGES/volto.po +5 -0
- package/locales/en.json +1 -1
- package/locales/es/LC_MESSAGES/volto.po +5 -0
- package/locales/es.json +1 -1
- package/locales/eu/LC_MESSAGES/volto.po +5 -0
- package/locales/eu.json +1 -1
- package/locales/fi/LC_MESSAGES/volto.po +5 -0
- package/locales/fi.json +1 -1
- package/locales/fr/LC_MESSAGES/volto.po +5 -0
- package/locales/fr.json +1 -1
- package/locales/hi/LC_MESSAGES/volto.po +5 -0
- package/locales/hi.json +1 -1
- package/locales/it/LC_MESSAGES/volto.po +5 -0
- package/locales/it.json +1 -1
- package/locales/ja/LC_MESSAGES/volto.po +5 -0
- package/locales/ja.json +1 -1
- package/locales/nl/LC_MESSAGES/volto.po +5 -0
- package/locales/nl.json +1 -1
- package/locales/pt/LC_MESSAGES/volto.po +5 -0
- package/locales/pt.json +1 -1
- package/locales/pt_BR/LC_MESSAGES/volto.po +5 -0
- package/locales/pt_BR.json +1 -1
- package/locales/ro/LC_MESSAGES/volto.po +5 -0
- package/locales/ro.json +1 -1
- package/locales/volto.pot +5 -0
- package/locales/zh_CN/LC_MESSAGES/volto.po +5 -0
- package/locales/zh_CN.json +1 -1
- package/package.json +9 -6
- package/razzle.config.js +13 -4
- package/src/actions/form/form.js +18 -2
- package/src/actions/index.js +1 -1
- package/src/components/manage/Blocks/Block/BlocksForm.jsx +157 -81
- package/src/components/manage/Blocks/Block/BlocksForm.test.jsx +8 -0
- package/src/components/manage/Blocks/Block/Edit.jsx +37 -4
- package/src/components/manage/Blocks/Block/Order/Item.jsx +122 -0
- package/src/components/manage/Blocks/Block/Order/Order.jsx +367 -0
- package/src/components/manage/Blocks/Block/Order/SortableItem.jsx +58 -0
- package/src/components/manage/Blocks/Block/Order/utilities.js +113 -0
- package/src/components/manage/Blocks/Container/Edit.jsx +1 -0
- package/src/components/manage/Blocks/Grid/Edit.jsx +6 -4
- package/src/components/manage/Blocks/Image/schema.js +2 -0
- package/src/components/manage/Controlpanels/Relations/RelationsListing.jsx +1 -1
- package/src/components/manage/Controlpanels/Relations/RelationsMatrix.jsx +1 -1
- package/src/components/manage/Form/Form.jsx +159 -151
- package/src/components/manage/Sidebar/Sidebar.jsx +28 -1
- package/src/components/manage/Widgets/InternalUrlWidget.jsx +10 -14
- package/src/components/theme/FormattedDate/FormattedDate.jsx +13 -1
- package/src/components/theme/Icon/Icon.jsx +4 -4
- package/src/config/Loadables.jsx +18 -0
- package/src/constants/ActionTypes.js +1 -0
- package/src/helpers/Blocks/Blocks.js +182 -1
- package/src/helpers/Blocks/Blocks.test.js +136 -0
- package/src/helpers/index.js +4 -0
- package/src/reducers/form/form.js +18 -1
- package/src/reducers/form/form.test.js +15 -1
- package/theme/themes/pastanaga/extras/blocks.less +7 -6
- package/theme/themes/pastanaga/extras/sidebar.less +145 -0
- package/types/actions/form/form.d.ts +8 -1
- package/types/actions/index.d.ts +1 -1
- package/types/components/manage/Blocks/Block/Order/Item.d.ts +2 -0
- package/types/components/manage/Blocks/Block/Order/Order.d.ts +13 -0
- package/types/components/manage/Blocks/Block/Order/SortableItem.d.ts +9 -0
- package/types/components/manage/Blocks/Block/Order/utilities.d.ts +9 -0
- package/types/components/manage/Blocks/Image/schema.d.ts +2 -0
- package/types/components/theme/Icon/Icon.d.ts +8 -8
- package/types/config/Loadables.d.ts +15 -162
- package/types/constants/ActionTypes.d.ts +1 -0
- package/types/helpers/Blocks/Blocks.d.ts +13 -0
- package/types/helpers/index.d.ts +2 -2
|
@@ -7,7 +7,11 @@ import { omit, without, endsWith, find, isObject, keys, merge } from 'lodash';
|
|
|
7
7
|
import move from 'lodash-move';
|
|
8
8
|
import { v4 as uuid } from 'uuid';
|
|
9
9
|
import config from '@plone/volto/registry';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
applySchemaEnhancer,
|
|
12
|
+
insertInArray,
|
|
13
|
+
removeFromArray,
|
|
14
|
+
} from '@plone/volto/helpers';
|
|
11
15
|
|
|
12
16
|
/**
|
|
13
17
|
* Get blocks field.
|
|
@@ -714,6 +718,183 @@ export function findBlocks(blocks, types, result = []) {
|
|
|
714
718
|
return result;
|
|
715
719
|
}
|
|
716
720
|
|
|
721
|
+
export const getBlocksHierarchy = (properties) => {
|
|
722
|
+
const blocksFieldName = getBlocksFieldname(properties);
|
|
723
|
+
const blocksLayoutFieldname = getBlocksLayoutFieldname(properties);
|
|
724
|
+
return properties[blocksLayoutFieldname]?.items?.map((n) => ({
|
|
725
|
+
id: n,
|
|
726
|
+
title: properties[blocksFieldName][n]?.['@type'],
|
|
727
|
+
data: properties[blocksFieldName][n],
|
|
728
|
+
children:
|
|
729
|
+
properties[blocksFieldName][n]?.['@type'] === 'gridBlock'
|
|
730
|
+
? getBlocksHierarchy(properties[blocksFieldName][n])
|
|
731
|
+
: [],
|
|
732
|
+
}));
|
|
733
|
+
};
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Move block to different location index within blocks_layout
|
|
737
|
+
* @function moveBlock
|
|
738
|
+
* @param {Object} formData Form data
|
|
739
|
+
* @param {number} source index within form blocks_layout items
|
|
740
|
+
* @param {number} destination index within form blocks_layout items
|
|
741
|
+
* @return {Object} New form data
|
|
742
|
+
*/
|
|
743
|
+
export function moveBlockEnhanced(formData, { source, destination }) {
|
|
744
|
+
const blocksLayoutFieldname = getBlocksLayoutFieldname(formData);
|
|
745
|
+
const blocksFieldName = getBlocksFieldname(formData);
|
|
746
|
+
|
|
747
|
+
// If either one of source and destination are present
|
|
748
|
+
// (Moves intra-container or container <-> main container)
|
|
749
|
+
if (source.parent || destination.parent) {
|
|
750
|
+
// Move from a container to the main container
|
|
751
|
+
if (source.parent && !destination.parent) {
|
|
752
|
+
let clonedFormData = { ...formData };
|
|
753
|
+
|
|
754
|
+
clonedFormData[blocksFieldName][source.id] =
|
|
755
|
+
formData[blocksFieldName][source.parent][blocksFieldName][source.id];
|
|
756
|
+
|
|
757
|
+
clonedFormData[blocksLayoutFieldname].items = insertInArray(
|
|
758
|
+
formData[blocksLayoutFieldname].items,
|
|
759
|
+
source.id,
|
|
760
|
+
destination.position,
|
|
761
|
+
);
|
|
762
|
+
|
|
763
|
+
// Remove the source block from the source parent
|
|
764
|
+
const sourceContainer = findContainer(clonedFormData, {
|
|
765
|
+
containerId: source.parent,
|
|
766
|
+
});
|
|
767
|
+
delete sourceContainer[blocksFieldName][source.id];
|
|
768
|
+
sourceContainer[blocksLayoutFieldname].items = removeFromArray(
|
|
769
|
+
sourceContainer[blocksLayoutFieldname].items,
|
|
770
|
+
source.position,
|
|
771
|
+
);
|
|
772
|
+
|
|
773
|
+
return clonedFormData;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
// Move from the main container to an inner container
|
|
777
|
+
if (!source.parent && destination.parent) {
|
|
778
|
+
let clonedFormData = { ...formData };
|
|
779
|
+
|
|
780
|
+
const destinationContainer = findContainer(clonedFormData, {
|
|
781
|
+
containerId: destination.parent,
|
|
782
|
+
});
|
|
783
|
+
destinationContainer[blocksFieldName][source.id] =
|
|
784
|
+
clonedFormData[blocksFieldName][source.id];
|
|
785
|
+
destinationContainer[blocksLayoutFieldname].items = insertInArray(
|
|
786
|
+
destinationContainer[blocksLayoutFieldname].items,
|
|
787
|
+
source.id,
|
|
788
|
+
destination.position,
|
|
789
|
+
);
|
|
790
|
+
|
|
791
|
+
// Remove the source block from the source parent
|
|
792
|
+
delete clonedFormData[blocksFieldName][source.id];
|
|
793
|
+
clonedFormData[blocksLayoutFieldname].items = removeFromArray(
|
|
794
|
+
clonedFormData[blocksLayoutFieldname].items,
|
|
795
|
+
source.position,
|
|
796
|
+
);
|
|
797
|
+
|
|
798
|
+
return clonedFormData;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// Move within the same container (except moves within the main container)
|
|
802
|
+
if (source.parent === destination.parent) {
|
|
803
|
+
let clonedFormData = { ...formData };
|
|
804
|
+
|
|
805
|
+
const destinationContainer = findContainer(clonedFormData, {
|
|
806
|
+
containerId: destination.parent,
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
destinationContainer[blocksLayoutFieldname].items = move(
|
|
810
|
+
destinationContainer[blocksLayoutFieldname].items,
|
|
811
|
+
source.position,
|
|
812
|
+
destination.position,
|
|
813
|
+
);
|
|
814
|
+
return clonedFormData;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// Move between containers
|
|
818
|
+
if (source.parent !== destination.parent) {
|
|
819
|
+
let clonedFormData = { ...formData };
|
|
820
|
+
|
|
821
|
+
const destinationContainer = findContainer(clonedFormData, {
|
|
822
|
+
containerId: destination.parent,
|
|
823
|
+
});
|
|
824
|
+
destinationContainer[blocksFieldName][source.id] =
|
|
825
|
+
formData[blocksFieldName][source.parent][blocksFieldName][source.id];
|
|
826
|
+
|
|
827
|
+
destinationContainer[blocksLayoutFieldname].items = insertInArray(
|
|
828
|
+
destinationContainer[blocksLayoutFieldname].items,
|
|
829
|
+
source.id,
|
|
830
|
+
destination.position,
|
|
831
|
+
);
|
|
832
|
+
|
|
833
|
+
// Remove the source block from the source parent
|
|
834
|
+
const sourceContainer = findContainer(clonedFormData, {
|
|
835
|
+
containerId: source.parent,
|
|
836
|
+
});
|
|
837
|
+
delete sourceContainer[blocksFieldName][source.id];
|
|
838
|
+
sourceContainer[blocksLayoutFieldname].items = removeFromArray(
|
|
839
|
+
sourceContainer[blocksLayoutFieldname].items,
|
|
840
|
+
source.position,
|
|
841
|
+
);
|
|
842
|
+
|
|
843
|
+
return clonedFormData;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
// Default catch all, no source/destination parent specified
|
|
848
|
+
// Move within the main container
|
|
849
|
+
return {
|
|
850
|
+
...formData,
|
|
851
|
+
[blocksLayoutFieldname]: {
|
|
852
|
+
items: move(
|
|
853
|
+
formData[blocksLayoutFieldname].items,
|
|
854
|
+
source.position,
|
|
855
|
+
destination.position,
|
|
856
|
+
),
|
|
857
|
+
},
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* Finds the container with the specified containerId in the given formData.
|
|
863
|
+
*
|
|
864
|
+
* @param {object} formData - The form data object.
|
|
865
|
+
* @param {object} options - The options object.
|
|
866
|
+
* @param {string} options.containerId - The ID of the container to find.
|
|
867
|
+
* @returns {object|undefined} - The container object if found, otherwise undefined.
|
|
868
|
+
*/
|
|
869
|
+
export const findContainer = (formData, { containerId }) => {
|
|
870
|
+
if (
|
|
871
|
+
formData.blocks[containerId] &&
|
|
872
|
+
Object.keys(formData.blocks[containerId]).includes('blocks') &&
|
|
873
|
+
Object.keys(formData.blocks[containerId]).includes('blocks_layout')
|
|
874
|
+
) {
|
|
875
|
+
return formData.blocks[containerId];
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
let container;
|
|
879
|
+
Object.keys(formData.blocks).every((blockId) => {
|
|
880
|
+
const block = formData.blocks[blockId];
|
|
881
|
+
if (
|
|
882
|
+
formData.blocks[blockId] &&
|
|
883
|
+
Object.keys(formData.blocks[blockId]).includes('blocks') &&
|
|
884
|
+
Object.keys(formData.blocks[blockId]).includes('blocks_layout')
|
|
885
|
+
) {
|
|
886
|
+
container = findContainer(block, { containerId });
|
|
887
|
+
}
|
|
888
|
+
if (container) {
|
|
889
|
+
return false;
|
|
890
|
+
} else {
|
|
891
|
+
return true;
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
|
|
895
|
+
return container;
|
|
896
|
+
};
|
|
897
|
+
|
|
717
898
|
const _dummyIntl = {
|
|
718
899
|
formatMessage() {},
|
|
719
900
|
};
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
getPreviousNextBlock,
|
|
23
23
|
blocksFormGenerator,
|
|
24
24
|
findBlocks,
|
|
25
|
+
findContainer,
|
|
25
26
|
} from './Blocks';
|
|
26
27
|
|
|
27
28
|
import config from '@plone/volto/registry';
|
|
@@ -1507,3 +1508,138 @@ describe('findBlocks', () => {
|
|
|
1507
1508
|
expect(findBlocks(blocks, types)).toStrictEqual(['3', '4', '8', '9']);
|
|
1508
1509
|
});
|
|
1509
1510
|
});
|
|
1511
|
+
|
|
1512
|
+
describe('findContainer', () => {
|
|
1513
|
+
const blocksData = { blocks: {}, blocks_layout: { items: [] } };
|
|
1514
|
+
|
|
1515
|
+
it('Get a container in the first level (main block container)', () => {
|
|
1516
|
+
const formData = {
|
|
1517
|
+
title: 'Example',
|
|
1518
|
+
blocks: {
|
|
1519
|
+
1: { title: 'title', '@type': 'title' },
|
|
1520
|
+
2: { title: 'an image', '@type': 'image' },
|
|
1521
|
+
3: { title: 'description', '@type': 'description' },
|
|
1522
|
+
4: { title: 'a container', '@type': 'container', ...blocksData },
|
|
1523
|
+
},
|
|
1524
|
+
blocks_layout: {
|
|
1525
|
+
items: ['1', '2', '3', '4'],
|
|
1526
|
+
},
|
|
1527
|
+
};
|
|
1528
|
+
|
|
1529
|
+
expect(findContainer(formData, { containerId: '4' })).toStrictEqual({
|
|
1530
|
+
title: 'a container',
|
|
1531
|
+
'@type': 'container',
|
|
1532
|
+
...blocksData,
|
|
1533
|
+
});
|
|
1534
|
+
});
|
|
1535
|
+
|
|
1536
|
+
it('Get a container in the second level', () => {
|
|
1537
|
+
const formData = {
|
|
1538
|
+
title: 'Example',
|
|
1539
|
+
blocks: {
|
|
1540
|
+
1: { title: 'title', '@type': 'title' },
|
|
1541
|
+
2: { title: 'an image', '@type': 'image' },
|
|
1542
|
+
3: { title: 'description', '@type': 'description' },
|
|
1543
|
+
4: {
|
|
1544
|
+
title: 'a container',
|
|
1545
|
+
'@type': 'container',
|
|
1546
|
+
blocks: {
|
|
1547
|
+
1: { title: 'title', '@type': 'title' },
|
|
1548
|
+
2: { title: 'an image', '@type': 'image' },
|
|
1549
|
+
'second-level': {
|
|
1550
|
+
title: 'a container',
|
|
1551
|
+
'@type': 'container',
|
|
1552
|
+
blocks: {},
|
|
1553
|
+
blocks_layout: { items: [] },
|
|
1554
|
+
},
|
|
1555
|
+
},
|
|
1556
|
+
blocks_layout: { items: [1, 2, 'second-level'] },
|
|
1557
|
+
},
|
|
1558
|
+
},
|
|
1559
|
+
blocks_layout: {
|
|
1560
|
+
items: ['1', '2', '3', '4'],
|
|
1561
|
+
},
|
|
1562
|
+
};
|
|
1563
|
+
|
|
1564
|
+
expect(
|
|
1565
|
+
findContainer(formData, { containerId: 'second-level' }),
|
|
1566
|
+
).toStrictEqual({
|
|
1567
|
+
title: 'a container',
|
|
1568
|
+
'@type': 'container',
|
|
1569
|
+
blocks: {},
|
|
1570
|
+
blocks_layout: { items: [] },
|
|
1571
|
+
});
|
|
1572
|
+
});
|
|
1573
|
+
|
|
1574
|
+
it('Get a container in the third level', () => {
|
|
1575
|
+
const formData = {
|
|
1576
|
+
title: 'Example',
|
|
1577
|
+
blocks: {
|
|
1578
|
+
1: { title: 'title', '@type': 'title' },
|
|
1579
|
+
2: { title: 'an image', '@type': 'image' },
|
|
1580
|
+
3: { title: 'description', '@type': 'description' },
|
|
1581
|
+
4: {
|
|
1582
|
+
title: 'a container',
|
|
1583
|
+
'@type': 'container',
|
|
1584
|
+
blocks: {
|
|
1585
|
+
1: { title: 'title', '@type': 'title' },
|
|
1586
|
+
2: { title: 'an image', '@type': 'image' },
|
|
1587
|
+
'second-level': {
|
|
1588
|
+
title: 'a second level container',
|
|
1589
|
+
'@type': 'container',
|
|
1590
|
+
blocks: {
|
|
1591
|
+
'third-level': {
|
|
1592
|
+
title: 'a third level container',
|
|
1593
|
+
'@type': 'container',
|
|
1594
|
+
blocks: {},
|
|
1595
|
+
blocks_layout: { items: [] },
|
|
1596
|
+
},
|
|
1597
|
+
},
|
|
1598
|
+
blocks_layout: { items: ['third-level'] },
|
|
1599
|
+
},
|
|
1600
|
+
},
|
|
1601
|
+
blocks_layout: { items: [1, 2, 'second-level'] },
|
|
1602
|
+
},
|
|
1603
|
+
},
|
|
1604
|
+
blocks_layout: {
|
|
1605
|
+
items: ['1', '2', '3', '4'],
|
|
1606
|
+
},
|
|
1607
|
+
};
|
|
1608
|
+
|
|
1609
|
+
expect(
|
|
1610
|
+
findContainer(formData, { containerId: 'third-level' }),
|
|
1611
|
+
).toStrictEqual({
|
|
1612
|
+
title: 'a third level container',
|
|
1613
|
+
'@type': 'container',
|
|
1614
|
+
blocks: {},
|
|
1615
|
+
blocks_layout: { items: [] },
|
|
1616
|
+
});
|
|
1617
|
+
});
|
|
1618
|
+
|
|
1619
|
+
describe('findContainer then modify it', () => {
|
|
1620
|
+
const blocksData = { blocks: {}, blocks_layout: { items: [] } };
|
|
1621
|
+
|
|
1622
|
+
it('Get and modifies a container in the first level (main block container)', () => {
|
|
1623
|
+
const formData = {
|
|
1624
|
+
title: 'Example',
|
|
1625
|
+
blocks: {
|
|
1626
|
+
1: { title: 'title', '@type': 'title' },
|
|
1627
|
+
2: { title: 'an image', '@type': 'image' },
|
|
1628
|
+
3: { title: 'description', '@type': 'description' },
|
|
1629
|
+
4: { title: 'a container', '@type': 'container', ...blocksData },
|
|
1630
|
+
},
|
|
1631
|
+
blocks_layout: {
|
|
1632
|
+
items: ['1', '2', '3', '4'],
|
|
1633
|
+
},
|
|
1634
|
+
};
|
|
1635
|
+
|
|
1636
|
+
const container = findContainer(formData, { containerId: '4' });
|
|
1637
|
+
container.title = 'Modified the title of the container';
|
|
1638
|
+
expect(findContainer(formData, { containerId: '4' })).toStrictEqual({
|
|
1639
|
+
title: 'Modified the title of the container',
|
|
1640
|
+
'@type': 'container',
|
|
1641
|
+
...blocksData,
|
|
1642
|
+
});
|
|
1643
|
+
});
|
|
1644
|
+
});
|
|
1645
|
+
});
|
package/src/helpers/index.js
CHANGED
|
@@ -61,6 +61,8 @@ export {
|
|
|
61
61
|
buildStyleObjectFromData,
|
|
62
62
|
getPreviousNextBlock,
|
|
63
63
|
findBlocks,
|
|
64
|
+
getBlocksHierarchy,
|
|
65
|
+
moveBlockEnhanced,
|
|
64
66
|
} from '@plone/volto/helpers/Blocks/Blocks';
|
|
65
67
|
export {
|
|
66
68
|
getSimpleDefaultBlocks,
|
|
@@ -98,6 +100,8 @@ export {
|
|
|
98
100
|
hasApiExpander,
|
|
99
101
|
replaceItemOfArray,
|
|
100
102
|
cloneDeepSchema,
|
|
103
|
+
insertInArray,
|
|
104
|
+
removeFromArray,
|
|
101
105
|
arrayRange,
|
|
102
106
|
reorderArray,
|
|
103
107
|
isInteractiveElement,
|
|
@@ -4,10 +4,19 @@
|
|
|
4
4
|
* @module reducers/form/form
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
SET_FORM_DATA,
|
|
9
|
+
SET_UI_STATE,
|
|
10
|
+
} from '@plone/volto/constants/ActionTypes';
|
|
8
11
|
|
|
9
12
|
const initialState = {
|
|
10
13
|
global: {},
|
|
14
|
+
ui: {
|
|
15
|
+
selected: null,
|
|
16
|
+
multiSelected: [],
|
|
17
|
+
gridSelected: null,
|
|
18
|
+
hovered: null,
|
|
19
|
+
},
|
|
11
20
|
};
|
|
12
21
|
|
|
13
22
|
/**
|
|
@@ -23,6 +32,14 @@ export default function form(state = initialState, action = {}) {
|
|
|
23
32
|
...state,
|
|
24
33
|
global: action.data,
|
|
25
34
|
};
|
|
35
|
+
case SET_UI_STATE:
|
|
36
|
+
return {
|
|
37
|
+
...state,
|
|
38
|
+
ui: {
|
|
39
|
+
...state.ui,
|
|
40
|
+
...action.ui,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
26
43
|
default:
|
|
27
44
|
return state;
|
|
28
45
|
}
|
|
@@ -3,7 +3,15 @@ import { SET_FORM_DATA } from '@plone/volto/constants/ActionTypes';
|
|
|
3
3
|
|
|
4
4
|
describe('Form reducer', () => {
|
|
5
5
|
it('should return the initial state', () => {
|
|
6
|
-
expect(form()).toEqual({
|
|
6
|
+
expect(form()).toEqual({
|
|
7
|
+
global: {},
|
|
8
|
+
ui: {
|
|
9
|
+
gridSelected: null,
|
|
10
|
+
hovered: null,
|
|
11
|
+
multiSelected: [],
|
|
12
|
+
selected: null,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
7
15
|
});
|
|
8
16
|
|
|
9
17
|
it('should handle SET_FORM_DATA', () => {
|
|
@@ -14,6 +22,12 @@ describe('Form reducer', () => {
|
|
|
14
22
|
}),
|
|
15
23
|
).toEqual({
|
|
16
24
|
global: { foo: 'bar' },
|
|
25
|
+
ui: {
|
|
26
|
+
gridSelected: null,
|
|
27
|
+
hovered: null,
|
|
28
|
+
multiSelected: [],
|
|
29
|
+
selected: null,
|
|
30
|
+
},
|
|
17
31
|
});
|
|
18
32
|
});
|
|
19
33
|
});
|
|
@@ -36,20 +36,21 @@
|
|
|
36
36
|
display: inline-block;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
.block .block.selected::before,
|
|
40
|
-
.block .block.selected:hover::before {
|
|
41
|
-
border-width: 1px;
|
|
42
|
-
border-color: rgba(120, 192, 215, 0.75);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
39
|
[data-slate-editor='true'] {
|
|
46
40
|
outline: none;
|
|
47
41
|
}
|
|
48
42
|
|
|
43
|
+
.block .block.hovered::before,
|
|
49
44
|
.block .block:hover::before {
|
|
50
45
|
border-color: rgba(120, 192, 215, 0.375);
|
|
51
46
|
}
|
|
52
47
|
|
|
48
|
+
.block .block.selected::before,
|
|
49
|
+
.block .block.selected:hover::before {
|
|
50
|
+
border-width: 1px;
|
|
51
|
+
border-color: rgba(120, 192, 215, 0.75);
|
|
52
|
+
}
|
|
53
|
+
|
|
53
54
|
.block .block.multiSelected::before {
|
|
54
55
|
z-index: 1;
|
|
55
56
|
background-color: rgba(120, 192, 215, 0.375);
|
|
@@ -504,3 +504,148 @@
|
|
|
504
504
|
.formtabs {
|
|
505
505
|
flex-wrap: wrap;
|
|
506
506
|
}
|
|
507
|
+
|
|
508
|
+
// Order
|
|
509
|
+
.tree-item-wrapper {
|
|
510
|
+
box-sizing: border-box;
|
|
511
|
+
padding-left: var(--spacing);
|
|
512
|
+
margin-bottom: -1px;
|
|
513
|
+
list-style: none;
|
|
514
|
+
|
|
515
|
+
.text {
|
|
516
|
+
overflow: hidden;
|
|
517
|
+
flex-grow: 1;
|
|
518
|
+
padding-left: 0.5rem;
|
|
519
|
+
text-overflow: ellipsis;
|
|
520
|
+
white-space: nowrap;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
&.disable-interaction {
|
|
524
|
+
pointer-events: none;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
&.disable-selection,
|
|
528
|
+
&.clone {
|
|
529
|
+
.text {
|
|
530
|
+
-webkit-user-select: none;
|
|
531
|
+
user-select: none;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
&.clone {
|
|
536
|
+
display: inline-block;
|
|
537
|
+
width: 375px;
|
|
538
|
+
height: 43px;
|
|
539
|
+
padding: 0;
|
|
540
|
+
pointer-events: none;
|
|
541
|
+
|
|
542
|
+
.tree-item {
|
|
543
|
+
box-shadow: 0px 15px 15px 0 rgba(34, 33, 81, 0.1);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
&.ghost {
|
|
548
|
+
&.indicator {
|
|
549
|
+
position: relative;
|
|
550
|
+
z-index: 1;
|
|
551
|
+
margin-bottom: -1px;
|
|
552
|
+
opacity: 1;
|
|
553
|
+
|
|
554
|
+
.tree-item {
|
|
555
|
+
position: relative;
|
|
556
|
+
height: 8px;
|
|
557
|
+
padding: 0;
|
|
558
|
+
border-color: #2389ff;
|
|
559
|
+
background-color: #56a1f8;
|
|
560
|
+
|
|
561
|
+
&:before {
|
|
562
|
+
position: absolute;
|
|
563
|
+
top: -4px;
|
|
564
|
+
left: -8px;
|
|
565
|
+
display: block;
|
|
566
|
+
width: 12px;
|
|
567
|
+
height: 12px;
|
|
568
|
+
border: 1px solid #2389ff;
|
|
569
|
+
border-radius: 50%;
|
|
570
|
+
background-color: #ffffff;
|
|
571
|
+
content: '';
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
> * {
|
|
575
|
+
height: 0;
|
|
576
|
+
/* Items are hidden using height and opacity to retain focus */
|
|
577
|
+
opacity: 0;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
&:not(.indicator) {
|
|
583
|
+
opacity: 0.5;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
.tree-item > * {
|
|
587
|
+
background-color: transparent;
|
|
588
|
+
box-shadow: none;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
.tree-item {
|
|
593
|
+
position: relative;
|
|
594
|
+
display: flex;
|
|
595
|
+
box-sizing: border-box;
|
|
596
|
+
align-items: center;
|
|
597
|
+
padding: var(--vertical-padding) 10px;
|
|
598
|
+
border: 1px solid #edf1f2;
|
|
599
|
+
background-color: #fff;
|
|
600
|
+
color: #222;
|
|
601
|
+
cursor: pointer;
|
|
602
|
+
--vertical-padding: 10px;
|
|
603
|
+
|
|
604
|
+
.delete {
|
|
605
|
+
visibility: hidden;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
&.depth-0 {
|
|
609
|
+
border-left: solid 1px white;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
&.hovered {
|
|
613
|
+
z-index: 99;
|
|
614
|
+
border: solid 1px #69b6fa;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
&.selected {
|
|
618
|
+
z-index: 99;
|
|
619
|
+
border: solid 1px #2996da;
|
|
620
|
+
|
|
621
|
+
.delete {
|
|
622
|
+
visibility: visible;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
&.multiSelected {
|
|
627
|
+
z-index: 99;
|
|
628
|
+
border: solid 1px #2996da;
|
|
629
|
+
background-color: rgba(120, 192, 215, 0.375);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
.action {
|
|
633
|
+
border: 0;
|
|
634
|
+
margin-left: 8px;
|
|
635
|
+
background-color: transparent;
|
|
636
|
+
color: rgba(0, 0, 0, 0.6);
|
|
637
|
+
|
|
638
|
+
.icon {
|
|
639
|
+
vertical-align: middle;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
&.delete {
|
|
643
|
+
cursor: pointer;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
&.drag {
|
|
647
|
+
cursor: grab;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
* Set form data function.
|
|
3
3
|
* @function setFormData
|
|
4
4
|
* @param {Object} data New form data.
|
|
5
|
-
* @returns {Object} Set
|
|
5
|
+
* @returns {Object} Set form data action.
|
|
6
6
|
*/
|
|
7
7
|
export function setFormData(data: any): any;
|
|
8
|
+
/**
|
|
9
|
+
* Set ui state function.
|
|
10
|
+
* @function setUIState
|
|
11
|
+
* @param {Object} ui New ui state.
|
|
12
|
+
* @returns {Object} Set ui state action.
|
|
13
|
+
*/
|
|
14
|
+
export function setUIState(ui: any): any;
|
package/types/actions/index.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export { listRoles } from "@plone/volto/actions/roles/roles";
|
|
|
10
10
|
export { getTypes } from "@plone/volto/actions/types/types";
|
|
11
11
|
export { getQuerystring } from "@plone/volto/actions/querystring/querystring";
|
|
12
12
|
export { getQueryStringResults } from "@plone/volto/actions/querystringsearch/querystringsearch";
|
|
13
|
-
export { setFormData } from "@plone/volto/actions/form/form";
|
|
14
13
|
export { loadLazyLibrary } from "@plone/volto/actions/lazyLibraries/lazyLibraries";
|
|
15
14
|
export { getContextNavigation } from "@plone/volto/actions/contextNavigation/contextNavigation";
|
|
16
15
|
export { authenticatedRole } from "@plone/volto/actions/authRole/authRole";
|
|
@@ -38,6 +37,7 @@ export { login, loginRenew, logout, resetLoginRequest } from "@plone/volto/actio
|
|
|
38
37
|
export { getVocabulary, getVocabularyTokenTitle } from "@plone/volto/actions/vocabularies/vocabularies";
|
|
39
38
|
export { getWorkflow, transitionWorkflow } from "@plone/volto/actions/workflow/workflow";
|
|
40
39
|
export { setMetadataFieldsets, setMetadataFocus, resetMetadataFocus, setSidebarTab } from "@plone/volto/actions/sidebar/sidebar";
|
|
40
|
+
export { setFormData, setUIState } from "@plone/volto/actions/form/form";
|
|
41
41
|
export { deleteLinkTranslation, getTranslationLocator, linkTranslation } from "@plone/volto/actions/translations/translations";
|
|
42
42
|
export { setBlocksClipboard, resetBlocksClipboard } from "@plone/volto/actions/blocksClipboard/blocksClipboard";
|
|
43
43
|
export { changeLanguage, changeLanguageCookies } from "./language/language";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function Order({ items, onMoveBlock, onDeleteBlock, onSelectBlock, indentationWidth, removable, dndKitCore, dndKitSortable, dndKitUtilities, }: {
|
|
2
|
+
items?: any[];
|
|
3
|
+
onMoveBlock: any;
|
|
4
|
+
onDeleteBlock: any;
|
|
5
|
+
onSelectBlock: any;
|
|
6
|
+
indentationWidth?: number;
|
|
7
|
+
removable: any;
|
|
8
|
+
dndKitCore: any;
|
|
9
|
+
dndKitSortable: any;
|
|
10
|
+
dndKitUtilities: any;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare const _default: any;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function SortableItem({ id, depth, dndKitSortable, dndKitUtilities, ...props }: {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
id: any;
|
|
4
|
+
depth: any;
|
|
5
|
+
dndKitSortable: any;
|
|
6
|
+
dndKitUtilities: any;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare const _default: any;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function getProjection(items: any, activeId: any, overId: any, dragOffset: any, indentationWidth: any, arrayMove: any): {
|
|
2
|
+
depth: any;
|
|
3
|
+
maxDepth: any;
|
|
4
|
+
minDepth: any;
|
|
5
|
+
parentId: any;
|
|
6
|
+
};
|
|
7
|
+
export function flattenTree(items: any): any;
|
|
8
|
+
export function findItem(items: any, itemId: any): any;
|
|
9
|
+
export function removeChildrenOf(items: any, ids: any): any;
|