gomtm 0.0.386 → 0.0.388
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 +16 -0
- package/dist/esm/block/BlockItem.js +180 -0
- package/dist/esm/block/BlockPage.d.ts +15 -0
- package/dist/esm/block/BlockPage.js +187 -0
- package/dist/esm/block/blocks/hello/edit.d.ts +3 -3
- package/dist/esm/block/blocks/hello/edit.js +4 -5
- package/dist/esm/block/blocks/hello/index.d.ts +0 -2
- package/dist/esm/block/blocks/hello/index.js +1 -3
- package/dist/esm/block/consts.d.ts +1 -0
- package/dist/esm/block/consts.js +4 -0
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
export interface BlockItemProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
originPropsList?: any;
|
|
5
|
+
designMode?: boolean;
|
|
6
|
+
overrideData?: any;
|
|
7
|
+
}
|
|
8
|
+
export interface DemoChildrenState extends BlockItemProps {
|
|
9
|
+
setOriginPropsList: (debugData: any) => void;
|
|
10
|
+
setDesignMode: (designMode: boolean) => void;
|
|
11
|
+
setOverrideData: (overrideData: any) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const blockItemContext: import("react").Context<import("zustand").StoreApi<DemoChildrenState> | null>;
|
|
14
|
+
export declare const BlockItemProvider: (props: PropsWithChildren<BlockItemProps>) => import("react").JSX.Element;
|
|
15
|
+
export declare function useBlockItem<T>(selector: (state: DemoChildrenState) => T): T;
|
|
16
|
+
export declare const BlockItem: (props: any) => import("react").JSX.Element;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
34
|
+
import { cn } from "mtxuilib/lib/utils";
|
|
35
|
+
import { Dialog, DialogContent, DialogTrigger } from "mtxuilib/ui/dialog";
|
|
36
|
+
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
37
|
+
import { Children, createContext, createElement, useContext, useMemo, useRef, useState } from "react";
|
|
38
|
+
import { createStore, useStore } from "zustand";
|
|
39
|
+
import { useDemoChildrenBlock } from "./BlockPage";
|
|
40
|
+
import { MtBlockRender, getComponentName } from "./blockRegister";
|
|
41
|
+
const createDemoChildrenStore = (initProps) => {
|
|
42
|
+
return createStore()((set, get) => __spreadProps(__spreadValues({}, initProps), {
|
|
43
|
+
setOriginPropsList: (debugData) => set({ originPropsList: debugData }),
|
|
44
|
+
setDesignMode: (designMode) => set({ designMode }),
|
|
45
|
+
setOverrideData: (overrideData) => set({ overrideData })
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
const blockItemContext = createContext(null);
|
|
49
|
+
const BlockItemProvider = (props) => {
|
|
50
|
+
const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
|
|
51
|
+
const storeRef = useRef();
|
|
52
|
+
if (!storeRef.current) {
|
|
53
|
+
storeRef.current = createDemoChildrenStore(props);
|
|
54
|
+
}
|
|
55
|
+
return /* @__PURE__ */ jsxs(blockItemContext.Provider, { value: storeRef.current, children: [
|
|
56
|
+
/* @__PURE__ */ jsx(BlockItemDesignToolbar, {}),
|
|
57
|
+
children
|
|
58
|
+
] });
|
|
59
|
+
};
|
|
60
|
+
function useBlockItem(selector) {
|
|
61
|
+
const store = useContext(blockItemContext);
|
|
62
|
+
if (!store)
|
|
63
|
+
throw new Error("useBlockItem Missing BlockItemProvider in the tree");
|
|
64
|
+
return useStore(store, selector);
|
|
65
|
+
}
|
|
66
|
+
const BlockItem = (props) => {
|
|
67
|
+
const { children } = props;
|
|
68
|
+
if (!children) {
|
|
69
|
+
return /* @__PURE__ */ jsx("div", { children: "no children" });
|
|
70
|
+
}
|
|
71
|
+
return /* @__PURE__ */ jsx(BlockItemProvider, { children: /* @__PURE__ */ jsxs("div", { children: [
|
|
72
|
+
/* @__PURE__ */ jsx("h1", { children: "BlockItem" }),
|
|
73
|
+
/* @__PURE__ */ jsx(ChildrenDebugInner, { children })
|
|
74
|
+
] }) });
|
|
75
|
+
};
|
|
76
|
+
const ChildrenDebugInner = (props) => {
|
|
77
|
+
const { children } = props;
|
|
78
|
+
const setDebugData = useDemoChildrenBlock((x) => x.setOriginPropsList);
|
|
79
|
+
const designMode = useDemoChildrenBlock((x) => x.designMode);
|
|
80
|
+
useMemo(() => {
|
|
81
|
+
let data2 = [];
|
|
82
|
+
{
|
|
83
|
+
Children.map(children, (child) => {
|
|
84
|
+
const compName = getComponentName(child.type);
|
|
85
|
+
const debugData = {
|
|
86
|
+
"blockType": compName,
|
|
87
|
+
"props": child.props
|
|
88
|
+
};
|
|
89
|
+
data2 = [...data2, debugData];
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
setDebugData(data2);
|
|
93
|
+
}, [children, setDebugData]);
|
|
94
|
+
if (!children) {
|
|
95
|
+
return /* @__PURE__ */ jsx("div", { children: "no children" });
|
|
96
|
+
}
|
|
97
|
+
return /* @__PURE__ */ jsx("div", { className: cn(
|
|
98
|
+
designMode && "bg-red-300 shadow-md outline"
|
|
99
|
+
), children: Children.map(children, (child, i) => {
|
|
100
|
+
return designMode ? /* @__PURE__ */ jsx(ChildrenEditMode, { child, i }) : /* @__PURE__ */ jsx(ChildrenOrigin, { child, i });
|
|
101
|
+
}) });
|
|
102
|
+
};
|
|
103
|
+
function ChildrenOrigin(props) {
|
|
104
|
+
const { child, i } = props;
|
|
105
|
+
const originPropsList = useDemoChildrenBlock((x) => x.originPropsList);
|
|
106
|
+
const overProps = useMemo(() => originPropsList && originPropsList[i].props, [i, originPropsList]);
|
|
107
|
+
return /* @__PURE__ */ jsx(Fragment, { children: createElement(child.type, __spreadValues(__spreadValues({}, child.props), overProps)) });
|
|
108
|
+
}
|
|
109
|
+
function ChildrenEditMode(props) {
|
|
110
|
+
var _a;
|
|
111
|
+
const { child, i } = props;
|
|
112
|
+
const [open, setOpen] = useState(false);
|
|
113
|
+
const originPropsList = useDemoChildrenBlock((x) => x.originPropsList);
|
|
114
|
+
const setOriginPropsList = useDemoChildrenBlock((x) => x.setOriginPropsList);
|
|
115
|
+
const oriProps = useMemo(() => {
|
|
116
|
+
return originPropsList[i];
|
|
117
|
+
}, [i, originPropsList]);
|
|
118
|
+
const Editor = (_a = child.type) == null ? void 0 : _a.Editor;
|
|
119
|
+
const overProps = useMemo(() => originPropsList && originPropsList[i].props, [i, originPropsList]);
|
|
120
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
121
|
+
/* @__PURE__ */ jsxs(
|
|
122
|
+
MtButton,
|
|
123
|
+
{
|
|
124
|
+
className: " absolute right-0 top-0",
|
|
125
|
+
onClick: () => {
|
|
126
|
+
setOpen(true);
|
|
127
|
+
},
|
|
128
|
+
children: [
|
|
129
|
+
"ed(",
|
|
130
|
+
i,
|
|
131
|
+
")"
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
),
|
|
135
|
+
createElement(child.type, __spreadValues(__spreadValues({}, child.props), overProps)),
|
|
136
|
+
/* @__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("\u8BBE\u7F6E\u65B0\u503C", values);
|
|
138
|
+
setOriginPropsList(originPropsList.map((item, j) => {
|
|
139
|
+
if (i == j) {
|
|
140
|
+
return { props: values };
|
|
141
|
+
}
|
|
142
|
+
return item;
|
|
143
|
+
}));
|
|
144
|
+
} }) }) })
|
|
145
|
+
] });
|
|
146
|
+
}
|
|
147
|
+
const BlockItemDesignToolbar = () => {
|
|
148
|
+
const debugData = useDemoChildrenBlock((x) => x.originPropsList);
|
|
149
|
+
const designMode = useDemoChildrenBlock((x) => x.designMode);
|
|
150
|
+
const setDesignMode = useDemoChildrenBlock((x) => x.setDesignMode);
|
|
151
|
+
if (!designMode) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-1 bg-slate-600 p-2", children: [
|
|
155
|
+
/* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
156
|
+
setDesignMode(!designMode);
|
|
157
|
+
}, children: "edit" }),
|
|
158
|
+
/* @__PURE__ */ jsxs(Dialog, { children: [
|
|
159
|
+
/* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx(MtButton, { children: "info" }) }),
|
|
160
|
+
/* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx("pre", { children: JSON.stringify(debugData, null, 2) }) })
|
|
161
|
+
] }),
|
|
162
|
+
/* @__PURE__ */ jsxs(Dialog, { children: [
|
|
163
|
+
/* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx(MtButton, { children: "reRender" }) }),
|
|
164
|
+
/* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(RenderByPresistData, { data: debugData }) })
|
|
165
|
+
] })
|
|
166
|
+
] });
|
|
167
|
+
};
|
|
168
|
+
function RenderByPresistData(props) {
|
|
169
|
+
const { data } = props;
|
|
170
|
+
const items = data;
|
|
171
|
+
return /* @__PURE__ */ jsx("div", { className: "bg-yellow-100 p-2", children: items.map((item, i) => {
|
|
172
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(MtBlockRender, { type: item.blockType, compProps: item.props }) }, i);
|
|
173
|
+
}) });
|
|
174
|
+
}
|
|
175
|
+
export {
|
|
176
|
+
BlockItem,
|
|
177
|
+
BlockItemProvider,
|
|
178
|
+
blockItemContext,
|
|
179
|
+
useBlockItem
|
|
180
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
export interface DemoChildrenProps {
|
|
3
|
+
originPropsList?: any;
|
|
4
|
+
designMode?: boolean;
|
|
5
|
+
overrideData?: any;
|
|
6
|
+
}
|
|
7
|
+
export interface DemoChildrenState extends DemoChildrenProps {
|
|
8
|
+
setOriginPropsList: (debugData: any) => void;
|
|
9
|
+
setDesignMode: (designMode: boolean) => void;
|
|
10
|
+
setOverrideData: (overrideData: any) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const blockContext: import("react").Context<import("zustand").StoreApi<DemoChildrenState> | null>;
|
|
13
|
+
export declare const DemoChildrenProvider: (props: PropsWithChildren<DemoChildrenProps>) => import("react").JSX.Element;
|
|
14
|
+
export declare function useDemoChildrenBlock<T>(selector: (state: DemoChildrenState) => T): T;
|
|
15
|
+
export declare const BlockPage: (props: any) => import("react").JSX.Element;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
34
|
+
import { cn } from "mtxuilib/lib/utils";
|
|
35
|
+
import { Dialog, DialogContent, DialogTrigger } from "mtxuilib/ui/dialog";
|
|
36
|
+
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
37
|
+
import { Children, createContext, createElement, useContext, useMemo, useRef, useState } from "react";
|
|
38
|
+
import { useHotkeys } from "react-hotkeys-hook";
|
|
39
|
+
import { createStore, useStore } from "zustand";
|
|
40
|
+
import { MtBlockRender, getComponentName } from "./blockRegister";
|
|
41
|
+
import { HOTKEY_Design_mode } from "./consts";
|
|
42
|
+
const createDemoChildrenStore = (initProps) => {
|
|
43
|
+
return createStore()((set, get) => __spreadProps(__spreadValues({}, initProps), {
|
|
44
|
+
setOriginPropsList: (debugData) => set({ originPropsList: debugData }),
|
|
45
|
+
setDesignMode: (designMode) => set({ designMode }),
|
|
46
|
+
setOverrideData: (overrideData) => set({ overrideData })
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
const blockContext = createContext(null);
|
|
50
|
+
const DemoChildrenProvider = (props) => {
|
|
51
|
+
const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
|
|
52
|
+
const storeRef = useRef();
|
|
53
|
+
if (!storeRef.current) {
|
|
54
|
+
storeRef.current = createDemoChildrenStore(props);
|
|
55
|
+
}
|
|
56
|
+
return /* @__PURE__ */ jsxs(blockContext.Provider, { value: storeRef.current, children: [
|
|
57
|
+
/* @__PURE__ */ jsx(BlockDesignToolbar, {}),
|
|
58
|
+
children,
|
|
59
|
+
/* @__PURE__ */ jsx(BlockPageSetup, {})
|
|
60
|
+
] });
|
|
61
|
+
};
|
|
62
|
+
function useDemoChildrenBlock(selector) {
|
|
63
|
+
const store = useContext(blockContext);
|
|
64
|
+
if (!store)
|
|
65
|
+
throw new Error("useDemoChildrenBlock Missing DemoChildrenProvider in the tree");
|
|
66
|
+
return useStore(store, selector);
|
|
67
|
+
}
|
|
68
|
+
const BlockPage = (props) => {
|
|
69
|
+
const { children } = props;
|
|
70
|
+
if (!children) {
|
|
71
|
+
return /* @__PURE__ */ jsx("div", { children: "no children" });
|
|
72
|
+
}
|
|
73
|
+
return /* @__PURE__ */ jsx(DemoChildrenProvider, { children: /* @__PURE__ */ jsx(ChildrenDebugInner, { children }) });
|
|
74
|
+
};
|
|
75
|
+
const BlockPageSetup = () => {
|
|
76
|
+
const setDesignMode = useDemoChildrenBlock((x) => x.setDesignMode);
|
|
77
|
+
const designMode = useDemoChildrenBlock((x) => x.designMode);
|
|
78
|
+
useHotkeys(HOTKEY_Design_mode, () => {
|
|
79
|
+
setDesignMode(!designMode);
|
|
80
|
+
}, [setDesignMode]);
|
|
81
|
+
return null;
|
|
82
|
+
};
|
|
83
|
+
const ChildrenDebugInner = (props) => {
|
|
84
|
+
const { children } = props;
|
|
85
|
+
const setDebugData = useDemoChildrenBlock((x) => x.setOriginPropsList);
|
|
86
|
+
const designMode = useDemoChildrenBlock((x) => x.designMode);
|
|
87
|
+
useMemo(() => {
|
|
88
|
+
let data2 = [];
|
|
89
|
+
{
|
|
90
|
+
Children.map(children, (child) => {
|
|
91
|
+
const compName = getComponentName(child.type);
|
|
92
|
+
const debugData = {
|
|
93
|
+
"blockType": compName,
|
|
94
|
+
"props": child.props
|
|
95
|
+
};
|
|
96
|
+
data2 = [...data2, debugData];
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
setDebugData(data2);
|
|
100
|
+
}, [children, setDebugData]);
|
|
101
|
+
if (!children) {
|
|
102
|
+
return /* @__PURE__ */ jsx("div", { children: "no children" });
|
|
103
|
+
}
|
|
104
|
+
return /* @__PURE__ */ jsx("div", { className: cn(
|
|
105
|
+
designMode && "bg-red-300 shadow-md outline"
|
|
106
|
+
), children: Children.map(children, (child, i) => {
|
|
107
|
+
return designMode ? /* @__PURE__ */ jsx(ChildrenEditMode, { child, i }) : /* @__PURE__ */ jsx(ChildrenOrigin, { child, i });
|
|
108
|
+
}) });
|
|
109
|
+
};
|
|
110
|
+
function ChildrenOrigin(props) {
|
|
111
|
+
const { child, i } = props;
|
|
112
|
+
const originPropsList = useDemoChildrenBlock((x) => x.originPropsList);
|
|
113
|
+
const overProps = useMemo(() => originPropsList && originPropsList[i].props, [i, originPropsList]);
|
|
114
|
+
return /* @__PURE__ */ jsx(Fragment, { children: createElement(child.type, __spreadValues(__spreadValues({}, child.props), overProps)) });
|
|
115
|
+
}
|
|
116
|
+
function ChildrenEditMode(props) {
|
|
117
|
+
var _a;
|
|
118
|
+
const { child, i } = props;
|
|
119
|
+
const [open, setOpen] = useState(false);
|
|
120
|
+
const originPropsList = useDemoChildrenBlock((x) => x.originPropsList);
|
|
121
|
+
const setOriginPropsList = useDemoChildrenBlock((x) => x.setOriginPropsList);
|
|
122
|
+
const oriProps = useMemo(() => {
|
|
123
|
+
return originPropsList[i];
|
|
124
|
+
}, [i, originPropsList]);
|
|
125
|
+
const Editor = (_a = child.type) == null ? void 0 : _a.Editor;
|
|
126
|
+
const overProps = useMemo(() => originPropsList && originPropsList[i].props, [i, originPropsList]);
|
|
127
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
128
|
+
/* @__PURE__ */ jsxs(
|
|
129
|
+
MtButton,
|
|
130
|
+
{
|
|
131
|
+
className: " absolute right-0 top-0",
|
|
132
|
+
onClick: () => {
|
|
133
|
+
setOpen(true);
|
|
134
|
+
},
|
|
135
|
+
children: [
|
|
136
|
+
"ed(",
|
|
137
|
+
i,
|
|
138
|
+
")"
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
createElement(child.type, __spreadValues(__spreadValues({}, child.props), overProps)),
|
|
143
|
+
/* @__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) => {
|
|
144
|
+
console.log("\u8BBE\u7F6E\u65B0\u503C", values);
|
|
145
|
+
setOriginPropsList(originPropsList.map((item, j) => {
|
|
146
|
+
if (i == j) {
|
|
147
|
+
return { props: values };
|
|
148
|
+
}
|
|
149
|
+
return item;
|
|
150
|
+
}));
|
|
151
|
+
} }) }) })
|
|
152
|
+
] });
|
|
153
|
+
}
|
|
154
|
+
const BlockDesignToolbar = () => {
|
|
155
|
+
const debugData = useDemoChildrenBlock((x) => x.originPropsList);
|
|
156
|
+
const designMode = useDemoChildrenBlock((x) => x.designMode);
|
|
157
|
+
const setDesignMode = useDemoChildrenBlock((x) => x.setDesignMode);
|
|
158
|
+
if (!designMode) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-1 bg-slate-600 p-2", children: [
|
|
162
|
+
/* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
163
|
+
setDesignMode(!designMode);
|
|
164
|
+
}, children: "edit" }),
|
|
165
|
+
/* @__PURE__ */ jsxs(Dialog, { children: [
|
|
166
|
+
/* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx(MtButton, { children: "info" }) }),
|
|
167
|
+
/* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx("pre", { children: JSON.stringify(debugData, null, 2) }) })
|
|
168
|
+
] }),
|
|
169
|
+
/* @__PURE__ */ jsxs(Dialog, { children: [
|
|
170
|
+
/* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx(MtButton, { children: "reRender" }) }),
|
|
171
|
+
/* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(RenderByPresistData, { data: debugData }) })
|
|
172
|
+
] })
|
|
173
|
+
] });
|
|
174
|
+
};
|
|
175
|
+
function RenderByPresistData(props) {
|
|
176
|
+
const { data } = props;
|
|
177
|
+
const items = data;
|
|
178
|
+
return /* @__PURE__ */ jsx("div", { className: "bg-yellow-100 p-2", children: items.map((item, i) => {
|
|
179
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(MtBlockRender, { type: item.blockType, compProps: item.props }) }, i);
|
|
180
|
+
}) });
|
|
181
|
+
}
|
|
182
|
+
export {
|
|
183
|
+
BlockPage,
|
|
184
|
+
DemoChildrenProvider,
|
|
185
|
+
blockContext,
|
|
186
|
+
useDemoChildrenBlock
|
|
187
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export default function HelloBlockEditor(
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export default function HelloBlockEditor(_props: {
|
|
3
|
+
props: any;
|
|
4
|
+
setProps: (props: any) => void;
|
|
5
5
|
}): import("react").JSX.Element;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
3
|
-
function HelloBlockEditor(
|
|
4
|
-
const {
|
|
3
|
+
function HelloBlockEditor(_props) {
|
|
4
|
+
const { props, setProps } = _props;
|
|
5
5
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
6
6
|
/* @__PURE__ */ jsx("h1", { children: "hello editor" }),
|
|
7
7
|
/* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
8
8
|
console.log("todo set text");
|
|
9
|
-
|
|
10
|
-
}, children: "set text" })
|
|
11
|
-
/* @__PURE__ */ jsx("pre", { children: JSON.stringify(preProps, null, 2) })
|
|
9
|
+
setProps({ text: "new text-------------------" });
|
|
10
|
+
}, children: "set text" })
|
|
12
11
|
] });
|
|
13
12
|
}
|
|
14
13
|
export {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
declare function HelloBlock(props: {
|
|
3
|
-
id: string;
|
|
4
3
|
text?: string;
|
|
5
4
|
}): import("react").JSX.Element;
|
|
6
5
|
declare namespace HelloBlock {
|
|
7
|
-
var blockName: string;
|
|
8
6
|
var Editor: import("react").LazyExoticComponent<typeof import("./edit").default>;
|
|
9
7
|
}
|
|
10
8
|
export default HelloBlock;
|
|
@@ -18,12 +18,10 @@ 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"));
|
|
22
21
|
function HelloBlock(props) {
|
|
23
22
|
return /* @__PURE__ */ jsx(LzHelloBlock, __spreadValues({}, props));
|
|
24
23
|
}
|
|
25
|
-
HelloBlock.
|
|
26
|
-
HelloBlock.Editor = LzEdit;
|
|
24
|
+
HelloBlock.Editor = lazy(() => import("./edit"));
|
|
27
25
|
export {
|
|
28
26
|
HelloBlock as default
|
|
29
27
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HOTKEY_Design_mode = "alt+d";
|