Skip to content

Commit e291f7d

Browse files
committed
Refactor TabBar to use document manager capability
Replaces the onOpenFile prop in TabBar with direct usage of useDocumentManagerCapability's provides.openFileDialog. Simplifies Application.vue by removing the onOpenFile handler and streamlines file dialog invocation.
1 parent f1c9a92 commit e291f7d

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

examples/vue-vuetify/src/components/Application.vue

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,6 @@ const handleInitialized = async (registry: PluginRegistry) => {
178178
:activeDocumentId="activeDocumentId"
179179
:onSelect="actions.select"
180180
:onClose="actions.close"
181-
:onOpenFile="
182-
() => {
183-
if (!registry) return;
184-
registry
185-
.getPlugin<DocumentManagerPlugin>(DocumentManagerPlugin.id)
186-
?.provides()
187-
?.openFileDialog();
188-
}
189-
"
190181
/>
191182

192183
<v-layout class="fill-height" style="flex: 1">

examples/vue-vuetify/src/components/TabBar.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<script setup lang="ts">
22
import type { DocumentState } from '@embedpdf/core';
3+
import { useDocumentManagerCapability } from '@embedpdf/plugin-document-manager/vue';
34
45
interface TabBarProps {
56
documentStates: DocumentState[];
67
activeDocumentId: string | null;
78
onSelect: (id: string) => void;
89
onClose: (id: string) => void;
9-
onOpenFile: () => void;
1010
}
1111
12+
const { provides } = useDocumentManagerCapability();
13+
1214
const props = defineProps<TabBarProps>();
1315
</script>
1416

@@ -52,7 +54,7 @@ const props = defineProps<TabBarProps>();
5254
size="small"
5355
variant="text"
5456
class="add-tab-btn"
55-
@click="props.onOpenFile"
57+
@click="provides?.openFileDialog()"
5658
aria-label="Open File"
5759
title="Open File"
5860
/>

0 commit comments

Comments
 (0)