fix: TextContent autoHeight

This commit is contained in:
unanmed 2025-08-16 16:35:27 +08:00
parent 3b6b534211
commit 3aab8f3987
2 changed files with 7 additions and 7 deletions

View File

@ -18,10 +18,6 @@ const iconsProps = {
props: ['loc']
} satisfies SetupComponentOptions<IconsProps>;
type PathGenerator = (width: number, height: number) => Path2D;
type PadFn = (
divisor: number
) => [left: number, right: number, top: number, bottom: number];
type IconLoc = [
x: number,
y: number,
@ -30,6 +26,9 @@ type IconLoc = [
cx: number,
cy: number
];
type IconPad = [left: number, right: number, top: number, bottom: number];
type PathGenerator = (width: number, height: number) => Path2D;
type PadFn = (divisor: number) => IconPad;
/**
* @param loc
@ -51,7 +50,7 @@ function pad(
width: number,
height: number,
divisor: number
): [left: number, right: number, top: number, bottom: number] {
): IconPad {
return [
x + width / divisor, // left
x + width - width / divisor, // right

View File

@ -117,7 +117,7 @@ export const TextContent = defineComponent<
TextContentEmits,
keyof TextContentEmits
>((props, { emit, expose }) => {
const loc = ref<ElementLocator>(
const loc = shallowRef<ElementLocator>(
(props.loc?.slice() as ElementLocator) ?? []
);
@ -160,7 +160,8 @@ export const TextContent = defineComponent<
const updateLoc = () => {
const height = getHeight();
if (props.autoHeight) {
const [x = 0, y = 0, width = 200, , ax = 0, ay = 0] = loc.value;
const [x = 0, y = 0, width = props.width, , ax = 0, ay = 0] =
loc.value;
loc.value = [x, y, width, height, ax, ay];
}
emit('updateHeight', height);