mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
copy-paste: Separate intial_end_tr logic into its own function.
Creates a new function get_end_tr_from_endc. This will make it easier to add more logic to this function to fix a bug (#22350).
This commit is contained in:
@@ -232,16 +232,7 @@ export function analyze_selection(selection) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$endc = $(range.endContainer);
|
$endc = $(range.endContainer);
|
||||||
// If the selection ends in the bottom whitespace, we should
|
$initial_end_tr = get_end_tr_from_endc($endc);
|
||||||
// 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]);
|
|
||||||
}
|
|
||||||
end_data = find_boundary_tr($initial_end_tr, ($row) => $row.prev());
|
end_data = find_boundary_tr($initial_end_tr, ($row) => $row.prev());
|
||||||
|
|
||||||
if (end_data === undefined) {
|
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) {
|
export function paste_handler_converter(paste_html) {
|
||||||
const turndownService = new TurndownService();
|
const turndownService = new TurndownService();
|
||||||
turndownService.addRule("headings", {
|
turndownService.addRule("headings", {
|
||||||
|
|||||||
Reference in New Issue
Block a user