Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use current theme styles in TinyMce editor #373

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 '';
}
}
Loading