mirror of
https://github.com/danbulant/Nertivia-Client
synced 2026-06-24 17:11:43 +00:00
add attributes
This commit is contained in:
parent
64bfc691c9
commit
fd8448b5cc
2 changed files with 34 additions and 10 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
<div class="triangle">
|
<div class="triangle">
|
||||||
<div class="triangle-inner" />
|
<div class="triangle-inner" />
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content" @dblclick="contentDoubleClickEvent">
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<div class="username"
|
<div class="username"
|
||||||
@click="openUserInformation"
|
@click="openUserInformation"
|
||||||
|
|
@ -149,8 +149,12 @@ export default {
|
||||||
|
|
||||||
},
|
},
|
||||||
editMessage() {
|
editMessage() {
|
||||||
|
if (this.uniqueID !== this.user.uniqueID) return;
|
||||||
this.dropDownVisable = false;
|
this.dropDownVisable = false;
|
||||||
this.$store.dispatch("setEditMessage", {channelID: this.channelID, messageID: this.messageID, message: this.message});
|
this.$store.dispatch("setEditMessage", {channelID: this.channelID, messageID: this.messageID, message: this.message});
|
||||||
|
},
|
||||||
|
contentDoubleClickEvent(event){
|
||||||
|
if (event.target.classList.contains("content") || event.target.closest('.user-info')) this.editMessage();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -449,6 +453,10 @@ export default {
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
|
.code-inline{
|
||||||
|
background: rgba(0, 0, 0, 0.322);
|
||||||
|
}
|
||||||
.msg-link {
|
.msg-link {
|
||||||
color: rgb(86, 159, 253);
|
color: rgb(86, 159, 253);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,16 +28,32 @@ const markdown = new MarkdownIt({
|
||||||
|
|
||||||
|
|
||||||
//add attributes to link tag
|
//add attributes to link tag
|
||||||
const defaultRender = markdown.renderer.rules.link_open || function(tokens, idx, options, env, self) {
|
(function() {
|
||||||
return self.renderToken(tokens, idx, options);
|
const defaultRender = markdown.renderer.rules.link_open || function(tokens, idx, options, env, self) {
|
||||||
};
|
return self.renderToken(tokens, idx, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
markdown.renderer.rules.link_open = function (tokens, idx, options, env, self) {
|
||||||
|
tokens[idx].attrPush(['target', '_blank']); // add new attribute
|
||||||
|
tokens[idx].attrPush(['class', 'msg-link']);
|
||||||
|
// pass token to default renderer.
|
||||||
|
return defaultRender(tokens, idx, options, env, self);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
markdown.renderer.rules.link_open = function (tokens, idx, options, env, self) {
|
// add addribute to code
|
||||||
tokens[idx].attrPush(['target', '_blank']); // add new attribute
|
(function() {
|
||||||
tokens[idx].attrPush(['class', 'msg-link']);
|
const defaultRender = markdown.renderer.rules.code_inline || function(tokens, idx, options, env, self) {
|
||||||
// pass token to default renderer.
|
return self.renderToken(tokens, idx, options);
|
||||||
return defaultRender(tokens, idx, options, env, self);
|
};
|
||||||
};
|
|
||||||
|
markdown.renderer.rules.code_inline = function (tokens, idx, options, env, self) {
|
||||||
|
tokens[idx].attrPush(['class', 'code-inline']);
|
||||||
|
// pass token to default renderer.
|
||||||
|
return defaultRender(tokens, idx, options, env, self);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
console.log(markdown.renderer.rules)
|
||||||
|
|
||||||
|
|
||||||
export default (message) => {
|
export default (message) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue