LOVE IT.
We definitely need a BBCode Manager down the line at this rate
LOVE IT.
We definitely need a BBCode Manager down the line at this rate
New version released which adds an audio bbcode.
Audio:
[audio mp3="song.mp3" ogg="song.ogg"]
or
[audio mp3="song.mp3"]
Result would be the browser's default audio player. I'm not including a screenshot since each browser is different. Also, I'm the author of the Soundmanager 2 audio extension. That extension is not compatible with the audio bbcode in this extension. So, you have a decision to make. Use this extension and have default browser audio players which sometimes look cool and have nice features like volume control and a download menu. Or, use my Soundmanager 2 extension which is compatible with more audio types, and will look the same in different browsers. But the player is simply a button basically. No controls.
https://github.com/zerosonesfun/bbbbcode/releases/tag/0.3.1
[space][/space]
https://github.com/zerosonesfun/bbbbcode/releases/tag/0.3.4
[spoiler="THIS IS THE HIDDEN TEXT"]Click at your own risk[/spoiler]
See the first post for a GIF example.
katos Anything's possible. But, that's out of my realm. The only thing I could do for you at this time is tell you how to disable the popup one completely. Or, one could make the bbcode very specific/unique, almost like a password, so that a regular member wouldn't know how to do it. For example, one could make the popup bbcode something like, [pop019284746]. Making it really hard for a normal user to guess what the bbcode is to make a popup.
katos I don't know if that's possible, as the Formatter configuration (which includes plugins added through extensions such as fof/formatting and custom bbcodes) is cached, so is only called when enabling/disabling some extensions and clearing the cache.
Perhaps one can simply make it so it doesn't render it (still processed though).
010101 one could make the bbcode very specific/unique, almost like a password, so that a regular member wouldn't know how to do it
If the bbcode is rendered in the editor preview, then its name can be found in the javascript source code.
Disabling the bbcode for certain groups could be done in the backend of frontend. In the backend you'd have to hook to the Rendering event and alter the html output by either completely removing it, or removing/adding a class that would disable it.
Or it could be done completely client side, by looking at the post author's groups or a policy on the post payload and using that information to allow opening the modal or not.
First off, these are great features to have, thanks for making this extension!
There are several problems I've noticed, though:
[spoiler]
completely breaks if there's more than one of them in a thread. Attempting to "show" a second or third spoiler in a thread just jumps up the page and opens up the first one (but can't close it again). This means there's no way to see content hidden under a second or third spoiler. [pop]
breaks in this same way-- attempting to "show" a second or third popup in a thread just opens up the first one.[spoiler]
doesn't work if there's any BBcode formatting in the spoiled text (I assume it interferes with the brackets of the [spoiler] tag itself). [spoiler]
also doesn't work if there are any line breaks in the text (i.e. multiple paragraphs). Markdown in the spoiled text doesn't break the [spoiler]
, but it simply doesn't format (it just displays as asterisks etc.). This severely limits the applicability of the tag.[spoiler=description text]hidden text[/spoiler]
. BBBBcode's spoiler is [spoiler=hidden text]description text[/spoiler]
. This switch has the potential to confuse users used to other forum platforms, as well as violating the principle that the shorter text should be mapped to the attribute field and the longer text mapped to the actual content field.[accordion]
box after opening it, except by opening another accordion (even though the box shows a "close" arrow when it's open, this button does nothing). This means that once the first accordion has been clicked, there will always be a single accordion open; you cannot have either no accordions open or multiple accordions open. It would be great to be able to close everything back up or open multiple boxes at once.[accordion]
titles, like [spoiler]
hidden texts, break with any BBcode and don't allow the use of Markdown.I understand that it's fun to try and make all these without using JS, but I wonder if it's more trouble than it's worth (your call though).
010101 putting BBcode inside of BBcode isn’t compatible no matter what
Actually, it is very possible. You'll need to use XSL for it. You can see an example @ https://github.com/FriendsOfFlarum/bbcode-tabs/blob/master/extend.php#L25.
PS: I learned how to do this today
datitisev I don’t understand how I could go the XSL route to allow all standard BBcode inside of a tag like this: [bbcode=“this is [b]bold[/b]”]
It seems like, if that was allowed, it would just work. I get using XSL for additional custom tags/parameters, but I’m not immediately seeing how it would need to be set up to allow all of the standard BBcode inside of the opening tag. But, I’m also not sure I want to allow that anyway.
Somyrion - Thanks again for the suggestions. I'll be releasing a new version shortly. Below is a summary of your suggestions and what I've been able to address:
[b]
bold[/b]
bbcode instead of custom bbcode tags[/bbcode] EDIT: Never mind. That is allowed. What’s not allowed is [bbcode=“some [b]bold[/b]
text”]How to update:
1) Run composer update zerosonesfun/bbbbcode
2) Empty CDN cache like Cloudflare if you use it.
3) Go to your dashboard, click on tools, and empty that cache.
4) Clear your browser cache and cookies.
010101
[bbcode] Then this is the content but I may want to [b]bold[/b] this word. [/bbcode]
This already works with Flarum's standard BBcode, and shouldn't be a problem (there's something wrong if your custom [tag]
closes itself with anything other than [/tag]
). See for example:
[u]Underlined content [b]with a section in bold[/b] here[/u]
becomes
Underlined content with a section in bold here
It actually looks to me like that's not the problem your tags are facing. For example, in your (edit: old) spoiler code, the description text - the part in between the tags ([spoiler=content]descrip[b]tion[/b] text[/spoiler]
) can be formatted just fine with BBCode and Markdown.
The problem is not using BBCode between two custom tags, but using BBCode within the tag itself:
[spoiler=can I [b]bold[/b] this text?]description text[/spoiler]
This is more of an issue because the open [spoiler=
can be unintentionally and erroneously closed by the closing bracket of the b]
tag. Maybe the solution to preventing this is to require that the text after the =
has quotes around it? I know of other forums/sites that manage to allow formatting within tags themselves, so it's worth looking into. @datitisev mentioned XSL marking as the key here, which may be the right way to do it if you can figure that out.
EDIT: Just saw your new posts. Thanks so much for the extremely speedy responses and changes, looking forward to trying out the new version!
Somyrion The problem is not using BBCode between two custom tags, but using BBCode within the tag itself:
Ok, this makes sense. Thanks for clarifying. You are right, BBcodes in between two BBcode tags works just fine. So, you can bold, underline, change colors, do whatever you need to do with BBcode for the spoiler content itself, and well as, for the popup BBcode, and the content for the accordion.
So, it's not as big of a deal as I was originally thinking. The only parts you can't further modify with additional BBcode are certain code's titles or headers. If someone knows of a quick fix let me know. But, I'm not interested in re-writing a lot just so that titles or the text you click on can be further BBcoded.
Please also keep in mind - I created this for my forums too. I don't want my members to be able to go too crazy and do a ton of formatting on parts like this. I personally like to keep things clean and a little more restrictive. So, I may not pursue this further unless I get really bored one day.
Thanks again for helping figure all this out and for the great suggestions!
010101 Yep, switching around the spoiler setup actually solved the issue for the most part. It's really useful to be able to put formatted text underneath a spoiler, but less necessary to be able to format the spoiler description text. If you ever get around to it, it'd be really great to be able to format the description text as well but it's not as crucial.
010101 I meant inside the BBCode content, not attributes, sorry. You'll want to do this with most, if not all, the bbcodes added by this extension, else you can only use plain text.
Here's an example using your code found @ https://github.com/zerosonesfun/bbbbcode/blob/master/extend.php.
$config->BBCodes->addCustom(
'[tooltip="{TEXT1}" placement="{TEXT2}"]{TEXT3}[/tooltip]',
<<<XML
<span class="bb-tooltip" data-tooltip="{TEXT1}" data-placement="{TEXT2}">
<xsl:apply-templates/>
</span>
XML
);