gomtm 0.0.389 → 0.0.391

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.
@@ -2,12 +2,10 @@ import { PropsWithChildren } from "react";
2
2
  export interface BlockItemProps {
3
3
  id?: string;
4
4
  originPropsList?: any;
5
- designMode?: boolean;
6
5
  overrideData?: any;
7
6
  }
8
7
  export interface DemoChildrenState extends BlockItemProps {
9
8
  setOriginPropsList: (debugData: any) => void;
10
- setDesignMode: (designMode: boolean) => void;
11
9
  setOverrideData: (overrideData: any) => void;
12
10
  }
13
11
  export declare const blockItemContext: import("react").Context<import("zustand").StoreApi<DemoChildrenState> | null>;
@@ -41,7 +41,6 @@ import { MtBlockRender, getComponentName } from "./blockRegister";
41
41
  const createDemoChildrenStore = (initProps) => {
42
42
  return createStore()((set, get) => __spreadProps(__spreadValues({}, initProps), {
43
43
  setOriginPropsList: (debugData) => set({ originPropsList: debugData }),
44
- setDesignMode: (designMode) => set({ designMode }),
45
44
  setOverrideData: (overrideData) => set({ overrideData })
46
45
  }));
47
46
  };
@@ -84,7 +83,7 @@ const BlockItemSetup = () => {
84
83
  };
