diff --git a/.circleci/config.yml b/.circleci/config.yml index 1e58d6ae06..f7a84333d5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -260,7 +260,7 @@ workflows: branches: only: - develop - - listing-develop-sync + - fix_for_job_descriptionn # Production builds are exectuted # when PR is merged to the master # Don't change anything in this configuration diff --git a/package.json b/package.json index eb006f35d7..d67459d508 100644 --- a/package.json +++ b/package.json @@ -140,7 +140,7 @@ "tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#dev", "tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.3", "tc-ui": "^1.0.12", - "topcoder-react-lib": "1.0.8", + "topcoder-react-lib": "1000.22.14", "topcoder-react-ui-kit": "2.0.1", "topcoder-react-utils": "0.7.8", "turndown": "^4.0.2", 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() || /
- {`${!_.isEmpty(work.timePeriodFrom) ? moment(work.timePeriodFrom).format('YYYY') : ''}${!_.isEmpty(work.timePeriodTo) ? ` - ${moment(work.timePeriodTo).format('YYYY')}` : ` ${current}`}`} + {`${!isDateEmpty(work.timePeriodFrom) ? moment(work.timePeriodFrom).format('YYYY') : ''}${!isDateEmpty(work.timePeriodTo) ? ` - ${moment(work.timePeriodTo).format('YYYY')}` : ` ${current}`}`}
{`${!_.isEmpty(work.position) ? `${work.position}` : ''}`} @@ -83,6 +90,30 @@ export default function Item(props) {