Skip to content

Commit

Permalink
Fix fields not loading on slideouts
Browse files Browse the repository at this point in the history
  • Loading branch information
ttempleton committed Feb 19, 2024
1 parent 69fa0c7 commit 83e1849
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fixed an error that occurred when creating a TinyMCE field
- Fixed a bug where, if no TinyMCE fields existed on an element editor page, TinyMCE fields would not load on slideout editors

## 2.0.0-alpha.2 - 2024-02-07

Expand Down
12 changes: 8 additions & 4 deletions src/fields/TinyMCE.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function getSettingsHtml(): string
protected function inputHtml(mixed $value, ?ElementInterface $element = null, bool $inline = false): string
{
$view = Craft::$app->getView();
$view->registerAssetBundle(FieldAsset::class);
$fieldAssetBundle = $view->registerAssetBundle(FieldAsset::class);

$id = Html::id($this->handle);
$sitesService = Craft::$app->getSites();
Expand Down Expand Up @@ -221,7 +221,13 @@ protected function inputHtml(mixed $value, ?ElementInterface $element = null, bo
// Load the editor from wherever it should be loaded based on the plugin settings
switch ($pluginSettings->nonNullTinymceSource()) {
case TinyMCESource::Default:
$view->registerAssetBundle(TinyMCEAsset::class);
$tinyAssetBundle = $view->registerAssetBundle(TinyMCEAsset::class);

if (!isset($settings['editorConfig']['base_url'])) {
$settings['editorConfig']['base_url'] = $tinyAssetBundle->baseUrl;
$settings['editorConfig']['suffix'] = '.min';
}

break;
case TinyMCESource::TinyCloud:
$view->registerJsFile("https://cdn.tiny.cloud/1/{$apiKey}/tinymce/6/tinymce.min.js", [
Expand Down Expand Up @@ -255,8 +261,6 @@ protected function inputHtml(mixed $value, ?ElementInterface $element = null, bo
throw new InvalidSourceException('Invalid `tinymceSource` setting set');
}

$fieldAssetBundle = $view->registerAssetBundle(FieldAsset::class);

if (!isset($settings['editorConfig']['skin_url'])) {
$settings['editorConfig']['skin_url'] = $fieldAssetBundle->baseUrl . DIRECTORY_SEPARATOR . 'styles';
}
Expand Down

0 comments on commit 83e1849

Please sign in to comment.