Skip to content

Commit

Permalink
Merge pull request #97 from AQuadic/2.x
Browse files Browse the repository at this point in the history
allow using external plugins
  • Loading branch information
mohamedsabil83 committed Sep 20, 2023
2 parents e3ec3c5 + dd93df3 commit 6460118
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
1 change: 1 addition & 0 deletions resources/views/tiny-editor.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class="relative z-0"
min_height: {{ $getMinHeight() }},
menubar: {{ $getShowMenuBar() ? 'true' : 'false' }},
plugins: ['{{ $getPlugins() }}'],
external_plugins: @js($getExternalPlugins()),
toolbar: '{{ $getToolbar() }}',
toolbar_mode: 'sliding',
relative_urls: {{ $getRelativeUrls() ? 'true' : 'false' }},
Expand Down
33 changes: 23 additions & 10 deletions src/Components/TinyEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class TinyEditor extends Field implements Contracts\CanBeLengthConstrained, Cont

protected int $minHeight = 0;

protected string $plugins;
// TinyMCE var: external_plugins
protected array $externalPlugins;

protected string $profile = 'default';

Expand Down Expand Up @@ -74,7 +75,7 @@ public function getMinHeight(): int

public function getFileAttachmentsDirectory(): ?string
{
return filled($directory = $this->evaluate($this->fileAttachmentsDirectory)) ? $directory : config('filament-forms-tinyeditor.profiles.'.$this->profile.'.upload_directory');
return filled($directory = $this->evaluate($this->fileAttachmentsDirectory)) ? $directory : config('filament-forms-tinyeditor.profiles.' . $this->profile . '.upload_directory');
}

public function getInterfaceLanguage(): string
Expand Down Expand Up @@ -205,13 +206,25 @@ public function getPlugins(): string
return 'autoresize directionality emoticons link wordcount';
}

if (config('filament-forms-tinyeditor.profiles.'.$this->profile.'.plugins')) {
return config('filament-forms-tinyeditor.profiles.'.$this->profile.'.plugins');
if (config('filament-forms-tinyeditor.profiles.' . $this->profile . '.plugins')) {
return config('filament-forms-tinyeditor.profiles.' . $this->profile . '.plugins');
}

return 'advlist codesample directionality emoticons fullscreen hr image imagetools link lists media table toc wordcount';
}

public function getExternalPlugins(): array
{
return $this->externalPlugins ?? [];
}

public function setExternalPlugins(array $plugins): static
{
$this->externalPlugins = $plugins;

return $this;
}

public function getShowMenuBar(): bool
{
return $this->showMenuBar;
Expand All @@ -223,8 +236,8 @@ public function getToolbar(): string
return 'removeformat | bold italic | rtl ltr | link emoticons';
}

if (config('filament-forms-tinyeditor.profiles.'.$this->profile.'.toolbar')) {
return config('filament-forms-tinyeditor.profiles.'.$this->profile.'.toolbar');
if (config('filament-forms-tinyeditor.profiles.' . $this->profile . '.toolbar')) {
return config('filament-forms-tinyeditor.profiles.' . $this->profile . '.toolbar');
}

return 'undo redo removeformat | formatselect fontsizeselect | bold italic | rtl ltr | alignjustify alignright aligncenter alignleft | numlist bullist | forecolor backcolor | blockquote table toc hr | image link media codesample emoticons | wordcount fullscreen';
Expand All @@ -246,7 +259,7 @@ public function minHeight(int $minHeight): static

public function isSimple(): bool
{
return (bool) $this->evaluate($this->isSimple);
return (bool)$this->evaluate($this->isSimple);
}

public function language(string $language): static
Expand Down Expand Up @@ -326,13 +339,13 @@ public function getTemplate(): string
return json_encode([]);
}

return json_encode(config('filament-forms-tinyeditor.templates.'.$this->template, []));
return json_encode(config('filament-forms-tinyeditor.templates.' . $this->template, []));
}

public function getCustomConfigs(): string
{
if (config('filament-forms-tinyeditor.profiles.'.$this->profile.'.custom_configs')) {
return '...'.json_encode(config('filament-forms-tinyeditor.profiles.'.$this->profile.'.custom_configs'));
if (config('filament-forms-tinyeditor.profiles.' . $this->profile . '.custom_configs')) {
return '...' . json_encode(config('filament-forms-tinyeditor.profiles.' . $this->profile . '.custom_configs'));
}

return '';
Expand Down

0 comments on commit 6460118

Please sign in to comment.