Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 @@ -15,6 +15,7 @@
- Fix: 一部のUI要素の色が正しく表示されない問題を修正
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/1243)
- Fix: 「D」キーでダークモードを切り替える際にsyncDeviceDarkModeのチェックがバイパスされる問題を修正
- Enhance(frontend): MkDraggable をタッチ操作対応

### Server
- Enhance: リモートノートクリーニングジョブのスキップ処理のパフォーマンス改善
Expand Down
472 changes: 409 additions & 63 deletions packages/frontend/src/components/MkDraggable.vue

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion packages/frontend/src/drag-and-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ type DragDataMap = {
driveFiles: Misskey.entities.DriveFile[];
driveFolders: Misskey.entities.DriveFolder[];
deckColumn: string;
MkDraggable: { item: { id: string }; instanceId: string; group: string; };
};

// NOTE: dataTransfer の format は大文字小文字区別されないっぽいので toLowerCase が必要
Expand Down
11 changes: 7 additions & 4 deletions packages/frontend/src/pages/admin/RolesEditorFormula.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div :class="$style.header">
<MkSelect v-model="typeModelForMkSelect" :items="typeDef" :class="$style.typeSelect">
</MkSelect>
<button v-if="draggable" class="_button" :class="$style.dragHandle" :draggable="true" @dragstart.stop="dragStartCallback">
<button v-if="draggable" class="_button" :class="$style.dragHandle" @pointerdown.stop="pointerStartCallback">
<i class="ti ti-menu-2"></i>
</button>
<button v-if="draggable" class="_button" :class="$style.remove" @click="removeSelf">
Expand All @@ -25,12 +25,12 @@ SPDX-License-Identifier: AGPL-3.0-only
manualDragStart
group="roleFormula"
>
<template #default="{ item, dragStart }">
<template #default="{ item, pointerStart }">
<div :class="$style.item">
<!-- divが無いとエラーになる -->
<RolesEditorFormula
:modelValue="item"
:dragStartCallback="dragStart"
:pointerStartCallback="pointerStart"
draggable
@update:modelValue="updated => childValuesItemUpdated(updated)"
@remove="removeChildItem(item.id)"
Expand Down Expand Up @@ -78,7 +78,7 @@ const emit = defineEmits<{
const props = defineProps<{
modelValue: Misskey.entities.Role['condFormula'];
draggable?: boolean;
dragStartCallback?: (ev: DragEvent) => void;
pointerStartCallback?: (ev: PointerEvent) => void;
}>();

const v = ref(deepClone(props.modelValue));
Expand Down Expand Up @@ -180,6 +180,9 @@ function removeSelf() {
.dragHandle {
cursor: move;
margin-left: 10px;
// MkDraggable のハンドル: ブラウザのスクロール/ズームジェスチャを抑止して、pointerdown を
// ドラッグ開始に確実に転送する (touch-action: manipulation を持つ `_button` を上書き)。
touch-action: none;
}

.remove {
Expand Down
6 changes: 4 additions & 2 deletions packages/frontend/src/pages/admin/server-rules.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ SPDX-License-Identifier: AGPL-3.0-only
withGaps
manualDragStart
>
<template #default="{ item, index, dragStart }">
<template #default="{ item, index, pointerStart }">
<div :class="$style.item">
<div :class="$style.itemHeader">
<div :class="$style.itemNumber">{{ index + 1 }}</div>
<span :class="$style.itemHandle" :draggable="true" @dragstart.stop="dragStart"><i class="ti ti-menu"></i></span>
<span :class="$style.itemHandle" @pointerdown.stop="pointerStart"><i class="ti ti-menu"></i></span>
<button class="_button" :class="$style.itemRemove" @click="remove(item.id)"><i class="ti ti-x"></i></button>
</div>
<MkInput :modelValue="item.text" @update:modelValue="serverRules[index].text = $event"/>
Expand Down Expand Up @@ -85,6 +85,8 @@ function remove(id: string): void {
align-items: center;
justify-content: center;
cursor: move;
// MkDraggable のハンドル: ブラウザのジェスチャを抑止
touch-action: none;
}

.itemNumber {
Expand Down
6 changes: 4 additions & 2 deletions packages/frontend/src/pages/channel-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ SPDX-License-Identifier: AGPL-3.0-only
manualDragStart
@update:modelValue="v => pinnedNoteIds = v.map(x => x.id)"
>
<template #default="{ item, dragStart }">
<template #default="{ item, pointerStart }">
<div :class="$style.pinnedNote">
<button class="_button" :class="$style.pinnedNoteHandle" tabindex="-1" :draggable="true" @dragstart.stop="dragStart"><i class="ti ti-menu"></i></button>
<button class="_button" :class="$style.pinnedNoteHandle" tabindex="-1" @pointerdown.stop="pointerStart"><i class="ti ti-menu"></i></button>
{{ item.id }}
<button class="_button" :class="$style.pinnedNoteRemove" @click="removePinnedNote(item.id)"><i class="ti ti-x"></i></button>
</div>
Expand Down Expand Up @@ -242,5 +242,7 @@ definePage(() => ({
height: 32px;
margin: 0 8px;
opacity: 0.5;
// MkDraggable のハンドル: ブラウザのジェスチャを抑止
touch-action: none;
}
</style>
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/page-editor/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/

import { i18n } from '@/i18n.js';
import type { MkSelectItem } from '@/components/MkSelect.vue';
import { i18n } from '@/i18n.js';

export function getPageBlockList() {
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only

<template>
<!-- eslint-disable vue/no-mutating-props -->
<XContainer :draggable="true" :dragStartCallback="dragStartCallback" @remove="() => emit('remove')">
<XContainer :draggable="true" :pointerStartCallback="pointerStartCallback" @remove="() => emit('remove')">
<template #header><i class="ti ti-photo"></i> {{ i18n.ts._pages.blocks.image }}</template>
<template #func>
<button @click="choose()">
Expand All @@ -30,7 +30,7 @@ import { i18n } from '@/i18n.js';
import { chooseDriveFile } from '@/utility/drive.js';

const props = defineProps<{
dragStartCallback?: (ev: DragEvent) => void;
pointerStartCallback?: (ev: PointerEvent) => void;
modelValue: Misskey.entities.PageBlock & { type: 'image' };
}>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only

<template>
<!-- eslint-disable vue/no-mutating-props -->
<XContainer :draggable="true" :dragStartCallback="dragStartCallback" @remove="() => emit('remove')">
<XContainer :draggable="true" :pointerStartCallback="pointerStartCallback" @remove="() => emit('remove')">
<template #header><i class="ti ti-note"></i> {{ i18n.ts._pages.blocks.note }}</template>

<section style="padding: 16px;" class="_gaps_s">
Expand All @@ -22,7 +22,6 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>

<script lang="ts" setup>
/* eslint-disable vue/no-mutating-props */
import { watch, ref } from 'vue';
import * as Misskey from 'misskey-js';
import XContainer from '../page-editor.container.vue';
Expand All @@ -34,7 +33,7 @@ import { misskeyApi } from '@/utility/misskey-api.js';
import { i18n } from '@/i18n.js';

const props = defineProps<{
dragStartCallback?: (ev: DragEvent) => void;
pointerStartCallback?: (ev: PointerEvent) => void;
modelValue: Misskey.entities.PageBlock & { type: 'note' };
}>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only

<template>
<!-- eslint-disable vue/no-mutating-props -->
<XContainer :draggable="true" :dragStartCallback="dragStartCallback" @remove="() => emit('remove')">
<XContainer :draggable="true" :pointerStartCallback="pointerStartCallback" @remove="() => emit('remove')">
<template #header><i class="ti ti-note"></i> {{ props.modelValue.title }}</template>
<template #func>
<button class="_button" @click="rename()">
Expand Down Expand Up @@ -35,7 +35,7 @@ import { getPageBlockList } from '@/pages/page-editor/common.js';
const XBlocks = defineAsyncComponent(() => import('../page-editor.blocks.vue'));

const props = defineProps<{
dragStartCallback?: (ev: DragEvent) => void;
pointerStartCallback?: (ev: PointerEvent) => void;
modelValue: Extract<Misskey.entities.PageBlock, { type: 'section'; }>,
}>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only

<template>
<!-- eslint-disable vue/no-mutating-props -->
<XContainer :draggable="true" :dragStartCallback="dragStartCallback" @remove="() => emit('remove')">
<XContainer :draggable="true" :pointerStartCallback="pointerStartCallback" @remove="() => emit('remove')">
<template #header><i class="ti ti-align-left"></i> {{ i18n.ts._pages.blocks.text }}</template>

<section>
Expand All @@ -22,7 +22,7 @@ import { i18n } from '@/i18n.js';
import { Autocomplete } from '@/utility/autocomplete.js';

const props = defineProps<{
dragStartCallback?: (ev: DragEvent) => void;
pointerStartCallback?: (ev: PointerEvent) => void;
modelValue: Misskey.entities.PageBlock & { type: 'text' }
}>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ SPDX-License-Identifier: AGPL-3.0-only
group="pageBlocks"
@update:modelValue="v => emit('update:modelValue', v)"
>
<template #default="{ item, dragStart }">
<template #default="{ item, pointerStart }">
<div>
<!-- divが無いとエラーになる -->
<component
:is="getComponent(item.type)"
:modelValue="item"
:dragStartCallback="dragStart"
:pointerStartCallback="pointerStart"
@update:modelValue="updateItem"
@remove="() => removeItem(item)"
/>
Expand All @@ -29,12 +29,12 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>

<script lang="ts" setup>
import type { Component } from 'vue';
import * as Misskey from 'misskey-js';
import XSection from './els/page-editor.el.section.vue';
import XText from './els/page-editor.el.text.vue';
import XImage from './els/page-editor.el.image.vue';
import XNote from './els/page-editor.el.note.vue';
import type { Component } from 'vue';
import MkDraggable from '@/components/MkDraggable.vue';

function getComponent(type: Misskey.entities.Page['content'][number]['type']): Component {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<button v-if="removable" class="_button" @click="remove()">
<i class="ti ti-trash"></i>
</button>
<button v-if="draggable" class="drag-handle _button" tabindex="-1" :draggable="true" @dragstart.stop="dragStartCallback">
<button v-if="draggable" class="drag-handle _button" tabindex="-1" @pointerdown.stop="pointerStartCallback">
<i class="ti ti-menu-2"></i>
</button>
<button class="_button" @click="toggleContent(!showBody)">
Expand All @@ -34,7 +34,7 @@ const props = withDefaults(defineProps<{
expanded?: boolean;
removable?: boolean;
draggable?: boolean;
dragStartCallback?: (ev: DragEvent) => void;
pointerStartCallback?: (ev: PointerEvent) => void;
}>(), {
expanded: true,
removable: true,
Expand Down Expand Up @@ -111,6 +111,8 @@ function remove() {

.drag-handle {
cursor: move;
// MkDraggable のハンドル: ブラウザのジェスチャを抑止
touch-action: none;
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions packages/frontend/src/pages/settings/navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ SPDX-License-Identifier: AGPL-3.0-only
direction="vertical"
manualDragStart
>
<template #default="{ item, dragStart }">
<template #default="{ item, pointerStart }">
<div
v-if="item.type === '-' || navbarItemDef[item.type]"
:class="$style.item"
>
<button class="_button" :class="$style.itemHandle" tabindex="-1" :draggable="true" @dragstart.stop="dragStart"><i class="ti ti-menu"></i></button>
<button class="_button" :class="$style.itemHandle" tabindex="-1" @pointerdown.stop="pointerStart"><i class="ti ti-menu"></i></button>
<i class="ti-fw" :class="[$style.itemIcon, navbarItemDef[item.type]?.icon]"></i><span :class="$style.itemText">{{ navbarItemDef[item.type]?.title ?? i18n.ts.divider }}</span>
<button class="_button" :class="$style.itemRemove" @click="removeItem(item.id)"><i class="ti ti-x"></i></button>
</div>
Expand Down Expand Up @@ -162,5 +162,7 @@ definePage(() => ({
height: 32px;
margin: 0 8px;
opacity: 0.5;
// MkDraggable のハンドル: ブラウザのジェスチャを抑止
touch-action: none;
}
</style>
6 changes: 4 additions & 2 deletions packages/frontend/src/pages/settings/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ SPDX-License-Identifier: AGPL-3.0-only
withGaps
manualDragStart
>
<template #default="{ item, dragStart }">
<template #default="{ item, pointerStart }">
<div v-panel :class="$style.fieldDragItem">
<button v-if="!fieldEditMode" class="_button" :class="$style.dragItemHandle" tabindex="-1" :draggable="true" @dragstart.stop="dragStart"><i class="ti ti-menu"></i></button>
<button v-if="!fieldEditMode" class="_button" :class="$style.dragItemHandle" tabindex="-1" @pointerdown.stop="pointerStart"><i class="ti ti-menu"></i></button>
<button v-if="fieldEditMode" :disabled="fields.length <= 1" class="_button" :class="$style.dragItemRemove" @click="deleteField(item.id)"><i class="ti ti-x"></i></button>
<div :class="$style.dragItemForm">
<FormSplit :minWidth="200">
Expand Down Expand Up @@ -426,6 +426,8 @@ definePage(() => ({
margin: 0 8px 0 0;
opacity: 0.5;
flex-shrink: 0;
// MkDraggable のハンドル: ブラウザのジェスチャを抑止
touch-action: none;

&:active {
cursor: grabbing;
Expand Down
Loading