mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 03:58:34 +08:00
FIX: ensure [date-range don't clashes with checklist
Adding the "→" was not setting the proper token nesting hierarchy.
This commit is contained in:
parent
d3f7b3b5f9
commit
36659531f7
|
@ -10,7 +10,10 @@ let currentRaw;
|
|||
|
||||
async function prepare(raw) {
|
||||
const cooked = await cook(raw, {
|
||||
siteSettings: { checklist_enabled: true },
|
||||
siteSettings: {
|
||||
checklist_enabled: true,
|
||||
discourse_local_dates_enabled: true,
|
||||
},
|
||||
});
|
||||
|
||||
const widget = { attrs: {}, scheduleRerender() {} };
|
||||
|
@ -38,6 +41,23 @@ acceptance("discourse-checklist | checklist", function (needs) {
|
|||
]);
|
||||
});
|
||||
|
||||
test("does not clash with date-range bbcode", async function (assert) {
|
||||
const [$elem, updated] = await prepare(`
|
||||
[date-range from=2024-03-22 to=2024-03-23]
|
||||
|
||||
[ ] task 1
|
||||
[ ] task 2
|
||||
[x] task 3
|
||||
`);
|
||||
|
||||
assert.equal($elem.find(".discourse-local-date").length, 2);
|
||||
assert.equal($elem.find(".chcklst-box").length, 3);
|
||||
$elem.find(".chcklst-box")[0].click();
|
||||
|
||||
const output = await updated;
|
||||
assert.ok(output.includes("[x] task 1"));
|
||||
});
|
||||
|
||||
test("does not check an image URL", async function (assert) {
|
||||
const [$elem, updated] = await prepare(`
|
||||
![](upload://zLd8FtsWc2ZSg3cZKIhwvhYxTcn.jpg)
|
||||
|
|
|
@ -115,7 +115,7 @@ function defaultDateConfig() {
|
|||
}
|
||||
|
||||
function parseTagAttributes(tag) {
|
||||
const matchString = tag.replace(/‘|’|„|“|«|»|”/g, '"');
|
||||
const matchString = tag.replace(/[‘’„“«»”]/g, '"');
|
||||
|
||||
return parseBBCodeTag(
|
||||
"[date date" + matchString + "]",
|
||||
|
@ -162,7 +162,9 @@ function addLocalRange(buffer, matches, state) {
|
|||
addSingleLocalDate(buffer, state, config);
|
||||
}
|
||||
if (config.range) {
|
||||
closeBuffer(buffer, state, "→");
|
||||
const token = new state.Token("text", "", 0);
|
||||
token.content = "→";
|
||||
buffer.push(token);
|
||||
}
|
||||
if (parsed.attrs.to) {
|
||||
[date, time] = parsed.attrs.to.split("T");
|
||||
|
|
Loading…
Reference in New Issue
Block a user