Files
ui/src/components/TextBox.vue

74 lines
2.0 KiB
Vue
Raw Normal View History

2022-04-09 16:12:24 -05:00
<script setup lang="ts">
import { ref } from "vue";
2022-04-09 20:12:43 -05:00
import { RichTextBox } from "../support/types";
import { stepX, stepY } from "../support/const";
const props = defineProps<{ value: RichTextBox }>();
2022-04-09 20:12:43 -05:00
2022-04-09 23:45:17 -05:00
const emit = defineEmits<{
(eventName: 'move', x: number, y: number): void,
2022-04-10 00:11:49 -05:00
(eventName: 'edit',): void,
(eventName: 'remove',): void,
2022-04-09 23:45:17 -05:00
}>()
function onControlledDrag(e: { event: MouseEvent, data: { x: number, y: number } }) {
2022-04-10 00:11:49 -05:00
// const x = e.x;
// const y = e.y;
const { x, y } = e.data;
props.value.x = x;
props.value.y = y;
console.log(e)
2022-04-09 23:45:17 -05:00
}
function onControlledDragStop(e: { event: MouseEvent, data: { x: number, y: number } }) {
2022-04-10 00:11:49 -05:00
// console.log(typeof(e))
const { x, y } = e.data;
// const x = e.x;
// const y = e.y;
console.log(self)
emit('move', x, y);
2022-04-09 23:45:17 -05:00
onControlledDrag(e);
}
2022-04-09 16:12:24 -05:00
</script>
<template>
2022-04-09 18:41:57 -05:00
<Draggable
:grid="[stepX, stepY]"
2022-04-09 18:41:57 -05:00
:default-position="{ x: props.value.x, y: props.value.y }"
2022-04-09 23:45:17 -05:00
:position="{ x: props.value.x, y: props.value.y }"
@stop="onControlledDragStop"
2022-04-09 18:41:57 -05:00
>
2022-04-09 19:08:49 -05:00
<div>
2022-04-09 16:12:24 -05:00
<q-card flat bordered>
2022-04-09 18:41:57 -05:00
<q-card-section style="padding: 0">
2022-04-09 16:12:24 -05:00
<div class="row items-center no-wrap">
2022-04-09 18:41:57 -05:00
<q-card-section v-html="props.value.text" />
2022-04-09 16:12:24 -05:00
<div class="col-auto">
<q-btn color="grey-7" round flat icon="more_vert">
<q-menu cover auto-close>
<q-list>
<q-item clickable>
2022-04-10 00:11:49 -05:00
<q-item-section @click="() => $emit('edit')">
<q-item-label>Edit</q-item-label>
</q-item-section>
2022-04-09 16:12:24 -05:00
</q-item>
<q-item clickable>
<q-item-section @click="() => $emit('remove')">Remove</q-item-section>
2022-04-09 16:12:24 -05:00
</q-item>
</q-list>
</q-menu>
</q-btn>
</div>
</div>
</q-card-section>
</q-card>
</div>
</Draggable>
</template>
<style lang="sass" scoped>
</style>