Disable some editor features for comments
authorCyperghost <olaf_schmitz_1@t-online.de>
Mon, 7 Oct 2024 06:44:39 +0000 (08:44 +0200)
committerCyperghost <olaf_schmitz_1@t-online.de>
Mon, 7 Oct 2024 06:44:39 +0000 (08:44 +0200)
com.woltlab.wcf/templates/commentEditor.tpl
com.woltlab.wcf/templates/commentResponseEditor.tpl
ts/WoltLabSuite/Core/Component/Comment/Add.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Comment/Add.js

index 3584ef3768092b09b64b932dd366b532ddf457a4..cd031b7b15d8ff80427bb3fddc280ce6087df291 100644 (file)
@@ -3,7 +3,7 @@
           data-disable-attachments="true"
           data-support-mention="true"
 >{$comment->message}</textarea>
-{include file='messageFormTabsInline'}
+{include file='messageFormTabsInline' wysiwygContainerID=$wysiwygSelector wysiwygSelector=$wysiwygSelector}
 
 <div class="formSubmit">
        <button type="button" class="button buttonPrimary" data-type="save" accesskey="s">{lang}wcf.global.button.submit{/lang}</button>
        <button type="button" class="button" data-type="cancel">{lang}wcf.global.button.cancel{/lang}</button>
 </div>
 
-{include file='wysiwyg'}
+<script data-relocate="true">
+       require(['WoltLabSuite/Core/Component/Comment/Add'], ({ setCommentEditorFeatures }) => {
+               setCommentEditorFeatures(document.getElementById('{$wysiwygSelector}'));
+       });
+</script>
+
+{include file='wysiwyg' wysiwygSelector=$wysiwygSelector}
index 6ff740e259765be0b790021b96ccf42da58fc77d..732b971e4d44f936950958cef5b5742d3b8815f2 100644 (file)
@@ -3,7 +3,7 @@
           data-disable-attachments="true"
           data-support-mention="true"
 >{$response->message}</textarea>
-{include file='messageFormTabsInline'}
+{include file='messageFormTabsInline' wysiwygContainerID=$wysiwygSelector wysiwygSelector=$wysiwygSelector}
 
 <div class="formSubmit">
        <button type="button" class="button buttonPrimary" data-type="save" accesskey="s">{lang}wcf.global.button.submit{/lang}</button>
        <button type="button" class="button" data-type="cancel">{lang}wcf.global.button.cancel{/lang}</button>
 </div>
 
-{include file='wysiwyg'}
+<script data-relocate="true">
+       require(['WoltLabSuite/Core/Component/Comment/Add'], ({ setCommentEditorFeatures }) => {
+               setCommentEditorFeatures(document.getElementById('{$wysiwygSelector}'));
+       });
+</script>
+
+{include file='wysiwyg' wysiwygSelector=$wysiwygSelector}
index d01fa5f2ec85f33ce9ddc21336dbf5e40d833acf..879ed19aa06a017a4ca98006565daa02dd03decd 100644 (file)
@@ -70,12 +70,7 @@ export class CommentAdd {
       void this.#submit();
     });
 
-    listenToCkeditor(this.#textarea).setupFeatures(({ features }) => {
-      features.heading = false;
-      features.quoteBlock = false;
-      features.spoiler = false;
-      features.table = false;
-    });
+    setCommentEditorFeatures(this.#textarea);
   }
 
   /**
@@ -237,3 +232,12 @@ export class CommentAdd {
     }
   }
 }
+
+export function setCommentEditorFeatures(textarea: HTMLTextAreaElement): void {
+  listenToCkeditor(textarea).setupFeatures(({ features }) => {
+    features.heading = false;
+    features.quoteBlock = false;
+    features.spoiler = false;
+    features.table = false;
+  });
+}
index f2911b78554a3ec3c4c70702c9689d5bd916dd28..5f6867540ebca3eba9581ae86313e85776887968 100644 (file)
@@ -9,7 +9,7 @@
 define(["require", "exports", "tslib", "../../Ajax", "../../Ui/Scroll", "../../Ui/Notification", "../../Language", "../../Event/Handler", "../../Dom/Util", "./GuestDialog", "../../Core", "../Ckeditor", "../Ckeditor/Event"], function (require, exports, tslib_1, Ajax_1, UiScroll, UiNotification, Language_1, EventHandler, Util_1, GuestDialog_1, Core, Ckeditor_1, Event_1) {
     "use strict";
     Object.defineProperty(exports, "__esModule", { value: true });
-    exports.CommentAdd = void 0;
+    exports.setCommentEditorFeatures = exports.CommentAdd = void 0;
     UiScroll = tslib_1.__importStar(UiScroll);
     UiNotification = tslib_1.__importStar(UiNotification);
     EventHandler = tslib_1.__importStar(EventHandler);
@@ -52,12 +52,7 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Ui/Scroll", "../../U
                 event.preventDefault();
                 void this.#submit();
             });
-            (0, Event_1.listenToCkeditor)(this.#textarea).setupFeatures(({ features }) => {
-                features.heading = false;
-                features.quoteBlock = false;
-                features.spoiler = false;
-                features.table = false;
-            });
+            setCommentEditorFeatures(this.#textarea);
         }
         /**
          * Scrolls the editor into view and sets the caret to the end of the editor.
@@ -194,4 +189,13 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Ui/Scroll", "../../U
         }
     }
     exports.CommentAdd = CommentAdd;
+    function setCommentEditorFeatures(textarea) {
+        (0, Event_1.listenToCkeditor)(textarea).setupFeatures(({ features }) => {
+            features.heading = false;
+            features.quoteBlock = false;
+            features.spoiler = false;
+            features.table = false;
+        });
+    }
+    exports.setCommentEditorFeatures = setCommentEditorFeatures;
 });