Skip to content

Commit 4a26040

Browse files
committed
Show images in a modal
1 parent f91084e commit 4a26040

3 files changed

Lines changed: 23 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
# Voyager documentation
22

3-
This plugin for Voyager II allows you to browse the official documentation directly in your admin panel.
4-
5-
## TODO
6-
7-
- Parse alert blocks
8-
- Display images in a lightbox
3+
This plugin for Voyager II allows you to browse the official documentation directly in your admin panel.

dist/voyager-docs.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Docs.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<Card :title="title">
3-
<div class="w-full my-4 flex space-x-1">
3+
<div class="w-full my-4 flex flex-wrap space-x-1 space-y-1">
44
<template v-for="(main, title) in toc">
55
<template v-if="title !== ''">
66
<Dropdown class="self-center" placement="bottom-start">
@@ -28,6 +28,9 @@
2828
</div>
2929
<div id="doc-content" v-html="parseContent(content, true)"></div>
3030
</Card>
31+
<Modal ref="imageModal">
32+
<img :src="selectedImageSource" class="w-full">
33+
</Modal>
3134
</template>
3235

3336
<script>
@@ -103,7 +106,7 @@ export default {
103106
if (!url.startsWith('https://') && !url.startsWith('http://')) {
104107
url = url.replaceAll('../', '').replace('.gitbook/assets/', '');
105108
106-
return `src="${route('voyager.voyager-docs-asset')}?path=${url}" class="mx-auto py-2 w-full lg:w-4/6"`;
109+
return `src="${route('voyager.voyager-docs-asset')}?path=${url}" class="mx-auto py-2 w-full lg:w-4/6 cursor-pointer"`;
107110
}
108111
109112
return `src="${url}"`;
@@ -145,6 +148,22 @@ export default {
145148
getLink(link) {
146149
return `${this.route('voyager.voyager-docs')}?path=${link}`;
147150
}
151+
},
152+
data() {
153+
return {
154+
selectedImageSource: null,
155+
}
156+
},
157+
mounted() {
158+
document.getElementById('doc-content').getElementsByTagName('img').forEach((image) => {
159+
if (image.src.startsWith(`${route('voyager.voyager-docs-asset')}?path=`)) {
160+
image.addEventListener('click', () => {
161+
this.selectedImageSource = image.src;
162+
163+
this.$refs.imageModal.open();
164+
});
165+
}
166+
});
148167
}
149168
}
150169
</script>

0 commit comments

Comments
 (0)