Forgot password?
 Create new account
View 154|Reply 3

粘贴上传图片

[Copy link]

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2022-7-15 02:48:06 |Read mode
Last edited by hbghlyj at 2023-5-2 10:43:00CodePen – HTML5 paste image to page


在文本框粘贴上传图片,例如MyBB从v. 1.8.22开始支持图片粘贴上传.
例如phpBB插件(GitHub)
例如Discuz插件(Discuz disgusts me)
例如GitHub的讨论区的编辑框.
例如SnipNote, textbox.io, Google Docs


(mybb)
(phpbb)
(Comparison of Internet forum software)

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2022-8-28 03:31:25
pasteboard.co/
Super simple and lightning fast image sharing. Upload clipboard images with Copy & Paste and image files with Drag & Drop.

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2022-9-3 06:44:13
Interact with the clipboard
Clipboard.read()
  1. const destinationImage = document.querySelector('#destination')
  2. destinationImage.addEventListener('click', pasteImage);
  3. async function pasteImage() {
  4.   try {
  5.     const permission = await navigator.permissions.query({ name: 'clipboard-read' });
  6.     if (permission.state === 'denied') {
  7.       throw new Error('Not allowed to read clipboard.');
  8.     }
  9.     const clipboardContents = await navigator.clipboard.read();
  10.     for (const item of clipboardContents) {
  11.       if (!item.types.includes('image/png')) {
  12.         throw new Error('Clipboard contains non-image data.');
  13.       }
  14.       const blob = await item.getType('image/png');
  15.       destinationImage.src = URL.createObjectURL(blob);
  16.     }
  17.   }
  18.   catch (error) {
  19.     console.error(error.message);
  20.   }
  21. }
Copy the Code

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2023-5-2 17:26:16
DiscuzX issue

popcorner
member
an hour ago

此功能计划在未来的新版编辑器中提供。
当前版本的编辑器没有添加这种功能的计划,但应用中心有支持此功能的第三方插件。可以在应用中心的论坛试用此效果。

手机版Mobile version|Leisure Math Forum

2025-4-20 22:09 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list