@blocklet/discuss-kit-ux 1.6.51 → 1.6.53

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-fda8b4e9.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
@@ -4283,6 +4284,7 @@ const useDefaultApiErrorHandler = (options) => {
4283
4284
  };
4284
4285
  const apiPrefix = inferDiscussKitApiPrefix();
4285
4286
  const baseURL = joinUrl(window.location.origin, apiPrefix);
4287
+ let cachedTemplateList = null;
4286
4288
  function DefaultEditorConfigProvider({
4287
4289
  request,
4288
4290
  children
@@ -4378,6 +4380,31 @@ function DefaultEditorConfigProvider({
4378
4380
  }
4379
4381
  };
4380
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
+ };
4381
4408
  const value = {
4382
4409
  uploader: {
4383
4410
  upload: async (blobFile) => {
@@ -4393,7 +4420,8 @@ function DefaultEditorConfigProvider({
4393
4420
  userService,
4394
4421
  blockletEmbedEndpoint: joinUrl(window.location.origin, apiPrefix, "/api/embed/check"),
4395
4422
  openGraphEndpoint: joinUrl(window.location.origin, apiPrefix, "/api/embed/og"),
4396
- AI
4423
+ AI,
4424
+ templatePlugin
4397
4425
  };
4398
4426
  return value;
4399
4427
  }, [isAdmin, request, (_b2 = session == null ? void 0 : session.user) == null ? void 0 : _b2.did, downMd]);
@@ -4430,7 +4458,7 @@ function Pagination({ page, size = 20, total, onChange, routerMode = true, ...re
4430
4458
  }
4431
4459
  );
4432
4460
  }
4433
- const Editor = lazy(() => import("./editor-13a9cb7c.mjs"));
4461
+ const Editor = lazy(() => import("./editor-538dd7f6.mjs"));
4434
4462
  function LazyEditor(props) {
4435
4463
  const fallback = /* @__PURE__ */ jsxs(Fragment, { children: [
4436
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-fda8b4e9.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
@@ -4223,6 +4224,7 @@ var __publicField = (obj, key, value) => {
4223
4224
  };
4224
4225
  const apiPrefix = inferDiscussKitApiPrefix();
4225
4226
  const baseURL = joinUrl(window.location.origin, apiPrefix);
4227
+ let cachedTemplateList = null;
4226
4228
  function DefaultEditorConfigProvider({
4227
4229
  request,
4228
4230
  children
@@ -4318,6 +4320,31 @@ var __publicField = (obj, key, value) => {
4318
4320
  }
4319
4321
  };
4320
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
+ };
4321
4348
  const value = {
4322
4349
  uploader: {
4323
4350
  upload: async (blobFile) => {
@@ -4333,7 +4360,8 @@ var __publicField = (obj, key, value) => {
4333
4360
  userService,
4334
4361
  blockletEmbedEndpoint: joinUrl(window.location.origin, apiPrefix, "/api/embed/check"),
4335
4362
  openGraphEndpoint: joinUrl(window.location.origin, apiPrefix, "/api/embed/og"),
4336
- AI
4363
+ AI,
4364
+ templatePlugin
4337
4365
  };
4338
4366
  return value;
4339
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.51",
3
+ "version": "1.6.53",
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.51",
33
- "@blocklet/labels": "1.6.51",
34
- "@blocklet/uploader": "^0.0.55",
32
+ "@blocklet/editor": "1.6.53",
33
+ "@blocklet/labels": "1.6.53",
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": "fe0f8b560a37d2a874ca04d02f7ff02557758aa2"
96
+ "gitHead": "712af123bd9ef343af6e541ac212a8fe00269eda"
97
97
  }