cst1229 @cst1229

@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)

Nov 7, 2021, 4:39 PM
2

comments

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.

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);
};