fix copy/paste
This commit is contained in:
parent
bfdfc2c778
commit
106e7910b9
|
@ -312,7 +312,7 @@ function setupGrid(): GridSetting {
|
||||||
bindTo: 'roleIdsThatCanBeUsedThisEmojiAsReaction', title: 'role', type: 'text', editable: true, width: 140,
|
bindTo: 'roleIdsThatCanBeUsedThisEmojiAsReaction', title: 'role', type: 'text', editable: true, width: 140,
|
||||||
valueTransformer: (row) => {
|
valueTransformer: (row) => {
|
||||||
// バックエンドからからはIDと名前のペア配列で受け取るが、表示にIDがあると煩雑なので名前だけにする
|
// バックエンドからからはIDと名前のペア配列で受け取るが、表示にIDがあると煩雑なので名前だけにする
|
||||||
return (gridItems.value[row.index].roleIdsThatCanBeUsedThisEmojiAsReaction ?? [])
|
return gridItems.value[row.index].roleIdsThatCanBeUsedThisEmojiAsReaction
|
||||||
.map((it) => it.name)
|
.map((it) => it.name)
|
||||||
.join(',');
|
.join(',');
|
||||||
},
|
},
|
||||||
|
@ -597,15 +597,15 @@ async function onGridKeyDown(event: GridKeyDownEvent, currentState: GridContext)
|
||||||
try {
|
try {
|
||||||
const obj = JSON.parse(value);
|
const obj = JSON.parse(value);
|
||||||
if (!Array.isArray(obj)) {
|
if (!Array.isArray(obj)) {
|
||||||
return undefined;
|
return [];
|
||||||
}
|
}
|
||||||
if (!obj.every(it => typeof it === 'object' && 'id' in it && 'name' in it)) {
|
if (!obj.every(it => typeof it === 'object' && 'id' in it && 'name' in it)) {
|
||||||
return undefined;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj.map(it => ({ id: it.id, name: it.name }));
|
return obj.map(it => ({ id: it.id, name: it.name }));
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
return undefined;
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@ import { DroppedFile, extractDroppedItems, flattenDroppedFiles } from '@/scripts
|
||||||
import { optInGridUtils } from '@/components/grid/optin-utils.js';
|
import { optInGridUtils } from '@/components/grid/optin-utils.js';
|
||||||
import XRegisterLogs from '@/pages/admin/custom-emojis-manager.local.logs.vue';
|
import XRegisterLogs from '@/pages/admin/custom-emojis-manager.local.logs.vue';
|
||||||
import { GridSetting } from '@/components/grid/grid.js';
|
import { GridSetting } from '@/components/grid/grid.js';
|
||||||
|
import { CellValue } from '@/components/grid/cell.js';
|
||||||
|
|
||||||
const MAXIMUM_EMOJI_REGISTER_COUNT = 100;
|
const MAXIMUM_EMOJI_REGISTER_COUNT = 100;
|
||||||
|
|
||||||
|
@ -163,7 +164,7 @@ function setupGrid(): GridSetting {
|
||||||
bindTo: 'roleIdsThatCanBeUsedThisEmojiAsReaction', title: 'role', type: 'text', editable: true, width: 140,
|
bindTo: 'roleIdsThatCanBeUsedThisEmojiAsReaction', title: 'role', type: 'text', editable: true, width: 140,
|
||||||
valueTransformer: (row) => {
|
valueTransformer: (row) => {
|
||||||
// バックエンドからからはIDと名前のペア配列で受け取るが、表示にIDがあると煩雑なので名前だけにする
|
// バックエンドからからはIDと名前のペア配列で受け取るが、表示にIDがあると煩雑なので名前だけにする
|
||||||
return (gridItems.value[row.index].roleIdsThatCanBeUsedThisEmojiAsReaction ?? [])
|
return gridItems.value[row.index].roleIdsThatCanBeUsedThisEmojiAsReaction
|
||||||
.map((it) => it.name)
|
.map((it) => it.name)
|
||||||
.join(',');
|
.join(',');
|
||||||
},
|
},
|
||||||
|
@ -383,8 +384,61 @@ function onGridCellValueChange(event: GridCellValueChangeEvent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onGridKeyDown(event: GridKeyDownEvent, currentState: GridContext) {
|
async function onGridKeyDown(event: GridKeyDownEvent, context: GridContext) {
|
||||||
optInGridUtils.defaultKeyDownHandler(gridItems, event, currentState);
|
function roleIdConverter(value: string): CellValue {
|
||||||
|
try {
|
||||||
|
const obj = JSON.parse(value);
|
||||||
|
if (!Array.isArray(obj)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (!obj.every(it => typeof it === 'object' && 'id' in it && 'name' in it)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj.map(it => ({ id: it.id, name: it.name }));
|
||||||
|
} catch (ex) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const { ctrlKey, shiftKey, code } = event.event;
|
||||||
|
|
||||||
|
switch (true) {
|
||||||
|
case ctrlKey && shiftKey: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ctrlKey: {
|
||||||
|
switch (code) {
|
||||||
|
case 'KeyC': {
|
||||||
|
optInGridUtils.copyToClipboard(gridItems, context);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'KeyV': {
|
||||||
|
await optInGridUtils.pasteFromClipboard(
|
||||||
|
gridItems,
|
||||||
|
context,
|
||||||
|
[
|
||||||
|
{ bindTo: 'roleIdsThatCanBeUsedThisEmojiAsReaction', converter: roleIdConverter },
|
||||||
|
],
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case shiftKey: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
switch (code) {
|
||||||
|
case 'Delete': {
|
||||||
|
optInGridUtils.deleteSelectionRange(gridItems, context);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fromDriveFile(it: Misskey.entities.DriveFile): GridItem {
|
function fromDriveFile(it: Misskey.entities.DriveFile): GridItem {
|
||||||
|
|
Loading…
Reference in New Issue