Skip to content
Snippets Groups Projects
Commit a620cedf authored by Ben Mullins's avatar Ben Mullins
Browse files

Issue #3294908 by nod_, Wim Leers, DanielVeza: Configuration overlaps between...

Issue #3294908 by nod_, Wim Leers, DanielVeza: Configuration overlaps between Styles and other CKE5 plugins
parent 38df9b35
No related branches found
No related tags found
24 merge requests!8506Draft: Issue #3456536 by ibrahim tameme,!5646Issue #3350972 by nod_: [random test failure]...,!5600Issue #3350972 by nod_: [random test failure]...,!5343Issue #3305066 by quietone, Rename RedirectLeadingSlashesSubscriber,!4350Issue #3307718: Implement xxHash for non-cryptographic use-cases,!3603#ISSUE 3346218 Add a different message on edit comment,!3555Issue #2473873: Views entity operations lack cacheability support, resulting in incorrect dropbuttons,!3494Issue #3327018 by Spokje, longwave, xjm, mondrake: Update PHPStan to 1.9.3 and...,!3410Issue #3340128: UserLoginForm::submitForm has some dead code,!3389Issue #3325184 by Spokje, andypost, xjm, smustgrave: $this->configFactory is...,!3381Issue #3332363: Refactor Claro's menus-and-lists stylesheet,!3307Issue #3326193: CKEditor 5 can grow past the viewport when there is a lot of content,!3236Issue #3332419: Refactor Claro's messages stylesheet,!3231Draft: Issue #3049525 by longwave, fougere, larowlan, kim.pepper, AaronBauman, Wim...,!3212Issue #3294003: Refactor Claro's entity-meta stylesheet,!3194Issue #3330981: Fix PHPStan L1 error "Relying on entity queries to check access by default is deprecated...",!3143Issue #3313342: [PHP 8.1] Deprecated function: strpos(): Passing null to parameter #1 LayoutBuilderUiCacheContext.php on line 28,!3024Issue #3307509: Empty option for views bulk form,!2972Issue #1845004: Replace custom password hashing library with PHP 5.5 password_hash(),!2719Issue #3110137: Remove Classy from core.,!2688Issue #3261452: [PP-1] Remove tracker module from core,!2437Issue #3238257 by hooroomoo, Wim Leers: Fragment link pointing to <textarea>...,!2296Issue #3100732: Allow specifying `meta` data on JSON:API objects,!1626Issue #3256642: Make life better for database drivers that extend another database driver
......@@ -107,7 +107,24 @@ private static function intersectionWithClasses(HTMLRestrictions $a, HTMLRestric
$tags_from_b = array_diff(array_keys($b->getConcreteSubset()->getAllowedElements()), ['*']);
$a = $a->merge(new HTMLRestrictions(array_fill_keys($tags_from_b, FALSE)));
$b = $b->merge(new HTMLRestrictions(array_fill_keys($tags_from_a, FALSE)));
$intersection = $a->intersect($b);
// When a plugin allows all classes on a tag, we assume there is no
// problem with having the style plugin adding classes to that element.
// When allowing all classes we don't expect a specific user experience
// so adding a class through a plugin or the style plugin is the same.
$b_without_class_wildcard = $b->getAllowedElements();
foreach ($b_without_class_wildcard as $allowedElement => $config) {
// When all classes are allowed, remove the configuration so that
// the intersect below does not include classes.
if (!empty($config['class']) && $config['class'] === TRUE) {
unset($b_without_class_wildcard[$allowedElement]['class']);
}
// HTMLRestrictions does not accept a tag with an empty array, make sure
// to remove them here.
if (empty($b_without_class_wildcard[$allowedElement])) {
unset($b_without_class_wildcard[$allowedElement]);
}
}
$intersection = $a->intersect(new HTMLRestrictions($b_without_class_wildcard));
// Leverage the "GHS configuration" representation to easily find whether
// there is an intersection for classes. Other implementations are possible.
......
......@@ -12,3 +12,15 @@ ckeditor5_plugin_conditions_test_plugins_condition:
- ckeditor5_table
elements:
- <foo>
ckeditor5_plugin_conditions_test_plugin_allow_all_classes_on_kbd:
ckeditor5:
plugins: {}
drupal:
label: TEST — Allow all classes on kbd
toolbar_items:
kbdAllClasses:
label: All classes on kbd (Test Plugins Condition)
elements:
- <kbd>
- <kbd class>
......@@ -14,7 +14,7 @@
use Drupal\Tests\SchemaCheckTestTrait;
use Symfony\Component\Yaml\Yaml;
// cspell:ignore onhover
// cspell:ignore onhover baguette
/**
* @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemConstraintValidator
......@@ -1253,6 +1253,209 @@ public function providerPair(): array {
'settings.plugins.ckeditor5_style' => 'The <em class="placeholder">Style</em> plugin needs another plugin to create <code>&lt;blockquote&gt;</code>, for it to be able to create the following attributes: <code>&lt;blockquote class=&quot;highlighted&quot;&gt;</code>. Enable a plugin that supports creating this tag. If none exists, you can configure the Source Editing plugin to support it.',
],
];
$data['INVALID: Style plugin configured to add class already added by an other plugin'] = [
'settings' => [
'toolbar' => [
'items' => [
'alignment',
'style',
],
],
'plugins' => [
'ckeditor5_alignment' => [
'enabled_alignments' => ['justify'],
],
'ckeditor5_style' => [
'styles' => [
[
'label' => 'Text align',
'element' => '<p class="text-align-justify">',
],
],
],
],
],
'image_upload' => [
'status' => FALSE,
],
'filters' => [
'filter_html' => [
'id' => 'filter_html',
'provider' => 'filter',
'status' => TRUE,
'weight' => 0,
'settings' => [
'allowed_html' => '<p class="text-align-justify"> <br>',
'filter_html_help' => TRUE,
'filter_html_nofollow' => TRUE,
],
],
],
'violations' => [
'settings.plugins.ckeditor5_style.styles.0.element' => 'A style must only specify classes not supported by other plugins. The <code>text-align-justify</code> classes on <code>&lt;p&gt;</code> are already supported by the enabled <em class="placeholder">Alignment</em> plugin.',
],
];
$data['VALID: Style plugin configured to add new class to an already restricted tag'] = [
'settings' => [
'toolbar' => [
'items' => [
'alignment',
'style',
],
],
'plugins' => [
'ckeditor5_alignment' => [
'enabled_alignments' => ['justify'],
],
'ckeditor5_style' => [
'styles' => [
[
'label' => 'Add baguette class',
'element' => '<p class="baguette">',
],
],
],
],
],
'image_upload' => [
'status' => FALSE,
],
'filters' => [
'filter_html' => [
'id' => 'filter_html',
'provider' => 'filter',
'status' => TRUE,
'weight' => 0,
'settings' => [
'allowed_html' => '<p class="text-align-justify baguette"> <br>',
'filter_html_help' => TRUE,
'filter_html_nofollow' => TRUE,
],
],
],
'violations' => [],
];
$data['VALID: Style plugin configured to add class to an element provided by an explicit plugin that already allows all classes'] = [
'settings' => [
'toolbar' => [
'items' => [
'kbdAllClasses',
'style',
],
],
'plugins' => [
'ckeditor5_style' => [
'styles' => [
[
'label' => 'Add baguette class',
'element' => '<kbd class="baguette">',
],
],
],
],
],
'image_upload' => [
'status' => FALSE,
],
'filters' => [
'filter_html' => [
'id' => 'filter_html',
'provider' => 'filter',
'status' => TRUE,
'weight' => 0,
'settings' => [
'allowed_html' => '<p> <br> <kbd class>',
'filter_html_help' => TRUE,
'filter_html_nofollow' => TRUE,
],
],
],
'violations' => [],
];
$data['VALID: Style plugin configured to add class to GHS-supported HTML5 tag'] = [
'settings' => [
'toolbar' => [
'items' => [
'style',
'sourceEditing',
],
],
'plugins' => [
'ckeditor5_sourceEditing' => [
'allowed_tags' => [
'<kbd>',
],
],
'ckeditor5_style' => [
'styles' => [
[
'label' => 'Add baguette class',
'element' => '<kbd class="baguette">',
],
],
],
],
],
'image_upload' => [
'status' => FALSE,
],
'filters' => [
'filter_html' => [
'id' => 'filter_html',
'provider' => 'filter',
'status' => TRUE,
'weight' => 0,
'settings' => [
'allowed_html' => '<p> <br> <kbd class="baguette">',
'filter_html_help' => TRUE,
'filter_html_nofollow' => TRUE,
],
],
],
'violations' => [],
];
$data['VALID: Style plugin configured to add class to GHS-supported HTML5 tag that already allows all classes'] = [
'settings' => [
'toolbar' => [
'items' => [
'style',
'sourceEditing',
],
],
'plugins' => [
'ckeditor5_sourceEditing' => [
'allowed_tags' => [
'<bdi class>',
],
],
'ckeditor5_style' => [
'styles' => [
[
'label' => 'Bidirectional name',
'element' => '<bdi class="name">',
],
],
],
],
],
'image_upload' => [
'status' => FALSE,
],
'filters' => [
'filter_html' => [
'id' => 'filter_html',
'provider' => 'filter',
'status' => TRUE,
'weight' => 0,
'settings' => [
'allowed_html' => '<p> <br> <bdi class>',
'filter_html_help' => TRUE,
'filter_html_nofollow' => TRUE,
],
],
],
'violations' => [],
];
return $data;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment