Fixed mention suggestion triggering inside invalid containers
authorAlexander Ebert <ebert@woltlab.com>
Sun, 18 Sep 2016 20:13:10 +0000 (22:13 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 18 Sep 2016 20:33:14 +0000 (22:33 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Mention.js

index 05af82cd25d5ecb6a8894fdc1c97f66ebc2a433f..e2103f3e34511af6599f38aaeb12849d8b36d509 100644 (file)
@@ -195,6 +195,16 @@ define(['Ajax', 'Environment', 'Ui/CloseOverlay'], function(Ajax, Environment, U
                                return null;
                        }
                        
+                       // check if we're inside code or quote blocks
+                       var container = selection.anchorNode, editor = this._redactor.core.editor()[0];
+                       while (container && container !== editor) {
+                               if (['PRE', 'WOLTLAB-QUOTE'].indexOf(container.nodeName) !== -1) {
+                                       return null;
+                               }
+                               
+                               container = container.parentNode;
+                       }
+                       
                        var range = selection.getRangeAt(0);
                        var endContainer = range.startContainer;
                        var endOffset = range.startOffset;