aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/DocumentButtonBar.tsx
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-11-15 14:15:38 -0500
committerBob Zeleznik <zzzman@gmail.com>2019-11-15 14:15:38 -0500
commit1dd4ab8bfdacb50512d3ec9bce6945e476d9686f (patch)
tree06bf2e34b18766e0d39b9bc56b02e20b30f01134 /src/client/views/DocumentButtonBar.tsx
parentc9fbdb9cfd5fcf35f7a599706cb41d4e7e586e19 (diff)
switched making text links to the standard doc decs link button.
Diffstat (limited to 'src/client/views/DocumentButtonBar.tsx')
-rw-r--r--src/client/views/DocumentButtonBar.tsx26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/client/views/DocumentButtonBar.tsx b/src/client/views/DocumentButtonBar.tsx
index ba87ecfb4..1412316f9 100644
--- a/src/client/views/DocumentButtonBar.tsx
+++ b/src/client/views/DocumentButtonBar.tsx
@@ -5,7 +5,7 @@ import { action, observable, runInAction } from "mobx";
import { observer } from "mobx-react";
import { Doc } from "../../new_fields/Doc";
import { RichTextField } from '../../new_fields/RichTextField';
-import { NumCast } from "../../new_fields/Types";
+import { NumCast, StrCast } from "../../new_fields/Types";
import { emptyFunction } from "../../Utils";
import { Pulls, Pushes } from '../apis/google_docs/GoogleApiClientUtils';
import { DragLinksAsDocuments, DragManager } from "../util/DragManager";
@@ -135,13 +135,27 @@ export class DocumentButtonBar extends React.Component<{ views: DocumentView[],
if (this._linkerButton.current !== null) {
document.removeEventListener("pointermove", this.onLinkerButtonMoved);
document.removeEventListener("pointerup", this.onLinkerButtonUp);
- let selDoc = this.props.views[0];
- let container = selDoc.props.ContainingCollectionDoc ? selDoc.props.ContainingCollectionDoc.proto : undefined;
- let dragData = new DragManager.LinkDragData(selDoc.props.Document, container ? [container] : []);
- let _linkDrag = UndoManager.StartBatch("Drag Link");
+ let docView = this.props.views[0];
+ let container = docView.props.ContainingCollectionDoc ? docView.props.ContainingCollectionDoc.proto : undefined;
+ let dragData = new DragManager.LinkDragData(docView.props.Document, container ? [container] : []);
+ let linkDrag = UndoManager.StartBatch("Drag Link");
DragManager.StartLinkDrag(this._linkerButton.current, dragData, e.pageX, e.pageY, {
handlers: {
- dragComplete: () => _linkDrag && _linkDrag.end()
+ dragComplete: () => {
+ let tooltipmenu = FormattedTextBox.ToolTipTextMenu;
+ let linkDoc = dragData.linkDocument;
+ if (linkDoc && tooltipmenu) {
+ let proto = Doc.GetProto(linkDoc);
+ if (proto && docView) {
+ proto.sourceContext = docView.props.ContainingCollectionDoc;
+ }
+ let text = tooltipmenu.makeLink(linkDoc, StrCast(linkDoc.anchor2.title), e.ctrlKey ? "onRight" : "inTab");
+ if (linkDoc instanceof Doc && linkDoc.anchor2 instanceof Doc) {
+ proto.title = text === "" ? proto.title : text + " to " + linkDoc.anchor2.title; // TODODO open to more descriptive descriptions of following in text link
+ }
+ }
+ linkDrag && linkDrag.end();
+ }
},
hideSource: false
});