@blocklet/discuss-kit-ux 2.0.89 → 2.0.95

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.
@@ -10,7 +10,7 @@ export declare const copy: (text: string) => void;
10
10
  export declare const getLastItem: <T>(arr: T[]) => T | null;
11
11
  export declare function tryParseJSONObject(str: string): boolean;
12
12
  export declare const getPreference: (key: string) => any;
13
- export declare const getBlockletMountPointInfo: (name: string) => any;
13
+ export declare const getBlockletMountPointInfo: (name: string) => ComponentMountPoint | undefined;
14
14
  export declare const blockletExists: (name: string) => boolean;
15
15
  export declare const inferDiscussKitApiPrefix: () => any;
16
16
  export declare const getDraftSessionKeyPrefix: () => string;
@@ -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-BPvWJjAI.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-CbxeLaB1.mjs";
8
8
  const BlockletEditor = lazy(() => import("@blocklet/editor"));
9
9
  const Root = styled(Box)`
10
10
  .be-editable,
@@ -4760,7 +4760,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, ...rest }) {
4760
4760
  }
4761
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" }) });
4762
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" }) });
4763
- const Editor = lazy(() => import("./editor-HBkw1czM.mjs"));
4763
+ const Editor = lazy(() => import("./editor-Dlj6ZsEf.mjs"));
4764
4764
  function LazyEditor(props) {
4765
4765
  const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
4766
4766
  /* @__PURE__ */ jsx(Skeleton, {}),
@@ -4993,7 +4993,6 @@ function ChatInput({ initialContent, send, onContentChange, onFocusChange }) {
4993
4993
  onContentChange == null ? void 0 : onContentChange(value);
4994
4994
  },
4995
4995
  autoFocus: false,
4996
- ignoreInitialChange: false,
4997
4996
  placeholder: "Jot something down",
4998
4997
  children: [
4999
4998
  /* @__PURE__ */ jsx(AutoClearPlugin, { clearKey: lastSent }),
@@ -6078,12 +6077,40 @@ const useBeforeUnloadPrompt = (dirty) => {
6078
6077
  };
6079
6078
  }, [dirty]);
6080
6079
  };
6080
+ const useDirtySources = () => {
6081
+ const [state, setState] = useState({});
6082
+ const dirty = Object.values(state).some(Boolean);
6083
+ const markDirty = useCallback(
6084
+ (key) => {
6085
+ setState((prev) => ({ ...prev, [key]: true }));
6086
+ },
6087
+ [setState]
6088
+ );
6089
+ const resetDirty = useCallback(
6090
+ (key) => {
6091
+ setState((prev) => ({ ...prev, [key]: false }));
6092
+ },
6093
+ [setState]
6094
+ );
6095
+ useEffect(() => {
6096
+ const onMarkDirty = (e) => markDirty(e.detail.key);
6097
+ const onReset = (e) => resetDirty(e.detail.key);
6098
+ window.addEventListener("blocklet:markDirty", onMarkDirty);
6099
+ window.addEventListener("blocklet:resetDirty", onReset);
6100
+ return () => {
6101
+ window.removeEventListener("blocklet:markDirty", onMarkDirty);
6102
+ window.removeEventListener("blocklet:resetDirty", onReset);
6103
+ };
6104
+ }, [markDirty, resetDirty]);
6105
+ return { dirty };
6106
+ };
6081
6107
  const useDirtyPrompt = () => {
6082
6108
  const { t } = useLocaleContext();
6083
6109
  const [dirty, setDirty, getDirty] = useGetState(false);
6084
6110
  const { confirm } = useConfirm();
6085
6111
  const resetCallbackRef = useRef(null);
6086
6112
  useBeforeUnloadPrompt(dirty);
6113
+ const multiDirtySourceState = useDirtySources();
6087
6114
  const reset = useCallback(
6088
6115
  (callback) => {
6089
6116
  resetCallbackRef.current = callback;
@@ -6115,7 +6142,7 @@ const useDirtyPrompt = () => {
6115
6142
  }
6116
6143
  return true;
6117
6144
  }, [confirm, reset, getDirty, t]);
6118
- return { dirty, markDirty, reset, check };
6145
+ return { dirty: dirty || multiDirtySourceState.dirty, markDirty, reset, check };
6119
6146
  };
6120
6147
  const DirtyPromptContainer = createContainer(useDirtyPrompt);
6121
6148
  function ConfirmNavigation() {
@@ -6149,7 +6176,8 @@ function ConfirmNavigation() {
6149
6176
  handleCancel: () => {
6150
6177
  var _a2;
6151
6178
  return (_a2 = blocker.reset) == null ? void 0 : _a2.call(blocker);
6152
- }
6179
+ },
6180
+ sx: { zIndex: 99999 }
6153
6181
  }
6154
6182
  );
6155
6183
  }
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-BPvWJjAI.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-CbxeLaB1.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
package/dist/index.umd.js CHANGED
@@ -4919,7 +4919,6 @@ var __publicField = (obj, key, value) => {
4919
4919
  onContentChange == null ? void 0 : onContentChange(value);
4920
4920
  },
4921
4921
  autoFocus: false,
4922
- ignoreInitialChange: false,
4923
4922
  placeholder: "Jot something down",
4924
4923
  children: [
4925
4924
  /* @__PURE__ */ jsxRuntime.jsx(AutoClearPlugin, { clearKey: lastSent }),
@@ -6004,12 +6003,40 @@ var __publicField = (obj, key, value) => {
6004
6003
  };
6005
6004
  }, [dirty]);
6006
6005
  };
6006
+ const useDirtySources = () => {
6007
+ const [state, setState] = react.useState({});
6008
+ const dirty = Object.values(state).some(Boolean);
6009
+ const markDirty = react.useCallback(
6010
+ (key) => {
6011
+ setState((prev) => ({ ...prev, [key]: true }));
6012
+ },
6013
+ [setState]
6014
+ );
6015
+ const resetDirty = react.useCallback(
6016
+ (key) => {
6017
+ setState((prev) => ({ ...prev, [key]: false }));
6018
+ },
6019
+ [setState]
6020
+ );
6021
+ react.useEffect(() => {
6022
+ const onMarkDirty = (e) => markDirty(e.detail.key);
6023
+ const onReset = (e) => resetDirty(e.detail.key);
6024
+ window.addEventListener("blocklet:markDirty", onMarkDirty);
6025
+ window.addEventListener("blocklet:resetDirty", onReset);
6026
+ return () => {
6027
+ window.removeEventListener("blocklet:markDirty", onMarkDirty);
6028
+ window.removeEventListener("blocklet:resetDirty", onReset);
6029
+ };
6030
+ }, [markDirty, resetDirty]);
6031
+ return { dirty };
6032
+ };
6007
6033
  const useDirtyPrompt = () => {
6008
6034
  const { t } = context.useLocaleContext();
6009
6035
  const [dirty, setDirty, getDirty] = ahooks.useGetState(false);
6010
6036
  const { confirm } = useConfirm();
6011
6037
  const resetCallbackRef = react.useRef(null);
6012
6038
  useBeforeUnloadPrompt(dirty);
6039
+ const multiDirtySourceState = useDirtySources();
6013
6040
  const reset = react.useCallback(
6014
6041
  (callback) => {
6015
6042
  resetCallbackRef.current = callback;
@@ -6041,7 +6068,7 @@ var __publicField = (obj, key, value) => {
6041
6068
  }
6042
6069
  return true;
6043
6070
  }, [confirm, reset, getDirty, t]);
6044
- return { dirty, markDirty, reset, check };
6071
+ return { dirty: dirty || multiDirtySourceState.dirty, markDirty, reset, check };
6045
6072
  };
6046
6073
  const DirtyPromptContainer = unstatedNext.createContainer(useDirtyPrompt);
6047
6074
  function ConfirmNavigation() {
@@ -6075,7 +6102,8 @@ var __publicField = (obj, key, value) => {
6075
6102
  handleCancel: () => {
6076
6103
  var _a2;
6077
6104
  return (_a2 = blocker.reset) == null ? void 0 : _a2.call(blocker);
6078
- }
6105
+ },
6106
+ sx: { zIndex: 99999 }
6079
6107
  }
6080
6108
  );
6081
6109
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "2.0.89",
3
+ "version": "2.0.95",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -28,12 +28,12 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@arcblock/bridge": "^2.10.6",
32
- "@arcblock/react-hooks": "^2.10.6",
33
- "@arcblock/ws": "^1.18.126",
34
- "@blocklet/editor": "2.0.89",
35
- "@blocklet/labels": "2.0.89",
36
- "@blocklet/uploader": "^0.1.19",
31
+ "@arcblock/bridge": "^2.10.12",
32
+ "@arcblock/react-hooks": "^2.10.12",
33
+ "@arcblock/ws": "^1.18.128",
34
+ "@blocklet/editor": "2.0.95",
35
+ "@blocklet/labels": "2.0.95",
36
+ "@blocklet/uploader": "^0.1.20",
37
37
  "@emotion/css": "^11.10.5",
38
38
  "@emotion/react": "^11.10.5",
39
39
  "@emotion/styled": "^11.10.5",
@@ -100,5 +100,5 @@
100
100
  "resolutions": {
101
101
  "react": "^18.2.0"
102
102
  },
103
- "gitHead": "0536b69b1e6f53fd09fc2e93e3e9a3e56fdb07ca"
103
+ "gitHead": "1a046d557cce0678f2ac833bd314dcdd25872733"
104
104
  }