diff options
author | Corey Hulen <corey@hulen.com> | 2015-11-17 16:57:04 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-11-17 16:57:04 -0800 |
commit | 2ed93f74021020bd72675a47dae9d4e622b27226 (patch) | |
tree | f873512533e26512d8fd776116f15066b0b9b699 /web/react/components | |
parent | 178e30ecededae61eb727f30919b30358590e7f5 (diff) | |
parent | e9a8bcd727e1bfbd98dc1955d1c574b76e9a4ad1 (diff) | |
download | chat-2ed93f74021020bd72675a47dae9d4e622b27226.tar.gz chat-2ed93f74021020bd72675a47dae9d4e622b27226.tar.bz2 chat-2ed93f74021020bd72675a47dae9d4e622b27226.zip |
Merge pull request #1403 from florianorben/PLT-327
PLT-327: Add help text for Markdown
Diffstat (limited to 'web/react/components')
-rw-r--r-- | web/react/components/docs.jsx | 41 | ||||
-rw-r--r-- | web/react/components/textbox.jsx | 15 |
2 files changed, 55 insertions, 1 deletions
diff --git a/web/react/components/docs.jsx b/web/react/components/docs.jsx new file mode 100644 index 000000000..68baa6dad --- /dev/null +++ b/web/react/components/docs.jsx @@ -0,0 +1,41 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +const TextFormatting = require('../utils/text_formatting.jsx'); +const UserStore = require('../stores/user_store.jsx'); + +export default class Docs extends React.Component { + constructor(props) { + super(props); + UserStore.setCurrentUser(global.window.mm_user || {}); + + this.state = {text: ''}; + const errorState = {text: '## 404'}; + + if (props.site) { + $.get('/static/help/' + props.site + '.md').then((response) => { + this.setState({text: response}); + }, () => { + this.setState(errorState); + }); + } else { + this.setState(errorState); + } + } + + render() { + return ( + <div + dangerouslySetInnerHTML={{__html: TextFormatting.formatText(this.state.text)}} + > + </div> + ); + } +} + +Docs.defaultProps = { + site: '' +}; +Docs.propTypes = { + site: React.PropTypes.string +}; diff --git a/web/react/components/textbox.jsx b/web/react/components/textbox.jsx index e6530b941..1a5269baa 100644 --- a/web/react/components/textbox.jsx +++ b/web/react/components/textbox.jsx @@ -295,6 +295,13 @@ export default class Textbox extends React.Component { this.resize(); } + showHelp(e) { + e.preventDefault(); + e.target.blur(); + + global.window.open('/docs/Messaging'); + } + render() { const previewLinkVisible = this.props.messageText.length > 0; @@ -336,11 +343,17 @@ export default class Textbox extends React.Component { > </div> <a + onClick={this.showHelp} + className='textbox-help-link' + > + {'Help'} + </a> + <a style={{visibility: previewLinkVisible ? 'visible' : 'hidden'}} onClick={this.showPreview} className='textbox-preview-link' > - {this.state.preview ? 'Edit message' : 'Preview'} + {this.state.preview ? 'Edit' : 'Preview'} </a> </div> ); |