From 4b5f402db33025ed8070490d45611d32247e27f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Wed, 19 Apr 2023 10:40:14 +0100 Subject: [PATCH] feat: add editor image support (#319) --- app/Http/Requests/Admin/SettingRequest.php | 1 + app/Models/Setting.php | 1 + app/View/Components/Site/Footer.php | 4 ++++ resources/js/components/Editor/Toolbar.vue | 16 ++++++++++++++++ resources/js/components/Form/Editor.vue | 9 +++++++++ resources/js/pages/Settings/Site.vue | 6 ++++++ .../components/site/footer-government.blade.php | 2 +- resources/views/components/site/footer.blade.php | 13 +++++++++---- 8 files changed, 47 insertions(+), 5 deletions(-) diff --git a/app/Http/Requests/Admin/SettingRequest.php b/app/Http/Requests/Admin/SettingRequest.php index e7e05e59..7eb2d89d 100644 --- a/app/Http/Requests/Admin/SettingRequest.php +++ b/app/Http/Requests/Admin/SettingRequest.php @@ -38,6 +38,7 @@ public function rules(): array 'settings.front_page' => ['required', 'exists:pages,id'], 'settings.privacy_page' => ['required', 'exists:pages,id'], 'settings.terms_page' => ['required', 'exists:pages,id'], + 'settings.footer' => ['array'], 'settings.html' => ['array'], 'settings.html.header' => ['nullable', 'string'], 'settings.html.footer' => ['nullable', 'string'], diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 6e27bd80..8fc4238d 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -39,6 +39,7 @@ protected static function defaults(): Collection 'terms_page' => null, 'logo' => null, 'favicon' => null, + 'footer' => $translatable, 'html' => [ 'header' => null, 'footer' => null, diff --git a/app/View/Components/Site/Footer.php b/app/View/Components/Site/Footer.php index 22c3b7a5..578cdc0f 100644 --- a/app/View/Components/Site/Footer.php +++ b/app/View/Components/Site/Footer.php @@ -14,6 +14,8 @@ class Footer extends Component { public ?string $title; + public ?string $footer; + public Collection $menu; public ?array $social; @@ -27,6 +29,8 @@ public function __construct() { $this->title = localized_settings('site.title'); + $this->footer = localized_settings('site.footer'); + $this->menu = MenuItem::query() ->location('footer') ->get() diff --git a/resources/js/components/Editor/Toolbar.vue b/resources/js/components/Editor/Toolbar.vue index 219bd607..360b7638 100644 --- a/resources/js/components/Editor/Toolbar.vue +++ b/resources/js/components/Editor/Toolbar.vue @@ -256,6 +256,22 @@ isActive: () => props.editor.isActive('paragraph'), }, ], + [ + { + icon: 'Media/image-fill', + action: () => { + const url = window.prompt('URL'); + + if (url) { + props.editor + .chain() + .focus() + .setImage({ src: url }) + .run(); + } + }, + }, + ], [ { icon: 'Editor/table-2', diff --git a/resources/js/components/Form/Editor.vue b/resources/js/components/Form/Editor.vue index 54de4a14..fe6b5291 100644 --- a/resources/js/components/Form/Editor.vue +++ b/resources/js/components/Form/Editor.vue @@ -155,5 +155,14 @@ cursor: ew-resize; cursor: col-resize; } + + img { + max-width: 100%; + height: auto; + + &.ProseMirror-selectednode { + outline: 3px solid #68cef8; + } + } } diff --git a/resources/js/pages/Settings/Site.vue b/resources/js/pages/Settings/Site.vue index a29b3db6..31c08919 100644 --- a/resources/js/pages/Settings/Site.vue +++ b/resources/js/pages/Settings/Site.vue @@ -80,6 +80,12 @@ :accept="['.png', '.gif', '.jpg', '.jpeg']" :help="$t('field_help.favicon')" /> + + diff --git a/resources/views/components/site/footer-government.blade.php b/resources/views/components/site/footer-government.blade.php index b4ef0377..8303b141 100644 --- a/resources/views/components/site/footer-government.blade.php +++ b/resources/views/components/site/footer-government.blade.php @@ -2,7 +2,7 @@
- {{-- TODO --}} + {!! $footer !!}