Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Minor fix UI
Enable Emoji & display issue
Fix \@ & \# detect
  • Loading branch information
cth-inni committed Oct 26, 2021
1 parent 65bb5ed commit e395477
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
49 changes: 23 additions & 26 deletions src/ChatBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ private function replaceEmojiTexttoImage($source='') {
$selectedEmoji = trim($emoji,':');
if(isset($this->emojiList[$selectedEmoji]))
{ // If exist in source's list
$selectedEmoji = '<img src="'.$this->emojiList[$selectedEmoji].'" />';
$selectedEmoji = '<img class="emoji-icon" alt="'.$selectedEmoji.'" src="'.$this->emojiList[$selectedEmoji].'" />';
}
$newTarget = preg_replace('/'.$emoji.'/', $selectedEmoji, $newTarget);
}
Expand Down Expand Up @@ -536,13 +536,10 @@ public function render(){
}else{
if(isset($this->dialogue['casts'][0]) && $this->dialogue['casts'][0]['name'] == $dialogue['_castname'])
{ // maincast
// $tempHtml .= $this->role_rightSide($dialogue);
$tempHtml .= $this->renderRoleSide($dialogue,'right',$this->settings->mainCastColor);
}else{
if(!is_null($dialogue['_context']))
{ // others cast
// $tempHtml .= $this->role_leftSide($dialogue);
// $chatColor = $this->loadCastColor($dialogue['_castname']);
$tempHtml .= $this->renderRoleSide($dialogue,'left',$this->loadCastColor($dialogue['_castname']));
}else
{ // Normal text
Expand Down Expand Up @@ -819,6 +816,7 @@ private function render_decisions_holder($dialogue)
// Misc
private function fn_stripTags($dialogue)
{
// return ($dialogue); // Strip all tag
return strip_tags($dialogue); // Strip all tag
}
private function fn_filter($dialogue)
Expand All @@ -832,10 +830,10 @@ private function fn_filter($dialogue)
switch($set[1])
{
case '`': $tag = 'code'; break;
case '*': $tag = 'b'; break;
case '-': $tag = 'del'; break;
case '_': $tag = 'em'; break;
default: $tag = null; break;
case '_': $tag = 'em'; break;
case '*': $tag = 'b'; break;
default: $tag = null; break;
}
if(!is_null($tag))
{
Expand All @@ -844,25 +842,21 @@ private function fn_filter($dialogue)
}
// Bold, Italic, Code, Delete - end
// @,# - start
// $regex = '([\@\#])((?:(?!\1).)+)\s';
// $regex = '[\#|\@][^$]';
// $regex = '(^|\s)[\#\@](\w*[a-zA-Z_]+\w*)';
// $regex = '([\#\@]\w*)';
// preg_match_all("~$regex~", $newStr, $matches2, PREG_SET_ORDER);
// foreach($matches2 as $set2)
// {
// print_r($set2);
// switch($set[1])
// {
// case '@': $tag = 'cast'; break;
// case '#': $tag = 'topic'; break;
// default: $tag = null; break;
// }
// if(!is_null($tag))
// {
// $newStr = str_replace($set2[0], "<span class=\"chat-label chat-label-{$tag}\">{$set2[2]}</span>&nbsp;", $newStr);
// }
// }
$regex = '([\@\#])((?:\S(?!\S\1))+)'; // start with @ or #, end with whitespace, no whitespace in between
preg_match_all("~$regex~", $newStr, $matches2, PREG_SET_ORDER);
foreach($matches2 as $set2)
{
switch($set2[1])
{
case '@': $tag = 'cast'; break;
case '#': $tag = 'topic'; break;
default: $tag = null; break;
}
if(!is_null($tag))
{
$newStr = str_replace($set2[0], "<span class=\"chat-label chat-label-{$tag}\">{$set2[2]}</span>", $newStr);
}
}
// @,# - end
$newStr = str_replace($this->linebreak,'<br/>',$newStr); // Allow to multiples lines
return trim($newStr);
Expand Down Expand Up @@ -945,6 +939,9 @@ private function renderRoleSide($dialogue,$direction='left',$color='#CCC')
case 'youtube':
$context = '<iframe frameborder="0" width="100%" height="90%" src="//www.youtube.com/embed/'.$dataPath.'"></iframe>';
break;
default:
$context = ($dialogue['_context']);
break;
}
$tempHtml .= '<p class="from-'.$classDirection.' disable-select" style="background-color:'.$color.'!important;">'.$context.'</p>';
}else{
Expand Down
11 changes: 9 additions & 2 deletions src/chatblock.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,22 @@

.chatblock .imessage p {
border-radius: 1.15rem;
line-height: 1.75;
line-height: 2;
max-width: 75%;
padding: 0.5rem;
padding: 0.5rem 0.75rem;
position: relative;
word-wrap: break-word;
text-align: justify;
}

.chatblock .imessage p img {
border-radius: 1rem;
}

.chatblock .imessage p img.emoji-icon {
max-width: 2rem;
}

.chatblock .imessage p::before,
.chatblock .imessage p::after {
bottom: -0.1rem;
Expand Down Expand Up @@ -251,6 +256,8 @@

.chatblock .imessage .chat-label{
font-weight: bold;
text-decoration: underline;
margin: 0px 4px;
}

.chatblock .imessage .text-center,
Expand Down

0 comments on commit e395477

Please sign in to comment.