123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <template>
- <TempComponent
- :data="tData"
- :ref="(v: any) => shape = v?.shape"
- :id="data.id"
- @update-content="updateContent"
- />
- <PropertyUpdate
- :describes="describes"
- :data="data"
- :target="shape"
- @change="emit('updateShape', { ...data })"
- />
- <Operate :target="shape" :menus="operateMenus" />
- </template>
- <script lang="ts" setup>
- import { SerialData, getMouseStyle, defaultStyle, matResponse } from "./index.ts";
- import { PropertyUpdate, Operate } from "../../html-mount/propertys/index.ts";
- import { TempComponent } from "./";
- import { useComponentStatus } from "@/core/hook/use-component.ts";
- import { Transform } from "konva/lib/Util";
- import { cloneRepShape, useCustomTransformer } from "@/core/hook/use-transformer.ts";
- import { Ellipse } from "konva/lib/shapes/Ellipse";
- import { Pos } from "@/utils/math.ts";
- const props = defineProps<{ data: SerialData }>();
- const emit = defineEmits<{
- (e: "updateShape", value: SerialData): void;
- (e: "addShape", value: SerialData): void;
- (e: "delShape"): void;
- }>();
- const updateContent = (val: string) => {
- data.value.content = val;
- emit("updateShape", { ...data.value });
- };
- const { shape, tData, data, operateMenus, describes } = useComponentStatus<
- Ellipse,
- SerialData
- >({
- emit,
- props,
- getMouseStyle,
- defaultStyle,
- alignment: (data, mat) => {
- return matResponse({ mat: mat.multiply(new Transform(data.mat)), data });
- },
- transformType: "custom",
- customTransform(callback, shape, data) {
- let initRadius: Pos;
- useCustomTransformer(shape, data, {
- openSnap: true,
- getRepShape($shape) {
- const repShape = cloneRepShape($shape).shape;
- initRadius = { x: repShape.radiusX(), y: repShape.radiusY() };
- return {
- shape: repShape,
- };
- },
- // beforeHandler(data, mat) {
- // return matToData(copy(data), mat);
- // },
- handler(data, mat) {
- matResponse({ data, mat }, initRadius);
- return true;
- },
- callback,
- transformerConfig: {
- rotateEnabled: false,
- enabledAnchors: ["top-left", "top-right", "bottom-left", "bottom-right"],
- },
- });
- },
- copyHandler(mat, data) {
- return matResponse({ data, mat: mat.multiply(new Transform(data.mat)) });
- },
- propertys: [
- "fill",
- "stroke",
- "fontColor",
- "strokeWidth",
- // "fontSize",
- // "ref",
- "opacity",
- "dash",
- // "zIndex"
- "fontStyle",
- // "ref", "zIndex"
- ],
- });
- </script>
|