fixed dragability after new statment is added

qi
Thomas 2 years ago
parent 83374615aa
commit 8fbab92e1b

@ -1,20 +1,17 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { ref } from "vue";
import { RichTextBox } from "../types.ts"; import { RichTextBox } from "../types.ts";
import { stepX, stepY } from "../support/const.ts";
const props = defineProps({ const props = defineProps({
value: { value: {
type: RichTextBox, type: RichTextBox,
}, },
// statement: { type: String, required: true },
// startingX: { type: Number, default: 0 },
// startingY: { type: Number, default: 0 },
}); });
</script> </script>
<template> <template>
<Draggable <Draggable
:grid="[5, 5]" :grid="[stepX, stepY]"
:default-position="{ x: props.value.x, y: props.value.y }" :default-position="{ x: props.value.x, y: props.value.y }"
> >
<div style="display: flex; bottom: 10px; right: 0"> <div style="display: flex; bottom: 10px; right: 0">

@ -11,6 +11,7 @@ import VarDeclEditor from './VarDeclEditor.vue'
import ExpressionEditor from './ExpressionEditor.vue' import ExpressionEditor from './ExpressionEditor.vue'
import TextBox from '../components/TextBox.vue' import TextBox from '../components/TextBox.vue'
import {RichTextBox} from "../types.ts"; import {RichTextBox} from "../types.ts";
import { stepX, stepY } from "../support/const.ts";
const math = new MathPage(uuidv4()) const math = new MathPage(uuidv4())
const statements = ref<MathStatement[]>([]) const statements = ref<MathStatement[]>([])
@ -114,15 +115,18 @@ function richUpdateValue() {
<q-page-container id="editor" > <q-page-container id="editor" >
<!-- <WrapperBox />--> <!-- <WrapperBox />-->
<span v-for="statement in statements"> <span v-for="statement in statements" style="display: flex">
<Draggable <Draggable
:grid="[25, 25]" :grid="[stepX, stepY]"
> >
<div>
<Statement <Statement
:key="statementsKey" :key="statementsKey"
:statement="statement" :statement="statement"
:evaluation="evaluation" :evaluation="evaluation"
/> />
</div>
</Draggable> </Draggable>
</span> </span>

@ -0,0 +1,2 @@
export const stepX = 5
export const stepY = 5

@ -269,6 +269,9 @@ export class MathStatement {
/** The raw statement input by the user. */ /** The raw statement input by the user. */
public readonly raw: string, public readonly raw: string,
public x: Number = 0,
public y: Number = 0,
) {} ) {}
/** Parse the raw statement to an AST. */ /** Parse the raw statement to an AST. */

@ -98,5 +98,7 @@ export class RichTextBox {
public text: string = '', public text: string = '',
public x: Number = 0, public x: Number = 0,
public y: Number = 0, public y: Number = 0,
) {} ) {
}
} }
Loading…
Cancel
Save