> */ public function addGlobalAttributes() { return [ ['types' => ['paragraph'], 'attributes' => ['data-symbol' => self::attribute('data-symbol')]], ['types' => ['bulletList', 'orderedList'], 'attributes' => [ 'data-marker' => self::attribute('data-marker'), 'data-symbol' => self::attribute('data-symbol'), 'data-tone' => self::attribute('data-tone'), ]], ]; } /** * @return array */ private static function attribute(string $name): array { return [ 'default' => null, 'parseHTML' => fn ($DOMNode) => $DOMNode->getAttribute($name) ?: null, 'renderHTML' => function ($attributes) use ($name) { $value = is_array($attributes) ? ($attributes[$name] ?? null) : ($attributes->{$name} ?? null); return $value === null || $value === '' ? null : [$name => $value]; }, ]; } }