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
Этот коммит содержится в:
Harrison Healey
2016-05-31 16:14:28 -04:00
коммит произвёл Joram Wilander
родитель 6e6257fcca
Коммит 12f6593727
11 изменённых файлов: 168 добавлений и 113 удалений

Просмотреть файл

@@ -1,11 +1,13 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import * as AsyncClient from 'utils/async_client.jsx';
import React from 'react';
class CommandSuggestion extends React.Component {
import * as AsyncClient from 'utils/async_client.jsx';
import Suggestion from './suggestion.jsx';
class CommandSuggestion extends Suggestion {
render() {
const {item, isSelection, onClick} = this.props;
@@ -30,16 +32,10 @@ class CommandSuggestion extends React.Component {
}
}
CommandSuggestion.propTypes = {
item: React.PropTypes.object.isRequired,
isSelection: React.PropTypes.bool,
onClick: React.PropTypes.func
};
export default class CommandProvider {
handlePretextChanged(suggestionId, pretext) {
if (pretext.startsWith('/')) {
AsyncClient.getSuggestedCommands(pretext, suggestionId, CommandSuggestion);
AsyncClient.getSuggestedCommands(pretext, suggestionId, CommandSuggestion, pretext);
}
}
}