Skip to content

Commit

Permalink
Use current theme styles in TinyMce editor
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Jan 14, 2025
1 parent c40e135 commit e72ec68
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
--------------------------
- Enh #353: Reduce translation message categories
- Fix #355: Fix visibility of attached images to Template Layout
- Fix #372: Use current theme styles in TinyMce editor

1.10.10 (October 12, 2024)
--------------------------
Expand Down
14 changes: 14 additions & 0 deletions widgets/TinyMce.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,25 @@ private function initDefaults()
'text' => Yii::t('CustomPagesModule.base', 'Panel'),
'tooltip' => Yii::t('CustomPagesModule.base', 'Wrap this HTML page with white panel'),
],
'content_css' => $this->getThemeCssUrl(),
'content_style' => 'body { background: #fff; padding: 0 }',
], $this->clientOptions);

// Fix issue with disabled inputs when it is loaded on modal window
// Fix the editor initialization on second time loading by modal window(without browser page refreshing)
$this->view->registerJs('$(document).on("focusin", "[class^=tox-] input", function(e) {e.stopImmediatePropagation()});
tinymce.remove("#' . $this->options['id'] . '")');
}

protected function getThemeCssUrl(): string
{
$filePath = '/css/theme.css';

if (file_exists(Yii::$app->view->theme->getBasePath() . $filePath)) {
$mtime = filemtime(Yii::$app->view->theme->getBasePath() . $filePath);
return Yii::$app->view->theme->getBaseUrl() . $filePath . '?v=' . $mtime;
}

return '';
}
}

0 comments on commit e72ec68

Please sign in to comment.