Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix: dragging text mistakenly as image #2111

Merged
merged 27 commits into from May 14, 2024
Merged

🐛 fix: dragging text mistakenly as image #2111

merged 27 commits into from May 14, 2024

Conversation

sxjeru
Copy link
Contributor

@sxjeru sxjeru commented Apr 20, 2024

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • ⚡️ perf
  • 📝 docs

🔀 变更说明 | Description of Change

原本使用 支持上传图片或文件的模型 时,不论拖入任何元素,还是拖动聊天时的文字,都会出现“上传图片”提示页,导致无法将拖拽的文字插入聊天框。

本修改使得拖拽上传只对本地文件生效。

特别的,当拖拽网页图片时,不会出现“上传图片”提示页。但拖拽到文本框后松开,能正常附上图片。

📝 补充信息 | Additional Information

不知是否需要公开 vercel 部署供验证,本人已测试多种情况,应当无异常。

Copy link

vercel bot commented Apr 20, 2024

@sxjeru is attempting to deploy a commit to the LobeHub Team on Vercel.

A member of the Team first needs to authorize it.

@lobehubbot
Copy link
Member

👍 @sxjeru

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

@arvinxx
Copy link
Contributor

arvinxx commented Apr 20, 2024

CI 挂了,merge 下 main

@lobehub lobehub deleted a comment from lobehubbot Apr 20, 2024
Copy link

codecov bot commented Apr 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.88%. Comparing base (380d8da) to head (cd4bcdb).
Report is 25 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2111   +/-   ##
=======================================
  Coverage   92.88%   92.88%           
=======================================
  Files         302      302           
  Lines       17643    17643           
  Branches     1273     1273           
=======================================
  Hits        16388    16388           
  Misses       1255     1255           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arvinxx
Copy link
Contributor

arvinxx commented Apr 20, 2024

@sxjeru 录个 before 和 after 的视频做个示意吧?

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Hold on.

@sxjeru
Copy link
Contributor Author

sxjeru commented Apr 20, 2024

展开视频
before.mp4
after.mp4

虽然视频中用的是 file:///,但效果与网页图片一样。

另外往里拖本地文件或图片,依旧都会显示“上传图片”的 overlay 提示。

@arvinxx
Copy link
Contributor

arvinxx commented Apr 20, 2024

能做到其他网页拖入的图片,仍然和之前的展示一样不?我觉得为了文字部分能拖动而牺牲图片拖动的展示,感觉不太合适。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Can pictures dragged from other web pages still be displayed the same as before? I don’t think it’s appropriate to sacrifice the dragging of images for the sake of dragging text.

@sxjeru
Copy link
Contributor Author

sxjeru commented Apr 21, 2024

能做到其他网页拖入的图片,仍然和之前的展示一样不?我觉得为了文字部分能拖动而牺牲图片拖动的展示,感觉不太合适。

这可能很难,因为 dragenter 时无法获取拖拽内容的 html,光靠 kind 与 type 不能区分 text 与 image。
并且 dragstart 也在其他页面,就只剩 drop 时访问内容了。

兹认为一般逻辑也是图片拖动到文本框即上传。(例如 Github)
或许可以考虑在拖动时给输入框添加一个背景,提示拖放到此上传。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Can pictures dragged from other web pages still be displayed the same as before? I don’t think it’s appropriate to sacrifice the dragging of images for the sake of dragging text.

This may be difficult because the html of the dragged content cannot be obtained during dragenter, and text and image cannot be distinguished by kind and type alone.
And dragstart is also on other pages, so only the content can be accessed during drop.

@sxjeru
Copy link
Contributor Author

sxjeru commented Apr 21, 2024

能做到其他网页拖入的图片,仍然和之前的展示一样不?我觉得为了文字部分能拖动而牺牲图片拖动的展示,感觉不太合适。

@arvinxx

已实现需求。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Can pictures dragged from other web pages still be displayed the same as before? I don’t think it’s appropriate to sacrifice the dragging of images for the sake of dragging text.

@arvinxx

Requirements realized.

Copy link

vercel bot commented Apr 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lobe-chat-community ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2024 2:43am

@arvinxx
Copy link
Contributor

arvinxx commented Apr 21, 2024

有录屏吗?为啥我试了下好像不行呢

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Is there any screen recording? Why doesn't it seem to work when I try it?

@sxjeru
Copy link
Contributor Author

sxjeru commented Apr 21, 2024

有录屏吗?为啥我试了下好像不行呢

刚刚用上面的 Preview 构建再试了一次(拖拽网页图片),是可以的。
务需选择 支持视觉识别 的模型。

当然拖拽 lobehub 自己页内的头像图片等是无效的,需要其他网页的图片。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Is there any screen recording? Why doesn't it seem to work when I try it?

I just tried it again using the Preview build above (drag and drop web images), and it works.
Be sure to choose a model that supports visual recognition.

@arvinxx
Copy link
Contributor

arvinxx commented Apr 21, 2024

@sxjeru 那我这个操作有问题么?试下来是无效的

Area.mp4

@sxjeru
Copy link
Contributor Author

sxjeru commented Apr 21, 2024

@arvinxx

排查了一会,需要把浮于下方的 Vercel Bar 禁用才行。(Preview 构建特有,Vercel 自带)

image

@sxjeru
Copy link
Contributor Author

sxjeru commented May 4, 2024

目前除 Win & Linux 的 Chromium 系浏览器,其他浏览器行为应当与修改前保持不变。

