Introduce SettingsController for managing editor settings

[MAILPOET-5637]
This commit is contained in:
Rostislav Wolny
2023-10-13 13:10:10 +02:00
committed by Aschepikov
parent 3e3e081dbf
commit 399ed61503
7 changed files with 95 additions and 13 deletions

View File

@@ -0,0 +1,49 @@
<?php declare(strict_types = 1);
namespace MailPoet\EmailEditor\Engine;
class SettingsController {
const ALLOWED_BLOCK_TYPES = [
'core/paragraph',
'core/heading',
'core/column',
'core/columns',
'core/image',
];
const DEFAULT_SETTINGS = [
'enableCustomSpacing' => true,
'enableCustomLineHeight' => true,
'disableCustomFontSizes' => false,
'enableCustomUnits' => ['px', '%'],
'__experimentalFeatures' => [
'color' => [
'custom' => true,
'text' => true,
'background' => true,
'customGradient' => false,
'defaultPalette' => true,
'palette' => [
'default' => [],
],
],
],
];
/** @var StylesController */
private $stylesController;
public function __construct(
StylesController $stylesController
) {
$this->stylesController = $stylesController;
}
public function getSettings(): array {
$settings = self::DEFAULT_SETTINGS;
$settings['allowedBlockTypes'] = self::ALLOWED_BLOCK_TYPES;
$settings['defaultEditorStyles'] = [[ 'css' => $this->stylesController->getEmailContentStyles() ]];
return $settings;
}
}