From b8c5461b9054573cb33a56a17213c83550ab6212 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 13 Jun 2017 15:13:26 -0300 Subject: [PATCH] Adding react-linkify --- .../client/components/CommentContent.js | 7 +- .../client/components/Link.js | 13 -- .../client/components/styles.css | 8 -- .../client/helpers/isLink.js | 5 - .../coral-plugin-comment-content/package.json | 14 +++ .../coral-plugin-comment-content/yarn.lock | 112 ++++++++++++++++++ 6 files changed, 130 insertions(+), 29 deletions(-) delete mode 100644 plugins/coral-plugin-comment-content/client/components/Link.js delete mode 100644 plugins/coral-plugin-comment-content/client/components/styles.css delete mode 100644 plugins/coral-plugin-comment-content/client/helpers/isLink.js create mode 100644 plugins/coral-plugin-comment-content/package.json create mode 100644 plugins/coral-plugin-comment-content/yarn.lock diff --git a/plugins/coral-plugin-comment-content/client/components/CommentContent.js b/plugins/coral-plugin-comment-content/client/components/CommentContent.js index 15a5bc9af..199982698 100644 --- a/plugins/coral-plugin-comment-content/client/components/CommentContent.js +++ b/plugins/coral-plugin-comment-content/client/components/CommentContent.js @@ -1,6 +1,5 @@ import React from 'react'; -import isLink from '../helpers/isLink'; -import Link from './Link'; +import Linkify from 'react-linkify'; const name = 'coral-plugin-comment-content'; @@ -11,7 +10,9 @@ const CommentContent = ({comment}) => { textbreaks.map((line, i) => { return ( - {line.split(' ').map((w) => isLink(w) ? : ` ${w}`)} + + {line} +
); diff --git a/plugins/coral-plugin-comment-content/client/components/Link.js b/plugins/coral-plugin-comment-content/client/components/Link.js deleted file mode 100644 index 14b718a73..000000000 --- a/plugins/coral-plugin-comment-content/client/components/Link.js +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import styles from './styles.css'; - -const Link = ({url, key}) => ( - - {' '} - - {url} - - -); - -export default Link; diff --git a/plugins/coral-plugin-comment-content/client/components/styles.css b/plugins/coral-plugin-comment-content/client/components/styles.css deleted file mode 100644 index 117942223..000000000 --- a/plugins/coral-plugin-comment-content/client/components/styles.css +++ /dev/null @@ -1,8 +0,0 @@ -.link { - color: grey; - text-decoration: underline; -} - -.link:hover { - cursor: pointer; -} \ No newline at end of file diff --git a/plugins/coral-plugin-comment-content/client/helpers/isLink.js b/plugins/coral-plugin-comment-content/client/helpers/isLink.js deleted file mode 100644 index cf4d43bc5..000000000 --- a/plugins/coral-plugin-comment-content/client/helpers/isLink.js +++ /dev/null @@ -1,5 +0,0 @@ -const linkRE = /(((http|ftp|https)\:\/\/)?([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)/gmi; - -const isLink = (s) => linkRE.test(s); - -export default isLink; diff --git a/plugins/coral-plugin-comment-content/package.json b/plugins/coral-plugin-comment-content/package.json new file mode 100644 index 000000000..ed668425f --- /dev/null +++ b/plugins/coral-plugin-comment-content/package.json @@ -0,0 +1,14 @@ +{ + "name": "coral-plugin-comment-content", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "react-linkify": "^0.2.1" + } +} diff --git a/plugins/coral-plugin-comment-content/yarn.lock b/plugins/coral-plugin-comment-content/yarn.lock new file mode 100644 index 000000000..9f312c11d --- /dev/null +++ b/plugins/coral-plugin-comment-content/yarn.lock @@ -0,0 +1,112 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +asap@~2.0.3: + version "2.0.5" + resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.5.tgz#522765b50c3510490e52d7dcfe085ef9ba96958f" + +core-js@^1.0.0: + version "1.2.7" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" + +encoding@^0.1.11: + version "0.1.12" + resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" + dependencies: + iconv-lite "~0.4.13" + +fbjs@^0.8.9: + version "0.8.12" + resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04" + dependencies: + core-js "^1.0.0" + isomorphic-fetch "^2.1.1" + loose-envify "^1.0.0" + object-assign "^4.1.0" + promise "^7.1.1" + setimmediate "^1.0.5" + ua-parser-js "^0.7.9" + +iconv-lite@~0.4.13: + version "0.4.18" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2" + +is-stream@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + +isomorphic-fetch@^2.1.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9" + dependencies: + node-fetch "^1.0.1" + whatwg-fetch ">=0.10.0" + +js-tokens@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" + +linkify-it@^1.2.0: + version "1.2.4" + resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-1.2.4.tgz#0773526c317c8fd13bd534ee1d180ff88abf881a" + dependencies: + uc.micro "^1.0.1" + +loose-envify@^1.0.0, loose-envify@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" + dependencies: + js-tokens "^3.0.0" + +node-fetch@^1.0.1: + version "1.7.1" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.1.tgz#899cb3d0a3c92f952c47f1b876f4c8aeabd400d5" + dependencies: + encoding "^0.1.11" + is-stream "^1.0.1" + +object-assign@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + +promise@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/promise/-/promise-7.1.1.tgz#489654c692616b8aa55b0724fa809bb7db49c5bf" + dependencies: + asap "~2.0.3" + +prop-types@^15.5.8: + version "15.5.10" + resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154" + dependencies: + fbjs "^0.8.9" + loose-envify "^1.3.1" + +react-linkify@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/react-linkify/-/react-linkify-0.2.1.tgz#b28d3f9544539a622fec8d42b4800eb9d23bf981" + dependencies: + linkify-it "^1.2.0" + prop-types "^15.5.8" + tlds "^1.57.0" + +setimmediate@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" + +tlds@^1.57.0: + version "1.189.0" + resolved "https://registry.yarnpkg.com/tlds/-/tlds-1.189.0.tgz#b8cb46ea76dc2f4a01d45b8d907bf19a66e9f729" + +ua-parser-js@^0.7.9: + version "0.7.12" + resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb" + +uc.micro@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.3.tgz#7ed50d5e0f9a9fb0a573379259f2a77458d50192" + +whatwg-fetch@>=0.10.0: + version "2.0.3" + resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"