85
84
  const ChildrenDebugInner = (props) => {
86
85
  const { children } = props;
87
- const setDebugData = useDemoChildrenBlock((x) => x.setOriginPropsList);
86
+ const setDebugData = useBlockItem((x) => x.setOriginPropsList);
88
87
  const designMode = useDemoChildrenBlock((x) => x.designMode);
89
88
  useMemo(() => {
90
89
  let data2 = [];
@@ -111,25 +110,33 @@ const ChildrenDebugInner = (props) => {
111
110
  };
112
111
  function ChildrenOrigin(props) {
113
112
  const { child, i } = props;
114
- const originPropsList = useDemoChildrenBlock((x) => x.originPropsList);
113
+ const originPropsList = useBlockItem((x) => x.originPropsList);
115
114
  const overProps = useMemo(() => originPropsList && originPropsList[i].props, [i, originPropsList]);
116
115
  return /* @__PURE__ */ jsx(Fragment, { children: createElement(child.type, __spreadValues(__spreadValues({}, child.props), overProps)) });
117
116
  }
118
117
  function ChildrenEditMode(props) {
119
- var _a;
120
118
  const { child, i } = props;
121
119
  const [open, setOpen] = useState(false);
122
- const originPropsList = useDemoChildrenBlock((x) => x.originPropsList);
123
- const setOriginPropsList = useDemoChildrenBlock((x) => x.setOriginPropsList);
120
+ const originPropsList = useBlockItem((x) => x.originPropsList);
121
+ const setOriginPropsList = useBlockItem((x) => x.setOriginPropsList);
124
122
  const oriProps = useMemo(() => {
125
123
  return originPropsList[i];
126
124
  }, [i, originPropsList]);
127
- const Editor = (_a = child.type) == null ? void 0 : _a.Editor;
128
- console.log("child.type555555555", child.type);
125
+ const Editor = useMemo(() => {
126
+ var _a, _b, _c, _d;
127
+ const a = (_a = child.type) == null ? void 0 : _a.Editor;
128
+ if (a) {
129
+ return a;
130
+ }
131
+ const b = (_d = (_c = (_b = child.type) == null ? void 0 : _b._payload) == null ? void 0 : _c.value) == null ? void 0 : _d.Editor;
132
+ if (b) {
133
+ return b;
134
+ }
135
+ }, [child.type]);
129
136
  const overProps = useMemo(() => {
130
- var _a2;
137
+ var _a;
131
138
  if (originPropsList) {
132
- return (_a2 = originPropsList[i]) == null ? void 0 : _a2.props;
139
+ return (_a = originPropsList[i]) == null ? void 0 : _a.props;
133
140
  }
134
141
  }, [i, originPropsList]);
135
142
  return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
@@ -149,7 +156,7 @@ function ChildrenEditMode(props) {
149
156
  ),
150
157
  createElement(child.type, __spreadValues(__spreadValues({}, child.props), overProps)),
151
158
  /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsx(DialogContent, { children: !Editor ? /* @__PURE__ */ jsx("div", { children: "missing editor" }) : /* @__PURE__ */ jsx(Editor, { props: oriProps, setProps: (values) => {
152
- console.log("\u8BBE\u7F6E\u65B0\u503C", values);
159
+ console.log("setProps", values);
153
160
  setOriginPropsList(originPropsList.map((item, j) => {
154
161
  if (i == j) {
155
162
  return { props: values };
@@ -160,7 +167,7 @@ function ChildrenEditMode(props) {
160
167
  ] });
161
168
  }
162
169
  const BlockItemDesignToolbar = () => {
163
- const debugData = useDemoChildrenBlock((x) => x.originPropsList);
170
+ const debugData = useBlockItem((x) => x.originPropsList);
164
171
  const designMode = useDemoChildrenBlock((x) => x.designMode);
165
172
  const setDesignMode = useDemoChildrenBlock((x) => x.setDesignMode);
166
173
  if (!designMode) {
@@ -70,14 +70,14 @@ const BlockPage = (props) => {
70
70
  if (!children) {
71
71
  return /* @__PURE__ */ jsx("div", { children: "no children" });
72
72
  }
73
- return /* @__PURE__ */ jsx(DemoChildrenProvider, { children: /* @__PURE__ */ jsx(ChildrenDebugInner, { children }) });
73
+ return /* @__PURE__ */ jsx(DemoChildrenProvider, { children });
74
74
  };
75
75
  const BlockPageSetup = () => {
76
76
  const setDesignMode = useDemoChildrenBlock((x) => x.setDesignMode);
77
77
  const designMode = useDemoChildrenBlock((x) => x.designMode);
78
78
  useHotkeys(HOTKEY_Design_mode, () => {
79
79
  setDesignMode(!designMode);
80
- }, [setDesignMode]);
80
+ }, [setDesignMode, designMode]);
81
81
  return null;
82
82
  };
83
83
  const ChildrenDebugInner = (props) => {
@@ -3,6 +3,7 @@ declare function HelloBlock(props: {
3
3
  text?: string;
4
4
  }): import("react").JSX.Element;
5
5
  declare namespace HelloBlock {
6
+ var blockName: string;
6
7
  var Editor: import("react").LazyExoticComponent<typeof import("./edit").default>;
7
8
  }
8
9
  export default HelloBlock;
@@ -18,10 +18,12 @@ var __spreadValues = (a, b) => {
18
18
  import { jsx } from "react/jsx-runtime";
19
19
  import { lazy } from "react";
20
20
  const LzHelloBlock = lazy(() => import("./Hello"));
21
+ const LzEdit = lazy(() => import("./edit"));
21
22
  function HelloBlock(props) {
22
23
  return /* @__PURE__ */ jsx(LzHelloBlock, __spreadValues({}, props));
23
24
  }
24
- HelloBlock.Editor = lazy(() => import("./edit"));
25
+ HelloBlock.blockName = "hello-block";
26
+ HelloBlock.Editor = LzEdit;
25
27
  export {
26
28
  HelloBlock as default
27
29
  };
@@ -1 +1 @@
1
- export declare const HOTKEY_Design_mode = "alt+d";
1
+ export declare const HOTKEY_Design_mode = "alt+x";
@@ -1,4 +1,4 @@
1
- const HOTKEY_Design_mode = "alt+d";
1
+ const HOTKEY_Design_mode = "alt+x";
2
2
  export {
3
3
  HOTKEY_Design_mode
4
4
  };