既然目前确认只有拖拽内容中的 Files 被上传,应当把文字拖拽扩展到所有浏览器。
对于不支持拖拽网页图片的浏览器,行为将是不弹上传提示 overlay,释放则新页面打开图片,类似于上面录的视频。
(Firefox 在输入框释放会嵌入图片 URL)

600655c

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


At present, except for the Chromium browsers on Win & Linux, the behavior of other browsers should remain unchanged as before the modification.

Since it is currently confirmed that only the Files in the dragged content are uploaded, text dragging should be extended to all browsers.
For browsers that do not support drag and drop web images, the behavior will be to not pop up the upload prompt overlay, and release the overlay to open the image on a new page, similar to the video recorded above.
(The image URL may be embedded in the input box)

@arvinxx
Copy link
Contributor

arvinxx commented May 8, 2024

@sxjeru 麻烦 rebase 下,然后我再构建下最后看一眼

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@sxjeru Please rebase, and then I will build it and take a final look.

@sxjeru
Copy link
Contributor Author

sxjeru commented May 8, 2024

@sxjeru 麻烦 rebase 下,然后我再构建下最后看一眼

ok 了,之前的 preview 测试了 win 的 chrome 与 Firefox,行为达成预期,应该可以合并了。
不过因为不需要判断浏览器了,所以 getEngine 方法不再被使用,不知要不要删除。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@sxjeru Please rebase, and then I will build it and take a final look.

OK, the previous preview tested Win's Chrome and Firefox, the behavior is as expected, and it should be possible to merge.
However, since there is no need to judge the browser, the getEngine method is no longer used. I wonder if it should be deleted.

@arvinxx
Copy link
Contributor

arvinxx commented May 9, 2024

所以 getEngine 方法不再被使用,不知要不要删除

删掉吧

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


So the getEngine method is no longer used. I wonder if it should be deleted.

Delete it

@arvinxx arvinxx merged commit 3c047ef into lobehub:main May 14, 2024
6 checks passed
@lobehubbot
Copy link
Member

❤️ Great PR @sxjeru ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.
项目的成长离不开用户反馈和贡献,感谢您的贡献! 如果您对 LobeHub 开发者社区感兴趣,请加入我们的 discord,然后私信 @arvinxx@canisminor1990。他们会邀请您加入我们的私密开发者频道。我们将会讨论关于 Lobe Chat 的开发,分享和讨论全球范围内的 AI 消息。

github-actions bot pushed a commit that referenced this pull request May 14, 2024
### [Version 0.159.2](v0.159.1...v0.159.2)
<sup>Released on **2024-05-14**</sup>

#### 🐛 Bug Fixes

- **misc**: Dragging text mistakenly as image.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's fixed

* **misc**: Dragging text mistakenly as image, closes [#2111](#2111) ([3c047ef](3c047ef))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehubbot
Copy link
Member

🎉 This PR is included in version 0.159.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit to bentwnghk/lobe-chat that referenced this pull request May 14, 2024
## [Version&nbsp;1.39.0](v1.38.1...v1.39.0)
<sup>Released on **2024-05-14**</sup>

#### ♻ Code Refactoring

- **misc**: Move next-auth hooks to user store actions.

#### ✨ Features

- **misc**: Support DeepSeek as new model provider.

#### 🐛 Bug Fixes

- **misc**: Dragging text mistakenly as image, pin `antd@5.17.0` to fix build error.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

* **misc**: Move next-auth hooks to user store actions, closes [lobehub#2364](https://github.com/bentwnghk/lobe-chat/issues/2364) ([6dbcd70](6dbcd70))

#### What's improved

* **misc**: Support DeepSeek as new model provider, closes [lobehub#2446](https://github.com/bentwnghk/lobe-chat/issues/2446) ([18028f3](18028f3))

#### What's fixed

* **misc**: Dragging text mistakenly as image, closes [lobehub#2111](https://github.com/bentwnghk/lobe-chat/issues/2111) ([3c047ef](3c047ef))
* **misc**: Pin `antd@5.17.0` to fix build error, closes [lobehub#2483](https://github.com/bentwnghk/lobe-chat/issues/2483) ([aa03833](aa03833))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
TheNameIsNigel pushed a commit to TheNameIsNigel/lobe-chat that referenced this pull request May 15, 2024
TheNameIsNigel pushed a commit to TheNameIsNigel/lobe-chat that referenced this pull request May 15, 2024
### [Version&nbsp;0.159.2](lobehub/lobe-chat@v0.159.1...v0.159.2)
<sup>Released on **2024-05-14**</sup>

#### 🐛 Bug Fixes

- **misc**: Dragging text mistakenly as image.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's fixed

* **misc**: Dragging text mistakenly as image, closes [lobehub#2111](lobehub#2111) ([3c047ef](lobehub@3c047ef))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
akvsdk pushed a commit to akvsdk/lobe-chat that referenced this pull request May 20, 2024
akvsdk pushed a commit to akvsdk/lobe-chat that referenced this pull request May 20, 2024
### [Version&nbsp;0.159.2](lobehub/lobe-chat@v0.159.1...v0.159.2)
<sup>Released on **2024-05-14**</sup>

#### 🐛 Bug Fixes

- **misc**: Dragging text mistakenly as image.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's fixed

* **misc**: Dragging text mistakenly as image, closes [lobehub#2111](lobehub#2111) ([3c047ef](lobehub@3c047ef))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants