@blocklet/discuss-kit-post 2.1.210 → 2.1.212
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/api.d.ts +4 -0
- package/dist/index.es.js +16 -3
- package/dist/index.umd.js +14 -1
- package/dist/post-paywall.d.ts +5 -0
- package/dist/types.d.ts +1 -0
- package/package.json +2 -2
package/dist/api.d.ts
CHANGED
|
@@ -7,3 +7,7 @@ export declare const updatePostContent: (id: string, payload: {
|
|
|
7
7
|
contentVersion: number;
|
|
8
8
|
locale?: string;
|
|
9
9
|
}) => Promise<any>;
|
|
10
|
+
export declare const fetchPaymentLink: (params: {
|
|
11
|
+
type: 'blog' | 'post' | 'bookmark' | 'doc';
|
|
12
|
+
redirect: string;
|
|
13
|
+
}) => Promise<any>;
|
package/dist/index.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var _a, _b;
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
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
5
|
import { useLocaleContext } 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
|
-
import { DirtyPromptContainer, useEventCallback, utils, toast, LazyEditor, EditorPreview, InternalThemeProvider, UploaderProvider, DefaultEditorConfigProvider } from "@blocklet/discuss-kit-ux";
|
|
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";
|
|
@@ -32,6 +32,10 @@ const updatePostContent = async (id, payload) => {
|
|
|
32
32
|
const { data } = await api.put(`/posts/${id}/content`, payload);
|
|
33
33
|
return data;
|
|
34
34
|
};
|
|
35
|
+
const fetchPaymentLink = async (params) => {
|
|
36
|
+
const { data } = await api.get("/subscriptions/payment-link", { params });
|
|
37
|
+
return data;
|
|
38
|
+
};
|
|
35
39
|
const useStatus = (saving) => {
|
|
36
40
|
const [status, setStatus] = useState("idle");
|
|
37
41
|
useEffect(() => {
|
|
@@ -199,6 +203,15 @@ function InternalPostEdit({ post, onSave, onUpdate, onCancel, ...rest }) {
|
|
|
199
203
|
function PostEdit(props) {
|
|
200
204
|
return /* @__PURE__ */ jsx(DirtyPromptContainer.Provider, { children: /* @__PURE__ */ jsx(InternalPostEdit, { ...props }) });
|
|
201
205
|
}
|
|
206
|
+
function PostPaywall({ post, children, ...rest }) {
|
|
207
|
+
if (post.accessType === "public") {
|
|
208
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
209
|
+
}
|
|
210
|
+
if (post.accessType === "paid") {
|
|
211
|
+
return /* @__PURE__ */ jsx(SubscriptionPaywall, { type: post.type, fetchPaymentLink, ...rest, children });
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
202
215
|
function InternalPost({ postId, sx, readonly, ...rest }) {
|
|
203
216
|
var _a2, _b2;
|
|
204
217
|
const { locale } = useLocaleContext();
|
|
@@ -247,7 +260,7 @@ function InternalPost({ postId, sx, readonly, ...rest }) {
|
|
|
247
260
|
children: /* @__PURE__ */ jsx(Edit, {})
|
|
248
261
|
}
|
|
249
262
|
),
|
|
250
|
-
editable ? /* @__PURE__ */ jsx(PostEdit, { post, onSave: handleSave, onUpdate: handleUpdate, onCancel: () => setEditable(false) }) : /* @__PURE__ */ jsx(EditorPreview, { content: post.content || "" })
|
|
263
|
+
editable ? /* @__PURE__ */ jsx(PostEdit, { post, onSave: handleSave, onUpdate: handleUpdate, onCancel: () => setEditable(false) }) : /* @__PURE__ */ jsx(PostPaywall, { post, children: /* @__PURE__ */ jsx(EditorPreview, { content: post.content || "" }) })
|
|
251
264
|
] }) }) }) });
|
|
252
265
|
}
|
|
253
266
|
function Post(props) {
|
package/dist/index.umd.js
CHANGED
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
const { data } = await api.put(`/posts/${id}/content`, payload);
|
|
27
27
|
return data;
|
|
28
28
|
};
|
|
29
|
+
const fetchPaymentLink = async (params) => {
|
|
30
|
+
const { data } = await api.get("/subscriptions/payment-link", { params });
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
29
33
|
const useStatus = (saving) => {
|
|
30
34
|
const [status, setStatus] = react.useState("idle");
|
|
31
35
|
react.useEffect(() => {
|
|
@@ -193,6 +197,15 @@
|
|
|
193
197
|
function PostEdit(props) {
|
|
194
198
|
return /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.DirtyPromptContainer.Provider, { children: /* @__PURE__ */ jsxRuntime.jsx(InternalPostEdit, { ...props }) });
|
|
195
199
|
}
|
|
200
|
+
function PostPaywall({ post, children, ...rest }) {
|
|
201
|
+
if (post.accessType === "public") {
|
|
202
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
203
|
+
}
|
|
204
|
+
if (post.accessType === "paid") {
|
|
205
|
+
return /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.SubscriptionPaywall, { type: post.type, fetchPaymentLink, ...rest, children });
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
196
209
|
function InternalPost({ postId, sx, readonly, ...rest }) {
|
|
197
210
|
var _a2, _b2;
|
|
198
211
|
const { locale } = context.useLocaleContext();
|
|
@@ -241,7 +254,7 @@
|
|
|
241
254
|
children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.Edit, {})
|
|
242
255
|
}
|
|
243
256
|
),
|
|
244
|
-
editable ? /* @__PURE__ */ jsxRuntime.jsx(PostEdit, { post, onSave: handleSave, onUpdate: handleUpdate, onCancel: () => setEditable(false) }) : /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.EditorPreview, { content: post.content || "" })
|
|
257
|
+
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 || "" }) })
|
|
245
258
|
] }) }) }) });
|
|
246
259
|
}
|
|
247
260
|
function Post(props) {
|
package/dist/types.d.ts
CHANGED
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.212",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@mui/icons-material": "^5.16.7",
|
|
23
23
|
"ahooks": "^3.8.1",
|
|
24
24
|
"ufo": "1.3.1",
|
|
25
|
-
"@blocklet/discuss-kit-ux": "^2.1.
|
|
25
|
+
"@blocklet/discuss-kit-ux": "^2.1.212"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@arcblock/did-connect": "^2.10.36",
|