Files
mostlymatter/webapp/components/suggestion/command_provider.jsx
Harrison Healey 12f6593727 PLT-2643 Fixed asynchronous autocomplete incorrectly replacing text (#3167)
* Allowed different suggestions to match different text. Added a Suggestion base component. Improved text replacement used when filling in suggestions

* Fixed formatting
2016-05-31 16:14:28 -04:00

42 строки
1.1 KiB
JavaScript

// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import * as AsyncClient from 'utils/async_client.jsx';
import Suggestion from './suggestion.jsx';
class CommandSuggestion extends Suggestion {
render() {
const {item, isSelection, onClick} = this.props;
let className = 'command';
if (isSelection) {
className += ' suggestion--selected';
}
return (
<div
className={className}
onClick={onClick}
>
<div className='command__title'>
<string>{item.suggestion} {item.hint}</string>
</div>
<div className='command__desc'>
{item.description}
</div>
</div>
);
}
}
export default class CommandProvider {
handlePretextChanged(suggestionId, pretext) {
if (pretext.startsWith('/')) {
AsyncClient.getSuggestedCommands(pretext, suggestionId, CommandSuggestion, pretext);
}
}
}