Skip to content

A self-hosted media server and file management system

fix: edit lyrics modal does not work in full screen or theatre modes

aminnausin53b20e22cb04
diff --git a/resources/js/components/cedar-ui/modal/GlobalModal.vue b/resources/js/components/cedar-ui/modal/GlobalModal.vue
index af8f7919..f13d41fd 100644
--- a/resources/js/components/cedar-ui/modal/GlobalModal.vue
+++ b/resources/js/components/cedar-ui/modal/GlobalModal.vue
@@ -4,10 +4,12 @@ import { useModalStore } from '@/stores/ModalStore';
import { UseFocusTrap } from '@vueuse/integrations/useFocusTrap/component';
import { cn } from '@aminnausin/cedar-ui';
+const props = withDefaults(defineProps<{ teleportDisabled?: boolean }>(), { teleportDisabled: false });
+
const modalStore = useModalStore();
</script>
<template>
- <Teleport to="body">
+ <Teleport :to="modalStore.props.teleportTarget ?? 'body'" :disabled="teleportDisabled">
<div
v-show="modalStore.isOpen || modalStore.isAnimating"
class="modal fixed top-0 left-0 z-300 flex h-screen w-screen items-center justify-center bg-transparent"
@@ -34,7 +36,10 @@ const modalStore = useModalStore();
leave-from-class="opacity-100 sm:scale-100"
leave-to-class="opacity-0 sm:scale-95"
>
- <UseFocusTrap v-if="modalStore.isOpen" class="scrollbar-hide relative flex h-full max-h-screen w-full items-center overflow-y-scroll px-4 py-10 sm:py-6">
+ <UseFocusTrap
+ v-if="modalStore.isOpen"
+ class="scrollbar-hide pointer-events-auto relative flex h-full max-h-screen w-full items-center overflow-y-scroll px-4 py-10 sm:py-6"
+ >
<OnClickOutside
@trigger="modalStore.close"
@keydown.esc="modalStore.close"
diff --git a/resources/js/components/modals/EditLyricsModal.vue b/resources/js/components/modals/EditLyricsModal.vue
new file mode 100644
index 00000000..fd79585b
--- /dev/null
+++ b/resources/js/components/modals/EditLyricsModal.vue
@@ -0,0 +1,29 @@
+<script setup lang="ts">
+import type { VideoResource } from '@/types/resources';
+
+import { useContentStore } from '@/stores/ContentStore';
+import { useModalStore } from '@/stores/ModalStore';
+import { BaseModal } from '@/components/cedar-ui/modal';
+
+import EditItemHeader from '@/components/headers/EditItemHeader.vue';
+import EditLyrics from '@/components/forms/EditLyrics.vue';
+
+const { updateVideoData } = useContentStore();
+
+const modal = useModalStore();
+
+const handleLyricsUpdated = (data: VideoResource) => {
+ updateVideoData(data);
+ modal.close();
+};
+</script>
+
+<template>
+ <BaseModal>
+ <template #title>{{ modal.props.title ?? 'Edit Song Lyrics' }}</template>
+ <template #description v-if="modal.props.mediaResource.edited_at && modal.props.mediaResource.metadata?.editor_id">
+ <EditItemHeader :edited_at="modal.props.mediaResource.edited_at" :editor_id="modal.props.mediaResource.metadata.editor_id" />
+ </template>
+ <EditLyrics v-if="modal.props.mediaResource" :video="modal.props.mediaResource" @handleFinish="handleLyricsUpdated" />
+ </BaseModal>
+</template>
diff --git a/resources/js/components/video/VideoLyrics.vue b/resources/js/components/video/VideoLyrics.vue
index decf9fb2..0a02f622 100644
--- a/resources/js/components/video/VideoLyrics.vue
+++ b/resources/js/components/video/VideoLyrics.vue
@@ -1,29 +1,25 @@
<script setup lang="ts">
-import type { VideoResource } from '@/types/resources';
import type { LyricItem } from '@/types/types';
import { computed, onMounted, onUnmounted, ref, useTemplateRef, watch, nextTick } from 'vue';
import { toFormattedDuration } from '@/service/util';
import { useContentStore } from '@/stores/ContentStore';
+import { useModalStore } from '@/stores/ModalStore';
import { useLyricStore } from '@/stores/LyricStore';
import { storeToRefs } from 'pinia';
import { ButtonIcon } from '@/components/cedar-ui/button';
-import { ModalBase } from '@/components/cedar-ui/modal';
import { onSeek } from '@/service/player/seekBus';
import VideoLyricItem from '@/components/video/VideoLyricItem.vue';
-import EditLyrics from '@/components/forms/EditLyrics.vue';
let unsubscribe: () => boolean;
-const { stateLyrics, editLyricsModal, dirtyLyric, isLoadingLyrics } = storeToRefs(useLyricStore());
-const { stateVideo } = storeToRefs(useContentStore());
-
+const { stateLyrics, dirtyLyric, isLoadingLyrics } = storeToRefs(useLyricStore());
const { handleGenerateLyrics, handleOpenLyricsModal } = useLyricStore();
-const { updateVideoData } = useContentStore();
+const { stateVideo } = storeToRefs(useContentStore());
const emit = defineEmits<{ seek: [value: number] }>();
-const props = defineProps<{ rawLyrics: string; player: HTMLVideoElement | null; timeDuration: number; isPaused: boolean; isFullscreen: boolean }>();
+const props = defineProps<{ rawLyrics: string; player: HTMLVideoElement | null; timeDuration: number; isPaused: boolean }>();
const lyrics = computed(() => {
const availableLyrics = stateLyrics.value;
@@ -140,14 +136,11 @@ const resetComponent = () => {
nextTick(() => {
lyricsContainer.value?.scrollTo({ top: 0, behavior: 'smooth' });
if (lyrics.value?.[0]?.percentage) activeTime.value = lyrics.value[0].percentage;
+ const modal = useModalStore();
+ modal.close();
});
};
-const handleLyricsUpdated = (data: VideoResource) => {
- editLyricsModal.value.toggleModal(false);
- updateVideoData(data);
-};
-
const handleForceScroll = (seconds: number) => {
const index = findCurrentLyric(lyricItems.value, seconds, false);
if (index < 0) return;
@@ -259,7 +252,7 @@ defineExpose({ scrollToCurrent });
</section>
<div class="pointer-events-auto absolute top-0 right-0 left-0 h-12" style="z-index: 6"></div>
<div class="pointer-events-auto absolute right-0 bottom-0 left-0 h-16" style="z-index: 6"></div>
- <div class="absolute top-4 right-4 flex gap-1" style="z-index: 7" v-show="!isFullscreen">
+ <div class="absolute top-4 right-4 flex gap-1" style="z-index: 7">
<ButtonIcon
variant="ghost"
:class="[
@@ -274,11 +267,6 @@ defineExpose({ scrollToCurrent });
</template>
</ButtonIcon>
</div>
- <ModalBase :modalData="editLyricsModal" :useControls="false">
- <template #content>
- <EditLyrics :video="stateVideo" @handleFinish="handleLyricsUpdated" />
- </template>
- </ModalBase>
</template>
<style lang="css" scoped>
diff --git a/resources/js/components/video/VideoPlayer.vue b/resources/js/components/video/VideoPlayer.vue
index 39a0aa82..2304e5c6 100755
--- a/resources/js/components/video/VideoPlayer.vue
+++ b/resources/js/components/video/VideoPlayer.vue
@@ -13,6 +13,7 @@ import { useContentStore } from '@/stores/ContentStore';
import { debounce, round } from 'lodash-es';
import { useAuthStore } from '@/stores/AuthStore';
import { ContextMenu } from '@/components/cedar-ui/context-menu';
+import { GlobalModal } from '@/components/cedar-ui/modal';
import { useAppStore } from '@/stores/AppStore';
import { storeToRefs } from 'pinia';
import { getMediaUrl } from '@/service/api';
@@ -1189,8 +1190,9 @@ defineExpose({
<div
:class="
cn(
- 'relative overflow-clip rounded-lg',
+ 'relative overflow-clip',
{ 'theatre-mode': isTheatreView },
+ { 'rounded-lg': isNormalView },
{ 'rounded-sm': isFullScreen },
{ 'max-h-[71vh]': isNormalView && !aspectRatio.isAspectVideo },
)
@@ -1548,7 +1550,6 @@ defineExpose({
:raw-lyrics="stateVideo?.metadata?.lyrics ?? ''"
:time-duration="timeDuration"
:is-paused="isPaused"
- :is-fullscreen="isFullScreen"
/>
</div>
</Transition>
@@ -1712,6 +1713,7 @@ defineExpose({
</div>
<div class="pointer-events-none absolute top-0 left-0 h-full w-full" v-show="isFullScreen || isTheatreView">
+ <GlobalModal :teleport-disabled="true" v-if="isFullScreen || isTheatreView" />
<ToastController :teleport-disabled="true" :position="'bottom-left'" />
<ContextMenu
ref="contextMenu"
diff --git a/resources/js/stores/LyricStore.ts b/resources/js/stores/LyricStore.ts
index f0fd5bdf..e7c5bad2 100644
--- a/resources/js/stores/LyricStore.ts
+++ b/resources/js/stores/LyricStore.ts
@@ -5,16 +5,16 @@ import { fetchSyncedLyrics, searchSyncedLyrics } from '@/service/lyricsService';
import { defineStore, storeToRefs } from 'pinia';
import { computed, ref, watch } from 'vue';
import { useContentStore } from '@/stores/ContentStore';
+import { useModalStore } from '@/stores/ModalStore';
import { toast } from '@aminnausin/cedar-ui';
-import useModal from '@/composables/useModal';
+import EditLyricsModal from '@/components/modals/EditLyricsModal.vue';
type SelectedLyric = (LrcLibResult & { source: 'search' | 'generated' }) | null;
export const useLyricStore = defineStore('Lyric', () => {
const { stateVideo } = storeToRefs(useContentStore());
-
- const editLyricsModal = useModal({ title: 'Edit Song Lyrics', submitText: 'Submit Changes' });
+ const modal = useModalStore();
const searchResults = ref<LrcLibResult[]>([]); // Holds search results
const hasSearchedForLyrics = ref<boolean>(false);
@@ -32,13 +32,13 @@ export const useLyricStore = defineStore('Lyric', () => {
const handlePreviewLyrics = (result: LrcLibResult) => {
if (!result.syncedLyrics) return;
handleSelectLyrics(result);
- editLyricsModal.toggleModal(false);
+ modal.close();
};
const handleOpenLyricsModal = async () => {
try {
validateData(stateVideo.value.metadata);
- editLyricsModal.toggleModal(true);
+ modal.open(EditLyricsModal, { mediaResource: stateVideo.value });
} catch (error: unknown) {
if (error instanceof Error) toast.error(error.message);
}
@@ -118,7 +118,6 @@ export const useLyricStore = defineStore('Lyric', () => {
stateLyrics,
searchResults,
isLoadingLyrics,
- editLyricsModal,
hasSearchedForLyrics,
handleSelectLyrics,
handlePreviewLyrics,