From 434089521ac0c5c895f9184d6fb111ce78701f57 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Tue, 9 Jul 2024 19:15:23 +0900 Subject: [PATCH] move scripts --- packages/frontend/src/components/MkMediaList.vue | 2 +- packages/frontend/src/components/MkMenu.vue | 4 ++-- packages/frontend/src/components/MkNote.vue | 2 +- packages/frontend/src/os.ts | 2 +- packages/frontend/src/scripts/{tms => }/focus.ts | 2 +- packages/frontend/src/scripts/{tms => }/get-or-null.ts | 0 packages/frontend/src/scripts/hotkey.ts | 3 ++- 7 files changed, 8 insertions(+), 7 deletions(-) rename packages/frontend/src/scripts/{tms => }/focus.ts (96%) rename packages/frontend/src/scripts/{tms => }/get-or-null.ts (100%) diff --git a/packages/frontend/src/components/MkMediaList.vue b/packages/frontend/src/components/MkMediaList.vue index d890c5c869..24b177d255 100644 --- a/packages/frontend/src/components/MkMediaList.vue +++ b/packages/frontend/src/components/MkMediaList.vue @@ -39,7 +39,7 @@ import XVideo from '@/components/MkMediaVideo.vue'; import * as os from '@/os.js'; import { FILE_TYPE_BROWSERSAFE } from '@/const.js'; import { defaultStore } from '@/store.js'; -import { focusParent } from '@/scripts/tms/focus.js'; +import { focusParent } from '@/scripts/focus.js'; const props = defineProps<{ mediaList: Misskey.entities.DriveFile[]; diff --git a/packages/frontend/src/components/MkMenu.vue b/packages/frontend/src/components/MkMenu.vue index def0531322..7338fd6eda 100644 --- a/packages/frontend/src/components/MkMenu.vue +++ b/packages/frontend/src/components/MkMenu.vue @@ -108,8 +108,8 @@ import * as os from '@/os.js'; import { i18n } from '@/i18n.js'; import { isTouchUsing } from '@/scripts/touch.js'; import { type Keymap } from '@/scripts/hotkey.js'; -import { focusParent, isFocusable } from '@/scripts/tms/focus.js'; -import { getNodeOrNull } from '@/scripts/tms/get-or-null.js'; +import { focusParent, isFocusable } from '@/scripts/focus.js'; +import { getNodeOrNull } from '@/scripts/get-or-null.js'; const childrenCache = new WeakMap(); diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index ce38cdb979..420ff2c651 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -198,7 +198,7 @@ import { showMovedDialog } from '@/scripts/show-moved-dialog.js'; import { shouldCollapsed } from '@/scripts/collapsed.js'; import { isEnabledUrlPreview } from '@/instance.js'; import { type Keymap } from '@/scripts/hotkey.js'; -import { focusPrev, focusNext } from '@/scripts/tms/focus.js'; +import { focusPrev, focusNext } from '@/scripts/focus.js'; const props = withDefaults(defineProps<{ note: Misskey.entities.Note; diff --git a/packages/frontend/src/os.ts b/packages/frontend/src/os.ts index 78e12c9068..8eb0b2b346 100644 --- a/packages/frontend/src/os.ts +++ b/packages/frontend/src/os.ts @@ -24,7 +24,7 @@ import MkContextMenu from '@/components/MkContextMenu.vue'; import { MenuItem } from '@/types/menu.js'; import copyToClipboard from '@/scripts/copy-to-clipboard.js'; import { showMovedDialog } from '@/scripts/show-moved-dialog.js'; -import { getHTMLElementOrNull } from '@/scripts/tms/get-or-null.js'; +import { getHTMLElementOrNull } from '@/scripts/get-or-null.js'; export const openingWindowsCount = ref(0); diff --git a/packages/frontend/src/scripts/tms/focus.ts b/packages/frontend/src/scripts/focus.ts similarity index 96% rename from packages/frontend/src/scripts/tms/focus.ts rename to packages/frontend/src/scripts/focus.ts index 146ddcf99d..0376ecf7d2 100644 --- a/packages/frontend/src/scripts/tms/focus.ts +++ b/packages/frontend/src/scripts/focus.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { getElementOrNull, getNodeOrNull } from '@/scripts/tms/get-or-null.js'; +import { getElementOrNull, getNodeOrNull } from '@/scripts/get-or-null.js'; type MaybeHTMLElement = EventTarget | Node | Element | HTMLElement; diff --git a/packages/frontend/src/scripts/tms/get-or-null.ts b/packages/frontend/src/scripts/get-or-null.ts similarity index 100% rename from packages/frontend/src/scripts/tms/get-or-null.ts rename to packages/frontend/src/scripts/get-or-null.ts diff --git a/packages/frontend/src/scripts/hotkey.ts b/packages/frontend/src/scripts/hotkey.ts index 499e8418b2..073d416263 100644 --- a/packages/frontend/src/scripts/hotkey.ts +++ b/packages/frontend/src/scripts/hotkey.ts @@ -2,6 +2,7 @@ * SPDX-FileCopyrightText: syuilo and misskey-project * SPDX-License-Identifier: AGPL-3.0-only */ +import { getHTMLElementOrNull } from "@/scripts/get-or-null.js"; //#region types export type Keymap = Record; @@ -55,7 +56,7 @@ export const makeHotkey = (keymap: Keymap) => { if ('pswp' in window && window.pswp != null) return; if (document.activeElement != null) { if (IGNORE_ELEMENTS.includes(document.activeElement.tagName.toLowerCase())) return; - if ((document.activeElement as HTMLElement).isContentEditable) return; + if (getHTMLElementOrNull(document.activeElement)?.isContentEditable) return; } for (const action of actions) { if (matchPatterns(ev, action)) {