From b517d760849eeab9e09b198c5302475de72d3674 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 17 Nov 2023 13:09:56 +0900 Subject: [PATCH] =?UTF-8?q?enhance(frontend):=20MFM=E3=81=A7=E3=83=AB?= =?UTF-8?q?=E3=83=93=E3=82=92=E6=8C=AF=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve #9161 --- CHANGELOG.md | 2 ++ packages/frontend/src/components/MkAutocomplete.vue | 2 +- .../src/components/global/MkMisskeyFlavoredMarkdown.ts | 6 ++++++ packages/frontend/src/const.ts | 2 ++ packages/frontend/src/scripts/mfm-tags.ts | 6 ------ 5 files changed, 11 insertions(+), 7 deletions(-) delete mode 100644 packages/frontend/src/scripts/mfm-tags.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index da183cba7..364199503 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ - Enhance: 依存関係の更新 ### Client +- Enhance: MFMでルビを振れるように + - 例: `$[ruby 三須木 みすき]` - Enhance: プラグインでエラーが発生した場合のハンドリングを強化 - Enhance: 細かなUIのブラッシュアップ - Fix: 効果音が再生されるとデバイスで再生している動画や音声が停止する問題を修正 #12339 diff --git a/packages/frontend/src/components/MkAutocomplete.vue b/packages/frontend/src/components/MkAutocomplete.vue index 7c4f91055..7e0c21904 100644 --- a/packages/frontend/src/components/MkAutocomplete.vue +++ b/packages/frontend/src/components/MkAutocomplete.vue @@ -45,12 +45,12 @@ import contains from '@/scripts/contains.js'; import { char2twemojiFilePath, char2fluentEmojiFilePath } from '@/scripts/emoji-base.js'; import { acct } from '@/filters/user.js'; import * as os from '@/os.js'; -import { MFM_TAGS } from '@/scripts/mfm-tags.js'; import { defaultStore } from '@/store.js'; import { emojilist, getEmojiName } from '@/scripts/emojilist.js'; import { i18n } from '@/i18n.js'; import { miLocalStorage } from '@/local-storage.js'; import { customEmojis } from '@/custom-emojis.js'; +import { MFM_TAGS } from '@/const.js'; type EmojiDef = { emoji: string; diff --git a/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts b/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts index d14a1fb63..1b6676920 100644 --- a/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts +++ b/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts @@ -238,6 +238,12 @@ export default function(props: MfmProps) { style = `background-color: #${color};`; break; } + case 'ruby': { + const child = token.children[0]; + const text = child.type === 'text' ? child.props.text : ''; + return h('ruby', { + }, [text.split(' ')[0], h('rt', text.split(' ')[1])]); + } } if (style == null) { return h('span', {}, ['$[', token.props.name, ' ', ...genEl(token.children, scale), ']']); diff --git a/packages/frontend/src/const.ts b/packages/frontend/src/const.ts index b3071fd92..002c198b4 100644 --- a/packages/frontend/src/const.ts +++ b/packages/frontend/src/const.ts @@ -92,3 +92,5 @@ export const CURRENT_STICKY_BOTTOM = 'CURRENT_STICKY_BOTTOM'; export const DEFAULT_SERVER_ERROR_IMAGE_URL = 'https://xn--931a.moe/assets/error.jpg'; export const DEFAULT_NOT_FOUND_IMAGE_URL = 'https://xn--931a.moe/assets/not-found.jpg'; export const DEFAULT_INFO_IMAGE_URL = 'https://xn--931a.moe/assets/info.jpg'; + +export const MFM_TAGS = ['tada', 'jelly', 'twitch', 'shake', 'spin', 'jump', 'bounce', 'flip', 'x2', 'x3', 'x4', 'scale', 'position', 'fg', 'bg', 'font', 'blur', 'rainbow', 'sparkle', 'rotate', 'ruby']; diff --git a/packages/frontend/src/scripts/mfm-tags.ts b/packages/frontend/src/scripts/mfm-tags.ts deleted file mode 100644 index dc78e4223..000000000 --- a/packages/frontend/src/scripts/mfm-tags.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* - * SPDX-FileCopyrightText: syuilo and other misskey contributors - * SPDX-License-Identifier: AGPL-3.0-only - */ - -export const MFM_TAGS = ['tada', 'jelly', 'twitch', 'shake', 'spin', 'jump', 'bounce', 'flip', 'x2', 'x3', 'x4', 'scale', 'position', 'fg', 'bg', 'font', 'blur', 'rainbow', 'sparkle', 'rotate'];