diff --git a/src/canvas/Canvas.js b/src/canvas/Canvas.js index 2e03189..68b6ba3 100644 --- a/src/canvas/Canvas.js +++ b/src/canvas/Canvas.js @@ -1,5 +1,5 @@ import React from 'react'; -import { convertToArray } from '../converters'; +import { convertToArray, convertToTeX, convertToEG } from '../converters'; import Toolbox from './Toolbox'; import StepMenu from './StepMenu'; import EGVariable from './EGVariable'; @@ -10,6 +10,10 @@ import DropdownMenu from './DropdownMenu'; import config from './config'; import manipulate from './manipulate'; import { CSSTransitionGroup } from 'react-transition-group'; +// KATEX +import 'katex/dist/katex.min.css'; +import TeX from '@matejmazur/react-katex'; + const nanoid = require('nanoid').nanoid; /** @@ -105,7 +109,9 @@ class Canvas extends React.Component { doubleCutRemove: () => manipulate(this).doubleCutRemove(), doubleCutEnclose: () => manipulate(this).doubleCutEnclose(), doubleCutAdd: () => manipulate(this).doubleCutAdd(), - } + }, + formula: '', + fitchNotation: false } } @@ -247,7 +253,7 @@ class Canvas extends React.Component { currentStep.push(id); this.setState({ data }); } - + removeElement(id) { let { steps } = this.state; steps[this.state.currentStep].push(id); @@ -383,6 +389,8 @@ class Canvas extends React.Component { if (this.panzoom) zoomWithWheel = this.panzoom.zoomWithWheel // CSSTransitionGroup lets us have entry fade-in + let tex = convertToTeX(this.state.formula); + let eg = convertToEG(this.state.formula); return ( -
+
+

Formula to Insert

+ this.setState({ fitchNotation: !this.state.fitchNotation }) } /> +
+ {this.state.fitchNotation ? ( +
+ + + + + + + + +
+ this.setState({ formula: e.target.value }) } /> + + {tex && } +
+ To insert: {eg && } +
+ ) : ( +
+ this.setState({ formula: e.target.value }) } />
+ To insert: +
+ )} + + + + +
+
{ let { steps, currentStep, data } = this.state; let step = this.copyStep(steps[currentStep]); // If the insertID data is not in a subgraph of the copID data, return - if (!this.isInNestedGraph(step, insertID, copyID)) { + let parentID = this.findParent(step, copyID).id; + if (!this.isInNestedGraph(step, insertID, parentID)) { console.log("Insert selection is not in a subgraph of Copy selection"); return null; } @@ -44,6 +45,7 @@ module.exports = ({ state, getSelection, getInsertionPoint }) => { console.log("Insert ID could not be found in Iterate"); return null; } + console.log(copy) insert.data = insert.data.concat(copy); let newCopyID = copy; if (typeof copy !== 'string')