mirror of
https://github.com/friendica/friendica
synced 2024-11-18 05:43:42 +00:00
attachment preview: fix a bug if inserted text did contain a new line between content and url
This commit is contained in:
parent
ac22c0593d
commit
b0372e5e93
1 changed files with 10 additions and 2 deletions
|
@ -815,12 +815,20 @@
|
||||||
function returnWord(text, caretPos) {
|
function returnWord(text, caretPos) {
|
||||||
var index = text.indexOf(caretPos);
|
var index = text.indexOf(caretPos);
|
||||||
var preText = text.substring(0, caretPos);
|
var preText = text.substring(0, caretPos);
|
||||||
// If the last charachter is a space remove the one space
|
// If the last charachter is a space or enter remove it
|
||||||
// We need this in friendica for the url preview.
|
// We need this in friendica for the url preview.
|
||||||
if (preText.slice(-1) == " ") {
|
var lastChar = preText.slice(-1)
|
||||||
|
if ( lastChar === " "
|
||||||
|
|| lastChar === "\n"
|
||||||
|
|| lastChar === "\r"
|
||||||
|
)
|
||||||
|
{
|
||||||
preText = preText.substring(0, preText.length -1);
|
preText = preText.substring(0, preText.length -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replace new line with space.
|
||||||
|
preText = preText.replace(/\n/g, " ");
|
||||||
|
|
||||||
if (preText.indexOf(" ") > 0) {
|
if (preText.indexOf(" ") > 0) {
|
||||||
var words = preText.split(" ");
|
var words = preText.split(" ");
|
||||||
return words[words.length - 1]; //return last word
|
return words[words.length - 1]; //return last word
|
||||||
|
|
Loading…
Reference in a new issue