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

複数選択:選択だけ実装 #1470

Merged
merged 59 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
30b055d
(add/multiple-selection)
sevenc-nanashi Aug 4, 2023
0ad4d77
Add: 選択を実装
sevenc-nanashi Aug 5, 2023
c46a2fd
Add: 単体クリックのテストを追加
sevenc-nanashi Aug 5, 2023
fb5788b
Add: focusでも良い感じになるように
sevenc-nanashi Aug 5, 2023
f122e7c
Add: テストを追加
sevenc-nanashi Aug 5, 2023
dc13b41
Merge: main -> add/multiple-selection
sevenc-nanashi Aug 5, 2023
ec906e1
Fix: 間を押したときの挙動を修正
sevenc-nanashi Aug 5, 2023
ac15bbd
Fix: ウィンドウのフォーカスを外したときの挙動を修正
sevenc-nanashi Aug 5, 2023
1223e63
Add: 複数ある物を削除
sevenc-nanashi Aug 5, 2023
847c89c
Fix: Mac周りを修正
sevenc-nanashi Aug 5, 2023
8068fad
Add: test.failを追加
sevenc-nanashi Aug 5, 2023
3980e97
Change: 当たり判定用のdivを召喚するように
sevenc-nanashi Aug 12, 2023
e808521
Update: テストを更新
sevenc-nanashi Aug 12, 2023
79836e4
Add: Shift+カーソルの選択を追加
sevenc-nanashi Aug 12, 2023
4b03835
Change: 実験的機能に隔離
sevenc-nanashi Aug 14, 2023
6e3baba
Fix: ハイライトを修正
sevenc-nanashi Aug 14, 2023
aedd4a4
Delete: skipFocusEvent周りの処理を削除
sevenc-nanashi Aug 15, 2023
b45efb9
Revert: onInputFocus -> setActiveAudioKey
sevenc-nanashi Aug 15, 2023
aae65a4
Revert: 不要な変更をRevert
sevenc-nanashi Aug 15, 2023
ea8453e
Change: 選択食を変更
sevenc-nanashi Aug 15, 2023
0f78045
Change: 少し濃く
sevenc-nanashi Aug 15, 2023
6fe825a
Change: enableSetting -> toggleSetting
sevenc-nanashi Aug 15, 2023
9176b38
Add: Shift+上下のテストを追加
sevenc-nanashi Aug 15, 2023
f001f83
Fix: hostの値を修正
sevenc-nanashi Aug 16, 2023
3942e2b
Fix: playwrightのサーバー起動を無効化していたのを修正
sevenc-nanashi Aug 16, 2023
d67e8a3
Change: selectedではないactiveなAudioCellができるように
sevenc-nanashi Aug 16, 2023
6453ff8
Merge: main -> add/multiple-selection
sevenc-nanashi Aug 16, 2023
4e910d1
Add: コメントを追加
sevenc-nanashi Aug 16, 2023
0ae8237
Revert: 不要な変更をRevert
sevenc-nanashi Aug 16, 2023
bbec109
Refactor: onClickWithModifierKey周りをリファクタ
sevenc-nanashi Aug 16, 2023
f61e3f4
Change: e2eテストをまとめる
sevenc-nanashi Aug 17, 2023
4ef7cd6
Add: コメントを追加
sevenc-nanashi Aug 17, 2023
76e0435
Fix: hostを修正
sevenc-nanashi Aug 17, 2023
3170f53
Merge: main -> add/multiple-selection
sevenc-nanashi Aug 19, 2023
d406a4b
Delete: Macでの分岐を削除
sevenc-nanashi Aug 19, 2023
998d165
Change: selectedは常にactiveを含むように
sevenc-nanashi Aug 19, 2023
0da07d2
Update: テストを更新
sevenc-nanashi Aug 19, 2023
877f6bf
Change: prepareAudioCells -> addAudioCells
sevenc-nanashi Aug 19, 2023
8dad306
Delete: Macでテストを無効化
sevenc-nanashi Aug 19, 2023
ee08b65
Delete: data-is-multi-select-enabledを削除
sevenc-nanashi Aug 19, 2023
9b29af9
Add: filterを追加
sevenc-nanashi Aug 19, 2023
c37df7e
Refactor: onKeyup/downをkeyEventListenerに
sevenc-nanashi Aug 19, 2023
b2019a7
Change: selectedじゃない時だけactiveを移動させるように
sevenc-nanashi Aug 20, 2023
a0e98eb
Improve: コメント回りを改善
sevenc-nanashi Aug 21, 2023
96a46ed
Change: focus周りの仕様を変更
sevenc-nanashi Aug 22, 2023
072093a
Change: 上下移動はテキスト欄にfocusするように
sevenc-nanashi Aug 22, 2023
19e6810
Add: :focusの理由を追加
sevenc-nanashi Aug 22, 2023
16966b5
Change: focusTextField -> focusTarget
sevenc-nanashi Aug 23, 2023
9db22ad
Fix: フォーカス対象を修正
sevenc-nanashi Aug 24, 2023
31b6d42
Add: focusCellのドキュメントを追加
sevenc-nanashi Aug 24, 2023
2f7e79b
Add: テストを追加
sevenc-nanashi Aug 24, 2023
5adcea8
Change: throwするように
sevenc-nanashi Aug 24, 2023
6e6e864
Improve: ドキュメントのわかりやすさを向上
sevenc-nanashi Aug 24, 2023
71393a7
Change: エラーメッセージを変更
sevenc-nanashi Aug 25, 2023
e6838eb
Merge: remove -> local
sevenc-nanashi Aug 25, 2023
1512a5f
Change: AudioCellのfocusCellのfocusTargetをOptionalに
sevenc-nanashi Aug 25, 2023
bc0472b
Delete: Macの処理変更を削除
sevenc-nanashi Aug 25, 2023
f15093d
Fix: Macで落ちることを追求
sevenc-nanashi Aug 26, 2023
60453aa
Update tests/e2e/browser/複数選択.spec.ts
Hiroshiba Aug 26, 2023
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
51 changes: 26 additions & 25 deletions src/components/AudioCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
@blurと@keydown.prevent.enter.exactに分けている
-->
<q-input
ref="textfield"
ref="textField"
filled
dense
hide-bottom-space
Expand Down Expand Up @@ -117,15 +117,15 @@ const emit =
defineEmits<{
(
e: "focusCell",
payload: { audioKey: AudioKey; focusTextField: boolean }
payload: { audioKey: AudioKey; focusTarget: "textField" | "root" }
): void;
}>();

