Unfortunately, the wiki information on compendium drop handling is not as comprehensive as it is for other aspects of sheet development. It sounds like you have a development version of your sheet that may have some of this, but in order for a sheet to handle drag and drop, it needs an element that is used as the drop target. The wiki shows this drop target inside a repeating section, but that is an out dated method from when compendiums first started and were not as complex. My current preferred method is to wrap the entire sheet in a div that is the compendium drop target:
<div class='compendium-drop-target'>
<!-- your sheet code here -->
</div>
This then turns the entire sheet into a drop point for dragging compendium items.
This is particularly useful for handling drops that affect the entire sheet like NPCs. For drops like NPCs that can be dropped directly to the VTT, you also need to add the category name as a class to the drop-target element so that Roll20 knows where to put the data. This category name class is all lowercase, with special characters like parentheses removed:
<div class='compendium-drop-target npcs'>
<!-- your sheet code here -->
</div>
And then you need attributes to accept the data that you are going to work with. It is possible to do this solely with html by making drop targets for each compendium attribute, but the better way is to make an input to accept the compendium name and the compendium data (compendium name honestly isn't even required):
<div class="compendium-drop-target npcs vehicles">
<input name="attr_drop_name" accept="Name" value="" type="hidden" title="@{drop_name}"/>
<input name="attr_drop_data" accept="data" value="" type="hidden" title="@{drop_data}"/>
<!-- your sheet code here -->
</div>
And then use a sheetworker to parse the json that is put into drop_data and apply it to the sheet as appropriate for the category of data it is.
<div class="compendium-drop-target npcs">
<input name="attr_drop_name" accept="Name" value="" type="hidden" title="@{drop_name}"/>
<input name="attr_drop_data" accept="data" value="" type="hidden" title="@{drop_data}"/>
<!-- your sheet code here -->
</div>
<script type="text/javascript">
on('change:drop_data',(event) => {
// don't do handling if this was changed by api or sheetworker
if(event.sourceType !== 'player') return;
getAttrs(['drop_data'],(attributes) => {
try{
const data = JSON.parse(attributes.drop_data);
if(data.Category === 'NPCs'){
// npc processing
}else if(data.Category === 'other category'){
// other category, conditional handling for each droppable category
}
}catch(err){
// handlig for if the data isn't correct
}
})
})
</script>
Note that I'm showing this as a chain of ifs for doing the data processing, but I would actually recommend functionalizing each category's drop handling rather than putting it all directly in the change handler. This will make it easier to troubleshoot and read your code.