gomtm 0.0.389 → 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 +19 -12
- package/dist/esm/block/BlockPage.js +2 -2
- 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
|
};
|
|
@@ -84,7 +83,7 @@ const BlockItemSetup = () => {
|
|
|
84
83
|
};
|
|
85
84
|
const ChildrenDebugInner = (props) => {
|
|
86
85
|
const { children } = props;
|
|
87
|
-
const setDebugData =
|
|
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 =
|
|
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 =
|
|
123
|
-
const 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 = (
|
|
128
|
-
|
|
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
|
|
137
|
+
var _a;
|
|
131
138
|
if (originPropsList) {
|
|
132
|
-
return (
|
|
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("
|
|
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 =
|
|
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
|
|
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) => {
|
|
@@ -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