diff --git a/src/CkEditor.php b/src/CkEditor.php index f433ce7..bbb72b3 100755 --- a/src/CkEditor.php +++ b/src/CkEditor.php @@ -1,57 +1,83 @@ false, - 'linkBrowser' => false, - ]; + public array $snippets = []; /** - * Enable Media Browser + * Enable Media Browser. * @param bool $enabled * @return $this */ - public function mediaBrowser($enabled = true): self + public function mediaBrowser(bool $enabled = true): self { - return $this->withMeta([ - 'mediaBrowser' => $enabled - ]); + $this->mediaBrowser = $enabled; + + return $this; } /** - * Enable Link Browser + * Enable Link Browser. * @param bool $enabled * @return $this */ - public function linkBrowser($enabled = true): self + public function linkBrowser(bool $enabled = true): self { - return $this->withMeta([ - 'linkBrowser' => $enabled - ]); + $this->linkBrowser = $enabled; + + return $this; } /** - * Enable Snippets Browser + * Enable Snippets Browser. * @param array $snippets * @return $this */ public function snippets(array $snippets): self { - return $this->withMeta([ - 'snippetBrowser' => $snippets + $this->snippets = $snippets; + + return $this; + } + + /** + * Prepare the element for JSON serialization. + * @return array + */ + public function jsonSerialize(): array + { + return array_merge(parent::jsonSerialize(), [ + 'mediaBrowser' => $this->mediaBrowser, + 'linkBrowser' => $this->linkBrowser, + 'snippets' => $this->snippets, + 'shouldShow' => $this->shouldBeExpanded(), ]); } }