@@ -625,29 +625,43 @@ export default {
625
625
dropEvent.preventDefault();
626
626
dropEvent.stopImmediatePropagation();
627
627
628
- const localImageDropped = dropEvent.dataTransfer.files?.[0]?.type.includes('image' );
629
- const imageUrl = dropEvent.dataTransfer.getData('URL' );
628
+ const dataTransferFiles = Array.from( dropEvent.dataTransfer.files);
629
+ const localImageDropped = dataTransferFiles.some((file) => file.type.includes('image') );
630
630
const snapshotId = dropEvent.dataTransfer.getData('openmct/snapshot/id');
631
+ const domainObjectData = dropEvent.dataTransfer.getData('openmct/domain-object-path');
632
+ const imageUrl = dropEvent.dataTransfer.getData('URL');
631
633
if (localImageDropped) {
632
- // local image dropped from disk (file)
633
- const imageData = dropEvent.dataTransfer.files[0];
634
- const imageEmbed = await createNewImageEmbed(imageData, this.openmct, imageData?.name);
635
- this.newEntry(imageEmbed);
634
+ // local image(s) dropped from disk (file)
635
+ const embeds = [];
636
+ await Promise.all(
637
+ dataTransferFiles.map(async (file) => {
638
+ if (file.type.includes('image')) {
639
+ const imageData = file;
640
+ const imageEmbed = await createNewImageEmbed(
641
+ imageData,
642
+ this.openmct,
643
+ imageData?.name
644
+ );
645
+ embeds.push(imageEmbed);
646
+ }
647
+ })
648
+ );
649
+ this.newEntry(embeds);
636
650
} else if (imageUrl) {
637
651
// remote image dropped (URL)
638
652
try {
639
653
const response = await fetch(imageUrl);
640
654
const imageData = await response.blob();
641
655
const imageEmbed = await createNewImageEmbed(imageData, this.openmct);
642
- this.newEntry(imageEmbed);
656
+ this.newEntry([ imageEmbed] );
643
657
} catch (error) {
644
658
this.openmct.notifications.alert(`Unable to add image: ${error.message} `);
645
659
console.error(`Problem embedding remote image`, error);
646
660
}
647
661
} else if (snapshotId.length) {
648
662
// snapshot object
649
663
const snapshot = this.snapshotContainer.getSnapshot(snapshotId);
650
- this.newEntry(snapshot.embedObject);
664
+ this.newEntry([ snapshot.embedObject] );
651
665
this.snapshotContainer.removeSnapshot(snapshotId);
652
666
653
667
const namespace = this.domainObject.identifier.namespace;
@@ -656,10 +670,9 @@ export default {
656
670
namespace
657
671
);
658
672
saveNotebookImageDomainObject(this.openmct, notebookImageDomainObject);
659
- } else {
673
+ } else if (domainObjectData) {
660
674
// plain domain object
661
- const data = dropEvent.dataTransfer.getData('openmct/domain-object-path');
662
- const objectPath = JSON.parse(data);
675
+ const objectPath = JSON.parse(domainObjectData);
663
676
const bounds = this.openmct.time.bounds();
664
677
const snapshotMeta = {
665
678
bounds,
@@ -668,8 +681,15 @@ export default {
668
681
openmct: this.openmct
669
682
};
670
683
const embed = await createNewEmbed(snapshotMeta);
671
-
672
- this.newEntry(embed);
684
+ this.newEntry([embed]);
685
+ } else {
686
+ this.openmct.notifications.error(
687
+ `Unknown object(s) dropped and cannot embed. Try again with an image or domain object.`
688
+ );
689
+ console.warn(
690
+ `Unknown object(s) dropped and cannot embed. Try again with an image or domain object.`
691
+ );
692
+ return;
673
693
}
674
694
},
675
695
focusOnEntryId() {
@@ -838,12 +858,12 @@ export default {
838
858
getSelectedSectionId() {
839
859
return this.selectedSection?.id;
840
860
},
841
- async newEntry(embed , event) {
861
+ async newEntry(embeds , event) {
842
862
this.startTransaction();
843
863
this.resetSearch();
844
864
const notebookStorage = this.createNotebookStorageObject();
845
865
this.updateDefaultNotebook(notebookStorage);
846
- const id = await addNotebookEntry(this.openmct, this.domainObject, notebookStorage, embed );
866
+ const id = await addNotebookEntry(this.openmct, this.domainObject, notebookStorage, embeds );
847
867
848
868
const element = this.$refs.notebookEntries.querySelector(`#${id}`);
849
869
const entryAnnotations = this.notebookAnnotations[id] ?? {};
@@ -861,6 +881,11 @@ export default {
861
881
this.filterAndSortEntries();
862
882
this.focusEntryId = id;
863
883
this.selectedEntryId = id;
884
+
885
+ // put entry into edit mode
886
+ this.$nextTick(() => {
887
+ element.dispatchEvent(new Event('click'));
888
+ });
864
889
},
865
890
orientationChange() {
866
891
this.formatSidebar();
0 commit comments