Merge remote-tracking branch 'origin/main' into irc-colours
This commit is contained in:
commit
68cb7438ce
15 changed files with 115 additions and 75 deletions
3
app.vue
3
app.vue
|
@ -6,7 +6,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import ContextMenu from '~/components/ContextMenu.vue';
|
import ContextMenu from '~/components/UserInterface/ContextMenu.vue';
|
||||||
import { render } from 'vue';
|
import { render } from 'vue';
|
||||||
|
|
||||||
const banner = useState("banner", () => false);
|
const banner = useState("banner", () => false);
|
||||||
|
@ -14,6 +14,7 @@ const banner = useState("banner", () => false);
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document.removeEventListener("contextmenu", contextMenuHandler);
|
document.removeEventListener("contextmenu", contextMenuHandler);
|
||||||
document.addEventListener("contextmenu", (e) => {
|
document.addEventListener("contextmenu", (e) => {
|
||||||
|
if (e.target instanceof Element && e.target.classList.contains("default-contextmenu")) return;
|
||||||
contextMenuHandler(e);
|
contextMenuHandler(e);
|
||||||
});
|
});
|
||||||
document.addEventListener("mousedown", (e) => {
|
document.addEventListener("mousedown", (e) => {
|
||||||
|
|
|
@ -4,23 +4,20 @@
|
||||||
<button class="guild-option-button" @click="setting.action" tabindex="0">{{ setting.name }}</button>
|
<button class="guild-option-button" @click="setting.action" tabindex="0">{{ setting.name }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<ModalInvite v-if="showInviteModal" :guild-id="guildId" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { render } from 'vue';
|
|
||||||
import InviteModal from './InviteModal.vue';
|
|
||||||
|
|
||||||
const settings = [
|
const settings = [
|
||||||
{ name: "Invite", icon: "lucide:letter", action: openInviteModal }
|
{ name: "Invite", icon: "lucide:letter", action: openInviteModal }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const guildId = useRoute().params.serverId as string;
|
||||||
|
const showInviteModal = ref(false);
|
||||||
|
|
||||||
function openInviteModal() {
|
function openInviteModal() {
|
||||||
const div = document.createElement("div");
|
showInviteModal.value = true;
|
||||||
const guildId = useRoute().params.serverId as string;
|
|
||||||
console.log("guild id:", guildId);
|
|
||||||
const inviteModal = h(InviteModal, { guildId });
|
|
||||||
document.body.appendChild(div);
|
|
||||||
render(inviteModal, div);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
|
@ -12,7 +12,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import Button from '../UserInterface/Button.vue';
|
import Button from '~/components/UserInterface/Button.vue';
|
||||||
|
|
||||||
const inputField = ref<HTMLInputElement>();
|
const inputField = ref<HTMLInputElement>();
|
||||||
const { addFriend } = useApi();
|
const { addFriend } = useApi();
|
||||||
|
|
|
@ -4,14 +4,10 @@
|
||||||
:editing.sync="props.editing" :replying-to.sync="props.replyingTo">
|
:editing.sync="props.editing" :replying-to.sync="props.replyingTo">
|
||||||
<div v-if="props.replyMessage" class="message-reply-svg">
|
<div v-if="props.replyMessage" class="message-reply-svg">
|
||||||
<svg
|
<svg
|
||||||
width="1.5em"
|
width="1.5em" height="1.5em"
|
||||||
height="1.5em"
|
viewBox="0 0 150 87.5" version="1.1" id="svg1"
|
||||||
viewBox="0 0 151.14355 87.562065"
|
|
||||||
version="1.1"
|
|
||||||
id="svg1"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
style="overflow: visible;">
|
style="overflow: visible;">
|
||||||
|
<defs id="defs1" />
|
||||||
<defs
|
<defs
|
||||||
id="defs1" />
|
id="defs1" />
|
||||||
<g
|
<g
|
||||||
|
@ -50,8 +46,9 @@
|
||||||
{{ date.toLocaleTimeString(undefined, { hour12: props.format == "12", timeStyle: "short" }) }}
|
{{ date.toLocaleTimeString(undefined, { hour12: props.format == "12", timeStyle: "short" }) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="message-text" v-html="sanitized" tabindex="0"></div>
|
<div class="message-text" v-html="sanitized" :hidden="hasEmbed" tabindex="0"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<MessageMedia v-if="mediaLinks.length" :links="mediaLinks" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else ref="messageElement" @contextmenu="createContextMenu($event, menuItems)" :id="props.last ? 'last-message' : undefined"
|
<div v-else ref="messageElement" @contextmenu="createContextMenu($event, menuItems)" :id="props.last ? 'last-message' : undefined"
|
||||||
class="message grouped-message" :class="{ 'message-margin-bottom': props.marginBottom, 'mentioned': props.replyMessage || props.isMentioned }"
|
class="message grouped-message" :class="{ 'message-margin-bottom': props.marginBottom, 'mentioned': props.replyMessage || props.isMentioned }"
|
||||||
|
@ -62,8 +59,9 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="message-data">
|
<div class="message-data">
|
||||||
<div class="message-text" :class="$style['message-text']" v-html="sanitized" tabindex="0"></div>
|
<div class="message-text" :class="$style['message-text']" v-html="sanitized" :hidden="hasEmbed" tabindex="0"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<MessageMedia v-if="mediaLinks.length" :links="mediaLinks" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -72,6 +70,8 @@ import DOMPurify from 'dompurify';
|
||||||
import { parse } from 'marked';
|
import { parse } from 'marked';
|
||||||
import type { MessageProps } from '~/types/props';
|
import type { MessageProps } from '~/types/props';
|
||||||
import generateIrcColor from '~/utils/generateIrcColor';
|
import generateIrcColor from '~/utils/generateIrcColor';
|
||||||
|
import MessageMedia from './MessageMedia.vue';
|
||||||
|
import MessageReply from './UserInterface/MessageReply.vue';
|
||||||
|
|
||||||
const props = defineProps<MessageProps>();
|
const props = defineProps<MessageProps>();
|
||||||
|
|
||||||
|
@ -86,6 +86,13 @@ console.log("[MSG] message to render:", props.message);
|
||||||
console.log("author:", props.author);
|
console.log("author:", props.author);
|
||||||
console.log("[MSG] reply message:", props.replyMessage);
|
console.log("[MSG] reply message:", props.replyMessage);
|
||||||
|
|
||||||
|
const linkRegex = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g;
|
||||||
|
const linkMatches = props.message.message.matchAll(linkRegex).map(link => link[0]);
|
||||||
|
const mediaLinks: string[] = [];
|
||||||
|
console.log("link matches:", linkMatches);
|
||||||
|
|
||||||
|
const hasEmbed = ref(false);
|
||||||
|
|
||||||
const sanitized = ref<string>();
|
const sanitized = ref<string>();
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
@ -98,7 +105,7 @@ onMounted(async () => {
|
||||||
],
|
],
|
||||||
ALLOW_DATA_ATTR: false,
|
ALLOW_DATA_ATTR: false,
|
||||||
ALLOW_SELF_CLOSE_IN_ATTR: false,
|
ALLOW_SELF_CLOSE_IN_ATTR: false,
|
||||||
ALLOWED_ATTR: []
|
ALLOWED_ATTR: ["href"]
|
||||||
});
|
});
|
||||||
console.log("adding listeners")
|
console.log("adding listeners")
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
@ -112,6 +119,27 @@ onMounted(async () => {
|
||||||
});
|
});
|
||||||
console.log("added listeners");
|
console.log("added listeners");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const link of linkMatches) {
|
||||||
|
console.log("link:", link);
|
||||||
|
try {
|
||||||
|
const res = await $fetch.raw(link);
|
||||||
|
if (res.ok && res.headers.get("content-type")?.match(/^image\/(apng|gif|jpeg|png|webp)$/)) {
|
||||||
|
console.log("link is image");
|
||||||
|
mediaLinks.push(link);
|
||||||
|
}
|
||||||
|
if (mediaLinks.length) {
|
||||||
|
hasEmbed.value = true
|
||||||
|
setTimeout(() => {
|
||||||
|
scrollToBottom(document.getElementById("messages") as HTMLDivElement);
|
||||||
|
}, 500);
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("media links:", mediaLinks);
|
||||||
});
|
});
|
||||||
|
|
||||||
//function toggleTooltip(e: Event) {
|
//function toggleTooltip(e: Event) {
|
||||||
|
|
|
@ -252,6 +252,8 @@ onMounted(async () => {
|
||||||
if (import.meta.server) return;
|
if (import.meta.server) return;
|
||||||
console.log("[MSG] messages keys:", Object.values(messages.value));
|
console.log("[MSG] messages keys:", Object.values(messages.value));
|
||||||
if (messagesElement.value) {
|
if (messagesElement.value) {
|
||||||
|
await nextTick();
|
||||||
|
await nextTick();
|
||||||
scrollToBottom(messagesElement.value);
|
scrollToBottom(messagesElement.value);
|
||||||
let fetched = false;
|
let fetched = false;
|
||||||
const amount = messages.value.length;
|
const amount = messages.value.length;
|
||||||
|
|
47
components/MessageMedia.vue
Normal file
47
components/MessageMedia.vue
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<template>
|
||||||
|
<div class="media-container">
|
||||||
|
<NuxtImg v-for="link of props.links" class="media-item" :src="link" @click.prevent="createModal(link)" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ModalBase } from '#components';
|
||||||
|
import { render } from 'vue';
|
||||||
|
|
||||||
|
|
||||||
|
const props = defineProps<{ links: string[] }>();
|
||||||
|
|
||||||
|
function createModal(link: string) {
|
||||||
|
const div = document.createElement("div");
|
||||||
|
const modal = h(ModalBase, {
|
||||||
|
obscure: true,
|
||||||
|
onClose: () => unrender(div),
|
||||||
|
onCancel: () => unrender(div),
|
||||||
|
},
|
||||||
|
[
|
||||||
|
h("img", {
|
||||||
|
src: link,
|
||||||
|
class: "default-contextmenu"
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
|
document.body.appendChild(div);
|
||||||
|
render(modal, div);
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
.media-container {
|
||||||
|
grid-column: 2;
|
||||||
|
grid-row: 3;
|
||||||
|
margin-left: .5dvw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.media-item {
|
||||||
|
cursor: pointer;
|
||||||
|
max-width: 15dvw;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ModalProps } from '~/types/interfaces';
|
import type { ModalProps } from '~/types/interfaces';
|
||||||
import Button from './UserInterface/Button.vue';
|
import Button from '~/components/UserInterface/Button.vue';
|
||||||
|
|
||||||
const props = defineProps<ModalProps>();
|
const props = defineProps<ModalProps>();
|
||||||
const dialog = ref<HTMLDialogElement>();
|
const dialog = ref<HTMLDialogElement>();
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<Modal v-bind="props" :title="props.title || 'Create an invite'">
|
<ModalBase v-bind="props" :title="props.title || 'Create an invite'">
|
||||||
<div v-if="invite" id="invite-body">
|
<div v-if="invite" id="invite-body">
|
||||||
<div id="invite-label">{{ invite }}</div>
|
<div id="invite-label">{{ invite }}</div>
|
||||||
<div id="invite-buttons">
|
<div id="invite-buttons">
|
||||||
|
@ -10,12 +10,12 @@
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<Button text="Generate Invite" variant="normal" :callback="generateInvite">Generate Invite</Button>
|
<Button text="Generate Invite" variant="normal" :callback="generateInvite">Generate Invite</Button>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</ModalBase>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { InviteResponse, ModalProps } from '~/types/interfaces';
|
import type { InviteResponse, ModalProps } from '~/types/interfaces';
|
||||||
import Button from './UserInterface/Button.vue';
|
import Button from '~/components/UserInterface/Button.vue';
|
||||||
|
|
||||||
const props = defineProps<ModalProps & { guildId: string }>();
|
const props = defineProps<ModalProps & { guildId: string }>();
|
||||||
|
|
|
@ -38,9 +38,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { ModalBase } from '#components';
|
||||||
import { render } from 'vue';
|
import { render } from 'vue';
|
||||||
import Dropdown from '~/components/Dropdown.vue';
|
import GuildDropdown from '~/components/Guild/GuildDropdown.vue';
|
||||||
import Modal from '~/components/Modal.vue';
|
|
||||||
import Button from '~/components/UserInterface/Button.vue';
|
import Button from '~/components/UserInterface/Button.vue';
|
||||||
import type { GuildResponse } from '~/types/interfaces';
|
import type { GuildResponse } from '~/types/interfaces';
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ const options = [
|
||||||
{ name: "Join", value: "join", callback: async () => {
|
{ name: "Join", value: "join", callback: async () => {
|
||||||
console.log("join guild!");
|
console.log("join guild!");
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
const guildJoinModal = h(Modal, {
|
const guildJoinModal = h(ModalBase, {
|
||||||
title: "Join Guild",
|
title: "Join Guild",
|
||||||
id: "guild-join-modal",
|
id: "guild-join-modal",
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
|
@ -97,7 +97,7 @@ const options = [
|
||||||
console.log("create guild");
|
console.log("create guild");
|
||||||
const user = await useAuth().getUser();
|
const user = await useAuth().getUser();
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
const guildCreateModal = h(Modal, {
|
const guildCreateModal = h(ModalBase, {
|
||||||
title: "Create a Guild",
|
title: "Create a Guild",
|
||||||
id: "guild-join-modal",
|
id: "guild-join-modal",
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
|
@ -138,49 +138,8 @@ const options = [
|
||||||
|
|
||||||
const guilds: GuildResponse[] | undefined = await fetchWithApi("/me/guilds");
|
const guilds: GuildResponse[] | undefined = await fetchWithApi("/me/guilds");
|
||||||
|
|
||||||
//const servers = await fetchWithApi("/servers") as { uuid: string, name: string, description: string }[];
|
|
||||||
//console.log("servers:", servers);
|
|
||||||
const members = [
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
function createDropdown() {
|
function createDropdown() {
|
||||||
const dropdown = h(Dropdown, { options });
|
const dropdown = h(GuildDropdown, { options });
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
div.classList.add("dropdown", "destroy-on-click");
|
div.classList.add("dropdown", "destroy-on-click");
|
||||||
if (createButtonContainer.value) {
|
if (createButtonContainer.value) {
|
||||||
|
@ -261,6 +220,11 @@ function createDropdown() {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1.5dvh;
|
gap: 1.5dvh;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
|
scrollbar-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#left-column-top::-webkit-scrollbar, #left-column-bottom::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#left-column-bottom {
|
#left-column-bottom {
|
||||||
|
@ -331,4 +295,4 @@ function createDropdown() {
|
||||||
color: var(--primary-highlighted-color)
|
color: var(--primary-highlighted-color)
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import ChannelEntry from "~/components/Guild/ChannelEntry.vue";
|
import ChannelEntry from "~/components/Guild/ChannelEntry.vue";
|
||||||
|
import GuildOptionsMenu from "~/components/Guild/GuildOptionsMenu.vue";
|
||||||
|
import MemberEntry from "~/components/Member/MemberEntry.vue";
|
||||||
|
import type { ChannelResponse, GuildMemberResponse, GuildResponse, MessageResponse } from "~/types/interfaces";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
@ -41,8 +44,6 @@ const members = ref<GuildMemberResponse[]>();
|
||||||
const showInvitePopup = ref(false);
|
const showInvitePopup = ref(false);
|
||||||
const showGuildSettings = ref(false);
|
const showGuildSettings = ref(false);
|
||||||
|
|
||||||
import type { ChannelResponse, GuildMemberResponse, GuildResponse, MessageResponse } from "~/types/interfaces";
|
|
||||||
|
|
||||||
//const servers = await fetchWithApi("/servers") as { uuid: string, name: string, description: string }[];
|
//const servers = await fetchWithApi("/servers") as { uuid: string, name: string, description: string }[];
|
||||||
//console.log("channelid: servers:", servers);
|
//console.log("channelid: servers:", servers);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { render } from "vue";
|
import { render } from "vue";
|
||||||
import ContextMenu from "~/components/ContextMenu.vue";
|
import ContextMenu from "~/components/UserInterface/ContextMenu.vue";
|
||||||
import type { ContextMenuItem } from "~/types/interfaces";
|
import type { ContextMenuItem } from "~/types/interfaces";
|
||||||
|
|
||||||
export default (e: MouseEvent, menuItems: ContextMenuItem[]) => {
|
export default (e: MouseEvent, menuItems: ContextMenuItem[]) => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { render } from "vue";
|
import { render } from "vue";
|
||||||
import MessageReply from "~/components/MessageReply.vue";
|
import MessageReply from "~/components/UserInterface/MessageReply.vue";
|
||||||
import type { MessageProps } from "~/types/props";
|
import type { MessageProps } from "~/types/props";
|
||||||
|
|
||||||
export default (element: HTMLDivElement, props: MessageProps) => {
|
export default (element: HTMLDivElement, props: MessageProps) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue