You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-31 13:44:28 +03:00
Treat lists with a single empty item as plain text, not Markdown. (#6833)
* Treat lists with a single empty item as plain text, not Markdown. This allows users to send simple messages such as `-`, `+`, `*` and `2021.` without Element Web mangling them into a nonsensical empty list. As soon as any non-whitespace content is added to the item, it switches back to treating it as a list of one item. Fixes vector-im/element-web#7631. * Fix type errors. * Lint. --------- Co-authored-by: Michael Weimann <michaelw@matrix.org> Co-authored-by: Johannes Marbach <johannesm@element.io>
This commit is contained in:
@ -81,6 +81,29 @@ describe("editor/serialize", function () {
|
||||
const html = htmlSerializeIfNeeded(model, {});
|
||||
expect(html).toBe("*hello* world < hey world!");
|
||||
});
|
||||
|
||||
it("lists with a single empty item are not considered markdown", function () {
|
||||
const pc = createPartCreator();
|
||||
|
||||
const model1 = new EditorModel([pc.plain("-")], pc);
|
||||
const html1 = htmlSerializeIfNeeded(model1, {});
|
||||
expect(html1).toBe(undefined);
|
||||
|
||||
const model2 = new EditorModel([pc.plain("* ")], pc);
|
||||
const html2 = htmlSerializeIfNeeded(model2, {});
|
||||
expect(html2).toBe(undefined);
|
||||
|
||||
const model3 = new EditorModel([pc.plain("2021.")], pc);
|
||||
const html3 = htmlSerializeIfNeeded(model3, {});
|
||||
expect(html3).toBe(undefined);
|
||||
});
|
||||
|
||||
it("lists with a single non-empty item are still markdown", function () {
|
||||
const pc = createPartCreator();
|
||||
const model = new EditorModel([pc.plain("2021. foo")], pc);
|
||||
const html = htmlSerializeIfNeeded(model, {});
|
||||
expect(html).toBe('<ol start="2021">\n<li>foo</li>\n</ol>\n');
|
||||
});
|
||||
});
|
||||
|
||||
describe("with plaintext", function () {
|
||||
|
Reference in New Issue
Block a user