import { CompArcObj } from "../../components/CompUI/basicUI/Arc"; import { CompCardObj } from "../../components/CompUI/basicUI/Container"; import { CompCurveObj } from "../../components/CompUI/basicUI/Curve"; import { CompEllipseObj } from "../../components/CompUI/basicUI/Ellipse"; import { CompGroupObj } from "../../components/CompUI/basicUI/Group"; import { CompImageObj } from "../../components/CompUI/basicUI/Image2"; import { CompLineObj } from "../../components/CompUI/basicUI/Line"; import { CompMapObj } from "../../components/CompUI/basicUI/Map"; import { CompPageObj } from "../../components/CompUI/basicUI/Page"; import { CompPolygonObj } from "../../components/CompUI/basicUI/Polygon"; import { CompPolygonNormalObj } from "../../components/CompUI/basicUI/PolygonNormal"; import { CompRectObj } from "../../components/CompUI/basicUI/Rectage"; import { CompTextObj } from "../../components/CompUI/basicUI/Text"; import { CompTriangleObj } from "../../components/CompUI/basicUI/Triangle"; import { CompVideoObj } from "../../components/CompUI/basicUI/Video"; import { CompWeb3DObj } from "../../components/CompUI/basicUI/Web3D"; import { HistoryController } from "../../controllers/ReactCtrl/history"; import { ICompKeys } from "../../typings"; import { DesignComp } from "./DesignComp"; const history = new HistoryController(); export function createObj( data:any, init = true) { const compKey = data.compKey as ICompKeys let obj = {} as DesignComp; switch(compKey) { case "Container": obj = new CompCardObj(); break; case "Image": obj = new CompImageObj(); break; case "Text": obj = new CompTextObj(); break; case "Group": obj = new CompGroupObj(); break; case "Page": obj = new CompPageObj(); break; case "Video": obj = new CompVideoObj(); break; case "Web3D": obj = new CompWeb3DObj(); break; case "Rectage": obj = new CompRectObj(); break; case "Line": obj = new CompLineObj(); break; case "Arc": obj = new CompArcObj(); break; case "Ellipse": obj = new CompEllipseObj(); break; case "Triangle": obj = new CompTriangleObj(); break; case "Polygon": obj = new CompPolygonObj(); break; case "PolygonNormal": obj = new CompPolygonNormalObj(); break; case "Curve": obj = new CompCurveObj(); break; case "Map": obj = new CompMapObj() break; } obj.compKey = compKey; obj.value.setHistory( history ); obj.layout.setHistory(history); obj.layout.background.setHistory(history); obj.layout.border.setHistory(history); obj.children.setHistory(history); if (init) obj.fromJson(data); return obj; } export {history};