-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOzuEditorField.php
More file actions
67 lines (51 loc) · 1.45 KB
/
Copy pathOzuEditorField.php
File metadata and controls
67 lines (51 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace Code16\OzuClient\OzuCms\Form;
class OzuEditorField extends OzuField
{
private bool $withoutParagraphs = false;
private bool $hideToolbar = false;
private array $toolbar = [
OzuEditorToolbarEnum::Bold,
OzuEditorToolbarEnum::Italic,
OzuEditorToolbarEnum::Separator,
OzuEditorToolbarEnum::BulletList,
OzuEditorToolbarEnum::Link,
];
private int $height = 200;
private ?int $maxHeight = null;
public function setWithoutParagraphs(): self
{
$this->withoutParagraphs = true;
return $this;
}
public function setToolbar(array $toolbar): self
{
$this->toolbar = $toolbar;
return $this;
}
public function hideToolbar(): self
{
$this->hideToolbar = true;
return $this;
}
public function setHeight(int $height, ?int $maxHeight = null): self
{
$this->height = $height;
$this->maxHeight = $maxHeight;
return $this;
}
public function type(): string
{
return 'editor';
}
public function toArray(): array
{
return array_merge(parent::toArray(), [
'withoutParagraphs' => $this->withoutParagraphs,
'hideToolbar' => $this->hideToolbar,
'toolbar' => collect($this->toolbar)->map(fn ($item) => $item->value)->toArray(),
'height' => $this->height,
'maxHeight' => $this->maxHeight,
]);
}
}