Can we have a "spoiler" tag in basic bbcode set? Using it as my separate plugin for xbbcode now:

<?php
function xbbcode_spoiler_init() {
drupal_add_js('misc/collapse.js');
}
function xbbcode_spoiler_xbbcode_info() {
  $tags['spoiler'] = array(
    'markup' => '<fieldset class="collapsible collapsed">
     <legend><span class="fieldset-legend">Hidden text</span></legend>
     <div class="fieldset-wrapper">{content}</div>
</fieldset>',
    'description' => t('Hidden text'),
    'sample' => t('[spoiler]Text[/spoiler]'),
   );
   return $tags;
}

Comments

cburschka’s picture

Status: Active » Needs work

This looks great! Pity that it will require unconditionally loading collapse.js once it's in, but that's not much overhead.
Just make the label translatable, and this is good to go.

(Also, code style: The markup doesn't really need linebreaks here. The other tags in xbbcode_basic also have all their markup in one line.)

If you can, could you upload the finished version as a patch? The tag would probably fit best just after the "definition" tag as it is a text object.

cburschka’s picture

Issue summary: View changes

minor text revision

cburschka’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)
cburschka’s picture

Version: 7.x-1.x-dev » 8.x-3.x-dev
Component: Code » Default tags
Priority: Minor » Normal
Status: Closed (won't fix) » Active

Maybe bring this back after all, now that assets can be conditionally loaded.

cburschka’s picture

Status: Active » Needs review
StatusFileSize
new1021 bytes

Annoyingly, I can't tell whether the "attached" thing actually works, because it looks like collapse.js is being loaded either way. Since the bbcode tag only returns HTML, I have no idea if the libraries attached to the rendered "Details" element have any way of bubbling up via some spooky side effect.

I'll leave them in on the grounds that it can't hurt, and it might be needed to ensure the library remains attached if the filter output is cached.

Status: Needs review » Needs work

The last submitted patch, 4: 0001-Issue-1754336-by-cburschka-basielienis-Spoiler.patch, failed testing.

cburschka’s picture

Status: Needs work » Needs review
StatusFileSize
new1021 bytes

  • cburschka committed ee30777 on 8.x-3.x
    Issue #1754336 by cburschka, basielienis: Spoiler
    
    Add a [spoiler] tag...
cburschka’s picture

Status: Needs review » Fixed

  • cburschka committed ee30777 on 9.x-1.x
    Issue #1754336 by cburschka, basielienis: Spoiler
    
    Add a [spoiler] tag...

  • cburschka committed ee30777 on 9.x-2.x
    Issue #1754336 by cburschka, basielienis: Spoiler
    
    Add a [spoiler] tag...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Dylan A’s picture

I've made a little port for Drupal 7.

In xbbcode_basic/xbbcode_basic.module, add somewhere in the function xbbcode_basic_xbbcode_info:

$tags['spoiler'] = array(
'callback' => 'xbbcode_basic_render_spoiler',
'markup' => '
Spoiler

{content}

',
'description' => t('Hidden text'),
'sample' => t('[spoiler]Text[/spoiler]'),
);

And add the following function:
function xbbcode_basic_render_spoiler($tag) {
drupal_add_js('misc/collapse.js');
}