@blocklet/discuss-kit-ux 2.1.161 → 2.1.163

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.
@@ -0,0 +1,16 @@
1
+ export declare const isInArcSphere: boolean;
2
+ export declare const isInArcSphereDialog: boolean;
3
+ interface OpenDialogOptions {
4
+ url: string;
5
+ type?: 'full' | 'half';
6
+ onClose?: (reason: string) => void;
7
+ }
8
+ export declare const openArcSphereDialog: ({ url, type, onClose }: OpenDialogOptions) => void;
9
+ export declare const closeArcSphereDialog: (reason?: string) => void;
10
+ export declare const useArcSphereDialog: () => {
11
+ open: ({ authRequired, ...options }: OpenDialogOptions & {
12
+ authRequired?: boolean | undefined;
13
+ }) => void;
14
+ close: (reason?: string) => void;
15
+ };
16
+ export {};
@@ -6,5 +6,5 @@ interface BackProps {
6
6
  sx?: SxProps;
7
7
  icon?: React.ReactNode;
8
8
  }
9
- export declare function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }: BackProps & ButtonProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }: BackProps & ButtonProps): import("react/jsx-runtime").JSX.Element | null;
10
10
  export {};
@@ -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 { lazyRetry } from "@arcblock/ux/lib/Util";
7
- import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-D271eHBV.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-CeuyJya0.mjs";
8
8
  const BlockletEditor = lazyRetry(() => import("@blocklet/editor"));
