@blocklet/discuss-kit-post 2.3.106 → 2.4.1
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 +21 -13
- package/dist/index.umd.js +21 -13
- package/package.json +15 -15
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var _a, _b;
|
|
2
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
2
|
import { useMediaQuery, Box, CircularProgress, Tooltip, Stack, Button, IconButton } from "@mui/material";
|
|
4
3
|
import { useSetState, useGetState, useDocumentVisibility, useRequest, useThrottleEffect, useTimeout } from "ahooks";
|
|
@@ -10,7 +9,7 @@ import { Edit } from "@mui/icons-material";
|
|
|
10
9
|
import { createAxios } from "@blocklet/js-sdk";
|
|
11
10
|
import { joinURL, withQuery } from "ufo";
|
|
12
11
|
import flat from "flat";
|
|
13
|
-
const discussKitService =
|
|
12
|
+
const discussKitService = window.blocklet?.componentMountPoints?.find(
|
|
14
13
|
(x) => x.did === "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu"
|
|
15
14
|
);
|
|
16
15
|
const discussKitPrefix = discussKitService ? joinURL(discussKitService.mountPoint, "/") : "";
|
|
@@ -133,7 +132,7 @@ function DraftStatus({ status, error, ...rest }) {
|
|
|
133
132
|
return status !== "idle" ? /* @__PURE__ */ jsx(Box, { sx: { display: { xs: "inline-block", md: "none", lineHeight: 1 } }, component: CircularProgress, size: 16 }) : null;
|
|
134
133
|
}
|
|
135
134
|
return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, ...rest, children: [
|
|
136
|
-
/* @__PURE__ */ jsx(Tooltip, { title: error
|
|
135
|
+
/* @__PURE__ */ jsx(Tooltip, { title: error?.message, children: /* @__PURE__ */ jsx(Box, { sx: { width: 8, height: 8, borderRadius: "100%", bgcolor: error ? "error.main" : "success.main" } }) }),
|
|
137
136
|
/* @__PURE__ */ jsx(Box, { sx: { color: "grey.600", fontSize: 13, lineHeight: 1 }, component: "span", className: "draft-status-text", children: error ? t("draftStatus.error") : t(`draftStatus.${status}`) })
|
|
138
137
|
] });
|
|
139
138
|
}
|
|
@@ -164,7 +163,7 @@ function InternalPostEdit({ post, onSave, onUpdate, onCancel, ...rest }) {
|
|
|
164
163
|
status,
|
|
165
164
|
error,
|
|
166
165
|
saveNow
|
|
167
|
-
} = useAutoSaveState({ title:
|
|
166
|
+
} = useAutoSaveState({ title: post?.title || "", content: post?.content || "" }, { save });
|
|
168
167
|
const handleContentChange = ({ content }) => {
|
|
169
168
|
setState({ content });
|
|
170
169
|
};
|
|
@@ -184,13 +183,23 @@ function InternalPostEdit({ post, onSave, onUpdate, onCancel, ...rest }) {
|
|
|
184
183
|
}
|
|
185
184
|
};
|
|
186
185
|
return /* @__PURE__ */ jsxs(Box, { ...rest, children: [
|
|
187
|
-
/* @__PURE__ */ jsxs(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
186
|
+
/* @__PURE__ */ jsxs(
|
|
187
|
+
Stack,
|
|
188
|
+
{
|
|
189
|
+
direction: "row",
|
|
190
|
+
sx: {
|
|
191
|
+
justifyContent: "space-between",
|
|
192
|
+
alignItems: "center"
|
|
193
|
+
},
|
|
194
|
+
children: [
|
|
195
|
+
/* @__PURE__ */ jsxs(Box, { sx: { mb: 1, display: "flex", gap: 1 }, children: [
|
|
196
|
+
/* @__PURE__ */ jsx(Button, { variant: "contained", color: "primary", onClick: () => handleSave(), children: t("save") }),
|
|
197
|
+
/* @__PURE__ */ jsx(Button, { variant: "outlined", onClick: handleCancel, children: t("cancel") })
|
|
198
|
+
] }),
|
|
199
|
+
/* @__PURE__ */ jsx(DraftStatus, { status, error })
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
),
|
|
194
203
|
/* @__PURE__ */ jsx(
|
|
195
204
|
LazyEditor,
|
|
196
205
|
{
|
|
@@ -261,10 +270,9 @@ const translations = {
|
|
|
261
270
|
en: flat(en)
|
|
262
271
|
};
|
|
263
272
|
function InternalPost({ postId, sx, readonly, ...rest }) {
|
|
264
|
-
var _a2, _b2;
|
|
265
273
|
const { locale } = useLocaleContext();
|
|
266
274
|
const sessionCtx = useContext(SessionContext);
|
|
267
|
-
const isAdmin = ["admin", "owner"].includes(
|
|
275
|
+
const isAdmin = ["admin", "owner"].includes(sessionCtx?.session?.user?.role);
|
|
268
276
|
const [editable, setEditable] = useState(false);
|
|
269
277
|
const {
|
|
270
278
|
data: post,
|
package/dist/index.umd.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
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
3
|
})(this, function(exports2, jsxRuntime, material, ahooks, context, Session, react, discussKitUx, iconsMaterial, jsSdk, ufo, flat) {
|
|
4
4
|
"use strict";
|
|
5
|
-
|
|
6
|
-
const discussKitService = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find(
|
|
5
|
+
const discussKitService = window.blocklet?.componentMountPoints?.find(
|
|
7
6
|
(x) => x.did === "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu"
|
|
8
7
|
);
|
|
9
8
|
const discussKitPrefix = discussKitService ? ufo.joinURL(discussKitService.mountPoint, "/") : "";
|
|
@@ -126,7 +125,7 @@
|
|
|
126
125
|
return status !== "idle" ? /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: { xs: "inline-block", md: "none", lineHeight: 1 } }, component: material.CircularProgress, size: 16 }) : null;
|
|
127
126
|
}
|
|
128
127
|
return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, ...rest, children: [
|
|
129
|
-
/* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: error
|
|
128
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: error?.message, children: /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { width: 8, height: 8, borderRadius: "100%", bgcolor: error ? "error.main" : "success.main" } }) }),
|
|
130
129
|
/* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { color: "grey.600", fontSize: 13, lineHeight: 1 }, component: "span", className: "draft-status-text", children: error ? t("draftStatus.error") : t(`draftStatus.${status}`) })
|
|
131
130
|
] });
|
|
132
131
|
}
|
|
@@ -157,7 +156,7 @@
|
|
|
157
156
|
status,
|
|
158
157
|
error,
|
|
159
158
|
saveNow
|
|
160
|
-
} = useAutoSaveState({ title:
|
|
159
|
+
} = useAutoSaveState({ title: post?.title || "", content: post?.content || "" }, { save });
|
|
161
160
|
const handleContentChange = ({ content }) => {
|
|
162
161
|
setState({ content });
|
|
163
162
|
};
|
|
@@ -177,13 +176,23 @@
|
|
|
177
176
|
}
|
|
178
177
|
};
|
|
179
178
|
return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { ...rest, children: [
|
|
180
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
179
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
180
|
+
material.Stack,
|
|
181
|
+
{
|
|
182
|
+
direction: "row",
|
|
183
|
+
sx: {
|
|
184
|
+
justifyContent: "space-between",
|
|
185
|
+
alignItems: "center"
|
|
186
|
+
},
|
|
187
|
+
children: [
|
|
188
|
+
/* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { mb: 1, display: "flex", gap: 1 }, children: [
|
|
189
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Button, { variant: "contained", color: "primary", onClick: () => handleSave(), children: t("save") }),
|
|
190
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Button, { variant: "outlined", onClick: handleCancel, children: t("cancel") })
|
|
191
|
+
] }),
|
|
192
|
+
/* @__PURE__ */ jsxRuntime.jsx(DraftStatus, { status, error })
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
),
|
|
187
196
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
188
197
|
discussKitUx.LazyEditor,
|
|
189
198
|
{
|
|
@@ -254,10 +263,9 @@
|
|
|
254
263
|
en: flat(en)
|
|
255
264
|
};
|
|
256
265
|
function InternalPost({ postId, sx, readonly, ...rest }) {
|
|
257
|
-
var _a2, _b2;
|
|
258
266
|
const { locale } = context.useLocaleContext();
|
|
259
267
|
const sessionCtx = react.useContext(Session.SessionContext);
|
|
260
|
-
const isAdmin = ["admin", "owner"].includes(
|
|
268
|
+
const isAdmin = ["admin", "owner"].includes(sessionCtx?.session?.user?.role);
|
|
261
269
|
const [editable, setEditable] = react.useState(false);
|
|
262
270
|
const {
|
|
263
271
|
data: post,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/discuss-kit-post",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@blocklet/js-sdk": "^1.16.44",
|
|
22
|
-
"@mui/icons-material": "^
|
|
22
|
+
"@mui/icons-material": "^7.1.2",
|
|
23
23
|
"ahooks": "^3.8.1",
|
|
24
24
|
"flat": "^5.0.2",
|
|
25
25
|
"ufo": "1.3.1",
|
|
26
|
-
"@blocklet/discuss-kit-ux": "^2.
|
|
26
|
+
"@blocklet/discuss-kit-ux": "^2.4.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@arcblock/did-connect": "^
|
|
30
|
-
"@arcblock/ux": "^
|
|
31
|
-
"@mui/material": "^
|
|
32
|
-
"react": "
|
|
33
|
-
"react-dom": "
|
|
29
|
+
"@arcblock/did-connect": "^3.0.1",
|
|
30
|
+
"@arcblock/ux": "^3.0.1",
|
|
31
|
+
"@mui/material": "^7.1.2",
|
|
32
|
+
"react": "^19.1.0",
|
|
33
|
+
"react-dom": "^19.1.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
@@ -42,23 +42,23 @@
|
|
|
42
42
|
"@storybook/addon-essentials": "^6.5.16",
|
|
43
43
|
"@storybook/addon-interactions": "^6.5.16",
|
|
44
44
|
"@storybook/addon-links": "^6.5.16",
|
|
45
|
-
"@storybook/builder-vite": "^
|
|
45
|
+
"@storybook/builder-vite": "^9.0.13",
|
|
46
46
|
"@storybook/react": "^6.5.16",
|
|
47
47
|
"@storybook/testing-library": "^0.0.13",
|
|
48
48
|
"@svgr/core": "^6.5.1",
|
|
49
49
|
"@types/react": "^18.3.9",
|
|
50
50
|
"@types/react-color": "^3.0.12",
|
|
51
51
|
"@types/react-dom": "^18.3.0",
|
|
52
|
-
"@vitejs/plugin-react": "^4.
|
|
52
|
+
"@vitejs/plugin-react": "^4.6.0",
|
|
53
53
|
"babel-loader": "^8.4.1",
|
|
54
|
-
"react": "^
|
|
55
|
-
"react-dom": "^
|
|
54
|
+
"react": "^19.1.0",
|
|
55
|
+
"react-dom": "^19.1.0",
|
|
56
56
|
"rollup-plugin-node-externals": "^7.1.3",
|
|
57
57
|
"typescript": "^4.9.5",
|
|
58
58
|
"unplugin-icons": "^0.14.15",
|
|
59
|
-
"vite": "^
|
|
60
|
-
"vite-plugin-dts": "^4.
|
|
61
|
-
"vite-plugin-libcss": "^1.1.
|
|
59
|
+
"vite": "^7.0.0",
|
|
60
|
+
"vite-plugin-dts": "^4.5.4",
|
|
61
|
+
"vite-plugin-libcss": "^1.1.2"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"dev": "npm run storybook",
|