From 93aa6832a5841aaed32d84b24eac0e181af93b0d Mon Sep 17 00:00:00 2001
From: Dave Long <dave@longwaveconsulting.com>
Date: Wed, 5 Jul 2023 22:49:41 +0100
Subject: [PATCH] Issue #3324225 by BramDriesen, Wim Leers, Emil Stoianov,
 smustgrave, pmagunia, lauriii, Graber: Support CKEditor 5's table properties
 and cell properties plugins in Full HTML

---
 .../modules/ckeditor5/ckeditor5.ckeditor5.yml | 39 +++++++++++++++++++
 .../modules/ckeditor5/ckeditor5.libraries.yml |  7 ++++
 core/modules/ckeditor5/css/table.css          | 11 ++++++
 3 files changed, 57 insertions(+)
 create mode 100644 core/modules/ckeditor5/css/table.css

diff --git a/core/modules/ckeditor5/ckeditor5.ckeditor5.yml b/core/modules/ckeditor5/ckeditor5.ckeditor5.yml
index 929992e498e2..45c96eaf0da4 100644
--- a/core/modules/ckeditor5/ckeditor5.ckeditor5.yml
+++ b/core/modules/ckeditor5/ckeditor5.ckeditor5.yml
@@ -500,6 +500,45 @@ ckeditor5_table:
       - <tfoot>
       - <caption>
 
+ckeditor5_table_properties:
+  ckeditor5:
+    plugins:
+      - table.TableProperties
+    config:
+      table:
+        contentToolbar: [tableProperties]
+  drupal:
+    label: Table properties
+    library: ckeditor5/internal.drupal.ckeditor5.table
+    conditions:
+      plugins:
+        - ckeditor5_table
+        # When arbitrary HTML is already allowed, it's harmless to enable CKEditor 5's UI for table properties.
+        - ckeditor5_arbitraryHtmlSupport
+    elements:
+      - <table style>
+
+ckeditor5_table_cell_properties:
+  ckeditor5:
+    plugins:
+      - table.TableCellProperties
+    config:
+      table:
+        contentToolbar: [tableCellProperties]
+  drupal:
+    label: Table cell properties
+    library: ckeditor5/internal.drupal.ckeditor5.table
+    conditions:
+      plugins:
+        - ckeditor5_table
+        # When arbitrary HTML is already allowed, it's harmless to enable CKEditor 5's UI for table cell properties.
+        - ckeditor5_arbitraryHtmlSupport
+    elements:
+      - <td style>
+      - <td rowspan colspan style>
+      - <th style>
+      - <th rowspan colspan style>
+
 ckeditor5_image:
   ckeditor5:
     plugins:
diff --git a/core/modules/ckeditor5/ckeditor5.libraries.yml b/core/modules/ckeditor5/ckeditor5.libraries.yml
index c08109e42b17..5d71066f4370 100644
--- a/core/modules/ckeditor5/ckeditor5.libraries.yml
+++ b/core/modules/ckeditor5/ckeditor5.libraries.yml
@@ -100,6 +100,13 @@ internal.drupal.ckeditor5.filter.admin:
     - core/drupal.ajax
     - core/drupalSettings
 
+internal.drupal.ckeditor5.table:
+  css:
+    theme:
+      css/table.css: { }
+  dependencies:
+    - core/ckeditor5.table
+
 internal.admin:
   js:
     js/ckeditor5.admin.js: { }
diff --git a/core/modules/ckeditor5/css/table.css b/core/modules/ckeditor5/css/table.css
new file mode 100644
index 000000000000..47b7e377afd8
--- /dev/null
+++ b/core/modules/ckeditor5/css/table.css
@@ -0,0 +1,11 @@
+/**
+ * Allow users to specify the background color in all themes.
+ *
+ * (Users can set this using CKEditor 5's optional TableProperties and
+ * TableCellProperties plugins.)
+ */
+.ck tr,
+.ck th,
+.ck td {
+  background-color: transparent;
+}
-- 
GitLab