@blocklet/discuss-kit-post 1.6.254
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/LICENSE +13 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.es.js +39 -0
- package/dist/index.umd.js +37 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2018-2020 ArcBlock
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/dist/index.d.ts
ADDED
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var _a, _b;
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Box } from "@mui/material";
|
|
4
|
+
import { useRequest } from "ahooks";
|
|
5
|
+
import { withQuery, joinURL } from "ufo";
|
|
6
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
7
|
+
import { EditorPreview, InternalThemeProvider } from "@blocklet/discuss-kit-ux";
|
|
8
|
+
const discussKitBlocklet = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find((x) => x.name === "did-comments");
|
|
9
|
+
const discussKitMountPoint = discussKitBlocklet == null ? void 0 : discussKitBlocklet.mountPoint;
|
|
10
|
+
const fetchPost = async (postId, locale) => {
|
|
11
|
+
const url = withQuery(joinURL(discussKitMountPoint, "/api/posts", postId), { locale });
|
|
12
|
+
try {
|
|
13
|
+
const result = await fetch(url).then((res) => res.json());
|
|
14
|
+
return result;
|
|
15
|
+
} catch (e) {
|
|
16
|
+
console.error(e);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function InternalPost({ postId, ...rest }) {
|
|
21
|
+
const { locale } = useLocaleContext();
|
|
22
|
+
const { data: post, loading } = useRequest(() => fetchPost(postId, locale), { refreshDeps: [postId, locale] });
|
|
23
|
+
if (loading) {
|
|
24
|
+
return EditorPreview.fallback;
|
|
25
|
+
}
|
|
26
|
+
if (!post) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return /* @__PURE__ */ jsx(InternalThemeProvider, { children: /* @__PURE__ */ jsx(Box, { ...rest, children: /* @__PURE__ */ jsx(EditorPreview, { content: post.content || "" }) }) });
|
|
30
|
+
}
|
|
31
|
+
function Post(props) {
|
|
32
|
+
if (!discussKitMountPoint) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return /* @__PURE__ */ jsx(InternalPost, { ...props });
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
Post
|
|
39
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("@mui/material"), require("ahooks"), require("ufo"), require("@arcblock/ux/lib/Locale/context"), require("@blocklet/discuss-kit-ux")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "@mui/material", "ahooks", "ufo", "@arcblock/ux/lib/Locale/context", "@blocklet/discuss-kit-ux"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.DiscussKitPost = {}, global.jsxRuntime, global.material, global.ahooks, global.ufo, global.context, global.discussKitUx));
|
|
3
|
+
})(this, function(exports2, jsxRuntime, material, ahooks, ufo, context, discussKitUx) {
|
|
4
|
+
"use strict";
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const discussKitBlocklet = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find((x) => x.name === "did-comments");
|
|
7
|
+
const discussKitMountPoint = discussKitBlocklet == null ? void 0 : discussKitBlocklet.mountPoint;
|
|
8
|
+
const fetchPost = async (postId, locale) => {
|
|
9
|
+
const url = ufo.withQuery(ufo.joinURL(discussKitMountPoint, "/api/posts", postId), { locale });
|
|
10
|
+
try {
|
|
11
|
+
const result = await fetch(url).then((res) => res.json());
|
|
12
|
+
return result;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
console.error(e);
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
function InternalPost({ postId, ...rest }) {
|
|
19
|
+
const { locale } = context.useLocaleContext();
|
|
20
|
+
const { data: post, loading } = ahooks.useRequest(() => fetchPost(postId, locale), { refreshDeps: [postId, locale] });
|
|
21
|
+
if (loading) {
|
|
22
|
+
return discussKitUx.EditorPreview.fallback;
|
|
23
|
+
}
|
|
24
|
+
if (!post) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.InternalThemeProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(material.Box, { ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(discussKitUx.EditorPreview, { content: post.content || "" }) }) });
|
|
28
|
+
}
|
|
29
|
+
function Post(props) {
|
|
30
|
+
if (!discussKitMountPoint) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx(InternalPost, { ...props });
|
|
34
|
+
}
|
|
35
|
+
exports2.Post = Post;
|
|
36
|
+
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
37
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blocklet/discuss-kit-post",
|
|
3
|
+
"version": "1.6.254",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist"
|
|
6
|
+
],
|
|
7
|
+
"main": "./dist/index.umd.js",
|
|
8
|
+
"module": "./dist/index.es.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.es.js",
|
|
13
|
+
"require": "./dist/index.umd.js"
|
|
14
|
+
},
|
|
15
|
+
"./src/*": "./src/*"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "npm run storybook",
|
|
19
|
+
"build": "tsc && vite build",
|
|
20
|
+
"build:watch": "vite build --watch",
|
|
21
|
+
"preview": "vite preview",
|
|
22
|
+
"storybook": "start-storybook -p 6006",
|
|
23
|
+
"build-storybook": "build-storybook",
|
|
24
|
+
"lint": "eslint src --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
25
|
+
"lint:fix": "eslint src --ext .mjs,.js,.jsx,.ts,.tsx --fix"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@blocklet/discuss-kit-ux": "1.6.254",
|
|
32
|
+
"ahooks": "^3.7.8",
|
|
33
|
+
"ufo": "1.3.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@arcblock/ux": "^2.9.80",
|
|
37
|
+
"@mui/material": "^5.10.13",
|
|
38
|
+
"react": ">=18.0.0",
|
|
39
|
+
"react-dom": ">=18.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@arcblock/eslint-config-ts": "^0.3.0",
|
|
43
|
+
"@babel/core": "^7.20.2",
|
|
44
|
+
"@iconify-json/iconoir": "^1.1.14",
|
|
45
|
+
"@iconify-json/material-symbols": "^1.1.26",
|
|
46
|
+
"@iconify-json/mdi": "^1.1.36",
|
|
47
|
+
"@storybook/addon-actions": "^6.5.13",
|
|
48
|
+
"@storybook/addon-essentials": "^6.5.13",
|
|
49
|
+
"@storybook/addon-interactions": "^6.5.13",
|
|
50
|
+
"@storybook/addon-links": "^6.5.13",
|
|
51
|
+
"@storybook/builder-vite": "^8.0.6",
|
|
52
|
+
"@storybook/react": "^6.5.13",
|
|
53
|
+
"@storybook/testing-library": "^0.0.13",
|
|
54
|
+
"@svgr/core": "^6.5.1",
|
|
55
|
+
"@types/react": "^18.0.24",
|
|
56
|
+
"@types/react-color": "^3.0.6",
|
|
57
|
+
"@types/react-dom": "^18.0.8",
|
|
58
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
59
|
+
"babel-loader": "^8.3.0",
|
|
60
|
+
"react": "^18.2.0",
|
|
61
|
+
"react-dom": "^18.2.0",
|
|
62
|
+
"rollup-plugin-node-externals": "^7.1.2",
|
|
63
|
+
"typescript": "^4.6.4",
|
|
64
|
+
"unplugin-icons": "^0.14.14",
|
|
65
|
+
"vite": "^5.2.8",
|
|
66
|
+
"vite-plugin-dts": "^3.8.1",
|
|
67
|
+
"vite-plugin-libcss": "^1.1.1"
|
|
68
|
+
},
|
|
69
|
+
"resolutions": {
|
|
70
|
+
"react": "^18.2.0"
|
|
71
|
+
},
|
|
72
|
+
"gitHead": "d73717ae2ab3692e8a1ed57f1343931234554964"
|
|
73
|
+
}
|