Disable the image upload when attachments are disabled
authorAlexander Ebert <ebert@woltlab.com>
Thu, 6 Apr 2023 16:32:54 +0000 (18:32 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 6 Apr 2023 16:32:54 +0000 (18:32 +0200)
Fixes WoltLab/editor#27

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 c2a2982a5a11ba1dba8a4bf26777702832b7d0d1..4bc50101ca3bbf513c161cd7b615df5b83f79a4c 100644 (file)
                        throw new Error("Unable to find the source element '{$wysiwygSelector|encodeJS}' for the editor.")
                }
 
+               let enableAttachments = element.dataset.disableAttachments !== "true";
+               {if !$attachmentHandler|empty && !$attachmentHandler->canUpload()}
+               enableAttachments = false;
+               {/if}
+
                const features = {
                        alignment: true,
-                       attachment: element.dataset.disableAttachments !== "true",
+                       attachment: enableAttachments,
                        autosave: element.dataset.autosave || "",
                        code: true,
                        codeBlock: true,
index 8ce6e2ec9d051dd2fcd1dbc4f199f911f2b0ce6d..41c112dbe4fed2fb4248544eaa7593b1e212b946 100644 (file)
@@ -118,6 +118,10 @@ class ConfigurationBuilder {
   #setupImage(): void {
     if (this.#features.image) {
       this.#toolbar.push("insertImage");
+
+      if (!this.#features.attachment) {
+        this.#removePlugins.push("ImageUpload", "ImageUploadUI", "WoltlabAttachment");
+      }
     } else {
       this.#removePlugins.push("ImageInsertUI", "ImageToolbar", "ImageStyle", "ImageUpload", "ImageUploadUI");
 
index c2a2982a5a11ba1dba8a4bf26777702832b7d0d1..4bc50101ca3bbf513c161cd7b615df5b83f79a4c 100644 (file)
                        throw new Error("Unable to find the source element '{$wysiwygSelector|encodeJS}' for the editor.")
                }
 
+               let enableAttachments = element.dataset.disableAttachments !== "true";
+               {if !$attachmentHandler|empty && !$attachmentHandler->canUpload()}
+               enableAttachments = false;
+               {/if}
+
                const features = {
                        alignment: true,
-                       attachment: element.dataset.disableAttachments !== "true",
+                       attachment: enableAttachments,
                        autosave: element.dataset.autosave || "",
                        code: true,
                        codeBlock: true,
index 689eed95cac3b7c106c815a425e3f74ef573fd6f..6bf78ca6393d0ecd2628ca670073fac45b78badf 100644 (file)
@@ -107,6 +107,9 @@ define(["require", "exports", "../../Language"], function (require, exports, Lan
         #setupImage() {
             if (this.#features.image) {
                 this.#toolbar.push("insertImage");
+                if (!this.#features.attachment) {
+                    this.#removePlugins.push("ImageUpload", "ImageUploadUI", "WoltlabAttachment");
+                }
             }
             else {
                 this.#removePlugins.push("ImageInsertUI", "ImageToolbar", "ImageStyle", "ImageUpload", "ImageUploadUI");