Skip to content

Commit 5b4f8b5

Browse files
authored
Emoji Replacer Widget (ServiceNowDevProgram#2590)
* Create README.md * Create HTML.html * Create CSS-SCSS.css * Create Client Script.cs * Update README.md * Update README.md * Add files via upload
1 parent 7b011df commit 5b4f8b5

File tree

5 files changed

+74
-0
lines changed

5 files changed

+74
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.card{
2+
max-width:600px;
3+
margin: auto;
4+
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
5+
border-radius: 12px;
6+
}
7+
textarea{
8+
resize: none;
9+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
api.controller=function($scope,$sce) {
2+
/* widget controller */
3+
var c = this;
4+
5+
c.emojiMap ={
6+
':smile:' :'😊',
7+
':sad:':'😓',
8+
":heart:":'❤️',
9+
":thumbsup:":'👍',
10+
":laugh:":"😀",
11+
":wink:":"😉",
12+
":clap:":"👏",
13+
":party:" :"🥳"
14+
};
15+
16+
c.replaceEmojis = function(){
17+
var text = $scope.data.inputText || '';
18+
19+
for(var key in c.emojiMap){
20+
var regex = new RegExp(key.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1"),'g');
21+
text = text.replace(regex,c.emojiMap[key]);
22+
}
23+
c.outputText= $sce.trustAsHtml(text);
24+
}
25+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div class="card p-3">
2+
<h4>😊
3+
Emoji Replacer
4+
</h4>
5+
<p class="text-muted">
6+
Type something using emoji shortcuts like <code>:smile:</code>,<code>:heart:</code>, or<code>:thumbsup:</code>
7+
</p>
8+
<textarea class="form-control" rows="4" ng-model="data.inputText" ng-change="c.replaceEmojis()"
9+
placeholder="Type your message here..."></textarea>
10+
<div class ="mt-3">
11+
<h5>
12+
Ouput Preview:
13+
</h5>
14+
<div class="p-2 border rounded bg-light" ng-bind-html="c.outputText">
15+
16+
</div>
17+
</div>
18+
</div>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Emoji Replacer Widget
2+
3+
This widget enhances the user experience by automatically converting emojis code into visual emojis while typing - adding personality and clarity to text communication.
4+
## How It works
5+
- User types in a text box:
6+
- "Great job team!:tada::thumbsup:"
7+
- Script will detects matching emoji code using regex.
8+
- The widget replaces them with real emojis:
9+
- "Great job team!🎉👍
10+
## Available Emoji in Widget
11+
":smile:" :😊,
12+
":sad:":😓,
13+
":heart:":❤️,
14+
":thumbsup:":👍,
15+
":laugh:":😀,
16+
":wink:":😉,
17+
":clap:":👏,
18+
":party:":🥳,
19+
":tada:":🎉
20+
## Output
21+
22+
18.2 KB
Loading

0 commit comments

Comments
 (0)