fix regional emojis converted to flags (#9294)
Co-authored-by: grimhilt <grimhilt@users.noreply.github.com> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Faye Duxovni <duxovni@duxovni.org> Co-authored-by: Faye Duxovni <fayed@element.io> Fixes https://github.com/vector-im/element-web/issues/19000
This commit is contained in:
parent
262c2fcff2
commit
5a08859e37
4 changed files with 71 additions and 16 deletions
|
@ -348,4 +348,32 @@ describe("editor/model", function () {
|
|||
expect(model.parts[0].text).toBe("foo@a");
|
||||
});
|
||||
});
|
||||
describe("emojis", function () {
|
||||
it("regional emojis should be separated to prevent them to be converted to flag", () => {
|
||||
const renderer = createRenderer();
|
||||
const pc = createPartCreator();
|
||||
const model = new EditorModel([], pc, renderer);
|
||||
const regionalEmojiA = String.fromCodePoint(127462);
|
||||
const regionalEmojiZ = String.fromCodePoint(127487);
|
||||
const caret = new DocumentOffset(0, true);
|
||||
|
||||
const regionalEmojis: string[] = [];
|
||||
regionalEmojis.push(regionalEmojiA);
|
||||
regionalEmojis.push(regionalEmojiZ);
|
||||
for (let i = 0; i < 2; i++) {
|
||||
const position = model.positionForOffset(caret.offset, caret.atNodeEnd);
|
||||
model.transform(() => {
|
||||
const addedLen = model.insert(pc.plainWithEmoji(regionalEmojis[i]), position);
|
||||
caret.offset += addedLen;
|
||||
return model.positionForOffset(caret.offset, true);
|
||||
});
|
||||
}
|
||||
|
||||
expect(model.parts.length).toBeGreaterThanOrEqual(4);
|
||||
expect(model.parts[0].type).toBe("emoji");
|
||||
expect(model.parts[1].type).not.toBe("emoji");
|
||||
expect(model.parts[2].type).toBe("emoji");
|
||||
expect(model.parts[3].type).not.toBe("emoji");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue