@select-org/select-post-builder 1.1.33 → 1.1.35
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 +2 -22
- package/dist/post-builder.cjs.js +79 -74
- package/dist/post-builder.css +21 -1
- package/dist/post-builder.js +79 -74
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,13 +4,11 @@ import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
|
|
6
6
|
declare type AppUserPayload = {
|
|
7
|
-
users: Array<UserPayload>;
|
|
8
7
|
background: string;
|
|
9
8
|
username: string;
|
|
10
9
|
relationship: 2;
|
|
11
10
|
refresh_token: string;
|
|
12
11
|
name: string;
|
|
13
|
-
new_user: boolean;
|
|
14
12
|
longitude: number;
|
|
15
13
|
latitude: number;
|
|
16
14
|
jwtoken: string;
|
|
@@ -20,11 +18,10 @@ declare type AppUserPayload = {
|
|
|
20
18
|
avatar: string;
|
|
21
19
|
avatarPlaceholder: string;
|
|
22
20
|
highResolutionAvatar: string;
|
|
23
|
-
twitterUsername: string;
|
|
24
|
-
email: string;
|
|
25
21
|
description: string;
|
|
26
|
-
email_verified: boolean;
|
|
27
22
|
featured_groups: string[];
|
|
23
|
+
new_user?: boolean;
|
|
24
|
+
email?: string;
|
|
28
25
|
};
|
|
29
26
|
|
|
30
27
|
declare type BasePollOptionItem = {
|
|
@@ -253,23 +250,6 @@ declare enum SpecialType {
|
|
|
253
250
|
FEATURED_POST = 1
|
|
254
251
|
}
|
|
255
252
|
|
|
256
|
-
declare type UserPayload = {
|
|
257
|
-
id: string;
|
|
258
|
-
username: string;
|
|
259
|
-
name: string;
|
|
260
|
-
avatar: string;
|
|
261
|
-
avatarPlaceholder: string;
|
|
262
|
-
highResolutionAvatar: string;
|
|
263
|
-
gender: string;
|
|
264
|
-
birthday: string;
|
|
265
|
-
description?: string;
|
|
266
|
-
type?: string;
|
|
267
|
-
latitude?: number;
|
|
268
|
-
longitude?: number;
|
|
269
|
-
relationship?: number;
|
|
270
|
-
interactionIds?: Array<string>;
|
|
271
|
-
};
|
|
272
|
-
|
|
273
253
|
declare type WithModalProps = BaseProps & {
|
|
274
254
|
openModal: boolean;
|
|
275
255
|
onModalOpenChange: (open: boolean) => void;
|
package/dist/post-builder.cjs.js
CHANGED
|
@@ -2506,6 +2506,11 @@ const {
|
|
|
2506
2506
|
getAdapter,
|
|
2507
2507
|
mergeConfig
|
|
2508
2508
|
} = axios;
|
|
2509
|
+
var ConversationType = /* @__PURE__ */ ((ConversationType2) => {
|
|
2510
|
+
ConversationType2[ConversationType2["GROUP"] = 0] = "GROUP";
|
|
2511
|
+
ConversationType2[ConversationType2["USER"] = 1] = "USER";
|
|
2512
|
+
return ConversationType2;
|
|
2513
|
+
})(ConversationType || {});
|
|
2509
2514
|
var PostType = /* @__PURE__ */ ((PostType2) => {
|
|
2510
2515
|
PostType2["Post"] = "post";
|
|
2511
2516
|
PostType2["Comment"] = "comment";
|
|
@@ -4189,10 +4194,12 @@ const asyncCache = (key, fetcher) => {
|
|
|
4189
4194
|
};
|
|
4190
4195
|
class CoreApi {
|
|
4191
4196
|
isAuthorize;
|
|
4197
|
+
baseUrl;
|
|
4192
4198
|
url;
|
|
4193
4199
|
language;
|
|
4194
4200
|
onError;
|
|
4195
4201
|
api;
|
|
4202
|
+
apiV2;
|
|
4196
4203
|
token;
|
|
4197
4204
|
toI18N;
|
|
4198
4205
|
/**
|
|
@@ -4203,13 +4210,14 @@ class CoreApi {
|
|
|
4203
4210
|
*/
|
|
4204
4211
|
constructor(coreUrl, token, toI18N, language) {
|
|
4205
4212
|
this.isAuthorize = false;
|
|
4213
|
+
this.baseUrl = coreUrl;
|
|
4206
4214
|
this.url = `${coreUrl}v1/`;
|
|
4207
4215
|
this.language = language ?? getLanguage();
|
|
4208
4216
|
this.onError = () => {
|
|
4209
4217
|
};
|
|
4210
4218
|
this.toI18N = toI18N;
|
|
4211
|
-
this.initApi();
|
|
4212
4219
|
this.token = token;
|
|
4220
|
+
this.initApi();
|
|
4213
4221
|
}
|
|
4214
4222
|
/**
|
|
4215
4223
|
* Set the 'Authorization' header
|
|
@@ -4246,6 +4254,12 @@ class CoreApi {
|
|
|
4246
4254
|
token: this.token,
|
|
4247
4255
|
isFileStore: false
|
|
4248
4256
|
});
|
|
4257
|
+
this.apiV2 = createApiClient({
|
|
4258
|
+
baseURL: `${this.baseUrl}v2/`,
|
|
4259
|
+
t: this.toI18N,
|
|
4260
|
+
token: this.token,
|
|
4261
|
+
isFileStore: false
|
|
4262
|
+
});
|
|
4249
4263
|
}
|
|
4250
4264
|
getErrorMessage(response) {
|
|
4251
4265
|
if (response && response.response && response.response.data && response.response.data.error) {
|
|
@@ -4257,26 +4271,19 @@ class CoreApi {
|
|
|
4257
4271
|
return null;
|
|
4258
4272
|
}
|
|
4259
4273
|
/**
|
|
4260
|
-
* get
|
|
4274
|
+
* get conversations sorted by last activity
|
|
4261
4275
|
*/
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
return response.data;
|
|
4265
|
-
}).catch((response) => {
|
|
4266
|
-
throw this.throwHTTPError(response);
|
|
4267
|
-
});
|
|
4268
|
-
}
|
|
4269
|
-
/**
|
|
4270
|
-
* get group conversations sorted by last activity
|
|
4271
|
-
*/
|
|
4272
|
-
fetchGroupConversations(amount, fromTime) {
|
|
4273
|
-
const cacheKey = `group-conversations`;
|
|
4276
|
+
fetchConversationList(amount, fromTime) {
|
|
4277
|
+
const cacheKey = `conversation-list`;
|
|
4274
4278
|
const cachedFetcher = asyncCache(
|
|
4275
4279
|
cacheKey,
|
|
4276
|
-
() => this.
|
|
4277
|
-
amount
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
+
() => this.apiV2.get("conversation/list", {
|
|
4281
|
+
params: { from_time: fromTime, amount }
|
|
4282
|
+
}).then(
|
|
4283
|
+
(response) => response?.data?.filter(
|
|
4284
|
+
(data) => data?.conversation_detail?.type === ConversationType.GROUP
|
|
4285
|
+
)
|
|
4286
|
+
).catch((response) => {
|
|
4280
4287
|
throw this.throwHTTPError(response);
|
|
4281
4288
|
})
|
|
4282
4289
|
);
|
|
@@ -4323,25 +4330,6 @@ class CoreApi {
|
|
|
4323
4330
|
l: limit,
|
|
4324
4331
|
o: offset2,
|
|
4325
4332
|
in_china: isUsingChineseProvider
|
|
4326
|
-
// || stringContainsChineseCharacter(query),
|
|
4327
|
-
}
|
|
4328
|
-
}).then((response) => {
|
|
4329
|
-
return response.data;
|
|
4330
|
-
}).catch((response) => {
|
|
4331
|
-
throw this.throwHTTPError(response);
|
|
4332
|
-
});
|
|
4333
|
-
}
|
|
4334
|
-
/**
|
|
4335
|
-
* Get random GIF based on q parameter via a GET request into the backend
|
|
4336
|
-
*
|
|
4337
|
-
* @param {string} query
|
|
4338
|
-
* @returns {Promise<WebImageSearchResponse>}
|
|
4339
|
-
* @memberof CoreApi
|
|
4340
|
-
*/
|
|
4341
|
-
fetchRandomGif(query) {
|
|
4342
|
-
return this.api.get("search/gifs/random", {
|
|
4343
|
-
params: {
|
|
4344
|
-
q: query
|
|
4345
4333
|
}
|
|
4346
4334
|
}).then((response) => {
|
|
4347
4335
|
return response.data;
|
|
@@ -4375,7 +4363,7 @@ class CoreApi {
|
|
|
4375
4363
|
});
|
|
4376
4364
|
}
|
|
4377
4365
|
/**
|
|
4378
|
-
* Fetch
|
|
4366
|
+
* Fetch metadata from url
|
|
4379
4367
|
*/
|
|
4380
4368
|
resolveUrl(url) {
|
|
4381
4369
|
const cacheKey = url;
|
|
@@ -4391,15 +4379,6 @@ class CoreApi {
|
|
|
4391
4379
|
);
|
|
4392
4380
|
return cachedFetcher();
|
|
4393
4381
|
}
|
|
4394
|
-
resolveUrlForText(body) {
|
|
4395
|
-
return this.api.post("url/resolve-text", {
|
|
4396
|
-
body
|
|
4397
|
-
}).then((response) => {
|
|
4398
|
-
return response.data;
|
|
4399
|
-
}).catch((response) => {
|
|
4400
|
-
throw this.throwHTTPError(response);
|
|
4401
|
-
});
|
|
4402
|
-
}
|
|
4403
4382
|
}
|
|
4404
4383
|
const byteToHex = [];
|
|
4405
4384
|
for (let i2 = 0; i2 < 256; ++i2) {
|
|
@@ -4572,11 +4551,11 @@ class MFSApi {
|
|
|
4572
4551
|
isFileStore: false
|
|
4573
4552
|
});
|
|
4574
4553
|
}
|
|
4575
|
-
getRecommendationPost(groupId, postId, offset2 = 0, amount = 10, excludedUserIds = [], includedUserIds = [], keyword = "", scope = ["
|
|
4554
|
+
getRecommendationPost(groupId, postId, offset2 = 0, amount = 10, excludedUserIds = [], includedUserIds = [], keyword = "", scope = ["user_details", "post_counter"]) {
|
|
4576
4555
|
const cacheKey = `post-recommendation:${groupId}${postId ? `:${postId}` : ``}`;
|
|
4577
4556
|
const cachedFetcher = asyncCache(
|
|
4578
4557
|
cacheKey,
|
|
4579
|
-
() => this.api.post("/recommendation/post", {
|
|
4558
|
+
() => this.api.post("v2/recommendation/post", {
|
|
4580
4559
|
group_id: groupId,
|
|
4581
4560
|
post_id: postId,
|
|
4582
4561
|
included_user_ids: includedUserIds,
|
|
@@ -4594,11 +4573,11 @@ class MFSApi {
|
|
|
4594
4573
|
);
|
|
4595
4574
|
return cachedFetcher();
|
|
4596
4575
|
}
|
|
4597
|
-
getRecommendationGroup(groupId, offset2 = 0, amount = 10, excludedUserIds = [], includedUserIds = [], keyword = "", scope = ["
|
|
4576
|
+
getRecommendationGroup(groupId, offset2 = 0, amount = 10, excludedUserIds = [], includedUserIds = [], keyword = "", scope = ["user_details"]) {
|
|
4598
4577
|
const cacheKey = `group-recommendation:${groupId}`;
|
|
4599
4578
|
const cachedFetcher = asyncCache(
|
|
4600
4579
|
cacheKey,
|
|
4601
|
-
() => this.api.post("/recommendation/group", {
|
|
4580
|
+
() => this.api.post("v2/recommendation/group", {
|
|
4602
4581
|
group_id: groupId,
|
|
4603
4582
|
included_user_ids: includedUserIds,
|
|
4604
4583
|
excluded_user_ids: excludedUserIds,
|
|
@@ -16370,9 +16349,9 @@ const GroupSelector = ({ store, onGroupSelect }) => {
|
|
|
16370
16349
|
const loadGroups = async () => {
|
|
16371
16350
|
setIsLoading(true);
|
|
16372
16351
|
try {
|
|
16373
|
-
const response = await core2.
|
|
16352
|
+
const response = await core2.fetchConversationList(999, 0);
|
|
16374
16353
|
if (!cancelled) {
|
|
16375
|
-
setGroups(response
|
|
16354
|
+
setGroups(response ?? []);
|
|
16376
16355
|
}
|
|
16377
16356
|
} catch (error) {
|
|
16378
16357
|
} finally {
|
|
@@ -16407,13 +16386,13 @@ const GroupSelector = ({ store, onGroupSelect }) => {
|
|
|
16407
16386
|
)
|
|
16408
16387
|
}
|
|
16409
16388
|
),
|
|
16410
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { align: "start", children: groups.map((
|
|
16389
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { align: "start", children: groups.map((conversation) => /* @__PURE__ */ jsxRuntime.jsxs(SelectItem, { value: conversation.conversation_id, children: [
|
|
16411
16390
|
/* @__PURE__ */ jsxRuntime.jsxs(Avatar, { className: "size-6", children: [
|
|
16412
|
-
/* @__PURE__ */ jsxRuntime.jsx(AvatarImage, { src:
|
|
16413
|
-
/* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { children:
|
|
16391
|
+
/* @__PURE__ */ jsxRuntime.jsx(AvatarImage, { src: conversation.conversation_detail.avatar ?? void 0 }),
|
|
16392
|
+
/* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { children: conversation.conversation_detail.name?.charAt(0) })
|
|
16414
16393
|
] }),
|
|
16415
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children:
|
|
16416
|
-
] },
|
|
16394
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children: conversation.conversation_detail.name ?? conversation.conversation_id })
|
|
16395
|
+
] }, conversation.conversation_id)) })
|
|
16417
16396
|
] }) });
|
|
16418
16397
|
};
|
|
16419
16398
|
const GifIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -32502,14 +32481,14 @@ const mentionService = (api, mfs, store, user) => {
|
|
|
32502
32481
|
}
|
|
32503
32482
|
const { groupId, postId } = params;
|
|
32504
32483
|
const response = postId ? await mfs.getRecommendationPost(groupId, postId, 0, 999) : await mfs.getRecommendationGroup(groupId, 0, 999);
|
|
32505
|
-
const apiResults = response.entries?.filter((item) => Boolean(item?.
|
|
32484
|
+
const apiResults = response.entries?.filter((item) => Boolean(item?.user_details))?.map(
|
|
32506
32485
|
(item) => ({
|
|
32507
|
-
id: item?.
|
|
32508
|
-
label: item?.
|
|
32509
|
-
avatar: item?.
|
|
32486
|
+
id: item?.user_details?.id,
|
|
32487
|
+
label: item?.user_details?.name,
|
|
32488
|
+
avatar: item?.user_details?.avatar,
|
|
32510
32489
|
inThisThread: 1,
|
|
32511
|
-
name: item?.
|
|
32512
|
-
selectId: item.
|
|
32490
|
+
name: item?.user_details?.name,
|
|
32491
|
+
selectId: item.user_details?.username,
|
|
32513
32492
|
type: MentionType.User,
|
|
32514
32493
|
from: PostType.Post
|
|
32515
32494
|
})
|
|
@@ -32536,18 +32515,18 @@ const mentionService = (api, mfs, store, user) => {
|
|
|
32536
32515
|
if (!activeGroupId) {
|
|
32537
32516
|
return [];
|
|
32538
32517
|
}
|
|
32539
|
-
const response = await api.
|
|
32540
|
-
return response.
|
|
32541
|
-
(
|
|
32542
|
-
id:
|
|
32543
|
-
label:
|
|
32544
|
-
avatar:
|
|
32518
|
+
const response = await api.fetchConversationList(999, 0);
|
|
32519
|
+
return response.map(
|
|
32520
|
+
(conversation) => ({
|
|
32521
|
+
id: conversation?.conversation_id,
|
|
32522
|
+
label: conversation?.conversation_detail?.name,
|
|
32523
|
+
avatar: conversation?.conversation_detail?.avatar,
|
|
32545
32524
|
inThisThread: 1,
|
|
32546
|
-
name:
|
|
32547
|
-
selectId:
|
|
32525
|
+
name: conversation?.conversation_detail?.name,
|
|
32526
|
+
selectId: conversation?.conversation_detail?.select_id,
|
|
32548
32527
|
type: MentionType.Group,
|
|
32549
32528
|
from: PostType.Post,
|
|
32550
|
-
isCrossExposureEnable:
|
|
32529
|
+
isCrossExposureEnable: conversation?.conversation_detail?.allow_cross_exposure
|
|
32551
32530
|
})
|
|
32552
32531
|
);
|
|
32553
32532
|
};
|
|
@@ -33689,10 +33668,20 @@ const PostBuilderEditorInstance = ({
|
|
|
33689
33668
|
placement
|
|
33690
33669
|
}) => {
|
|
33691
33670
|
const [isDragging, setIsDragging] = React.useState(false);
|
|
33671
|
+
const [hasGroupSelected, setHasGroupSelected] = React.useState(true);
|
|
33692
33672
|
const { trackPublish } = useAnalyticsTracking();
|
|
33693
33673
|
const { clearContent } = usePersistence(placement);
|
|
33694
33674
|
useHostAnalyticsBridge();
|
|
33695
33675
|
useEditorTracking({ editor, editorType: editorTab });
|
|
33676
|
+
React.useEffect(() => {
|
|
33677
|
+
const checkGroupSelection = () => {
|
|
33678
|
+
const { groupId, selectedGroupId } = store.getState();
|
|
33679
|
+
setHasGroupSelected(!!(groupId || selectedGroupId));
|
|
33680
|
+
};
|
|
33681
|
+
checkGroupSelection();
|
|
33682
|
+
const unsubscribe = store.subscribe(checkGroupSelection);
|
|
33683
|
+
return () => unsubscribe();
|
|
33684
|
+
}, [store]);
|
|
33696
33685
|
const handleDragOver = (e2) => {
|
|
33697
33686
|
e2.preventDefault();
|
|
33698
33687
|
setIsDragging(true);
|
|
@@ -33705,6 +33694,12 @@ const PostBuilderEditorInstance = ({
|
|
|
33705
33694
|
e2.preventDefault();
|
|
33706
33695
|
setIsDragging(false);
|
|
33707
33696
|
};
|
|
33697
|
+
const handleOpenGroupSelector = () => {
|
|
33698
|
+
const selectorTrigger = document.querySelector('[aria-label="Select group"]');
|
|
33699
|
+
if (selectorTrigger) {
|
|
33700
|
+
selectorTrigger.click();
|
|
33701
|
+
}
|
|
33702
|
+
};
|
|
33708
33703
|
const handleSubmit = (sendCrossMention) => {
|
|
33709
33704
|
if (!editor) return;
|
|
33710
33705
|
const html2 = editor?.getHTML();
|
|
@@ -33752,11 +33747,21 @@ const PostBuilderEditorInstance = ({
|
|
|
33752
33747
|
"div",
|
|
33753
33748
|
{
|
|
33754
33749
|
className: cn(
|
|
33755
|
-
"post-builder-editor bg-background border rounded-md overflow-hidden max-h-full grow flex flex-col overflow-y-auto transition-all duration-300 ease-in-out",
|
|
33750
|
+
"post-builder-editor bg-background border rounded-md overflow-hidden max-h-full grow flex flex-col overflow-y-auto transition-all duration-300 ease-in-out relative",
|
|
33756
33751
|
placement === EditorPlacement.Comment ? "min-h-32" : "min-h-60",
|
|
33757
33752
|
className
|
|
33758
33753
|
),
|
|
33759
33754
|
children: [
|
|
33755
|
+
!hasGroupSelected && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "z-50 absolute inset-0 bg-foreground/30 backdrop-blur-xs flex items-center justify-center rounded-md pointer-events-none", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
33756
|
+
Button,
|
|
33757
|
+
{
|
|
33758
|
+
variant: "outline",
|
|
33759
|
+
size: "lg",
|
|
33760
|
+
onClick: handleOpenGroupSelector,
|
|
33761
|
+
className: "pointer-events-auto cursor-pointer hover:animate-none animate-pulse",
|
|
33762
|
+
children: "Please select a group first"
|
|
33763
|
+
}
|
|
33764
|
+
) }),
|
|
33760
33765
|
placement !== EditorPlacement.Comment && /* @__PURE__ */ jsxRuntime.jsx(EditorTypeTabs, { editorTab, onSwitchEditorTab: onSwitchEditor }),
|
|
33761
33766
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
33762
33767
|
Toolbar,
|
package/dist/post-builder.css
CHANGED
|
@@ -147,6 +147,7 @@
|
|
|
147
147
|
--animate-spin: spin 1s linear infinite;
|
|
148
148
|
--animate-pulse: pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;
|
|
149
149
|
--animate-bounce: bounce 1s infinite;
|
|
150
|
+
--blur-xs: 4px;
|
|
150
151
|
--blur-sm: 8px;
|
|
151
152
|
--blur-2xl: 40px;
|
|
152
153
|
--default-transition-duration: .15s;
|
|
@@ -454,6 +455,10 @@ body {
|
|
|
454
455
|
container: field-group / inline-size;
|
|
455
456
|
}
|
|
456
457
|
|
|
458
|
+
[data-theme="select-post-builder"] .pointer-events-auto {
|
|
459
|
+
pointer-events: auto;
|
|
460
|
+
}
|
|
461
|
+
|
|
457
462
|
[data-theme="select-post-builder"] .pointer-events-none {
|
|
458
463
|
pointer-events: none;
|
|
459
464
|
}
|
|
@@ -2298,10 +2303,16 @@ body {
|
|
|
2298
2303
|
background-color: var(--destructive);
|
|
2299
2304
|
}
|
|
2300
2305
|
|
|
2301
|
-
[data-theme="select-post-builder"] .bg-foreground {
|
|
2306
|
+
[data-theme="select-post-builder"] .bg-foreground, [data-theme="select-post-builder"] .bg-foreground\/30 {
|
|
2302
2307
|
background-color: var(--foreground);
|
|
2303
2308
|
}
|
|
2304
2309
|
|
|
2310
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
2311
|
+
[data-theme="select-post-builder"] .bg-foreground\/30 {
|
|
2312
|
+
background-color: color-mix(in oklab, var(--foreground) 30%, transparent);
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2305
2316
|
[data-theme="select-post-builder"] .bg-gray-50 {
|
|
2306
2317
|
background-color: var(--color-gray-50);
|
|
2307
2318
|
}
|
|
@@ -2950,6 +2961,11 @@ body {
|
|
|
2950
2961
|
backdrop-filter: var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );
|
|
2951
2962
|
}
|
|
2952
2963
|
|
|
2964
|
+
[data-theme="select-post-builder"] .backdrop-blur-xs {
|
|
2965
|
+
--tw-backdrop-blur: blur(var(--blur-xs));
|
|
2966
|
+
backdrop-filter: var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2953
2969
|
[data-theme="select-post-builder"] .transition {
|
|
2954
2970
|
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, backdrop-filter, display, content-visibility, overlay, pointer-events;
|
|
2955
2971
|
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
|
@@ -3258,6 +3274,10 @@ body {
|
|
|
3258
3274
|
scale: 1.02;
|
|
3259
3275
|
}
|
|
3260
3276
|
|
|
3277
|
+
[data-theme="select-post-builder"] .hover\:animate-none:hover {
|
|
3278
|
+
animation: none;
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3261
3281
|
[data-theme="select-post-builder"] .hover\:border-accent:hover {
|
|
3262
3282
|
border-color: var(--accent);
|
|
3263
3283
|
}
|
package/dist/post-builder.js
CHANGED
|
@@ -2476,6 +2476,11 @@ const {
|
|
|
2476
2476
|
getAdapter,
|
|
2477
2477
|
mergeConfig
|
|
2478
2478
|
} = axios;
|
|
2479
|
+
var ConversationType = /* @__PURE__ */ ((ConversationType2) => {
|
|
2480
|
+
ConversationType2[ConversationType2["GROUP"] = 0] = "GROUP";
|
|
2481
|
+
ConversationType2[ConversationType2["USER"] = 1] = "USER";
|
|
2482
|
+
return ConversationType2;
|
|
2483
|
+
})(ConversationType || {});
|
|
2479
2484
|
var PostType = /* @__PURE__ */ ((PostType2) => {
|
|
2480
2485
|
PostType2["Post"] = "post";
|
|
2481
2486
|
PostType2["Comment"] = "comment";
|
|
@@ -4159,10 +4164,12 @@ const asyncCache = (key, fetcher) => {
|
|
|
4159
4164
|
};
|
|
4160
4165
|
class CoreApi {
|
|
4161
4166
|
isAuthorize;
|
|
4167
|
+
baseUrl;
|
|
4162
4168
|
url;
|
|
4163
4169
|
language;
|
|
4164
4170
|
onError;
|
|
4165
4171
|
api;
|
|
4172
|
+
apiV2;
|
|
4166
4173
|
token;
|
|
4167
4174
|
toI18N;
|
|
4168
4175
|
/**
|
|
@@ -4173,13 +4180,14 @@ class CoreApi {
|
|
|
4173
4180
|
*/
|
|
4174
4181
|
constructor(coreUrl, token, toI18N, language) {
|
|
4175
4182
|
this.isAuthorize = false;
|
|
4183
|
+
this.baseUrl = coreUrl;
|
|
4176
4184
|
this.url = `${coreUrl}v1/`;
|
|
4177
4185
|
this.language = language ?? getLanguage();
|
|
4178
4186
|
this.onError = () => {
|
|
4179
4187
|
};
|
|
4180
4188
|
this.toI18N = toI18N;
|
|
4181
|
-
this.initApi();
|
|
4182
4189
|
this.token = token;
|
|
4190
|
+
this.initApi();
|
|
4183
4191
|
}
|
|
4184
4192
|
/**
|
|
4185
4193
|
* Set the 'Authorization' header
|
|
@@ -4216,6 +4224,12 @@ class CoreApi {
|
|
|
4216
4224
|
token: this.token,
|
|
4217
4225
|
isFileStore: false
|
|
4218
4226
|
});
|
|
4227
|
+
this.apiV2 = createApiClient({
|
|
4228
|
+
baseURL: `${this.baseUrl}v2/`,
|
|
4229
|
+
t: this.toI18N,
|
|
4230
|
+
token: this.token,
|
|
4231
|
+
isFileStore: false
|
|
4232
|
+
});
|
|
4219
4233
|
}
|
|
4220
4234
|
getErrorMessage(response) {
|
|
4221
4235
|
if (response && response.response && response.response.data && response.response.data.error) {
|
|
@@ -4227,26 +4241,19 @@ class CoreApi {
|
|
|
4227
4241
|
return null;
|
|
4228
4242
|
}
|
|
4229
4243
|
/**
|
|
4230
|
-
* get
|
|
4244
|
+
* get conversations sorted by last activity
|
|
4231
4245
|
*/
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
return response.data;
|
|
4235
|
-
}).catch((response) => {
|
|
4236
|
-
throw this.throwHTTPError(response);
|
|
4237
|
-
});
|
|
4238
|
-
}
|
|
4239
|
-
/**
|
|
4240
|
-
* get group conversations sorted by last activity
|
|
4241
|
-
*/
|
|
4242
|
-
fetchGroupConversations(amount, fromTime) {
|
|
4243
|
-
const cacheKey = `group-conversations`;
|
|
4246
|
+
fetchConversationList(amount, fromTime) {
|
|
4247
|
+
const cacheKey = `conversation-list`;
|
|
4244
4248
|
const cachedFetcher = asyncCache(
|
|
4245
4249
|
cacheKey,
|
|
4246
|
-
() => this.
|
|
4247
|
-
amount
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
+
() => this.apiV2.get("conversation/list", {
|
|
4251
|
+
params: { from_time: fromTime, amount }
|
|
4252
|
+
}).then(
|
|
4253
|
+
(response) => response?.data?.filter(
|
|
4254
|
+
(data) => data?.conversation_detail?.type === ConversationType.GROUP
|
|
4255
|
+
)
|
|
4256
|
+
).catch((response) => {
|
|
4250
4257
|
throw this.throwHTTPError(response);
|
|
4251
4258
|
})
|
|
4252
4259
|
);
|
|
@@ -4293,25 +4300,6 @@ class CoreApi {
|
|
|
4293
4300
|
l: limit,
|
|
4294
4301
|
o: offset2,
|
|
4295
4302
|
in_china: isUsingChineseProvider
|
|
4296
|
-
// || stringContainsChineseCharacter(query),
|
|
4297
|
-
}
|
|
4298
|
-
}).then((response) => {
|
|
4299
|
-
return response.data;
|
|
4300
|
-
}).catch((response) => {
|
|
4301
|
-
throw this.throwHTTPError(response);
|
|
4302
|
-
});
|
|
4303
|
-
}
|
|
4304
|
-
/**
|
|
4305
|
-
* Get random GIF based on q parameter via a GET request into the backend
|
|
4306
|
-
*
|
|
4307
|
-
* @param {string} query
|
|
4308
|
-
* @returns {Promise<WebImageSearchResponse>}
|
|
4309
|
-
* @memberof CoreApi
|
|
4310
|
-
*/
|
|
4311
|
-
fetchRandomGif(query) {
|
|
4312
|
-
return this.api.get("search/gifs/random", {
|
|
4313
|
-
params: {
|
|
4314
|
-
q: query
|
|
4315
4303
|
}
|
|
4316
4304
|
}).then((response) => {
|
|
4317
4305
|
return response.data;
|
|
@@ -4345,7 +4333,7 @@ class CoreApi {
|
|
|
4345
4333
|
});
|
|
4346
4334
|
}
|
|
4347
4335
|
/**
|
|
4348
|
-
* Fetch
|
|
4336
|
+
* Fetch metadata from url
|
|
4349
4337
|
*/
|
|
4350
4338
|
resolveUrl(url) {
|
|
4351
4339
|
const cacheKey = url;
|
|
@@ -4361,15 +4349,6 @@ class CoreApi {
|
|
|
4361
4349
|
);
|
|
4362
4350
|
return cachedFetcher();
|
|
4363
4351
|
}
|
|
4364
|
-
resolveUrlForText(body) {
|
|
4365
|
-
return this.api.post("url/resolve-text", {
|
|
4366
|
-
body
|
|
4367
|
-
}).then((response) => {
|
|
4368
|
-
return response.data;
|
|
4369
|
-
}).catch((response) => {
|
|
4370
|
-
throw this.throwHTTPError(response);
|
|
4371
|
-
});
|
|
4372
|
-
}
|
|
4373
4352
|
}
|
|
4374
4353
|
const byteToHex = [];
|
|
4375
4354
|
for (let i2 = 0; i2 < 256; ++i2) {
|
|
@@ -4542,11 +4521,11 @@ class MFSApi {
|
|
|
4542
4521
|
isFileStore: false
|
|
4543
4522
|
});
|
|
4544
4523
|
}
|
|
4545
|
-
getRecommendationPost(groupId, postId, offset2 = 0, amount = 10, excludedUserIds = [], includedUserIds = [], keyword = "", scope = ["
|
|
4524
|
+
getRecommendationPost(groupId, postId, offset2 = 0, amount = 10, excludedUserIds = [], includedUserIds = [], keyword = "", scope = ["user_details", "post_counter"]) {
|
|
4546
4525
|
const cacheKey = `post-recommendation:${groupId}${postId ? `:${postId}` : ``}`;
|
|
4547
4526
|
const cachedFetcher = asyncCache(
|
|
4548
4527
|
cacheKey,
|
|
4549
|
-
() => this.api.post("/recommendation/post", {
|
|
4528
|
+
() => this.api.post("v2/recommendation/post", {
|
|
4550
4529
|
group_id: groupId,
|
|
4551
4530
|
post_id: postId,
|
|
4552
4531
|
included_user_ids: includedUserIds,
|
|
@@ -4564,11 +4543,11 @@ class MFSApi {
|
|
|
4564
4543
|
);
|
|
4565
4544
|
return cachedFetcher();
|
|
4566
4545
|
}
|
|
4567
|
-
getRecommendationGroup(groupId, offset2 = 0, amount = 10, excludedUserIds = [], includedUserIds = [], keyword = "", scope = ["
|
|
4546
|
+
getRecommendationGroup(groupId, offset2 = 0, amount = 10, excludedUserIds = [], includedUserIds = [], keyword = "", scope = ["user_details"]) {
|
|
4568
4547
|
const cacheKey = `group-recommendation:${groupId}`;
|
|
4569
4548
|
const cachedFetcher = asyncCache(
|
|
4570
4549
|
cacheKey,
|
|
4571
|
-
() => this.api.post("/recommendation/group", {
|
|
4550
|
+
() => this.api.post("v2/recommendation/group", {
|
|
4572
4551
|
group_id: groupId,
|
|
4573
4552
|
included_user_ids: includedUserIds,
|
|
4574
4553
|
excluded_user_ids: excludedUserIds,
|
|
@@ -16340,9 +16319,9 @@ const GroupSelector = ({ store, onGroupSelect }) => {
|
|
|
16340
16319
|
const loadGroups = async () => {
|
|
16341
16320
|
setIsLoading(true);
|
|
16342
16321
|
try {
|
|
16343
|
-
const response = await core.
|
|
16322
|
+
const response = await core.fetchConversationList(999, 0);
|
|
16344
16323
|
if (!cancelled) {
|
|
16345
|
-
setGroups(response
|
|
16324
|
+
setGroups(response ?? []);
|
|
16346
16325
|
}
|
|
16347
16326
|
} catch (error) {
|
|
16348
16327
|
} finally {
|
|
@@ -16377,13 +16356,13 @@ const GroupSelector = ({ store, onGroupSelect }) => {
|
|
|
16377
16356
|
)
|
|
16378
16357
|
}
|
|
16379
16358
|
),
|
|
16380
|
-
/* @__PURE__ */ jsx(SelectContent, { align: "start", children: groups.map((
|
|
16359
|
+
/* @__PURE__ */ jsx(SelectContent, { align: "start", children: groups.map((conversation) => /* @__PURE__ */ jsxs(SelectItem, { value: conversation.conversation_id, children: [
|
|
16381
16360
|
/* @__PURE__ */ jsxs(Avatar, { className: "size-6", children: [
|
|
16382
|
-
/* @__PURE__ */ jsx(AvatarImage, { src:
|
|
16383
|
-
/* @__PURE__ */ jsx(AvatarFallback, { children:
|
|
16361
|
+
/* @__PURE__ */ jsx(AvatarImage, { src: conversation.conversation_detail.avatar ?? void 0 }),
|
|
16362
|
+
/* @__PURE__ */ jsx(AvatarFallback, { children: conversation.conversation_detail.name?.charAt(0) })
|
|
16384
16363
|
] }),
|
|
16385
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm", children:
|
|
16386
|
-
] },
|
|
16364
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: conversation.conversation_detail.name ?? conversation.conversation_id })
|
|
16365
|
+
] }, conversation.conversation_id)) })
|
|
16387
16366
|
] }) });
|
|
16388
16367
|
};
|
|
16389
16368
|
const GifIcon = (props) => /* @__PURE__ */ jsx(
|
|
@@ -32472,14 +32451,14 @@ const mentionService = (api, mfs, store, user) => {
|
|
|
32472
32451
|
}
|
|
32473
32452
|
const { groupId, postId } = params;
|
|
32474
32453
|
const response = postId ? await mfs.getRecommendationPost(groupId, postId, 0, 999) : await mfs.getRecommendationGroup(groupId, 0, 999);
|
|
32475
|
-
const apiResults = response.entries?.filter((item) => Boolean(item?.
|
|
32454
|
+
const apiResults = response.entries?.filter((item) => Boolean(item?.user_details))?.map(
|
|
32476
32455
|
(item) => ({
|
|
32477
|
-
id: item?.
|
|
32478
|
-
label: item?.
|
|
32479
|
-
avatar: item?.
|
|
32456
|
+
id: item?.user_details?.id,
|
|
32457
|
+
label: item?.user_details?.name,
|
|
32458
|
+
avatar: item?.user_details?.avatar,
|
|
32480
32459
|
inThisThread: 1,
|
|
32481
|
-
name: item?.
|
|
32482
|
-
selectId: item.
|
|
32460
|
+
name: item?.user_details?.name,
|
|
32461
|
+
selectId: item.user_details?.username,
|
|
32483
32462
|
type: MentionType.User,
|
|
32484
32463
|
from: PostType.Post
|
|
32485
32464
|
})
|
|
@@ -32506,18 +32485,18 @@ const mentionService = (api, mfs, store, user) => {
|
|
|
32506
32485
|
if (!activeGroupId) {
|
|
32507
32486
|
return [];
|
|
32508
32487
|
}
|
|
32509
|
-
const response = await api.
|
|
32510
|
-
return response.
|
|
32511
|
-
(
|
|
32512
|
-
id:
|
|
32513
|
-
label:
|
|
32514
|
-
avatar:
|
|
32488
|
+
const response = await api.fetchConversationList(999, 0);
|
|
32489
|
+
return response.map(
|
|
32490
|
+
(conversation) => ({
|
|
32491
|
+
id: conversation?.conversation_id,
|
|
32492
|
+
label: conversation?.conversation_detail?.name,
|
|
32493
|
+
avatar: conversation?.conversation_detail?.avatar,
|
|
32515
32494
|
inThisThread: 1,
|
|
32516
|
-
name:
|
|
32517
|
-
selectId:
|
|
32495
|
+
name: conversation?.conversation_detail?.name,
|
|
32496
|
+
selectId: conversation?.conversation_detail?.select_id,
|
|
32518
32497
|
type: MentionType.Group,
|
|
32519
32498
|
from: PostType.Post,
|
|
32520
|
-
isCrossExposureEnable:
|
|
32499
|
+
isCrossExposureEnable: conversation?.conversation_detail?.allow_cross_exposure
|
|
32521
32500
|
})
|
|
32522
32501
|
);
|
|
32523
32502
|
};
|
|
@@ -33659,10 +33638,20 @@ const PostBuilderEditorInstance = ({
|
|
|
33659
33638
|
placement
|
|
33660
33639
|
}) => {
|
|
33661
33640
|
const [isDragging, setIsDragging] = useState(false);
|
|
33641
|
+
const [hasGroupSelected, setHasGroupSelected] = useState(true);
|
|
33662
33642
|
const { trackPublish } = useAnalyticsTracking();
|
|
33663
33643
|
const { clearContent } = usePersistence(placement);
|
|
33664
33644
|
useHostAnalyticsBridge();
|
|
33665
33645
|
useEditorTracking({ editor, editorType: editorTab });
|
|
33646
|
+
useEffect(() => {
|
|
33647
|
+
const checkGroupSelection = () => {
|
|
33648
|
+
const { groupId, selectedGroupId } = store.getState();
|
|
33649
|
+
setHasGroupSelected(!!(groupId || selectedGroupId));
|
|
33650
|
+
};
|
|
33651
|
+
checkGroupSelection();
|
|
33652
|
+
const unsubscribe = store.subscribe(checkGroupSelection);
|
|
33653
|
+
return () => unsubscribe();
|
|
33654
|
+
}, [store]);
|
|
33666
33655
|
const handleDragOver = (e2) => {
|
|
33667
33656
|
e2.preventDefault();
|
|
33668
33657
|
setIsDragging(true);
|
|
@@ -33675,6 +33664,12 @@ const PostBuilderEditorInstance = ({
|
|
|
33675
33664
|
e2.preventDefault();
|
|
33676
33665
|
setIsDragging(false);
|
|
33677
33666
|
};
|
|
33667
|
+
const handleOpenGroupSelector = () => {
|
|
33668
|
+
const selectorTrigger = document.querySelector('[aria-label="Select group"]');
|
|
33669
|
+
if (selectorTrigger) {
|
|
33670
|
+
selectorTrigger.click();
|
|
33671
|
+
}
|
|
33672
|
+
};
|
|
33678
33673
|
const handleSubmit = (sendCrossMention) => {
|
|
33679
33674
|
if (!editor) return;
|
|
33680
33675
|
const html2 = editor?.getHTML();
|
|
@@ -33722,11 +33717,21 @@ const PostBuilderEditorInstance = ({
|
|
|
33722
33717
|
"div",
|
|
33723
33718
|
{
|
|
33724
33719
|
className: cn(
|
|
33725
|
-
"post-builder-editor bg-background border rounded-md overflow-hidden max-h-full grow flex flex-col overflow-y-auto transition-all duration-300 ease-in-out",
|
|
33720
|
+
"post-builder-editor bg-background border rounded-md overflow-hidden max-h-full grow flex flex-col overflow-y-auto transition-all duration-300 ease-in-out relative",
|
|
33726
33721
|
placement === EditorPlacement.Comment ? "min-h-32" : "min-h-60",
|
|
33727
33722
|
className
|
|
33728
33723
|
),
|
|
33729
33724
|
children: [
|
|
33725
|
+
!hasGroupSelected && /* @__PURE__ */ jsx("div", { className: "z-50 absolute inset-0 bg-foreground/30 backdrop-blur-xs flex items-center justify-center rounded-md pointer-events-none", children: /* @__PURE__ */ jsx(
|
|
33726
|
+
Button,
|
|
33727
|
+
{
|
|
33728
|
+
variant: "outline",
|
|
33729
|
+
size: "lg",
|
|
33730
|
+
onClick: handleOpenGroupSelector,
|
|
33731
|
+
className: "pointer-events-auto cursor-pointer hover:animate-none animate-pulse",
|
|
33732
|
+
children: "Please select a group first"
|
|
33733
|
+
}
|
|
33734
|
+
) }),
|
|
33730
33735
|
placement !== EditorPlacement.Comment && /* @__PURE__ */ jsx(EditorTypeTabs, { editorTab, onSwitchEditorTab: onSwitchEditor }),
|
|
33731
33736
|
/* @__PURE__ */ jsx(
|
|
33732
33737
|
Toolbar,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@select-org/select-post-builder",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.35",
|
|
4
4
|
"description": "A reusable, extensible Post Builder widget for the Select platform and beyond.",
|
|
5
5
|
"main": "./dist/post-builder.cjs.js",
|
|
6
6
|
"module": "./dist/post-builder.js",
|