Loading core/modules/ckeditor5/ckeditor5.api.php +10 −1 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ * library: MODULE_NAME/ckeditor5.marquee * elements: * - <marquee> * - <marquee behavior> * @endcode * * Declared as an Annotation: Loading @@ -82,7 +83,7 @@ * * drupal = @DrupalAspectsOfCKEditor5Plugin( * * label = @Translation("Marquee"), * * library = "MODULE_NAME/ckeditor5.marquee" * * elements = { "<marquee>" }, * * elements = { "<marquee>", "<marquee behavior>" }, * * ) * * ) * * / Loading Loading @@ -125,6 +126,14 @@ * explicitly enabled in any plugin. i.e. if only '<p>', '<h3>' and '<h2>' * tags are allowed, then '<$text-container data-something>' will allow the * 'data-something' attribute for '<p>', '<h3>' and '<h2>' tags. * Note that while the syntax is the same, some extra nuance is needed: * although this syntax can be used to create an attribute on an element, f.e. * (['<marquee behavior>']) creating the `behavior` attribute on `<marquee>`, * the tag itself must be creatable as well (['<marquee>']). If a plugin wants * the tag and attribute to be created, list both: * (['<marquee>', '<marquee behavior>']). Validation logic ensures that a * plugin supporting only the creation of attributes cannot be enabled if the * tag cannot be created via itself or through another CKEditor 5 plugin. * - drupal.toolbar_items: List of toolbar items the plugin provides. Keyed by a * machine name and the value being a pair defining the label: * @code Loading core/modules/ckeditor5/ckeditor5.ckeditor5.yml +7 −0 Original line number Diff line number Diff line Loading @@ -247,6 +247,7 @@ ckeditor5_codeBlock: label: Code Block elements: - <pre> - <code> - <code class="language-*"> ckeditor5_strikethrough: Loading Loading @@ -314,6 +315,7 @@ ckeditor5_link: link: label: Link elements: - <a> - <a href> ckeditor5_linkImage: Loading Loading @@ -374,6 +376,7 @@ ckeditor5_list: label: Numbered list elements: - <ul> - <ol> - <ol reversed start> - <li> Loading Loading @@ -457,7 +460,9 @@ ckeditor5_table: elements: - <table> - <tr> - <td> - <td rowspan colspan> - <th> - <th rowspan colspan> - <thead> - <tbody> Loading @@ -477,6 +482,7 @@ ckeditor5_image: label: Image library: ckeditor5/drupal.ckeditor5.image elements: - <img> - <img src alt data-entity-uuid data-entity-type height width> conditions: toolbarItem: uploadImage Loading Loading @@ -601,6 +607,7 @@ media_media: library: ckeditor5/drupal.ckeditor5.media class: Drupal\ckeditor5\Plugin\CKEditor5Plugin\Media elements: - <drupal-media> - <drupal-media data-entity-type data-entity-uuid alt data-view-mode> conditions: filter: media_embed Loading core/modules/ckeditor5/src/Annotation/DrupalAspectsOfCKEditor5Plugin.php +13 −0 Original line number Diff line number Diff line Loading @@ -75,7 +75,20 @@ class DrupalAspectsOfCKEditor5Plugin extends Plugin { * - <element data-*> only allows that HTML element with any attribute that * has the given prefix. * * Note that <element> means such an element (tag) can be created, whereas * <element attrA attrB> means that `attrA` and `attrB` can be created on the * tag. If a plugin supports both creating the element as well as setting some * attributes or attribute values on it, it should have distinct entries in * the list. * For example, for a link plugin: `<a>` and `<a href>`. The first indicates * the plugin can create such tags, the second indicates it can set the `href` * attribute on it. If the first were omitted, the Drupal CKEditor 5 module * would interpret that as "this plugin cannot create `<a>`, it can only set * the `href` attribute on it". * * @var string[]|false * * @see \Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition::getCreatableElements() */ public $elements; Loading core/modules/ckeditor5/src/HTMLRestrictions.php +27 −0 Original line number Diff line number Diff line Loading @@ -887,6 +887,33 @@ public function getConcreteSubset(): HTMLRestrictions { }, ARRAY_FILTER_USE_KEY)); } /** * Gets the subset of plain tags (no attributes) from allowed elements. * * @return \Drupal\ckeditor5\HTMLRestrictions * The subset of the given set of HTML restrictions. */ public function getPlainTagsSubset(): HTMLRestrictions { // This implicitly excludes wildcard tags and the global attribute `*` tag // because they always have attributes specified. return new self(array_filter($this->elements, function ($value) { return $value === FALSE; })); } /** * Extracts the subset of plain tags (attributes omitted) from allowed elements. * * @return \Drupal\ckeditor5\HTMLRestrictions * The extracted subset of the given set of HTML restrictions. */ public function extractPlainTagsSubset(): HTMLRestrictions { // Ignore the global attribute `*` HTML tag: that is by definition not a // plain tag. $plain_tags = array_diff(array_keys($this->getConcreteSubset()->getAllowedElements()), ['*']); return new self(array_fill_keys($plain_tags, FALSE)); } /** * Checks whether given tag is a wildcard. * Loading core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Media.php +2 −1 Original line number Diff line number Diff line Loading @@ -200,7 +200,8 @@ public function getElementsSubset(): array { if (!$view_mode_override_enabled) { $subset = $subset->diff(HTMLRestrictions::fromString('<drupal-media data-view-mode>')); } return $subset->toCKEditor5ElementsArray(); // @todo Simplify in https://www.drupal.org/project/drupal/issues/3278636, that will allow removing all uses of HTMLRestrictions in this class. return array_merge(['<drupal-media>'], $subset->toCKEditor5ElementsArray()); } /** Loading Loading
core/modules/ckeditor5/ckeditor5.api.php +10 −1 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ * library: MODULE_NAME/ckeditor5.marquee * elements: * - <marquee> * - <marquee behavior> * @endcode * * Declared as an Annotation: Loading @@ -82,7 +83,7 @@ * * drupal = @DrupalAspectsOfCKEditor5Plugin( * * label = @Translation("Marquee"), * * library = "MODULE_NAME/ckeditor5.marquee" * * elements = { "<marquee>" }, * * elements = { "<marquee>", "<marquee behavior>" }, * * ) * * ) * * / Loading Loading @@ -125,6 +126,14 @@ * explicitly enabled in any plugin. i.e. if only '<p>', '<h3>' and '<h2>' * tags are allowed, then '<$text-container data-something>' will allow the * 'data-something' attribute for '<p>', '<h3>' and '<h2>' tags. * Note that while the syntax is the same, some extra nuance is needed: * although this syntax can be used to create an attribute on an element, f.e. * (['<marquee behavior>']) creating the `behavior` attribute on `<marquee>`, * the tag itself must be creatable as well (['<marquee>']). If a plugin wants * the tag and attribute to be created, list both: * (['<marquee>', '<marquee behavior>']). Validation logic ensures that a * plugin supporting only the creation of attributes cannot be enabled if the * tag cannot be created via itself or through another CKEditor 5 plugin. * - drupal.toolbar_items: List of toolbar items the plugin provides. Keyed by a * machine name and the value being a pair defining the label: * @code Loading
core/modules/ckeditor5/ckeditor5.ckeditor5.yml +7 −0 Original line number Diff line number Diff line Loading @@ -247,6 +247,7 @@ ckeditor5_codeBlock: label: Code Block elements: - <pre> - <code> - <code class="language-*"> ckeditor5_strikethrough: Loading Loading @@ -314,6 +315,7 @@ ckeditor5_link: link: label: Link elements: - <a> - <a href> ckeditor5_linkImage: Loading Loading @@ -374,6 +376,7 @@ ckeditor5_list: label: Numbered list elements: - <ul> - <ol> - <ol reversed start> - <li> Loading Loading @@ -457,7 +460,9 @@ ckeditor5_table: elements: - <table> - <tr> - <td> - <td rowspan colspan> - <th> - <th rowspan colspan> - <thead> - <tbody> Loading @@ -477,6 +482,7 @@ ckeditor5_image: label: Image library: ckeditor5/drupal.ckeditor5.image elements: - <img> - <img src alt data-entity-uuid data-entity-type height width> conditions: toolbarItem: uploadImage Loading Loading @@ -601,6 +607,7 @@ media_media: library: ckeditor5/drupal.ckeditor5.media class: Drupal\ckeditor5\Plugin\CKEditor5Plugin\Media elements: - <drupal-media> - <drupal-media data-entity-type data-entity-uuid alt data-view-mode> conditions: filter: media_embed Loading
core/modules/ckeditor5/src/Annotation/DrupalAspectsOfCKEditor5Plugin.php +13 −0 Original line number Diff line number Diff line Loading @@ -75,7 +75,20 @@ class DrupalAspectsOfCKEditor5Plugin extends Plugin { * - <element data-*> only allows that HTML element with any attribute that * has the given prefix. * * Note that <element> means such an element (tag) can be created, whereas * <element attrA attrB> means that `attrA` and `attrB` can be created on the * tag. If a plugin supports both creating the element as well as setting some * attributes or attribute values on it, it should have distinct entries in * the list. * For example, for a link plugin: `<a>` and `<a href>`. The first indicates * the plugin can create such tags, the second indicates it can set the `href` * attribute on it. If the first were omitted, the Drupal CKEditor 5 module * would interpret that as "this plugin cannot create `<a>`, it can only set * the `href` attribute on it". * * @var string[]|false * * @see \Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition::getCreatableElements() */ public $elements; Loading
core/modules/ckeditor5/src/HTMLRestrictions.php +27 −0 Original line number Diff line number Diff line Loading @@ -887,6 +887,33 @@ public function getConcreteSubset(): HTMLRestrictions { }, ARRAY_FILTER_USE_KEY)); } /** * Gets the subset of plain tags (no attributes) from allowed elements. * * @return \Drupal\ckeditor5\HTMLRestrictions * The subset of the given set of HTML restrictions. */ public function getPlainTagsSubset(): HTMLRestrictions { // This implicitly excludes wildcard tags and the global attribute `*` tag // because they always have attributes specified. return new self(array_filter($this->elements, function ($value) { return $value === FALSE; })); } /** * Extracts the subset of plain tags (attributes omitted) from allowed elements. * * @return \Drupal\ckeditor5\HTMLRestrictions * The extracted subset of the given set of HTML restrictions. */ public function extractPlainTagsSubset(): HTMLRestrictions { // Ignore the global attribute `*` HTML tag: that is by definition not a // plain tag. $plain_tags = array_diff(array_keys($this->getConcreteSubset()->getAllowedElements()), ['*']); return new self(array_fill_keys($plain_tags, FALSE)); } /** * Checks whether given tag is a wildcard. * Loading
core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Media.php +2 −1 Original line number Diff line number Diff line Loading @@ -200,7 +200,8 @@ public function getElementsSubset(): array { if (!$view_mode_override_enabled) { $subset = $subset->diff(HTMLRestrictions::fromString('<drupal-media data-view-mode>')); } return $subset->toCKEditor5ElementsArray(); // @todo Simplify in https://www.drupal.org/project/drupal/issues/3278636, that will allow removing all uses of HTMLRestrictions in this class. return array_merge(['<drupal-media>'], $subset->toCKEditor5ElementsArray()); } /** Loading