9
9
  const Root = styled(Box)`
10
10
  .be-editable,
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- var _a, _b, _c, _d, _e;
4
+ var _a, _b, _c, _d, _e, _f;
5
5
  import { Labels2, LabelPicker } from "@blocklet/labels";
6
6
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
7
7
  import { useTheme, ThemeProvider, styled as styled$1 } from "@mui/material/styles";
@@ -13,7 +13,7 @@ import { useEditorConfig, EditorConfigProvider } from "@blocklet/editor/lib/conf
13
13
  import { lazyWithPreload } from "react-lazy-with-preload";
14
14
  import { $getRoot, $createParagraphNode, $createTextNode, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection } from "lexical";
15
15
  import { $isRootTextContentEmpty } from "@lexical/text";
16
- import { joinURL, withTrailingSlash, withQuery } from "ufo";
16
+ import { joinURL, withTrailingSlash, withQuery, parseQuery } from "ufo";
17
17
  import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
18
18
  import { ImageNode } from "@blocklet/editor/lib/main/nodes/ImageNode";
19
19
  import { VideoNode } from "@blocklet/editor/lib/ext/VideoPlugin/VideoNode";
@@ -1039,7 +1039,7 @@ function Badge({
1039
1039
  ] }) : null;
1040
1040
  }
1041
1041
  const useSessionContext = () => {
1042
- var _a2, _b2, _c2, _d2, _e2, _f;
1042
+ var _a2, _b2, _c2, _d2, _e2, _f2;
1043
1043
  const ctx = useContext(SessionContext) || {};
1044
1044
  const roles = [...((_c2 = (_b2 = (_a2 = ctx == null ? void 0 : ctx.session) == null ? void 0 : _a2.user) == null ? void 0 : _b2.passports) == null ? void 0 : _c2.map((p) => p.role)) || [], "guest"];
1045
1045
  const permissionSet = useMemo(() => {
@@ -1055,7 +1055,7 @@ const useSessionContext = () => {
1055
1055
  };
1056
1056
  return {
1057
1057
  ...ctx,
1058
- isAuthenticated: !!((_f = ctx.session) == null ? void 0 : _f.user),
1058
+ isAuthenticated: !!((_f2 = ctx.session) == null ? void 0 : _f2.user),
1059
1059
  isAdmin: hasAnyPassport(["admin", "owner"]),
1060
1060
  isMember: hasAnyPassport(["member"]),
1061
1061
  isBlogEditor: hasAnyPassport(["blogEditor"]),
@@ -4781,10 +4781,60 @@ function Participants({ users, sx, ...rest }) {
4781
4781
  }
4782
4782
  ) }) });
4783
4783
  }
4784
+ const isInArcSphere$1 = ((_e = window == null ? void 0 : window.navigator) == null ? void 0 : _e.userAgent.indexOf("ArcSphere")) > -1;
4785
+ const isInArcSphereDialog = !!parseQuery(window.location.search).arcSphereDialog;
4786
+ function normalizeUrl(url) {
4787
+ if (url.startsWith("/")) {
4788
+ return withQuery(joinURL(window.origin, window.blocklet.prefix, url), { arcSphereDialog: 1 });
4789
+ }
4790
+ return url;
4791
+ }
4792
+ const openArcSphereDialog = ({ url, type = "full", onClose }) => {
4793
+ bridge.register("closePopupCallback", (arg) => {
4794
+ onClose == null ? void 0 : onClose(arg);
4795
+ });
4796
+ bridge.call("arc__openPopup", {
4797
+ url: normalizeUrl(url),
4798
+ type
4799
+ });
4800
+ };
4801
+ const closeArcSphereDialog = (reason) => {
4802
+ if (isInArcSphereDialog) {
4803
+ bridge.call("arc__closePopup", {
4804
+ callback: "closePopupCallback",
4805
+ args: [reason || ""]
4806
+ });
4807
+ }
4808
+ };
4809
+ const useArcSphereDialog = () => {
4810
+ const { session } = useSessionContext();
4811
+ const open = useCallback(
4812
+ ({ authRequired = true, ...options }) => {
4813
+ if (authRequired && !session.user) {
4814
+ session.login(() => {
4815
+ openArcSphereDialog(options);
4816
+ });
4817
+ } else {
4818
+ openArcSphereDialog(options);
4819
+ }
4820
+ },
4821
+ [session]
4822
+ );
4823
+ const close = useCallback((reason) => {
4824
+ closeArcSphereDialog(reason);
4825
+ }, []);
4826
+ return {
4827
+ open,
4828
+ close
4829
+ };
4830
+ };
4784
4831
  function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }) {
4785
4832
  const navigate = useNavigate();
4786
4833
  const location = useLocation();
4787
4834
  const mergedSx = [{}, ...Array.isArray(sx) ? sx : [sx]];
4835
+ if (isInArcSphere$1) {
4836
+ return null;
4837
+ }
4788
4838
  const handleClick = () => {
4789
4839
  var _a2;
4790
4840
  if (url) {
@@ -4804,7 +4854,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }) {
4804
4854
  }
4805
4855
  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" }) });
4806
4856
  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" }) });
4807
- const Editor = lazyRetry(() => import("./editor-BLDD04i2.mjs"));
4857
+ const Editor = lazyRetry(() => import("./editor-BFgzPrJQ.mjs"));
4808
4858
  function LazyEditor(props) {
4809
4859
  const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
4810
4860
  /* @__PURE__ */ jsx(Skeleton, {}),
@@ -5863,7 +5913,7 @@ let toast = Object.assign(hotToast, {
5863
5913
  return hotToast.error(message, { ...options, icon: "⚠️" });
5864
5914
  }
5865
5915
  });
5866
- const isInArcSphere = ((_e = window == null ? void 0 : window.navigator) == null ? void 0 : _e.userAgent.indexOf("ArcSphere")) > -1;
5916
+ const isInArcSphere = ((_f = window == null ? void 0 : window.navigator) == null ? void 0 : _f.userAgent.indexOf("ArcSphere")) > -1;
5867
5917
  if (isInArcSphere) {
5868
5918
  toast = Object.assign(
5869
5919
  (message) => {
@@ -11926,14 +11976,14 @@ function create(prefix2) {
11926
11976
  }
11927
11977
  });
11928
11978
  }
11929
- function getWsClient(prefix2 = ((_f) => (_f = window.blocklet) == null ? void 0 : _f.prefix)() || "/") {
11979
+ function getWsClient(prefix2 = ((_g) => (_g = window.blocklet) == null ? void 0 : _g.prefix)() || "/") {
11930
11980
  if (!client) {
11931
11981
  client = create(prefix2);
11932
11982
  }
11933
11983
  return client;
11934
11984
  }
11935
11985
  const useSubscription = (event, cb = () => {
11936
- }, deps = [], prefix2 = ((_g) => (_g = window.blocklet) == null ? void 0 : _g.prefix)() || "/") => {
11986
+ }, deps = [], prefix2 = ((_h) => (_h = window.blocklet) == null ? void 0 : _h.prefix)() || "/") => {
11937
11987
  useEffect(() => {
11938
11988
  if (event) {
11939
11989
  if (!client) {
@@ -12381,6 +12431,11 @@ export {
12381
12431
  getWsClient as as,
12382
12432
  useSubscription as at,
12383
12433
  toast as au,
12434
+ isInArcSphere$1 as av,
12435
+ isInArcSphereDialog as aw,
12436
+ openArcSphereDialog as ax,
12437
+ closeArcSphereDialog as ay,
12438
+ useArcSphereDialog as az,
12384
12439
  Input as b,
12385
12440
  useChanged as c,
12386
12441
  useSessionContext as d,
package/dist/index.d.ts CHANGED
@@ -28,4 +28,5 @@ export * from './components/button-group';
28
28
  export * from './components/segmented-control';
29
29
  export * from './ws';
30
30
  export * from './components/toast';
31
+ export * from './components/arcsphere';
31
32
  export { default as RelativeTime } from './components/shared/relative-time';
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, ar, N, am, as, l, f, p, r, j, au, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-D271eHBV.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, ay, ar, N, am, as, av, aw, l, ax, f, p, r, j, au, t, h, aa, az, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-CeuyJya0.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
@@ -62,11 +62,15 @@ export {
62
62
  ai as UploaderContext,
63
63
  al as UploaderProvider,
64
64
  ak as UploaderTrigger,
65
+ ay as closeArcSphereDialog,
65
66
  ar as create,
66
67
  N as getBlogLink,
67
68
  am as getUploadedImageUrl,
68
69
  as as getWsClient,
70
+ av as isInArcSphere,
71
+ aw as isInArcSphereDialog,
69
72
  l as lexicalUtils,
73
+ ax as openArcSphereDialog,
70
74
  f as preferences,
71
75
  p as preloadInput,
72
76
  r as routes,
@@ -75,6 +79,7 @@ export {
75
79
  t as translations,
76
80
  h as typography,
77
81
  aa as useApiErrorHandler,
82
+ az as useArcSphereDialog,
78
83
  U as useAuthzContext,
79
84
  c as useChanged,
80
85
  a0 as useChatContext,
package/dist/index.umd.js CHANGED
@@ -5,7 +5,7 @@
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
7
 
8
- var _a, _b, _c, _d, _e;
8
+ var _a, _b, _c, _d, _e, _f;
9
9
  const typography = {
10
10
  h1: {
11
11
  fontSize: "1.875rem",
@@ -961,7 +961,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
961
961
  ] }) : null;
962
962
  }
963
963
  const useSessionContext = () => {
964
- var _a2, _b2, _c2, _d2, _e2, _f;
964
+ var _a2, _b2, _c2, _d2, _e2, _f2;
965
965
  const ctx = react.useContext(Session.SessionContext) || {};
966
966
  const roles = [...((_c2 = (_b2 = (_a2 = ctx == null ? void 0 : ctx.session) == null ? void 0 : _a2.user) == null ? void 0 : _b2.passports) == null ? void 0 : _c2.map((p) => p.role)) || [], "guest"];
967
967
  const permissionSet = react.useMemo(() => {
@@ -977,7 +977,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
977
977
  };
978
978
  return {
979
979
  ...ctx,
980
- isAuthenticated: !!((_f = ctx.session) == null ? void 0 : _f.user),
980
+ isAuthenticated: !!((_f2 = ctx.session) == null ? void 0 : _f2.user),
981
981
  isAdmin: hasAnyPassport(["admin", "owner"]),
982
982
  isMember: hasAnyPassport(["member"]),
983
983
  isBlogEditor: hasAnyPassport(["blogEditor"]),
@@ -4703,10 +4703,60 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4703
4703
  }
4704
4704
  ) }) });
4705
4705
  }
4706
+ const isInArcSphere$1 = ((_e = window == null ? void 0 : window.navigator) == null ? void 0 : _e.userAgent.indexOf("ArcSphere")) > -1;
4707
+ const isInArcSphereDialog = !!ufo.parseQuery(window.location.search).arcSphereDialog;
4708
+ function normalizeUrl(url) {
4709
+ if (url.startsWith("/")) {
4710
+ return ufo.withQuery(ufo.joinURL(window.origin, window.blocklet.prefix, url), { arcSphereDialog: 1 });
4711
+ }
4712
+ return url;
4713
+ }
4714
+ const openArcSphereDialog = ({ url, type = "full", onClose }) => {
4715
+ bridge.register("closePopupCallback", (arg) => {
4716
+ onClose == null ? void 0 : onClose(arg);
4717
+ });
4718
+ bridge.call("arc__openPopup", {
4719
+ url: normalizeUrl(url),
4720
+ type
4721
+ });
4722
+ };
4723
+ const closeArcSphereDialog = (reason) => {
4724
+ if (isInArcSphereDialog) {
4725
+ bridge.call("arc__closePopup", {
4726
+ callback: "closePopupCallback",
4727
+ args: [reason || ""]
4728
+ });
4729
+ }
4730
+ };
4731
+ const useArcSphereDialog = () => {
4732
+ const { session } = useSessionContext();
4733
+ const open = react.useCallback(
4734
+ ({ authRequired = true, ...options }) => {
4735
+ if (authRequired && !session.user) {
4736
+ session.login(() => {
4737
+ openArcSphereDialog(options);
4738
+ });
4739
+ } else {
4740
+ openArcSphereDialog(options);
4741
+ }
4742
+ },
4743
+ [session]
4744
+ );
4745
+ const close = react.useCallback((reason) => {
4746
+ closeArcSphereDialog(reason);
4747
+ }, []);
4748
+ return {
4749
+ open,
4750
+ close
4751
+ };
4752
+ };
4706
4753
  function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }) {
4707
4754
  const navigate = reactRouterDom.useNavigate();
4708
4755
  const location = reactRouterDom.useLocation();
4709
4756
  const mergedSx = [{}, ...Array.isArray(sx) ? sx : [sx]];
4757
+ if (isInArcSphere$1) {
4758
+ return null;
4759
+ }
4710
4760
  const handleClick = () => {
4711
4761
  var _a2;
4712
4762
  if (url) {
@@ -5785,7 +5835,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5785
5835
  return hotToast.error(message, { ...options, icon: "⚠️" });
5786
5836
  }
5787
5837
  });
5788
- const isInArcSphere = ((_e = window == null ? void 0 : window.navigator) == null ? void 0 : _e.userAgent.indexOf("ArcSphere")) > -1;
5838
+ const isInArcSphere = ((_f = window == null ? void 0 : window.navigator) == null ? void 0 : _f.userAgent.indexOf("ArcSphere")) > -1;
5789
5839
  if (isInArcSphere) {
5790
5840
  exports2.toast = Object.assign(
5791
5841
  (message) => {
@@ -11848,14 +11898,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
11848
11898
  }
11849
11899
  });
11850
11900
  }
11851
- function getWsClient(prefix2 = ((_f) => (_f = window.blocklet) == null ? void 0 : _f.prefix)() || "/") {
11901
+ function getWsClient(prefix2 = ((_g) => (_g = window.blocklet) == null ? void 0 : _g.prefix)() || "/") {
11852
11902
  if (!client) {
11853
11903
  client = create(prefix2);
11854
11904
  }
11855
11905
  return client;
11856
11906
  }
11857
11907
  const useSubscription = (event, cb = () => {
11858
- }, deps = [], prefix2 = ((_g) => (_g = window.blocklet) == null ? void 0 : _g.prefix)() || "/") => {
11908
+ }, deps = [], prefix2 = ((_h) => (_h = window.blocklet) == null ? void 0 : _h.prefix)() || "/") => {
11859
11909
  react.useEffect(() => {
11860
11910
  if (event) {
11861
11911
  if (!client) {
@@ -12334,11 +12384,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
12334
12384
  exports2.UploaderContext = UploaderContext;
12335
12385
  exports2.UploaderProvider = UploaderProvider;
12336
12386
  exports2.UploaderTrigger = UploaderTrigger;
12387
+ exports2.closeArcSphereDialog = closeArcSphereDialog;
12337
12388
  exports2.create = create;
12338
12389
  exports2.getBlogLink = getBlogLink;
12339
12390
  exports2.getUploadedImageUrl = getUploadedImageUrl;
12340
12391
  exports2.getWsClient = getWsClient;
12392
+ exports2.isInArcSphere = isInArcSphere$1;
12393
+ exports2.isInArcSphereDialog = isInArcSphereDialog;
12341
12394
  exports2.lexicalUtils = lexical;
12395
+ exports2.openArcSphereDialog = openArcSphereDialog;
12342
12396
  exports2.preferences = preferences;
12343
12397
  exports2.preloadInput = preloadInput;
12344
12398
  exports2.routes = routes;
@@ -12346,6 +12400,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
12346
12400
  exports2.translations = translations;
12347
12401
  exports2.typography = typography;
12348
12402
  exports2.useApiErrorHandler = useApiErrorHandler;
12403
+ exports2.useArcSphereDialog = useArcSphereDialog;
12349
12404
  exports2.useAuthzContext = useAuthzContext;
12350
12405
  exports2.useChanged = useChanged;
12351
12406
  exports2.useChatContext = useChatContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "2.1.161",
3
+ "version": "2.1.163",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -45,8 +45,8 @@
45
45
  "ufo": "^1.5.4",
46
46
  "unstated-next": "^1.1.0",
47
47
  "url-join": "^4.0.1",
48
- "@blocklet/editor": "^2.1.161",
49
- "@blocklet/labels": "^2.1.161"
48
+ "@blocklet/editor": "^2.1.163",
49
+ "@blocklet/labels": "^2.1.163"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@arcblock/did-connect": "^2.10.36",