move function outside of drop component

pull/5370/head
Joseph Izang 7 months ago
parent 639a2080ab
commit cd27326459
  1. 33
      libs/remix-ui/workspace/src/lib/utils/getEventTarget.ts

@ -22,4 +22,35 @@ export const getEventTarget = async (e: any, useLabel: boolean = false) => {
position: endPosition
}
}
}
}
/**
* When multiple files are selected in FileExplorer,
* and these files are dragged to a target folder,
* this function will build the profile of each selected item
* in FileExplorer so they can be moved when dropped
* @param target - Initial target item in FileExplorer
* @returns - {DragStructure} Array of selected items
*/
export const buildMultiSelectedItemProfiles = (target: {
path: string
type: string
content: string
position: {
top: number
left: number
}
}) => {
const selectItems = []
document.querySelectorAll('li.remixui_selected').forEach(item => {
const dragTarget = {
position: { top: target?.position.top || 0, left: target?.position.left || 0 },
path: item.getAttribute('data-path') || item.getAttribute('data-label-path') || '',
type: item.getAttribute('data-type') || item.getAttribute('data-label-type') || '',
content: item.textContent || ''
}
selectItems.push(dragTarget)
})
return selectItems
}

Loading…
Cancel
Save