@blocklet/discuss-kit-ux 2.0.83 → 2.0.85

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.
@@ -17,4 +17,5 @@ export declare const getDraftSessionKeyPrefix: () => string;
17
17
  export declare const getExcerptFromLexicalContent: (content: any, size?: number) => string;
18
18
  export declare const mergeSx: (initial: SystemStyleObject<Theme>, sx?: SxProps<Theme>) => any[];
19
19
  export declare const discussKitMountPoint: string | undefined;
20
- export declare const openProfileInNewTab: (did: string) => void;
20
+ export declare const isInDiscussKitApp: boolean | "" | undefined;
21
+ export declare const openProfile: (did: string, newTab?: boolean) => void;
@@ -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-DL2IN0gQ.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-D7n269m9.mjs";
8
8
  const BlockletEditor = lazy(() => import("@blocklet/editor"));
9
9
  const Root = styled(Box)`
10
10
  .be-editable,
@@ -16,8 +16,7 @@ import { useEditorConfig, EditorConfigProvider } from "@blocklet/editor/lib/conf
16
16
  import { lazyWithPreload } from "react-lazy-with-preload";
17
17
  import { $getRoot, $createParagraphNode, $createTextNode, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection } from "lexical";
18
18
  import { $isRootTextContentEmpty } from "@lexical/text";
19
- import { resolvePath, Link, useNavigate, useMatch, useLocation, useParams, Outlet, useSearchParams, useBlocker } from "react-router-dom";
20
- import { joinURL } from "ufo";
19
+ import { withTrailingSlash, withQuery, joinURL } from "ufo";
21
20
  import joinUrl from "url-join";
22
21
  import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
23
22
  import { ImageNode } from "@blocklet/editor/lib/main/nodes/ImageNode";
@@ -36,6 +35,7 @@ import { grey, green, amber } from "@mui/material/colors";
36
35
  import useMediaQuery$1 from "@mui/material/useMediaQuery";
37
36
  import DID from "@arcblock/ux/lib/DID";
38
37
  import Tooltip, { tooltipClasses } from "@mui/material/Tooltip";
38
+ import { Link, useNavigate, useMatch, useLocation, useParams, Outlet, useSearchParams, useBlocker } from "react-router-dom";
39
39
  import { useBrowser } from "@arcblock/react-hooks";
40
40
  import UxRelativeTime from "@arcblock/ux/lib/RelativeTime";
41
41
  import Chip from "@mui/material/Chip";
@@ -343,10 +343,10 @@ const mergeSx = (initial, sx) => {
343
343
  return mergedSx;
344
344
  };
345
345
  const discussKitMountPoint = (_a = getBlockletMountPointInfo("did-comments")) == null ? void 0 : _a.mountPoint;
346
- const openProfileInNewTab = (did) => {
346
+ const isInDiscussKitApp = discussKitMountPoint && withTrailingSlash(window.blocklet.prefix) === withTrailingSlash(discussKitMountPoint);
347
+ const openProfile = (did, newTab) => {
347
348
  if (did) {
348
- const { pathname } = resolvePath(`/profile/${did}`);
349
- window.open(joinURL(discussKitMountPoint || "/", pathname), "_blank");
349
+ window.open(withQuery(joinURL(discussKitMountPoint || "/", "profile"), { did }), newTab ? "_blank" : "_self");
350
350
  }
351
351
  };
352
352
  const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -361,9 +361,10 @@ const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
361
361
  getPreference,
362
362
  getResizedAvatar,
363
363
  inferDiscussKitApiPrefix,
364
+ isInDiscussKitApp,
364
365
  mergeSx,
365
366
  minDelay,
366
- openProfileInNewTab,
367
+ openProfile,
367
368
  protectLogin,
368
369
  repairBase64Avatar,
369
370
  sleep,
@@ -1323,10 +1324,14 @@ function AuthorInfo({
1323
1324
  (_b2 = e == null ? void 0 : e.preventDefault) == null ? void 0 : _b2.call(e);
1324
1325
  setOpen(false);
1325
1326
  if (chatInWallet) {
1326
- openProfileInNewTab(user == null ? void 0 : user.did);
1327
+ openProfile(user == null ? void 0 : user.did, true);
1327
1328
  } else {
1328
1329
  setTimeout(() => {
1329
- navigate(`/profile/${user == null ? void 0 : user.did}`);
1330
+ if (isInDiscussKitApp) {
1331
+ navigate(`/profile?did=${user == null ? void 0 : user.did}`);
1332
+ } else {
1333
+ openProfile(user == null ? void 0 : user.did);
1334
+ }
1330
1335
  }, 100);
1331
1336
  }
1332
1337
  };
@@ -4755,7 +4760,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, ...rest }) {
4755
4760
  }
4756
4761
  const tablerSend = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", "data-iconify": "tabler", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 14L21 3m0 0l-6.5 18a.55.55 0 0 1-1 0L10 14l-7-3.5a.55.55 0 0 1 0-1z" }) });
4757
4762
  const tablerLetterCase = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", "data-iconify": "tabler", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M14 15.5a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0-7 0M3 19V8.5a3.5 3.5 0 0 1 7 0V19m-7-6h7m11-1v7" }) });
4758
- const Editor = lazy(() => import("./editor-C--h9pxj.mjs"));
4763
+ const Editor = lazy(() => import("./editor-C5zNpwwt.mjs"));
4759
4764
  function LazyEditor(props) {
4760
4765
  const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
4761
4766
  /* @__PURE__ */ jsx(Skeleton, {}),
@@ -5723,7 +5728,7 @@ function ChatListInWallet({ sx, ...rest }) {
5723
5728
  variant: "circle",
5724
5729
  onClick: () => {
5725
5730
  var _a3;
5726
- return openProfileInNewTab((_a3 = session == null ? void 0 : session.user) == null ? void 0 : _a3.did);
5731
+ return openProfile((_a3 = session == null ? void 0 : session.user) == null ? void 0 : _a3.did, true);
5727
5732
  }
5728
5733
  }
5729
5734
  )
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "@blocklet/labels";
2
- import { T, n, W, A, m, ad, B, F, K, J, L, ap, Y, X, $, Z, _, a1, w, C, x, y, E, a5, a6, ah, a8, O, Q, ac, D, ag, af, H, G, b, k, ae, M, P, ao, v, q, R, S, a9, aq, o, a2, a4, ai, al, ak, am, ar, N, as, l, f, p, r, j, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-DL2IN0gQ.mjs";
2
+ import { T, n, W, A, m, ad, B, F, K, J, L, ap, Y, X, $, Z, _, a1, w, C, x, y, E, a5, a6, ah, a8, O, Q, ac, D, ag, af, H, G, b, k, ae, M, P, ao, v, q, R, S, a9, aq, o, a2, a4, ai, al, ak, am, ar, N, as, l, f, p, r, j, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-D7n269m9.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
package/dist/index.umd.js CHANGED
@@ -269,10 +269,10 @@ var __publicField = (obj, key, value) => {
269
269
  return mergedSx;
270
270
  };
271
271
  const discussKitMountPoint = (_a = getBlockletMountPointInfo("did-comments")) == null ? void 0 : _a.mountPoint;
272
- const openProfileInNewTab = (did) => {
272
+ const isInDiscussKitApp = discussKitMountPoint && ufo.withTrailingSlash(window.blocklet.prefix) === ufo.withTrailingSlash(discussKitMountPoint);
273
+ const openProfile = (did, newTab) => {
273
274
  if (did) {
274
- const { pathname } = reactRouterDom.resolvePath(`/profile/${did}`);
275
- window.open(ufo.joinURL(discussKitMountPoint || "/", pathname), "_blank");
275
+ window.open(ufo.withQuery(ufo.joinURL(discussKitMountPoint || "/", "profile"), { did }), newTab ? "_blank" : "_self");
276
276
  }
277
277
  };
278
278
  const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -287,9 +287,10 @@ var __publicField = (obj, key, value) => {
287
287
  getPreference,
288
288
  getResizedAvatar,
289
289
  inferDiscussKitApiPrefix,
290
+ isInDiscussKitApp,
290
291
  mergeSx,
291
292
  minDelay,
292
- openProfileInNewTab,
293
+ openProfile,
293
294
  protectLogin,
294
295
  repairBase64Avatar,
295
296
  sleep,
@@ -1249,10 +1250,14 @@ var __publicField = (obj, key, value) => {
1249
1250
  (_b2 = e == null ? void 0 : e.preventDefault) == null ? void 0 : _b2.call(e);
1250
1251
  setOpen(false);
1251
1252
  if (chatInWallet) {
1252
- openProfileInNewTab(user == null ? void 0 : user.did);
1253
+ openProfile(user == null ? void 0 : user.did, true);
1253
1254
  } else {
1254
1255
  setTimeout(() => {
1255
- navigate(`/profile/${user == null ? void 0 : user.did}`);
1256
+ if (isInDiscussKitApp) {
1257
+ navigate(`/profile?did=${user == null ? void 0 : user.did}`);
1258
+ } else {
1259
+ openProfile(user == null ? void 0 : user.did);
1260
+ }
1256
1261
  }, 100);
1257
1262
  }
1258
1263
  };
@@ -5649,7 +5654,7 @@ var __publicField = (obj, key, value) => {
5649
5654
  variant: "circle",
5650
5655
  onClick: () => {
5651
5656
  var _a3;
5652
- return openProfileInNewTab((_a3 = session == null ? void 0 : session.user) == null ? void 0 : _a3.did);
5657
+ return openProfile((_a3 = session == null ? void 0 : session.user) == null ? void 0 : _a3.did, true);
5653
5658
  }
5654
5659
  }
5655
5660
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "2.0.83",
3
+ "version": "2.0.85",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -31,8 +31,8 @@
31
31
  "@arcblock/bridge": "^2.10.6",
32
32
  "@arcblock/react-hooks": "^2.10.6",
33
33
  "@arcblock/ws": "^1.18.126",
34
- "@blocklet/editor": "2.0.83",
35
- "@blocklet/labels": "2.0.83",
34
+ "@blocklet/editor": "2.0.85",
35
+ "@blocklet/labels": "2.0.85",
36
36
  "@blocklet/uploader": "^0.1.19",
37
37
  "@emotion/css": "^11.10.5",
38
38
  "@emotion/react": "^11.10.5",
@@ -100,5 +100,5 @@
100
100
  "resolutions": {
101
101
  "react": "^18.2.0"
102
102
  },
103
- "gitHead": "ffe6740390580b8e886bb350a92c30c0b86fa62a"
103
+ "gitHead": "a59a345501aeab25f6c71c1aeacfb94fd2e55de5"
104
104
  }