|
|
|
@ -1,17 +1,15 @@
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import {onMounted, ref} from 'vue'
|
|
|
|
|
import { v4 as uuidv4 } from 'uuid'
|
|
|
|
|
import WrapperBox from '../components/WrapperBox.vue'
|
|
|
|
|
import {MathPage} from '../support/page'
|
|
|
|
|
import {MathStatement} from '../support/parse'
|
|
|
|
|
import Katex from '../components/Katex.vue'
|
|
|
|
|
import {EvaluationResult, hasOwnProperty, StatementID} from '../types'
|
|
|
|
|
import {EvaluationResult, hasOwnProperty} from '../types'
|
|
|
|
|
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";
|
|
|
|
|
import {RichTextBox} from '../types'
|
|
|
|
|
import { stepX, stepY } from '../support/const'
|
|
|
|
|
|
|
|
|
|
const math = new MathPage(uuidv4())
|
|
|
|
|
const statements = ref<MathStatement[]>([])
|
|
|
|
@ -49,6 +47,17 @@ const openNewExpressionModal = () => {
|
|
|
|
|
newExpressionModalOpen.value = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const editingStatement = ref<MathStatement|undefined>()
|
|
|
|
|
const editExpressionModalOpen = ref(false)
|
|
|
|
|
const openEditExpressionModal = () => {
|
|
|
|
|
editExpressionModalOpen.value = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const editVarDeclModalOpen = ref(false)
|
|
|
|
|
const openEditVarDeclModal = () => {
|
|
|
|
|
editVarDeclModalOpen.value = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const updateStatements = () => {
|
|
|
|
|
statements.value = math.getStatements()
|
|
|
|
|
try {
|
|
|
|
@ -92,6 +101,27 @@ const saveNewExpression = (stmt: MathStatement) => {
|
|
|
|
|
updateStatements()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const editStatement = (stmt: MathStatement) => {
|
|
|
|
|
editingStatement.value = stmt
|
|
|
|
|
if ( stmt.isDeclaration() ) {
|
|
|
|
|
openEditVarDeclModal()
|
|
|
|
|
} else if ( stmt.isFunctionDeclaration() ) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
openEditExpressionModal()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const removeStatement = (stmt: MathStatement) => {
|
|
|
|
|
math.removeStatement(stmt.id)
|
|
|
|
|
updateStatements()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const finishEditStatement = () => {
|
|
|
|
|
editExpressionModalOpen.value = false
|
|
|
|
|
updateStatements()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Rich Text Stuff
|
|
|
|
|
*/
|
|
|
|
@ -204,6 +234,8 @@ function richUpdateValue() {
|
|
|
|
|
:key="statementsKey"
|
|
|
|
|
:statement="statement"
|
|
|
|
|
:evaluation="evaluation"
|
|
|
|
|
v-on:edit="() => editStatement(statement)"
|
|
|
|
|
v-on:remove="() => removeStatement(statement)"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
@ -222,6 +254,20 @@ function richUpdateValue() {
|
|
|
|
|
/>
|
|
|
|
|
</q-dialog>
|
|
|
|
|
|
|
|
|
|
<q-dialog v-model="editExpressionModalOpen">
|
|
|
|
|
<ExpressionEditor
|
|
|
|
|
:statement="editingStatement"
|
|
|
|
|
v-on:save="() => finishEditStatement()"
|
|
|
|
|
/>
|
|
|
|
|
</q-dialog>
|
|
|
|
|
|
|
|
|
|
<q-dialog v-model="editVarDeclModalOpen">
|
|
|
|
|
<VarDeclEditor
|
|
|
|
|
:statement="editingStatement"
|
|
|
|
|
v-on:save="() => finishEditStatement()"
|
|
|
|
|
/>
|
|
|
|
|
</q-dialog>
|
|
|
|
|
|
|
|
|
|
<q-page-sticky position="bottom-right" :offset="[32, 32]">
|
|
|
|
|
<q-fab color="primary" icon="add" direction="left">
|
|
|
|
|
<q-fab-action
|
|
|
|
|