feat(bbcode): Implement color customization for [box] tag (#1920)

* feat(bbcode): implement color customization for `[box]` tag

* feat(bbcode): implement color customization for `[box]` tag
This commit is contained in:
Roman Kelesidis 2025-06-07 14:46:42 +03:00 committed by GitHub
commit 4c24cb65bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 3 deletions

View file

@ -83,6 +83,23 @@ HTML;
<span class="post-hr">-</span>
HTML;
// Box
$bbcode_tpl['box_open'] = <<<HTML
<div class="post-box-default"><div class="post-box">
HTML;
$bbcode_tpl['box_open_color'] = <<<HTML
<div class="post-box-default"><div class="post-box" style="border-color: $1; background-color: $2;">
HTML;
$bbcode_tpl['box_open_color_single'] = <<<HTML
<div class="post-box-default"><div class="post-box" style="border-color: $1;">
HTML;
$bbcode_tpl['box_close'] = <<<HTML
</div></div>
HTML;
array_deep($bbcode_tpl, 'bbcode_tpl_compact');
return $bbcode_tpl;
}

View file

@ -1842,7 +1842,7 @@ $lang['BOLD'] = 'Bold text: [b]text[/b] (Ctrl+B)';
$lang['ITALIC'] = 'Italic text: [i]text[/i] (Ctrl+I)';
$lang['UNDERLINE'] = 'Underline text: [u]text[/u] (Ctrl+U)';
$lang['STRIKEOUT'] = 'Strikeout text: [s]text[/s] (Ctrl+S)';
$lang['BOX_TAG'] = 'Frame around text: [box]text[/box]';
$lang['BOX_TAG'] = 'Frame around text: [box]text[/box] or [box=#333,#888]text[/box]';
$lang['INDENT_TAG'] = 'Insert indent: [indent]text[/indent]';
$lang['SUPERSCRIPT'] = 'Superscript text: [sup]text[/sup]';
$lang['SUBSCRIPT'] = 'Subscript text: [sub]text[/sub]';

View file

@ -97,6 +97,8 @@ class BBCode
"#\[img=(left|right|center)\]($img_exp)\[/img\]\s*#isu" => $tpl['img_aligned'],
"#\[email\]($email_exp)\[/email\]#isu" => '<a href="mailto:$1">$1</a>',
"#\[qpost=([0-9]*)\]#isu" => '<u class="q-post">$1</u>',
'#\[box=(?:\s*[\'"])?([\#0-9a-zA-Z]+)(?:[\'"]\s*)?\]#isu' => $tpl['box_open_color_single'],
'#\[box=(?:\s*[\'"])?([\#0-9a-zA-Z]+)(?:[\'"]\s*)?,\s*[\'"]?([\#0-9a-zA-Z]+)[\'"]?\]#isu' => $tpl['box_open_color'],
];
$this->str = [
@ -127,8 +129,8 @@ class BBCode
'[/sup]' => '</small></sup>',
'[sub]' => '<sub><small>',
'[/sub]' => '</small></sub>',
'[box]' => '<div class="post-box-default"><div class="post-box">',
'[/box]' => '</div></div>',
'[box]' => $tpl['box_open'],
'[/box]' => $tpl['box_close'],
'[indent]' => '<div class="post-indent">',
'[/indent]' => '</div>',
'[del]' => '<span class="post-s">',