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.ts31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index 4f30e92ce..8d8975763 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -4,7 +4,7 @@ import { Doc, Field, Opt, StrListCast } from '../../fields/Doc';
import { List } from '../../fields/List';
import { PrefetchProxy } from '../../fields/Proxy';
import { ScriptField } from '../../fields/ScriptField';
-import { BoolCast, ScriptCast, StrCast } from '../../fields/Types';
+import { ScriptCast, StrCast } from '../../fields/Types';
import { emptyFunction, Utils } from '../../Utils';
import { Docs, DocUtils } from '../documents/Documents';
import * as globalCssVariables from '../views/global/globalCssVariables.scss';
@@ -191,13 +191,6 @@ export namespace DragManager {
// drag a document and drop it (or make an embed/copy on drop)
export function StartDocumentDrag(eles: HTMLElement[], dragData: DocumentDragData, downX: number, downY: number, options?: DragOptions, onDropCompleted?: (e?: DragCompleteEvent) => any) {
- dragData.draggedViews.forEach(
- action(view => {
- const ffview = view.props.CollectionFreeFormDocumentView?.().props.CollectionFreeFormView;
- ffview && (ffview.GroupChildDrag = BoolCast(ffview.Document._isGroup));
- ffview?.setupDragLines(false);
- })
- );
const addAudioTag = (dropDoc: any) => {
dropDoc && !dropDoc.author_date && (dropDoc.author_date = new DateField());
dropDoc instanceof Doc && DocUtils.MakeLinkToActiveAudio(() => dropDoc);
@@ -205,14 +198,7 @@ export namespace DragManager {
};
const finishDrag = async (e: DragCompleteEvent) => {
const docDragData = e.docDragData;
- setTimeout(() =>
- dragData.draggedViews.forEach(
- action(view => {
- const ffview = view.props.CollectionFreeFormDocumentView?.().props.CollectionFreeFormView;
- ffview && (ffview.GroupChildDrag = false);
- })
- )
- );
+ setTimeout(() => dragData.draggedViews.forEach(view => view.props.CollectionFreeFormDocumentView?.().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;
@@ -248,6 +234,7 @@ export namespace DragManager {
};
dragData.draggedDocuments.map(d => d.dragFactory); // does this help? trying to make sure the dragFactory Doc is loaded
StartDrag(eles, dragData, downX, downY, options, finishDrag);
+ dragData.draggedViews.forEach(view => view.props.CollectionFreeFormDocumentView?.().dragStarting());
return true;
}
@@ -281,9 +268,6 @@ export namespace DragManager {
StartDrag(ele, dragData, downX, downY, options, undefined, 'Drag Column');
}
- export function SetSnapLines(horizLines: number[], vertLines: number[]) {
- SnappingManager.setSnapLines(horizLines, vertLines);
- }
export function snapDragAspect(dragPt: number[], snapAspect: number) {
let closest = Utils.SNAP_THRESHOLD;
let near = dragPt;
@@ -345,7 +329,7 @@ export namespace DragManager {
DocDragData = dragData as DocumentDragData;
const batch = UndoManager.StartBatch(dragUndoName ?? 'document drag');
eles = eles.filter(e => e);
- CanEmbed = dragData.canEmbed || false;
+ SnappingManager.SetCanEmbed(dragData.canEmbed || false);
if (!dragDiv) {
dragDiv = document.createElement('div');
dragDiv.className = 'dragManager-dragDiv';
@@ -471,7 +455,7 @@ export namespace DragManager {
runInAction(() => docsBeingDragged.push(...docsToDrag));
const hideDragShowOriginalElements = (hide: boolean) => {
- dragLabel.style.display = hide && !CanEmbed ? '' : 'none';
+ dragLabel.style.display = hide && !SnappingManager.GetCanEmbed() ? '' : 'none';
!hide && dragElements.map(dragElement => dragElement.parentNode === dragDiv && dragDiv.removeChild(dragElement));
setTimeout(() => eles.forEach(ele => (ele.hidden = hide)));
};
@@ -491,13 +475,14 @@ export namespace DragManager {
};
const cleanupDrag = action((undo: boolean) => {
+ (dragData as DocumentDragData).draggedViews?.forEach(view => view.props.CollectionFreeFormDocumentView?.().dragEnding());
hideDragShowOriginalElements(false);
document.removeEventListener('pointermove', moveHandler, true);
document.removeEventListener('pointerup', upHandler, true);
SnappingManager.SetIsDragging(false);
- SnappingManager.clearSnapLines();
if (batch.end() && undo) UndoManager.Undo();
docsBeingDragged.length = 0;
+ SnappingManager.SetCanEmbed(false);
});
var startWindowDragTimer: any;
const moveHandler = (e: PointerEvent) => {
@@ -604,7 +589,7 @@ export namespace DragManager {
altKey: e.altKey,
metaKey: e.metaKey,
ctrlKey: e.ctrlKey,
- embedKey: CanEmbed,
+ embedKey: SnappingManager.GetCanEmbed(),
},
};
target.dispatchEvent(new CustomEvent<DropEvent>('dashPreDrop', dropArgs));