<script>
import Moveable from "vue3-moveable";
import { ref } from "vue";

export default {
    components: { Moveable },
    setup() {
        const containerScale = "$preview_containerScale";
        const targetRef = ref(null);
        const onRender = e => {
            e.target.style.cssText += e.cssText;
        };
        return { containerScale, targetRef, onRender };
    }
};
</script>
<template>
    <div
        class="root"
        style="padding-left: 100px;padding-top: 100px;"
    >
        <div
            class="container"
            :style="`transform-origin: 0 0;transform: ${`scale(${containerScale})`};`"
        >
            <svg
                viewBox="0 0 200 200"
                style="border: 1px solid black;width: 200px;height: 200px;"
            >
                <line
                    x1="0"
                    y1="80"
                    x2="100"
                    y2="80"
                    strokeWidth="4"
                    stroke="black"
                    ref="targetRef"/>
            </svg>
            <Moveable
                :target="targetRef"
                :draggable="true"
                :rotatable="true"
                :scalable="true"
                @render="onRender"
            ></Moveable>
        </div>
    </div>
</template>