Skip to content

Commit

Permalink
feat: add editor image support (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio authored Apr 19, 2023
1 parent af4a0e4 commit 4b5f402
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/Http/Requests/Admin/SettingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
1 change: 1 addition & 0 deletions app/Models/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected static function defaults(): Collection
'terms_page' => null,
'logo' => null,
'favicon' => null,
'footer' => $translatable,
'html' => [
'header' => null,
'footer' => null,
Expand Down
4 changes: 4 additions & 0 deletions app/View/Components/Site/Footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Footer extends Component
{
public ?string $title;

public ?string $footer;

public Collection $menu;

public ?array $social;
Expand All @@ -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()
Expand Down
16 changes: 16 additions & 0 deletions resources/js/components/Editor/Toolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
9 changes: 9 additions & 0 deletions resources/js/components/Form/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,14 @@
cursor: ew-resize;
cursor: col-resize;
}
img {
max-width: 100%;
height: auto;
&.ProseMirror-selectednode {
outline: 3px solid #68cef8;
}
}
}
</style>
6 changes: 6 additions & 0 deletions resources/js/pages/Settings/Site.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
:accept="['.png', '.gif', '.jpg', '.jpeg']"
:help="$t('field_help.favicon')"
/>

<localized-field
field="form-editor"
:label="$t('field.footer')"
v-model="form.settings.footer"
/>
</panel>

<panel title="Custom HTML">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="container py-12 lg:py-16">
<div class="grid gap-8 xl:grid-cols-3">
<div>
{{-- TODO --}}
{!! $footer !!}
</div>

<nav class="xl:col-span-2">
Expand Down
13 changes: 9 additions & 4 deletions resources/views/components/site/footer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="container py-12 lg:py-16">
<div class="grid gap-8 xl:grid-cols-3">
<div>
{{-- TODO --}}
{!! $footer !!}
</div>

<nav class="xl:col-span-2">
Expand All @@ -18,7 +18,8 @@
<x-dynamic-component
class="text-sm font-semibold tracking-wider text-gray-400 uppercase hover:text-gray-900"
:component="$item->component"
:item="$item" />
:item="$item"
/>

@if ($item->children->count())
<ul class="space-y-4">
Expand All @@ -27,7 +28,8 @@ class="text-sm font-semibold tracking-wider text-gray-400 uppercase hover:text-g
<x-dynamic-component
class="text-gray-500 hover:text-gray-900"
:component="$item->component"
:item="$item" />
:item="$item"
/>
</li>
@endforeach
</ul>
Expand All @@ -39,7 +41,10 @@ class="text-gray-500 hover:text-gray-900"
</div>

<div class="pt-8 mt-8 border-t border-gray-200 md:flex md:items-center md:justify-between">
<x-social-media-links :links="$social" class="text-gray-400 md:order-2" />
<x-social-media-links
:links="$social"
class="text-gray-400 md:order-2"
/>

<p class="mt-8 text-base text-gray-400 md:mt-0 md:order-1">
&copy; {{ date('Y') }} {{ $title }}.
Expand Down

0 comments on commit 4b5f402

Please sign in to comment.