diff --git a/panel/src/components/Views/Files/DefaultFilePreview.vue b/panel/src/components/Views/Files/DefaultFilePreview.vue index 60e96a5978..07edd1d382 100644 --- a/panel/src/components/Views/Files/DefaultFilePreview.vue +++ b/panel/src/components/Views/Files/DefaultFilePreview.vue @@ -29,7 +29,7 @@ export default { diff --git a/panel/src/components/Views/Files/index.js b/panel/src/components/Views/Files/index.js index 3de22d430c..7b0151d94e 100644 --- a/panel/src/components/Views/Files/index.js +++ b/panel/src/components/Views/Files/index.js @@ -9,6 +9,7 @@ import FilePreviewFrame from "./FilePreviewFrame.vue"; import DefaultFilePreview from "./DefaultFilePreview.vue"; import AudioFilePreview from "./AudioFilePreview.vue"; import ImageFilePreview from "./ImageFilePreview.vue"; +import PdfFilePreview from "./PdfFilePreview.vue"; import VideoFilePreview from "./VideoFilePreview.vue"; export default { @@ -22,6 +23,7 @@ export default { app.component("k-default-file-preview", DefaultFilePreview); app.component("k-audio-file-preview", AudioFilePreview); app.component("k-image-file-preview", ImageFilePreview); + app.component("k-pdf-file-preview", PdfFilePreview); app.component("k-video-file-preview", VideoFilePreview); } }; diff --git a/src/Cms/Core.php b/src/Cms/Core.php index 10847d4db4..598109beb2 100644 --- a/src/Cms/Core.php +++ b/src/Cms/Core.php @@ -13,6 +13,7 @@ use Kirby\Form\Field\LayoutField; use Kirby\Panel\Ui\FilePreviews\AudioFilePreview; use Kirby\Panel\Ui\FilePreviews\ImageFilePreview; +use Kirby\Panel\Ui\FilePreviews\PdfFilePreview; use Kirby\Panel\Ui\FilePreviews\VideoFilePreview; /** @@ -289,7 +290,8 @@ public function filePreviews(): array return [ AudioFilePreview::class, ImageFilePreview::class, - VideoFilePreview::class + PdfFilePreview::class, + VideoFilePreview::class, ]; } diff --git a/src/Panel/Ui/FilePreviews/PdfFilePreview.php b/src/Panel/Ui/FilePreviews/PdfFilePreview.php new file mode 100644 index 0000000000..5494988f31 --- /dev/null +++ b/src/Panel/Ui/FilePreviews/PdfFilePreview.php @@ -0,0 +1,29 @@ + + * @link https://getkirby.com + * @copyright Bastian Allgeier + * @license https://getkirby.com/license + * @since 5.0.0 + * @internal + */ +class PdfFilePreview extends FilePreview +{ + public function __construct( + public File $file, + public string $component = 'k-pdf-file-preview' + ) { + } + + public static function accepts(File $file): bool + { + return $file->extension() === 'pdf'; + } +}