[Rt-commit] rt branch 5.0/refine-selected-text-quoting-transaction-area created. rt-5.0.3-221-g58642d85f0

BPS Git Server git at git.bestpractical.com
Mon Jan 23 15:08:58 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/refine-selected-text-quoting-transaction-area has been created
        at  58642d85f09d648291f691d24d79c9d628d6d14b (commit)

- Log -----------------------------------------------------------------
commit 58642d85f09d648291f691d24d79c9d628d6d14b
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Mon Jan 23 12:08:08 2023 -0300

    Only quote text from transaction areas in the ticket history

diff --git a/share/static/js/quoteselection.js b/share/static/js/quoteselection.js
index 6d1fdf1e7c..48e01a7557 100644
--- a/share/static/js/quoteselection.js
+++ b/share/static/js/quoteselection.js
@@ -4,12 +4,35 @@ jQuery(function() {
             var link = jQuery(this);
 
             var selection;
-            if (window.getSelection)
+            var activeElement;
+            if (window.getSelection) {
                 selection = window.getSelection();
-            else if (document.getSelection)
-                selection = document.getSelection();
-            else if (document.selection)
-                selection = document.selection.createRange().text;
+            } else {
+                return;
+            }
+
+            if (selection.rangeCount) {
+                activeElement = selection.getRangeAt(0);
+            } else {
+                return;
+            }
+
+            // check if selection has commonAncestorContainer with class 'messagebody'
+            var commonAncestor = activeElement.commonAncestorContainer;
+            if (commonAncestor) {
+                var isMessageBody = false;
+                var parent = commonAncestor.parentNode;
+                while (parent) {
+                    if (parent.className && parent.className.indexOf('messagebody') != -1) {
+                        isMessageBody = true;
+                        break;
+                    }
+                    parent = parent.parentNode;
+                }
+                if (!isMessageBody) {
+                    return;
+                }
+            }
 
             if (selection.toString)
                 selection = selection.toString();

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list