defineExpose({
audioKey: computed(() => props.audioKey),
focusCell: ({ focusTextField }: { focusTextField: boolean }) => {
if (focusTextField) {
textfield.value?.focus();
focusCell: ({ focusTarget }: { focusTarget: "textField" | "root" }) => {
if (focusTarget === "textField") {
textField.value?.focus();
} else {
root.value?.focus();
}
Expand Down Expand Up @@ -301,7 +301,7 @@ const pushAudioTextIfNeeded = async (event?: KeyboardEvent) => {
// see https://github.com/VOICEVOX/voicevox/pull/1364#issuecomment-1620594931
const clearInputSelection = () => {
if (!willFocusOrBlur.value) {
textfieldSelection.toEmpty();
textFieldSelection.toEmpty();
}
};

Expand Down Expand Up @@ -339,11 +339,11 @@ const paste = async (options?: { text?: string }) => {
}

const beforeLength = audioTextBuffer.value.length;
const end = textfieldSelection.selectionEnd ?? 0;
setAudioTextBuffer(textfieldSelection.getReplacedStringTo(text));
const end = textFieldSelection.selectionEnd ?? 0;
setAudioTextBuffer(textFieldSelection.getReplacedStringTo(text));
await nextTick();
// 自動的に削除される改行などの文字数を念のため考慮している
textfieldSelection.setCursorPosition(
textFieldSelection.setCursorPosition(
end + audioTextBuffer.value.length - beforeLength
);
};
Expand All @@ -369,7 +369,7 @@ const putMultilineText = async (texts: string[]) => {
if (audioKeys.length > 0) {
emit("focusCell", {
audioKey: audioKeys[audioKeys.length - 1],
focusTextField: true,
focusTarget: "textField",
});
}
};
Expand All @@ -396,7 +396,7 @@ const moveCell = (offset: number) => (e?: KeyboardEvent) => {
const selectedAudioKeys = store.getters.SELECTED_AUDIO_KEYS;
emit("focusCell", {
audioKey: audioKeys.value[index],
focusTextField: false,
focusTarget: "textField",
});
if (isMultiSelectEnabled.value && e?.shiftKey) {
store.dispatch("SET_SELECTED_AUDIO_KEYS", {
Expand Down Expand Up @@ -426,12 +426,12 @@ const removeCell = async () => {
if (index > 0) {
emit("focusCell", {
audioKey: audioKeys.value[index - 1],
focusTextField: true,
focusTarget: "textField",
});
} else {
emit("focusCell", {
audioKey: audioKeys.value[index + 1],
focusTextField: true,
focusTarget: "textField",
});
}

Expand Down Expand Up @@ -469,14 +469,14 @@ const contextMenudata = ref<
label: "切り取り",
onClick: async () => {
contextMenu.value?.hide();
if (textfieldSelection.isEmpty) return;
if (textFieldSelection.isEmpty) return;

const text = textfieldSelection.getAsString();
const start = textfieldSelection.selectionStart;
setAudioTextBuffer(textfieldSelection.getReplacedStringTo(""));
const text = textFieldSelection.getAsString();
const start = textFieldSelection.selectionStart;
setAudioTextBuffer(textFieldSelection.getReplacedStringTo(""));
await nextTick();
navigator.clipboard.writeText(text);
textfieldSelection.setCursorPosition(start);
textFieldSelection.setCursorPosition(start);
},
disableWhenUiLocked: true,
},
Expand All @@ -485,9 +485,9 @@ const contextMenudata = ref<
label: "コピー",
onClick: () => {
contextMenu.value?.hide();
if (textfieldSelection.isEmpty) return;
if (textFieldSelection.isEmpty) return;

navigator.clipboard.writeText(textfieldSelection.getAsString());
navigator.clipboard.writeText(textFieldSelection.getAsString());
},
disableWhenUiLocked: true,
},
Expand All @@ -506,7 +506,7 @@ const contextMenudata = ref<
label: "全選択",
onClick: async () => {
contextMenu.value?.hide();
textfield.value?.select();
textField.value?.select();
},
disableWhenUiLocked: true,
},
Expand All @@ -521,7 +521,7 @@ const contextMenudata = ref<
audioKey: props.audioKey,
text: audioTextBuffer.value,
});
textfield.value?.blur();
textField.value?.blur();
},
disableWhenUiLocked: true,
},
Expand All @@ -546,7 +546,7 @@ const readyForContextMenu = () => {
const SHORTED_HEADER_FRAGMENT_LENGTH = 5;

// 選択範囲を1行目に表示
const selectionText = textfieldSelection.getAsString();
const selectionText = textFieldSelection.getAsString();
if (selectionText.length === 0) {
isRangeSelected.value = false;
getMenuItemButton("切り取り").disabled = true;
Expand Down Expand Up @@ -579,8 +579,8 @@ const endContextMenuOperation = async () => {
const root = ref<HTMLElement>();

// テキスト欄
const textfield = ref<QInput>();
const textfieldSelection = new SelectionHelperForQInput(textfield);
const textField = ref<QInput>();
const textFieldSelection = new SelectionHelperForQInput(textField);

// 複数エンジン
const isMultipleEngine = computed(() => store.state.engineIds.length > 1);
Expand All @@ -596,6 +596,7 @@ const isMultipleEngine = computed(() => store.state.engineIds.length > 1);
padding: 0.4rem 0.5rem;
margin: 0.2rem 0.5rem;
&:focus {
// divはフォーカスするとデフォルトで青い枠が出るので消す
outline: none;
}
&.selected {
Expand Down
14 changes: 7 additions & 7 deletions src/views/EditorHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const hotkeyMap = new Map<HotkeyAction, () => HotkeyReturnType>([
"テキスト欄にフォーカスを戻す",
() => {
if (activeAudioKey.value !== undefined) {
focusCell({ audioKey: activeAudioKey.value, focusTextField: true });
focusCell({ audioKey: activeAudioKey.value, focusTarget: "textField" });
}
return false; // this is the same with event.preventDefault()
},
Expand Down Expand Up @@ -406,7 +406,7 @@ const addAudioItem = async () => {
audioItem,
prevAudioKey: activeAudioKey.value,
});
audioCellRefs[newAudioKey].focusCell({ focusTextField: true });
audioCellRefs[newAudioKey].focusCell({ focusTarget: "textField" });
};
const duplicateAudioItem = async () => {
const prevAudioKey = activeAudioKey.value;
Expand All @@ -420,7 +420,7 @@ const duplicateAudioItem = async () => {
audioItem: cloneDeep(prevAudioItem),
prevAudioKey: activeAudioKey.value,
});
audioCellRefs[newAudioKey].focusCell({ focusTextField: true });
audioCellRefs[newAudioKey].focusCell({ focusTarget: "textField" });
};

// Pane
Expand Down Expand Up @@ -474,12 +474,12 @@ watch(shouldShowPanes, (val, old) => {
// セルをフォーカス
const focusCell = ({
audioKey,
focusTextField,
focusTarget,
}: {
audioKey: AudioKey;
focusTextField: boolean;
focusTarget: "root" | "textField";
}) => {
audioCellRefs[audioKey].focusCell({ focusTextField });
audioCellRefs[audioKey].focusCell({ focusTarget });
};

// Electronのデフォルトのundo/redoを無効化
Expand Down Expand Up @@ -568,7 +568,7 @@ onMounted(async () => {
const newAudioKey = await store.dispatch("REGISTER_AUDIO_ITEM", {
audioItem,
});
focusCell({ audioKey: newAudioKey, focusTextField: true });
focusCell({ audioKey: newAudioKey, focusTarget: "textField" });

// 最初の話者を初期化
store.dispatch("SETUP_SPEAKER", {
Expand Down