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

feat: コンテキストメニューにアクセント句の削除を追加 #1554

Merged
23 changes: 22 additions & 1 deletion src/components/AudioAccent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@
</svg>
</div>
</template>
<context-menu v-if="props.editable" :menudata="contextMenudata" />
</template>

<script setup lang="ts">
import { computed } from "vue";
import { computed, ref } from "vue";
import ContextMenu from "./ContextMenu.vue";
import { MenuItemButton } from "./MenuBar.vue";
import { previewSliderHelper } from "@/helpers/previewSliderHelper";
import { AccentPhrase } from "@/openapi";

Expand All @@ -70,16 +73,23 @@ const props = withDefaults(
accentPhraseIndex: number;
uiLocked: boolean;
shiftKeyFlag?: boolean;
editable?: boolean;
onChangeAccent: (
accentPhraseIndex: number,
accent: number
) => Promise<void>;
}>(),
{
shiftKeyFlag: false,
editable: false,
}
);

const emit =
defineEmits<{
(e: "delete"): void;
}>();

const changeAccent = (accent: number) =>
props.onChangeAccent(props.accentPhraseIndex, accent);

Expand All @@ -105,6 +115,17 @@ const accentLine = computed(() => {
.toString();
});

const contextMenudata = ref<[MenuItemButton]>([
{
type: "button",
label: "削除",
onClick: async () => {
emit("delete");
},
disableWhenUiLocked: true,
},
]);

// クリックでアクセント句が選択されないように、@click.stopに渡す
const stopPropagation = undefined;
</script>
Expand Down
10 changes: 10 additions & 0 deletions src/components/AudioDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
:ui-locked="uiLocked"
:shift-key-flag="shiftKeyFlag"
:on-change-accent="changeAccent"
:editable="true"
@delete="deleteAccentPhrase(accentPhraseIndex)"
thiramisu marked this conversation as resolved.
Show resolved Hide resolved
/>
</template>
<template v-if="selectedDetail === 'pitch'">
Expand Down Expand Up @@ -450,6 +452,14 @@ const toggleAccentPhraseSplit = (
...(!isPause ? { isPause, moraIndex: moraIndex as number } : { isPause }),
});
};
const deleteAccentPhrase = (phraseIndex: number) => {
store.dispatch("COMMAND_CHANGE_SINGLE_ACCENT_PHRASE", {
audioKey: props.activeAudioKey,
newPronunciation: "",
accentPhraseIndex: phraseIndex,
popUntilPause: false,
});
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
};

const maxPitch = 6.5;
const minPitch = 3;
Expand Down