aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DragManager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/util/DragManager.ts')
-rw-r--r--src/client/util/DragManager.ts40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index e2e4c0fe4..a66e6998b 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -234,29 +234,27 @@ export namespace DragManager {
dropDoc instanceof Doc && CreateLinkToActiveAudio(() => dropDoc);
return dropDoc;
};
- const finishDrag = async (e: DragCompleteEvent) => {
+ const finishDrag = (e: DragCompleteEvent) => {
const { docDragData } = e;
setTimeout(() => dragData.dragEnding?.());
onDropCompleted?.(e); // glr: optional additional function to be called - in this case with presentation trails
if (docDragData && !docDragData.droppedDocuments.length) {
docDragData.dropAction = dragData.userDropAction || dragData.dropAction;
- docDragData.droppedDocuments = (
- await Promise.all(
- dragData.draggedDocuments.map(async d =>
- !dragData.isDocDecorationMove && !dragData.userDropAction && ScriptCast(d.onDragStart)
- ? addAudioTag(ScriptCast(d.onDragStart).script.run({ this: d }).result as Doc)
- : docDragData.dropAction === dropActionType.embed
- ? Doc.BestEmbedding(d)
- : docDragData.dropAction === dropActionType.add
- ? d
- : docDragData.dropAction === dropActionType.proto
- ? d[DocData]
- : docDragData.dropAction === dropActionType.copy
- ? (await Doc.MakeClone(d)).clone
- : d
- )
+ docDragData.droppedDocuments = dragData.draggedDocuments
+ .map(d =>
+ !dragData.isDocDecorationMove && !dragData.userDropAction && ScriptCast(d.onDragStart)
+ ? addAudioTag(ScriptCast(d.onDragStart)!.script.run({ this: d }).result as Doc)
+ : docDragData.dropAction === dropActionType.embed
+ ? Doc.BestEmbedding(d)
+ : docDragData.dropAction === dropActionType.add
+ ? d
+ : docDragData.dropAction === dropActionType.proto
+ ? d[DocData]
+ : docDragData.dropAction === dropActionType.copy
+ ? Doc.MakeClone(d).clone
+ : d
)
- ).filter(d => d);
+ .filter(d => d);
![dropActionType.same, dropActionType.proto].includes(StrCast(docDragData.dropAction) as dropActionType) &&
docDragData.droppedDocuments
// .filter(drop => !drop.dragOnlyWithinContainer || ['embed', 'copy'].includes(docDragData.dropAction as any))
@@ -364,7 +362,7 @@ export namespace DragManager {
};
}
- async function dispatchDrag(target: Element, e: PointerEvent, complete: DragCompleteEvent, pos: { x: number; y: number }, finishDrag?: (e: DragCompleteEvent) => void, options?: DragOptions, endDrag?: () => void) {
+ function dispatchDrag(target: Element, e: PointerEvent, complete: DragCompleteEvent, pos: { x: number; y: number }, finishDrag?: (e: DragCompleteEvent) => void, options?: DragOptions, endDrag?: () => void) {
const dropArgs = {
cancelable: true, // allows preventDefault() to be called to cancel the drop
bubbles: true,
@@ -380,7 +378,7 @@ export namespace DragManager {
};
target.dispatchEvent(new CustomEvent<DropEvent>('dashPreDrop', dropArgs));
UndoManager.StartTempBatch(); // run drag/drop in temp batch in case drop is not allowed (so we can undo any intermediate changes)
- await finishDrag?.(complete);
+ finishDrag?.(complete);
UndoManager.EndTempBatch(target.dispatchEvent(new CustomEvent<DropEvent>('dashOnDrop', dropArgs))); // event return val is true unless the event preventDefault() is called
options?.dragComplete?.(complete);
endDrag?.();
@@ -566,11 +564,11 @@ export namespace DragManager {
const targClassName = e.target instanceof HTMLElement && typeof e.target.className === 'string' ? e.target.className : '';
if (['lm_tab', 'lm_title_wrap', 'lm_tabs', 'lm_header'].includes(targClassName) && docDragData.draggedDocuments.length === 1) {
if (!startWindowDragTimer) {
- startWindowDragTimer = setTimeout(async () => {
+ startWindowDragTimer = setTimeout(() => {
startWindowDragTimer = undefined;
docDragData.dropAction = docDragData.userDropAction || dropActionType.same;
AbortDrag();
- await finishDrag?.(new DragCompleteEvent(true, docDragData));
+ finishDrag?.(new DragCompleteEvent(true, docDragData));
DragManager.StartWindowDrag?.(e, docDragData.droppedDocuments, aborted => {
if (!aborted && (docDragData?.dropAction === dropActionType.move || docDragData?.dropAction === dropActionType.same)) {
docDragData.removeDocument?.(docDragData?.draggedDocuments[0]);