@select-org/select-post-builder 1.1.46 → 1.1.48
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/index.d.ts +110 -41
- package/dist/post-builder.cjs.js +49 -49
- package/dist/post-builder.js +3869 -3631
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,21 @@ import { JSONContent as JSONContent_2 } from '@tiptap/core';
|
|
|
4
4
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Walks the editor JSON and updates the media node whose `attrs.uid === itemKey`
|
|
9
|
+
* with the hosted URL + payload from a resolved upload result. Returns a new
|
|
10
|
+
* doc; never mutates the input. If no matching node is found, returns the input.
|
|
11
|
+
*/
|
|
12
|
+
export declare function applyResolvedMediaItem(jsonBody: JSONContent_2 | undefined, itemKey: string, resolvedItem: ResolvedMediaItem): JSONContent_2 | undefined;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Walks a serialized htmlBody string, finds the `[data-media][data-uid=itemKey]`
|
|
16
|
+
* wrapper and rewrites it to point at the hosted URL + payload from a resolved
|
|
17
|
+
* upload result. Mirrors `applyResolvedMediaItem` for the JSON form. If no
|
|
18
|
+
* matching node is found, returns the input unchanged.
|
|
19
|
+
*/
|
|
20
|
+
export declare function applyResolvedMediaItemToHtml(html: string | undefined, itemKey: string, resolvedItem: ResolvedMediaItem_2): string | undefined;
|
|
21
|
+
|
|
7
22
|
declare type AppUserPayload = {
|
|
8
23
|
background: string;
|
|
9
24
|
username: string;
|
|
@@ -39,16 +54,21 @@ declare type BaseProps = {
|
|
|
39
54
|
hideGroupSelector?: boolean;
|
|
40
55
|
isSubmitting?: boolean;
|
|
41
56
|
clearOnSuccess?: boolean;
|
|
42
|
-
onCreatePost: (params:
|
|
43
|
-
payload: Partial<PostCreationData>;
|
|
44
|
-
html: string;
|
|
45
|
-
json: JSONContent;
|
|
46
|
-
text: string;
|
|
47
|
-
}) => void;
|
|
57
|
+
onCreatePost: (params: CreatePostCallbackPayload) => void;
|
|
48
58
|
onVoiceComment?: (params: {
|
|
49
59
|
voiceUrl: string;
|
|
50
60
|
voiceTime: number;
|
|
51
61
|
}) => void;
|
|
62
|
+
/**
|
|
63
|
+
* Optional voice handoff for hosts that want to upload voice in their
|
|
64
|
+
* own pipeline. When provided AND `allowSendWhileUploading` is on, the
|
|
65
|
+
* comments-toolbar emits the recorded Blob via this callback instead of
|
|
66
|
+
* uploading sync via Filestore.uploadVoiceV2.
|
|
67
|
+
*/
|
|
68
|
+
onVoiceRecord?: (params: {
|
|
69
|
+
blob: Blob;
|
|
70
|
+
voiceTime: number;
|
|
71
|
+
}) => void;
|
|
52
72
|
onGroupSelect?: (groupId: string) => void;
|
|
53
73
|
onDirtyStateChange?: (isDirty: boolean) => void;
|
|
54
74
|
onReady?: (controls: PostBuilderControls) => void;
|
|
@@ -61,6 +81,27 @@ declare type BaseProps = {
|
|
|
61
81
|
onEditorTabChange?: (tab: EditorTypes) => void;
|
|
62
82
|
};
|
|
63
83
|
|
|
84
|
+
declare type CreatePostCallbackPayload = {
|
|
85
|
+
payload: Partial<PostCreationData> & {
|
|
86
|
+
error?: string;
|
|
87
|
+
};
|
|
88
|
+
html: string;
|
|
89
|
+
json: JSONContent;
|
|
90
|
+
text: string;
|
|
91
|
+
/**
|
|
92
|
+
* Per-item upload state for in-flight media. Only populated when
|
|
93
|
+
* `allowSendWhileUploading` is on AND there are items with blob: URLs at
|
|
94
|
+
* submit time. Each entry: blob (the source File for host persistence),
|
|
95
|
+
* promise (resolves to the final hosted item), abort (cancel the underlying
|
|
96
|
+
* axios request).
|
|
97
|
+
*/
|
|
98
|
+
pendingUploads?: Map<string, {
|
|
99
|
+
blob: File | Blob;
|
|
100
|
+
promise: Promise<PostCreationMediaItem | PollPostMediaOptionItem>;
|
|
101
|
+
abort: () => void;
|
|
102
|
+
}>;
|
|
103
|
+
};
|
|
104
|
+
|
|
64
105
|
export declare enum EditorPlacement {
|
|
65
106
|
Feed = "Feed",
|
|
66
107
|
Modal = "Modal",
|
|
@@ -144,6 +185,14 @@ export declare interface PostBuilderConfig {
|
|
|
144
185
|
toI18N: (key: string) => string;
|
|
145
186
|
i18nKeys?: Partial<PostBuilderI18nKeys>;
|
|
146
187
|
logEvent: (name: string, properties: Record<string, unknown>) => void;
|
|
188
|
+
/**
|
|
189
|
+
* When true, allows Send to fire while media uploads are still in flight.
|
|
190
|
+
* The host must provide an `onCreatePost` handler that consumes the new
|
|
191
|
+
* `pendingUploads` field on the payload, and an `onVoiceRecord` prop on
|
|
192
|
+
* the editor for the voice handoff. Defaults to false; existing consumers
|
|
193
|
+
* are unaffected.
|
|
194
|
+
*/
|
|
195
|
+
allowSendWhileUploading?: boolean;
|
|
147
196
|
}
|
|
148
197
|
|
|
149
198
|
export declare interface PostBuilderControls {
|
|
@@ -236,7 +285,7 @@ declare interface PostBuilderI18nKeys {
|
|
|
236
285
|
uploadsInProgressKey: string;
|
|
237
286
|
}
|
|
238
287
|
|
|
239
|
-
export declare const PostBuilderProvider: ({ children, apiBaseURL, authToken, toI18N, i18nKeys, logEvent, }: PostBuilderConfig) => JSX_2.Element;
|
|
288
|
+
export declare const PostBuilderProvider: ({ children, apiBaseURL, authToken, toI18N, i18nKeys, logEvent, allowSendWhileUploading, }: PostBuilderConfig) => JSX_2.Element;
|
|
240
289
|
|
|
241
290
|
declare type PostCreationData = {
|
|
242
291
|
body: string;
|
|
@@ -287,11 +336,31 @@ export declare type PublishEventDetails = {
|
|
|
287
336
|
failureReason?: string;
|
|
288
337
|
};
|
|
289
338
|
|
|
339
|
+
declare type ResolvedMediaItem = PostCreationMediaItem | PollPostMediaOptionItem;
|
|
340
|
+
|
|
341
|
+
declare type ResolvedMediaItem_2 = PostCreationMediaItem | PollPostMediaOptionItem;
|
|
342
|
+
|
|
290
343
|
declare enum SpecialType {
|
|
291
344
|
POST = 0,
|
|
292
345
|
FEATURED_POST = 1
|
|
293
346
|
}
|
|
294
347
|
|
|
348
|
+
/**
|
|
349
|
+
* Walks a serialized htmlBody string and removes media wrappers whose upload
|
|
350
|
+
* did not complete (data-src missing or blob:-prefixed). Empty
|
|
351
|
+
* `[data-media-group]` wrappers left behind are also removed. Mirrors
|
|
352
|
+
* `stripPendingMediaFromJsonBody` for the JSON form.
|
|
353
|
+
*/
|
|
354
|
+
export declare function stripPendingMediaFromHtml(html: string | undefined): string | undefined;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Walks the editor JSON and removes media nodes whose upload did not complete
|
|
358
|
+
* (uploading: true OR src starts with 'blob:'). Also removes empty mediaGroup
|
|
359
|
+
* wrappers left behind. Used by failure / boot-GC paths to keep stripped drafts
|
|
360
|
+
* consistent with the items[] array.
|
|
361
|
+
*/
|
|
362
|
+
export declare function stripPendingMediaFromJsonBody(jsonBody: JSONContent_2 | undefined): JSONContent_2 | undefined;
|
|
363
|
+
|
|
295
364
|
declare type WithModalProps = BaseProps & {
|
|
296
365
|
openModal: boolean;
|
|
297
366
|
onModalOpenChange: (open: boolean) => void;
|
|
@@ -346,14 +415,13 @@ declare module '@tiptap/core' {
|
|
|
346
415
|
|
|
347
416
|
declare module '@tiptap/core' {
|
|
348
417
|
interface Commands<ReturnType> {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
height?: string;
|
|
418
|
+
smartMediaUpload: {
|
|
419
|
+
insertMediaWithUpload: (params: {
|
|
420
|
+
source: File | Blob | string;
|
|
421
|
+
type: MediaNodeTypes;
|
|
422
|
+
mediaType?: MediaItemType;
|
|
423
|
+
caption?: string;
|
|
424
|
+
searchFrom?: ImageSearchFrom;
|
|
357
425
|
}) => ReturnType;
|
|
358
426
|
};
|
|
359
427
|
}
|
|
@@ -362,13 +430,14 @@ declare module '@tiptap/core' {
|
|
|
362
430
|
|
|
363
431
|
declare module '@tiptap/core' {
|
|
364
432
|
interface Commands<ReturnType> {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
433
|
+
iframe: {
|
|
434
|
+
/**
|
|
435
|
+
* Insert an iframe node into the document
|
|
436
|
+
*/
|
|
437
|
+
setIframe: (options: {
|
|
438
|
+
src: string;
|
|
439
|
+
width?: string;
|
|
440
|
+
height?: string;
|
|
372
441
|
}) => ReturnType;
|
|
373
442
|
};
|
|
374
443
|
}
|
|
@@ -377,27 +446,28 @@ declare module '@tiptap/core' {
|
|
|
377
446
|
|
|
378
447
|
declare module '@tiptap/core' {
|
|
379
448
|
interface Commands<ReturnType> {
|
|
380
|
-
|
|
449
|
+
linkPreview: {
|
|
381
450
|
/**
|
|
382
|
-
* Insert a new link
|
|
451
|
+
* Insert a new link preview node
|
|
383
452
|
*/
|
|
384
|
-
|
|
453
|
+
setLinkPreview: (attributes: LinkPreviewAttributes) => ReturnType;
|
|
385
454
|
/**
|
|
386
|
-
* Update an existing link
|
|
455
|
+
* Update an existing link preview node
|
|
387
456
|
*/
|
|
388
|
-
|
|
457
|
+
updateLinkPreview: (attributes: LinkPreviewAttributes) => ReturnType;
|
|
389
458
|
/**
|
|
390
459
|
* Update media node attributes by uid
|
|
391
460
|
*/
|
|
392
|
-
|
|
461
|
+
updateLinkPreviewByUid: (uid: string, attrs: Partial<LinkPreviewAttributes>) => ReturnType;
|
|
393
462
|
/**
|
|
394
463
|
* Delete link preview node by uid
|
|
395
464
|
*/
|
|
396
|
-
|
|
465
|
+
deleteLinkPreviewByUid: (uid: string) => ReturnType;
|
|
397
466
|
/**
|
|
398
|
-
*
|
|
467
|
+
* Insert a link preview node directly after the top-level block containing
|
|
468
|
+
* the link mark with the given uid. Skips nested content (depth > 1).
|
|
399
469
|
*/
|
|
400
|
-
|
|
470
|
+
insertLinkPreviewAfterLink: (uid: string, attrs: LinkPreviewAttributes) => ReturnType;
|
|
401
471
|
};
|
|
402
472
|
}
|
|
403
473
|
}
|
|
@@ -405,28 +475,27 @@ declare module '@tiptap/core' {
|
|
|
405
475
|
|
|
406
476
|
declare module '@tiptap/core' {
|
|
407
477
|
interface Commands<ReturnType> {
|
|
408
|
-
|
|
478
|
+
customLink: {
|
|
409
479
|
/**
|
|
410
|
-
* Insert a new link preview
|
|
480
|
+
* Insert a new link mark with preview
|
|
411
481
|
*/
|
|
412
|
-
|
|
482
|
+
insertLink: (attrs: LinkMarkAttrs) => ReturnType;
|
|
413
483
|
/**
|
|
414
|
-
* Update an existing link preview
|
|
484
|
+
* Update an existing link mark with its preview
|
|
415
485
|
*/
|
|
416
|
-
|
|
486
|
+
updateLink: (uid: string, attrs: Partial<Omit<LinkMarkAttrs, 'uid'>>) => ReturnType;
|
|
417
487
|
/**
|
|
418
488
|
* Update media node attributes by uid
|
|
419
489
|
*/
|
|
420
|
-
|
|
490
|
+
updateLinkByUid: (uid: string, attrs: Partial<LinkMarkAttrs>) => ReturnType;
|
|
421
491
|
/**
|
|
422
492
|
* Delete link preview node by uid
|
|
423
493
|
*/
|
|
424
|
-
|
|
494
|
+
deleteLinkByUid: (uid: string) => ReturnType;
|
|
425
495
|
/**
|
|
426
|
-
*
|
|
427
|
-
* the link mark with the given uid. Skips nested content (depth > 1).
|
|
496
|
+
* Re-run unfurl resolution for existing links after content rehydration.
|
|
428
497
|
*/
|
|
429
|
-
|
|
498
|
+
rehydrateLinkPreviews: () => ReturnType;
|
|
430
499
|
};
|
|
431
500
|
}
|
|
432
501
|
}
|