@blocklet/discuss-kit-post 2.1.217 → 2.1.219
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.es.js +47 -5
- package/dist/index.umd.js +47 -6
- package/dist/locales/en.d.ts +19 -0
- package/dist/locales/index.d.ts +4 -0
- package/dist/locales/zh.d.ts +19 -0
- package/package.json +3 -2
package/dist/index.es.js
CHANGED
|
@@ -2,13 +2,14 @@ var _a, _b;
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useMediaQuery, Box, CircularProgress, Tooltip, Stack, Button, IconButton } from "@mui/material";
|
|
4
4
|
import { useSetState, useGetState, useDocumentVisibility, useRequest, useThrottleEffect, useTimeout } from "ahooks";
|
|
5
|
-
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
5
|
+
import { useLocaleContext, LocaleProvider } from "@arcblock/ux/lib/Locale/context";
|
|
6
6
|
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
7
7
|
import { useRef, useState, useCallback, useEffect, useContext } from "react";
|
|
8
8
|
import { DirtyPromptContainer, useEventCallback, utils, toast, LazyEditor, SubscriptionPaywall, EditorPreview, InternalThemeProvider, UploaderProvider, DefaultEditorConfigProvider } from "@blocklet/discuss-kit-ux";
|
|
9
9
|
import { Edit } from "@mui/icons-material";
|
|
10
10
|
import { createAxios } from "@blocklet/js-sdk";
|
|
11
11
|
import { joinURL, withQuery } from "ufo";
|
|
12
|
+
import flat from "flat";
|
|
12
13
|
const discussKitService = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find(
|
|
13
14
|
(x) => x.did === "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu"
|
|
14
15
|
);
|
|
@@ -137,6 +138,7 @@ function DraftStatus({ status, error, ...rest }) {
|
|
|
137
138
|
] });
|
|
138
139
|
}
|
|
139
140
|
function InternalPostEdit({ post, onSave, onUpdate, onCancel, ...rest }) {
|
|
141
|
+
const { t } = useLocaleContext();
|
|
140
142
|
const { reset, check } = DirtyPromptContainer.useContainer();
|
|
141
143
|
const save = async (state) => {
|
|
142
144
|
if (!post) {
|
|
@@ -184,8 +186,8 @@ function InternalPostEdit({ post, onSave, onUpdate, onCancel, ...rest }) {
|
|
|
184
186
|
return /* @__PURE__ */ jsxs(Box, { ...rest, children: [
|
|
185
187
|
/* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [
|
|
186
188
|
/* @__PURE__ */ jsxs(Box, { sx: { mb: 1, display: "flex", gap: 1 }, children: [
|
|
187
|
-
/* @__PURE__ */ jsx(Button, { variant: "contained", color: "primary", onClick: () => handleSave(), children: "
|
|
188
|
-
/* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: handleCancel, children: "
|
|
189
|
+
/* @__PURE__ */ jsx(Button, { variant: "contained", color: "primary", onClick: () => handleSave(), children: t("save") }),
|
|
190
|
+
/* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: handleCancel, children: t("cancel") })
|
|
189
191
|
] }),
|
|
190
192
|
/* @__PURE__ */ jsx(DraftStatus, { status, error })
|
|
191
193
|
] }),
|
|
@@ -212,6 +214,46 @@ function PostPaywall({ post, children, ...rest }) {
|
|
|
212
214
|
}
|
|
213
215
|
return null;
|
|
214
216
|
}
|
|
217
|
+
const en = {
|
|
218
|
+
draftStatus: {
|
|
219
|
+
idle: "Draft",
|
|
220
|
+
saving: "Saving changes...",
|
|
221
|
+
saved: "Draft saved",
|
|
222
|
+
error: "Failed to save"
|
|
223
|
+
},
|
|
224
|
+
paywall: {
|
|
225
|
+
subscription: {
|
|
226
|
+
title: "This post is for paid subscribers only",
|
|
227
|
+
desc: "Subscribe now to read the full story and get access to all paid posts",
|
|
228
|
+
subscribeNow: "Subscribe now",
|
|
229
|
+
alreadySubscribe: "Already subscribe?"
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
save: "Save",
|
|
233
|
+
cancel: "Cancel"
|
|
234
|
+
};
|
|
235
|
+
const zh = {
|
|
236
|
+
paywall: {
|
|
237
|
+
subscription: {
|
|
238
|
+
title: "此帖仅供付费订阅者使用",
|
|
239
|
+
desc: "立即订阅以阅读完整内容并获取所有相关内容的访问权限。",
|
|
240
|
+
subscribeNow: "立即订阅",
|
|
241
|
+
alreadySubscribe: "已经订阅?"
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
draftStatus: {
|
|
245
|
+
idle: "草稿",
|
|
246
|
+
saving: "保存中...",
|
|
247
|
+
saved: "草稿已保存",
|
|
248
|
+
error: "保存失败"
|
|
249
|
+
},
|
|
250
|
+
save: "保存",
|
|
251
|
+
cancel: "取消"
|
|
252
|
+
};
|
|
253
|
+
const translations = {
|
|
254
|
+
zh: flat(zh),
|
|
255
|
+
en: flat(en)
|
|
256
|
+
};
|
|
215
257
|
function InternalPost({ postId, sx, readonly, ...rest }) {
|
|
216
258
|
var _a2, _b2;
|
|
217
259
|
const { locale } = useLocaleContext();
|
|
@@ -249,7 +291,7 @@ function InternalPost({ postId, sx, readonly, ...rest }) {
|
|
|
249
291
|
},
|
|
250
292
|
...Array.isArray(sx) ? sx : [sx]
|
|
251
293
|
];
|
|
252
|
-
return /* @__PURE__ */ jsx(InternalThemeProvider, { children: /* @__PURE__ */ jsx(UploaderProvider, { children: /* @__PURE__ */ jsx(DefaultEditorConfigProvider, { request: api, children: /* @__PURE__ */ jsxs(Box, { sx: mergedSx, ...rest, children: [
|
|
294
|
+
return /* @__PURE__ */ jsx(InternalThemeProvider, { children: /* @__PURE__ */ jsx(LocaleProvider, { translations, children: /* @__PURE__ */ jsx(UploaderProvider, { children: /* @__PURE__ */ jsx(DefaultEditorConfigProvider, { request: api, children: /* @__PURE__ */ jsxs(Box, { sx: mergedSx, ...rest, children: [
|
|
253
295
|
!readonly && isAdmin && !editable && /* @__PURE__ */ jsx(
|
|
254
296
|
IconButton,
|
|
255
297
|
{
|
|
@@ -261,7 +303,7 @@ function InternalPost({ postId, sx, readonly, ...rest }) {
|
|
|
261
303
|
}
|
|
262
304
|
),
|
|
263
305
|
editable ? /* @__PURE__ */ jsx(PostEdit, { post, onSave: handleSave, onUpdate: handleUpdate, onCancel: () => setEditable(false) }) : /* @__PURE__ */ jsx(PostPaywall, { post, children: /* @__PURE__ */ jsx(EditorPreview, { content: post.content || "" }) })
|
|
264
|
-
] }) }) }) });
|
|
306
|
+
] }) }) }) }) });
|
|
265
307
|
}
|
|
266
308
|
function Post(props) {
|
|
267
309
|
if (!discussKitService) {
|
package/dist/index.umd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("@mui/material"), require("ahooks"), require("@arcblock/ux/lib/Locale/context"), require("@arcblock/did-connect/lib/Session"), require("react"), require("@blocklet/discuss-kit-ux"), require("@mui/icons-material"), require("@blocklet/js-sdk"), require("ufo")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "@mui/material", "ahooks", "@arcblock/ux/lib/Locale/context", "@arcblock/did-connect/lib/Session", "react", "@blocklet/discuss-kit-ux", "@mui/icons-material", "@blocklet/js-sdk", "ufo"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.DiscussKitPost = {}, global.jsxRuntime, global.material, global.ahooks, global.context, global.Session, global.react, global.discussKitUx, global.iconsMaterial, global.jsSdk, global.ufo));
|
|
3
|
-
})(this, function(exports2, jsxRuntime, material, ahooks, context, Session, react, discussKitUx, iconsMaterial, jsSdk, ufo) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("@mui/material"), require("ahooks"), require("@arcblock/ux/lib/Locale/context"), require("@arcblock/did-connect/lib/Session"), require("react"), require("@blocklet/discuss-kit-ux"), require("@mui/icons-material"), require("@blocklet/js-sdk"), require("ufo"), require("flat")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "@mui/material", "ahooks", "@arcblock/ux/lib/Locale/context", "@arcblock/did-connect/lib/Session", "react", "@blocklet/discuss-kit-ux", "@mui/icons-material", "@blocklet/js-sdk", "ufo", "flat"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.DiscussKitPost = {}, global.jsxRuntime, global.material, global.ahooks, global.context, global.Session, global.react, global.discussKitUx, global.iconsMaterial, global.jsSdk, global.ufo, global.flat));
|
|
3
|
+
})(this, function(exports2, jsxRuntime, material, ahooks, context, Session, react, discussKitUx, iconsMaterial, jsSdk, ufo, flat) {
|
|
4
4
|
"use strict";
|
|
5
5
|
var _a, _b;
|
|
6
6
|
const discussKitService = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find(
|
|
@@ -131,6 +131,7 @@
|
|
|
131
131
|
] });
|
|
132
132
|
}
|
|
133
133
|
function InternalPostEdit({ post, onSave, onUpdate, onCancel, ...rest }) {
|
|
134
|
+
const { t } = context.useLocaleContext();
|
|
134
135
|
const { reset, check } = discussKitUx.DirtyPromptContainer.useContainer();
|
|
135
136
|
const save = async (state) => {
|
|
136
137
|
if (!post) {
|
|
@@ -178,8 +179,8 @@
|
|
|
178
179
|
return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { ...rest, children: [
|
|
179
180
|
/* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [
|
|
180
181
|
/* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { mb: 1, display: "flex", gap: 1 }, children: [
|
|
181
|
-
/* @__PURE__ */ jsxRuntime.jsx(material.Button, { variant: "contained", color: "primary", onClick: () => handleSave(), children: "
|
|
182
|
-
/* @__PURE__ */ jsxRuntime.jsx(material.Button, { variant: "outlined", onClick: handleCancel, children: "
|
|
182
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Button, { variant: "contained", color: "primary", onClick: () => handleSave(), children: t("save") }),
|
|
183
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Button, { variant: "outlined", onClick: handleCancel, children: t("cancel") })
|
|
183
184
|
] }),
|
|
184
185
|
/* @__PURE__ */ jsxRuntime.jsx(DraftStatus, { status, error })
|
|
185
186
|
] }),
|
|
@@ -206,6 +207,46 @@
|
|
|
206
207
|
}
|
|
207
208
|
return null;
|
|
208
209
|
}
|
|
210
|
+
const en = {
|
|
211
|
+
draftStatus: {
|
|
212
|
+
idle: "Draft",
|
|
213
|
+
saving: "Saving changes...",
|
|
214
|
+
saved: "Draft saved",
|
|
215
|
+
error: "Failed to save"
|
|
216
|
+
},
|
|
217
|
+
paywall: {
|
|
218
|
+
subscription: {
|
|
219
|
+
title: "This post is for paid subscribers only",
|
|
220
|
+
desc: "Subscribe now to read the full story and get access to all paid posts",
|
|
221
|
+
subscribeNow: "Subscribe now",
|
|
222
|
+
alreadySubscribe: "Already subscribe?"
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
save: "Save",
|
|
226
|
+
cancel: "Cancel"
|
|
227
|
+
};
|
|
228
|
+
const zh = {
|
|
229
|
+
paywall: {
|
|
230
|
+
subscription: {
|
|
231
|
+
title: "此帖仅供付费订阅者使用",
|
|
232
|
+
desc: "立即订阅以阅读完整内容并获取所有相关内容的访问权限。",
|
|
233
|
+
subscribeNow: "立即订阅",
|
|
234
|
+
alreadySubscribe: "已经订阅?"
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
draftStatus: {
|
|
238
|
+
idle: "草稿",
|
|
239
|
+
saving: "保存中...",
|
|
240
|
+
saved: "草稿已保存",
|
|
241
|
+
error: "保存失败"
|
|
242
|
+
},
|
|
243
|
+
save: "保存",
|
|
244
|
+
cancel: "取消"
|
|
245
|
+
};
|
|
246
|
+
const translations = {
|
|
247
|
+
zh: flat(zh),
|
|
248
|
+
en: flat(en)
|
|
249
|
+
};
|
|
209
250
|
function InternalPost({ postId, sx, readonly, ...rest }) {
|
|
210
251
|
var _a2, _b2;
|
|
211
252
|
const { locale } = context.useLocaleContext();
|
|
@@ -243,7 +284,7 @@
|
|
|
243
284
|
},
|
|
244
285
|
...Array.isArray(sx) ? sx : [sx]
|
|
245
286
|
];
|
|
246
|
-
return /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.InternalThemeProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.UploaderProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.DefaultEditorConfigProvider, { request: api, children: /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: mergedSx, ...rest, children: [
|
|
287
|
+
return /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.InternalThemeProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(context.LocaleProvider, { translations, children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.UploaderProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.DefaultEditorConfigProvider, { request: api, children: /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: mergedSx, ...rest, children: [
|
|
247
288
|
!readonly && isAdmin && !editable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
248
289
|
material.IconButton,
|
|
249
290
|
{
|
|
@@ -255,7 +296,7 @@
|
|
|
255
296
|
}
|
|
256
297
|
),
|
|
257
298
|
editable ? /* @__PURE__ */ jsxRuntime.jsx(PostEdit, { post, onSave: handleSave, onUpdate: handleUpdate, onCancel: () => setEditable(false) }) : /* @__PURE__ */ jsxRuntime.jsx(PostPaywall, { post, children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.EditorPreview, { content: post.content || "" }) })
|
|
258
|
-
] }) }) }) });
|
|
299
|
+
] }) }) }) }) });
|
|
259
300
|
}
|
|
260
301
|
function Post(props) {
|
|
261
302
|
if (!discussKitService) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
draftStatus: {
|
|
3
|
+
idle: string;
|
|
4
|
+
saving: string;
|
|
5
|
+
saved: string;
|
|
6
|
+
error: string;
|
|
7
|
+
};
|
|
8
|
+
paywall: {
|
|
9
|
+
subscription: {
|
|
10
|
+
title: string;
|
|
11
|
+
desc: string;
|
|
12
|
+
subscribeNow: string;
|
|
13
|
+
alreadySubscribe: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
save: string;
|
|
17
|
+
cancel: string;
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
paywall: {
|
|
3
|
+
subscription: {
|
|
4
|
+
title: string;
|
|
5
|
+
desc: string;
|
|
6
|
+
subscribeNow: string;
|
|
7
|
+
alreadySubscribe: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
draftStatus: {
|
|
11
|
+
idle: string;
|
|
12
|
+
saving: string;
|
|
13
|
+
saved: string;
|
|
14
|
+
error: string;
|
|
15
|
+
};
|
|
16
|
+
save: string;
|
|
17
|
+
cancel: string;
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/discuss-kit-post",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.219",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
"@blocklet/js-sdk": "^1.16.41-beta-20250319-131732-1224cca5",
|
|
22
22
|
"@mui/icons-material": "^5.16.7",
|
|
23
23
|
"ahooks": "^3.8.1",
|
|
24
|
+
"flat": "^5.0.2",
|
|
24
25
|
"ufo": "1.3.1",
|
|
25
|
-
"@blocklet/discuss-kit-ux": "^2.1.
|
|
26
|
+
"@blocklet/discuss-kit-ux": "^2.1.219"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
29
|
"@arcblock/did-connect": "^2.10.36",
|