-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #448 from RocketChat/colors-2
Process colors in messages
- Loading branch information
Showing
5 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
### | ||
# Colors is a named function that will process Colors | ||
# @param {Object} message - The message object | ||
### | ||
|
||
class ColorsClient | ||
constructor: (message) -> | ||
if _.trim message.html | ||
msg = message.html | ||
|
||
msg = msg.replace /(?:^|\s|\n)(#[A-Fa-f0-9]{3}([A-Fa-f0-9]{3})?)\b/g, (match, completeColor) -> | ||
return match.replace completeColor, "<div class=\"message-color\"><div class=\"message-color-sample\" style=\"background-color: #{completeColor}\"></div>#{completeColor.toUpperCase()}</div>" | ||
|
||
message.html = msg | ||
return message | ||
|
||
RocketChat.callbacks.add 'renderMessage', ColorsClient, RocketChat.callbacks.priority.HIGH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Package.describe({ | ||
name: 'rocketchat:colors', | ||
version: '0.0.1', | ||
summary: 'Message pre-processor that will process colors', | ||
git: '' | ||
}); | ||
|
||
Package.onUse(function(api) { | ||
api.versionsFrom('1.0'); | ||
|
||
api.use([ | ||
'coffeescript', | ||
'rocketchat:lib@0.0.1' | ||
]); | ||
|
||
api.addFiles('client.coffee', 'client'); | ||
api.addFiles('style.css', 'client'); | ||
}); | ||
|
||
Package.onTest(function(api) { | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.message-color { | ||
display: inline-block; | ||
font-weight: 100; | ||
} | ||
|
||
.message-color-sample { | ||
width: 14px; | ||
height: 14px; | ||
display: inline-block; | ||
border-radius: 3px; | ||
margin-right: 3px; | ||
margin-left: 2px; | ||
border: 1px solid rgba(0,0,0,.2); | ||
position: relative; | ||
top: 2px; | ||
} |