Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(frontend): ブラウザのコンテキストメニューを使用できるように #14076

Merged
merged 20 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
(Cherry-picked from https://github.com/taiyme/misskey/pull/238)
- Enhance: AiScriptを0.19.0にアップデート
- Enhance: Allow negative delay for MFM animation elements (`tada`, `jelly`, `twitch`, `shake`, `spin`, `jump`, `bounce`, `rainbow`)
- Enhance: ブラウザのコンテキストメニューを使用できるように
- Fix: `/about#federation` ページなどで各インスタンスのチャートが表示されなくなっていた問題を修正
- Fix: ユーザーページの追加情報のラベルを投稿者のサーバーの絵文字で表示する (#13968)
- Fix: リバーシの対局を正しく共有できないことがある問題を修正
Expand Down
18 changes: 18 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10086,6 +10086,24 @@ export interface Locale extends ILocale {
*/
"loop": string;
};
"_contextMenu": {
/**
* Misskey独自のコンテキストメニュー
*/
"title": string;
/**
* 常に表示する
*/
"always": string;
/**
* Shiftキーを押しながらで表示
*/
"withShift": string;
/**
* 無効(常にブラウザのUIを使用)
*/
"never": string;
};
}
declare const locales: {
[lang: string]: Locale;
Expand Down
6 changes: 6 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2689,3 +2689,9 @@ _mediaControls:
pip: "ピクチャインピクチャ"
playbackRate: "再生速度"
loop: "ループ再生"

_contextMenu:
title: "Misskey独自のコンテキストメニュー"
always: "常に表示する"
withShift: "Shiftキーを押しながらで表示"
never: "無効(常にブラウザのUIを使用)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title: "Misskey独自のコンテキストメニュー"
always: "常に表示する"
withShift: "Shiftキーを押しながらで表示"
never: "無効(常にブラウザのUIを使用)"
title: "コンテキストメニュー"
app: "アプリケーション"
appWithShift: "Shiftキーでアプリケーション"
native: "ネイティブ"

で良さそう

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「アプリケーション」だと何のことか分からなくならない?(ブラウザもアプリケーションなので)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_contextMenu:
  title: "コンテキストメニュー"
  app: "Misskey"
  appWithShift: "ShiftキーでMisskey"
  native: "ブラウザのUI"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

利用者は今使っているものが「Misskey」であると認識していない可能性があるわね

Copy link
Contributor Author

@kakkokari-gtyih kakkokari-gtyih Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

うーむ
かといってアプリケーションは混同しそうだしサーバー名書いてもかえってなんのことかわかりにくそう

Copy link
Contributor Author

@kakkokari-gtyih kakkokari-gtyih Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

選択肢は「アプリケーション」にしてcaptionつけるか

それはそれで書くほどのこと無い気がしたので最初の提案通りで(わかりにくい旨の指摘が出たら再検討でよいかも)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

個人的にはWebアプリをアプリケーションというのはちょっと違う気が…

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(インストールが必要な一般の"アプリ"やソフトウェアの意味に感じる)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「標準メニュー」と「Misskey独自メニュー」とか?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「標準メニュー」と「Misskey独自メニュー」とか?

個人的には良さそうなのですが

利用者は今使っているものが「Misskey」であると認識していない可能性があるわね

があり…(個人的にはそこまで気にしなくても良いのではないかとも思ってしまいますが)

8 changes: 8 additions & 0 deletions packages/frontend/src/os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as Misskey from 'misskey-js';
import type { ComponentProps as CP } from 'vue-component-type-helpers';
import type { Form, GetFormResultType } from '@/scripts/form.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { defaultStore } from '@/store.js';
import { i18n } from '@/i18n.js';
import MkPostFormDialog from '@/components/MkPostFormDialog.vue';
import MkWaitingDialog from '@/components/MkWaitingDialog.vue';
Expand Down Expand Up @@ -649,6 +650,13 @@ export function popupMenu(items: MenuItem[], src?: HTMLElement | EventTarget | n
}

export function contextMenu(items: MenuItem[], ev: MouseEvent): Promise<void> {
if (
defaultStore.state.contextMenu === 'never' ||
(defaultStore.state.contextMenu === 'withShift' && !ev.shiftKey)
) {
return Promise.resolve();
}

let returnFocusTo = getHTMLElementOrNull(ev.currentTarget ?? ev.target) ?? getHTMLElementOrNull(document.activeElement);
ev.preventDefault();
return new Promise(resolve => nextTick(() => {
Expand Down
8 changes: 8 additions & 0 deletions packages/frontend/src/pages/settings/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ SPDX-License-Identifier: AGPL-3.0-only
<option value="dialog">{{ i18n.ts._serverDisconnectedBehavior.dialog }}</option>
<option value="quiet">{{ i18n.ts._serverDisconnectedBehavior.quiet }}</option>
</MkSelect>
<MkSelect v-model="contextMenu">
<template #label>{{ i18n.ts._contextMenu.title }}</template>
<option value="always">{{ i18n.ts._contextMenu.always }}</option>
<option value="withShift">{{ i18n.ts._contextMenu.withShift }}</option>
<option value="never">{{ i18n.ts._contextMenu.never }}</option>
</MkSelect>
<MkRange v-model="numberOfPageCache" :min="1" :max="10" :step="1" easing>
<template #label>{{ i18n.ts.numberOfPageCache }}</template>
<template #caption>{{ i18n.ts.numberOfPageCacheDescription }}</template>
Expand Down Expand Up @@ -315,6 +321,7 @@ const enableSeasonalScreenEffect = computed(defaultStore.makeGetterSetter('enabl
const enableHorizontalSwipe = computed(defaultStore.makeGetterSetter('enableHorizontalSwipe'));
const useNativeUIForVideoAudioPlayer = computed(defaultStore.makeGetterSetter('useNativeUIForVideoAudioPlayer'));
const alwaysConfirmFollow = computed(defaultStore.makeGetterSetter('alwaysConfirmFollow'));
const contextMenu = computed(defaultStore.makeGetterSetter('contextMenu'));

watch(lang, () => {
miLocalStorage.setItem('lang', lang.value as string);
Expand Down Expand Up @@ -357,6 +364,7 @@ watch([
disableStreamingTimeline,
enableSeasonalScreenEffect,
alwaysConfirmFollow,
contextMenu,
], async () => {
await reloadAsk();
});
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: true,
},
contextMenu: {
where: 'device',
default: 'always' as 'always' | 'withShift' | 'never',
},

sound_masterVolume: {
where: 'device',
Expand Down
Loading