From d20baa3ea336345cdc82eabd341d58e71e573838 Mon Sep 17 00:00:00 2001 From: Louis Date: Fri, 24 Jul 2026 11:30:33 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20lokale=20Bildauswahl=20im=20Editor=20er?= =?UTF-8?q?g=C3=A4nzen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- netbox_documentation/__init__.py | 2 +- .../netbox_documentation/document_edit.html | 24 +++++++++++++++++++ pyproject.toml | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/netbox_documentation/__init__.py b/netbox_documentation/__init__.py index 69b6f40..9dcbaae 100644 --- a/netbox_documentation/__init__.py +++ b/netbox_documentation/__init__.py @@ -5,7 +5,7 @@ class DocumentationConfig(PluginConfig): name = "netbox_documentation" verbose_name = "NetBox Dokumentation" description = "Wiki und Office-Dokumentation direkt in NetBox" - version = "0.7.13" + version = "0.7.14" author = "LKE" base_url = "documentation" min_version = "4.0.0" diff --git a/netbox_documentation/templates/netbox_documentation/document_edit.html b/netbox_documentation/templates/netbox_documentation/document_edit.html index c6f7e75..4a8c2e5 100644 --- a/netbox_documentation/templates/netbox_documentation/document_edit.html +++ b/netbox_documentation/templates/netbox_documentation/document_edit.html @@ -101,6 +101,30 @@ paste_convert_word_fake_lists: true, smart_paste: true, images_reuse_filename: true, + file_picker_types: 'image', + file_picker_callback: (callback, value, meta) => { + if (meta.filetype !== 'image') return; + const picker = document.createElement('input'); + picker.type = 'file'; + picker.accept = 'image/png,image/jpeg,image/gif,image/webp'; + picker.addEventListener('change', () => { + const file = picker.files && picker.files[0]; + if (!file) return; + const allowedTypes = ['image/png', 'image/jpeg', 'image/gif', 'image/webp']; + if (!allowedTypes.includes(file.type)) { + window.alert('Unterstützt werden PNG, JPEG, GIF und WebP.'); + return; + } + const reader = new FileReader(); + reader.addEventListener('load', () => callback(reader.result, { + alt: file.name, + title: file.name + })); + reader.addEventListener('error', () => window.alert('Das Bild konnte nicht gelesen werden.')); + reader.readAsDataURL(file); + }, {once: true}); + picker.click(); + }, relative_urls: false, setup: editor => { const selectedTableCells = () => { diff --git a/pyproject.toml b/pyproject.toml index 1b44075..f79ed64 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "netbox-documentation" -version = "0.7.13" +version = "0.7.14" description = "Integrated Markdown wiki and office document importer for NetBox" readme = "README.md" requires-python = ">=3.10"