@blocklet/discuss-kit-ux 1.6.50 → 1.6.52

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.
@@ -4,7 +4,7 @@ import { OnContentChangePlugin } from "@blocklet/editor/lib/ext/OnContentChangeP
4
4
  import { CtrlsShortcutPlugin } from "@blocklet/editor/lib/ext/ShortcutPlugin";
5
5
  import { SafeAreaPlugin } from "@blocklet/editor/lib/ext/SafeAreaPlugin";
6
6
  import { lazy } from "react";
7
- import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-8ce9d402.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-30ba003a.mjs";
8
8
  import "@blocklet/labels";
9
9
  import "@mui/material/styles";
10
10
  import "@mui/material/Box";
@@ -2476,7 +2476,8 @@ function UploaderProvider({ children }) {
2476
2476
  "image/webp",
2477
2477
  "image/svg+xml",
2478
2478
  "video/mp4",
2479
- "video/webm"
2479
+ "video/webm",
2480
+ "application/pdf"
2480
2481
  ],
2481
2482
  maxNumberOfFiles: void 0
2482
2483
  // default is unlimited
@@ -2744,16 +2745,7 @@ function BlogItem({
2744
2745
  /* @__PURE__ */ jsxs(Box, { sx: { flex: 1, pr: { xs: 2, md: 4 } }, children: [
2745
2746
  typeof prepend === "function" ? prepend(item) : prepend,
2746
2747
  hideAuthor === "1" || /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(AuthorInfo, { user: item.author, createdAt: downMd ? void 0 : item.publishTime, size: "sm", responsive: true }) }),
2747
- /* @__PURE__ */ jsx(
2748
- Typography,
2749
- {
2750
- variant: "h6",
2751
- component: "h3",
2752
- sx: { ...lineClamp2, fontSize: { xs: 14, md: 18, lg: 20 }, my: 0.5 },
2753
- className: "item-title",
2754
- children: item.title
2755
- }
2756
- ),
2748
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", component: "h3", sx: { ...lineClamp2, my: 0.5 }, className: "item-title", children: item.title }),
2757
2749
  item.excerpt && /* @__PURE__ */ jsxs(
2758
2750
  Typography,
2759
2751
  {
@@ -2939,7 +2931,7 @@ const BlogCard = forwardRef(
2939
2931
  children: [
2940
2932
  /* @__PURE__ */ jsx(Box, { sx: { flex: "0 0 auto" }, children: /* @__PURE__ */ jsx(CoverImage, { url: post.cover, sx: { borderRadius: 0 }, loading: "lazy", width: 640 }) }),
2941
2933
  /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", flex: 1, mt: 1, p: 2, pt: 0 }, children: [
2942
- /* @__PURE__ */ jsx(Typography, { variant: "h6", component: "h3", sx: { ...lineClamp2, my: 0.5, fontSize: 18, lineHeight: 1.4 }, children: post.title }),
2934
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", sx: { ...lineClamp2, my: 0.5 }, children: post.title }),
2943
2935
  post.excerpt && /* @__PURE__ */ jsxs(Typography, { variant: "body1", sx: { ...lineClamp2, fontSize: { xs: 13, md: 14 }, color: "grey.600" }, children: [
2944
2936
  post.excerpt,
2945
2937
  "..."
@@ -4292,6 +4284,7 @@ const useDefaultApiErrorHandler = (options) => {
4292
4284
  };
4293
4285
  const apiPrefix = inferDiscussKitApiPrefix();
4294
4286
  const baseURL = joinUrl(window.location.origin, apiPrefix);
4287
+ let cachedTemplateList = null;
4295
4288
  function DefaultEditorConfigProvider({
4296
4289
  request,
4297
4290
  children
@@ -4387,6 +4380,31 @@ function DefaultEditorConfigProvider({
4387
4380
  }
4388
4381
  };
4389
4382
  }
4383
+ const templatePlugin = {
4384
+ fetchTemplateList: async ({ reload = false } = {}) => {
4385
+ var _a3;
4386
+ if (!reload && (cachedTemplateList == null ? void 0 : cachedTemplateList.length) > 0) {
4387
+ return cachedTemplateList;
4388
+ }
4389
+ try {
4390
+ const { data = [] } = await request.get(joinUrl("/api/resources/posts"), { baseURL });
4391
+ cachedTemplateList = data;
4392
+ return data;
4393
+ } catch (e) {
4394
+ (_a3 = e.markAsHandled) == null ? void 0 : _a3.call(e);
4395
+ console.error(e);
4396
+ cachedTemplateList = null;
4397
+ return [];
4398
+ }
4399
+ },
4400
+ importTemplate: async (item) => {
4401
+ if (!(item == null ? void 0 : item.id) || !(item == null ? void 0 : item.content)) {
4402
+ throw new Error("item is required");
4403
+ }
4404
+ const { data } = await request.post(joinUrl("/api/resources/import"), item, { baseURL });
4405
+ return data;
4406
+ }
4407
+ };
4390
4408
  const value = {
4391
4409
  uploader: {
4392
4410
  upload: async (blobFile) => {
@@ -4402,7 +4420,8 @@ function DefaultEditorConfigProvider({
4402
4420
  userService,
4403
4421
  blockletEmbedEndpoint: joinUrl(window.location.origin, apiPrefix, "/api/embed/check"),
4404
4422
  openGraphEndpoint: joinUrl(window.location.origin, apiPrefix, "/api/embed/og"),
4405
- AI
4423
+ AI,
4424
+ templatePlugin
4406
4425
  };
4407
4426
  return value;
4408
4427
  }, [isAdmin, request, (_b2 = session == null ? void 0 : session.user) == null ? void 0 : _b2.did, downMd]);
@@ -4439,7 +4458,7 @@ function Pagination({ page, size = 20, total, onChange, routerMode = true, ...re
4439
4458
  }
4440
4459
  );
4441
4460
  }
4442
- const Editor = lazy(() => import("./editor-9918fcea.mjs"));
4461
+ const Editor = lazy(() => import("./editor-538dd7f6.mjs"));
4443
4462
  function LazyEditor(props) {
4444
4463
  const fallback = /* @__PURE__ */ jsxs(Fragment, { children: [
4445
4464
  /* @__PURE__ */ jsx(Skeleton, {}),
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "@blocklet/labels";
2
- import { K, j, N, A, h, a6, B, z, y, E, Q, O, T, W, o, C, q, v, x, _, $, aa, a1, H, J, D, a9, a8, G, c, b, a7, M, P, ah, n, m, a5, R, S, a2, k, X, Z, ab, ae, ad, af, ai, F, aj, l, p, r, t, d, a3, L, e, U, w, a0, a4, u, ag, ak, Y, ac, f } from "./index-8ce9d402.mjs";
2
+ import { K, j, N, A, h, a6, B, z, y, E, Q, O, T, W, o, C, q, v, x, _, $, aa, a1, H, J, D, a9, a8, G, c, b, a7, M, P, ah, n, m, a5, R, S, a2, k, X, Z, ab, ae, ad, af, ai, F, aj, l, p, r, t, d, a3, L, e, U, w, a0, a4, u, ag, ak, Y, ac, f } from "./index-30ba003a.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
package/dist/index.umd.js CHANGED
@@ -2416,7 +2416,8 @@ var __publicField = (obj, key, value) => {
2416
2416
  "image/webp",
2417
2417
  "image/svg+xml",
2418
2418
  "video/mp4",
2419
- "video/webm"
2419
+ "video/webm",
2420
+ "application/pdf"
2420
2421
  ],
2421
2422
  maxNumberOfFiles: void 0
2422
2423
  // default is unlimited
@@ -2684,16 +2685,7 @@ var __publicField = (obj, key, value) => {
2684
2685
  /* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { flex: 1, pr: { xs: 2, md: 4 } }, children: [
2685
2686
  typeof prepend === "function" ? prepend(item) : prepend,
2686
2687
  hideAuthor === "1" || /* @__PURE__ */ jsxRuntime.jsx(Box, { children: /* @__PURE__ */ jsxRuntime.jsx(AuthorInfo, { user: item.author, createdAt: downMd ? void 0 : item.publishTime, size: "sm", responsive: true }) }),
2687
- /* @__PURE__ */ jsxRuntime.jsx(
2688
- Typography,
2689
- {
2690
- variant: "h6",
2691
- component: "h3",
2692
- sx: { ...lineClamp2, fontSize: { xs: 14, md: 18, lg: 20 }, my: 0.5 },
2693
- className: "item-title",
2694
- children: item.title
2695
- }
2696
- ),
2688
+ /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h4", component: "h3", sx: { ...lineClamp2, my: 0.5 }, className: "item-title", children: item.title }),
2697
2689
  item.excerpt && /* @__PURE__ */ jsxRuntime.jsxs(
2698
2690
  Typography,
2699
2691
  {
@@ -2879,7 +2871,7 @@ var __publicField = (obj, key, value) => {
2879
2871
  children: [
2880
2872
  /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { flex: "0 0 auto" }, children: /* @__PURE__ */ jsxRuntime.jsx(CoverImage, { url: post.cover, sx: { borderRadius: 0 }, loading: "lazy", width: 640 }) }),
2881
2873
  /* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { display: "flex", flexDirection: "column", flex: 1, mt: 1, p: 2, pt: 0 }, children: [
2882
- /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h6", component: "h3", sx: { ...lineClamp2, my: 0.5, fontSize: 18, lineHeight: 1.4 }, children: post.title }),
2874
+ /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h4", sx: { ...lineClamp2, my: 0.5 }, children: post.title }),
2883
2875
  post.excerpt && /* @__PURE__ */ jsxRuntime.jsxs(Typography, { variant: "body1", sx: { ...lineClamp2, fontSize: { xs: 13, md: 14 }, color: "grey.600" }, children: [
2884
2876
  post.excerpt,
2885
2877
  "..."
@@ -4232,6 +4224,7 @@ var __publicField = (obj, key, value) => {
4232
4224
  };
4233
4225
  const apiPrefix = inferDiscussKitApiPrefix();
4234
4226
  const baseURL = joinUrl(window.location.origin, apiPrefix);
4227
+ let cachedTemplateList = null;
4235
4228
  function DefaultEditorConfigProvider({
4236
4229
  request,
4237
4230
  children
@@ -4327,6 +4320,31 @@ var __publicField = (obj, key, value) => {
4327
4320
  }
4328
4321
  };
4329
4322
  }
4323
+ const templatePlugin = {
4324
+ fetchTemplateList: async ({ reload = false } = {}) => {
4325
+ var _a3;
4326
+ if (!reload && (cachedTemplateList == null ? void 0 : cachedTemplateList.length) > 0) {
4327
+ return cachedTemplateList;
4328
+ }
4329
+ try {
4330
+ const { data = [] } = await request.get(joinUrl("/api/resources/posts"), { baseURL });
4331
+ cachedTemplateList = data;
4332
+ return data;
4333
+ } catch (e) {
4334
+ (_a3 = e.markAsHandled) == null ? void 0 : _a3.call(e);
4335
+ console.error(e);
4336
+ cachedTemplateList = null;
4337
+ return [];
4338
+ }
4339
+ },
4340
+ importTemplate: async (item) => {
4341
+ if (!(item == null ? void 0 : item.id) || !(item == null ? void 0 : item.content)) {
4342
+ throw new Error("item is required");
4343
+ }
4344
+ const { data } = await request.post(joinUrl("/api/resources/import"), item, { baseURL });
4345
+ return data;
4346
+ }
4347
+ };
4330
4348
  const value = {
4331
4349
  uploader: {
4332
4350
  upload: async (blobFile) => {
@@ -4342,7 +4360,8 @@ var __publicField = (obj, key, value) => {
4342
4360
  userService,
4343
4361
  blockletEmbedEndpoint: joinUrl(window.location.origin, apiPrefix, "/api/embed/check"),
4344
4362
  openGraphEndpoint: joinUrl(window.location.origin, apiPrefix, "/api/embed/og"),
4345
- AI
4363
+ AI,
4364
+ templatePlugin
4346
4365
  };
4347
4366
  return value;
4348
4367
  }, [isAdmin, request, (_b2 = session == null ? void 0 : session.user) == null ? void 0 : _b2.did, downMd]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "1.6.50",
3
+ "version": "1.6.52",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -29,9 +29,9 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@arcblock/ws": "^1.18.107",
32
- "@blocklet/editor": "1.6.50",
33
- "@blocklet/labels": "1.6.50",
34
- "@blocklet/uploader": "^0.0.55",
32
+ "@blocklet/editor": "1.6.52",
33
+ "@blocklet/labels": "1.6.52",
34
+ "@blocklet/uploader": "^0.0.60",
35
35
  "@emotion/css": "^11.10.5",
36
36
  "@emotion/react": "^11.10.5",
37
37
  "@emotion/styled": "^11.10.5",
@@ -93,5 +93,5 @@
93
93
  "resolutions": {
94
94
  "react": "^18.2.0"
95
95
  },
96
- "gitHead": "8f30dc9366bb2abe317eb3390373b4ff596e2871"
96
+ "gitHead": "7987de908e09c131b364cadec86603b62740bd6f"
97
97
  }