Skip to content

Commit 4a97f27

Browse files
committed
Use enum for editor toolbar
1 parent ba1ae71 commit 4a97f27

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/OzuCms/Form/OzuEditorField.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ class OzuEditorField extends OzuField
77
private bool $withoutParagraphs = false;
88
private bool $hideToolbar = false;
99
private array $toolbar = [
10-
'B', 'I', '|', 'UL', '|', 'A'
10+
OzuEditorToolbarEnum::Bold,
11+
OzuEditorToolbarEnum::Italic,
12+
OzuEditorToolbarEnum::Separator,
13+
OzuEditorToolbarEnum::BulletList,
14+
OzuEditorToolbarEnum::Link,
1115
];
1216
private int $height = 200;
1317
private ?int $maxHeight = null;
@@ -51,7 +55,7 @@ public function toArray(): array
5155
return array_merge(parent::toArray(), [
5256
'withoutParagraphs' => $this->withoutParagraphs,
5357
'hideToolbar' => $this->hideToolbar,
54-
'toolbar' => $this->toolbar,
58+
'toolbar' => collect($this->toolbar)->map(fn($item) => $item->value)->toArray(),
5559
'height' => $this->height,
5660
'maxHeight' => $this->maxHeight,
5761
]);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Code16\OzuClient\OzuCms\Form;
4+
5+
enum OzuEditorToolbarEnum: string
6+
{
7+
case Bold = 'bold';
8+
case Italic = 'italic';
9+
case Link = 'link';
10+
case Separator = '|';
11+
case BulletList = 'bullet-list';
12+
case OrderedList = 'ordered-list';
13+
case Heading1 = 'heading-1';
14+
case Heading2 = 'heading-2';
15+
}

0 commit comments

Comments
 (0)