From b1ddfbe0a393dce03a8e5da9d70e9a46dc3b9755 Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 30 Sep 2020 11:51:37 -0400 Subject: fixed dragging alias buttons --- src/client/views/DocumentButtonBar.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/client/views/DocumentButtonBar.tsx') diff --git a/src/client/views/DocumentButtonBar.tsx b/src/client/views/DocumentButtonBar.tsx index 5ec43319b..bca3c6ce9 100644 --- a/src/client/views/DocumentButtonBar.tsx +++ b/src/client/views/DocumentButtonBar.tsx @@ -282,12 +282,8 @@ export class DocumentButtonBar extends React.Component<{ views: () => (DocumentV const dragDocView = this.view0!; const dragData = new DragManager.DocumentDragData([dragDocView.props.Document]); const [left, top] = dragDocView.props.ScreenToLocalTransform().inverse().transformPoint(0, 0); - dragData.dropAction = "alias"; - DragManager.StartDocumentDrag([dragDocView.ContentDiv!], dragData, left, top, { - offsetX: dragData.offset[0], - offsetY: dragData.offset[1], - hideSource: false - }); + dragData.defaultDropAction = "alias"; + DragManager.StartDocumentDrag([dragDocView.ContentDiv!], dragData, left, top, { hideSource: false }); return true; } return false; -- cgit v1.2.3-70-g09d2 From 58f83cc1eef844420e5b418011231f995c9cf043 Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 30 Sep 2020 12:16:24 -0400 Subject: fixed dragging aliases using alias button. made dragging title of doc decorations or alias button allow doc to be embedded --- src/client/util/DragManager.ts | 3 ++- src/client/views/DocumentButtonBar.tsx | 3 ++- src/client/views/DocumentDecorations.tsx | 12 ++++++++---- src/client/views/collections/CollectionMenu.tsx | 3 ++- 4 files changed, 14 insertions(+), 7 deletions(-) (limited to 'src/client/views/DocumentButtonBar.tsx') diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts index 0169b07fc..3a0f306f3 100644 --- a/src/client/util/DragManager.ts +++ b/src/client/util/DragManager.ts @@ -129,6 +129,7 @@ export namespace DragManager { treeViewDoc?: Doc; dontHideOnDrop?: boolean; offset: number[]; + canEmbed?: boolean; userDropAction: dropActionType; // the user requested drop action -- this will be honored as specified by modifier keys defaultDropAction?: dropActionType; // an optionally specified default drop action when there is no user drop actionl - this will be honored if there is no user drop action dropAction: dropActionType; // a drop action request by the initiating code. the actual drop action may be different -- eg, if the request is 'alias', but the document is dropped within the same collection, the drop action will be switched to 'move' @@ -324,7 +325,7 @@ export namespace DragManager { if (dragData.dropAction === "none") return; const batch = UndoManager.StartBatch("dragging"); eles = eles.filter(e => e); - CanEmbed = false; + CanEmbed = dragData.canEmbed || false; if (!dragDiv) { dragDiv = document.createElement("div"); dragDiv.className = "dragManager-dragDiv"; diff --git a/src/client/views/DocumentButtonBar.tsx b/src/client/views/DocumentButtonBar.tsx index bca3c6ce9..fff410267 100644 --- a/src/client/views/DocumentButtonBar.tsx +++ b/src/client/views/DocumentButtonBar.tsx @@ -283,6 +283,7 @@ export class DocumentButtonBar extends React.Component<{ views: () => (DocumentV const dragData = new DragManager.DocumentDragData([dragDocView.props.Document]); const [left, top] = dragDocView.props.ScreenToLocalTransform().inverse().transformPoint(0, 0); dragData.defaultDropAction = "alias"; + dragData.canEmbed = true; DragManager.StartDocumentDrag([dragDocView.ContentDiv!], dragData, left, top, { hideSource: false }); return true; } @@ -299,7 +300,7 @@ export class DocumentButtonBar extends React.Component<{ views: () => (DocumentV Array.from(["Caption", "Title", "TitleHover"]).map(template => templates.set(template, views.reduce((checked, doc) => checked || doc?.props.Document["_show" + template] ? true : false, false as boolean))); return !view0 ? (null) : - CustomizeLayout} open={this._tooltipOpen} onClose={action(() => this._tooltipOpen = false)} placement="bottom"> + Tap to Customize Layout. Drag an embeddable alias} open={this._tooltipOpen} onClose={action(() => this._tooltipOpen = false)} placement="bottom">
!this._ref.current?.getBoundingClientRect().width && (this._tooltipOpen = true))} > diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index 9432d1ffb..fa7220e7d 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -119,7 +119,7 @@ export class DocumentDecorations extends React.Component<{}, { value: string }> } } @action onTitleDown = (e: React.PointerEvent): void => { - setupMoveUpEvents(this, e, this.onBackgroundMove, (e) => { }, this.onTitleClick); + setupMoveUpEvents(this, e, e => this.onBackgroundMove(true, e), (e) => { }, this.onTitleClick); } @action onTitleClick = (e: PointerEvent): void => { !this._edtingTitle && (this._accumulatedTitle = this._titleControlString.startsWith("#") ? this.selectionTitle : this._titleControlString); @@ -128,22 +128,26 @@ export class DocumentDecorations extends React.Component<{}, { value: string }> } onBackgroundDown = (e: React.PointerEvent): void => { - setupMoveUpEvents(this, e, this.onBackgroundMove, (e) => { }, (e) => { }); + setupMoveUpEvents(this, e, e => this.onBackgroundMove(false, e), (e) => { }, (e) => { }); } @action - onBackgroundMove = (e: PointerEvent, down: number[]): boolean => { + onBackgroundMove = (dragTitle: boolean, e: PointerEvent): boolean => { const dragDocView = SelectionManager.SelectedDocuments()[0]; const dragData = new DragManager.DocumentDragData(SelectionManager.SelectedDocuments().map(dv => dv.props.Document)); const [left, top] = dragDocView.props.ScreenToLocalTransform().scale(dragDocView.props.ContentScaling()).inverse().transformPoint(0, 0); dragData.offset = dragDocView.props.ScreenToLocalTransform().scale(dragDocView.props.ContentScaling()).transformDirection(e.x - left, e.y - top); dragData.moveDocument = dragDocView.props.moveDocument; dragData.isSelectionMove = true; + dragData.canEmbed = dragTitle; dragData.dropAction = dragDocView.props.dropAction; this.Interacting = true; this._hidden = true; DragManager.StartDocumentDrag(SelectionManager.SelectedDocuments().map(dv => dv.ContentDiv!), dragData, e.x, e.y, { - dragComplete: action(e => this._hidden = this.Interacting = false), + dragComplete: action(e => { + dragData.canEmbed && SelectionManager.DeselectAll(); + this._hidden = this.Interacting = false; + }), hideSource: true }); return true; diff --git a/src/client/views/collections/CollectionMenu.tsx b/src/client/views/collections/CollectionMenu.tsx index 7464f7cd3..51d1d5559 100644 --- a/src/client/views/collections/CollectionMenu.tsx +++ b/src/client/views/collections/CollectionMenu.tsx @@ -442,6 +442,7 @@ export class CollectionViewBaseChrome extends React.Component{"Tap or Drag to create an alias"}
} placement="top"> -
; -- cgit v1.2.3-70-g09d2