From bf90bba792643b8890abe7f895de152b4d30910b Mon Sep 17 00:00:00 2001 From: Thomas Haaf Date: Fri, 14 Jun 2024 15:02:28 +0200 Subject: [PATCH] image drop onto textarea --- client/src/components/ImagePreview.vue | 6 ++++++ client/src/views/PostFormView.vue | 24 +++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/client/src/components/ImagePreview.vue b/client/src/components/ImagePreview.vue index 29df22c..4025aac 100644 --- a/client/src/components/ImagePreview.vue +++ b/client/src/components/ImagePreview.vue @@ -26,6 +26,7 @@ .btn-paste { color: #222; + &:hover { color: #22222255; } @@ -33,6 +34,7 @@ .btn-delete { color: #a00; + &:hover { color: #e00; } @@ -113,6 +115,10 @@ const getMarkdownString = () => { const onDragStart = (event: DragEvent) => { if (props.showPaste) { + const ghostImage = event.target as HTMLImageElement; + const horizPos = ghostImage.width / 2; + const vertPos = ghostImage.height / 2; + event.dataTransfer?.setDragImage(ghostImage, horizPos, vertPos); event.dataTransfer?.setData("text/markdown", getMarkdownString()); } }; diff --git a/client/src/views/PostFormView.vue b/client/src/views/PostFormView.vue index cabfaa7..05413b4 100644 --- a/client/src/views/PostFormView.vue +++ b/client/src/views/PostFormView.vue @@ -45,7 +45,7 @@