TURBO shortcode search
This commit is contained in:
parent
cbf00168f1
commit
a3760b7729
|
@ -43,6 +43,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
|
||||||
onSuggestionSelected: PropTypes.func.isRequired,
|
onSuggestionSelected: PropTypes.func.isRequired,
|
||||||
onSuggestionsClearRequested: PropTypes.func.isRequired,
|
onSuggestionsClearRequested: PropTypes.func.isRequired,
|
||||||
onSuggestionsFetchRequested: PropTypes.func.isRequired,
|
onSuggestionsFetchRequested: PropTypes.func.isRequired,
|
||||||
|
onLocalSuggestionsFetchRequested: PropTypes.func.isRequired,
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
onKeyUp: PropTypes.func,
|
onKeyUp: PropTypes.func,
|
||||||
onKeyDown: PropTypes.func,
|
onKeyDown: PropTypes.func,
|
||||||
|
@ -66,7 +67,13 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
|
||||||
|
|
||||||
if (token !== null && this.state.lastToken !== token) {
|
if (token !== null && this.state.lastToken !== token) {
|
||||||
this.setState({ lastToken: token, selectedSuggestion: 0, tokenStart });
|
this.setState({ lastToken: token, selectedSuggestion: 0, tokenStart });
|
||||||
this.props.onSuggestionsFetchRequested(token);
|
if (token[0] === ':') {
|
||||||
|
// faster debounce for shortcodes.
|
||||||
|
// hashtags have long debounce because they're fetched from server.
|
||||||
|
this.props.onLocalSuggestionsFetchRequested(token);
|
||||||
|
} else {
|
||||||
|
this.props.onSuggestionsFetchRequested(token);
|
||||||
|
}
|
||||||
} else if (token === null) {
|
} else if (token === null) {
|
||||||
this.setState({ lastToken: null });
|
this.setState({ lastToken: null });
|
||||||
this.props.onSuggestionsClearRequested();
|
this.props.onSuggestionsClearRequested();
|
||||||
|
|
|
@ -90,6 +90,10 @@ export default class ComposeForm extends ImmutablePureComponent {
|
||||||
this.props.onFetchSuggestions(token);
|
this.props.onFetchSuggestions(token);
|
||||||
}, 500, { trailing: true })
|
}, 500, { trailing: true })
|
||||||
|
|
||||||
|
onLocalSuggestionsFetchRequested = debounce((token) => {
|
||||||
|
this.props.onFetchSuggestions(token);
|
||||||
|
}, 100, { trailing: true })
|
||||||
|
|
||||||
onSuggestionSelected = (tokenStart, token, value) => {
|
onSuggestionSelected = (tokenStart, token, value) => {
|
||||||
this._restoreCaret = null;
|
this._restoreCaret = null;
|
||||||
this.props.onSuggestionSelected(tokenStart, token, value);
|
this.props.onSuggestionSelected(tokenStart, token, value);
|
||||||
|
@ -186,6 +190,7 @@ export default class ComposeForm extends ImmutablePureComponent {
|
||||||
suggestions={this.props.suggestions}
|
suggestions={this.props.suggestions}
|
||||||
onKeyDown={this.handleKeyDown}
|
onKeyDown={this.handleKeyDown}
|
||||||
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
|
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
|
||||||
|
onLocalSuggestionsFetchRequested={this.onLocalSuggestionsFetchRequested}
|
||||||
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
|
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
|
||||||
onSuggestionSelected={this.onSuggestionSelected}
|
onSuggestionSelected={this.onSuggestionSelected}
|
||||||
onPaste={onPaste}
|
onPaste={onPaste}
|
||||||
|
|
Reference in New Issue