@blocklet/discuss-kit 1.0.10 → 1.0.11
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/lib/cjs/api.js +1 -1
- package/lib/cjs/components/uploader.css +1287 -0
- package/lib/cjs/components/uploader.js +41 -0
- package/lib/cjs/did-comment.js +26 -8
- package/lib/es/api.js +1 -1
- package/lib/es/components/uploader.css +1287 -0
- package/lib/es/components/uploader.js +39 -0
- package/lib/es/did-comment.js +26 -8
- package/package.json +8 -6
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const joinUrl = require("url-join");
|
|
4
|
+
const uppload$1 = require("uppload");
|
|
5
|
+
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
6
|
+
const joinUrl__default = /* @__PURE__ */ _interopDefaultLegacy(joinUrl);
|
|
7
|
+
const uppload = "";
|
|
8
|
+
const light = "";
|
|
9
|
+
const getEndpoint = () => {
|
|
10
|
+
const obj = new window.URL(window.location.origin);
|
|
11
|
+
obj.pathname = joinUrl__default.default(window.blocklet.prefix, "/api/uploads");
|
|
12
|
+
return obj.href;
|
|
13
|
+
};
|
|
14
|
+
const upload = uppload$1.xhrUploader({
|
|
15
|
+
endpoint: getEndpoint(),
|
|
16
|
+
fileKeyName: "image",
|
|
17
|
+
responseFunction: (text) => {
|
|
18
|
+
try {
|
|
19
|
+
const json = JSON.parse(text);
|
|
20
|
+
return json.url;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return Promise.reject(error);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const uploader = new uppload$1.Uppload({
|
|
27
|
+
lang: uppload$1.en,
|
|
28
|
+
defaultService: "local",
|
|
29
|
+
maxWidth: 1440,
|
|
30
|
+
maxHeight: 900,
|
|
31
|
+
uploader: uppload$1.xhrUploader({
|
|
32
|
+
endpoint: getEndpoint(),
|
|
33
|
+
fileKeyName: "image"
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
uploader.use([new uppload$1.Local({
|
|
37
|
+
mimeTypes: ["image/png", "image/jpeg", "image/gif"]
|
|
38
|
+
}), new uppload$1.Camera(), new uppload$1.Screenshot(), new uppload$1.URL(), new uppload$1.Twitter(), new uppload$1.Facebook()]);
|
|
39
|
+
uploader.use([new uppload$1.Preview(), new uppload$1.Rotate(), new uppload$1.Crop(), new uppload$1.Blur(), new uppload$1.Contrast(), new uppload$1.Grayscale(), new uppload$1.Saturate()]);
|
|
40
|
+
exports.default = uploader;
|
|
41
|
+
exports.upload = upload;
|
package/lib/cjs/did-comment.js
CHANGED
|
@@ -10,12 +10,14 @@ const Button = require("@arcblock/ux/lib/Button");
|
|
|
10
10
|
const Box = require("@mui/material/Box");
|
|
11
11
|
const CircularProgress = require("@mui/material/CircularProgress");
|
|
12
12
|
const ButtonGroup = require("@mui/material/ButtonGroup");
|
|
13
|
+
const editor = require("@blocklet/editor");
|
|
13
14
|
const context = require("@arcblock/ux/lib/Locale/context");
|
|
14
15
|
const reactErrorBoundary = require("react-error-boundary");
|
|
15
16
|
const discussKitUx = require("@blocklet/discuss-kit-ux");
|
|
16
17
|
const ErrorFallback = require("./components/error-fallback");
|
|
17
18
|
const locales = require("./locales");
|
|
18
19
|
const getWsClient = require("./ws");
|
|
20
|
+
const uploader = require("./components/uploader");
|
|
19
21
|
const api = require("./api");
|
|
20
22
|
const jsxRuntime = require("react/jsx-runtime");
|
|
21
23
|
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
@@ -115,6 +117,12 @@ const commentAPI = {
|
|
|
115
117
|
},
|
|
116
118
|
unrate: async (comment) => {
|
|
117
119
|
await api__default.default.delete(`/objects/${comment.objectId}/comments/${comment.id}/ratings`);
|
|
120
|
+
},
|
|
121
|
+
fetchRatings: async (id) => {
|
|
122
|
+
const {
|
|
123
|
+
data
|
|
124
|
+
} = await api__default.default.get(`/ratings/${id}`);
|
|
125
|
+
return data;
|
|
118
126
|
}
|
|
119
127
|
};
|
|
120
128
|
function DIDComment({
|
|
@@ -207,7 +215,8 @@ function DIDComment({
|
|
|
207
215
|
onRate: handleOnRate,
|
|
208
216
|
onUnrate: handleOnUnrate,
|
|
209
217
|
variant: "inverse",
|
|
210
|
-
size: "lg"
|
|
218
|
+
size: "lg",
|
|
219
|
+
fetchRatings: () => commentAPI.fetchRatings(object.id)
|
|
211
220
|
})
|
|
212
221
|
}), showConnectBtn && (session.user ? /* @__PURE__ */ jsxRuntime.jsx(SessionManager__default.default, {
|
|
213
222
|
style: {
|
|
@@ -328,13 +337,22 @@ function Wrapper({
|
|
|
328
337
|
translations: locales.translations,
|
|
329
338
|
locale,
|
|
330
339
|
children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.InternalThemeProvider, {
|
|
331
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
340
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(editor.EditorConfigProvider, {
|
|
341
|
+
value: {
|
|
342
|
+
uploader: {
|
|
343
|
+
upload: (file) => uploader.upload(file).then((url) => ({
|
|
344
|
+
url
|
|
345
|
+
}))
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.CommentsProvider, {
|
|
349
|
+
target: object,
|
|
350
|
+
api: commentAPI,
|
|
351
|
+
flatView,
|
|
352
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(DIDComment, {
|
|
353
|
+
...rest,
|
|
354
|
+
object
|
|
355
|
+
})
|
|
338
356
|
})
|
|
339
357
|
})
|
|
340
358
|
})
|
package/lib/es/api.js
CHANGED
|
@@ -7,7 +7,7 @@ request.interceptors.request.use(
|
|
|
7
7
|
(error) => Promise.reject(error)
|
|
8
8
|
);
|
|
9
9
|
const fetchRatingStats = async (id) => {
|
|
10
|
-
const { data } = await request.get(`/ratings/${id}`);
|
|
10
|
+
const { data } = await request.get(`/ratings/${id}/stats`);
|
|
11
11
|
return data;
|
|
12
12
|
};
|
|
13
13
|
const fetchComments = async (params) => {
|