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

BPS Git Server git at git.bestpractical.com
Fri Mar 24 17:21:41 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  3722d4db754527608aa9e50abed0b5a7441e912d (commit)

- Log -----------------------------------------------------------------
commit 3722d4db754527608aa9e50abed0b5a7441e912d
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Fri Mar 24 11:31:44 2023 -0300

    Only quote text from transaction areas in the ticket history
    
    Selected text from any place on the Ticket Display page was being quoted
    uncorrectly. Now, only text from the transaction areas is quoted.

diff --git a/share/static/js/quoteselection.js b/share/static/js/quoteselection.js
index ec246790ee..e058e8e6c0 100644
--- a/share/static/js/quoteselection.js
+++ b/share/static/js/quoteselection.js
@@ -3,12 +3,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