Repository: go-gitea/gitea
File: web_src/js/features/comp/EditorUpload.ts (TypeScript)

Code before:
      images.push(item.getAsFile());
    }
  }
  return images;
}

export function initEasyMDEPaste(easyMDE: EasyMDE, dropzoneEl: HTMLElement) {
  const editor = new CodeMirrorEditor(easyMDE.codemirror as any);
  easyMDE.codemirror.on('paste', (_, e) => {
    const images = getPastedImages(e);
    if (!images.length) return;
    handleUploadFiles(editor, dropzoneEl, images, e);
  });
  easyMDE.codemirror.on('drop', (_, e) => {
    if (!e.dataTransfer.files.length) return;
    handleUploadFiles(editor, dropzoneEl, e.dataTransfer.files, e);
  });
  dropzoneEl.dropzone.on(DropzoneCustomEventRemovedFile, ({fileUuid}) => {
    const oldText = easyMDE.codemirror.getValue();
    const newText = removeAttachmentLinksFromMarkdown(oldText, fileUuid);
    if (oldText !== newText) easyMDE.codemirror.setValue(newText);
  });
}

export function initTextareaEvents(textarea: HTMLTextAreaElement, dropzoneEl: HTMLElement) {
  subscribe(textarea); // enable paste-related features
  textarea.addEventListener('paste', (e: ClipboardEvent) => {
    const images = getPastedImages(e);
    if (images.length && dropzoneEl) {
      handleUploadFiles(new TextareaEditor(textarea), dropzoneEl, images, e);
    }
  });
  textarea.addEventListener('drop', (e: DragEvent) => {
    if (!e.dataTransfer.files.length) return;
    if (!dropzoneEl) return;
    handleUploadFiles(new TextareaEditor(textarea), dropzoneEl, e.dataTransfer.files, e);
  });
  dropzoneEl?.dropzone.on(DropzoneCustomEventRemovedFile, ({fileUuid}: {fileUuid: string}) => {
    const newText = removeAttachmentLinksFromMarkdown(textarea.value, fileUuid);
    if (textarea.value !== newText) textarea.value = newText;
  });
}


Review comment (suggestion):
```suggestion
  subscribe(textarea); // enable paste features
```

Code after:
      images.push(item.getAsFile());
    }
  }
  return images;
}

export function initEasyMDEPaste(easyMDE: EasyMDE, dropzoneEl: HTMLElement) {
  const editor = new CodeMirrorEditor(easyMDE.codemirror as any);
  easyMDE.codemirror.on('paste', (_, e) => {
    const images = getPastedImages(e);
    if (!images.length) return;
    handleUploadFiles(editor, dropzoneEl, images, e);
  });
  easyMDE.codemirror.on('drop', (_, e) => {
    if (!e.dataTransfer.files.length) return;
    handleUploadFiles(editor, dropzoneEl, e.dataTransfer.files, e);
  });
  dropzoneEl.dropzone.on(DropzoneCustomEventRemovedFile, ({fileUuid}) => {
    const oldText = easyMDE.codemirror.getValue();
    const newText = removeAttachmentLinksFromMarkdown(oldText, fileUuid);
    if (oldText !== newText) easyMDE.codemirror.setValue(newText);
  });
}

export function initTextareaEvents(textarea: HTMLTextAreaElement, dropzoneEl: HTMLElement) {
  subscribe(textarea); // enable paste features
  textarea.addEventListener('paste', (e: ClipboardEvent) => {
    const images = getPastedImages(e);
    if (images.length && dropzoneEl) {
      handleUploadFiles(new TextareaEditor(textarea), dropzoneEl, images, e);
    }
  });
  textarea.addEventListener('drop', (e: DragEvent) => {
    if (!e.dataTransfer.files.length) return;
    if (!dropzoneEl) return;
    handleUploadFiles(new TextareaEditor(textarea), dropzoneEl, e.dataTransfer.files, e);
  });
  dropzoneEl?.dropzone.on(DropzoneCustomEventRemovedFile, ({fileUuid}: {fileUuid: string}) => {
    const newText = removeAttachmentLinksFromMarkdown(textarea.value, fileUuid);
    if (textarea.value !== newText) textarea.value = newText;
  });
}