diff options
author | monikahedman <monika_hedman@brown.edu> | 2019-08-20 12:12:58 -0400 |
---|---|---|
committer | monikahedman <monika_hedman@brown.edu> | 2019-08-20 12:12:58 -0400 |
commit | 9a39ac87972243787474d489856818f44b90d524 (patch) | |
tree | 00fefeb187929fd88412314d78f5718ab958d974 | |
parent | b987fe6e18c4b37a1ec40abcb4d8360d57dc7d54 (diff) |
send halp
-rw-r--r-- | src/client/views/PreviewCursor.tsx | 2 | ||||
-rw-r--r-- | src/client/views/nodes/WebBox.tsx | 41 |
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; } |