Drag&Drop JSON in a drop zone in UI Dashboard

Hello,

I try to create in my node red dashboard a drop zone where to drop a JSON. Then I want to run my flow from this input.

The code of the template node is the following:

<div id="dropZone"
  style="width: 300px; height: 150px; border: 2px dashed #ccc; line-height: 150px; text-align: center;">
  Drop your text here
</div>

<script>
  const dropZone = document.getElementById('dropZone');

  dropZone.addEventListener('dragover', (e) => {
    e.preventDefault();
    e.stopPropagation();
    dropZone.style.borderColor = 'blue';
  });

  dropZone.addEventListener('dragleave', (e) => {
    e.preventDefault();
    e.stopPropagation();
    dropZone.style.borderColor = '#ccc';
  });

  dropZone.addEventListener('drop', (e) => {
    e.preventDefault();
    e.stopPropagation();
    dropZone.style.borderColor = '#ccc';

    // Retrieve the dropped text
    const text = e.dataTransfer.getData('text/plain');

    if (text) {
      // Send the text to Node-RED flow
      if (typeof scope !== 'undefined' && scope.send) {
        scope.send({ payload: text });
      } else {
        console.log('Dropped text:', text);
      }
    } else {
      alert('No text data dropped');
    }
  });
</script>

and it gives this in the dashboard:

If I drop the JSON text in the "text input" it works well. But nothing from the template node.

Can someone help me?

Thanks

Which input field are you using in the template?
you can use a v-textarea in which you can either type or paste text, or v-file-input which allows you to drag & drop a file

This looks like the user is using the old depreciated dashboard 1. v-xxx components are Dashboard 2.0 only.

@Julien
As for why it doesnt work, scope.send is only accessible when you property wrap your code (see the ui_template built in help)