Skip to content

Commit 4a4334d

Browse files
committed
[#164] Code refactoring
1 parent 377b8f2 commit 4a4334d

File tree

174 files changed

+1052
-910
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+1052
-910
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"resize-observer-polyfill": "^1.5.1",
7272
"store": "^2.0.12",
7373
"uuid": "^7.0.3",
74+
"uuidv4": "^6.2.8",
7475
"warning": "^4.0.3"
7576
},
7677
"devDependencies": {
@@ -94,6 +95,7 @@
9495
"@types/react-helmet": "^5.0.15",
9596
"@types/uuid": "^7.0.2",
9697
"@types/warning": "^3.0.0",
98+
"@types/webpack-env": "^1.16.0",
9799
"babel-eslint": "^10.1.0",
98100
"babel-loader": "^8.1.0",
99101
"babel-plugin-dynamic-import-webpack": "^1.1.0",

src/containers/App.tsx renamed to src/App.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import React, { Component } from 'react';
22
import { Helmet } from 'react-helmet';
33

4-
import ImageMapEditor from '../components/imagemap/ImageMapEditor';
5-
import WorkflowEditor from '../components/workflow/WorkflowEditor';
6-
import Title from './Title';
7-
import FlowEditor from '../components/flow/FlowEditor';
8-
import FlowContainer from './FlowContainer';
9-
import HexGrid from '../components/hexgrid/HexGrid';
4+
import Title from './components/layout/Title';
5+
import FlowContainer from './containers/FlowContainer';
6+
import { FiberEditor, FlowEditor, HexGridEditor, ImageMapEditor, WorkflowEditor } from './editors';
107

11-
type EditorType = 'imagemap' | 'workflow' | 'flow' | 'hexgrid';
8+
type EditorType = 'imagemap' | 'workflow' | 'flow' | 'hexgrid' | 'fiber';
129

1310
interface IState {
1411
activeEditor?: EditorType;
@@ -19,7 +16,7 @@ class App extends Component<any, IState> {
1916
activeEditor: 'imagemap',
2017
};
2118

22-
onChangeMenu = ({ key }) => {
19+
handleChangeEditor = ({ key }) => {
2320
this.setState({
2421
activeEditor: key,
2522
});
@@ -34,7 +31,9 @@ class App extends Component<any, IState> {
3431
case 'flow':
3532
return <FlowEditor />;
3633
case 'hexgrid':
37-
return <HexGrid />;
34+
return <HexGridEditor />;
35+
case 'fiber':
36+
return <FiberEditor />;
3837
}
3938
};
4039

@@ -65,7 +64,7 @@ class App extends Component<any, IState> {
6564
<script async={true} src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" />
6665
</Helmet>
6766
<div className="rde-title">
68-
<Title onChangeMenu={this.onChangeMenu} current={activeEditor} />
67+
<Title onChangeEditor={this.handleChangeEditor} currentEditor={activeEditor} />
6968
</div>
7069
<FlowContainer>
7170
<div className="rde-content">{this.renderEditor(activeEditor)}</div>

src/components/canvas/Canvas.tsx renamed to src/canvas/Canvas.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import React, { Component } from 'react';
22
import { fabric } from 'fabric';
3-
import { v4 } from 'uuid';
43
import ResizeObserver from 'resize-observer-polyfill';
5-
64
import Handler, { HandlerOptions } from './handlers/Handler';
75
import { FabricCanvas } from './utils';
86
import { defaults } from './constants';
7+
import { uuid } from 'uuidv4';
98

10-
import '../../styles/core/canvas.less';
11-
import '../../styles/core/tooltip.less';
12-
import '../../styles/core/contextmenu.less';
13-
import '../../styles/fabricjs/fabricjs.less';
9+
import '../styles/core/canvas.less';
10+
import '../styles/core/tooltip.less';
11+
import '../styles/core/contextmenu.less';
12+
import '../styles/fabricjs/fabricjs.less';
1413

1514
export type CanvasProps = HandlerOptions & {
1615
responsive?: boolean;
@@ -29,7 +28,7 @@ class Canvas extends Component<CanvasProps, IState> {
2928
public container = React.createRef<HTMLDivElement>();
3029
private resizeObserver: ResizeObserver;
3130
static defaultProps: CanvasProps = {
32-
id: v4(),
31+
id: uuid(),
3332
editable: true,
3433
zoomEnabled: true,
3534
minZoom: 30,
@@ -40,7 +39,7 @@ class Canvas extends Component<CanvasProps, IState> {
4039
};
4140

4241
state: IState = {
43-
id: v4(),
42+
id: uuid(),
4443
loaded: false,
4544
};
4645

File renamed without changes.

src/components/canvas/global.d.ts renamed to src/canvas/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ declare module 'fabric/fabric-impl' {
2525
declare global {
2626
interface Window {
2727
gifler: any;
28+
adsbygoogle: any;
2829
}
2930
}

0 commit comments

Comments
 (0)