remove dead code and fix some types
This commit is contained in:
parent
78f569de94
commit
28eaac0ef8
4 changed files with 7 additions and 28 deletions
|
@ -33,9 +33,9 @@ interface IProps {
|
||||||
// the query string for which to show autocomplete suggestions
|
// the query string for which to show autocomplete suggestions
|
||||||
query: string;
|
query: string;
|
||||||
// method invoked with range and text content when completion is confirmed
|
// method invoked with range and text content when completion is confirmed
|
||||||
onConfirm: (ICompletion) => void;
|
onConfirm: (completion: ICompletion) => void;
|
||||||
// method invoked when selected (if any) completion changes
|
// method invoked when selected (if any) completion changes
|
||||||
onSelectionChange?: (ICompletion, number) => void;
|
onSelectionChange?: (partIndex: number) => void;
|
||||||
selection: ISelectionRange;
|
selection: ISelectionRange;
|
||||||
// The room in which we're autocompleting
|
// The room in which we're autocompleting
|
||||||
room: Room;
|
room: Room;
|
||||||
|
@ -172,7 +172,7 @@ export default class Autocomplete extends React.PureComponent<IProps, IState> {
|
||||||
if (anyMatches) {
|
if (anyMatches) {
|
||||||
hide = false;
|
hide = false;
|
||||||
if (this.props.onSelectionChange) {
|
if (this.props.onSelectionChange) {
|
||||||
this.props.onSelectionChange(this.state.completionList[selectionOffset - 1], selectionOffset - 1);
|
this.props.onSelectionChange(selectionOffset - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ export default class Autocomplete extends React.PureComponent<IProps, IState> {
|
||||||
setSelection(selectionOffset: number) {
|
setSelection(selectionOffset: number) {
|
||||||
this.setState({selectionOffset, hide: false});
|
this.setState({selectionOffset, hide: false});
|
||||||
if (this.props.onSelectionChange) {
|
if (this.props.onSelectionChange) {
|
||||||
this.props.onSelectionChange(this.state.completionList[selectionOffset - 1], selectionOffset - 1);
|
this.props.onSelectionChange(selectionOffset - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -575,10 +575,9 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
|
||||||
this.props.model.autoComplete.onComponentConfirm(completion);
|
this.props.model.autoComplete.onComponentConfirm(completion);
|
||||||
};
|
};
|
||||||
|
|
||||||
private onAutoCompleteSelectionChange = (completion: ICompletion, completionIndex: number) => {
|
private onAutoCompleteSelectionChange = (completionIndex: number) => {
|
||||||
this.modifiedFlag = true;
|
this.modifiedFlag = true;
|
||||||
// this.props.model.autoComplete.onComponentSelectionChange(completion);
|
this.setState({ completionIndex });
|
||||||
this.setState({completionIndex});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private configureEmoticonAutoReplace = () => {
|
private configureEmoticonAutoReplace = () => {
|
||||||
|
|
|
@ -32,7 +32,6 @@ export type GetAutocompleterComponent = () => Autocomplete;
|
||||||
export type UpdateQuery = (test: string) => Promise<void>;
|
export type UpdateQuery = (test: string) => Promise<void>;
|
||||||
|
|
||||||
export default class AutocompleteWrapperModel {
|
export default class AutocompleteWrapperModel {
|
||||||
private queryPart: Part;
|
|
||||||
private partIndex: number;
|
private partIndex: number;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -45,10 +44,6 @@ export default class AutocompleteWrapperModel {
|
||||||
|
|
||||||
public onEscape(e: KeyboardEvent) {
|
public onEscape(e: KeyboardEvent) {
|
||||||
this.getAutocompleterComponent().onEscape(e);
|
this.getAutocompleterComponent().onEscape(e);
|
||||||
this.updateCallback({
|
|
||||||
replaceParts: [this.partCreator.plain(this.queryPart.text)],
|
|
||||||
close: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public close() {
|
public close() {
|
||||||
|
@ -89,25 +84,10 @@ export default class AutocompleteWrapperModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public onPartUpdate(part: Part, pos: DocumentPosition) {
|
public onPartUpdate(part: Part, pos: DocumentPosition) {
|
||||||
// cache the typed value and caret here
|
|
||||||
// so we can restore it in onComponentSelectionChange when the value is undefined (meaning it should be the typed text)
|
|
||||||
this.queryPart = part;
|
|
||||||
this.partIndex = pos.index;
|
this.partIndex = pos.index;
|
||||||
return this.updateQuery(part.text);
|
return this.updateQuery(part.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public onComponentSelectionChange(completion: ICompletion) {
|
|
||||||
if (!completion) {
|
|
||||||
this.updateCallback({
|
|
||||||
replaceParts: [this.queryPart],
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.updateCallback({
|
|
||||||
replaceParts: this.partForCompletion(completion),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public onComponentConfirm(completion: ICompletion) {
|
public onComponentConfirm(completion: ICompletion) {
|
||||||
this.updateCallback({
|
this.updateCallback({
|
||||||
replaceParts: this.partForCompletion(completion),
|
replaceParts: this.partForCompletion(completion),
|
||||||
|
|
|
@ -237,7 +237,7 @@ export default class EditorModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// not _autoComplete, only there if active part is autocomplete part
|
// not autoComplete, only there if active part is autocomplete part
|
||||||
if (this.autoComplete) {
|
if (this.autoComplete) {
|
||||||
return this.autoComplete.onPartUpdate(part, pos);
|
return this.autoComplete.onPartUpdate(part, pos);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue