Merge branch 'main' of github.com:hackku22/Mathy
This commit is contained in:
commit
1def341c03
@ -1,27 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
|
||||
import { RichTextBox } from "../types.ts";
|
||||
import { stepX, stepY } from "../support/const.ts";
|
||||
const props = defineProps({
|
||||
statement: { type: String, required: true },
|
||||
})
|
||||
value: {
|
||||
type: RichTextBox,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Draggable :grid="[25, 25]">
|
||||
<div style="display: flex">
|
||||
<Draggable
|
||||
:grid="[stepX, stepY]"
|
||||
:default-position="{ x: props.value.x, y: props.value.y }"
|
||||
>
|
||||
<div>
|
||||
<q-card flat bordered>
|
||||
<q-card-section style="padding:0">
|
||||
<q-card-section style="padding: 0">
|
||||
<div class="row items-center no-wrap">
|
||||
<q-card-section v-html="props.statement" />
|
||||
<q-card-section v-html="props.value.text" />
|
||||
<div class="col-auto">
|
||||
<q-btn color="grey-7" round flat icon="more_vert">
|
||||
<q-menu cover auto-close>
|
||||
<q-list>
|
||||
<q-item clickable>
|
||||
<q-item-section @click="() => $emit('edit')">Edit</q-item-section>
|
||||
<q-item-section @click="() => $emit('edit')"
|
||||
>Edit</q-item-section
|
||||
>
|
||||
</q-item>
|
||||
<q-item clickable>
|
||||
<q-item-section @click="() => $emit('remove')">Remove</q-item-section>
|
||||
<q-item-section @click="() => $emit('remove')"
|
||||
>Remove</q-item-section
|
||||
>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
|
@ -10,6 +10,8 @@ import Statement from '../components/Statement.vue'
|
||||
import VarDeclEditor from './VarDeclEditor.vue'
|
||||
import ExpressionEditor from './ExpressionEditor.vue'
|
||||
import TextBox from '../components/TextBox.vue'
|
||||
import {RichTextBox} from "../types.ts";
|
||||
import { stepX, stepY } from "../support/const.ts";
|
||||
|
||||
const math = new MathPage(uuidv4())
|
||||
const statements = ref<MathStatement[]>([])
|
||||
@ -95,10 +97,10 @@ const saveNewExpression = (stmt: MathStatement) => {
|
||||
*/
|
||||
|
||||
const richTextStatements = ref([
|
||||
{ text: "test" },
|
||||
{ text: "test2" },
|
||||
{ text: "test3" },
|
||||
]);
|
||||
new RichTextBox('newText'),
|
||||
new RichTextBox('newText', 0,100)
|
||||
|
||||
]);
|
||||
|
||||
const richEditModal = ref(false);
|
||||
const richEditExpression = ref("");
|
||||
@ -190,18 +192,21 @@ function richUpdateValue() {
|
||||
<!-- drawer content -->
|
||||
</q-drawer>
|
||||
|
||||
<q-page-container id="editor" style="display: flex">
|
||||
<q-page-container id="editor" >
|
||||
<!-- <WrapperBox />-->
|
||||
|
||||
<span v-for="statement in statements">
|
||||
<span v-for="statement in statements" style="display: flex">
|
||||
<Draggable
|
||||
:grid="[25, 25]"
|
||||
:grid="[stepX, stepY]"
|
||||
>
|
||||
<div>
|
||||
<Statement
|
||||
:key="statementsKey"
|
||||
:statement="statement"
|
||||
:evaluation="evaluation"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</Draggable>
|
||||
</span>
|
||||
|
||||
@ -245,12 +250,13 @@ function richUpdateValue() {
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
<span v-for="(item, index) in richTextStatements">
|
||||
<div v-for="(item, index) in richTextStatements" style="display: flex">
|
||||
<TextBox
|
||||
:statement="item.text"
|
||||
:value="item"
|
||||
v-on:edit="() => (item.text ? richEditStatement(index) : {})"
|
||||
></TextBox>
|
||||
</span>
|
||||
/>
|
||||
|
||||
</div>
|
||||
</q-page-container>
|
||||
|
||||
<q-footer reveal elevated class="bg-grey-8 text-white">
|
||||
|
2
src/support/const.ts
Normal file
2
src/support/const.ts
Normal file
@ -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. */
|
||||
public readonly raw: string,
|
||||
|
||||
public x: Number = 0,
|
||||
public y: Number = 0,
|
||||
) {}
|
||||
|
||||
/** Parse the raw statement to an AST. */
|
||||
|
11
src/types.ts
11
src/types.ts
@ -91,3 +91,14 @@ export interface EvaluationResult {
|
||||
variables: Record<VariableName, any>
|
||||
statements: Record<StatementID, any>
|
||||
}
|
||||
|
||||
|
||||
export class RichTextBox {
|
||||
constructor(
|
||||
public text: string = '',
|
||||
public x: Number = 0,
|
||||
public y: Number = 0,
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user