Split MessageEditor in edit-specifics & reusable part for main composer

This commit is contained in:
Bruno Windels 2019-08-05 15:27:40 +02:00
parent e8fcfbe2bf
commit 299cf8542c
6 changed files with 273 additions and 163 deletions

View file

@ -24,9 +24,17 @@ export default class EditorModel {
this._activePartIdx = null;
this._autoComplete = null;
this._autoCompletePartIdx = null;
this.setUpdateCallback(updateCallback);
}
setUpdateCallback(updateCallback) {
this._updateCallback = updateCallback;
}
get partCreator() {
return this._partCreator;
}
clone() {
return new EditorModel(this._parts, this._partCreator, this._updateCallback);
}

View file

@ -325,7 +325,7 @@ class PillCandidatePart extends PlainPart {
}
createAutoComplete(updateCallback) {
return this._autoCompleteCreator(updateCallback);
return this._autoCompleteCreator.create(updateCallback);
}
acceptsInsertion(chr, i) {
@ -363,10 +363,14 @@ export function autoCompleteCreator(getAutocompleterComponent, updateQuery) {
}
export class PartCreator {
constructor(autoCompleteCreator, room, client) {
constructor(room, client, autoCompleteCreator) {
this._room = room;
this._client = client;
this._autoCompleteCreator = autoCompleteCreator(this);
this._autoCompleteCreator = {create: autoCompleteCreator && autoCompleteCreator(this)};
}
setAutoCompleteCreator(autoCompleteCreator) {
this._autoCompleteCreator.create = autoCompleteCreator(this);
}
createPartForInput(input) {