diff options
author | bobzel <zzzman@gmail.com> | 2024-05-03 10:23:46 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-05-03 10:23:46 -0400 |
commit | 723c8b33ade753764d1d02b130c189fb65e20425 (patch) | |
tree | e278304fdace45a2c38562e72a3ccd2e8e91b759 /src/client/views/collections/CollectionStackingViewFieldColumn.tsx | |
parent | f410a7b314dd78244e18c9c52140b67b37ab0c87 (diff) | |
parent | 2caf7b7bb80b663b6ba585f88cdbd2d725f8505e (diff) |
Merge branch 'master' into nathan-starter
Diffstat (limited to 'src/client/views/collections/CollectionStackingViewFieldColumn.tsx')
-rw-r--r-- | src/client/views/collections/CollectionStackingViewFieldColumn.tsx | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/client/views/collections/CollectionStackingViewFieldColumn.tsx b/src/client/views/collections/CollectionStackingViewFieldColumn.tsx index 641e01b81..c5292f880 100644 --- a/src/client/views/collections/CollectionStackingViewFieldColumn.tsx +++ b/src/client/views/collections/CollectionStackingViewFieldColumn.tsx @@ -12,7 +12,7 @@ import { TraceMobx } from '../../../fields/util'; import { DivHeight, DivWidth, emptyFunction, returnEmptyString, setupMoveUpEvents } from '../../../Utils'; import { Docs, DocUtils } from '../../documents/Documents'; import { DocumentType } from '../../documents/DocumentTypes'; -import { DragManager } from '../../util/DragManager'; +import { DragManager, dropActionType } from '../../util/DragManager'; import { SnappingManager } from '../../util/SnappingManager'; import { Transform } from '../../util/Transform'; import { undoBatch } from '../../util/UndoManager'; @@ -66,11 +66,26 @@ export class CollectionStackingViewFieldColumn extends ObservableReactComponent< _ele: HTMLElement | null = null; + protected onInternalPreDrop = (e: Event, de: DragManager.DropEvent, targetDropAction: dropActionType) => { + const dragData = de.complete.docDragData; + if (dragData) { + const sourceDragAction = dragData.dropAction; + const sameCollection = !dragData.draggedDocuments.some(d => !this._props.docList.includes(d)); + dragData.dropAction = !sameCollection // if doc from another tree + ? sourceDragAction || targetDropAction // then use the source's dragAction otherwise the target's + : sourceDragAction === dropActionType.inPlace // if source drag is inPlace + ? sourceDragAction // keep the doc in place + : dropActionType.same; // otherwise use same tree semantics to move within tree + + e.stopPropagation(); + } + }; + // This is likely similar to what we will be doing. Why do we need to make these refs? // is that the only way to have drop targets? createColumnDropRef = (ele: HTMLDivElement | null) => { this.dropDisposer?.(); - if (ele) this.dropDisposer = DragManager.MakeDropTarget(ele, this.columnDrop.bind(this), this._props.Document); + if (ele) this.dropDisposer = DragManager.MakeDropTarget(ele, this.columnDrop.bind(this), this._props.Document, this.onInternalPreDrop.bind(this)); else if (this._ele) this.props.refList.splice(this.props.refList.indexOf(this._ele), 1); this._ele = ele; }; @@ -345,7 +360,7 @@ export class CollectionStackingViewFieldColumn extends ObservableReactComponent< <div> <div key={`${heading}-stack`} - className={`collectionStackingView-masonrySingle`} + className="collectionStackingView-masonrySingle" style={{ padding: `${columnYMargin}px ${0}px ${this._props.yMargin}px ${0}px`, margin: 'auto', |