aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-06-04 13:55:10 -0400
committerbob <bcz@cs.brown.edu>2019-06-04 13:55:10 -0400
commit7d3ef1c914cc1cc0b6c05b14773a8b83e1b95c96 (patch)
treed782d7e14ecdfd8553dbe4221a322e3f4b241947 /src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
parent4cfad07d853dfc77fb9255070b2e0421e26fd9b1 (diff)
drop prosemirror text w/ links
Diffstat (limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx')
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 1a1614ac7..9d19df540 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -25,6 +25,7 @@ import { pageSchema } from "../../nodes/ImageBox";
import { InkField, StrokeData } from "../../../../new_fields/InkField";
import { HistoryUtil } from "../../../util/History";
import { Id } from "../../../../new_fields/FieldSymbols";
+import { DocServer } from "../../../DocServer";
export const panZoomSchema = createSchema({
panX: "number",
@@ -228,7 +229,24 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
@action
onDrop = (e: React.DragEvent): void => {
var pt = this.getTransform().transformPoint(e.pageX, e.pageY);
- super.onDrop(e, { x: pt[0], y: pt[1] });
+ let html = e.dataTransfer.getData("text/html");
+ if (html && html.indexOf(document.location.origin)) { // prosemirror text containing link to dash document
+ e.stopPropagation();
+ e.preventDefault();
+ let start = html.indexOf(window.location.origin);
+ let path = html.substr(start, html.length - start);
+ let docid = path.substr(0, path.indexOf("\">")).replace(DocServer.prepend("/doc/"), "").split("?")[0];
+ DocServer.GetRefField(docid).then(f => {
+ if (f instanceof Doc) {
+ f.x = pt[0];
+ f.y = pt[1];
+ (f instanceof Doc) && this.props.addDocument(f, false);
+ }
+ });
+ return;
+ } else {
+ super.onDrop(e, { x: pt[0], y: pt[1] });
+ }
}
onDragOver = (): void => {