|
@@ -1,9 +1,10 @@
|
|
import { TipIcons } from "../../components/TipIcons";
|
|
import { TipIcons } from "../../components/TipIcons";
|
|
import { EditorModule } from "../../module";
|
|
import { EditorModule } from "../../module";
|
|
import { ICompKeys } from "../../typings";
|
|
import { ICompKeys } from "../../typings";
|
|
-import { DesignComp } from "../DesignTemp/DesignComp";
|
|
|
|
|
|
|
|
-function getVisible(this: EditorModule, comp: DesignComp) {
|
|
|
|
|
|
+import { CompBase } from "../Elements/base";
|
|
|
|
+
|
|
|
|
+function getVisible(this: EditorModule, comp: CompBase<any>) {
|
|
return !!comp;
|
|
return !!comp;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -12,8 +13,8 @@ type ItemParams = Pick<ToolbarItem, "getValue" | "component" | "onClick"> & {
|
|
};
|
|
};
|
|
class ToolbarItem {
|
|
class ToolbarItem {
|
|
component: any;
|
|
component: any;
|
|
- getValue?: (c: DesignComp) => number;
|
|
|
|
- onClick: (this: EditorModule, c: DesignComp) => void;
|
|
|
|
|
|
+ getValue?: (c: CompBase<any>) => number;
|
|
|
|
+ onClick: (this: EditorModule, c: CompBase<any>) => void;
|
|
getVisible!: typeof getVisible;
|
|
getVisible!: typeof getVisible;
|
|
|
|
|
|
constructor(data: ItemParams) {
|
|
constructor(data: ItemParams) {
|
|
@@ -91,9 +92,9 @@ export const toolbars = createToolbars({
|
|
// 显示/隐藏
|
|
// 显示/隐藏
|
|
visible: {
|
|
visible: {
|
|
component: TipIcons.Visible,
|
|
component: TipIcons.Visible,
|
|
- getValue: (comp) => (comp.layout.visible !== false ? 0 : 1),
|
|
|
|
|
|
+ getValue: (comp:any) => (comp.state.visible !== false ? 0 : 1),
|
|
onClick(comp) {
|
|
onClick(comp) {
|
|
- this.actions.setCompVisible(comp);
|
|
|
|
|
|
+ this.actions.setCompVisible(comp as any);
|
|
},
|
|
},
|
|
},
|
|
},
|
|
// 锁定
|
|
// 锁定
|
|
@@ -101,7 +102,7 @@ export const toolbars = createToolbars({
|
|
component: TipIcons.Lock,
|
|
component: TipIcons.Lock,
|
|
getValue: (comp) => (comp ? 0 : 1),
|
|
getValue: (comp) => (comp ? 0 : 1),
|
|
onClick(comp) {
|
|
onClick(comp) {
|
|
- this.actions.setCompLock(comp);
|
|
|
|
|
|
+ this.actions.setCompLock(comp as any);
|
|
},
|
|
},
|
|
},
|
|
},
|
|
// 删除
|
|
// 删除
|
|
@@ -114,45 +115,45 @@ export const toolbars = createToolbars({
|
|
this.actions.removeComp(comp.id);
|
|
this.actions.removeComp(comp.id);
|
|
},
|
|
},
|
|
},
|
|
},
|
|
- // 对齐
|
|
|
|
- align: {
|
|
|
|
- component: TipIcons.Align,
|
|
|
|
- getVisible: (comp) => !comp.isPostioned() && !comp.isFullWidth(),
|
|
|
|
- getValue: (comp) =>
|
|
|
|
- ["start", "center", "end"].indexOf(comp.layout.alignSelf || "start"),
|
|
|
|
- onClick(comp) {
|
|
|
|
- const vals = ["start", "center", "end"];
|
|
|
|
- let index = vals.indexOf(comp.layout.alignSelf || "start");
|
|
|
|
- this.actions.setCompAlign(comp, vals[++index % 3]);
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
|
|
+ // // 对齐
|
|
|
|
+ // align: {
|
|
|
|
+ // component: TipIcons.Align,
|
|
|
|
+ // getVisible: (comp) => !comp.isPostioned() && !comp.isFullWidth(),
|
|
|
|
+ // getValue: (comp) =>
|
|
|
|
+ // ["start", "center", "end"].indexOf(comp.layout.alignSelf || "start"),
|
|
|
|
+ // onClick(comp) {
|
|
|
|
+ // const vals = ["start", "center", "end"];
|
|
|
|
+ // let index = vals.indexOf(comp.layout.alignSelf || "start");
|
|
|
|
+ // this.actions.setCompAlign(comp, vals[++index % 3]);
|
|
|
|
+ // },
|
|
|
|
+ // },
|
|
// 绝对定位
|
|
// 绝对定位
|
|
- position: {
|
|
|
|
- component: TipIcons.Position,
|
|
|
|
- getVisible(comp) {
|
|
|
|
- return this.helper.isCustomChildComp(comp);
|
|
|
|
- },
|
|
|
|
- getValue: (comp) => (comp.layout.position === "absolute" ? 1 : 0),
|
|
|
|
- onClick(comp) {
|
|
|
|
- this.actions.setCompPosition(comp);
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
|
|
+ // position: {
|
|
|
|
+ // component: TipIcons.Position,
|
|
|
|
+ // getVisible(comp) {
|
|
|
|
+ // return this.helper.isCustomChildComp(comp);
|
|
|
|
+ // },
|
|
|
|
+ // getValue: (comp) => (comp.layout.position === "absolute" ? 1 : 0),
|
|
|
|
+ // onClick(comp) {
|
|
|
|
+ // this.actions.setCompPosition(comp);
|
|
|
|
+ // },
|
|
|
|
+ // },
|
|
// 全屏尺寸
|
|
// 全屏尺寸
|
|
- fullWidth: {
|
|
|
|
- component: TipIcons.FullWidth,
|
|
|
|
- getVisible: (comp) => !comp.isTransformed && !comp.isFullWidth,
|
|
|
|
- onClick(comp) {
|
|
|
|
- this.actions.fullCompWidth(comp);
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
|
|
+ // fullWidth: {
|
|
|
|
+ // component: TipIcons.FullWidth,
|
|
|
|
+ // getVisible: (comp) => !comp.isTransformed && !comp.isFullWidth,
|
|
|
|
+ // onClick(comp) {
|
|
|
|
+ // this.actions.fullCompWidth(comp);
|
|
|
|
+ // },
|
|
|
|
+ // },
|
|
// 清除变换
|
|
// 清除变换
|
|
- clearTransform: {
|
|
|
|
- component: TipIcons.ClearTransform,
|
|
|
|
- getVisible: (comp) => comp.isTransformed(),
|
|
|
|
- onClick(comp) {
|
|
|
|
- this.actions.clearCompTransform(comp);
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
|
|
+ // clearTransform: {
|
|
|
|
+ // component: TipIcons.ClearTransform,
|
|
|
|
+ // getVisible: (comp) => comp.isTransformed(),
|
|
|
|
+ // onClick(comp) {
|
|
|
|
+ // this.actions.clearCompTransform(comp);
|
|
|
|
+ // },
|
|
|
|
+ // },
|
|
// 定位图层上移
|
|
// 定位图层上移
|
|
layerUp: {
|
|
layerUp: {
|
|
component: TipIcons.LayerUp,
|
|
component: TipIcons.LayerUp,
|
|
@@ -173,7 +174,7 @@ export const toolbars = createToolbars({
|
|
parentComp: {
|
|
parentComp: {
|
|
component: TipIcons.ParentComp,
|
|
component: TipIcons.ParentComp,
|
|
getVisible(comp) {
|
|
getVisible(comp) {
|
|
- return !this.helper.isCustomChildComp(comp);
|
|
|
|
|
|
+ return !this.helper.isCustomChildComp(comp as any);
|
|
},
|
|
},
|
|
onClick(comp) {
|
|
onClick(comp) {
|
|
this.actions.pickParentComp(comp.id);
|
|
this.actions.pickParentComp(comp.id);
|
|
@@ -183,10 +184,10 @@ export const toolbars = createToolbars({
|
|
saveAsComp: {
|
|
saveAsComp: {
|
|
component: TipIcons.SaveAsComp,
|
|
component: TipIcons.SaveAsComp,
|
|
getVisible(comp) {
|
|
getVisible(comp) {
|
|
- return this.helper.isShowSaveComp(comp);
|
|
|
|
|
|
+ return this.helper.isShowSaveComp(comp as any);
|
|
},
|
|
},
|
|
async onClick(comp) {
|
|
async onClick(comp) {
|
|
- await this.actions.saveAsComp(comp);
|
|
|
|
|
|
+ await this.actions.saveAsComp(comp as any);
|
|
this.controls.compUICtrl.init();
|
|
this.controls.compUICtrl.init();
|
|
},
|
|
},
|
|
},
|
|
},
|