From f4bcbfc960d2bbd5f17e6b09121b3bac41898a56 Mon Sep 17 00:00:00 2001
From: Marcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de>
Date: Fri, 21 Apr 2023 10:15:04 +0000
Subject: [PATCH] Fix several problems of #1899.

Merge request studip/studip!1732
---
 lib/classes/Markup.class.php                  |  2 ++
 .../assets/javascripts/chunks/wysiwyg.js      | 11 ++++++++++
 .../assets/stylesheets/scss/content.scss      | 12 +++++-----
 .../stylesheets/scss/studip-cke-ui.scss       | 12 ++++++++++
 .../assets/stylesheets/scss/typography.scss   |  2 +-
 resources/assets/stylesheets/studip.less      | 22 +++++++++++++++++++
 6 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/lib/classes/Markup.class.php b/lib/classes/Markup.class.php
index f329a92375c..64aa5fe384e 100644
--- a/lib/classes/Markup.class.php
+++ b/lib/classes/Markup.class.php
@@ -342,6 +342,7 @@ class Markup
             'link-extern',
             'link-intern',
             'math-tex',
+            'table',
             'usercode',
             'wiki-link'
         ]);
@@ -358,6 +359,7 @@ class Markup
             'height',
             'color',
             'background-color', // needed by span, td
+            'border-color',
             'border-style',
             'float',
             'border'
diff --git a/resources/assets/javascripts/chunks/wysiwyg.js b/resources/assets/javascripts/chunks/wysiwyg.js
index ade57319305..7d9ccfc472f 100644
--- a/resources/assets/javascripts/chunks/wysiwyg.js
+++ b/resources/assets/javascripts/chunks/wysiwyg.js
@@ -220,10 +220,21 @@ ClassicEditor.defaultConfig = {
         tableProperties: {
             borderColors: customColorPalette,
             backgroundColors: customColorPalette,
+            defaultProperties: {
+                alignment: 'left',
+                borderStyle: 'solid',
+                borderColor: '#666666',
+                borderWidth: '1px',
+            },
         },
         tableCellProperties: {
             borderColors: customColorPalette,
             backgroundColors: customColorPalette,
+            defaultProperties: {
+                borderStyle: 'solid',
+                borderColor: '#666666',
+                borderWidth: '1px',
+            },
         },
     },
     typing: {
diff --git a/resources/assets/stylesheets/scss/content.scss b/resources/assets/stylesheets/scss/content.scss
index aca9cb0a96d..4769434f04d 100644
--- a/resources/assets/stylesheets/scss/content.scss
+++ b/resources/assets/stylesheets/scss/content.scss
@@ -55,18 +55,16 @@
         white-space: pre-wrap;
     }
 
-    figure {
+    figure.table {
         display: table;
         margin: 0.9em auto;
 
-        table {
-            width: 100%;
-            height: 100%;
-            border-collapse: collapse;
-            border-spacing: 0;
+        &:not([style]) {
+            margin-inline-start: 0;
+        }
 
+        table {
             td {
-                border: unset;
                 min-width: 2em;
                 padding: 0.4em;
             }
diff --git a/resources/assets/stylesheets/scss/studip-cke-ui.scss b/resources/assets/stylesheets/scss/studip-cke-ui.scss
index a6cd72b68e9..65a29555276 100644
--- a/resources/assets/stylesheets/scss/studip-cke-ui.scss
+++ b/resources/assets/stylesheets/scss/studip-cke-ui.scss
@@ -260,6 +260,18 @@ a.ck.ck-button.ck-button_with-text.ck-dropdown__button:not(.ck-disabled):hover {
     border: 1px solid var(--dark-gray-color-60);
 }
 
+/* table */
+.ck-content .table {
+    margin: 0.9em auto;
+}
+.ck-content .table {
+    margin: 0.9em auto;
+
+    &:not([style]) {
+        margin-inline-start: 0;
+    }
+}
+
 /* StudipWikiLink plugin */
 .ck.ck-studip-wiki-link-form {
     max-width: 100%;
diff --git a/resources/assets/stylesheets/scss/typography.scss b/resources/assets/stylesheets/scss/typography.scss
index e225c42cd40..0c2295d8842 100644
--- a/resources/assets/stylesheets/scss/typography.scss
+++ b/resources/assets/stylesheets/scss/typography.scss
@@ -69,7 +69,7 @@ h1, h2 {
 
 h1 {
   margin-top: 0;
-  span {
+  span:not([style]) {
     display: block;
     font-size: calc($font-size-h1 * 0.75);
     font-weight: calc($headings-font-weight / 7);
diff --git a/resources/assets/stylesheets/studip.less b/resources/assets/stylesheets/studip.less
index 1cb3da3db77..d0ba0564472 100644
--- a/resources/assets/stylesheets/studip.less
+++ b/resources/assets/stylesheets/studip.less
@@ -45,6 +45,28 @@ table.content {
         border: thin solid #666;
         padding: 3px;
     }
+
+    /* for CKE5 Table Border Colors */
+    &[style*='border-color'] {
+        border-width: thin;
+        border-style: solid;
+    }
+
+    td:first-child {
+        border-inline-start: unset;
+    }
+
+    td:last-child {
+        border-inline-end: unset;
+    }
+
+    tr:first-child td {
+        border-block-start: unset;
+    }
+
+    tr:last-child td {
+        border-block-end: unset;
+    }
 }
 
 
-- 
GitLab