aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonikahedman <monika_hedman@brown.edu>2019-08-20 12:12:58 -0400
committermonikahedman <monika_hedman@brown.edu>2019-08-20 12:12:58 -0400
commit9a39ac87972243787474d489856818f44b90d524 (patch)
tree00fefeb187929fd88412314d78f5718ab958d974
parentb987fe6e18c4b37a1ec40abcb4d8360d57dc7d54 (diff)
send halp
-rw-r--r--src/client/views/PreviewCursor.tsx2
-rw-r--r--src/client/views/nodes/WebBox.tsx41
2 files changed, 35 insertions, 8 deletions
diff --git a/src/client/views/PreviewCursor.tsx b/src/client/views/PreviewCursor.tsx
index 40be470d6..d8e161ab6 100644
--- a/src/client/views/PreviewCursor.tsx
+++ b/src/client/views/PreviewCursor.tsx
@@ -49,7 +49,7 @@ export class PreviewCursor extends React.Component<{}> {
}
// tests for URL and makes web document
- let re: any = /^https?:\/\/www\./g;
+ let re: any = /^https?:\/\//g;
if (re.test(e.clipboardData.getData("text/plain"))) {
const url = e.clipboardData.getData("text/plain")
PreviewCursor._addDocument(Docs.Create.WebDocument(url, {
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index 6e23d6fb7..c43b90f91 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -13,7 +13,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faStickyNote } from '@fortawesome/free-solid-svg-icons';
import { observable, action, computed } from "mobx";
import { listSpec } from "../../../new_fields/Schema";
-import { Field, FieldResult } from "../../../new_fields/Doc";
+import { Field, FieldResult, Doc, Opt } from "../../../new_fields/Doc";
import { RefField } from "../../../new_fields/RefField";
import { ObjectField } from "../../../new_fields/ObjectField";
import { updateSourceFile } from "typescript";
@@ -22,6 +22,10 @@ import { setReactionScheduler } from "mobx/lib/internal";
import { library } from "@fortawesome/fontawesome-svg-core";
import { Docs } from "../../documents/Documents";
import { PreviewCursor } from "../PreviewCursor";
+import { SelectionManager } from "../../util/SelectionManager";
+import { CollectionView } from "../collections/CollectionView";
+import { CollectionPDFView } from "../collections/CollectionPDFView";
+import { CollectionVideoView } from "../collections/CollectionVideoView";
library.add(faStickyNote)
@@ -75,21 +79,44 @@ export class WebBox extends React.Component<FieldViewProps> {
}
}
- switchToText() {
- console.log("switchng to text")
- if (this.props.removeDocument) this.props.removeDocument(this.props.Document);
- // let newPoint = PreviewCursor._getTransform().transformPoint(PreviewCursor._clickPoint[0], PreviewCursor._clickPoint[1]);
+
+ switchToText = () => {
+ let url: string = "";
+ let field = Cast(this.props.Document[this.props.fieldKey], WebField);
+ if (field) url = field.url.href;
+
+ let parent: Opt<CollectionView | CollectionPDFView | CollectionVideoView>;
+ // let parentDoc: any;
+ SelectionManager.SelectedDocuments().map(dv => {
+ parent = dv.props.ContainingCollectionView;
+ // if(parent) parentDoc = parent.props.Document;
+ dv.props.removeDocument && dv.props.removeDocument(dv.props.Document);
+ });
+
+ // // let newPoint = PreviewCursor._getTransform().transformPoint(PreviewCursor._clickPoint[0], PreviewCursor._clickPoint[1]);
let newBox = Docs.Create.TextDocument({
width: 200, height: 100,
// x: newPoint[0],
// y: newPoint[1],
x: NumCast(this.props.Document.x),
y: NumCast(this.props.Document.y),
- title: "-pasted text-"
+ title: url
});
+ console.log(newBox)
+ if (parent) {
+ let parentDoc: Doc = parent.props.Document;
+ if (parentDoc && parentDoc.props) {
+ parentDoc.props.addDocument();
+ }
+ }
+
newBox.proto!.autoHeight = true;
- PreviewCursor._addLiveTextDoc(newBox);
+ // PreviewCursor._addLiveTextDoc(newBox);
+ // if (parent && parent.props.addDocument) {
+ // console.log("adding doc")
+ // parent.props.addDocument(newBox);
+ // }
return;
}