From 556805b42dcb2a783101adbe6de2bc404f635de2 Mon Sep 17 00:00:00 2001 From: Grygorii Date: Thu, 30 Jul 2020 00:47:46 +0300 Subject: [PATCH] comments feature, fix vulnerabilities --- .eslintrc | 25 +- .gitignore | 2 +- examples/src/CommentBlock.tsx | 86 + examples/src/index.tsx | 139 +- package-lock.json | 11022 ++++++++++++++++++++++++++++++ package.json | 171 +- src/compute-lines.ts | 394 +- src/index.tsx | 1325 ++-- src/styles.ts | 782 ++- test/react-diff-viewer-test.tsx | 27 +- tsconfig.json | 7 +- webpack.config.js | 52 +- yarn.lock | 5064 +++++++------- 13 files changed, 15344 insertions(+), 3752 deletions(-) create mode 100644 examples/src/CommentBlock.tsx create mode 100644 package-lock.json diff --git a/.eslintrc b/.eslintrc index df6bc2a2..d3934c4b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,11 +2,24 @@ "extends": ["airbnb-base", "plugin:@typescript-eslint/recommended"], "rules": { "no-tabs": "off", - "@typescript-eslint/indent": ["error", 2], - "max-len": ["error", { - "code": 100 - }], "arrow-body-style": "off", + "comma-dangle": "off", + "@typescript-eslint/no-var-requires": 0, + "operator-linebreak": "off", + "@typescript-eslint/no-explicit-any": 0, + "@typescript-eslint/explicit-function-return-type": 0, + "implicit-arrow-linebreak": "off", + "@typescript-eslint/indent": 0, + "import/extensions": [ + "error", + "ignorePackages", + { + "ts": "never", + "js": "never", + "mjs": "never", + "jsx": "never" + } + ] }, "settings": { "import/resolver": { @@ -18,6 +31,6 @@ "env": { "mocha": true, "node": true, - "browser": true, - }, + "browser": true + } } diff --git a/.gitignore b/.gitignore index e3584bd5..f596c21d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ node_modules dist lib -*.log +*.log \ No newline at end of file diff --git a/examples/src/CommentBlock.tsx b/examples/src/CommentBlock.tsx new file mode 100644 index 00000000..c6ab90bd --- /dev/null +++ b/examples/src/CommentBlock.tsx @@ -0,0 +1,86 @@ +import * as React from 'react'; +import { CommentInfo } from '../../lib'; + +interface Props { + updateComment: (commentInfo: CommentInfo, text: string) => void; + removeComment: (lineId: string) => void; + comment: any; + show: boolean; +} + +const CommentBlock: React.FC = ({ + updateComment, + removeComment, + comment, + show +}) => { + const [isComment, setIsComment] = React.useState(show); + const [text, setText] = React.useState( + comment.body ? comment.body.text : '' + ); + + const handleChange = (e: React.ChangeEvent) => { + setText(e.target.value); + }; + + if (!isComment) { + return ( +
+
+