feat: add listen code change

This commit is contained in:
2024-09-23 20:51:59 +08:00
parent 4d308921a3
commit 27f487c48f
13 changed files with 419 additions and 97 deletions

View File

@@ -43,22 +43,25 @@ export const Deck = () => {
const codes = nodes.map((node: any) => {
const container = node.container;
const data = container?.data || {};
const nodeData = node.data || {};
let style = nodeData.style ?? {
position: 'absolute',
width: 100,
height: 100,
};
return {
id: node.id,
title: node.title,
code: container?.code || '',
data: data,
children: node.children,
...data, // style className shadowRoot showChild
// TODO: style className shadowRoot showChild
className: nodeData.className,
shadowRoot: nodeData.shadowRoot,
showChild: nodeData.showChild,
style,
};
});
// const code = {
// id: data.id,
// title: data.title,
// code: data.code,
// data: data.data,
// };
// init([code]);
init(codes);
console.log('codes', codes);
}

View File

@@ -5,7 +5,7 @@ import { useShallow } from 'zustand/react/shallow';
import { Form } from 'antd';
import copy from 'copy-to-clipboard';
import { useNavigate } from 'react-router';
import { useToCodeEditor } from '@/pages/code-editor';
const FormModal = () => {
const [form] = Form.useForm();
@@ -69,6 +69,7 @@ const FormModal = () => {
};
export const List = () => {
const navicate = useNavigate();
const toCodeEditor = useToCodeEditor();
const editStore = useEditStore(
useShallow((state) => {
return {
@@ -134,6 +135,12 @@ export const List = () => {
}}>
Deck
</Button>
<Button
onClick={() => {
toCodeEditor.toPagePage(record);
}}>
Source Data Editor
</Button>
<Button
danger
onClick={() => {