gomtm 0.0.388 → 0.0.390
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.
- package/dist/esm/block/BlockItem.d.ts +0 -2
- package/dist/esm/block/BlockItem.js +37 -15
- package/dist/esm/block/BlockPage.js +14 -4
- package/dist/esm/block/blocks/hello/index.d.ts +1 -0
- package/dist/esm/block/blocks/hello/index.js +3 -1
- package/dist/esm/block/consts.d.ts +1 -1
- package/dist/esm/block/consts.js +1 -1
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -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
|
};
|
|
@@ -68,14 +67,23 @@ const BlockItem = (props) => {
|
|
|
68
67
|
if (!children) {
|
|
69
68
|
return /* @__PURE__ */ jsx("div", { children: "no children" });
|
|
70
69
|
}
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */ jsx(
|
|
73
|
-
/* @__PURE__ */ jsx(
|
|
74
|
-
|
|
70
|
+
return /* @__PURE__ */ jsxs(BlockItemProvider, { children: [
|
|
71
|
+
/* @__PURE__ */ jsx(BlockItemSetup, {}),
|
|
72
|
+
/* @__PURE__ */ jsx(BlockItemDesignToolbar, {}),
|
|
73
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
74
|
+
/* @__PURE__ */ jsx("h1", { children: "BlockItem" }),
|
|
75
|
+
/* @__PURE__ */ jsx(ChildrenDebugInner, { children })
|
|
76
|
+
] })
|
|
77
|
+
] });
|
|
78
|
+
};
|
|
79
|
+
const BlockItemSetup = () => {
|
|
80
|
+
const setDesignMode = useDemoChildrenBlock((x) => x.setDesignMode);
|
|
81
|
+
const designMode = useDemoChildrenBlock((x) => x.designMode);
|
|
82
|
+
return null;
|
|
75
83
|
};
|
|
76
84
|
const ChildrenDebugInner = (props) => {
|
|
77
85
|
const { children } = props;
|
|
78
|
-
const setDebugData =
|
|
86
|
+
const setDebugData = useBlockItem((x) => x.setOriginPropsList);
|
|
79
87
|
const designMode = useDemoChildrenBlock((x) => x.designMode);
|
|
80
88
|
useMemo(() => {
|
|
81
89
|
let data2 = [];
|
|
@@ -102,21 +110,35 @@ const ChildrenDebugInner = (props) => {
|
|
|
102
110
|
};
|
|
103
111
|
function ChildrenOrigin(props) {
|
|
104
112
|
const { child, i } = props;
|
|
105
|
-
const originPropsList =
|
|
113
|
+
const originPropsList = useBlockItem((x) => x.originPropsList);
|
|
106
114
|
const overProps = useMemo(() => originPropsList && originPropsList[i].props, [i, originPropsList]);
|
|
107
115
|
return /* @__PURE__ */ jsx(Fragment, { children: createElement(child.type, __spreadValues(__spreadValues({}, child.props), overProps)) });
|
|
108
116
|
}
|
|
109
117
|
function ChildrenEditMode(props) {
|
|
110
|
-
var _a;
|
|
111
118
|
const { child, i } = props;
|
|
112
119
|
const [open, setOpen] = useState(false);
|
|
113
|
-
const originPropsList =
|
|
114
|
-
const setOriginPropsList =
|
|
120
|
+
const originPropsList = useBlockItem((x) => x.originPropsList);
|
|
121
|
+
const setOriginPropsList = useBlockItem((x) => x.setOriginPropsList);
|
|
115
122
|
const oriProps = useMemo(() => {
|
|
116
123
|
return originPropsList[i];
|
|
117
124
|
}, [i, originPropsList]);
|
|
118
|
-
const Editor = (
|
|
119
|
-
|
|
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]);
|
|
136
|
+
const overProps = useMemo(() => {
|
|
137
|
+
var _a;
|
|
138
|
+
if (originPropsList) {
|
|
139
|
+
return (_a = originPropsList[i]) == null ? void 0 : _a.props;
|
|
140
|
+
}
|
|
141
|
+
}, [i, originPropsList]);
|
|
120
142
|
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
121
143
|
/* @__PURE__ */ jsxs(
|
|
122
144
|
MtButton,
|
|
@@ -134,7 +156,7 @@ function ChildrenEditMode(props) {
|
|
|
134
156
|
),
|
|
135
157
|
createElement(child.type, __spreadValues(__spreadValues({}, child.props), overProps)),
|
|
136
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) => {
|
|
137
|
-
console.log("
|
|
159
|
+
console.log("setProps", values);
|
|
138
160
|
setOriginPropsList(originPropsList.map((item, j) => {
|
|
139
161
|
if (i == j) {
|
|
140
162
|
return { props: values };
|
|
@@ -145,13 +167,13 @@ function ChildrenEditMode(props) {
|
|
|
145
167
|
] });
|
|
146
168
|
}
|
|
147
169
|
const BlockItemDesignToolbar = () => {
|
|
148
|
-
const debugData =
|
|
170
|
+
const debugData = useBlockItem((x) => x.originPropsList);
|
|
149
171
|
const designMode = useDemoChildrenBlock((x) => x.designMode);
|
|
150
172
|
const setDesignMode = useDemoChildrenBlock((x) => x.setDesignMode);
|
|
151
173
|
if (!designMode) {
|
|
152
174
|
return null;
|
|
153
175
|
}
|
|
154
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-1 bg-
|
|
176
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-1 bg-blue-300 p-1", children: [
|
|
155
177
|
/* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
156
178
|
setDesignMode(!designMode);
|
|
157
179
|
}, children: "edit" }),
|
|
@@ -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
|
|
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) => {
|
|
@@ -110,7 +110,12 @@ const ChildrenDebugInner = (props) => {
|
|
|
110
110
|
function ChildrenOrigin(props) {
|
|
111
111
|
const { child, i } = props;
|
|
112
112
|
const originPropsList = useDemoChildrenBlock((x) => x.originPropsList);
|
|
113
|
-
const overProps = useMemo(() =>
|
|
113
|
+
const overProps = useMemo(() => {
|
|
114
|
+
var _a;
|
|
115
|
+
if (originPropsList) {
|
|
116
|
+
return (_a = originPropsList[i]) == null ? void 0 : _a.props;
|
|
117
|
+
}
|
|
118
|
+
}, [i, originPropsList]);
|
|
114
119
|
return /* @__PURE__ */ jsx(Fragment, { children: createElement(child.type, __spreadValues(__spreadValues({}, child.props), overProps)) });
|
|
115
120
|
}
|
|
116
121
|
function ChildrenEditMode(props) {
|
|
@@ -123,7 +128,12 @@ function ChildrenEditMode(props) {
|
|
|
123
128
|
return originPropsList[i];
|
|
124
129
|
}, [i, originPropsList]);
|
|
125
130
|
const Editor = (_a = child.type) == null ? void 0 : _a.Editor;
|
|
126
|
-
const overProps = useMemo(() =>
|
|
131
|
+
const overProps = useMemo(() => {
|
|
132
|
+
var _a2;
|
|
133
|
+
if (originPropsList) {
|
|
134
|
+
return (_a2 = originPropsList[i]) == null ? void 0 : _a2.props;
|
|
135
|
+
}
|
|
136
|
+
}, [i, originPropsList]);
|
|
127
137
|
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
128
138
|
/* @__PURE__ */ jsxs(
|
|
129
139
|
MtButton,
|
|
@@ -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.
|
|
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+
|
|
1
|
+
export declare const HOTKEY_Design_mode = "alt+x";
|
package/dist/esm/block/consts.js
CHANGED