(fix) lint issues

This commit is contained in:
kakkokari-gtyih 2023-04-09 19:00:16 +09:00
parent 8c976ee855
commit 50e401426f
9 changed files with 69 additions and 62 deletions

View File

@ -98,4 +98,4 @@ function nav(ev: MouseEvent) {
router.push(props.to, ev.ctrlKey ? 'forcePage' : null);
}
</script>
</script>

View File

@ -1,4 +1,7 @@
import JSON5 from 'json5';
/**
* Client (Embed) entry point
*/
import 'vite/modulepreload-polyfill';
import { miLocalStorage } from '@/local-storage';
import { version, lang, updateLocale, url } from '@/config';
import { embedInitI18n } from './scripts/embed-i18n';
@ -14,7 +17,7 @@ import lightTheme from '@/themes/_light.json5';
import darkTheme from '@/themes/_dark.json5';
import { isDeviceDarkmode } from '@/scripts/is-device-darkmode';
console.info(`Misskey (Embed Sandbox) v${version}`);
console.info(`Misskey (Embed) v${version}`);
const supportedEmbedEntity: string[] = [
'notes'
@ -77,7 +80,7 @@ if (!path.includes('/embed')) {
location.href = url;
throw new Error('Embed script was loaded on non-embed page. Force redirect to the top page.');
}
const pageMetaValues:string[] = path.split('/').filter((e) => e != '' && e != 'embed');
const pageMetaValues:string[] = path.split('/').filter((dir) => dir !== '' && dir !== 'embed');
const pageMeta: { entityName: string; id: string; } = {
entityName: pageMetaValues[0],
id: pageMetaValues[1],
@ -131,8 +134,8 @@ function afterPageInitialization() {
embedInitI18n();
//@ts-ignore
document.querySelectorAll(".mfm").forEach((e: HTMLElement) => {
e.innerHTML = parseMfm(e.innerText, enableAnimatedMfm).outerHTML;
document.querySelectorAll(".mfm").forEach((el: HTMLElement) => {
el.innerHTML = parseMfm(el.innerText, enableAnimatedMfm).outerHTML;
});
parseEmoji();
@ -150,5 +153,5 @@ function afterPageInitialization() {
}
//#endregion
embedInitLinkAnime();
}
embedInitLinkAnime();
}

View File

@ -23,7 +23,7 @@ document.querySelectorAll("time.locale-string").forEach((el) => {
const invalid = Number.isNaN(_time);
const absolute:string = !invalid ? dateTimeFormat.format(_time) : i18n.ts._ago.invalid;
let now = new Date().getTime();
const now = new Date().getTime();
const relative = () => {
if (invalid) return i18n.ts._ago.invalid;
@ -57,4 +57,4 @@ document.querySelectorAll("time.locale-string").forEach((el) => {
}
});
export { };
export { };

View File

@ -1,22 +1,28 @@
import { locale } from "@/config";
import { I18n } from "@/scripts/i18n";
const i18n = new I18n(locale);
export const embedI18n = i18n;
/**
* vueページ向け翻訳適用関数
*
* :
* ```html
* <span data-mi-i18n="翻訳key必須" data-mi-i18n-ctx=" *JSON Objectで動的な値を指定任意* "></span>
* <span data-mi-i18n="翻訳key必須" data-mi-i18n-ctx=" *JSON Objectで動的な値を指定任意* ">
* <element>
* ...
* <element data-mi-i18n-target=" *動的な値を入れたい要素にkeyを指定* "></element>
* ...
* </element>
* </span>
* ```
*/
const i18n = new I18n(locale);
export const embedI18n = i18n;
export function embedInitI18n() {
const els: NodeListOf<HTMLElement> = document.querySelectorAll("[data-mi-i18n]");
els.forEach((tag: HTMLElement) => {
const key: string[] | null = tag.dataset.miI18n?.split('.') || null;
const key: string[] | null = tag.dataset.miI18n?.split('.') ?? null;
const translationContext: Record<string, string | number> | null = JSON.parse(tag.dataset.miI18nCtx ?? 'null');
if (!key) {
console.warn("[i18n] Key doesn't exist!", tag);
@ -48,4 +54,4 @@ export function embedInitI18n() {
tag.innerText = key.reduce((o, i) => o[i], i18n.ts);
}
});
}
}

View File

@ -30,4 +30,4 @@ export function embedInitLinkAnime() {
});
});
}
}
}

View File

@ -3,17 +3,17 @@ import { char2twemojiFilePath } from '@/scripts/emoji-base';
const char2path = char2twemojiFilePath;
const remoteCustomEmojiEl = document.getElementById("remote_custom_emojis");
let remoteCustomEmoji: { name: string; url: string; host?: string; }[] = [];
let remoteCustomEmojis: { name: string; url: string; host?: string; }[] = [];
if (remoteCustomEmojiEl) {
remoteCustomEmoji = JSON.parse(remoteCustomEmojiEl.innerHTML);
remoteCustomEmojis = JSON.parse(remoteCustomEmojiEl.innerHTML);
}
function getCustomEmojiName(ceNameRaw: string) {
return (ceNameRaw.startsWith(":") ? ceNameRaw.substr(1, ceNameRaw.length - 2) : ceNameRaw).replace('@.', '')
return (ceNameRaw.startsWith(":") ? ceNameRaw.substr(1, ceNameRaw.length - 2) : ceNameRaw).replace('@.', '');
}
function getCustomEmojiUrl(ceName: string) {
const remote = remoteCustomEmoji.find((e) => e.name === ceName);
const remote = remoteCustomEmojis.find((emoji) => emoji.name === ceName);
if (remote) {
return remote.url;
}
@ -36,4 +36,4 @@ export function parseEmoji() {
el.innerHTML = emojiEl.outerHTML;
}
});
}
}

View File

@ -50,16 +50,16 @@ export function parseMfm(text: string, useAnim: boolean = false): HTMLDivElement
case 'bold': {
const el = document.createElement("b");
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
return [el];
}
case 'strike': {
const el = document.createElement("del");
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
return [el];
}
@ -67,8 +67,8 @@ export function parseMfm(text: string, useAnim: boolean = false): HTMLDivElement
case 'italic': {
const el = document.createElement("i");
el.style.fontStyle = 'oblique';
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
return [el];
}
@ -131,25 +131,25 @@ export function parseMfm(text: string, useAnim: boolean = false): HTMLDivElement
case 'x2': {
const el = document.createElement("span");
el.classList.add('mfm-x2');
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
})
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
return [el];
}
case 'x3': {
const el = document.createElement("span");
el.classList.add('mfm-x3');
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
})
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
return [el];
}
case 'x4': {
const el = document.createElement("span");
el.classList.add('mfm-x4');
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
})
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
return [el];
}
case 'font': {
@ -168,9 +168,9 @@ export function parseMfm(text: string, useAnim: boolean = false): HTMLDivElement
case 'blur': {
const el = document.createElement("span");
el.classList.add('_mfm_blur_');
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
})
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
return [el];
}
case 'rainbow': {
@ -214,15 +214,15 @@ export function parseMfm(text: string, useAnim: boolean = false): HTMLDivElement
}
if (style == null) {
const el = document.createElement("span");
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
el.innerHTML = `$[${token.props.name} ${el.innerHTML}]`;
return [el];
} else {
const el = document.createElement("span");
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
el.setAttribute('style', `display: inline-block; ${style}`);
return [el];
@ -232,8 +232,8 @@ export function parseMfm(text: string, useAnim: boolean = false): HTMLDivElement
case 'small': {
const el = document.createElement("small");
el.style.opacity = '.7';
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
return [el];
}
@ -241,8 +241,8 @@ export function parseMfm(text: string, useAnim: boolean = false): HTMLDivElement
case 'center': {
const el = document.createElement("div");
el.style.textAlign = "center";
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
return [el];
}
@ -262,8 +262,8 @@ export function parseMfm(text: string, useAnim: boolean = false): HTMLDivElement
el.href = token.props.url;
el.target = '_blank';
el.rel = 'nofollow noopener';
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
return [el];
}
@ -319,8 +319,8 @@ export function parseMfm(text: string, useAnim: boolean = false): HTMLDivElement
case 'quote': {
const el = document.createElement('div');
el.setAttribute('style', QUOTE_STYLE);
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
return [el];
}
@ -370,8 +370,8 @@ export function parseMfm(text: string, useAnim: boolean = false): HTMLDivElement
case 'plain': {
const el = document.createElement('span');
genEl(token.children).forEach((e) => {
el.appendChild(e as HTMLElement);
genEl(token.children).forEach((child) => {
el.appendChild(child as HTMLElement);
});
return [el];
}
@ -397,4 +397,4 @@ export function parseMfm(text: string, useAnim: boolean = false): HTMLDivElement
});
return el;
}
}

View File

@ -9,14 +9,13 @@ export function renderNotFound() {
<div id="instance-info">
<a class="click-anime" href="http://localhost:3000" target="_blank">
<img src="/static-assets/splash.png" class="_anime_bounce_standBy">
<span class="sr-only">${i18n.t('aboutX', {x: instanceName || 'Misskey'})}</span>
<span class="sr-only">${ i18n.t('aboutX', { x: instanceName || 'Misskey' }) }</span>
</a>
</div>
<img class="main" src="https://xn--931a.moe/assets/not-found.jpg">
<h2>${i18n.ts.notFound}</h2>
<p>${i18n.ts.notFoundDescription}</p>
<h2>${ i18n.ts.notFound }</h2>
<p>${ i18n.ts.notFoundDescription }</p>
</div>
</div>`;
}
}
}

View File

@ -81,7 +81,6 @@ export function applyTheme(theme: Theme, persist = true) {
miLocalStorage.setItem('theme', JSON.stringify(props));
miLocalStorage.setItem('colorSchema', colorSchema);
}
}
function compile(theme: Theme): Record<string, string> {