Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.card{
max-width:600px;
margin: auto;
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
border-radius: 12px;
}
textarea{
resize: none;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
api.controller=function($scope,$sce) {
/* widget controller */
var c = this;

c.emojiMap ={
':smile:' :'😊',
':sad:':'😓',
":heart:":'❤️',
":thumbsup:":'👍',
":laugh:":"😀",
":wink:":"😉",
":clap:":"👏",
":party:" :"🥳"
};

c.replaceEmojis = function(){
var text = $scope.data.inputText || '';

for(var key in c.emojiMap){
var regex = new RegExp(key.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1"),'g');
text = text.replace(regex,c.emojiMap[key]);
}
c.outputText= $sce.trustAsHtml(text);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This use of $sce.trustAsHtml() gives explicit trust to the input and makes this widget vulnerable - using the below input will allow XSS:
<script>alert("XSS");</script>. I'll create an issue and quickly resolve this in a follow up

}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="card p-3">
<h4>😊
Emoji Replacer
</h4>
<p class="text-muted">
Type something using emoji shortcuts like <code>:smile:</code>,<code>:heart:</code>, or<code>:thumbsup:</code>
</p>
<textarea class="form-control" rows="4" ng-model="data.inputText" ng-change="c.replaceEmojis()"
placeholder="Type your message here..."></textarea>
<div class ="mt-3">
<h5>
Ouput Preview:
</h5>
<div class="p-2 border rounded bg-light" ng-bind-html="c.outputText">

</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Emoji Replacer Widget

This widget enhances the user experience by automatically converting emojis code into visual emojis while typing - adding personality and clarity to text communication.
## How It works
- User types in a text box:
- "Great job team!:tada::thumbsup:"
- Script will detects matching emoji code using regex.
- The widget replaces them with real emojis:
- "Great job team!🎉👍
## Available Emoji in Widget
":smile:" :😊,
":sad:":😓,
":heart:":❤️,
":thumbsup:":👍,
":laugh:":😀,
":wink:":😉,
":clap:":👏,
":party:":🥳,
":tada:":🎉
## Output


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading