From 4f247a0784be6d3d75e988cb84fd8f962a3d8681 Mon Sep 17 00:00:00 2001 From: FineArchs <133759614+FineArchs@users.noreply.github.com> Date: Mon, 25 Dec 2023 18:03:06 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=E3=82=AF=E3=83=AA=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88=E3=82=92=E7=99=BA=E7=94=9F?= =?UTF-8?q?=E3=81=95=E3=81=9B=E3=82=8BMFM=E6=A7=8B=E6=96=87=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=20(#12798)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update MkMisskeyFlavoredMarkdown.ts * fix MkMisskeyFlavoredMarkdown.ts * Update MkAsUi.vue * Update ui.ts * Fix MkMisskeyFlavoredMarkdown.ts * Update CHANGELOG.md * fix ui.ts * revert CHANGELOG.md * Update CHANGELOG.md --- CHANGELOG.md | 1 + packages/frontend/src/components/MkAsUi.vue | 2 +- .../global/MkMisskeyFlavoredMarkdown.ts | 15 +++++++++++++-- packages/frontend/src/scripts/aiscript/ui.ts | 6 ++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5db3783e1..e452eb384 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ ### Client - Fix: 一部のモデログ(logYellowでの表示対象)について、表示の色が変わらない問題を修正 +- Feat: AiScript専用のMFM構文`$[clickable.ev=EVENTNAME ...]`を追加。`Mk:C:mfm`のオプション`onClickEv`に関数を渡すと、クリック時に`EVENTNAME`を引数にして呼び出す ### Server - Enhance: センシティブワードの設定がハッシュタグトレンドにも適用されるようになりました diff --git a/packages/frontend/src/components/MkAsUi.vue b/packages/frontend/src/components/MkAsUi.vue index 4239cc609..0ff5bd703 100644 --- a/packages/frontend/src/components/MkAsUi.vue +++ b/packages/frontend/src/components/MkAsUi.vue @@ -11,7 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only {{ c.text }} - + {{ c.text }}
{{ button.text }} diff --git a/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts b/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts index a46c7f0ce..3e72b6479 100644 --- a/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts +++ b/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { VNode, h } from 'vue'; +import { VNode, h, SetupContext } from 'vue'; import * as mfm from 'mfm-js'; import * as Misskey from 'misskey-js'; import MkUrl from '@/components/global/MkUrl.vue'; @@ -43,8 +43,12 @@ type MfmProps = { enableEmojiMenuReaction?: boolean; }; +type MfmEvents = { + clickEv(id: string): void; +}; + // eslint-disable-next-line import/no-default-export -export default function(props: MfmProps) { +export default function(props: MfmProps, context: SetupContext) { const isNote = props.isNote ?? true; const shouldNyaize = props.nyaize ? props.nyaize === 'respect' ? props.author?.isCat : false : false; @@ -281,6 +285,13 @@ export default function(props: MfmProps) { }), ]); } + case 'clickable': { + return h('span', { onClick(ev: MouseEvent): void { + ev.stopPropagation(); + ev.preventDefault(); + context.emit('clickEv', token.props.args.ev ?? ''); + } }, genEl(token.children, scale)); + } } if (style === undefined) { return h('span', {}, ['$[', token.props.name, ' ', ...genEl(token.children, scale), ']']); diff --git a/packages/frontend/src/scripts/aiscript/ui.ts b/packages/frontend/src/scripts/aiscript/ui.ts index 75b924843..08ba1e6d9 100644 --- a/packages/frontend/src/scripts/aiscript/ui.ts +++ b/packages/frontend/src/scripts/aiscript/ui.ts @@ -47,6 +47,7 @@ export type AsUiMfm = AsUiComponentBase & { bold?: boolean; color?: string; font?: 'serif' | 'sans-serif' | 'monospace'; + onClickEv?: (evId: string) => void }; export type AsUiButton = AsUiComponentBase & { @@ -230,6 +231,8 @@ function getMfmOptions(def: values.Value | undefined): Omit { + if (onClickEv) call(onClickEv, values.STR(evId)); + }, }; }