cst1229 — 11/7/2021, 4:39:39 PM

@jeffalo how did you detect the origin of a pasted image (it only works from cubeupload or imgbb. i thought copied images only include the image data)

♥ 1 ↩ 0 💬 2 comments

comments

jeffalo:

i have no idea.

tiptap does it and its not even intentional. admins have a button for image by url, and i didnt know tiptap would even paste images in, somehow it works.

11/7/2021, 5:11:18 PM
cst1229:

apparently event data transfers have that data. like this code (pasted from stackoverflow):

target.onpaste = (e) => {
  const dT = e.clipboardData || window.clipboardData;
  const html = dT.getData('text/html') || "";
  const parsed = new DOMParser().parseFromString(html, 'text/html');
  const img = parsed.querySelector('img');
  if( !img ) { console.warn('no image here'); return; }
  const url = img.src;
  console.log(url);
};
11/7/2021, 5:20:36 PM