@select-org/select-post-builder 1.1.47 → 1.1.49

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 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;
@@ -60,6 +75,12 @@ declare type BaseProps = {
60
75
  disableNavigationWarning?: boolean;
61
76
  /** Tiptap JSONContent to pre-populate the editor with (takes precedence over localStorage draft) */
62
77
  initialContent?: JSONContent;
78
+ /**
79
+ * Initial tab to land on when the editor first mounts. Applied on first mount
80
+ * only — subsequent prop changes are ignored. Same semantics as `initialContent`.
81
+ * Default: `EditorTypes.Media`.
82
+ */
83
+ initialTab?: EditorTypes;
63
84
  /** When true, the submit/post button in the toolbar is hidden */
64
85
  hideSubmitButton?: boolean;
65
86
  /** Fires when the user switches between editor tabs (Media, Blog, Poll) */
@@ -87,6 +108,11 @@ declare type CreatePostCallbackPayload = {
87
108
  }>;
88
109
  };
89
110
 
111
+ export declare interface DraftRehydrateRequestDetail {
112
+ groupId: string;
113
+ editorType?: EditorTypes;
114
+ }
115
+
90
116
  export declare enum EditorPlacement {
91
117
  Feed = "Feed",
92
118
  Modal = "Modal",
@@ -101,6 +127,18 @@ export declare enum EditorTypes {
101
127
  Poll = "Poll"
102
128
  }
103
129
 
130
+ /**
131
+ * Ensures a poll has at least two choices. The feed renderer requires >=2 to
132
+ * display a poll. When given exactly one choice, returns a two-element array
133
+ * by duplicating the choice with a fresh `option_id` and the appropriate
134
+ * `option_color`. When given zero or >=2, returns the input untouched.
135
+ *
136
+ * Used by `generatePollPostPayload` for fresh sends and by the host's resend
137
+ * path so that a failed-then-stripped poll draft (which can collapse to a
138
+ * single hosted item) still produces a renderable post.
139
+ */
140
+ export declare const ensurePollMinimum: (items: PollChoiceItem[]) => PollChoiceItem[];
141
+
104
142
  declare interface ImageInfo {
105
143
  width: number;
106
144
  height: number;
@@ -205,7 +243,8 @@ export declare enum PostBuilderEvents {
205
243
  POST_PUBLISH_ATTEMPTED = "select:post_publish_attempted",
206
244
  POST_PUBLISH_SUCCESSFUL = "select:post_publish_success",
207
245
  POST_PUBLISH_FAILED = "select:post_publish_failed",
208
- POST_SESSION_ROTATED = "select:post_session_rotated"
246
+ POST_SESSION_ROTATED = "select:post_session_rotated",
247
+ DRAFT_REHYDRATE_REQUEST = "select:draft_rehydrate_request"
209
248
  }
210
249
 
211
250
  declare interface PostBuilderI18nKeys {
@@ -321,11 +360,31 @@ export declare type PublishEventDetails = {
321
360
  failureReason?: string;
322
361
  };
323
362
 
363
+ declare type ResolvedMediaItem = PostCreationMediaItem | PollPostMediaOptionItem;
364
+
365
+ declare type ResolvedMediaItem_2 = PostCreationMediaItem | PollPostMediaOptionItem;
366
+
324
367
  declare enum SpecialType {
325
368
  POST = 0,
326
369
  FEATURED_POST = 1
327
370
  }
328
371
 
372
+ /**
373
+ * Walks a serialized htmlBody string and removes media wrappers whose upload
374
+ * did not complete (data-src missing or blob:-prefixed). Empty
375
+ * `[data-media-group]` wrappers left behind are also removed. Mirrors
376
+ * `stripPendingMediaFromJsonBody` for the JSON form.
377
+ */
378
+ export declare function stripPendingMediaFromHtml(html: string | undefined): string | undefined;
379
+
380
+ /**
381
+ * Walks the editor JSON and removes media nodes whose upload did not complete
382
+ * (uploading: true OR src starts with 'blob:'). Also removes empty mediaGroup
383
+ * wrappers left behind. Used by failure / boot-GC paths to keep stripped drafts
384
+ * consistent with the items[] array.
385
+ */
386
+ export declare function stripPendingMediaFromJsonBody(jsonBody: JSONContent_2 | undefined): JSONContent_2 | undefined;
387
+
329
388
  declare type WithModalProps = BaseProps & {
330
389
  openModal: boolean;
331
390
  onModalOpenChange: (open: boolean) => void;
@@ -422,6 +481,21 @@ declare module '@tiptap/core' {
422
481
  }
423
482
 
424
483
 
484
+ declare module '@tiptap/core' {
485
+ interface Commands<ReturnType> {
486
+ smartMediaUpload: {
487
+ insertMediaWithUpload: (params: {
488
+ source: File | Blob | string;
489
+ type: MediaNodeTypes;
490
+ mediaType?: MediaItemType;
491
+ caption?: string;
492
+ searchFrom?: ImageSearchFrom;
493
+ }) => ReturnType;
494
+ };
495
+ }
496
+ }
497
+
498
+
425
499
  declare module '@tiptap/core' {
426
500
  interface Commands<ReturnType> {
427
501
  linkPreview: {
@@ -449,18 +523,3 @@ declare module '@tiptap/core' {
449
523
  };
450
524
  }
451
525
  }
452
-
453
-
454
- declare module '@tiptap/core' {
455
- interface Commands<ReturnType> {
456
- smartMediaUpload: {
457
- insertMediaWithUpload: (params: {
458
- source: File | Blob | string;
459
- type: MediaNodeTypes;
460
- mediaType?: MediaItemType;
461
- caption?: string;
462
- searchFrom?: ImageSearchFrom;
463
- }) => ReturnType;
464
- };
465
- }
466
- }