3 namespace Drupal\ckeditor\Ajax;
5 use Drupal\Core\Ajax\CommandInterface;
8 * AJAX command to add style sheets to a CKEditor instance.
10 class AddStyleSheetCommand implements CommandInterface {
13 * The CKEditor instance ID.
20 * The style sheet URLs to add to the CKEditor instance.
24 protected $styleSheets = [];
27 * AddStyleSheetCommand constructor.
29 * @param string $editor_id
30 * The CKEditor instance ID.
31 * @param string[] $stylesheets
32 * The style sheet URLs to add to the CKEditor instance.
34 public function __construct($editor_id, array $stylesheets = []) {
35 $this->editorId = $editor_id;
36 $this->styleSheets = $stylesheets;
40 * Adds a style sheet to the CKEditor instance.
42 * @param string $stylesheet
43 * The style sheet URL.
46 * The called object, for chaining.
48 public function addStyleSheet($stylesheet) {
49 $this->styleSheets[] = $stylesheet;
56 public function render() {
58 'command' => 'ckeditor_add_stylesheet',
59 'editor_id' => $this->editorId,
60 'stylesheets' => $this->styleSheets,