@prismicio/editor-fields 0.4.28 → 0.4.29
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/dist/EditorConfig.d.ts +2 -0
- package/dist/core/MediaLibrary/components/MediaLibraryContext.d.ts +7 -2
- package/dist/core/MediaLibrary/components/Sidepane/components/SidepaneMetadataTags.d.ts +1 -1
- package/dist/core/MediaLibrary/hooks/mediaLibraryData.d.ts +144 -13
- package/dist/core/MediaLibrary/hooks/tagData.d.ts +7 -4
- package/dist/core/MediaLibrary/hooks/useMediaLibraryAnalytics.d.ts +1 -0
- package/dist/core/MediaLibrary/hooks/useSelectedMedia.d.ts +9 -1
- package/dist/core/service/document.d.ts +2859 -0
- package/dist/index.cjs.js +30 -30
- package/dist/index.es.js +16545 -16236
- package/package.json +7 -3
package/dist/EditorConfig.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ interface OnAnalyticsEvent {
|
|
|
52
52
|
numberOfWords: string;
|
|
53
53
|
numberOfResults: string;
|
|
54
54
|
timeToGetResults: string;
|
|
55
|
+
tags: string;
|
|
55
56
|
}): void;
|
|
56
57
|
(event: "Media Added To Page", args: {
|
|
57
58
|
useOpenSearch: "1" | "0";
|
|
@@ -62,6 +63,7 @@ interface OnAnalyticsEvent {
|
|
|
62
63
|
searchPosition: string;
|
|
63
64
|
mediaIds: string;
|
|
64
65
|
timeToAddMediaToPage: string;
|
|
66
|
+
tags: string;
|
|
65
67
|
}): void;
|
|
66
68
|
(event: "Unsplash Image Searched" | "Unsplash Image Added"): void;
|
|
67
69
|
}
|
|
@@ -6,8 +6,8 @@ interface MediaLibraryContextValue {
|
|
|
6
6
|
isFetchingMedia: boolean;
|
|
7
7
|
media: MediaAsset[];
|
|
8
8
|
mediaTotal: number;
|
|
9
|
-
/** Remove
|
|
10
|
-
deleteMedia: (
|
|
9
|
+
/** Remove media assets from the media library and the cache. */
|
|
10
|
+
deleteMedia: (ids: string[]) => void;
|
|
11
11
|
/** Update a media asset in the cache. */
|
|
12
12
|
updateMedia: (id: string, update: Partial<MediaAsset>) => void;
|
|
13
13
|
/**
|
|
@@ -27,10 +27,15 @@ interface MediaLibraryContextValue {
|
|
|
27
27
|
revalidateMedia: () => void;
|
|
28
28
|
keyword: string;
|
|
29
29
|
onKeywordChange: (term: string) => void;
|
|
30
|
+
tagIds: string[];
|
|
31
|
+
onTagIdsChange: (newTagIds: string[]) => void;
|
|
30
32
|
isSearchingMedia: boolean;
|
|
31
33
|
tagManagerOpen: boolean;
|
|
32
34
|
setTagManagerOpen: (open: boolean) => void;
|
|
35
|
+
openMediaSection: MediaSection | undefined;
|
|
36
|
+
setOpenMediaSection: (section: MediaSection | undefined) => void;
|
|
33
37
|
}
|
|
38
|
+
type MediaSection = "tags";
|
|
34
39
|
interface MediaLibraryProviderProps extends PropsWithChildren {
|
|
35
40
|
/**
|
|
36
41
|
* The type of media to fetch from the media library.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare function Tags(): JSX.Element;
|
|
2
|
+
export declare function Tags(): JSX.Element | null;
|
|
@@ -29,11 +29,41 @@ export declare const mediaAssetType: z.ZodObject<{
|
|
|
29
29
|
notes?: string[] | undefined;
|
|
30
30
|
credits?: string[] | undefined;
|
|
31
31
|
}>>;
|
|
32
|
+
tags: z.ZodArray<z.ZodObject<{
|
|
33
|
+
id: z.ZodString;
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
uploader_id: z.ZodOptional<z.ZodString>;
|
|
36
|
+
created_at: z.ZodNumber;
|
|
37
|
+
last_modified: z.ZodNumber;
|
|
38
|
+
count: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
created_at: number;
|
|
43
|
+
last_modified: number;
|
|
44
|
+
count: number;
|
|
45
|
+
uploader_id?: string | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
created_at: number;
|
|
50
|
+
last_modified: number;
|
|
51
|
+
uploader_id?: string | undefined;
|
|
52
|
+
count?: number | undefined;
|
|
53
|
+
}>, "many">;
|
|
32
54
|
}, "strip", z.ZodTypeAny, {
|
|
33
55
|
id: string;
|
|
56
|
+
tags: {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
created_at: number;
|
|
60
|
+
last_modified: number;
|
|
61
|
+
count: number;
|
|
62
|
+
uploader_id?: string | undefined;
|
|
63
|
+
}[];
|
|
64
|
+
last_modified: number;
|
|
34
65
|
kind: string;
|
|
35
66
|
filename: string;
|
|
36
|
-
last_modified: number;
|
|
37
67
|
url: string;
|
|
38
68
|
size: number;
|
|
39
69
|
extension?: string | undefined;
|
|
@@ -50,9 +80,17 @@ export declare const mediaAssetType: z.ZodObject<{
|
|
|
50
80
|
} | undefined;
|
|
51
81
|
}, {
|
|
52
82
|
id: string;
|
|
83
|
+
tags: {
|
|
84
|
+
id: string;
|
|
85
|
+
name: string;
|
|
86
|
+
created_at: number;
|
|
87
|
+
last_modified: number;
|
|
88
|
+
uploader_id?: string | undefined;
|
|
89
|
+
count?: number | undefined;
|
|
90
|
+
}[];
|
|
91
|
+
last_modified: number;
|
|
53
92
|
kind: string;
|
|
54
93
|
filename: string;
|
|
55
|
-
last_modified: number;
|
|
56
94
|
url: string;
|
|
57
95
|
size: number;
|
|
58
96
|
extension?: string | undefined;
|
|
@@ -103,11 +141,41 @@ export declare const mediaSearchResponse: z.ZodObject<{
|
|
|
103
141
|
notes?: string[] | undefined;
|
|
104
142
|
credits?: string[] | undefined;
|
|
105
143
|
}>>;
|
|
144
|
+
tags: z.ZodArray<z.ZodObject<{
|
|
145
|
+
id: z.ZodString;
|
|
146
|
+
name: z.ZodString;
|
|
147
|
+
uploader_id: z.ZodOptional<z.ZodString>;
|
|
148
|
+
created_at: z.ZodNumber;
|
|
149
|
+
last_modified: z.ZodNumber;
|
|
150
|
+
count: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
151
|
+
}, "strip", z.ZodTypeAny, {
|
|
152
|
+
id: string;
|
|
153
|
+
name: string;
|
|
154
|
+
created_at: number;
|
|
155
|
+
last_modified: number;
|
|
156
|
+
count: number;
|
|
157
|
+
uploader_id?: string | undefined;
|
|
158
|
+
}, {
|
|
159
|
+
id: string;
|
|
160
|
+
name: string;
|
|
161
|
+
created_at: number;
|
|
162
|
+
last_modified: number;
|
|
163
|
+
uploader_id?: string | undefined;
|
|
164
|
+
count?: number | undefined;
|
|
165
|
+
}>, "many">;
|
|
106
166
|
}, "strip", z.ZodTypeAny, {
|
|
107
167
|
id: string;
|
|
168
|
+
tags: {
|
|
169
|
+
id: string;
|
|
170
|
+
name: string;
|
|
171
|
+
created_at: number;
|
|
172
|
+
last_modified: number;
|
|
173
|
+
count: number;
|
|
174
|
+
uploader_id?: string | undefined;
|
|
175
|
+
}[];
|
|
176
|
+
last_modified: number;
|
|
108
177
|
kind: string;
|
|
109
178
|
filename: string;
|
|
110
|
-
last_modified: number;
|
|
111
179
|
url: string;
|
|
112
180
|
size: number;
|
|
113
181
|
extension?: string | undefined;
|
|
@@ -124,9 +192,17 @@ export declare const mediaSearchResponse: z.ZodObject<{
|
|
|
124
192
|
} | undefined;
|
|
125
193
|
}, {
|
|
126
194
|
id: string;
|
|
195
|
+
tags: {
|
|
196
|
+
id: string;
|
|
197
|
+
name: string;
|
|
198
|
+
created_at: number;
|
|
199
|
+
last_modified: number;
|
|
200
|
+
uploader_id?: string | undefined;
|
|
201
|
+
count?: number | undefined;
|
|
202
|
+
}[];
|
|
203
|
+
last_modified: number;
|
|
127
204
|
kind: string;
|
|
128
205
|
filename: string;
|
|
129
|
-
last_modified: number;
|
|
130
206
|
url: string;
|
|
131
207
|
size: number;
|
|
132
208
|
extension?: string | undefined;
|
|
@@ -146,9 +222,17 @@ export declare const mediaSearchResponse: z.ZodObject<{
|
|
|
146
222
|
total: number;
|
|
147
223
|
items: {
|
|
148
224
|
id: string;
|
|
225
|
+
tags: {
|
|
226
|
+
id: string;
|
|
227
|
+
name: string;
|
|
228
|
+
created_at: number;
|
|
229
|
+
last_modified: number;
|
|
230
|
+
count: number;
|
|
231
|
+
uploader_id?: string | undefined;
|
|
232
|
+
}[];
|
|
233
|
+
last_modified: number;
|
|
149
234
|
kind: string;
|
|
150
235
|
filename: string;
|
|
151
|
-
last_modified: number;
|
|
152
236
|
url: string;
|
|
153
237
|
size: number;
|
|
154
238
|
extension?: string | undefined;
|
|
@@ -169,9 +253,17 @@ export declare const mediaSearchResponse: z.ZodObject<{
|
|
|
169
253
|
total: number;
|
|
170
254
|
items: {
|
|
171
255
|
id: string;
|
|
256
|
+
tags: {
|
|
257
|
+
id: string;
|
|
258
|
+
name: string;
|
|
259
|
+
created_at: number;
|
|
260
|
+
last_modified: number;
|
|
261
|
+
uploader_id?: string | undefined;
|
|
262
|
+
count?: number | undefined;
|
|
263
|
+
}[];
|
|
264
|
+
last_modified: number;
|
|
172
265
|
kind: string;
|
|
173
266
|
filename: string;
|
|
174
|
-
last_modified: number;
|
|
175
267
|
url: string;
|
|
176
268
|
size: number;
|
|
177
269
|
extension?: string | undefined;
|
|
@@ -204,17 +296,26 @@ export type MediaAssetOrExternalImage = MediaAsset | ExternalImage;
|
|
|
204
296
|
* @param image for only images
|
|
205
297
|
*/
|
|
206
298
|
export type MediaAssetType = "all" | "image";
|
|
207
|
-
export declare function searchMedia(baseUrl: URL | undefined, repository: string, authStrategy: AuthStrategy, assetType: MediaAssetType, keyword: string, useOpenSearch: boolean, page: number, cursor?: string): Promise<{
|
|
299
|
+
export declare function searchMedia(baseUrl: URL | undefined, repository: string, authStrategy: AuthStrategy, assetType: MediaAssetType, keyword: string, tags: string, useOpenSearch: boolean, page: number, cursor?: string): Promise<{
|
|
208
300
|
time: string;
|
|
209
301
|
assetType: MediaAssetType;
|
|
210
302
|
keyword: string;
|
|
211
303
|
page: number;
|
|
304
|
+
tags: string;
|
|
212
305
|
total: number;
|
|
213
306
|
items: {
|
|
214
307
|
id: string;
|
|
308
|
+
tags: {
|
|
309
|
+
id: string;
|
|
310
|
+
name: string;
|
|
311
|
+
created_at: number;
|
|
312
|
+
last_modified: number;
|
|
313
|
+
count: number;
|
|
314
|
+
uploader_id?: string | undefined;
|
|
315
|
+
}[];
|
|
316
|
+
last_modified: number;
|
|
215
317
|
kind: string;
|
|
216
318
|
filename: string;
|
|
217
|
-
last_modified: number;
|
|
218
319
|
url: string;
|
|
219
320
|
size: number;
|
|
220
321
|
extension?: string | undefined;
|
|
@@ -239,11 +340,21 @@ interface UseMediaLibrarySearchArgs {
|
|
|
239
340
|
export declare function useMediaSearch(args: UseMediaLibrarySearchArgs): {
|
|
240
341
|
keyword: string;
|
|
241
342
|
setKeyword: (keyword: string) => void;
|
|
343
|
+
tagIds: string[];
|
|
344
|
+
setTagIds: (newTagIds: string[]) => void;
|
|
242
345
|
media: {
|
|
243
346
|
id: string;
|
|
347
|
+
tags: {
|
|
348
|
+
id: string;
|
|
349
|
+
name: string;
|
|
350
|
+
created_at: number;
|
|
351
|
+
last_modified: number;
|
|
352
|
+
count: number;
|
|
353
|
+
uploader_id?: string | undefined;
|
|
354
|
+
}[];
|
|
355
|
+
last_modified: number;
|
|
244
356
|
kind: string;
|
|
245
357
|
filename: string;
|
|
246
|
-
last_modified: number;
|
|
247
358
|
url: string;
|
|
248
359
|
size: number;
|
|
249
360
|
extension?: string | undefined;
|
|
@@ -273,14 +384,26 @@ declare function updateMedia(newFiles: {
|
|
|
273
384
|
id: string;
|
|
274
385
|
response: Partial<MediaAsset> | undefined;
|
|
275
386
|
}[]): void;
|
|
276
|
-
declare function deleteMedia(
|
|
277
|
-
|
|
387
|
+
declare function deleteMedia(mediaIds: string[]): void;
|
|
388
|
+
interface DeleteSearchDataArgs {
|
|
389
|
+
keyword?: string;
|
|
390
|
+
tagIds?: string[];
|
|
391
|
+
}
|
|
392
|
+
declare function deleteSearchData(args: DeleteSearchDataArgs): void;
|
|
278
393
|
type MediaPage = Awaited<ReturnType<typeof searchMedia>>;
|
|
279
|
-
export declare function getMedia(allPages: MediaPage[], assetType: MediaAssetType, keyword: string): {
|
|
394
|
+
export declare function getMedia(allPages: MediaPage[], assetType: MediaAssetType, keyword: string, tags: string): {
|
|
280
395
|
id: string;
|
|
396
|
+
tags: {
|
|
397
|
+
id: string;
|
|
398
|
+
name: string;
|
|
399
|
+
created_at: number;
|
|
400
|
+
last_modified: number;
|
|
401
|
+
count: number;
|
|
402
|
+
uploader_id?: string | undefined;
|
|
403
|
+
}[];
|
|
404
|
+
last_modified: number;
|
|
281
405
|
kind: string;
|
|
282
406
|
filename: string;
|
|
283
|
-
last_modified: number;
|
|
284
407
|
url: string;
|
|
285
408
|
size: number;
|
|
286
409
|
extension?: string | undefined;
|
|
@@ -296,6 +419,13 @@ export declare function getMedia(allPages: MediaPage[], assetType: MediaAssetTyp
|
|
|
296
419
|
credits?: string | undefined;
|
|
297
420
|
} | undefined;
|
|
298
421
|
}[];
|
|
422
|
+
interface PageMetadata {
|
|
423
|
+
page: number;
|
|
424
|
+
assetType: MediaAssetType;
|
|
425
|
+
keyword: string;
|
|
426
|
+
}
|
|
427
|
+
type UpdateMediaFunction = (currentItems: MediaAsset[], metadata: PageMetadata) => MediaAsset[] | undefined;
|
|
428
|
+
export declare function updateMediaCache(updateFunction: UpdateMediaFunction): void;
|
|
299
429
|
interface RevalidateFirstPageArgs {
|
|
300
430
|
config: EditorConfig;
|
|
301
431
|
assetType: MediaAssetType;
|
|
@@ -318,6 +448,7 @@ interface SearchMediaArgs {
|
|
|
318
448
|
authStrategy: AuthStrategy;
|
|
319
449
|
assetType: MediaAssetType;
|
|
320
450
|
keyword: string;
|
|
451
|
+
tagIds: string[];
|
|
321
452
|
useOpenSearch: boolean;
|
|
322
453
|
page: number;
|
|
323
454
|
cursor?: string;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare function useTagSearch(): {
|
|
3
|
-
|
|
3
|
+
tags: {
|
|
4
4
|
id: string;
|
|
5
5
|
name: string;
|
|
6
|
+
created_at: number;
|
|
6
7
|
last_modified: number;
|
|
7
8
|
count: number;
|
|
8
|
-
created_at: number;
|
|
9
9
|
uploader_id?: string | undefined;
|
|
10
10
|
}[];
|
|
11
11
|
};
|
|
12
|
+
export declare const minTagNameLength = 3;
|
|
13
|
+
export declare const maxTagNameLength = 20;
|
|
14
|
+
export declare const tagNameSchema: z.ZodString;
|
|
12
15
|
export declare const tagSchema: z.ZodObject<{
|
|
13
16
|
id: z.ZodString;
|
|
14
17
|
name: z.ZodString;
|
|
@@ -19,15 +22,15 @@ export declare const tagSchema: z.ZodObject<{
|
|
|
19
22
|
}, "strip", z.ZodTypeAny, {
|
|
20
23
|
id: string;
|
|
21
24
|
name: string;
|
|
25
|
+
created_at: number;
|
|
22
26
|
last_modified: number;
|
|
23
27
|
count: number;
|
|
24
|
-
created_at: number;
|
|
25
28
|
uploader_id?: string | undefined;
|
|
26
29
|
}, {
|
|
27
30
|
id: string;
|
|
28
31
|
name: string;
|
|
29
|
-
last_modified: number;
|
|
30
32
|
created_at: number;
|
|
33
|
+
last_modified: number;
|
|
31
34
|
uploader_id?: string | undefined;
|
|
32
35
|
count?: number | undefined;
|
|
33
36
|
}>;
|
|
@@ -2,6 +2,7 @@ import { type MediaAssetType } from "./mediaLibraryData";
|
|
|
2
2
|
interface AnalyticsMediaSearchArgs {
|
|
3
3
|
assetType: MediaAssetType;
|
|
4
4
|
keyword: string;
|
|
5
|
+
tagIds: string[];
|
|
5
6
|
mode: "select" | "browse";
|
|
6
7
|
}
|
|
7
8
|
export declare function useMediaLibraryAnalyticsMediaSearch(args: AnalyticsMediaSearchArgs): void;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
export declare function useSelectedMedia(): {
|
|
2
2
|
id: string;
|
|
3
|
+
tags: {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
created_at: number;
|
|
7
|
+
last_modified: number;
|
|
8
|
+
count: number;
|
|
9
|
+
uploader_id?: string | undefined;
|
|
10
|
+
}[];
|
|
11
|
+
last_modified: number;
|
|
3
12
|
kind: string;
|
|
4
13
|
filename: string;
|
|
5
|
-
last_modified: number;
|
|
6
14
|
url: string;
|
|
7
15
|
size: number;
|
|
8
16
|
extension?: string | undefined;
|