From 4f0a7db958b7c333ccf60147fe20ef6ac10a026a Mon Sep 17 00:00:00 2001 From: Guiqiang Zhang Date: Mon, 28 Sep 2020 21:52:57 +0800 Subject: [PATCH 1/4] fix for job descriptionn --- package-lock.json | 165 ++++++---- src/shared/components/Editor/index.jsx | 77 +++-- .../Profile/Work/List/Item/_mixin.scss | 42 +++ .../Settings/Profile/Work/List/Item/index.jsx | 37 ++- .../Profile/Work/List/Item/styles.scss | 49 +++ .../Settings/Profile/Work/Toolbar/index.jsx | 156 +++++++++ .../Settings/Profile/Work/Toolbar/style.scss | 37 +++ .../Settings/Profile/Work/index.jsx | 306 +++++++++++++++++- .../Settings/Profile/Work/styles.scss | 174 +++++++++- src/shared/containers/Settings.jsx | 2 + src/shared/utils/settings.js | 18 +- 11 files changed, 952 insertions(+), 111 deletions(-) create mode 100644 src/shared/components/Settings/Profile/Work/List/Item/_mixin.scss create mode 100644 src/shared/components/Settings/Profile/Work/Toolbar/index.jsx create mode 100644 src/shared/components/Settings/Profile/Work/Toolbar/style.scss diff --git a/package-lock.json b/package-lock.json index 9835410199..3265c7d849 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8312,6 +8312,11 @@ "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, + "fast-safe-stringify": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", + "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==" + }, "fastparse": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/fastparse/-/fastparse-1.1.2.tgz", @@ -20392,7 +20397,8 @@ "semver-compare": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", - "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=" + "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=", + "dev": true }, "semver-regex": { "version": "2.0.0", @@ -22377,17 +22383,14 @@ } }, "tc-accounts": { - "version": "git+https://github.com/appirio-tech/accounts-app.git#33f4aeb29d07dbe4e6d8206d718830fd54943f47", + "version": "git+https://github.com/appirio-tech/accounts-app.git#41529eab164d442cff0d43eeed07998c097a2afe", "from": "git+https://github.com/appirio-tech/accounts-app.git#dev", "requires": { "@uirouter/angularjs": "^1.0.0", "angucomplete-alt": "^2.1.0", "angular": "^1.4.8", - "angular-animate": "^1.7.9", - "angular-aria": "^1.7.9", "angular-auth0": "^3.0.0", "angular-cookies": "^1.5.1", - "angular-material": "^1.1.21", "angular-messages": "^1.5.2", "appirio-tech-ng-iso-constants": "github:appirio-tech/ng-iso-constants#v1.0.7", "appirio-tech-ng-ui-components": "^2.2.4", @@ -22569,16 +22572,6 @@ "resolved": "https://registry.npmjs.org/angular/-/angular-1.7.2.tgz", "integrity": "sha512-JcKKJbBdybUsmQ6x1M3xWyTYQ/ioVKJhSByEAjqrhmlOfvMFdhfMqAx5KIo8rLGk4DFolYPcCSgssjgTVjCtRQ==" }, - "angular-animate": { - "version": "1.7.9", - "resolved": "https://registry.npmjs.org/angular-animate/-/angular-animate-1.7.9.tgz", - "integrity": "sha512-fV+AISy/HTzurQH2ngsJg+lLIvfu0ahc1h4AYKauaXVw97rZc2k4iUA1bMstiEyClsdayQX568kjQc1NK+oYhw==" - }, - "angular-aria": { - "version": "1.7.9", - "resolved": "https://registry.npmjs.org/angular-aria/-/angular-aria-1.7.9.tgz", - "integrity": "sha512-luI3Jemd1AbOQW0krdzfEG3fM0IFtLY0bSSqIDEx3POE0XjKIC1MkrO8Csyq9PPgueLphyAPofzUwZ8YeZ88SA==" - }, "angular-auth0": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/angular-auth0/-/angular-auth0-3.0.0.tgz", @@ -22593,11 +22586,6 @@ "resolved": "https://registry.npmjs.org/angular-cookies/-/angular-cookies-1.7.2.tgz", "integrity": "sha512-5+B6ypV51aRPbQaqC2R5pr96q946C662dQC8QC1UL+cAlLkgkKZXXXzFRhiaEnhntkSnURWVCPasLVHQdZ3YgA==" }, - "angular-material": { - "version": "1.1.21", - "resolved": "https://registry.npmjs.org/angular-material/-/angular-material-1.1.21.tgz", - "integrity": "sha512-BiqvEu82dqQ4Sb4OjJHdVp/YJvFEMrtr7K2eS+6qlWPWUiF9K2K6IkX2H3p0wD7QlscjTz8n9W8uKL46PQjlCQ==" - }, "angular-messages": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/angular-messages/-/angular-messages-1.7.2.tgz", @@ -22965,16 +22953,6 @@ "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-1.2.0.tgz", "integrity": "sha1-qkSM8JhtVcxAdzsXF0t90GbLfPs=" }, - "libphonenumber-js": { - "version": "1.4.6", - "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.4.6.tgz", - "integrity": "sha512-TD1DyhPjVfNNiIxhwsooCO5j9L6JB60Qd+rlIEItgw8RKEqezu8Tva3V/4wrBiYMnBOHkp3uyzAe/PT9omyUdw==", - "requires": { - "minimist": "^1.2.0", - "semver-compare": "^1.0.0", - "xml2js": "^0.4.17" - } - }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -22983,11 +22961,6 @@ "js-tokens": "^3.0.0 || ^4.0.0" } }, - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" - }, "moment": { "version": "2.24.0", "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", @@ -23049,20 +23022,6 @@ "requires": { "loose-envify": "^1.0.0" } - }, - "xml2js": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", - "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", - "requires": { - "sax": ">=0.6.0", - "xmlbuilder": "~11.0.0" - } - }, - "xmlbuilder": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", - "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" } } }, @@ -31660,9 +31619,9 @@ "integrity": "sha1-qkSM8JhtVcxAdzsXF0t90GbLfPs=" }, "moment": { - "version": "2.27.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz", - "integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==" + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.0.tgz", + "integrity": "sha512-z6IJ5HXYiuxvFTI6eiQ9dm77uE0gyy1yXNApVHqTcnIKfY9tIwEjlzsZ6u1LQXvVgKeTnv9Xm7NDvJ7lso3MtA==" }, "query-string": { "version": "3.0.3", @@ -33204,9 +33163,9 @@ "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" }, "topcoder-react-lib": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/topcoder-react-lib/-/topcoder-react-lib-1.0.3.tgz", - "integrity": "sha512-cb4QLW2m3CqzJHWkfbx5TM/rV1bpJXk3FqetNIyKETipebkXtbL83mxtkaV3IEDYrpeKmfzDwjmbxwBh8Gopkw==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/topcoder-react-lib/-/topcoder-react-lib-1.0.5.tgz", + "integrity": "sha512-vit+BVaU5SbjwTzLDAqFxE2P539+huV6QspsV3Ud5fL12HQqu3cpJg8iZLmEcCPSXonocVyhtvqdrSgqF1oB4Q==", "requires": { "auth0-js": "^6.8.4", "config": "^3.2.0", @@ -33258,13 +33217,21 @@ } }, "config": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/config/-/config-3.3.1.tgz", - "integrity": "sha512-+2/KaaaAzdwUBE3jgZON11L1ggLLhpf2FsGrfqYFHZW22ySGv/HqYIXrBwKKvn+XZh1UBUjHwAcrfsSkSygT+Q==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/config/-/config-3.3.2.tgz", + "integrity": "sha512-NlGfBn2565YA44Irn7GV5KHlIGC3KJbf0062/zW5ddP9VXIuRj0m7HVyFAWvMZvaHPEglyGfwmevGz3KosIpCg==", "requires": { "json5": "^2.1.1" } }, + "debug": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", + "requires": { + "ms": "2.1.2" + } + }, "follow-redirects": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-0.0.7.tgz", @@ -33272,6 +33239,31 @@ "requires": { "debug": "^2.2.0", "stream-consume": "^0.1.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "form-data": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", + "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" } }, "hoist-non-react-statics": { @@ -33290,6 +33282,16 @@ "minimist": "^1.2.5" } }, + "mime": { + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz", + "integrity": "sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA==" + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, "object-keys": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", @@ -33308,11 +33310,44 @@ "react-is": "^16.8.2" } }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==" + }, "serialize-javascript": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.9.1.tgz", "integrity": "sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A==" }, + "superagent": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-5.3.1.tgz", + "integrity": "sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==", + "requires": { + "component-emitter": "^1.3.0", + "cookiejar": "^2.1.2", + "debug": "^4.1.1", + "fast-safe-stringify": "^2.0.7", + "form-data": "^3.0.0", + "formidable": "^1.2.2", + "methods": "^1.1.2", + "mime": "^2.4.6", + "qs": "^6.9.4", + "readable-stream": "^3.6.0", + "semver": "^7.3.2" + } + }, "tc-core-library-js": { "version": "github:appirio-tech/tc-core-library-js#d16413db30b1eed21c0cf426e185bedb2329ddab", "from": "github:appirio-tech/tc-core-library-js#v2.6", @@ -33329,15 +33364,15 @@ }, "dependencies": { "auth0-js": { - "version": "9.13.4", - "resolved": "https://registry.npmjs.org/auth0-js/-/auth0-js-9.13.4.tgz", - "integrity": "sha512-G7wXTtEUe8OG5UMdcFPoS47odorEZ3WerNyWLLhoGlLqYcPgv0t+B0ECHv/rVLULbpctbSBrRFFYa43/bJV4+Q==", + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/auth0-js/-/auth0-js-9.14.0.tgz", + "integrity": "sha512-40gIBUejmYAYse06ck6sxdNO0KU0pX+KDIQsWAkcyFtI0HU6dY5aeHxZfVYkYjtbArKr5s13LuZFdKrUiGyCqQ==", "requires": { "base64-js": "^1.3.0", "idtoken-verifier": "^2.0.3", "js-cookie": "^2.2.0", "qs": "^6.7.0", - "superagent": "^3.8.3", + "superagent": "^5.3.1", "url-join": "^4.0.1", "winchan": "^0.2.2" } @@ -33436,9 +33471,9 @@ } }, "topcoder-react-ui-kit": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/topcoder-react-ui-kit/-/topcoder-react-ui-kit-2.0.0.tgz", - "integrity": "sha512-9Ph8fRzRjVVB0VH13s8/N4+/ZWPLflrnW7D0fmS+oeDwnQe6k5wMknyFcBCI/pqWHr/11nhclXX7np3LdyWSwA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/topcoder-react-ui-kit/-/topcoder-react-ui-kit-2.0.1.tgz", + "integrity": "sha512-pl8tysSZYHDSbWn8srLZxV+8lK9f32ya8N+yt5C2XF2PKak30Qnqb3PCDhBO1fKmFF90p4ohJRsCi0IxLRyH/A==", "requires": { "prop-types": "^15.6.2", "react": "^16.4.1", diff --git a/src/shared/components/Editor/index.jsx b/src/shared/components/Editor/index.jsx index 40762b3513..58cc02b467 100644 --- a/src/shared/components/Editor/index.jsx +++ b/src/shared/components/Editor/index.jsx @@ -46,30 +46,27 @@ export default class EditorWrapper extends React.Component { this.customPlugin = createCustomPlugin({ editor: this, }); + + this.onBeforeInput = this.onBeforeInput.bind(this); + this.onPasteText = this.onPasteText.bind(this); } componentDidMount() { const { connector, initialContent } = this.props; connector.addEditor(this); - if (initialContent) { - let editorState = convertFromHTML(initialContent); - editorState = ContentState.createFromBlockArray( - editorState.contentBlocks, - editorState.entityMap, - ); - editorState = EditorState.createWithContent(editorState); - this.initialContent = editorState.getCurrentContent(); - setImmediate(() => this.setState({ editor: editorState })); - } + this.setInitialContent(initialContent); } - componentWillReceiveProps({ connector, id }) { - const { connector: prevConnector } = this.props; + componentWillReceiveProps({ connector, id, initialContent }) { + const { connector: prevConnector, initialContent: prevInitialContent } = this.props; this.id = id; if (connector !== prevConnector) { if (prevConnector) prevConnector.removeEditor(this); if (connector) connector.addEditor(this); } + if (initialContent !== prevInitialContent) { + this.setInitialContent(initialContent); + } } componentWillUnmount() { @@ -77,6 +74,41 @@ export default class EditorWrapper extends React.Component { connector.removeEditor(this); } + onBeforeInput() { // eslint-disable-line consistent-return + const { maxLength } = this.props; + const { editor: editorState } = this.state; + if (maxLength !== -1 && maxLength <= editorState.getCurrentContent().getPlainText('').length) { + return 'handled'; + } + } + + onPasteText(text) { // eslint-disable-line consistent-return + const { maxLength } = this.props; + const { editor: editorState } = this.state; + if (maxLength !== -1 && maxLength <= text.length + editorState.getCurrentContent().getPlainText('').length) { + return 'handled'; + } + } + + setInitialContent(content) { + if (content) { + let editorState = convertFromHTML(content); + if (editorState.contentBlocks) { + editorState = ContentState.createFromBlockArray( + editorState.contentBlocks, + editorState.entityMap, + ); + editorState = EditorState.createWithContent(editorState); + this.initialContent = editorState.getCurrentContent(); + setImmediate(() => this.setState({ editor: editorState })); + } + } else { + let { editor: editorState } = this.state; + editorState = EditorState.push(editorState, ContentState.createFromText('')); + this.setState({ editor: editorState }); + } + } + getHtml() { const { editor } = this.state; return editorStateToHTML(editor.getCurrentContent()); @@ -98,10 +130,9 @@ export default class EditorWrapper extends React.Component { * @param {String} type The new block style */ applyBlockStyle(type) { - const { editor } = this.state; - let editorState = editor; + let { editor: editorState } = this.state; editorState = RichUtils.toggleBlockType(editorState, type); - this.setState({ editorState }); // eslint-disable-line + this.setState({ editor: editorState }); // eslint-disable-line } /** @@ -231,13 +262,16 @@ export default class EditorWrapper extends React.Component { } render() { - const { connector, theme } = this.props; + const { connector, theme, placeholder } = this.props; const st = this.state; let containerStyles = style.container; if (st.editor.getSelection().getHasFocus()) { - containerStyles += ` ${style.focused}`; + containerStyles += ` ${style.focused} is-focused`; + } + if (st.editor.getCurrentContent().hasText() || /
    |