|
@@ -1,10 +1,7 @@
|
|
|
-import { TransferCtrl } from "@/modules/editor/controllers/TransferCtrl";
|
|
|
+import { CompToolbars } from "@/modules/editor/objects/EditingCompTools";
|
|
|
import { css } from "@linaria/core";
|
|
|
-import { defineComponent, onMounted, ref } from "vue";
|
|
|
+import { defineComponent, onMounted, onUnmounted } from "vue";
|
|
|
import { useEditor } from "../../../..";
|
|
|
-import { string } from "vue-types";
|
|
|
-import { CompToolbars } from "@/modules/editor/objects/EditingCompTools";
|
|
|
-import { DesignComp } from "@/modules/editor/objects/DesignTemp/DesignComp";
|
|
|
|
|
|
const btnStyles = {
|
|
|
top: {
|
|
@@ -30,42 +27,65 @@ const btnStyles = {
|
|
|
};
|
|
|
|
|
|
export const Transfer = defineComponent({
|
|
|
- props: {
|
|
|
- compId: string().isRequired,
|
|
|
- },
|
|
|
- setup(props) {
|
|
|
- const transferRef = ref();
|
|
|
+ setup() {
|
|
|
const editor = useEditor();
|
|
|
- const transferCtrl = new TransferCtrl(editor);
|
|
|
+ const { store } = editor;
|
|
|
+ const { transferCtrl } = editor.controls;
|
|
|
+ const { transferStyle } = transferCtrl;
|
|
|
|
|
|
onMounted(() => {
|
|
|
- transferCtrl.init(
|
|
|
- transferRef.value.parentElement as HTMLElement,
|
|
|
- props.compId
|
|
|
- );
|
|
|
+ setTimeout(() => {
|
|
|
+ transferCtrl.init();
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ onUnmounted(() => {
|
|
|
+ transferCtrl.resetStyle();
|
|
|
});
|
|
|
|
|
|
return () => {
|
|
|
- const comp = editor.helper.findComp(props.compId) as DesignComp;
|
|
|
+ const comp = store.currComp;
|
|
|
return (
|
|
|
- <div ref={transferRef}>
|
|
|
- <div class={toolbarStyle}>
|
|
|
- {CompToolbars.default.map((item, i) => {
|
|
|
- return (
|
|
|
- <item.component
|
|
|
- class="p-4px"
|
|
|
- value={item.value?.(comp)}
|
|
|
- onClick={() => item.onClick.call(editor, comp)}
|
|
|
- />
|
|
|
- );
|
|
|
- })}
|
|
|
- </div>
|
|
|
- <div class={borderStyle}></div>
|
|
|
+ transferStyle.width && (
|
|
|
<div
|
|
|
- class={[resizeStyle, "drag-disable"]}
|
|
|
- onMousedown={(e) => transferCtrl.mousedown(e, "resize")}
|
|
|
- ></div>
|
|
|
- {Object.entries(btnStyles).map(([name, style]) => (
|
|
|
+ class={rootStyle}
|
|
|
+ style={{
|
|
|
+ top: transferStyle.top,
|
|
|
+ left: transferStyle.left,
|
|
|
+ width: transferStyle.width,
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <div class={toolbarStyle}>
|
|
|
+ {CompToolbars.default.map((item, i) => {
|
|
|
+ return (
|
|
|
+ <item.component
|
|
|
+ class="p-4px"
|
|
|
+ value={item.value?.(comp)}
|
|
|
+ onClick={() => item.onClick.call(editor, comp)}
|
|
|
+ />
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ class={borderStyle}
|
|
|
+ style={{
|
|
|
+ width: transferStyle.width,
|
|
|
+ height: transferStyle.height,
|
|
|
+ }}
|
|
|
+ ></div>
|
|
|
+ <div
|
|
|
+ class={resizeStyle}
|
|
|
+ style={{ marginBottom: "-" + transferStyle.height }}
|
|
|
+ onMousedown={(e) => transferCtrl.mousedown(e, "resize")}
|
|
|
+ ></div>
|
|
|
+ <div
|
|
|
+ class={offsetBtnStyle}
|
|
|
+ style={{ marginBottom: "-" + transferStyle.height }}
|
|
|
+ onMousedown={(e) => transferCtrl.mousedown(e, "offset")}
|
|
|
+ >
|
|
|
+ +
|
|
|
+ </div>
|
|
|
+ {/* {Object.entries(btnStyles).map(([name, style]) => (
|
|
|
<div
|
|
|
class={[fanBtnStyle, "drag-disable"]}
|
|
|
style={style}
|
|
@@ -78,13 +98,18 @@ export const Transfer = defineComponent({
|
|
|
>
|
|
|
↑
|
|
|
</div>
|
|
|
- ))}
|
|
|
- </div>
|
|
|
+ ))} */}
|
|
|
+ </div>
|
|
|
+ )
|
|
|
);
|
|
|
};
|
|
|
},
|
|
|
});
|
|
|
|
|
|
+const rootStyle = css`
|
|
|
+ position: absolute;
|
|
|
+`;
|
|
|
+
|
|
|
const borderStyle = css`
|
|
|
position: absolute;
|
|
|
top: 0;
|
|
@@ -113,6 +138,27 @@ const resizeStyle = css`
|
|
|
}
|
|
|
`;
|
|
|
|
|
|
+const offsetBtnStyle = css`
|
|
|
+ position: absolute;
|
|
|
+ bottom: 0;
|
|
|
+ left: 50%;
|
|
|
+ width: 30px;
|
|
|
+ height: 30px;
|
|
|
+ border-radius: 50%;
|
|
|
+ background-color: #fff;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 30px;
|
|
|
+ font-size: 16px;
|
|
|
+ z-index: 9;
|
|
|
+ transform: translate(-50%, 40px);
|
|
|
+
|
|
|
+ @apply shadow cursor-move;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ background-color: @inf-primary-color;
|
|
|
+ }
|
|
|
+`;
|
|
|
+
|
|
|
const fanBtnStyle = css`
|
|
|
position: absolute;
|
|
|
width: 30px;
|
|
@@ -135,5 +181,5 @@ const toolbarStyle = css`
|
|
|
position: absolute;
|
|
|
top: 0;
|
|
|
left: 50%;
|
|
|
- transform: translate(-50%, -60px);
|
|
|
+ transform: translate(-50%, -40px);
|
|
|
`;
|