Editor toolbar generates invalid multi-paragraph spoilers

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 Me gusta

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 Me gusta

¿Puedes asignar a alguien a esto @eviltrout si sigue siendo un problema?

[spoiler]Aún es

un problema[/spoiler]

2 Me gusta

Esto va a ser difícil de solucionar, ya que solo soportamos BBCode de bloque o en línea

[spoiler]
block
[/spoiler]
[spoiler]inline[/spoiler]

No parece difícil, ¿simplemente usa la forma correcta para selecciones de varias líneas?

1 me gusta

Sí, no es una corrección de Markdown, simplemente un ajuste en la forma en que funciona la barra de herramientas. La barra de herramientas genera Markdown incorrecto; necesita ser más inteligente al agregar saltos de línea.

1 me gusta

Bien, es fácil corregir la barra de herramientas para que use el “modo bloque” cuando hay saltos de línea en la selección.

Sin embargo, no es tan sencillo dar soporte a

[spoiler]formato
mixto
[/spoiler]
1 me gusta

Sí, pero eso es lo único que se está solicitando aquí.

3 Me gusta

@pmusaraj ¿puedes echar un vistazo? La selección y los botones en el editor están muy bien probados, por lo que debería ser bastante obvio cómo crear una prueba para esta situación.

3 Me gusta

Esto debería solucionarse mediante estos dos commits (core, discourse-spoiler-alert); el botón de la barra de herramientas utilizará el «modo bloque» si la cadena seleccionada abarca varias líneas.

6 Me gusta

Este tema se cerró automáticamente después de 47 horas. Ya no se permiten nuevas respuestas.