@secretstache/wordpress-gutenberg 0.3.13 → 0.3.14
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -2,7 +2,7 @@ import { Button, Icon as WPIcon } from '@wordpress/components';
|
|
2
2
|
import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
|
3
3
|
import { page as pageIcon } from '@wordpress/icons';
|
4
4
|
|
5
|
-
import {
|
5
|
+
import { MEDIA_TYPE } from '../utils/index.js';
|
6
6
|
|
7
7
|
export const ImageRenderer = ({
|
8
8
|
imageId,
|
@@ -115,12 +115,12 @@ export const MediaControl = ({
|
|
115
115
|
mediaFileName = '',
|
116
116
|
onSelect,
|
117
117
|
onRemove,
|
118
|
-
type =
|
118
|
+
type = MEDIA_TYPE.IMAGE,
|
119
119
|
selectButtonLabel,
|
120
120
|
removeButtonLabel,
|
121
121
|
...other
|
122
122
|
}) => {
|
123
|
-
if (type ===
|
123
|
+
if (type === MEDIA_TYPE.IMAGE) {
|
124
124
|
return (
|
125
125
|
<MediaUploadCheck>
|
126
126
|
<MediaUpload
|
@@ -143,7 +143,7 @@ export const MediaControl = ({
|
|
143
143
|
/>
|
144
144
|
</MediaUploadCheck>
|
145
145
|
);
|
146
|
-
} else if (type ===
|
146
|
+
} else if (type === MEDIA_TYPE.VIDEO) {
|
147
147
|
return (
|
148
148
|
<MediaUploadCheck>
|
149
149
|
<MediaUpload
|
@@ -164,7 +164,7 @@ export const MediaControl = ({
|
|
164
164
|
/>
|
165
165
|
</MediaUploadCheck>
|
166
166
|
);
|
167
|
-
} else if (type ===
|
167
|
+
} else if (type === MEDIA_TYPE.ANIMATION) {
|
168
168
|
return (
|
169
169
|
<MediaUploadCheck>
|
170
170
|
<MediaUpload
|
@@ -2,11 +2,11 @@ import { useMemo } from '@wordpress/element';
|
|
2
2
|
import { SelectControl } from '@wordpress/components';
|
3
3
|
|
4
4
|
import { MediaControl } from './MediaControl.js';
|
5
|
-
import {
|
5
|
+
import { MEDIA_TYPE_LABEL, MEDIA_TYPE } from '../utils/index.js';
|
6
6
|
|
7
7
|
export const MediaTypeControl = (props) => {
|
8
8
|
const {
|
9
|
-
types = [
|
9
|
+
types = [ MEDIA_TYPE.IMAGE, MEDIA_TYPE.VIDEO ],
|
10
10
|
|
11
11
|
selectedType,
|
12
12
|
onTypeChange,
|
@@ -22,9 +22,9 @@ export const MediaTypeControl = (props) => {
|
|
22
22
|
} = props;
|
23
23
|
|
24
24
|
const typesOptions = useMemo(() => types
|
25
|
-
?.filter((type) =>
|
25
|
+
?.filter((type) => MEDIA_TYPE_LABEL[type]) // Ensure it's an allowed type
|
26
26
|
?.map((type) => ({
|
27
|
-
label:
|
27
|
+
label: MEDIA_TYPE_LABEL[type],
|
28
28
|
value: type,
|
29
29
|
}))
|
30
30
|
, [ types ]);
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import { useSelect } from '@wordpress/data';
|
2
|
-
import {
|
2
|
+
import { QUERY_TYPE } from '../utils';
|
3
3
|
|
4
|
-
// TODO: numberOfPosts -1 is not a valid value, the API requires the per_page to be >= 1
|
4
|
+
// TODO: 1. numberOfPosts -1 is not a valid value, the API requires the per_page to be >= 1
|
5
|
+
// TODO: 2. make 'dependencies' the separate second argument
|
6
|
+
// TODO: 3. consider supporting the string value for the getPostType as well as function
|
5
7
|
export const useDataQuery = (props) => {
|
6
8
|
const {
|
7
9
|
getPostType,
|
@@ -25,9 +27,9 @@ export const useDataQuery = (props) => {
|
|
25
27
|
...extraQueryArgs,
|
26
28
|
};
|
27
29
|
|
28
|
-
if (queryType ===
|
30
|
+
if (queryType === QUERY_TYPE.BY_CATEGORY && categoriesTaxonomy && curatedCategoriesIds?.length > 0) {
|
29
31
|
queryArgs[categoriesTaxonomy] = curatedCategoriesIds.join(',');
|
30
|
-
} else if (queryType ===
|
32
|
+
} else if (queryType === QUERY_TYPE.CURATED && curatedPostsIds?.length > 0) {
|
31
33
|
queryArgs['include'] = curatedPostsIds;
|
32
34
|
queryArgs['orderby'] = 'include';
|
33
35
|
}
|
package/src/utils/constants.js
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
export const
|
1
|
+
export const QUERY_TYPE = {
|
2
2
|
LATEST: 'latest',
|
3
3
|
CURATED: 'curated',
|
4
4
|
BY_CATEGORY: 'by_category'
|
5
5
|
};
|
6
6
|
|
7
|
-
export const
|
7
|
+
export const MEDIA_TYPE = {
|
8
8
|
IMAGE: 'image',
|
9
9
|
VIDEO: 'video',
|
10
10
|
ANIMATION: 'animation',
|
11
11
|
};
|
12
12
|
|
13
|
-
export const
|
14
|
-
[
|
15
|
-
[
|
16
|
-
[
|
13
|
+
export const MEDIA_TYPE_LABEL = {
|
14
|
+
[MEDIA_TYPE.IMAGE]: 'Image',
|
15
|
+
[MEDIA_TYPE.VIDEO]: 'Video',
|
16
|
+
[MEDIA_TYPE.ANIMATION]: 'Animation',
|
17
17
|
};
|