Add support for font styles
authorAlexander Ebert <ebert@woltlab.com>
Wed, 3 May 2023 18:34:53 +0000 (20:34 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 3 May 2023 18:34:53 +0000 (20:34 +0200)
See WoltLab/editor#34

com.woltlab.wcf/templates/wysiwyg.tpl
ts/WoltLabSuite/Core/Component/Ckeditor/Configuration.ts
wcfsetup/install/files/acp/templates/wysiwyg.tpl
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Configuration.js

index df4ebee570fd4ae2ca81211606e3006a25122df2..3ba7abadb7e56342b95f970799810d21e0d15963 100644 (file)
@@ -31,6 +31,9 @@
                        autosave: element.dataset.autosave || "",
                        code: true,
                        codeBlock: true,
+                       fontColor: {if $__wcf->getBBCodeHandler()->isAvailableBBCode('color')}true{else}false{/if},
+                       fontFamily: {if $__wcf->getBBCodeHandler()->isAvailableBBCode('font')}true{else}false{/if},
+                       fontSize: {if $__wcf->getBBCodeHandler()->isAvailableBBCode('size')}true{else}false{/if},
                        heading: true,
                        html: {if $__wcf->getBBCodeHandler()->isAvailableBBCode('html')}true{else}false{/if},
                        image: {if $__wcf->getBBCodeHandler()->isAvailableBBCode('img')}true{else}false{/if},
index fb5eebc37acc991bf14b5590675b0e7a00e8b133..786b85dfa04883d7c092d339757fbdd09966bdbb 100644 (file)
@@ -64,6 +64,24 @@ class ConfigurationBuilder {
       this.#removePlugins.push("Superscript");
     }
 
+    if (this.#features.fontColor) {
+      items.push("fontColor");
+    } else {
+      this.#removePlugins.push("FontColor");
+    }
+
+    if (this.#features.fontFamily) {
+      items.push("fontFamily");
+    } else {
+      this.#removePlugins.push("FontFamily");
+    }
+
+    if (this.#features.fontSize) {
+      items.push("fontSize");
+    } else {
+      this.#removePlugins.push("FontSize");
+    }
+
     if (this.#features.code) {
       items.push("code");
     } else {
@@ -257,6 +275,23 @@ class ConfigurationBuilder {
       },
       language,
       removePlugins: this.#removePlugins,
+      fontFamily: {
+        options: [
+          "default",
+          "Arial, Helvetica, sans-serif",
+          "Comic Sans MS, Marker Felt, cursive",
+          "Consolas, Courier New, Courier, monospace",
+          "Georgia, serif",
+          "Lucida Sans Unicode, Lucida Grande, sans-serif",
+          "Tahoma, Geneva, sans-serif",
+          "Times New Roman, Times, serif",
+          'Trebuchet MS", Helvetica, sans-serif',
+          "Verdana, Geneva, sans-serif",
+        ],
+      },
+      fontSize: {
+        options: [8, 10, 12, "default", 18, 24, 36],
+      },
       toolbar: this.#getToolbar(),
       woltlabToolbarGroup: this.#toolbarGroups,
     } as any;
@@ -269,6 +304,9 @@ export type Features = {
   autosave: string;
   code: boolean;
   codeBlock: boolean;
+  fontColor: boolean;
+  fontFamily: boolean;
+  fontSize: boolean;
   heading: boolean;
   html: boolean;
   image: boolean;
index df4ebee570fd4ae2ca81211606e3006a25122df2..3ba7abadb7e56342b95f970799810d21e0d15963 100644 (file)
@@ -31,6 +31,9 @@
                        autosave: element.dataset.autosave || "",
                        code: true,
                        codeBlock: true,
+                       fontColor: {if $__wcf->getBBCodeHandler()->isAvailableBBCode('color')}true{else}false{/if},
+                       fontFamily: {if $__wcf->getBBCodeHandler()->isAvailableBBCode('font')}true{else}false{/if},
+                       fontSize: {if $__wcf->getBBCodeHandler()->isAvailableBBCode('size')}true{else}false{/if},
                        heading: true,
                        html: {if $__wcf->getBBCodeHandler()->isAvailableBBCode('html')}true{else}false{/if},
                        image: {if $__wcf->getBBCodeHandler()->isAvailableBBCode('img')}true{else}false{/if},
index bbf535d3602196d131941f818b7e74ff233d6090..2b11a0ee77186c063fd9be56f90725b6da0d4b27 100644 (file)
@@ -56,6 +56,24 @@ define(["require", "exports", "../../Language"], function (require, exports, Lan
             else {
                 this.#removePlugins.push("Superscript");
             }
+            if (this.#features.fontColor) {
+                items.push("fontColor");
+            }
+            else {
+                this.#removePlugins.push("FontColor");
+            }
+            if (this.#features.fontFamily) {
+                items.push("fontFamily");
+            }
+            else {
+                this.#removePlugins.push("FontFamily");
+            }
+            if (this.#features.fontSize) {
+                items.push("fontSize");
+            }
+            else {
+                this.#removePlugins.push("FontSize");
+            }
             if (this.#features.code) {
                 items.push("code");
             }
@@ -223,6 +241,23 @@ define(["require", "exports", "../../Language"], function (require, exports, Lan
                 },
                 language,
                 removePlugins: this.#removePlugins,
+                fontFamily: {
+                    options: [
+                        "default",
+                        "Arial, Helvetica, sans-serif",
+                        "Comic Sans MS, Marker Felt, cursive",
+                        "Consolas, Courier New, Courier, monospace",
+                        "Georgia, serif",
+                        "Lucida Sans Unicode, Lucida Grande, sans-serif",
+                        "Tahoma, Geneva, sans-serif",
+                        "Times New Roman, Times, serif",
+                        'Trebuchet MS", Helvetica, sans-serif',
+                        "Verdana, Geneva, sans-serif",
+                    ],
+                },
+                fontSize: {
+                    options: [8, 10, 12, "default", 18, 24, 36],
+                },
                 toolbar: this.#getToolbar(),
                 woltlabToolbarGroup: this.#toolbarGroups,
             };