From cf3a315b236c702146829b19bcb5d7be1fbb0d8d Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 13 Aug 2024 21:14:25 +0900 Subject: [PATCH 1/2] feat: localizable dialog title for enter section title --- locales/index.d.ts | 4 ++++ locales/ja-JP.yml | 1 + .../src/pages/page-editor/els/page-editor.el.section.vue | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/locales/index.d.ts b/locales/index.d.ts index 91d36a14a627..9252b5ae1096 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -8985,6 +8985,10 @@ export interface Locale extends ILocale { * ブロックを追加 */ "chooseBlock": string; + /** + * セクションタイトルを入力 + */ + "enterSectionTitle": string; /** * 種類を選択 */ diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index b493183974cc..c655e4678dfc 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2371,6 +2371,7 @@ _pages: eyeCatchingImageSet: "アイキャッチ画像を設定" eyeCatchingImageRemove: "アイキャッチ画像を削除" chooseBlock: "ブロックを追加" + enterSectionTitle: "セクションタイトルを入力" selectType: "種類を選択" contentBlocks: "コンテンツ" inputBlocks: "入力" diff --git a/packages/frontend/src/pages/page-editor/els/page-editor.el.section.vue b/packages/frontend/src/pages/page-editor/els/page-editor.el.section.vue index 47e9c08c2caf..2f0a1f2c3ade 100644 --- a/packages/frontend/src/pages/page-editor/els/page-editor.el.section.vue +++ b/packages/frontend/src/pages/page-editor/els/page-editor.el.section.vue @@ -53,11 +53,11 @@ watch(children, () => { deep: true, }); -const getPageBlockList = inject<(any) => any>('getPageBlockList'); +const getPageBlockList = inject<() => any>('getPageBlockList'); async function rename() { const { canceled, result: title } = await os.inputText({ - title: 'Enter title', + title: i18n.ts._pages.enterSectionTitle, default: props.modelValue.title, }); if (canceled) return; From bfcaf76914c62a4e19864a44c819d20211192178 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 13 Aug 2024 21:16:47 +0900 Subject: [PATCH 2/2] refactor: define `getPageBlockList` in separated file and import instead of provide/inject --- packages/frontend/src/pages/page-editor/common.ts | 15 +++++++++++++++ .../page-editor/els/page-editor.el.section.vue | 3 +-- .../src/pages/page-editor/page-editor.vue | 11 +---------- 3 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 packages/frontend/src/pages/page-editor/common.ts diff --git a/packages/frontend/src/pages/page-editor/common.ts b/packages/frontend/src/pages/page-editor/common.ts new file mode 100644 index 000000000000..420c8fc967eb --- /dev/null +++ b/packages/frontend/src/pages/page-editor/common.ts @@ -0,0 +1,15 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { i18n } from '@/i18n.js'; + +export function getPageBlockList() { + return [ + { value: 'section', text: i18n.ts._pages.blocks.section }, + { value: 'text', text: i18n.ts._pages.blocks.text }, + { value: 'image', text: i18n.ts._pages.blocks.image }, + { value: 'note', text: i18n.ts._pages.blocks.note }, + ]; +} diff --git a/packages/frontend/src/pages/page-editor/els/page-editor.el.section.vue b/packages/frontend/src/pages/page-editor/els/page-editor.el.section.vue index 2f0a1f2c3ade..0f8dc33143ea 100644 --- a/packages/frontend/src/pages/page-editor/els/page-editor.el.section.vue +++ b/packages/frontend/src/pages/page-editor/els/page-editor.el.section.vue @@ -29,6 +29,7 @@ import * as os from '@/os.js'; import { i18n } from '@/i18n.js'; import { deepClone } from '@/scripts/clone.js'; import MkButton from '@/components/MkButton.vue'; +import { getPageBlockList } from '@/pages/page-editor/common.js'; const XBlocks = defineAsyncComponent(() => import('../page-editor.blocks.vue')); @@ -53,8 +54,6 @@ watch(children, () => { deep: true, }); -const getPageBlockList = inject<() => any>('getPageBlockList'); - async function rename() { const { canceled, result: title } = await os.inputText({ title: i18n.ts._pages.enterSectionTitle, diff --git a/packages/frontend/src/pages/page-editor/page-editor.vue b/packages/frontend/src/pages/page-editor/page-editor.vue index af32fd227465..eaef7c337a4c 100644 --- a/packages/frontend/src/pages/page-editor/page-editor.vue +++ b/packages/frontend/src/pages/page-editor/page-editor.vue @@ -77,6 +77,7 @@ import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { $i } from '@/account.js'; import { mainRouter } from '@/router/main.js'; +import { getPageBlockList } from '@/pages/page-editor/common.js'; const props = defineProps<{ initPageId?: string; @@ -101,7 +102,6 @@ const alignCenter = ref(false); const hideTitleWhenPinned = ref(false); provide('readonly', readonly.value); -provide('getPageBlockList', getPageBlockList); watch(eyeCatchingImageId, async () => { if (eyeCatchingImageId.value == null) { @@ -216,15 +216,6 @@ async function add() { content.value.push({ id, type }); } -function getPageBlockList() { - return [ - { value: 'section', text: i18n.ts._pages.blocks.section }, - { value: 'text', text: i18n.ts._pages.blocks.text }, - { value: 'image', text: i18n.ts._pages.blocks.image }, - { value: 'note', text: i18n.ts._pages.blocks.note }, - ]; -} - function setEyeCatchingImage(img) { selectFile(img.currentTarget ?? img.target, null).then(file => { eyeCatchingImageId.value = file.id;