Skip to content

Commit d1c5a2c

Browse files
committed
removed event listener and isObjectType
1 parent 15d6a3f commit d1c5a2c

File tree

7 files changed

+15
-29
lines changed

7 files changed

+15
-29
lines changed

app/src/components/bottom/CodePreview.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import 'ace-builds/src-noconflict/theme-solarized_dark';
88
import 'ace-builds/src-noconflict/theme-solarized_light';
99
import 'ace-builds/src-noconflict/theme-terminal';
1010
import { Component } from '../../interfaces/Interfaces';
11+
import { EditorState } from 'draft-js';
12+
import { Editor } from 'react-draft-wysiwyg';
1113
import useResizeObserver from '../../tree/useResizeObserver';
1214
import { string } from 'prop-types';
1315

@@ -26,9 +28,10 @@ const CodePreview: React.FC<{
2628
(elem: Component) => elem.id === state.canvasFocus.componentId
2729
);
2830

29-
const handleCodeSnipChange = val => {
31+
const handleCodeSnipChange = (val) => {
3032
currentComponent.code = val;
3133
};
34+
3235
useEffect(() => {
3336
setDivHeight(height);
3437
}, [height])
@@ -40,7 +43,6 @@ const CodePreview: React.FC<{
4043
height: '100%',
4144
maxWidth: '100%',
4245
justifyContent: 'center',
43-
4446
}}
4547
>
4648
<AceEditor

app/src/components/main/Canvas.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function Canvas() {
3232
// make a deep clone of state
3333
const deepCopiedState = JSON.parse(JSON.stringify(state));
3434
state.past.push(deepCopiedState.components[0].children);
35+
3536
};
3637

3738
// This hook will allow the user to drag items from the left panel on to the canvas

app/src/components/main/DirectChildHTML.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function DirectChildHTML({
1414
type,
1515
typeId,
1616
style,
17+
value,
1718
}: ChildElement) {
1819
const [state, dispatch] = useContext(StateContext);
1920
const ref = useRef(null);

app/src/containers/RightContainer.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ const RightContainer = ({isThemeLight}): JSX.Element => {
4949
const style = configTarget.child
5050
? configTarget.child.style
5151
: configTarget.style;
52-
console.log('styleContext style', style)
5352
setDisplayMode(style.display ? style.display : '');
5453
setFlexDir(style.flexDirection ? style.flexDirection : '');
5554
setFlexJustify(style.justifyContent ? style.justifyContent : '');
@@ -68,7 +67,7 @@ const RightContainer = ({isThemeLight}): JSX.Element => {
6867
// handles all input field changes, with specific updates called based on input's name
6968
const handleChange = (e: React.ChangeEvent<{ value: any }>) => {
7069
let inputVal = e.target.value;
71-
console.log('inputVal', inputVal)
70+
7271
switch (e.target.name) {
7372
case 'display':
7473
setDisplayMode(inputVal);
@@ -213,9 +212,6 @@ const undoRedoKey = useCallback((e) => {
213212

214213
useEffect(() => {
215214
document.addEventListener("keydown", undoRedoKey);
216-
return () => {
217-
document.removeEventListener("keydown", undoRedoKey);
218-
};
219215
}, []);
220216

221217
// placeholder for handling deleting instance

app/src/helperFunctions/generateCode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React, {useContext, useRef, useState} from 'react';
2+
import StateContext from '../context/context';
13
import {
24
Component,
35
State,
@@ -69,7 +71,6 @@ const generateUnformattedCode = (
6971
});
7072
return enrichedChildren;
7173
};
72-
7374
// write all code that will be under the "return" of the component
7475
const writeNestedElements = (enrichedChildren: any) => {
7576
return `${enrichedChildren
@@ -175,7 +176,6 @@ const generateUnformattedCode = (
175176
${classBased ? `import React, {Component} from 'react';` : ''}
176177
${!stateful && !classBased ? `import React from 'react';` : ''}
177178
${importsMapped}
178-
179179
${
180180
classBased
181181
? `class ${currentComponent.name} extends Component {`

app/src/interfaces/Interfaces.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ export interface State {
1717
future: any[];
1818
}
1919

20-
export interface PastElement {
21-
type: string;
22-
typeId: number;
23-
name: string;
24-
childId: number;
25-
style: object;
26-
attributes?: object;
27-
children?: PastElement[];
28-
}
29-
3020
export interface ChildElement {
3121
type: string;
3222
typeId: number;
@@ -36,7 +26,6 @@ export interface ChildElement {
3626
attributes?: object;
3727
children?: ChildElement[];
3828
}
39-
4029
export interface Component {
4130
id: number;
4231
name: string;

app/src/reducers/componentReducer.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
import initialState from '../context/initialState';
99
import generateCode from '../helperFunctions/generateCode';
1010
import manageSeparators from '../helperFunctions/manageSeparators';
11-
import { isObjectType } from 'graphql';
1211

1312
let separator = initialState.HTMLTypes[1];
1413

@@ -210,7 +209,7 @@ const reducer = (state: State, action: Action) => {
210209
style: {},
211210
code: '',
212211
children: [],
213-
isPage: action.payload.root
212+
isPage: action.payload.root,
214213
};
215214
components.push(newComponent);
216215

@@ -238,7 +237,7 @@ const reducer = (state: State, action: Action) => {
238237
const {
239238
type,
240239
typeId,
241-
childId
240+
childId,
242241
}: { type: string; typeId: number; childId: any } = action.payload;
243242

244243
const parentComponentId: number = state.canvasFocus.componentId;
@@ -286,15 +285,16 @@ const reducer = (state: State, action: Action) => {
286285
name: newName,
287286
childId: state.nextChildId,
288287
style: {},
289-
children: componentChildren
288+
children: componentChildren,
289+
290290
};
291291
const topSeparator: ChildElement = {
292292
type: 'HTML Element',
293293
typeId: separator.id,
294294
name: 'separator',
295295
childId: state.nextTopSeparatorId,
296296
style: separator.style,
297-
children: []
297+
children: [],
298298
};
299299

300300

@@ -620,8 +620,6 @@ const reducer = (state: State, action: Action) => {
620620
state.components[0].children = state.past[state.past.length-1];
621621
//the last element of past array gets pushed into future;
622622
state.future.push(state.past.pop());
623-
624-
console.log('state in undo', state)
625623
//generate code for the Code Preview
626624
state.components.forEach((el, i) => {
627625
el.code = generateCode(
@@ -643,8 +641,6 @@ const reducer = (state: State, action: Action) => {
643641
state.components[0].children = state.future[state.future.length - 1];
644642
//the last element of the future array gets pushed into the past array and the last element of the future array gets popped off
645643
state.past.push(state.future.pop());
646-
647-
console.log('state in redo', state)
648644
//generate code for the Code Preview
649645
state.components.forEach((el, i) => {
650646
el.code = generateCode(
@@ -659,6 +655,7 @@ const reducer = (state: State, action: Action) => {
659655
...state
660656
};
661657
}
658+
case 'CHANGEDVALUE': {}
662659

663660
default:
664661
return state;

0 commit comments

Comments
 (0)