add g6
This commit is contained in:
1 parent
6fc77ad797
commit
46123a9b83
5 files changed
+2885
-197
No files matched your search
Generated
+2848
-178
File diff suppressed because it is too large.
Load diff
@@ -33,6 +33,7 @@
|
|||||||
"antd": "^4.6.6",
|
"antd": "^4.6.6",
|
||||||
"electron": "^10.1.3",
|
"electron": "^10.1.3",
|
||||||
"electron-packager": "^15.1.0",
|
"electron-packager": "^15.1.0",
|
||||||
|
"g6": "^0.2.0",
|
||||||
"gg-editor": "^3.1.3",
|
"gg-editor": "^3.1.3",
|
||||||
"react": "^16.13.1",
|
"react": "^16.13.1",
|
||||||
"react-dom": "^16.13.1"
|
"react-dom": "^16.13.1"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import GGEditor, { Mind, RegisterNode, setAnchorPointsState } from 'gg-editor';
|
import GGEditor, { Mind, RegisterNode, setAnchorPointsState } from 'gg-editor';
|
||||||
import { MindData } from 'gg-editor/lib/common/interfaces';
|
import { INode } from '@antv/g6/lib/interface/item';
|
||||||
|
import { MindData, Graph, GraphEvent } from 'gg-editor/lib/common/interfaces';
|
||||||
const data: MindData = {
|
const data: MindData = {
|
||||||
id: "1",
|
id: "1",
|
||||||
label: 'Central Topic111',
|
label: 'Central Topic111',
|
||||||
@@ -21,23 +22,33 @@ const data: MindData = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface BehaviorTreeProps {
|
interface BehaviorTreeProps {
|
||||||
|
onSelectNode: (node: INode | null) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
class BehaviorTree extends React.Component<BehaviorTreeProps> {
|
class BehaviorTree extends React.Component<BehaviorTreeProps> {
|
||||||
|
graph: Graph;
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
// const { graph } = this.props;
|
}
|
||||||
// graph.on('click', (ev: any) => {
|
|
||||||
// console.log("click", ev);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// graph.on('dbclick', (ev: any) => {
|
initGraph(graph: Graph) {
|
||||||
// console.log("dbclick", ev);
|
const { onSelectNode } = this.props;
|
||||||
// });
|
graph.on('click', (ev: GraphEvent) => {
|
||||||
|
console.log("click", ev);
|
||||||
|
if (!ev.item) {
|
||||||
|
onSelectNode(null);
|
||||||
|
} else if (ev.item) {
|
||||||
|
onSelectNode(ev.item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// graph.on('dragenter', (ev: any) => {
|
graph.on('dbclick', (ev: GraphEvent) => {
|
||||||
// console.log("dragenter", ev);
|
console.log("dbclick", ev);
|
||||||
// });
|
});
|
||||||
|
|
||||||
|
graph.on('dragenter', (ev: GraphEvent) => {
|
||||||
|
console.log("dragenter", ev);
|
||||||
|
});
|
||||||
|
this.graph = graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -52,7 +63,7 @@ class BehaviorTree extends React.Component <BehaviorTreeProps> {
|
|||||||
data={data}
|
data={data}
|
||||||
ref={component => {
|
ref={component => {
|
||||||
if (component) {
|
if (component) {
|
||||||
console.log('graph:', component.graph);
|
this.initGraph(component.graph);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -7,10 +7,13 @@ import BehaviorTree from './BehaviorTree';
|
|||||||
import './Editor.css';
|
import './Editor.css';
|
||||||
|
|
||||||
export interface EditorProps {
|
export interface EditorProps {
|
||||||
|
filepath: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Editor extends React.Component<EditorProps> {
|
export default class Editor extends React.Component<EditorProps> {
|
||||||
|
componentWillMount() {
|
||||||
|
|
||||||
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
console.log("props", this.props);
|
console.log("props", this.props);
|
||||||
}
|
}
|
||||||
@@ -20,7 +23,11 @@ export default class Editor extends React.Component<EditorProps> {
|
|||||||
<GGEditor className="editor">
|
<GGEditor className="editor">
|
||||||
<Row className="editorBd">
|
<Row className="editorBd">
|
||||||
<Col span={18} className="editorContent">
|
<Col span={18} className="editorContent">
|
||||||
<BehaviorTree />
|
<BehaviorTree
|
||||||
|
onSelectNode={(node) => {
|
||||||
|
console.log("onSelectNode", node)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={6} className="editorSidebar">
|
<Col span={6} className="editorSidebar">
|
||||||
<NodePanel />
|
<NodePanel />
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export default class Main extends Component {
|
|||||||
/>
|
/>
|
||||||
</Sider>
|
</Sider>
|
||||||
<Content className="content">
|
<Content className="content">
|
||||||
{/* <Tabs
|
<Tabs
|
||||||
hideAdd
|
hideAdd
|
||||||
className="tabs"
|
className="tabs"
|
||||||
type="editable-card"
|
type="editable-card"
|
||||||
@@ -123,13 +123,12 @@ export default class Main extends Component {
|
|||||||
filepaths.map(filepath => {
|
filepaths.map(filepath => {
|
||||||
return (
|
return (
|
||||||
<TabPane tab={path.basename(filepath)} key={filepath}>
|
<TabPane tab={path.basename(filepath)} key={filepath}>
|
||||||
<Editor/>
|
<Editor filepath={filepath} />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</Tabs> */}
|
</Tabs>
|
||||||
<Editor />
|
|
||||||
</Content>
|
</Content>
|
||||||
</Layout>
|
</Layout>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user