From c984e62378fbbae9f468ac2bcd87aeb2900aea87 Mon Sep 17 00:00:00 2001 From: Beowulf Date: Sun, 16 Jun 2024 12:45:34 +0000 Subject: [PATCH] Restore old image pasting behavior (#3965) This removes the difference between high density images and other images regarding the pasting. ## Why With this change, all images are clickable by default again. I don't think there is any problem regarding the img size because 1. it is the old behaviour, 2. the comment container already limits the size of the image. ## Alternatives We can add an a-tag automatically when the user pastes an image. I do not prefer this because this adds a really long text (it's already bad with the img-tag) e.g.: `grafik` ## Testing 1. Open an issue or pull request 2. Paste an image in the comment text box 3. The image should be pasted with valid Markdown syntax Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3965 Reviewed-by: twenty-panda Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Beowulf Co-committed-by: Beowulf --- web_src/js/features/comp/Paste.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/web_src/js/features/comp/Paste.js b/web_src/js/features/comp/Paste.js index b26296d1fc..aab6997ad5 100644 --- a/web_src/js/features/comp/Paste.js +++ b/web_src/js/features/comp/Paste.js @@ -1,6 +1,4 @@ -import {htmlEscape} from 'escape-goat'; import {POST} from '../../modules/fetch.js'; -import {imageInfo} from '../../utils/image.js'; import {getPastedContent, replaceTextareaSelection} from '../../utils/dom.js'; import {isUrl} from '../../utils/url.js'; @@ -98,17 +96,9 @@ async function handleClipboardImages(editor, dropzone, images, e) { editor.insertPlaceholder(placeholder); const {uuid} = await uploadFile(img, uploadUrl); - const {width, dppx} = await imageInfo(img); const url = `/attachments/${uuid}`; - let text; - if (width > 0 && dppx > 1) { - // Scale down images from HiDPI monitors. This uses the tag because it's the only - // method to change image size in Markdown that is supported by all implementations. - text = `${htmlEscape(name)}`; - } else { - text = `![${name}](${url})`; - } + const text = `![${name}](${url})`; editor.replacePlaceholder(placeholder, text); const input = document.createElement('input');