Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

copy-paste: Separate intial_end_tr logic into its own function.

evykassirer96b2e18b0d9e
diff --git a/static/js/copy_and_paste.js b/static/js/copy_and_paste.js
index e6141bda293..291ab2720de 100644
--- a/static/js/copy_and_paste.js
+++ b/static/js/copy_and_paste.js
@@ -232,16 +232,7 @@ export function analyze_selection(selection) {
}
$endc = $(range.endContainer);
- // If the selection ends in the bottom whitespace, we should
- // act as though the selection ends on the final message.
- // This handles the issue that Chrome seems to like selecting
- // the compose_close button when you go off the end of the
- // last message
- if ($endc.attr("id") === "bottom_whitespace" || $endc.attr("id") === "compose_close") {
- $initial_end_tr = $(".message_row").last();
- } else {
- $initial_end_tr = $($endc.parents(".selectable_row")[0]);
- }
+ $initial_end_tr = get_end_tr_from_endc($endc);
end_data = find_boundary_tr($initial_end_tr, ($row) => $row.prev());
if (end_data === undefined) {
@@ -267,6 +258,19 @@ export function analyze_selection(selection) {
};
}
+function get_end_tr_from_endc($endc) {
+ if ($endc.attr("id") === "bottom_whitespace" || $endc.attr("id") === "compose_close") {
+ // If the selection ends in the bottom whitespace, we should
+ // act as though the selection ends on the final message.
+ // This handles the issue that Chrome seems to like selecting
+ // the compose_close button when you go off the end of the
+ // last message
+ return $(".message_row").last();
+ }
+
+ return $($endc.parents(".selectable_row")[0]);
+}
+
export function paste_handler_converter(paste_html) {
const turndownService = new TurndownService();
turndownService.addRule("headings", {