| 645 | } |
| 646 | |
| 647 | drop(item?: DroppableItem): void { |
| 648 | if (!this.currentDropTarget) { |
| 649 | this.cancel(); |
| 650 | return; |
| 651 | } |
| 652 | |
| 653 | if (typeof item?.getDropOperation === 'function') { |
| 654 | let types = getTypes(this.dragTarget.items); |
| 655 | this.dropOperation = item.getDropOperation(types, this.dragTarget.allowedDropOperations); |
| 656 | } else if (typeof this.currentDropTarget.getDropOperation === 'function') { |
| 657 | let types = getTypes(this.dragTarget.items); |
| 658 | this.dropOperation = this.currentDropTarget.getDropOperation( |
| 659 | types, |
| 660 | this.dragTarget.allowedDropOperations |
| 661 | ); |
| 662 | } else { |
| 663 | // TODO: show menu ?? |
| 664 | this.dropOperation = this.dragTarget.allowedDropOperations[0]; |
| 665 | } |
| 666 | |
| 667 | if (typeof this.currentDropTarget.onDrop === 'function') { |
| 668 | let items: DropItem[] = this.dragTarget.items.map(item => ({ |
| 669 | kind: 'text', |
| 670 | types: new Set(Object.keys(item)), |
| 671 | getText: (type: string) => Promise.resolve(item[type]) |
| 672 | })); |
| 673 | |
| 674 | let rect = this.currentDropTarget.element.getBoundingClientRect(); |
| 675 | this.currentDropTarget.onDrop( |
| 676 | { |
| 677 | type: 'drop', |
| 678 | x: rect.left + rect.width / 2, |
| 679 | y: rect.top + rect.height / 2, |
| 680 | items, |
| 681 | dropOperation: this.dropOperation |
| 682 | }, |
| 683 | item?.target ?? null |
| 684 | ); |
| 685 | } |
| 686 | |
| 687 | this.end(); |
| 688 | announce(this.stringFormatter.format('dropComplete')); |
| 689 | } |
| 690 | |
| 691 | activate(dropTarget: DropTarget | null, dropItem: DroppableItem | null | undefined): void { |
| 692 | if (dropTarget && typeof dropTarget.onDropActivate === 'function') { |