colored messages, format buttons

This commit is contained in:
supertiger1234 2019-11-18 17:09:10 +00:00
parent 7160a1fd88
commit 0f297f3274
8 changed files with 167 additions and 22 deletions

View file

@ -22,6 +22,7 @@
:channelID="msg.channelID" :channelID="msg.channelID"
:type="msg.type" :type="msg.type"
:timeEdited="msg.timeEdited" :timeEdited="msg.timeEdited"
:color="msg.color"
/> />
<uploadsQueue v-if="uploadQueue !== undefined" :queue="uploadQueue" /> <uploadsQueue v-if="uploadQueue !== undefined" :queue="uploadQueue" />

View file

@ -42,6 +42,17 @@
<edit-panel v-if="editMessage" :data="editMessage" /> <edit-panel v-if="editMessage" :data="editMessage" />
<div class="seperater" /> <div class="seperater" />
<div class="markdown-buttons" style="color: white;" v-if="sendMessagePermission === true || editMessage">
<div class="material-icons markdown-icon" @click="addFormat('**')" title="Bold">format_bold</div>
<div class="material-icons markdown-icon" @click="addFormat('_')" title="Italic">format_italic</div>
<div class="material-icons markdown-icon" @click="addFormat('__')" title="Underline">format_underlined</div>
<div class="material-icons markdown-icon" @click="addFormat('```\n', '\n```', 4)" title="Code block">code</div>
<div class="color-picker" title="Message color">
<input type="color" ref="colorPic" style="display: none" @change="messageColorChange" value="#e7e7e7">
<div class="color" :style="{background: customColor}" @click="$refs.colorPic.click()"></div>
<div class="reset-button" @click="customColor = null" v-if="customColor">Reset</div>
</div>
</div>
<!-- <div class="info"> <!-- <div class="info">
<div <div
@ -101,6 +112,7 @@ import MessageLogs from "@/components/app/MessageLogs.vue";
import emojiParser from "@/utils/emojiParser.js"; import emojiParser from "@/utils/emojiParser.js";
import windowProperties from "@/utils/windowProperties"; import windowProperties from "@/utils/windowProperties";
import TypingStatus from "@/components/app/TypingStatus.vue"; import TypingStatus from "@/components/app/TypingStatus.vue";
import { isMobile } from '../../utils/Mobile';
const emojiPanel = () => import("@/components/app/EmojiPanels/emojiPanel.vue"); const emojiPanel = () => import("@/components/app/EmojiPanels/emojiPanel.vue");
const EditPanel = () => import("@/components/app/EditPanel.vue"); const EditPanel = () => import("@/components/app/EditPanel.vue");
@ -126,10 +138,41 @@ export default {
typingRecipients: {}, typingRecipients: {},
showEmojiPanel: false, showEmojiPanel: false,
scrolledDown: true customColor: null,
scrolledDown: true,
mobile: isMobile(),
}; };
}, },
methods: { methods: {
messageColorChange(e) {
const hexColor = e.target.value;
this.customColor = hexColor;
},
addFormat(type, customEnding, customPos) {
const msgBox = this.$refs['input-box'];
msgBox.focus()
const startPos = msgBox.selectionStart;
const endPos = msgBox.selectionEnd;
const selection = window.getSelection();
const selected = selection.toString();
console.log(selected)
if (selected === ""){
this.message = [this.message.slice(0, endPos), type+ (customEnding||type ), this.message.slice(endPos)].join('');
this.$nextTick(() => {
const offsetCursorPos = customPos || type.length
msgBox.focus()
msgBox.setSelectionRange(endPos+ offsetCursorPos, endPos+ offsetCursorPos);
})
return;
}
this.message = [this.message.slice(0, startPos), type + selected + (customEnding||type ), this.message.slice(endPos)].join('');
this.$nextTick(() => {
msgBox.focus()
msgBox.setSelectionRange(startPos + type.length, endPos + type.length);
})
},
generateNum(n) { generateNum(n) {
var add = 1, var add = 1,
max = 12 - add; // 12 is the min safe number Math.random() can generate without it starting to pad the end with zeros. max = 12 - add; // 12 is the min safe number Math.random() can generate without it starting to pad the end with zeros.
@ -179,6 +222,7 @@ export default {
this.selectedChannelID, this.selectedChannelID,
{ {
message: msg, message: msg,
color: this.customColor,
socketID: this.$socket.id, socketID: this.$socket.id,
tempID tempID
} }
@ -199,7 +243,7 @@ export default {
const editMessage = this.editMessage; const editMessage = this.editMessage;
this.$refs["input-box"].focus(); this.$refs["input-box"].focus();
this.message = this.message.trim(); this.message = this.message.trim();
if (this.message === this.editMessage.message) { if (this.message === this.editMessage.message && (this.customColor || undefined) === (this.editMessage.color)) {
this.$store.dispatch("setEditMessage", null); this.$store.dispatch("setEditMessage", null);
this.message = ""; this.message = "";
return; return;
@ -223,6 +267,7 @@ export default {
editMessage.messageID, editMessage.messageID,
editMessage.channelID, editMessage.channelID,
{ {
color: this.customColor || -1,
message: msg message: msg
} }
); );
@ -364,6 +409,7 @@ export default {
this.emojiSwitchKey(event); this.emojiSwitchKey(event);
// when enter is press // when enter is press
if (event.keyCode == 13) { if (event.keyCode == 13) {
if (this.mobile) {return}
// and the shift key is not held // and the shift key is not held
if (!event.shiftKey) { if (!event.shiftKey) {
event.preventDefault(); event.preventDefault();
@ -393,7 +439,8 @@ export default {
this.$store.dispatch("setEditMessage", { this.$store.dispatch("setEditMessage", {
messageID: lastMessage.messageID, messageID: lastMessage.messageID,
channelID: lastMessage.channelID, channelID: lastMessage.channelID,
message: lastMessage.message message: lastMessage.message,
color: lastMessage.color,
}); });
} }
}, },
@ -474,6 +521,8 @@ export default {
this.message = editMessage this.message = editMessage
? emojiParser.emojiToShortcode(editMessage.message) ? emojiParser.emojiToShortcode(editMessage.message)
: ""; : "";
if (editMessage)
this.customColor = editMessage.color || null;
}, },
onBlur() { onBlur() {
clearTimeout(this.postTimerID); clearTimeout(this.postTimerID);
@ -714,7 +763,6 @@ export default {
align-self: center; align-self: center;
background-color: #a0c8d5; background-color: #a0c8d5;
flex-shrink: 0; flex-shrink: 0;
margin-bottom: 10px;
} }
.chat-input-area .info { .chat-input-area .info {
color: rgba(255, 255, 255, 0.466); color: rgba(255, 255, 255, 0.466);
@ -851,4 +899,57 @@ export default {
user-select: none; user-select: none;
cursor: default; cursor: default;
} }
.markdown-buttons {
display: flex;
height: 35px;
align-items: center;
align-content: center;
margin-left: 10px;
flex-shrink: 0;
.markdown-icon {
flex-shrink: 0;
display: flex;
align-content: center;
align-items: center;
justify-content: center;
user-select: none;
cursor: pointer;
height: 100%;
width: 35px;
margin-left: 2px;
transition: 0.2s;
color: #d5dcdd;
&:hover {
color: white;
}
}
}
.color-picker {
display: flex;
height: 100%;
justify-content: center;
align-items: center;
transition: 0.2s;
flex-shrink: 0;
min-width: 35px;
.color {
width: 15px;
height: 15px;
background: rgb(231, 231, 231);
flex-shrink: 0;
cursor: pointer;
}
.reset-button {
user-select: none;
cursor: pointer;
margin-left: 5px;
transition: 0.2s;
opacity: 0.6;
flex-shrink: 0;
&:hover {
opacity: 1;
}
}
}
</style> </style>

View file

@ -21,7 +21,7 @@
<div class="username" @click="openUserInformation">{{ this.$props.username }}</div> <div class="username" @click="openUserInformation">{{ this.$props.username }}</div>
<div class="date">{{ getDate }}</div> <div class="date">{{ getDate }}</div>
</div> </div>
<SimpleMarkdown class="content-message" :message="message" /> <SimpleMarkdown class="content-message" :style="[color && color !== -2 ? {color: color}: '']" :message="message" />
<div class="file-content" v-if="getFile && !getFile.fileName.endsWith('.mp3')"> <div class="file-content" v-if="getFile && !getFile.fileName.endsWith('.mp3')">
<div class="icon"> <div class="icon">
<i class="material-icons">insert_drive_file</i> <i class="material-icons">insert_drive_file</i>
@ -116,7 +116,8 @@ export default {
"embed", "embed",
"messageID", "messageID",
"channelID", "channelID",
"timeEdited" "timeEdited",
"color"
], ],
components: { components: {
ProfilePicture, ProfilePicture,
@ -139,7 +140,8 @@ export default {
messageID: this.messageID, messageID: this.messageID,
message: this.message, message: this.message,
uniqueID: this.uniqueID, uniqueID: this.uniqueID,
type: this.type type: this.type,
color: this.color
}); });
}, },
openUserInformation() { openUserInformation() {
@ -154,7 +156,8 @@ export default {
this.$store.dispatch("setEditMessage", { this.$store.dispatch("setEditMessage", {
channelID: this.channelID, channelID: this.channelID,
messageID: this.messageID, messageID: this.messageID,
message: this.message message: this.message,
color: this.color,
}); });
}, },
contentDoubleClickEvent(event) { contentDoubleClickEvent(event) {

View file

@ -30,7 +30,8 @@ export default {
this.$store.dispatch("setEditMessage", { this.$store.dispatch("setEditMessage", {
channelID: this.contextDetails.channelID, channelID: this.contextDetails.channelID,
messageID: this.contextDetails.messageID, messageID: this.contextDetails.messageID,
message: this.contextDetails.message message: this.contextDetails.message,
color: this.contextDetails.color,
}); });
this.closeMenu(); this.closeMenu();
}, },
@ -70,7 +71,8 @@ export default {
message, message,
channelID, channelID,
uniqueID, uniqueID,
type type,
color
} = this.$store.getters.popouts.messageContextMenu; } = this.$store.getters.popouts.messageContextMenu;
return { return {
x, x,
@ -79,7 +81,8 @@ export default {
message, message,
channelID, channelID,
uniqueID, uniqueID,
type type,
color
}; };
}, },
serverID() { serverID() {

View file

@ -26,7 +26,7 @@
} }
.codeblock { .codeblock {
background-color: rgba(0, 0, 0, 0.397); background-color: #233538;
padding: 5px; padding: 5px;
word-wrap: break-word; word-wrap: break-word;
word-break: break-word; word-break: break-word;
@ -44,10 +44,10 @@
.inline-code { .inline-code {
background: rgba(0, 0, 0, 0.322); background: #273c3e;
} }
.link { .link {
color: rgb(86, 159, 253); color: #68aaff;
} }
</style> </style>

View file

@ -3,8 +3,6 @@
<navigation /> <navigation />
<div class="changelog"> <div class="changelog">
<div class="change-log"> <div class="change-log">
<span class="news-title">Changes in this release</span>
<div v-for="(change, index) in changelog" :key="index" class="change"> <div v-for="(change, index) in changelog" :key="index" class="change">
<div <div
class="heading" class="heading"
@ -38,6 +36,7 @@
<div v-if="change.msg" v-html="change.msg" /> <div v-if="change.msg" v-html="change.msg" />
</div> </div>
</div> </div>
<div class="see-all-button" v-if="!showAll" @click="showAll = true">View older changes</div>
</div> </div>
</div> </div>
</div> </div>
@ -51,8 +50,16 @@ export default {
components: { Navigation }, components: { Navigation },
data() { data() {
return { return {
changelog showAll: false,
}; };
},
computed: {
changelog() {
if (this.showAll) {
return changelog;
}
return [changelog[0]];
}
} }
}; };
</script> </script>
@ -90,7 +97,7 @@ export default {
} }
.heading { .heading {
padding: 10px; padding: 10px;
background: #071415; background: #15282a;
margin-bottom: 10px; margin-bottom: 10px;
} }
.information { .information {
@ -101,9 +108,10 @@ export default {
background: rgba(38, 139, 255, 0.87); background: rgba(38, 139, 255, 0.87);
} }
.change-log { .change-log {
background: #0a1e20; background: #294c51;
overflow-y: auto; overflow-y: auto;
max-width: 700px; max-width: 700px;
width: 100%;
margin: auto; margin: auto;
} }
.changelog { .changelog {
@ -130,4 +138,20 @@ export default {
margin-top: -5px; margin-top: -5px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.see-all-button {
background: #172a2c;
display: flex;
flex-shrink: 0;
justify-content: center;
align-items: center;
align-content: center;
height: 40px;
user-select: none;
cursor: pointer;
transition: 0.2s;
}
.see-all-button:hover {
background: #0b1415;
}
</style> </style>

View file

@ -90,7 +90,7 @@ const actions = {
}, },
setMessageContext( setMessageContext(
context, context,
{ messageID, x, y, channelID, message, uniqueID, type } { messageID, x, y, channelID, message, uniqueID, type, color }
) { ) {
context.commit("setMessageContext", { context.commit("setMessageContext", {
messageID, messageID,
@ -99,7 +99,8 @@ const actions = {
channelID, channelID,
message, message,
uniqueID, uniqueID,
type type,
color
}); });
}, },
setServerMemberContext(context, { uniqueID, x, y, serverID }) { setServerMemberContext(context, { uniqueID, x, y, serverID }) {

View file

@ -9,12 +9,24 @@ const prototype = {
}; };
const config = [ const config = [
{
version: 8.5,
title: "format buttons and color text!",
shortTitle: "",
date: "18/11/2019",
headColor: "#0c7b7f",
new: [
"Enter will now create new lines on mobile.",
"You can now easily format your messages using the format buttons above.",
"You can now color your messages! <font color='pink'>WOO!</font>",
],
},
{ {
version: 8.4, version: 8.4,
title: "Redesigns and built in mp3 player!", title: "Redesigns and built in mp3 player!",
shortTitle: "", shortTitle: "",
date: "17/11/2019", date: "17/11/2019",
headColor: "#0c7b7f",
new: [ new: [
"You can now play mp3 files within nertivia! (mp4 coming soon)", "You can now play mp3 files within nertivia! (mp4 coming soon)",
"Redesigned some components such as file upload, edit messages and more.", "Redesigned some components such as file upload, edit messages and more.",