@wordpress/editor 13.17.0 → 13.18.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 +2 -0
- package/build/components/entities-saved-states/hooks/use-is-dirty.js +17 -12
- package/build/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js +18 -13
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/package.json +31 -31
- package/src/components/entities-saved-states/hooks/use-is-dirty.js +16 -20
package/CHANGELOG.md
CHANGED
|
@@ -24,27 +24,32 @@ const TRANSLATED_SITE_PROPERTIES = {
|
|
|
24
24
|
};
|
|
25
25
|
const useIsDirty = () => {
|
|
26
26
|
const {
|
|
27
|
-
|
|
27
|
+
editedEntities,
|
|
28
|
+
siteEdits
|
|
28
29
|
} = (0, _data.useSelect)(select => {
|
|
29
|
-
const
|
|
30
|
-
|
|
30
|
+
const {
|
|
31
|
+
__experimentalGetDirtyEntityRecords,
|
|
32
|
+
getEntityRecordEdits
|
|
33
|
+
} = select(_coreData.store);
|
|
34
|
+
return {
|
|
35
|
+
editedEntities: __experimentalGetDirtyEntityRecords(),
|
|
36
|
+
siteEdits: getEntityRecordEdits('root', 'site')
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
39
|
+
const dirtyEntityRecords = (0, _element.useMemo)(() => {
|
|
31
40
|
// Remove site object and decouple into its edited pieces.
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const siteEditsAsEntities = [];
|
|
41
|
+
const editedEntitiesWithoutSite = editedEntities.filter(record => !(record.kind === 'root' && record.name === 'site'));
|
|
42
|
+
const editedSiteEntities = [];
|
|
35
43
|
for (const property in siteEdits) {
|
|
36
|
-
|
|
44
|
+
editedSiteEntities.push({
|
|
37
45
|
kind: 'root',
|
|
38
46
|
name: 'site',
|
|
39
47
|
title: TRANSLATED_SITE_PROPERTIES[property] || property,
|
|
40
48
|
property
|
|
41
49
|
});
|
|
42
50
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
dirtyEntityRecords: dirtyRecordsWithSiteItems
|
|
46
|
-
};
|
|
47
|
-
}, []);
|
|
51
|
+
return [...editedEntitiesWithoutSite, ...editedSiteEntities];
|
|
52
|
+
}, [editedEntities, siteEdits]);
|
|
48
53
|
|
|
49
54
|
// Unchecked entities to be ignored by save function.
|
|
50
55
|
const [unselectedEntities, _setUnselectedEntities] = (0, _element.useState)([]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_coreData","_element","_i18n","TRANSLATED_SITE_PROPERTIES","title","__","description","site_logo","site_icon","show_on_front","page_on_front","posts_per_page","default_comment_status","useIsDirty","
|
|
1
|
+
{"version":3,"names":["_data","require","_coreData","_element","_i18n","TRANSLATED_SITE_PROPERTIES","title","__","description","site_logo","site_icon","show_on_front","page_on_front","posts_per_page","default_comment_status","useIsDirty","editedEntities","siteEdits","useSelect","select","__experimentalGetDirtyEntityRecords","getEntityRecordEdits","coreStore","dirtyEntityRecords","useMemo","editedEntitiesWithoutSite","filter","record","kind","name","editedSiteEntities","property","push","unselectedEntities","_setUnselectedEntities","useState","setUnselectedEntities","key","checked","elt","isDirty","length","exports"],"sources":["@wordpress/editor/src/components/entities-saved-states/hooks/use-is-dirty.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMemo, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\nconst TRANSLATED_SITE_PROPERTIES = {\n\ttitle: __( 'Title' ),\n\tdescription: __( 'Tagline' ),\n\tsite_logo: __( 'Logo' ),\n\tsite_icon: __( 'Icon' ),\n\tshow_on_front: __( 'Show on front' ),\n\tpage_on_front: __( 'Page on front' ),\n\tposts_per_page: __( 'Maximum posts per page' ),\n\tdefault_comment_status: __( 'Allow comments on new posts' ),\n};\n\nexport const useIsDirty = () => {\n\tconst { editedEntities, siteEdits } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetDirtyEntityRecords, getEntityRecordEdits } =\n\t\t\tselect( coreStore );\n\n\t\treturn {\n\t\t\teditedEntities: __experimentalGetDirtyEntityRecords(),\n\t\t\tsiteEdits: getEntityRecordEdits( 'root', 'site' ),\n\t\t};\n\t}, [] );\n\n\tconst dirtyEntityRecords = useMemo( () => {\n\t\t// Remove site object and decouple into its edited pieces.\n\t\tconst editedEntitiesWithoutSite = editedEntities.filter(\n\t\t\t( record ) => ! ( record.kind === 'root' && record.name === 'site' )\n\t\t);\n\n\t\tconst editedSiteEntities = [];\n\t\tfor ( const property in siteEdits ) {\n\t\t\teditedSiteEntities.push( {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t\ttitle: TRANSLATED_SITE_PROPERTIES[ property ] || property,\n\t\t\t\tproperty,\n\t\t\t} );\n\t\t}\n\n\t\treturn [ ...editedEntitiesWithoutSite, ...editedSiteEntities ];\n\t}, [ editedEntities, siteEdits ] );\n\n\t// Unchecked entities to be ignored by save function.\n\tconst [ unselectedEntities, _setUnselectedEntities ] = useState( [] );\n\n\tconst setUnselectedEntities = (\n\t\t{ kind, name, key, property },\n\t\tchecked\n\t) => {\n\t\tif ( checked ) {\n\t\t\t_setUnselectedEntities(\n\t\t\t\tunselectedEntities.filter(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind !== kind ||\n\t\t\t\t\t\telt.name !== name ||\n\t\t\t\t\t\telt.key !== key ||\n\t\t\t\t\t\telt.property !== property\n\t\t\t\t)\n\t\t\t);\n\t\t} else {\n\t\t\t_setUnselectedEntities( [\n\t\t\t\t...unselectedEntities,\n\t\t\t\t{ kind, name, key, property },\n\t\t\t] );\n\t\t}\n\t};\n\n\tconst isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;\n\n\treturn {\n\t\tdirtyEntityRecords,\n\t\tisDirty,\n\t\tsetUnselectedEntities,\n\t\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from '@wordpress/data';
|
|
5
5
|
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
-
import { useState } from '@wordpress/element';
|
|
6
|
+
import { useMemo, useState } from '@wordpress/element';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
const TRANSLATED_SITE_PROPERTIES = {
|
|
9
9
|
title: __('Title'),
|
|
@@ -17,27 +17,32 @@ const TRANSLATED_SITE_PROPERTIES = {
|
|
|
17
17
|
};
|
|
18
18
|
export const useIsDirty = () => {
|
|
19
19
|
const {
|
|
20
|
-
|
|
20
|
+
editedEntities,
|
|
21
|
+
siteEdits
|
|
21
22
|
} = useSelect(select => {
|
|
22
|
-
const
|
|
23
|
-
|
|
23
|
+
const {
|
|
24
|
+
__experimentalGetDirtyEntityRecords,
|
|
25
|
+
getEntityRecordEdits
|
|
26
|
+
} = select(coreStore);
|
|
27
|
+
return {
|
|
28
|
+
editedEntities: __experimentalGetDirtyEntityRecords(),
|
|
29
|
+
siteEdits: getEntityRecordEdits('root', 'site')
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
32
|
+
const dirtyEntityRecords = useMemo(() => {
|
|
24
33
|
// Remove site object and decouple into its edited pieces.
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const siteEditsAsEntities = [];
|
|
34
|
+
const editedEntitiesWithoutSite = editedEntities.filter(record => !(record.kind === 'root' && record.name === 'site'));
|
|
35
|
+
const editedSiteEntities = [];
|
|
28
36
|
for (const property in siteEdits) {
|
|
29
|
-
|
|
37
|
+
editedSiteEntities.push({
|
|
30
38
|
kind: 'root',
|
|
31
39
|
name: 'site',
|
|
32
40
|
title: TRANSLATED_SITE_PROPERTIES[property] || property,
|
|
33
41
|
property
|
|
34
42
|
});
|
|
35
43
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
dirtyEntityRecords: dirtyRecordsWithSiteItems
|
|
39
|
-
};
|
|
40
|
-
}, []);
|
|
44
|
+
return [...editedEntitiesWithoutSite, ...editedSiteEntities];
|
|
45
|
+
}, [editedEntities, siteEdits]);
|
|
41
46
|
|
|
42
47
|
// Unchecked entities to be ignored by save function.
|
|
43
48
|
const [unselectedEntities, _setUnselectedEntities] = useState([]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","store","coreStore","useState","__","TRANSLATED_SITE_PROPERTIES","title","description","site_logo","site_icon","show_on_front","page_on_front","posts_per_page","default_comment_status","useIsDirty","
|
|
1
|
+
{"version":3,"names":["useSelect","store","coreStore","useMemo","useState","__","TRANSLATED_SITE_PROPERTIES","title","description","site_logo","site_icon","show_on_front","page_on_front","posts_per_page","default_comment_status","useIsDirty","editedEntities","siteEdits","select","__experimentalGetDirtyEntityRecords","getEntityRecordEdits","dirtyEntityRecords","editedEntitiesWithoutSite","filter","record","kind","name","editedSiteEntities","property","push","unselectedEntities","_setUnselectedEntities","setUnselectedEntities","key","checked","elt","isDirty","length"],"sources":["@wordpress/editor/src/components/entities-saved-states/hooks/use-is-dirty.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMemo, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\nconst TRANSLATED_SITE_PROPERTIES = {\n\ttitle: __( 'Title' ),\n\tdescription: __( 'Tagline' ),\n\tsite_logo: __( 'Logo' ),\n\tsite_icon: __( 'Icon' ),\n\tshow_on_front: __( 'Show on front' ),\n\tpage_on_front: __( 'Page on front' ),\n\tposts_per_page: __( 'Maximum posts per page' ),\n\tdefault_comment_status: __( 'Allow comments on new posts' ),\n};\n\nexport const useIsDirty = () => {\n\tconst { editedEntities, siteEdits } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetDirtyEntityRecords, getEntityRecordEdits } =\n\t\t\tselect( coreStore );\n\n\t\treturn {\n\t\t\teditedEntities: __experimentalGetDirtyEntityRecords(),\n\t\t\tsiteEdits: getEntityRecordEdits( 'root', 'site' ),\n\t\t};\n\t}, [] );\n\n\tconst dirtyEntityRecords = useMemo( () => {\n\t\t// Remove site object and decouple into its edited pieces.\n\t\tconst editedEntitiesWithoutSite = editedEntities.filter(\n\t\t\t( record ) => ! ( record.kind === 'root' && record.name === 'site' )\n\t\t);\n\n\t\tconst editedSiteEntities = [];\n\t\tfor ( const property in siteEdits ) {\n\t\t\teditedSiteEntities.push( {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t\ttitle: TRANSLATED_SITE_PROPERTIES[ property ] || property,\n\t\t\t\tproperty,\n\t\t\t} );\n\t\t}\n\n\t\treturn [ ...editedEntitiesWithoutSite, ...editedSiteEntities ];\n\t}, [ editedEntities, siteEdits ] );\n\n\t// Unchecked entities to be ignored by save function.\n\tconst [ unselectedEntities, _setUnselectedEntities ] = useState( [] );\n\n\tconst setUnselectedEntities = (\n\t\t{ kind, name, key, property },\n\t\tchecked\n\t) => {\n\t\tif ( checked ) {\n\t\t\t_setUnselectedEntities(\n\t\t\t\tunselectedEntities.filter(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind !== kind ||\n\t\t\t\t\t\telt.name !== name ||\n\t\t\t\t\t\telt.key !== key ||\n\t\t\t\t\t\telt.property !== property\n\t\t\t\t)\n\t\t\t);\n\t\t} else {\n\t\t\t_setUnselectedEntities( [\n\t\t\t\t...unselectedEntities,\n\t\t\t\t{ kind, name, key, property },\n\t\t\t] );\n\t\t}\n\t};\n\n\tconst isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;\n\n\treturn {\n\t\tdirtyEntityRecords,\n\t\tisDirty,\n\t\tsetUnselectedEntities,\n\t\tunselectedEntities,\n\t};\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,EAAE,QAAQ,iBAAiB;AAEpC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E,GAAGN,yBAAyB,EAAE,GAAGK,kBAAkB,CAAE;EAC/D,CAAC,EAAE,CAAEX,cAAc,EAAEC,SAAS,CAAG,CAAC;;EAElC;EACA,MAAM,CAAEa,kBAAkB,EAAEC,sBAAsB,CAAE,GAAG3B,QAAQ,CAAE,EAAG,CAAC;EAErE,MAAM4B,qBAAqB,GAAGA,CAC7B;IAAEP,IAAI;IAAEC,IAAI;IAAEO,GAAG;IAAEL;EAAS,CAAC,EAC7BM,OAAO,KACH;IACJ,IAAKA,OAAO,EAAG;MACdH,sBAAsB,CACrBD,kBAAkB,CAACP,MAAM,CACtBY,GAAG,IACJA,GAAG,CAACV,IAAI,KAAKA,IAAI,IACjBU,GAAG,CAACT,IAAI,KAAKA,IAAI,IACjBS,GAAG,CAACF,GAAG,KAAKA,GAAG,IACfE,GAAG,CAACP,QAAQ,KAAKA,QACnB,CACD,CAAC;IACF,CAAC,MAAM;MACNG,sBAAsB,CAAE,CACvB,GAAGD,kBAAkB,EACrB;QAAEL,IAAI;QAAEC,IAAI;QAAEO,GAAG;QAAEL;MAAS,CAAC,CAC5B,CAAC;IACJ;EACD,CAAC;EAED,MAAMQ,OAAO,GAAGf,kBAAkB,CAACgB,MAAM,GAAGP,kBAAkB,CAACO,MAAM,GAAG,CAAC;EAEzE,OAAO;IACNhB,kBAAkB;IAClBe,OAAO;IACPJ,qBAAqB;IACrBF;EACD,CAAC;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.18.0",
|
|
4
4
|
"description": "Enhanced block editor for WordPress posts.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,35 +31,35 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.16.0",
|
|
34
|
-
"@wordpress/a11y": "^3.
|
|
35
|
-
"@wordpress/api-fetch": "^6.
|
|
36
|
-
"@wordpress/blob": "^3.
|
|
37
|
-
"@wordpress/block-editor": "^12.
|
|
38
|
-
"@wordpress/blocks": "^12.
|
|
39
|
-
"@wordpress/components": "^25.
|
|
40
|
-
"@wordpress/compose": "^6.
|
|
41
|
-
"@wordpress/core-data": "^6.
|
|
42
|
-
"@wordpress/data": "^9.
|
|
43
|
-
"@wordpress/date": "^4.
|
|
44
|
-
"@wordpress/deprecated": "^3.
|
|
45
|
-
"@wordpress/dom": "^3.
|
|
46
|
-
"@wordpress/element": "^5.
|
|
47
|
-
"@wordpress/hooks": "^3.
|
|
48
|
-
"@wordpress/html-entities": "^3.
|
|
49
|
-
"@wordpress/i18n": "^4.
|
|
50
|
-
"@wordpress/icons": "^9.
|
|
51
|
-
"@wordpress/keyboard-shortcuts": "^4.
|
|
52
|
-
"@wordpress/keycodes": "^3.
|
|
53
|
-
"@wordpress/media-utils": "^4.
|
|
54
|
-
"@wordpress/notices": "^4.
|
|
55
|
-
"@wordpress/patterns": "^1.
|
|
56
|
-
"@wordpress/preferences": "^3.
|
|
57
|
-
"@wordpress/private-apis": "^0.
|
|
58
|
-
"@wordpress/reusable-blocks": "^4.
|
|
59
|
-
"@wordpress/rich-text": "^6.
|
|
60
|
-
"@wordpress/server-side-render": "^4.
|
|
61
|
-
"@wordpress/url": "^3.
|
|
62
|
-
"@wordpress/wordcount": "^3.
|
|
34
|
+
"@wordpress/a11y": "^3.41.0",
|
|
35
|
+
"@wordpress/api-fetch": "^6.38.0",
|
|
36
|
+
"@wordpress/blob": "^3.41.0",
|
|
37
|
+
"@wordpress/block-editor": "^12.9.0",
|
|
38
|
+
"@wordpress/blocks": "^12.18.0",
|
|
39
|
+
"@wordpress/components": "^25.7.0",
|
|
40
|
+
"@wordpress/compose": "^6.18.0",
|
|
41
|
+
"@wordpress/core-data": "^6.18.0",
|
|
42
|
+
"@wordpress/data": "^9.11.0",
|
|
43
|
+
"@wordpress/date": "^4.41.0",
|
|
44
|
+
"@wordpress/deprecated": "^3.41.0",
|
|
45
|
+
"@wordpress/dom": "^3.41.0",
|
|
46
|
+
"@wordpress/element": "^5.18.0",
|
|
47
|
+
"@wordpress/hooks": "^3.41.0",
|
|
48
|
+
"@wordpress/html-entities": "^3.41.0",
|
|
49
|
+
"@wordpress/i18n": "^4.41.0",
|
|
50
|
+
"@wordpress/icons": "^9.32.0",
|
|
51
|
+
"@wordpress/keyboard-shortcuts": "^4.18.0",
|
|
52
|
+
"@wordpress/keycodes": "^3.41.0",
|
|
53
|
+
"@wordpress/media-utils": "^4.32.0",
|
|
54
|
+
"@wordpress/notices": "^4.9.0",
|
|
55
|
+
"@wordpress/patterns": "^1.2.0",
|
|
56
|
+
"@wordpress/preferences": "^3.18.0",
|
|
57
|
+
"@wordpress/private-apis": "^0.23.0",
|
|
58
|
+
"@wordpress/reusable-blocks": "^4.18.0",
|
|
59
|
+
"@wordpress/rich-text": "^6.18.0",
|
|
60
|
+
"@wordpress/server-side-render": "^4.18.0",
|
|
61
|
+
"@wordpress/url": "^3.42.0",
|
|
62
|
+
"@wordpress/wordcount": "^3.41.0",
|
|
63
63
|
"classnames": "^2.3.1",
|
|
64
64
|
"date-fns": "^2.28.0",
|
|
65
65
|
"memize": "^2.1.0",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "5eac1734bcdca2301fdd37ec8cfe2a45e722a2c4"
|
|
78
78
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
5
|
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
-
import { useState } from '@wordpress/element';
|
|
6
|
+
import { useMemo, useState } from '@wordpress/element';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
|
|
9
9
|
const TRANSLATED_SITE_PROPERTIES = {
|
|
@@ -18,38 +18,34 @@ const TRANSLATED_SITE_PROPERTIES = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export const useIsDirty = () => {
|
|
21
|
-
const {
|
|
22
|
-
const
|
|
23
|
-
select( coreStore )
|
|
21
|
+
const { editedEntities, siteEdits } = useSelect( ( select ) => {
|
|
22
|
+
const { __experimentalGetDirtyEntityRecords, getEntityRecordEdits } =
|
|
23
|
+
select( coreStore );
|
|
24
24
|
|
|
25
|
+
return {
|
|
26
|
+
editedEntities: __experimentalGetDirtyEntityRecords(),
|
|
27
|
+
siteEdits: getEntityRecordEdits( 'root', 'site' ),
|
|
28
|
+
};
|
|
29
|
+
}, [] );
|
|
30
|
+
|
|
31
|
+
const dirtyEntityRecords = useMemo( () => {
|
|
25
32
|
// Remove site object and decouple into its edited pieces.
|
|
26
|
-
const
|
|
33
|
+
const editedEntitiesWithoutSite = editedEntities.filter(
|
|
27
34
|
( record ) => ! ( record.kind === 'root' && record.name === 'site' )
|
|
28
35
|
);
|
|
29
36
|
|
|
30
|
-
const
|
|
31
|
-
'root',
|
|
32
|
-
'site'
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const siteEditsAsEntities = [];
|
|
37
|
+
const editedSiteEntities = [];
|
|
36
38
|
for ( const property in siteEdits ) {
|
|
37
|
-
|
|
39
|
+
editedSiteEntities.push( {
|
|
38
40
|
kind: 'root',
|
|
39
41
|
name: 'site',
|
|
40
42
|
title: TRANSLATED_SITE_PROPERTIES[ property ] || property,
|
|
41
43
|
property,
|
|
42
44
|
} );
|
|
43
45
|
}
|
|
44
|
-
const dirtyRecordsWithSiteItems = [
|
|
45
|
-
...dirtyRecordsWithoutSite,
|
|
46
|
-
...siteEditsAsEntities,
|
|
47
|
-
];
|
|
48
46
|
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
}, [] );
|
|
47
|
+
return [ ...editedEntitiesWithoutSite, ...editedSiteEntities ];
|
|
48
|
+
}, [ editedEntities, siteEdits ] );
|
|
53
49
|
|
|
54
50
|
// Unchecked entities to be ignored by save function.
|
|
55
51
|
const [ unselectedEntities, _setUnselectedEntities ] = useState( [] );
|