|
@@ -7,13 +7,16 @@ import { View } from "../View";
|
|
|
import HeadlessEditor from "./EditorCustom";
|
|
|
import { useCompData } from "../../defines/hook";
|
|
|
import { CompTextObj } from ".";
|
|
|
+import { Matrix } from "@/modules/editor/controllers/SelectCtrl/matrix";
|
|
|
+import { Transform } from "@/modules/editor/controllers/SelectCtrl/objects/transform";
|
|
|
+
|
|
|
export const Component = defineComponent({
|
|
|
props: {
|
|
|
compId: string().def(""),
|
|
|
},
|
|
|
setup(props) {
|
|
|
const comp = useCompData<CompTextObj>(props.compId);
|
|
|
- const { store, actions, controls } = useEditor();
|
|
|
+ const { store, actions, controls , helper} = useEditor();
|
|
|
|
|
|
const state = reactive({
|
|
|
editableId: "",
|
|
@@ -30,7 +33,28 @@ export const Component = defineComponent({
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- return () => (
|
|
|
+ return () => {
|
|
|
+
|
|
|
+ //样式的scale转 width
|
|
|
+ const m = Matrix.createFromMatrixStr(comp.layout.transformMatrix);
|
|
|
+ const t = new Transform();
|
|
|
+ t.setFromMatrix(m);
|
|
|
+ m.ty = 0
|
|
|
+ m.tx = 0
|
|
|
+ m.rotate( -m.getRotate() )
|
|
|
+
|
|
|
+ const [w, h] = comp.layout.size;
|
|
|
+
|
|
|
+ const currWidth = w * t.scale.x
|
|
|
+ const textWidth = currWidth / t.scale.y;
|
|
|
+
|
|
|
+ const width = helper.designToNaturalSize(currWidth);
|
|
|
+ const textWidthSize = helper.designToNaturalSize(textWidth);
|
|
|
+ // const height = helper.designToNaturalSize(h * t.scale.y);
|
|
|
+ m.invert();
|
|
|
+ //m x m1 = m
|
|
|
+
|
|
|
+ return (
|
|
|
<View
|
|
|
class={[textStyle]}
|
|
|
compId={props.compId}
|
|
@@ -40,24 +64,31 @@ export const Component = defineComponent({
|
|
|
}
|
|
|
}}
|
|
|
>
|
|
|
- {state.editableId ? (
|
|
|
- <EditorComp
|
|
|
- compId={props.compId}
|
|
|
- key={state.editableId}
|
|
|
- onLost={() => {
|
|
|
- state.editableId = "";
|
|
|
- controls.textEditorCtrl.setCurrEditor(null);
|
|
|
- }}
|
|
|
- />
|
|
|
- ) : (
|
|
|
- <div
|
|
|
- innerHTML={comp.value.text}
|
|
|
- id={`editor_${props.compId}`}
|
|
|
- class={[textStyle, store.isEditMode && `pointer-events-none`]}
|
|
|
- />
|
|
|
- )}
|
|
|
+
|
|
|
+ <div style={{width: width, transform:`${m.getMatrixStr()}`, transformOrigin: "0 0"}}>
|
|
|
+ <div style={{width:textWidthSize, transform:`scale(${t.scale.y})`, transformOrigin: "0 0"}}>
|
|
|
+ {state.editableId ? (
|
|
|
+ <EditorComp
|
|
|
+ compId={props.compId}
|
|
|
+ key={state.editableId}
|
|
|
+ onLost={() => {
|
|
|
+ state.editableId = "";
|
|
|
+ controls.textEditorCtrl.setCurrEditor(null);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ ) : (
|
|
|
+ <div
|
|
|
+ innerHTML={comp.value.text}
|
|
|
+ id={`editor_${props.compId}`}
|
|
|
+ class={[textStyle, store.isEditMode && `pointer-events-none`]}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
</View>
|
|
|
- );
|
|
|
+ )};
|
|
|
},
|
|
|
});
|
|
|
|