mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: Improve selecting text over line breaks
This commit is contained in:
@ -102,14 +102,18 @@ export function selectedText() {
|
||||
}
|
||||
}
|
||||
|
||||
html = html.replace(/<br>/g, "\n");
|
||||
|
||||
// Strip out any .click elements from the HTML before converting it to text
|
||||
var div = document.createElement('div');
|
||||
const div = document.createElement('div');
|
||||
div.innerHTML = html;
|
||||
var $div = $(div);
|
||||
|
||||
const $div = $(div);
|
||||
|
||||
// Find all emojis and replace with its title attribute.
|
||||
$div.find('img.emoji').replaceWith(function() { return this.title; });
|
||||
$div.find('img.emoji').replaceWith(() => this.title);
|
||||
$('.clicks', $div).remove();
|
||||
var text = div.textContent || div.innerText || "";
|
||||
const text = div.textContent || div.innerText || "";
|
||||
|
||||
return String(text).trim();
|
||||
}
|
||||
|
Reference in New Issue
Block a user