mirror of https://github.com/vector-im/riot-web
Merge pull request #5951 from SimonBrandner/fix/room-pill-history
Fix saving room pill part to historypull/21833/head
commit
ed8b05b730
|
@ -158,7 +158,7 @@ export default class EditorModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reset(serializedParts: SerializedPart[], caret: Caret, inputType: string) {
|
reset(serializedParts: SerializedPart[], caret?: Caret, inputType?: string) {
|
||||||
this._parts = serializedParts.map(p => this._partCreator.deserializePart(p));
|
this._parts = serializedParts.map(p => this._partCreator.deserializePart(p));
|
||||||
if (!caret) {
|
if (!caret) {
|
||||||
caret = this.getPositionAtEnd();
|
caret = this.getPositionAtEnd();
|
||||||
|
|
|
@ -34,7 +34,7 @@ interface ISerializedPart {
|
||||||
interface ISerializedPillPart {
|
interface ISerializedPillPart {
|
||||||
type: Type.AtRoomPill | Type.RoomPill | Type.UserPill;
|
type: Type.AtRoomPill | Type.RoomPill | Type.UserPill;
|
||||||
text: string;
|
text: string;
|
||||||
resourceId: string;
|
resourceId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SerializedPart = ISerializedPart | ISerializedPillPart;
|
export type SerializedPart = ISerializedPart | ISerializedPillPart;
|
||||||
|
@ -287,6 +287,14 @@ abstract class PillPart extends BasePart implements IPillPart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
serialize(): ISerializedPillPart {
|
||||||
|
return {
|
||||||
|
type: this.type,
|
||||||
|
text: this.text,
|
||||||
|
resourceId: this.resourceId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
get canEdit() {
|
get canEdit() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -366,6 +374,13 @@ class AtRoomPillPart extends RoomPillPart {
|
||||||
get type(): IPillPart["type"] {
|
get type(): IPillPart["type"] {
|
||||||
return Type.AtRoomPill;
|
return Type.AtRoomPill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
serialize(): ISerializedPillPart {
|
||||||
|
return {
|
||||||
|
type: this.type,
|
||||||
|
text: this.text,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserPillPart extends PillPart {
|
class UserPillPart extends PillPart {
|
||||||
|
@ -394,14 +409,6 @@ class UserPillPart extends PillPart {
|
||||||
get className() {
|
get className() {
|
||||||
return "mx_UserPill mx_Pill";
|
return "mx_UserPill mx_Pill";
|
||||||
}
|
}
|
||||||
|
|
||||||
serialize(): ISerializedPillPart {
|
|
||||||
return {
|
|
||||||
type: this.type,
|
|
||||||
text: this.text,
|
|
||||||
resourceId: this.resourceId,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PillCandidatePart extends PlainBasePart implements IPillCandidatePart {
|
class PillCandidatePart extends PlainBasePart implements IPillCandidatePart {
|
||||||
|
@ -495,7 +502,7 @@ export class PartCreator {
|
||||||
case Type.PillCandidate:
|
case Type.PillCandidate:
|
||||||
return this.pillCandidate(part.text);
|
return this.pillCandidate(part.text);
|
||||||
case Type.RoomPill:
|
case Type.RoomPill:
|
||||||
return this.roomPill(part.text);
|
return this.roomPill(part.resourceId);
|
||||||
case Type.UserPill:
|
case Type.UserPill:
|
||||||
return this.userPill(part.text, part.resourceId);
|
return this.userPill(part.text, part.resourceId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ describe('editor/deserialize', function() {
|
||||||
const parts = normalize(parseEvent(htmlMessage(html), createPartCreator()));
|
const parts = normalize(parseEvent(htmlMessage(html), createPartCreator()));
|
||||||
expect(parts.length).toBe(3);
|
expect(parts.length).toBe(3);
|
||||||
expect(parts[0]).toStrictEqual({type: "plain", text: "Try "});
|
expect(parts[0]).toStrictEqual({type: "plain", text: "Try "});
|
||||||
expect(parts[1]).toStrictEqual({type: "room-pill", text: "#room:hs.tld"});
|
expect(parts[1]).toStrictEqual({type: "room-pill", text: "#room:hs.tld", resourceId: "#room:hs.tld"});
|
||||||
expect(parts[2]).toStrictEqual({type: "plain", text: "?"});
|
expect(parts[2]).toStrictEqual({type: "plain", text: "?"});
|
||||||
});
|
});
|
||||||
it('@room pill', function() {
|
it('@room pill', function() {
|
||||||
|
|
Loading…
Reference in New Issue