Skip to content

Commit

Permalink
[#236] code is being cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
salgum1114 committed Aug 15, 2022
1 parent b70f6f9 commit d8fbcf9
Show file tree
Hide file tree
Showing 96 changed files with 585 additions and 532 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
lib
74 changes: 36 additions & 38 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
{
"parser": "babel-eslint",
"rules": {
"max-len": [1, 120, 2, { "ignoreComments": true }],
"indent": [1, 4, { "SwitchCase": 1 }],
"arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }],
"react/jsx-indent": [1, 4],
"linebreak-style": 0,
"react/jsx-filename-extension": 0,
"react/prefer-stateless-function": 0,
"react/prop-types": 0,
"react/jsx-indent-props": [2, 4],
"react/forbid-prop-types": 0,
"react/require-default-props": [0, { "forbidDefaultForRequired": false }],
"jsx-a11y/href-no-hash": 0,
"no-mixed-operators": [
"error",
{
"groups": [
["+", "-", "*", "/", "%", "**"],
["&", "|", "^", "~", "<<", ">>", ">>>"],
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
["&&", "||"],
["in", "instanceof"]
],
"allowSamePrecedence": false
}
],
"jsx-a11y/anchor-is-valid": 0,
"object-curly-newline": 0,
"import/no-unresolved": [
"error",
{
"ignore": ["src/"]
}
],
"react/sort-comp": false,
"func-names": "off"
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint"],
"extends": [
"airbnb",
"airbnb-typescript",
"airbnb/hooks",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"env": {
"browser": true,
"node": true
},
"extends": ["airbnb", "prettier"]
"rules": {
"indent": "off",
"no-tabs": "off",
"object-curly-newline": "off",
"import/no-cycle": "off",
"max-len": ["error", { "code": 120 }],
"implicit-arrow-linebreak": "off",
"operator-linebreak": "off",
"arrow-parens": "off",
"no-shadow": "off",
"no-else-return": "off",
"class-methods-use-this": "warn",
"linebreak-style": ["error", "windows"], // CRLF
"import/no-extraneous-dependencies": "off",
"react/require-default-props": "off",
"react/destructuring-assignment": "off",
"react/jsx-indent": [4, "tab"],
"react/no-unused-class-component-methods": "warn",
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-shadow": "off",
"@typescript-eslint/ban-ts-comment": "off"
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ lib/
.vscode/
docs/
.DS_Store
package-lock.json

# lerna
__tests__
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
package-lock=false
legacy-peer-deps=true
7 changes: 0 additions & 7 deletions conf/app.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"packages": ["packages/*"],
"version": "1.0.0"
}
108 changes: 50 additions & 58 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
"version": "0.0.50",
"description": "Design Editor Tools with React.js + ant.design + fabric.js",
"main": "dist/react-design-editor.min.js",
"typings": "lib/index.d.ts",
"types": "lib/index.d.ts",
"files": [
"dist",
"lib"
],
"workspaces": [
"packages/*"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "npm run clean && webpack --node-env production --config webpack.prod.js && typedoc",
"start": "npm install && npx lerna bootstrap --hoist && webpack serve --node-env development --config webpack.dev.js",
"build": "npm run clean && npx lerna bootstrap && webpack --node-env production --config webpack.prod.js && typedoc",
"build:lib": "npm run tsc && webpack --node-env production --config webpack.lib.js",
"start": "npm install && npm run start:dev",
"start:dev": "webpack serve --config webpack.dev.js",
"serve": "http-server docs -p 4001",
"ghpages": "npm run build && node scripts/ghpages",
"deploy": "npm run build:lib && npm publish",
Expand Down Expand Up @@ -42,10 +44,13 @@
"peerDependencies": {
"animejs": "^3.0.0",
"fabric": "^4.6.0",
"react": "^16.14.0",
"react-dom": "^16.14.0"
"react": ">=18.0.0",
"react-dom": ">=18.0.0"
},
"dependencies": {
"@react-design-editor/canvas": "^1.0.0",
"@react-design-editor/components": "^1.0.0",
"@react-design-editor/editors": "^1.0.0",
"animejs": "^3.0.0",
"antd": "3.15.0",
"classnames": "^2.2.6",
Expand All @@ -58,78 +63,65 @@
"i18next-browser-languagedetector": "^2.2.4",
"lodash": "^4.17.10",
"mediaelement": "^4.2.9",
"prop-types": "^15.6.2",
"react": "^16.14.0",
"nanoid": "^4.0.0",
"react": "^18.2.0",
"react-ace": "^8.1.0",
"react-color": "^2.14.1",
"react-custom-scrollbars": "^4.2.1",
"react-dom": "^16.14.0",
"react-helmet": "^5.2.0",
"react-hot-loader": "^4.12.20",
"react-dom": "^18.2.0",
"react-helmet-async": "^1.3.0",
"react-json-view": "^1.19.1",
"react-refresh": "^0.14.0",
"resize-observer-polyfill": "^1.5.1",
"store": "^2.0.12",
"uuid": "^7.0.3",
"uuidv4": "^6.2.8",
"warning": "^4.0.3"
},
"devDependencies": {
"@babel/core": "^7.16.0",
"@babel/plugin-proposal-class-properties": "^7.16.0",
"@babel/plugin-proposal-decorators": "^7.16.4",
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
"@babel/plugin-proposal-private-methods": "^7.16.0",
"@babel/plugin-proposal-private-property-in-object": "^7.16.0",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.16.4",
"@babel/plugin-transform-typescript": "^7.16.1",
"@babel/preset-env": "^7.16.4",
"@babel/preset-react": "^7.16.0",
"@babel/preset-typescript": "^7.16.0",
"@hot-loader/react-dom": "^17.0.1",
"@babel/core": "^7.18.10",
"@babel/plugin-proposal-decorators": "^7.18.9",
"@babel/plugin-transform-react-jsx-source": "^7.18.6",
"@babel/plugin-transform-runtime": "^7.18.9",
"@babel/preset-env": "^7.18.9",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
"@types/animejs": "^3.1.0",
"@types/color": "^3.0.1",
"@types/echarts": "^4.4.6",
"@types/fabric": "^4.5.7",
"@types/lodash": "^4.14.150",
"@types/react": "^16.14.21",
"@types/react-dom": "^16.9.14",
"@types/react-helmet": "^5.0.15",
"@types/uuid": "^7.0.2",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@types/warning": "^3.0.0",
"@types/webpack-env": "^1.16.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"babel-plugin-dynamic-import-webpack": "^1.1.0",
"babel-plugin-import": "^1.13.0",
"core-js": "^3.19.1",
"css-loader": "^3.5.2",
"babel-loader": "^8.2.5",
"core-js": "^3.24.1",
"css-loader": "^6.7.1",
"del": "^5.1.0",
"eslint": "^8.3.0",
"eslint-config-airbnb": "^19.0.0",
"eslint": "^8.22.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.19.0",
"file-loader": "^6.0.0",
"fs-extra": "^9.0.0",
"gh-pages": "^2.2.0",
"html-webpack-plugin": "^3.2.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.30.1",
"file-loader": "^6.2.0",
"fs-extra": "^10.1.0",
"gh-pages": "^4.0.0",
"html-webpack-plugin": "^5.5.0",
"http-server": "^14.1.0",
"less": "^2.7.3",
"less-loader": "^5.0.0",
"less": "^4.1.3",
"less-loader": "^11.0.0",
"path": "^0.12.7",
"style-loader": "^1.1.4",
"terser-webpack-plugin": "^4.2.3",
"tslint": "^6.1.1",
"tslint-react": "^5.0.0",
"style-loader": "^3.3.1",
"terser-webpack-plugin": "^5.3.4",
"tsconfig-paths-webpack-plugin": "^4.0.0",
"typedoc": "^0.17.4",
"typescript": "^3.9.10",
"url-loader": "^4.1.0",
"webpack": "^4.46.0",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^3.11.3",
"webpack-merge": "^4.2.2",
"workbox-webpack-plugin": "^5.1.2"
"typescript": "^4.7.4",
"url-loader": "^4.1.1",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.10.0",
"webpack-merge": "^5.8.0",
"workbox-webpack-plugin": "^6.5.4"
}
}
11 changes: 11 additions & 0 deletions packages/canvas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `canvas`

> TODO: description
## Usage

```
const canvas = require('canvas');
// TODO: DEMONSTRATE API
```
39 changes: 39 additions & 0 deletions packages/canvas/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "@react-design-editor/canvas",
"version": "1.0.0",
"description": "> TODO: description",
"private": true,
"keywords": [
"react-design-editor"
],
"author": "Sung Gyun Oh <[email protected]>",
"homepage": "https://salgum1114.github.io/react-design-editor/tree/main/packages/canvas#readme",
"license": "MIT",
"source": "src/index.tsx",
"main": "lib/index.js",
"types": "lib/types/index.d.ts",
"files": [
"lib"
],
"repository": {
"type": "git",
"url": "git+https://github.com/salgum1114/react-design-editor.git"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1"
},
"bugs": {
"url": "https://github.com/salgum1114/react-design-editor/issues"
},
"dependencies": {
"fabric": "^5.2.1",
"nanoid": "^4.0.0"
},
"devDependencies": {
"@types/fabric": "^4.5.11"
},
"peerDependencies": {
"react": ">=16.8.0",
"react-dom": ">=16.8.0"
}
}
6 changes: 3 additions & 3 deletions src/canvas/Canvas.tsx → packages/canvas/src/Canvas.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fabric } from 'fabric';
import { nanoid } from 'nanoid';
import React, { Component, useRef } from 'react';
import ResizeObserver from 'resize-observer-polyfill';
import { uuid } from 'uuidv4';
import { defaults } from './constants';
import Handler, { HandlerOptions } from './handlers/Handler';
import './styles/canvas.less';
Expand Down Expand Up @@ -34,7 +34,7 @@ class InternalCanvas extends Component<CanvasProps, IState> implements CanvasIns
private resizeObserver: ResizeObserver;

static defaultProps: CanvasProps = {
id: uuid(),
id: nanoid(),
editable: true,
zoomEnabled: true,
minZoom: 30,
Expand All @@ -45,7 +45,7 @@ class InternalCanvas extends Component<CanvasProps, IState> implements CanvasIns
};

state: IState = {
id: uuid(),
id: nanoid(),
loaded: false,
};

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fabric } from 'fabric';
import { uuid } from 'uuidv4';
import { nanoid } from 'nanoid';
import { Arrow, Line } from '../objects';
import { FabricEvent, FabricObject } from '../utils';
import Handler from './Handler';
Expand Down Expand Up @@ -52,7 +52,7 @@ class DrawingHandler {
hoverCursor: 'pointer',
}) as FabricObject<fabric.Circle>;
circle.set({
id: uuid(),
id: nanoid(),
});
if (!this.handler.pointArray.length) {
circle.set({
Expand Down Expand Up @@ -118,7 +118,7 @@ class DrawingHandler {
},
generate: (pointArray: FabricObject<fabric.Circle>[]) => {
const points = [] as any[];
const id = uuid();
const id = nanoid();
pointArray.forEach(point => {
points.push({
x: point.left,
Expand Down Expand Up @@ -170,7 +170,7 @@ class DrawingHandler {
// this.handler.pointArray.push(circle);
// });
// const group = [target].concat(this.pointArray);
// this.handler.canvas.add(new fabric.Group(group, { type: 'polygon', id: uuid() }));
// this.handler.canvas.add(new fabric.Group(group, { type: 'polygon', id: nanoid() }));
// },
// removeResize: () => {
// if (this.handler.pointArray) {
Expand Down Expand Up @@ -257,7 +257,7 @@ class DrawingHandler {
const { absolutePointer } = opt;
const { x, y } = absolutePointer;
let points = [] as number[];
const id = uuid();
const id = nanoid();
this.handler.pointArray.forEach(point => {
points = points.concat(point.left, point.top, x, y);
this.handler.canvas.remove(point);
Expand Down Expand Up @@ -346,7 +346,7 @@ class DrawingHandler {
});
this.handler.canvas.remove(this.handler.activeLine);
const option = {
id: uuid(),
id: nanoid(),
points,
type: 'arrow',
stroke: 'rgba(0, 0, 0, 1)',
Expand Down
File renamed without changes.
Loading

0 comments on commit d8fbcf9

Please sign in to comment.