aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DragManager.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-04-21 13:48:58 -0400
committerbobzel <zzzman@gmail.com>2025-04-21 13:48:58 -0400
commit17e24e780b54f2f7015c0ca955c3aa5091bba19c (patch)
treeb13002c92d58cb52a02b46e4e1d578f1d57125f2 /src/client/util/DragManager.ts
parent22a40443193320487c27ce02bd3f134d13cb7d65 (diff)
parent1f294ef4a171eec72a069a9503629eaf7975d983 (diff)
merged with master and cleaned up outpainting a bit.
Diffstat (limited to 'src/client/util/DragManager.ts')
-rw-r--r--src/client/util/DragManager.ts45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index 2a7859f09..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))
@@ -280,11 +278,12 @@ export namespace DragManager {
export function StartButtonDrag(eles: HTMLElement[], script: string, title: string, vars: { [name: string]: FieldType }, params: string[], initialize: (button: Doc) => void, downX: number, downY: number, options?: DragOptions) {
const finishDrag = (e: DragCompleteEvent) => {
const bd = Docs.Create.ButtonDocument({ toolTip: title, z: 1, _width: 150, _height: 50, title, onClick: ScriptField.MakeScript(script) });
+ const bdData = bd[DocData];
params.forEach(p => {
- Object.keys(vars).indexOf(p) !== -1 && (bd[DocData][p] = new PrefetchProxy(vars[p] as Doc));
+ Object.keys(vars).indexOf(p) !== -1 && (bdData[p] = new PrefetchProxy(vars[p] as Doc));
}); // copy all "captured" arguments into document parameterfields
initialize?.(bd);
- bd[DocData]['onClick-paramFieldKeys'] = new List<string>(params);
+ bd.$onClick_paramFieldKeys = new List<string>(params);
e.docDragData && (e.docDragData.droppedDocuments = [bd]);
return e;
};
@@ -363,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,
@@ -379,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?.();
@@ -565,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]);