12 public function execute(
bool $undo =
true): bool
14 $block =
new Block((
int)$this->params[
'block']);
15 $selector = $this->params[
'selector'];
16 $position = $this->params[
'position'];
17 $isWrapper = $this->params[
'isWrapper'];
18 $value = $undo ? $this->params[
'valueBefore'] : $this->params[
'valueAfter'];
22 if ($position >= 0 && !$isWrapper)
24 $selector = $selector .
'@' . $position;
28 'classList' => explode(
' ', $value[
'className']),
29 'style' => $value[
'style'],
30 'affect' => $this->params[
'affect'],
34 return $block->setClasses($data) && $block->save();
47 $getValue =
static function($content) {
48 $doc =
new DOM\Document();
49 $doc->loadHTML($content);
50 $children = $doc->getChildNodesArray();
51 $node = array_pop($children);
55 'className' => $node->getClassName() ?:
'',
56 'style' => DOM\StyleInliner::getStyle($node,
true),
57 'styleString' => $node->getAttribute(
'style') ?:
'',
63 'block' => $block->getId(),
64 'selector' =>
$params[
'selector'] ?:
'',
65 'isWrapper' =>
$params[
'isWrapper'] ??
false,
66 'position' =>
$params[
'position'] ?? -1,
67 'affect' =>
$params[
'affect'] ?: [],
68 'lid' => $block->getLandingId(),
69 'valueBefore' => $getValue(
$params[
'contentBefore']),
70 'valueAfter' => $getValue(
$params[
'contentAfter']),
79 && $this->params[
'valueBefore'] !== $this->params[
'valueAfter'];
88 $params = parent::getJsCommand($undo);
92 ?
$params[
'params'][
'valueBefore']
93 :
$params[
'params'][
'valueAfter'];
94 $params[
'params'][
'value'][
'style'] =
$params[
'params'][
'value'][
'styleString'];
97 $params[
'params'][
'valueAfter'],
98 $params[
'params'][
'valueBefore'],
99 $params[
'params'][
'value'][
'styleString'],
111 public static function compareParams(array $oldParams, array $newParams): bool
113 unset($oldParams[
'valueBefore'], $newParams[
'valueBefore']);
115 return $oldParams === $newParams;
static enrichParams(array $params)
getJsCommand(bool $undo=true)
static compareParams(array $oldParams, array $newParams)