diff --git a/package.json b/package.json index 36a5ba9991..0793860305 100644 --- a/package.json +++ b/package.json @@ -140,7 +140,7 @@ "supertest": "^3.1.0", "tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.3", "tc-ui": "^1.0.12", - "topcoder-react-lib": "1000.25.7", + "topcoder-react-lib": "1000.25.8", "topcoder-react-ui-kit": "2.0.1", "topcoder-react-utils": "0.7.8", "turndown": "^4.0.2", diff --git a/src/assets/images/settings/profile/work/tc-text-16-bold-active.svg b/src/assets/images/settings/profile/work/tc-text-16-bold-active.svg new file mode 100644 index 0000000000..3aa72fbbae --- /dev/null +++ b/src/assets/images/settings/profile/work/tc-text-16-bold-active.svg @@ -0,0 +1,3 @@ + diff --git a/src/assets/images/settings/profile/work/tc-text-16-bold.svg b/src/assets/images/settings/profile/work/tc-text-16-bold.svg new file mode 100644 index 0000000000..133a76cf16 --- /dev/null +++ b/src/assets/images/settings/profile/work/tc-text-16-bold.svg @@ -0,0 +1,3 @@ + diff --git a/src/assets/images/settings/profile/work/tc-text-16-italic-active.svg b/src/assets/images/settings/profile/work/tc-text-16-italic-active.svg new file mode 100644 index 0000000000..4be060733d --- /dev/null +++ b/src/assets/images/settings/profile/work/tc-text-16-italic-active.svg @@ -0,0 +1,3 @@ + diff --git a/src/assets/images/settings/profile/work/tc-text-16-italic.svg b/src/assets/images/settings/profile/work/tc-text-16-italic.svg new file mode 100644 index 0000000000..df5bb5e7be --- /dev/null +++ b/src/assets/images/settings/profile/work/tc-text-16-italic.svg @@ -0,0 +1,3 @@ + diff --git a/src/assets/images/settings/profile/work/tc-text-16-underline-active.svg b/src/assets/images/settings/profile/work/tc-text-16-underline-active.svg new file mode 100644 index 0000000000..9586af3aa8 --- /dev/null +++ b/src/assets/images/settings/profile/work/tc-text-16-underline-active.svg @@ -0,0 +1,6 @@ + diff --git a/src/assets/images/settings/profile/work/tc-text-16-underline.svg b/src/assets/images/settings/profile/work/tc-text-16-underline.svg new file mode 100644 index 0000000000..26d903b0fe --- /dev/null +++ b/src/assets/images/settings/profile/work/tc-text-16-underline.svg @@ -0,0 +1,6 @@ + diff --git a/src/assets/images/settings/profile/work/text-16px_list-bullet-active.svg b/src/assets/images/settings/profile/work/text-16px_list-bullet-active.svg new file mode 100644 index 0000000000..568ce8ffb3 --- /dev/null +++ b/src/assets/images/settings/profile/work/text-16px_list-bullet-active.svg @@ -0,0 +1,12 @@ + + + + diff --git a/src/assets/images/settings/profile/work/text-16px_list-bullet.svg b/src/assets/images/settings/profile/work/text-16px_list-bullet.svg new file mode 100644 index 0000000000..df85bf388f --- /dev/null +++ b/src/assets/images/settings/profile/work/text-16px_list-bullet.svg @@ -0,0 +1,12 @@ + + + + diff --git a/src/assets/images/settings/profile/work/text-16px_list-numbers-active.svg b/src/assets/images/settings/profile/work/text-16px_list-numbers-active.svg new file mode 100644 index 0000000000..302f06e53f --- /dev/null +++ b/src/assets/images/settings/profile/work/text-16px_list-numbers-active.svg @@ -0,0 +1,23 @@ + + + + diff --git a/src/assets/images/settings/profile/work/text-16px_list-numbers.svg b/src/assets/images/settings/profile/work/text-16px_list-numbers.svg new file mode 100644 index 0000000000..9baebe060d --- /dev/null +++ b/src/assets/images/settings/profile/work/text-16px_list-numbers.svg @@ -0,0 +1,23 @@ + + + + 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) {