diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/util/DragManager.ts | 1 | ||||
-rw-r--r-- | src/client/views/DocumentDecorations.scss | 2 | ||||
-rw-r--r-- | src/client/views/DocumentDecorations.tsx | 2 | ||||
-rw-r--r-- | src/client/views/collections/CollectionFreeFormView.tsx | 3 | ||||
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 33 |
5 files changed, 36 insertions, 5 deletions
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts index 60910a40b..95bf44560 100644 --- a/src/client/util/DragManager.ts +++ b/src/client/util/DragManager.ts @@ -95,7 +95,6 @@ export namespace DragManager { } export function StartDrag(ele: HTMLElement, dragData: { [id: string]: any }, options?: DragOptions) { - DocumentDecorations.Instance.Hidden = true; if (!dragDiv) { dragDiv = document.createElement("div"); DragManager.Root().appendChild(dragDiv); diff --git a/src/client/views/DocumentDecorations.scss b/src/client/views/DocumentDecorations.scss index fa9fc2c20..ca7896088 100644 --- a/src/client/views/DocumentDecorations.scss +++ b/src/client/views/DocumentDecorations.scss @@ -2,7 +2,7 @@ position: absolute; display: grid; z-index: 1000; - grid-template-rows: 20px 1fr 20px; + grid-template-rows: 20px 1fr 20px 0px; grid-template-columns: 20px 1fr 20px; pointer-events: none; #documentDecorations-centerCont { diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index d2f835fc8..fb8a724c5 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -83,7 +83,7 @@ export class DocumentDecorations extends React.Component { handlers: { dragComplete: action(() => { }), }, - hideSource: true + hideSource: false }) } document.removeEventListener("pointermove", this.onLinkButtonMoved) diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx index 63255dd90..75f019fd5 100644 --- a/src/client/views/collections/CollectionFreeFormView.tsx +++ b/src/client/views/collections/CollectionFreeFormView.tsx @@ -52,6 +52,9 @@ export class CollectionFreeFormView extends CollectionViewBase { @undoBatch @action drop = (e: Event, de: DragManager.DropEvent) => { + if (!("documentView" in de.data)) { + return; + } super.drop(e, de); const docView: DocumentView = de.data["documentView"]; let doc: Document = docView ? docView.props.Document : de.data["document"]; diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 51d073f7a..feae967cb 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -112,6 +112,32 @@ export class DocumentView extends React.Component<DocumentViewProps> { } } + private dropDisposer?: DragManager.DragDropDisposer; + protected createDropTarget = (ele: HTMLDivElement) => { + + } + + componentDidMount() { + if (this._mainCont.current) { + this.dropDisposer = DragManager.MakeDropTarget(this._mainCont.current, { handlers: { drop: this.drop.bind(this) } }); + } + } + + componentDidUpdate() { + if (this.dropDisposer) { + this.dropDisposer(); + } + if (this._mainCont.current) { + this.dropDisposer = DragManager.MakeDropTarget(this._mainCont.current, { handlers: { drop: this.drop.bind(this) } }); + } + } + + componentWillUnmount() { + if (this.dropDisposer) { + this.dropDisposer(); + } + } + onPointerMove = (e: PointerEvent): void => { if (e.cancelBubble) { return; @@ -168,11 +194,14 @@ export class DocumentView extends React.Component<DocumentViewProps> { drop = (e: Event, de: DragManager.DropEvent) => { console.log("drop"); const sourceDocView: DocumentView = de.data["linkSourceDoc"]; + if (!sourceDocView) { + return; + } let sourceDoc: Document = sourceDocView.props.Document; let destDoc: Document = this.props.Document; - sourceDoc.GetAsync(KeyStore.LinkedToDocs, field => { (field as ListField<Document>).Data.push(destDoc) }); - destDoc.GetAsync(KeyStore.LinkedFromDocs, field => { (field as ListField<Document>).Data.push(sourceDoc) }); + sourceDoc.GetOrCreateAsync(KeyStore.LinkedToDocs, ListField, field => { (field as ListField<Document>).Data.push(destDoc) }); + destDoc.GetOrCreateAsync(KeyStore.LinkedFromDocs, ListField, field => { (field as ListField<Document>).Data.push(sourceDoc) }); e.stopPropagation(); } |