2018-02-20 11:29:52 +00:00
|
|
|
<template>
|
2023-04-08 00:01:42 +00:00
|
|
|
<div
|
|
|
|
ref="rootEl"
|
|
|
|
class="swhvrteh _popup _shadow"
|
|
|
|
:style="{ zIndex }"
|
|
|
|
@contextmenu.prevent="() => {}"
|
|
|
|
>
|
|
|
|
<ol v-if="type === 'user'" ref="suggests" class="users">
|
|
|
|
<li
|
|
|
|
v-for="user in users"
|
|
|
|
tabindex="-1"
|
|
|
|
class="user"
|
|
|
|
@click="complete(type, user)"
|
|
|
|
@keydown="onKeydown"
|
|
|
|
>
|
|
|
|
<img class="avatar" :src="user.avatarUrl" />
|
|
|
|
<span class="name">
|
|
|
|
<MkUserName :key="user.id" :user="user" />
|
|
|
|
</span>
|
|
|
|
<span class="username">@{{ acct(user) }}</span>
|
|
|
|
</li>
|
|
|
|
<li
|
|
|
|
tabindex="-1"
|
|
|
|
class="choose"
|
|
|
|
@click="chooseUser()"
|
|
|
|
@keydown="onKeydown"
|
|
|
|
>
|
|
|
|
{{ i18n.ts.selectUser }}
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
<ol v-else-if="hashtags.length > 0" ref="suggests" class="hashtags">
|
|
|
|
<li
|
|
|
|
v-for="hashtag in hashtags"
|
|
|
|
tabindex="-1"
|
|
|
|
@click="complete(type, hashtag)"
|
|
|
|
@keydown="onKeydown"
|
|
|
|
>
|
|
|
|
<span class="name">{{ hashtag }}</span>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
<ol v-else-if="emojis.length > 0" ref="suggests" class="emojis">
|
|
|
|
<li
|
|
|
|
v-for="emoji in emojis"
|
|
|
|
tabindex="-1"
|
|
|
|
@click="complete(type, emoji.emoji)"
|
|
|
|
@keydown="onKeydown"
|
|
|
|
>
|
|
|
|
<span v-if="emoji.isCustomEmoji" class="emoji"
|
|
|
|
><img
|
|
|
|
:src="
|
|
|
|
defaultStore.state.disableShowingAnimatedImages
|
|
|
|
? getStaticImageUrl(emoji.url)
|
|
|
|
: emoji.url
|
|
|
|
"
|
|
|
|
:alt="emoji.emoji"
|
|
|
|
/></span>
|
|
|
|
<span
|
|
|
|
v-else-if="!defaultStore.state.useOsNativeEmojis"
|
|
|
|
class="emoji"
|
|
|
|
><img :src="emoji.url" :alt="emoji.emoji"
|
|
|
|
/></span>
|
|
|
|
<span v-else class="emoji">{{ emoji.emoji }}</span>
|
|
|
|
<span
|
|
|
|
class="name"
|
|
|
|
v-html="emoji.name.replace(q, `<b>${q}</b>`)"
|
|
|
|
></span>
|
|
|
|
<span v-if="emoji.aliasOf" class="alias"
|
|
|
|
>({{ emoji.aliasOf }})</span
|
|
|
|
>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
<ol v-else-if="mfmTags.length > 0" ref="suggests" class="mfmTags">
|
|
|
|
<li
|
|
|
|
v-for="tag in mfmTags"
|
|
|
|
tabindex="-1"
|
|
|
|
@click="complete(type, tag)"
|
|
|
|
@keydown="onKeydown"
|
|
|
|
>
|
|
|
|
<span class="tag">{{ tag }}</span>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
</div>
|
2018-02-20 11:29:52 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2023-04-08 00:01:42 +00:00
|
|
|
import {
|
|
|
|
markRaw,
|
|
|
|
ref,
|
|
|
|
onUpdated,
|
|
|
|
onMounted,
|
|
|
|
onBeforeUnmount,
|
|
|
|
nextTick,
|
|
|
|
watch,
|
|
|
|
} from "vue";
|
|
|
|
import contains from "@/scripts/contains";
|
|
|
|
import { char2filePath } from "@/scripts/twemoji-base";
|
|
|
|
import { getStaticImageUrl } from "@/scripts/get-static-image-url";
|
|
|
|
import { acct } from "@/filters/user";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { MFM_TAGS } from "@/scripts/mfm-tags";
|
|
|
|
import { defaultStore } from "@/store";
|
|
|
|
import { emojilist } from "@/scripts/emojilist";
|
|
|
|
import { instance } from "@/instance";
|
|
|
|
import { i18n } from "@/i18n";
|
2018-02-20 11:29:52 +00:00
|
|
|
|
2018-11-01 12:28:39 +00:00
|
|
|
type EmojiDef = {
|
|
|
|
emoji: string;
|
|
|
|
name: string;
|
|
|
|
aliasOf?: string;
|
|
|
|
url?: string;
|
2018-11-05 10:20:35 +00:00
|
|
|
isCustomEmoji?: boolean;
|
2018-11-01 12:28:39 +00:00
|
|
|
};
|
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
const lib = emojilist.filter((x) => x.category !== "flags");
|
2018-04-09 09:52:29 +00:00
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
const emjdb: EmojiDef[] = lib.map((x) => ({
|
2019-09-21 12:31:38 +00:00
|
|
|
emoji: x.char,
|
|
|
|
name: x.name,
|
2022-06-19 15:33:46 +00:00
|
|
|
url: char2filePath(x.char),
|
2018-02-25 08:03:39 +00:00
|
|
|
}));
|
2018-04-09 09:52:29 +00:00
|
|
|
|
2019-09-21 12:31:38 +00:00
|
|
|
for (const x of lib) {
|
|
|
|
if (x.keywords) {
|
|
|
|
for (const k of x.keywords) {
|
2018-02-25 08:03:39 +00:00
|
|
|
emjdb.push({
|
2019-09-21 12:31:38 +00:00
|
|
|
emoji: x.char,
|
2018-02-25 08:03:39 +00:00
|
|
|
name: k,
|
2019-09-21 12:31:38 +00:00
|
|
|
aliasOf: x.name,
|
2022-06-19 15:33:46 +00:00
|
|
|
url: char2filePath(x.char),
|
2018-02-25 08:03:39 +00:00
|
|
|
});
|
2018-12-11 11:36:55 +00:00
|
|
|
}
|
2018-02-25 08:03:39 +00:00
|
|
|
}
|
2018-12-11 11:36:55 +00:00
|
|
|
}
|
2018-04-09 09:52:29 +00:00
|
|
|
|
2018-02-25 08:03:39 +00:00
|
|
|
emjdb.sort((a, b) => a.name.length - b.name.length);
|
|
|
|
|
2021-08-12 03:41:57 +00:00
|
|
|
//#region Construct Emoji DB
|
|
|
|
const customEmojis = instance.emojis;
|
|
|
|
const emojiDefinitions: EmojiDef[] = [];
|
|
|
|
|
|
|
|
for (const x of customEmojis) {
|
|
|
|
emojiDefinitions.push({
|
|
|
|
name: x.name,
|
|
|
|
emoji: `:${x.name}:`,
|
|
|
|
url: x.url,
|
2023-04-08 00:01:42 +00:00
|
|
|
isCustomEmoji: true,
|
2021-08-12 03:41:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (x.aliases) {
|
|
|
|
for (const alias of x.aliases) {
|
|
|
|
emojiDefinitions.push({
|
|
|
|
name: alias,
|
|
|
|
aliasOf: x.name,
|
|
|
|
emoji: `:${x.name}:`,
|
|
|
|
url: x.url,
|
2023-04-08 00:01:42 +00:00
|
|
|
isCustomEmoji: true,
|
2021-08-12 03:41:57 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
emojiDefinitions.sort((a, b) => a.name.length - b.name.length);
|
|
|
|
|
|
|
|
const emojiDb = markRaw(emojiDefinitions.concat(emjdb));
|
|
|
|
//#endregion
|
|
|
|
|
2022-01-10 15:05:18 +00:00
|
|
|
export default {
|
|
|
|
emojiDb,
|
|
|
|
emojiDefinitions,
|
|
|
|
emojilist,
|
|
|
|
customEmojis,
|
|
|
|
};
|
|
|
|
</script>
|
2018-07-17 22:19:24 +00:00
|
|
|
|
2022-01-10 15:05:18 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
const props = defineProps<{
|
|
|
|
type: string;
|
|
|
|
q: string | null;
|
|
|
|
textarea: HTMLTextAreaElement;
|
|
|
|
close: () => void;
|
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
2023-04-08 00:01:42 +00:00
|
|
|
(event: "done", value: { type: string; value: any }): void;
|
|
|
|
(event: "closed"): void;
|
2022-01-10 15:05:18 +00:00
|
|
|
}>();
|
|
|
|
|
|
|
|
const suggests = ref<Element>();
|
|
|
|
const rootEl = ref<HTMLDivElement>();
|
|
|
|
|
|
|
|
const fetching = ref(true);
|
|
|
|
const users = ref<any[]>([]);
|
|
|
|
const hashtags = ref<any[]>([]);
|
2023-04-08 00:01:42 +00:00
|
|
|
const emojis = ref<EmojiDef[]>([]);
|
2022-01-10 15:05:18 +00:00
|
|
|
const items = ref<Element[] | HTMLCollection>([]);
|
|
|
|
const mfmTags = ref<string[]>([]);
|
|
|
|
const select = ref(-1);
|
2023-04-08 00:01:42 +00:00
|
|
|
const zIndex = os.claimZIndex("high");
|
2022-01-10 15:05:18 +00:00
|
|
|
|
|
|
|
function complete(type: string, value: any) {
|
2023-04-08 00:01:42 +00:00
|
|
|
emit("done", { type, value });
|
|
|
|
emit("closed");
|
|
|
|
if (type === "emoji") {
|
2022-01-10 15:05:18 +00:00
|
|
|
let recents = defaultStore.state.recentlyUsedEmojis;
|
2022-04-28 01:56:18 +00:00
|
|
|
recents = recents.filter((emoji: any) => emoji !== value);
|
2022-01-10 15:05:18 +00:00
|
|
|
recents.unshift(value);
|
2023-04-08 00:01:42 +00:00
|
|
|
defaultStore.set("recentlyUsedEmojis", recents.splice(0, 32));
|
2022-01-10 15:05:18 +00:00
|
|
|
}
|
|
|
|
}
|
2018-07-17 22:19:24 +00:00
|
|
|
|
2022-01-10 15:05:18 +00:00
|
|
|
function setPosition() {
|
|
|
|
if (!rootEl.value) return;
|
|
|
|
if (props.x + rootEl.value.offsetWidth > window.innerWidth) {
|
2023-04-08 00:01:42 +00:00
|
|
|
rootEl.value.style.left =
|
|
|
|
window.innerWidth - rootEl.value.offsetWidth + "px";
|
2022-01-10 15:05:18 +00:00
|
|
|
} else {
|
|
|
|
rootEl.value.style.left = `${props.x}px`;
|
|
|
|
}
|
|
|
|
if (props.y + rootEl.value.offsetHeight > window.innerHeight) {
|
2023-04-08 00:01:42 +00:00
|
|
|
rootEl.value.style.top = props.y - rootEl.value.offsetHeight + "px";
|
|
|
|
rootEl.value.style.marginTop = "0";
|
2022-01-10 15:05:18 +00:00
|
|
|
} else {
|
2023-04-08 00:01:42 +00:00
|
|
|
rootEl.value.style.top = props.y + "px";
|
|
|
|
rootEl.value.style.marginTop = "calc(1em + 8px)";
|
2022-01-10 15:05:18 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-31 22:38:40 +00:00
|
|
|
|
2022-01-10 15:05:18 +00:00
|
|
|
function exec() {
|
|
|
|
select.value = -1;
|
|
|
|
if (suggests.value) {
|
|
|
|
for (const el of Array.from(items.value)) {
|
2023-04-08 00:01:42 +00:00
|
|
|
el.removeAttribute("data-selected");
|
2022-01-10 15:05:18 +00:00
|
|
|
}
|
|
|
|
}
|
2023-04-08 00:01:42 +00:00
|
|
|
if (props.type === "user") {
|
2022-01-10 15:05:18 +00:00
|
|
|
if (!props.q) {
|
|
|
|
users.value = [];
|
|
|
|
fetching.value = false;
|
|
|
|
return;
|
|
|
|
}
|
2018-02-20 11:29:52 +00:00
|
|
|
|
2022-01-10 15:05:18 +00:00
|
|
|
const cacheKey = `autocomplete:user:${props.q}`;
|
|
|
|
const cache = sessionStorage.getItem(cacheKey);
|
|
|
|
|
|
|
|
if (cache) {
|
2022-03-02 09:52:49 +00:00
|
|
|
users.value = JSON.parse(cache);
|
2022-01-10 15:05:18 +00:00
|
|
|
fetching.value = false;
|
|
|
|
} else {
|
2023-04-08 00:01:42 +00:00
|
|
|
os.api("users/search-by-username-and-host", {
|
2022-01-10 15:05:18 +00:00
|
|
|
username: props.q,
|
|
|
|
limit: 10,
|
2023-04-08 00:01:42 +00:00
|
|
|
detail: false,
|
|
|
|
}).then((searchedUsers) => {
|
2022-01-10 15:05:18 +00:00
|
|
|
users.value = searchedUsers as any[];
|
|
|
|
fetching.value = false;
|
|
|
|
// キャッシュ
|
|
|
|
sessionStorage.setItem(cacheKey, JSON.stringify(searchedUsers));
|
|
|
|
});
|
|
|
|
}
|
2023-04-08 00:01:42 +00:00
|
|
|
} else if (props.type === "hashtag") {
|
|
|
|
if (!props.q || props.q === "") {
|
|
|
|
hashtags.value = JSON.parse(
|
|
|
|
localStorage.getItem("hashtags") || "[]"
|
|
|
|
);
|
2022-01-10 15:05:18 +00:00
|
|
|
fetching.value = false;
|
|
|
|
} else {
|
|
|
|
const cacheKey = `autocomplete:hashtag:${props.q}`;
|
|
|
|
const cache = sessionStorage.getItem(cacheKey);
|
|
|
|
if (cache) {
|
|
|
|
const hashtags = JSON.parse(cache);
|
|
|
|
hashtags.value = hashtags;
|
|
|
|
fetching.value = false;
|
|
|
|
} else {
|
2023-04-08 00:01:42 +00:00
|
|
|
os.api("hashtags/search", {
|
2022-01-10 15:05:18 +00:00
|
|
|
query: props.q,
|
2023-04-08 00:01:42 +00:00
|
|
|
limit: 30,
|
|
|
|
}).then((searchedHashtags) => {
|
2022-01-10 15:05:18 +00:00
|
|
|
hashtags.value = searchedHashtags as any[];
|
|
|
|
fetching.value = false;
|
|
|
|
// キャッシュ
|
2023-04-08 00:01:42 +00:00
|
|
|
sessionStorage.setItem(
|
|
|
|
cacheKey,
|
|
|
|
JSON.stringify(searchedHashtags)
|
|
|
|
);
|
2022-01-10 15:05:18 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2023-04-08 00:01:42 +00:00
|
|
|
} else if (props.type === "emoji") {
|
|
|
|
if (!props.q || props.q === "") {
|
2022-01-10 15:05:18 +00:00
|
|
|
// 最近使った絵文字をサジェスト
|
2023-04-08 00:01:42 +00:00
|
|
|
emojis.value = defaultStore.state.recentlyUsedEmojis
|
|
|
|
.map((emoji) =>
|
|
|
|
emojiDb.find((dbEmoji) => dbEmoji.emoji === emoji)
|
|
|
|
)
|
|
|
|
.filter((x) => x) as EmojiDef[];
|
2022-01-10 15:05:18 +00:00
|
|
|
return;
|
2018-12-11 11:36:55 +00:00
|
|
|
}
|
2018-02-20 11:29:52 +00:00
|
|
|
|
2022-01-10 15:05:18 +00:00
|
|
|
const matched: EmojiDef[] = [];
|
|
|
|
const max = 30;
|
2018-02-25 08:38:16 +00:00
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
emojiDb.some((x) => {
|
|
|
|
if (
|
|
|
|
x.name.startsWith(props.q ?? "") &&
|
|
|
|
!x.aliasOf &&
|
|
|
|
!matched.some((y) => y.emoji === x.emoji)
|
|
|
|
)
|
|
|
|
matched.push(x);
|
2022-03-01 12:36:20 +00:00
|
|
|
return matched.length === max;
|
2018-02-25 09:40:39 +00:00
|
|
|
});
|
2018-07-17 22:19:24 +00:00
|
|
|
|
2022-01-10 15:05:18 +00:00
|
|
|
if (matched.length < max) {
|
2023-04-08 00:01:42 +00:00
|
|
|
emojiDb.some((x) => {
|
|
|
|
if (
|
|
|
|
x.name.startsWith(props.q ?? "") &&
|
|
|
|
!matched.some((y) => y.emoji === x.emoji)
|
|
|
|
)
|
|
|
|
matched.push(x);
|
2022-03-01 12:36:20 +00:00
|
|
|
return matched.length === max;
|
2022-01-10 15:05:18 +00:00
|
|
|
});
|
|
|
|
}
|
2018-02-20 11:29:52 +00:00
|
|
|
|
2022-01-10 15:05:18 +00:00
|
|
|
if (matched.length < max) {
|
2023-04-08 00:01:42 +00:00
|
|
|
emojiDb.some((x) => {
|
|
|
|
if (
|
|
|
|
x.name.includes(props.q ?? "") &&
|
|
|
|
!matched.some((y) => y.emoji === x.emoji)
|
|
|
|
)
|
|
|
|
matched.push(x);
|
2022-03-01 12:36:20 +00:00
|
|
|
return matched.length === max;
|
2022-01-10 15:05:18 +00:00
|
|
|
});
|
2018-12-11 11:36:55 +00:00
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-01-10 15:05:18 +00:00
|
|
|
emojis.value = matched;
|
2023-04-08 00:01:42 +00:00
|
|
|
} else if (props.type === "mfmTag") {
|
|
|
|
if (!props.q || props.q === "") {
|
2022-01-10 15:05:18 +00:00
|
|
|
mfmTags.value = MFM_TAGS;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
mfmTags.value = MFM_TAGS.filter((tag) => tag.startsWith(props.q ?? ""));
|
2022-01-10 15:05:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-28 01:56:18 +00:00
|
|
|
function onMousedown(event: Event) {
|
2023-04-08 00:01:42 +00:00
|
|
|
if (!contains(rootEl.value, event.target) && rootEl.value !== event.target)
|
|
|
|
props.close();
|
2022-01-10 15:05:18 +00:00
|
|
|
}
|
|
|
|
|
2022-04-28 01:56:18 +00:00
|
|
|
function onKeydown(event: KeyboardEvent) {
|
2022-01-10 15:05:18 +00:00
|
|
|
const cancel = () => {
|
2022-04-28 01:56:18 +00:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2022-01-10 15:05:18 +00:00
|
|
|
};
|
|
|
|
|
2022-04-28 01:56:18 +00:00
|
|
|
switch (event.key) {
|
2023-04-08 00:01:42 +00:00
|
|
|
case "Enter":
|
2022-01-10 15:05:18 +00:00
|
|
|
if (select.value !== -1) {
|
|
|
|
cancel();
|
|
|
|
(items.value[select.value] as any).click();
|
2020-01-31 22:38:40 +00:00
|
|
|
} else {
|
2022-01-10 15:05:18 +00:00
|
|
|
props.close();
|
2020-01-31 22:38:40 +00:00
|
|
|
}
|
2022-01-10 15:05:18 +00:00
|
|
|
break;
|
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
case "Escape":
|
2022-01-10 15:05:18 +00:00
|
|
|
cancel();
|
|
|
|
props.close();
|
|
|
|
break;
|
2020-01-31 22:38:40 +00:00
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
case "ArrowUp":
|
2022-01-10 15:05:18 +00:00
|
|
|
if (select.value !== -1) {
|
|
|
|
cancel();
|
|
|
|
selectPrev();
|
2020-01-31 22:38:40 +00:00
|
|
|
} else {
|
2022-01-10 15:05:18 +00:00
|
|
|
props.close();
|
2018-02-25 09:40:39 +00:00
|
|
|
}
|
2022-01-10 15:05:18 +00:00
|
|
|
break;
|
2018-02-25 09:40:39 +00:00
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
case "Tab":
|
|
|
|
case "ArrowDown":
|
2022-01-10 15:05:18 +00:00
|
|
|
cancel();
|
|
|
|
selectNext();
|
|
|
|
break;
|
2018-02-20 11:29:52 +00:00
|
|
|
|
2022-01-10 15:05:18 +00:00
|
|
|
default:
|
2022-04-28 01:56:18 +00:00
|
|
|
event.stopPropagation();
|
2022-01-10 15:05:18 +00:00
|
|
|
props.textarea.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectNext() {
|
|
|
|
if (++select.value >= items.value.length) select.value = 0;
|
|
|
|
if (items.value.length === 0) select.value = -1;
|
|
|
|
applySelect();
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectPrev() {
|
|
|
|
if (--select.value < 0) select.value = items.value.length - 1;
|
|
|
|
applySelect();
|
|
|
|
}
|
|
|
|
|
|
|
|
function applySelect() {
|
|
|
|
for (const el of Array.from(items.value)) {
|
2023-04-08 00:01:42 +00:00
|
|
|
el.removeAttribute("data-selected");
|
2022-01-10 15:05:18 +00:00
|
|
|
}
|
2020-01-31 22:38:40 +00:00
|
|
|
|
2022-01-10 15:05:18 +00:00
|
|
|
if (select.value !== -1) {
|
2023-04-08 00:01:42 +00:00
|
|
|
items.value[select.value].setAttribute("data-selected", "true");
|
2022-01-10 15:05:18 +00:00
|
|
|
(items.value[select.value] as any).focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function chooseUser() {
|
|
|
|
props.close();
|
2023-04-08 00:01:42 +00:00
|
|
|
os.selectUser().then((user) => {
|
|
|
|
complete("user", user);
|
2022-01-10 15:05:18 +00:00
|
|
|
props.textarea.focus();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onUpdated(() => {
|
|
|
|
setPosition();
|
2022-03-01 12:36:20 +00:00
|
|
|
items.value = suggests.value?.children ?? [];
|
2022-01-10 15:05:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
setPosition();
|
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
props.textarea.addEventListener("keydown", onKeydown);
|
2022-01-10 15:05:18 +00:00
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
for (const el of Array.from(document.querySelectorAll("body *"))) {
|
|
|
|
el.addEventListener("mousedown", onMousedown);
|
2022-01-10 15:05:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
exec();
|
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
watch(
|
|
|
|
() => props.q,
|
|
|
|
() => {
|
|
|
|
nextTick(() => {
|
|
|
|
exec();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
2022-01-10 15:05:18 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
2023-04-08 00:01:42 +00:00
|
|
|
props.textarea.removeEventListener("keydown", onKeydown);
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
for (const el of Array.from(document.querySelectorAll("body *"))) {
|
|
|
|
el.removeEventListener("mousedown", onMousedown);
|
2018-02-20 11:29:52 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<style lang="scss" scoped>
|
2020-01-31 22:38:40 +00:00
|
|
|
.swhvrteh {
|
2020-01-29 19:37:25 +00:00
|
|
|
position: fixed;
|
|
|
|
max-width: 100%;
|
|
|
|
margin-top: calc(1em + 8px);
|
2021-03-02 13:57:16 +00:00
|
|
|
overflow: hidden;
|
2020-01-29 19:37:25 +00:00
|
|
|
transition: top 0.1s ease, left 0.1s ease;
|
|
|
|
|
|
|
|
> ol {
|
|
|
|
display: block;
|
|
|
|
margin: 0;
|
|
|
|
padding: 4px 0;
|
|
|
|
max-height: 190px;
|
|
|
|
max-width: 500px;
|
|
|
|
overflow: auto;
|
|
|
|
list-style: none;
|
|
|
|
|
|
|
|
> li {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: 4px 12px;
|
|
|
|
white-space: nowrap;
|
2021-03-02 13:57:16 +00:00
|
|
|
overflow: hidden;
|
2020-01-29 19:37:25 +00:00
|
|
|
font-size: 0.9em;
|
|
|
|
cursor: default;
|
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
&,
|
|
|
|
* {
|
2020-01-29 19:37:25 +00:00
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
* {
|
2021-03-02 13:57:16 +00:00
|
|
|
overflow: hidden;
|
2020-01-29 19:37:25 +00:00
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
2020-07-04 18:49:58 +00:00
|
|
|
background: var(--X3);
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
&[data-selected="true"] {
|
2020-01-29 19:37:25 +00:00
|
|
|
background: var(--accent);
|
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
&,
|
|
|
|
* {
|
2020-01-29 19:37:25 +00:00
|
|
|
color: #fff !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&:active {
|
|
|
|
background: var(--accentDarken);
|
|
|
|
|
2023-04-08 00:01:42 +00:00
|
|
|
&,
|
|
|
|
* {
|
2020-01-29 19:37:25 +00:00
|
|
|
color: #fff !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .users > li {
|
|
|
|
.avatar {
|
|
|
|
min-width: 28px;
|
|
|
|
min-height: 28px;
|
|
|
|
max-width: 28px;
|
|
|
|
max-height: 28px;
|
|
|
|
margin: 0 8px 0 0;
|
|
|
|
border-radius: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.name {
|
|
|
|
margin: 0 8px 0 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .emojis > li {
|
|
|
|
.emoji {
|
|
|
|
display: inline-block;
|
|
|
|
margin: 0 4px 0 0;
|
|
|
|
width: 24px;
|
|
|
|
|
|
|
|
> img {
|
|
|
|
width: 24px;
|
|
|
|
vertical-align: bottom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.alias {
|
|
|
|
margin: 0 0 0 8px;
|
|
|
|
}
|
|
|
|
}
|
2021-09-25 17:55:11 +00:00
|
|
|
|
|
|
|
> .mfmTags > li {
|
|
|
|
.name {
|
|
|
|
}
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
2018-02-20 11:29:52 +00:00
|
|
|
</style>
|