mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
markdown links in chat will now open in a blank window.
* added `target` attribute for the markdown directive to specify. default behavior is `_self`.
This commit is contained in:
@@ -100,7 +100,7 @@ habitrpg.directive('habitrpgSortable', ['User', function(User) {
|
||||
.replace(/'/g, ''');
|
||||
};
|
||||
if (cap[0].charAt(0) !== '!') {
|
||||
return '<a target="_blank" class="markdown-link" href="'
|
||||
return '<a class="markdown-link" href="'
|
||||
+ escape(link.href)
|
||||
+ '"'
|
||||
+ (link.title
|
||||
@@ -114,7 +114,7 @@ habitrpg.directive('habitrpgSortable', ['User', function(User) {
|
||||
} else {
|
||||
return '<a class="markdown-img-link" href="'
|
||||
+ escape(link.href)
|
||||
+ '" target="_blank"'
|
||||
+ '"'
|
||||
+ (link.title
|
||||
? ' title="'
|
||||
+ escape(link.title)
|
||||
@@ -147,7 +147,9 @@ habitrpg.directive('habitrpgSortable', ['User', function(User) {
|
||||
link: function(scope, element, attrs) {
|
||||
scope.$watch(attrs.ngModel, function(value, oldValue) {
|
||||
var markdown = value;
|
||||
var linktarget = attrs.target || '_self';
|
||||
var html = md.toHtml(markdown);
|
||||
html = html.replace(' href','target="'+linktarget+'" href');
|
||||
element.html(html);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ li(bindonce='group.chat', ng-repeat='message in group.chat', bo-class='{highligh
|
||||
a.label.chat-message(class='hidden-label')
|
||||
span {{message.user}}
|
||||
|
|
||||
markdown(ng-model='message.text')
|
||||
markdown(ng-model='message.text',target='_blank')
|
||||
| -
|
||||
span.muted.time(from-now='message.timestamp')
|
||||
a(bo-show='user.contributor.admin || message.uuid == user.id', ng-click='deleteChatMessage(group, message)')
|
||||
|
||||
Reference in New Issue
Block a user