From b987fe6e18c4b37a1ec40abcb4d8360d57dc7d54 Mon Sep 17 00:00:00 2001 From: monikahedman Date: Mon, 19 Aug 2019 23:14:00 -0400 Subject: switch to text needs help lol --- src/client/views/PreviewCursor.tsx | 18 +++++++++++++++++- src/client/views/nodes/WebBox.tsx | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/client/views/PreviewCursor.tsx b/src/client/views/PreviewCursor.tsx index 7bf0d8ace..40be470d6 100644 --- a/src/client/views/PreviewCursor.tsx +++ b/src/client/views/PreviewCursor.tsx @@ -34,8 +34,10 @@ export class PreviewCursor extends React.Component<{}> { let newPoint = PreviewCursor._getTransform().transformPoint(PreviewCursor._clickPoint[0], PreviewCursor._clickPoint[1]); runInAction(() => { PreviewCursor.Visible = false; }); - // pasting in text/video from youtube + if (e.clipboardData.getData("text/plain") !== "") { + + // tests for youtube and makes video document if (e.clipboardData.getData("text/plain").indexOf("www.youtube.com/watch") !== -1) { const url = e.clipboardData.getData("text/plain").replace("youtube.com/watch?v=", "youtube.com/embed/"); PreviewCursor._addDocument(Docs.Create.VideoDocument(url, { @@ -45,6 +47,20 @@ export class PreviewCursor extends React.Component<{}> { }), false); return; } + + // tests for URL and makes web document + let re: any = /^https?:\/\/www\./g; + if (re.test(e.clipboardData.getData("text/plain"))) { + const url = e.clipboardData.getData("text/plain") + PreviewCursor._addDocument(Docs.Create.WebDocument(url, { + title: url, width: 300, height: 300, + // nativeWidth: 300, nativeHeight: 472.5, + x: newPoint[0], y: newPoint[1] + }), false); + return; + } + + // creates text document let newBox = Docs.Create.TextDocument({ width: 200, height: 100, x: newPoint[0], diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx index 91170e99a..6e23d6fb7 100644 --- a/src/client/views/nodes/WebBox.tsx +++ b/src/client/views/nodes/WebBox.tsx @@ -10,6 +10,7 @@ import { InkTool } from "../../../new_fields/InkField"; import { Cast, FieldValue, NumCast, StrCast } from "../../../new_fields/Types"; import { Utils } from "../../../Utils"; 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"; @@ -18,6 +19,11 @@ import { ObjectField } from "../../../new_fields/ObjectField"; import { updateSourceFile } from "typescript"; import { KeyValueBox } from "./KeyValueBox"; import { setReactionScheduler } from "mobx/lib/internal"; +import { library } from "@fortawesome/fontawesome-svg-core"; +import { Docs } from "../../documents/Documents"; +import { PreviewCursor } from "../PreviewCursor"; + +library.add(faStickyNote) @observer export class WebBox extends React.Component { @@ -69,6 +75,24 @@ export class WebBox extends React.Component { } } + 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]); + 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-" + }); + + newBox.proto!.autoHeight = true; + PreviewCursor._addLiveTextDoc(newBox); + return; + } + urlEditor() { return (
@@ -91,9 +115,18 @@ export class WebBox extends React.Component { onChange={this.onURLChange} onKeyDown={this.onValueKeyDown} /> - + +
-- cgit v1.2.3-70-g09d2