mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-01 15:31:16 +00: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:
parent
6736da36d4
commit
f4323ddc24
2 changed files with 5 additions and 3 deletions
|
|
@ -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)')
|
||||
|
|
|
|||
Loading…
Reference in a new issue