Subject: [PATCH] test
---
Index: core/modules/ckeditor5/js/ckeditor5.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/modules/ckeditor5/js/ckeditor5.js b/core/modules/ckeditor5/js/ckeditor5.js
--- a/core/modules/ckeditor5/js/ckeditor5.js (revision e08a3d908ec894b1285dd7fe0fb29ca9c9e53d57)
+++ b/core/modules/ckeditor5/js/ckeditor5.js (date 1753765037429)
@@ -324,7 +324,6 @@
const addedCss = [
`${prefix} .ck.ck-content * {display:revert;background:revert;color:initial;padding:revert;}`,
`${prefix} .ck.ck-content li {display:list-item}`,
- `${prefix} .ck.ck-content ol li {list-style-type: decimal}`,
];
const prefixedCss = [...addedCss].join('\n');
@@ -625,6 +624,30 @@
},
};
+ Drupal.behaviors.editorStyleFix = {
+ attach(context) {
+ // CKEditor's DLL injects a style tag that overrides native list
+ // type styling. The following find the style(s) causing the problem
+ // and removes them.
+ // @todo remove this entire behavior when this issue is fixed
+ // https://github.com/ckeditor/ckeditor5/issues/14613
+ [...document.styleSheets]
+ .filter((sheet) => sheet.ownerNode.hasAttribute('data-cke'))
+ .forEach((sheet) => {
+ [...sheet.cssRules].forEach((rule, ruleIndex) => {
+ if (
+ rule?.selectorText &&
+ (rule.selectorText.includes(' ol') ||
+ rule.selectorText.includes(' ul')) &&
+ !rule.selectorText.includes('type')
+ ) {
+ sheet.cssRules[ruleIndex].style['list-style-type'] = null;
+ }
+ });
+ });
+ },
+ };
+
// Redirect on hash change when the original hash has an associated CKEditor 5.
function redirectTextareaFragmentToCKEditor5Instance() {
const hash = window.location.hash.substring(1);
Index: core/modules/ckeditor5/ckeditor5.module
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/modules/ckeditor5/ckeditor5.module b/core/modules/ckeditor5/ckeditor5.module
--- a/core/modules/ckeditor5/ckeditor5.module (revision e08a3d908ec894b1285dd7fe0fb29ca9c9e53d57)
+++ b/core/modules/ckeditor5/ckeditor5.module (date 1753765497935)
@@ -698,5 +698,36 @@
}
$editor->setSettings($settings);
+
+ if ($editor->getEditor() === 'ckeditor5') {
+ $settings = $editor->getSettings();
+ // @see ckeditor5_post_update_list_type()
+ if (array_key_exists('ckeditor5_list', $settings['plugins']) && array_key_exists('ckeditor5_sourceEditing', $settings['plugins'])) {
+ $source_edited = HTMLRestrictions::fromString(implode(' ', $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags']));
+ $format_restrictions = HTMLRestrictions::fromTextFormat($editor->getFilterFormat());
+
+ // If neither
or are allowed through Source Editing
+ // (the only way it could possibly be supported until now), and it is
+ // not an unrestricted text format (such as "Full HTML"), then set the
+ // new "styles" setting for the List plugin to false.
+ $ol_type = HTMLRestrictions::fromString('');
+ $ul_type = HTMLRestrictions::fromString('');
+ if (!array_key_exists('styles', $settings['plugins']['ckeditor5_list']['properties'])) {
+ $settings['plugins']['ckeditor5_list']['properties']['styles'] =
+ $ol_type->diff($source_edited)->allowsNothing() ||
+ $ul_type->diff($source_edited)->allowsNothing() ||
+ $format_restrictions->isUnrestricted();
+ }
+
+ // Update the Source Editing configuration too.
+ $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags'] = $source_edited
+ ->diff($ol_type)
+ ->diff($ul_type)
+ ->toCKEditor5ElementsArray();
+ }
+
+ $editor->setSettings($settings);
+
+ }
}
}
Index: core/modules/ckeditor5/config/schema/ckeditor5.schema.yml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/modules/ckeditor5/config/schema/ckeditor5.schema.yml b/core/modules/ckeditor5/config/schema/ckeditor5.schema.yml
--- a/core/modules/ckeditor5/config/schema/ckeditor5.schema.yml (revision e08a3d908ec894b1285dd7fe0fb29ca9c9e53d57)
+++ b/core/modules/ckeditor5/config/schema/ckeditor5.schema.yml (date 1753764927357)
@@ -150,6 +150,12 @@
label: 'Allow start index'
constraints:
NotNull: []
+ styles:
+ type: boolean
+ # @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ol#type
+ label: 'Allow list style type'
+ constraints:
+ NotNull: []
multiBlock:
type: boolean
label: 'Allow blocks to be created in list items'
Index: core/modules/ckeditor5/ckeditor5.post_update.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/modules/ckeditor5/ckeditor5.post_update.php b/core/modules/ckeditor5/ckeditor5.post_update.php
--- a/core/modules/ckeditor5/ckeditor5.post_update.php (revision e08a3d908ec894b1285dd7fe0fb29ca9c9e53d57)
+++ b/core/modules/ckeditor5/ckeditor5.post_update.php (date 1753765239187)
@@ -142,3 +142,21 @@
&& array_key_exists('ckeditor5_sourceEditing', $settings['plugins']);
});
}
+
+/**
+ * Updates Text Editors using CKEditor 5 to native List "type" functionality.
+ */
+function ckeditor5_post_update_list_type(array &$sandbox = []): void {
+ $config_entity_updater = \Drupal::classResolver(ConfigEntityUpdater::class);
+ $config_entity_updater->update($sandbox, 'editor', function (Editor $editor): bool {
+ // Only try to update editors using CKEditor 5.
+ if ($editor->getEditor() !== 'ckeditor5') {
+ return FALSE;
+ }
+ $settings = $editor->getSettings();
+
+ // @see Ckeditor5Hooks::editorPresave()
+ return array_key_exists('ckeditor5_list', $settings['plugins'])
+ && array_key_exists('ckeditor5_sourceEditing', $settings['plugins']);
+ });
+}
Index: core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/ListPlugin.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/ListPlugin.php b/core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/ListPlugin.php
--- a/core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/ListPlugin.php (revision e08a3d908ec894b1285dd7fe0fb29ca9c9e53d57)
+++ b/core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/ListPlugin.php (date 1753765155492)
@@ -26,7 +26,11 @@
*/
public function defaultConfiguration() {
return [
- 'properties' => ['reversed' => TRUE, 'startIndex' => TRUE],
+ 'properties' => [
+ 'reversed' => TRUE,
+ 'startIndex' => TRUE,
+ 'styles' => TRUE,
+ ],
'multiBlock' => TRUE,
];
}
@@ -50,6 +54,12 @@
'#title' => $this->t('Allow the user to create paragraphs in list items (or other block elements)'),
'#default_value' => $this->configuration['multiBlock'],
];
+ $form['styles'] = [
+ '#type' => 'checkbox',
+ '#title' => $this->t('Allow the user to choose a list style type'),
+ '#description' => $this->t('Available list style types for ordered lists: letters and Roman numerals instead of only numbers. Available list style types for unordered lists: circles and squares instead of only discs.'),
+ '#default_value' => $this->configuration['properties']['styles'],
+ ];
return $form;
}
@@ -62,6 +72,8 @@
$form_state->setValue('reversed', (bool) $form_value);
$form_value = $form_state->getValue('startIndex');
$form_state->setValue('startIndex', (bool) $form_value);
+ $form_value = $form_state->getValue('styles');
+ $form_state->setValue('styles', (bool) $form_value);
$form_value = $form_state->getValue('multiBlock');
$form_state->setValue('multiBlock', (bool) $form_value);
}
@@ -72,6 +84,7 @@
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['properties']['reversed'] = $form_state->getValue('reversed');
$this->configuration['properties']['startIndex'] = $form_state->getValue('startIndex');
+ $this->configuration['properties']['styles'] = $form_state->getValue('styles');
$this->configuration['multiBlock'] = $form_state->getValue('multiBlock');
}
@@ -79,7 +92,13 @@
* {@inheritdoc}
*/
public function getDynamicPluginConfig(array $static_plugin_config, EditorInterface $editor): array {
- $static_plugin_config['list']['properties'] = $this->getConfiguration()['properties'] + $static_plugin_config['list']['properties'];
+ $static_plugin_config['list']['properties'] = $this->getConfiguration()['properties'];
+ // Generate configuration to use `type` attribute-based list styles on
+ // and elements.
+ // @see https://ckeditor.com/docs/ckeditor5/latest/api/module_list_listconfig-ListPropertiesStyleConfig.html#member-useAttribute
+ if ($this->getConfiguration()['properties']['styles']) {
+ $static_plugin_config['list']['properties']['styles'] = ['useAttribute' => TRUE];
+ }
$static_plugin_config['list']['multiBlock'] = $this->getConfiguration()['multiBlock'];
return $static_plugin_config;
}
@@ -89,6 +108,12 @@
*/
public function getElementsSubset(): array {
$subset = $this->getPluginDefinition()->getElements();
+ if (!$this->getConfiguration()['properties']['styles']) {
+ $subset = array_diff($subset, [
+ '',
+ '',
+ ]);
+ }
$subset = array_diff($subset, ['']);
$reversed_enabled = $this->getConfiguration()['properties']['reversed'];
$start_index_enabled = $this->getConfiguration()['properties']['startIndex'];
Index: core/modules/ckeditor5/ckeditor5.ckeditor5.yml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/modules/ckeditor5/ckeditor5.ckeditor5.yml b/core/modules/ckeditor5/ckeditor5.ckeditor5.yml
--- a/core/modules/ckeditor5/ckeditor5.ckeditor5.yml (revision e08a3d908ec894b1285dd7fe0fb29ca9c9e53d57)
+++ b/core/modules/ckeditor5/ckeditor5.ckeditor5.yml (date 1753765228098)
@@ -394,11 +394,8 @@
plugins:
- list.List
- list.ListProperties
- config:
- list:
- properties:
- # @todo Make this configurable in https://www.drupal.org/project/drupal/issues/3274635
- styles: false
+ # @see \Drupal\ckeditor5\Plugin\CKEditor5Plugin\ListPlugin::getDynamicPluginConfig()
+ config: {}
drupal:
label: List
library: core/ckeditor5.list
@@ -414,6 +411,8 @@
-
-
- -
+ -
+ -
ckeditor5_horizontalLine:
ckeditor5: