Merge remote-tracking branch 'misskey-original/develop' into develop
# Conflicts: # package.json # packages/backend/src/server/api/endpoints.ts # packages/frontend/src/components/MkButton.vue # packages/frontend/src/components/MkDrive.vue # packages/frontend/src/components/MkEmojiPicker.section.vue # packages/frontend/src/components/MkEmojiPicker.vue # packages/frontend/src/components/MkFoldableSection.vue # packages/frontend/src/components/MkInput.vue # packages/frontend/src/components/MkMenu.vue # packages/frontend/src/components/MkNote.vue # packages/frontend/src/components/MkPostForm.vue # packages/frontend/src/components/MkSignupDialog.form.vue # packages/frontend/src/components/MkSwitch.button.vue # packages/frontend/src/components/MkTab.vue # packages/frontend/src/components/MkTimeline.vue # packages/frontend/src/components/MkUserSelectDialog.vue # packages/frontend/src/components/global/MkCustomEmoji.vue # packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts # packages/frontend/src/os.ts # packages/frontend/src/pages/admin/index.vue # packages/frontend/src/pages/user/home.vue # packages/frontend/src/ui/universal.vue
This commit is contained in:
commit
942b7f1b3c
250 changed files with 2788 additions and 1788 deletions
|
|
@ -24,6 +24,7 @@ import { mixEmoji } from '@/scripts/emojiKitchen/emojiMixer';
|
|||
import { nyaize as doNyaize } from '@/scripts/nyaize.js';
|
||||
import { uhoize as doUhoize } from '@/scripts/uhoize.js';
|
||||
import {ID, Instance} from "misskey-js/built/entities.js";
|
||||
import { safeParseFloat } from '@/scripts/safe-parse.js';
|
||||
|
||||
const QUOTE_STYLE = `
|
||||
display: block;
|
||||
|
|
@ -69,7 +70,7 @@ type MfmProps = {
|
|||
isBot?: boolean;};
|
||||
i?: Misskey.entities.UserLite | null;
|
||||
isNote?: boolean;
|
||||
emojiUrls?: string[];
|
||||
emojiUrls?: Record<string, string>;
|
||||
rootScale?: number;
|
||||
nyaize?: boolean | 'respect';
|
||||
uhoize: boolean | 'respect';
|
||||
|
|
@ -83,7 +84,7 @@ type MfmEvents = {
|
|||
};
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function(props: MfmProps, context: SetupContext<MfmEvents>) {
|
||||
export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEvents>['emit'] }) {
|
||||
const isNote = props.isNote ?? true;
|
||||
const shouldNyaize = props.nyaize ? props.nyaize === 'respect' ? props.author?.isCat : false : false;
|
||||
const shouldUhoize = props.nyaize ? props.nyaize === 'respect' ? props.author?.isGorilla : false : false;
|
||||
|
|
@ -92,13 +93,14 @@ export default function(props: MfmProps, context: SetupContext<MfmEvents>) {
|
|||
|
||||
const rootAst = props.parsedNodes ?? (props.plain ? mfm.parseSimple : mfm.parse)(props.text);
|
||||
|
||||
const validTime = (t: string | null | undefined) => {
|
||||
const validTime = (t: string | boolean | null | undefined) => {
|
||||
if (t == null || typeof t === 'boolean') return null;
|
||||
if (typeof t === 'boolean') return null;
|
||||
return t.match(/^[0-9.]+s$/) ? t : null;
|
||||
};
|
||||
|
||||
const validColor = (c: string | null | undefined): string | null => {
|
||||
if (c == null) return null;
|
||||
const validColor = (c: unknown): string | null => {
|
||||
if (typeof c !== 'string') return null;
|
||||
return c.match(/^[0-9a-f]{3,6}$/i) ? c : null;
|
||||
};
|
||||
|
||||
|
|
@ -257,7 +259,7 @@ export default function(props: MfmProps, context: SetupContext<MfmEvents>) {
|
|||
return h(MkSparkle, {}, genEl(token.children, scale));
|
||||
}
|
||||
case 'rotate': {
|
||||
const degrees = parseFloat(token.props.args.deg ?? '90');
|
||||
const degrees = safeParseFloat(token.props.args.deg) ?? 90;
|
||||
let rotateText = `rotate(${degrees}deg)`;
|
||||
if (!token.props.args.deg && (token.props.args.x || token.props.args.y || token.props.args.z)) {
|
||||
rotateText = '';
|
||||
|
|
@ -279,8 +281,8 @@ export default function(props: MfmProps, context: SetupContext<MfmEvents>) {
|
|||
}
|
||||
case 'position': {
|
||||
if (!defaultStore.state.advancedMfm) break;
|
||||
const x = parseFloat(token.props.args.x ?? '0');
|
||||
const y = parseFloat(token.props.args.y ?? '0');
|
||||
const x = safeParseFloat(token.props.args.x) ?? 0;
|
||||
const y = safeParseFloat(token.props.args.y) ?? 0;
|
||||
style = `transform: translateX(${x}em) translateY(${y}em);`;
|
||||
break;
|
||||
}
|
||||
|
|
@ -289,8 +291,8 @@ export default function(props: MfmProps, context: SetupContext<MfmEvents>) {
|
|||
style = '';
|
||||
break;
|
||||
}
|
||||
const x = Math.min(parseFloat(token.props.args.x ?? '1'), 5);
|
||||
const y = Math.min(parseFloat(token.props.args.y ?? '1'), 5);
|
||||
const x = Math.min(safeParseFloat(token.props.args.x) ?? 1, 5);
|
||||
const y = Math.min(safeParseFloat(token.props.args.y) ?? 1, 5);
|
||||
style = `transform: scale(${x}, ${y});`;
|
||||
scale = scale * Math.max(x, y);
|
||||
break;
|
||||
|
|
@ -312,11 +314,12 @@ export default function(props: MfmProps, context: SetupContext<MfmEvents>) {
|
|||
color = color ? `#${color}` : 'var(--accent)';
|
||||
let b_style = token.props.args.style;
|
||||
if (
|
||||
typeof b_style !== 'string' ||
|
||||
!['hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset']
|
||||
.includes(b_style)
|
||||
) b_style = 'solid';
|
||||
const width = parseFloat(token.props.args.width ?? '1');
|
||||
const radius = parseFloat(token.props.args.radius ?? '0');
|
||||
const width = safeParseFloat(token.props.args.width) ?? 1;
|
||||
const radius = safeParseFloat(token.props.args.radius) ?? 0;
|
||||
style = `border: ${width}px ${b_style} ${color}; border-radius: ${radius}px;${token.props.args.noclip ? '' : ' overflow: clip;'}`;
|
||||
break;
|
||||
}
|
||||
|
|
@ -381,7 +384,8 @@ export default function(props: MfmProps, context: SetupContext<MfmEvents>) {
|
|||
return h('span', { onClick(ev: MouseEvent): void {
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
context.emit('clickEv', token.props.args.ev ?? '');
|
||||
const clickEv = typeof token.props.args.ev === 'string' ? token.props.args.ev : '';
|
||||
emit('clickEv', clickEv);
|
||||
} }, genEl(token.children, scale));
|
||||
}
|
||||
}
|
||||
|
|
@ -442,7 +446,7 @@ export default function(props: MfmProps, context: SetupContext<MfmEvents>) {
|
|||
return [h(MkCode, {
|
||||
key: Math.random(),
|
||||
code: token.props.code,
|
||||
lang: token.props.lang,
|
||||
lang: token.props.lang ?? undefined,
|
||||
})];
|
||||
}
|
||||
|
||||
|
|
@ -485,8 +489,7 @@ export default function(props: MfmProps, context: SetupContext<MfmEvents>) {
|
|||
return [h(MkCustomEmoji, {
|
||||
key: Math.random(),
|
||||
name: token.props.name,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
url: props.emojiUrls ? props.emojiUrls[token.props.name] : null,
|
||||
url: props.emojiUrls && props.emojiUrls[token.props.name],
|
||||
normal: props.plain,
|
||||
host: props.author.host,
|
||||
useOriginalSize: scale >= 2.5,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue