@blocklet/discuss-kit 1.0.10 → 1.0.12

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.
@@ -0,0 +1,39 @@
1
+ import joinUrl from "url-join";
2
+ import { xhrUploader, Uppload, en, Local, Camera, Screenshot, URL, Twitter, Facebook, Preview, Rotate, Crop, Blur, Contrast, Grayscale, Saturate } from "uppload";
3
+ const uppload = "";
4
+ const light = "";
5
+ const getEndpoint = () => {
6
+ const obj = new window.URL(window.location.origin);
7
+ obj.pathname = joinUrl(window.blocklet.prefix, "/api/uploads");
8
+ return obj.href;
9
+ };
10
+ const upload = xhrUploader({
11
+ endpoint: getEndpoint(),
12
+ fileKeyName: "image",
13
+ responseFunction: (text) => {
14
+ try {
15
+ const json = JSON.parse(text);
16
+ return json.url;
17
+ } catch (error) {
18
+ return Promise.reject(error);
19
+ }
20
+ }
21
+ });
22
+ const uploader = new Uppload({
23
+ lang: en,
24
+ defaultService: "local",
25
+ maxWidth: 1440,
26
+ maxHeight: 900,
27
+ uploader: xhrUploader({
28
+ endpoint: getEndpoint(),
29
+ fileKeyName: "image"
30
+ })
31
+ });
32
+ uploader.use([new Local({
33
+ mimeTypes: ["image/png", "image/jpeg", "image/gif"]
34
+ }), new Camera(), new Screenshot(), new URL(), new Twitter(), new Facebook()]);
35
+ uploader.use([new Preview(), new Rotate(), new Crop(), new Blur(), new Contrast(), new Grayscale(), new Saturate()]);
36
+ export {
37
+ uploader as default,
38
+ upload
39
+ };
@@ -15,6 +15,7 @@ import { useCommentSettings, InternalThemeProvider, CommentsProvider, useComment
15
15
  import ErrorFallback from "./components/error-fallback";
16
16
  import { translations } from "./locales";
17
17
  import getWsClient, { useSubscription } from "./ws";
18
+ import UploadProvider from "./components/upload-provider";
18
19
  import api, { fetchRatingStats } from "./api";
19
20
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
20
21
  const getPrefix = () => {
@@ -102,6 +103,12 @@ const commentAPI = {
102
103
  },
103
104
  unrate: async (comment) => {
104
105
  await api.delete(`/objects/${comment.objectId}/comments/${comment.id}/ratings`);
106
+ },
107
+ fetchRatings: async (id) => {
108
+ const {
109
+ data
110
+ } = await api.get(`/ratings/${id}`);
111
+ return data;
105
112
  }
106
113
  };
107
114
  function DIDComment({
@@ -194,7 +201,8 @@ function DIDComment({
194
201
  onRate: handleOnRate,
195
202
  onUnrate: handleOnUnrate,
196
203
  variant: "inverse",
197
- size: "lg"
204
+ size: "lg",
205
+ fetchRatings: () => commentAPI.fetchRatings(object.id)
198
206
  })
199
207
  }), showConnectBtn && (session.user ? /* @__PURE__ */ jsx(SessionManager, {
200
208
  style: {
@@ -315,13 +323,15 @@ function Wrapper({
315
323
  translations,
316
324
  locale,
317
325
  children: /* @__PURE__ */ jsx(InternalThemeProvider, {
318
- children: /* @__PURE__ */ jsx(CommentsProvider, {
319
- target: object,
320
- api: commentAPI,
321
- flatView,
322
- children: /* @__PURE__ */ jsx(DIDComment, {
323
- ...rest,
324
- object
326
+ children: /* @__PURE__ */ jsx(UploadProvider, {
327
+ children: /* @__PURE__ */ jsx(CommentsProvider, {
328
+ target: object,
329
+ api: commentAPI,
330
+ flatView,
331
+ children: /* @__PURE__ */ jsx(DIDComment, {
332
+ ...rest,
333
+ object
334
+ })
325
335
  })
326
336
  })
327
337
  })
package/lib/es/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import { default as default2 } from "./did-comment";
2
2
  import { default as default3 } from "./did-comment-with-session";
3
3
  import { default as default4 } from "./theme-provider";
4
+ import { default as default5 } from "./components/upload-provider";
4
5
  export {
5
6
  default2 as DIDComment,
6
7
  default3 as DIDCommentWithSession,
7
- default4 as ThemeProvider
8
+ default4 as ThemeProvider,
9
+ default5 as UploadProvider
8
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "A react component for DID Comments blocklet.",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/es/index.js",
@@ -34,10 +34,11 @@
34
34
  "author": "Nate <nate@arcblock.io> (http://github.com/NateRobinson)",
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
- "@arcblock/did-connect": "^2.4.52",
38
- "@arcblock/ux": "^2.4.52",
39
- "@arcblock/ws": "^1.18.15",
40
- "@blocklet/discuss-kit-ux": "1.0.10",
37
+ "@arcblock/did-connect": "^2.4.57",
38
+ "@arcblock/ux": "^2.4.57",
39
+ "@arcblock/ws": "^1.18.30",
40
+ "@blocklet/discuss-kit-ux": "1.0.12",
41
+ "@blocklet/editor": "^0.0.10",
41
42
  "@emotion/react": "^11.10.5",
42
43
  "@emotion/styled": "^11.10.5",
43
44
  "@mui/icons-material": "^5.10.9",
@@ -54,6 +55,7 @@
54
55
  "react-use": "^17.4.0",
55
56
  "rehype-sanitize": "^5.0.1",
56
57
  "timeago.js": "^4.0.2",
58
+ "uppload": "^3.2.1",
57
59
  "url-join": "^4.0.1"
58
60
  },
59
61
  "peerDependencies": {
@@ -75,5 +77,5 @@
75
77
  "vite-plugin-build": "^0.6.0",
76
78
  "vite-plugin-svgr": "^2.2.2"
77
79
  },
78
- "gitHead": "6893fc8ce35e12834ea91d126dcedea17d0dafdb"
80
+ "gitHead": "0ff93c4c300d6ef849bec08ce79def6fd39dc728"
79
81
  }