|
@@ -9,6 +9,7 @@ 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";
|
|
|
+import { DesignComp } from "@/modules/editor/objects/DesignTemp/DesignComp";
|
|
|
|
|
|
export const Component = defineComponent({
|
|
|
props: {
|
|
@@ -16,7 +17,7 @@ export const Component = defineComponent({
|
|
|
},
|
|
|
setup(props) {
|
|
|
const comp = useCompData<CompTextObj>(props.compId);
|
|
|
- const { store, actions, controls , helper} = useEditor();
|
|
|
+ const { store, actions, controls, helper } = useEditor();
|
|
|
|
|
|
const state = reactive({
|
|
|
editableId: "",
|
|
@@ -34,18 +35,17 @@ export const Component = defineComponent({
|
|
|
}
|
|
|
|
|
|
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() )
|
|
|
+ //样式的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 currWidth = w * t.scale.x;
|
|
|
const textWidth = currWidth / t.scale.y;
|
|
|
|
|
|
const width = helper.designToNaturalSize(currWidth);
|
|
@@ -55,40 +55,50 @@ export const Component = defineComponent({
|
|
|
//m x m1 = m
|
|
|
|
|
|
return (
|
|
|
- <View
|
|
|
- class={[textStyle]}
|
|
|
- compId={props.compId}
|
|
|
- onDblclick={() => {
|
|
|
- if (store.isEditMode) {
|
|
|
- state.editableId = "" + Date.now();
|
|
|
- }
|
|
|
- }}
|
|
|
- >
|
|
|
-
|
|
|
- <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);
|
|
|
- }}
|
|
|
- />
|
|
|
- ) : (
|
|
|
+ <View
|
|
|
+ class={[textStyle]}
|
|
|
+ compId={props.compId}
|
|
|
+ onDblclick={() => {
|
|
|
+ if (store.isEditMode) {
|
|
|
+ state.editableId = "" + Date.now();
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ style={{
|
|
|
+ width: width,
|
|
|
+ transform: `${m.getMatrixStr()}`,
|
|
|
+ transformOrigin: "0 0",
|
|
|
+ }}
|
|
|
+ >
|
|
|
<div
|
|
|
- innerHTML={comp.value.text}
|
|
|
- id={`editor_${props.compId}`}
|
|
|
- class={[textStyle, store.isEditMode && `pointer-events-none`]}
|
|
|
- />
|
|
|
- )}
|
|
|
-
|
|
|
+ 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>
|
|
|
- </div>
|
|
|
-
|
|
|
- </View>
|
|
|
- )};
|
|
|
+ </View>
|
|
|
+ );
|
|
|
+ };
|
|
|
},
|
|
|
});
|
|
|
|
|
@@ -123,7 +133,7 @@ const EditorComp = defineComponent({
|
|
|
const isChange = Math.abs(preHeight.value - h) > 1;
|
|
|
preHeight.value = h;
|
|
|
if (isChange) {
|
|
|
- const size :any = comp.layout.size.slice(0);
|
|
|
+ const size: any = comp.layout.size.slice(0);
|
|
|
size[1] = h;
|
|
|
comp.layout.size = size;
|
|
|
helper.extendStreamCard(page.currStreamCardId);
|
|
@@ -191,6 +201,7 @@ const EditorComp = defineComponent({
|
|
|
document.removeEventListener("mousedown", blur, { capture: true });
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
const initEditor = async () => {
|
|
|
// const dom: HTMLElement | null = document.querySelector(
|
|
|
// `#editor_${props.compId}`
|
|
@@ -223,8 +234,22 @@ const EditorComp = defineComponent({
|
|
|
preHeight.value = h;
|
|
|
|
|
|
if (isChange) {
|
|
|
- const size: any = comp.layout.size.slice(0);
|
|
|
- gizmo.selected[0].setSize(helper.designSizeToPx(size[0]), helper.designSizeToPx(h))
|
|
|
+ const size: any = comp.layout.size.slice(0);
|
|
|
+ if (
|
|
|
+ gizmo.selected.length == 1 &&
|
|
|
+ gizmo.selected[0].comp.compKey == "Group"
|
|
|
+ ) {
|
|
|
+ // 组内文本组件,更新组高度
|
|
|
+ const currentComp = helper.findComp(props.compId);
|
|
|
+ if (!currentComp) return;
|
|
|
+ currentComp.setSize(size[0], h);
|
|
|
+ helper.updateGroups(props.compId);
|
|
|
+ } else {
|
|
|
+ gizmo.selected[0].setSize(
|
|
|
+ helper.designSizeToPx(size[0]),
|
|
|
+ helper.designSizeToPx(h)
|
|
|
+ );
|
|
|
+ }
|
|
|
helper.extendStreamCard(page.currStreamCardId);
|
|
|
}
|
|
|
});
|