mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 05:36:16 +00:00
Improve textarea paste (part of gitea#31948)
When pasting a URL over another URL, replace the URL instead of creating a useless `[url](url)`. (Partially picked from commit 55502265716f000a2c61c98fa093244e1310d97f) Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
parent
6149f0de7c
commit
ebd32d626f
|
@ -116,7 +116,7 @@ function handleClipboardText(textarea, text, e) {
|
||||||
if (_shiftDown) return;
|
if (_shiftDown) return;
|
||||||
const selectedText = value.substring(selectionStart, selectionEnd);
|
const selectedText = value.substring(selectionStart, selectionEnd);
|
||||||
const trimmedText = text.trim();
|
const trimmedText = text.trim();
|
||||||
if (selectedText && isUrl(trimmedText)) {
|
if (selectedText && isUrl(trimmedText) && !isUrl(selectedText)) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
replaceTextareaSelection(textarea, `[${selectedText}](${trimmedText})`);
|
replaceTextareaSelection(textarea, `[${selectedText}](${trimmedText})`);
|
||||||
|
|
Loading…
Reference in a new issue