Editor toolbar generates invalid multi-paragraph spoilers

AI 生成的摘要

The editor toolbar generates invalid multi-paragraph spoilers. To reproduce the issue, select two paragraphs with double line breaks, click the gear, and click “Blur Spoiler.” The actual output is an inline spoiler that does not render correctly.

dfabulich reports that the bug is still present, despite claims that it was fixed. The expected behavior is to insert spoiler tags at the start and end of the selection, creating a multi-paragraph spoiler block.

codinghorror agrees that the editor should add spoiler BBCode tags at the top and bottom of the selection, and sam notes that the code toolbar button already works this way for inline spoilers.

zogstrip mentions that supporting mixed formatting within a spoiler block is not possible due to limitations in BBCode. However, codinghorror and sam argue that fixing the toolbar to use “block mode” for multi-line selections is a simple solution.

The issue has been assigned to pmusaraj, who has fixed the problem via two commits, making the toolbar button use “block mode” for multi-line selections.

Continuing the discussion from HTML <b> across paragraph breaks differs between preview and result:

The editor bug is still there as far as I can see.

To reproduce: on meta.discourse.org or try.discourse.org, type two paragraphs with double line breaks separating them like this:

foo

bar

Select the paragraphs, click the gear, and click “Blur Spoiler.”

Actual: The editor inserts spoiler tags inline at the start/end of the selection, which used to work, but which no longer makes a multi-paragraph spoiler.

[spoiler]foo

bar[/spoiler]

It renders like this:

[spoiler]foo

bar[/spoiler]

Expected:

[spoiler]
foo

bar
[/spoiler]

foo

bar

4 个赞

Note that it should also do the right thing if you select the spoilers in this example:

foo Rosebud is a sled

Bruce Willis died in Act 1

It was Kevin Spacey the whole time

Darth is Anakin bar 

Currently it does this:

foo [spoiler]Rosebud is a sled

Bruce Willis died in Act 1

It was Kevin Spacey the whole time

Darth is Anakin[/spoiler] bar

I’m not 100% sure what it should do in this case. One thing it might do is convert the inline spoilers into a spoiler block like this.

foo
[spoiler]
Rosebud is a sled

Bruce Willis died in Act 1

It was Kevin Spacey the whole time

Darth is Anakin
[/spoiler]
bar

foo

Rosebud is a sled

Bruce Willis died in Act 1

It was Kevin Spacey the whole time

Darth is Anakin

bar

But perhaps instead it should wrap each inline section with its own [spoiler] tag and embed all of the paragraphs in a spoiler block.

foo [spoiler]Rosebud is a sled[/spoiler]

[spoiler]
Bruce Willis died in Act 1

It was Kevin Spacey the whole time
[/spoiler]

[spoiler]Darth is Anakin[/spoiler] bar 

foo Rosebud is a sled

Bruce Willis died in Act 1

It was Kevin Spacey the whole time

Darth is Anakin bar

But that introduces three spoilers; you have to click on each spoiler one at a time to reveal it. :confused:

Incorrect, it should simply add spoiler BBCode tags at the top and bottom. And if it does not, we should definitely fix that @eviltrout

[spoiler]
foo Rosebud is a sled

Bruce Willis died in Act 1

It was Kevin Spacey the whole time

Darth is Anakin bar 
[/spoiler]

I guess that’s OK, too. (A bit weird that non-spoiler text “foo” and “bar” sneaks in.)

I just want to make sure inline spoilers will still work.

So if you select the spoiler here:

foo Rosebud is a sled bar

it should continue to generate an inline spoiler

foo [spoiler]Rosebud is a sled[/spoiler] bar

foo Rosebud is a sled bar

Yes, that is more or less how the code toolbar button already works – try it – so I think @eviltrout can just adopt that exact behavior.

@eviltrout I recall fixing this a few weeks back with the details plugin.

Current behavior:

test []test

test[] test

Hit spoiler

test [spoiler]test

test[/spoiler] test

Desired

test
[spoiler]
test

test
[/spoiler]
test

Since spoiler is also inline, this needs to work as well

text spoil text
text [spoiler]spoil[/spoiler] text
3 个赞

如果这仍然是一个问题,能否请@eviltrout 指派专人处理?

[spoiler]这仍然

是一个问题[/spoiler]

2 个赞

这很难修复,因为我们只支持 块级或内联 BBCode

[spoiler]
块级内容
[/spoiler]
[spoiler]内联内容[/spoiler]

看起来不难,只需为多行选择使用正确的格式即可?

1 个赞

是的,这并非 Markdown 修复,只是对工具栏运行方式的调整。工具栏会生成错误的 Markdown,它需要更智能地处理换行。

1 个赞

好的,当选区中包含换行符时,将工具栏固定为“块模式”很容易实现。

但支持

[spoiler]混合
格式
[/spoiler]

则不容易。

1 个赞

是的,但这里要求的仅此而已。

3 个赞

@pmusaraj 能看一下吗?编辑器中的选择和按钮已经过充分测试,因此为这种情况创建测试应该相当直观。

3 个赞

这应通过以下两个提交修复(core,discourse-spoiler-alert):如果选中的文本为多行,工具栏按钮将使用“块模式”。

6 个赞

此主题已在 47 小时后自动关闭,不再接受新回复。