From 81100809b0f824cfc1481b19dbe38c31814539e1 Mon Sep 17 00:00:00 2001
From: monikahedman <monika_hedman@brown.edu>
Date: Wed, 14 Aug 2019 17:20:57 -0400
Subject: drag new webpage and easy URL change working

---
 src/client/views/nodes/WebBox.tsx | 87 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 84 insertions(+), 3 deletions(-)

(limited to 'src/client/views/nodes/WebBox.tsx')

diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index c8749b7cd..ff5297783 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -7,13 +7,23 @@ import { FieldView, FieldViewProps } from './FieldView';
 import "./WebBox.scss";
 import React = require("react");
 import { InkTool } from "../../../new_fields/InkField";
-import { Cast, FieldValue, NumCast } from "../../../new_fields/Types";
+import { Cast, FieldValue, NumCast, StrCast } from "../../../new_fields/Types";
 import { Utils } from "../../../Utils";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { observable, action, computed } from "mobx";
+import { listSpec } from "../../../new_fields/Schema";
+import { Field, FieldResult } from "../../../new_fields/Doc";
+import { RefField } from "../../../new_fields/RefField";
+import { ObjectField } from "../../../new_fields/ObjectField";
+import { updateSourceFile } from "typescript";
+import { KeyValueBox } from "./KeyValueBox";
 
 @observer
 export class WebBox extends React.Component<FieldViewProps> {
 
     public static LayoutString() { return FieldView.LayoutString(WebBox); }
+    @observable private collapsed: boolean = true;
+    @observable private url: string = "";
 
     componentWillMount() {
 
@@ -30,6 +40,76 @@ export class WebBox extends React.Component<FieldViewProps> {
         }
     }
 
+    @action
+    onURLChange = (e: React.ChangeEvent<HTMLInputElement>) => {
+        this.url = e.target.value;
+    }
+
+    @action
+    submitURL = () => {
+        const script = KeyValueBox.CompileKVPScript(`new WebField("${this.url}")`);
+        if (!script) return;
+        KeyValueBox.ApplyKVPScript(this.props.Document, "data", script);
+        let mod = document.getElementById("webpage-input");
+        if (mod) mod.style.display = "none";
+    }
+
+    @computed
+    get getURL() {
+        let urlField: FieldResult<WebField> = Cast(this.props.Document.data, WebField)
+        if (urlField) return urlField.url.toString();
+        return "";
+    }
+
+    onValueKeyDown = async (e: React.KeyboardEvent) => {
+        if (e.key === "Enter") {
+            e.stopPropagation();
+            this.submitURL();
+        }
+    }
+
+    urlEditor() {
+        return (
+            <div className="webView-urlEditor" style={{ top: this.collapsed ? -70 : 0 }}>
+                <div className="urlEditor">
+                    <div className="collectionViewBaseChrome">
+                        <button className="collectionViewBaseChrome-collapse"
+                            style={{
+                                top: this.collapsed ? 70 : 10,
+                                transform: `rotate(${this.collapsed ? 180 : 0}deg) scale(${this.collapsed ? 0.5 : 1}) translate(${this.collapsed ? "-100%, -100%" : "0, 0"})`,
+                                opacity: (this.collapsed && !this.props.isSelected()) ? 0 : 0.9,
+                                left: (this.collapsed ? 0 : "unset"),
+                            }}
+                            title="Collapse Url Editor" onClick={this.toggleCollapse}>
+                            <FontAwesomeIcon icon="caret-up" size="2x" />
+                        </button>
+                        <div style={{ marginLeft: 54, width: "100%", display: this.collapsed ? "none" : "flex" }}>
+                            <input className="webpage-urlInput"
+                                placeholder="ENTER URL"
+                                value={this.getURL}
+                                onChange={this.onURLChange}
+                                onKeyDown={this.onValueKeyDown}
+                            // onPointerDown={this.openViewSpecs}
+                            />
+                            <button className="submitUrl" onClick={this.submitURL}>
+                                SUBMIT URL
+                            </button>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        );
+    }
+
+    @action
+    toggleCollapse = () => {
+        // this.props.CollectionView.props.Document.chromeStatus = this.props.CollectionView.props.Document.chromeStatus === "enabled" ? "this.collapsed" : "enabled";
+        // if (this.props.collapse) {
+        //     this.props.collapse(this.props.CollectionView.props.Document.chromeStatus !== "enabled");
+        // }
+        this.collapsed = !this.collapsed;
+    }
+
     _ignore = 0;
     onPreWheel = (e: React.WheelEvent) => {
         this._ignore = e.timeStamp;
@@ -53,12 +133,13 @@ export class WebBox extends React.Component<FieldViewProps> {
         if (field instanceof HtmlField) {
             view = <span id="webBox-htmlSpan" dangerouslySetInnerHTML={{ __html: field.html }} />;
         } else if (field instanceof WebField) {
-            view = <iframe src={Utils.CorsProxy(field.url.href)} style={{ position: "absolute", width: "100%", height: "100%" }} />;
+            view = <iframe src={Utils.CorsProxy(field.url.href)} style={{ position: "absolute", width: "100%", height: "100%", top: 0 }} />;
         } else {
-            view = <iframe src={"https://crossorigin.me/https://cs.brown.edu"} style={{ position: "absolute", width: "100%", height: "100%" }} />;
+            view = <iframe src={"https://crossorigin.me/https://cs.brown.edu"} style={{ position: "absolute", width: "100%", height: "100%", top: 0 }} />;
         }
         let content =
             <div style={{ width: "100%", height: "100%", position: "absolute" }} onWheel={this.onPostWheel} onPointerDown={this.onPostPointer} onPointerMove={this.onPostPointer} onPointerUp={this.onPostPointer}>
+                {this.urlEditor()}
                 {view}
             </div>;
 
-- 
cgit v1.2.3-70-g09d2


From 819ca614b022417776580251cb0fdc419ea47ddd Mon Sep 17 00:00:00 2001
From: monikahedman <monika_hedman@brown.edu>
Date: Thu, 15 Aug 2019 15:33:16 -0400
Subject: url editable again

---
 src/client/views/nodes/WebBox.tsx | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

(limited to 'src/client/views/nodes/WebBox.tsx')

diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index ff5297783..dc30dbed3 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -17,6 +17,7 @@ import { RefField } from "../../../new_fields/RefField";
 import { ObjectField } from "../../../new_fields/ObjectField";
 import { updateSourceFile } from "typescript";
 import { KeyValueBox } from "./KeyValueBox";
+import { setReactionScheduler } from "mobx/lib/internal";
 
 @observer
 export class WebBox extends React.Component<FieldViewProps> {
@@ -38,11 +39,16 @@ export class WebBox extends React.Component<FieldViewProps> {
                 this.props.Document.height = NumCast(this.props.Document.width) / youtubeaspect;
             }
         }
+
+        this.setURL();
     }
 
     @action
     onURLChange = (e: React.ChangeEvent<HTMLInputElement>) => {
+        console.log("changing")
+        console.log(e.target.value)
         this.url = e.target.value;
+        console.log(this.url)
     }
 
     @action
@@ -50,8 +56,13 @@ export class WebBox extends React.Component<FieldViewProps> {
         const script = KeyValueBox.CompileKVPScript(`new WebField("${this.url}")`);
         if (!script) return;
         KeyValueBox.ApplyKVPScript(this.props.Document, "data", script);
-        let mod = document.getElementById("webpage-input");
-        if (mod) mod.style.display = "none";
+    }
+
+    @action
+    setURL() {
+        let urlField: FieldResult<WebField> = Cast(this.props.Document.data, WebField)
+        if (urlField) this.url = urlField.url.toString();
+        else this.url = "";
     }
 
     @computed
@@ -86,7 +97,7 @@ export class WebBox extends React.Component<FieldViewProps> {
                         <div style={{ marginLeft: 54, width: "100%", display: this.collapsed ? "none" : "flex" }}>
                             <input className="webpage-urlInput"
                                 placeholder="ENTER URL"
-                                value={this.getURL}
+                                value={this.url}
                                 onChange={this.onURLChange}
                                 onKeyDown={this.onValueKeyDown}
                             // onPointerDown={this.openViewSpecs}
-- 
cgit v1.2.3-70-g09d2


From 70a3cc69966c52fb0b84809a942d0e363a315684 Mon Sep 17 00:00:00 2001
From: monikahedman <monika_hedman@brown.edu>
Date: Thu, 15 Aug 2019 15:39:39 -0400
Subject: things workin

---
 src/client/views/nodes/WebBox.tsx | 7 -------
 1 file changed, 7 deletions(-)

(limited to 'src/client/views/nodes/WebBox.tsx')

diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index dc30dbed3..9a177ca54 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -65,13 +65,6 @@ export class WebBox extends React.Component<FieldViewProps> {
         else this.url = "";
     }
 
-    @computed
-    get getURL() {
-        let urlField: FieldResult<WebField> = Cast(this.props.Document.data, WebField)
-        if (urlField) return urlField.url.toString();
-        return "";
-    }
-
     onValueKeyDown = async (e: React.KeyboardEvent) => {
         if (e.key === "Enter") {
             e.stopPropagation();
-- 
cgit v1.2.3-70-g09d2


From 1c1d4d4865b5dd90489cdde4c8f3dfceba60496b Mon Sep 17 00:00:00 2001
From: monikahedman <monika_hedman@brown.edu>
Date: Thu, 15 Aug 2019 16:14:17 -0400
Subject: done!

---
 src/client/views/nodes/WebBox.tsx | 8 --------
 1 file changed, 8 deletions(-)

(limited to 'src/client/views/nodes/WebBox.tsx')

diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index 9a177ca54..91170e99a 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -45,10 +45,7 @@ export class WebBox extends React.Component<FieldViewProps> {
 
     @action
     onURLChange = (e: React.ChangeEvent<HTMLInputElement>) => {
-        console.log("changing")
-        console.log(e.target.value)
         this.url = e.target.value;
-        console.log(this.url)
     }
 
     @action
@@ -93,7 +90,6 @@ export class WebBox extends React.Component<FieldViewProps> {
                                 value={this.url}
                                 onChange={this.onURLChange}
                                 onKeyDown={this.onValueKeyDown}
-                            // onPointerDown={this.openViewSpecs}
                             />
                             <button className="submitUrl" onClick={this.submitURL}>
                                 SUBMIT URL
@@ -107,10 +103,6 @@ export class WebBox extends React.Component<FieldViewProps> {
 
     @action
     toggleCollapse = () => {
-        // this.props.CollectionView.props.Document.chromeStatus = this.props.CollectionView.props.Document.chromeStatus === "enabled" ? "this.collapsed" : "enabled";
-        // if (this.props.collapse) {
-        //     this.props.collapse(this.props.CollectionView.props.Document.chromeStatus !== "enabled");
-        // }
         this.collapsed = !this.collapsed;
     }
 
-- 
cgit v1.2.3-70-g09d2


From 9d76e8c2f318b4c6a4f941e6d2c8e795bc93f372 Mon Sep 17 00:00:00 2001
From: monikahedman <monika_hedman@brown.edu>
Date: Thu, 15 Aug 2019 16:15:05 -0400
Subject: updated webbox

---
 src/client/views/nodes/WebBox.tsx | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

(limited to 'src/client/views/nodes/WebBox.tsx')

diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index ff5297783..91170e99a 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -17,6 +17,7 @@ import { RefField } from "../../../new_fields/RefField";
 import { ObjectField } from "../../../new_fields/ObjectField";
 import { updateSourceFile } from "typescript";
 import { KeyValueBox } from "./KeyValueBox";
+import { setReactionScheduler } from "mobx/lib/internal";
 
 @observer
 export class WebBox extends React.Component<FieldViewProps> {
@@ -38,6 +39,8 @@ export class WebBox extends React.Component<FieldViewProps> {
                 this.props.Document.height = NumCast(this.props.Document.width) / youtubeaspect;
             }
         }
+
+        this.setURL();
     }
 
     @action
@@ -50,15 +53,13 @@ export class WebBox extends React.Component<FieldViewProps> {
         const script = KeyValueBox.CompileKVPScript(`new WebField("${this.url}")`);
         if (!script) return;
         KeyValueBox.ApplyKVPScript(this.props.Document, "data", script);
-        let mod = document.getElementById("webpage-input");
-        if (mod) mod.style.display = "none";
     }
 
-    @computed
-    get getURL() {
+    @action
+    setURL() {
         let urlField: FieldResult<WebField> = Cast(this.props.Document.data, WebField)
-        if (urlField) return urlField.url.toString();
-        return "";
+        if (urlField) this.url = urlField.url.toString();
+        else this.url = "";
     }
 
     onValueKeyDown = async (e: React.KeyboardEvent) => {
@@ -86,10 +87,9 @@ export class WebBox extends React.Component<FieldViewProps> {
                         <div style={{ marginLeft: 54, width: "100%", display: this.collapsed ? "none" : "flex" }}>
                             <input className="webpage-urlInput"
                                 placeholder="ENTER URL"
-                                value={this.getURL}
+                                value={this.url}
                                 onChange={this.onURLChange}
                                 onKeyDown={this.onValueKeyDown}
-                            // onPointerDown={this.openViewSpecs}
                             />
                             <button className="submitUrl" onClick={this.submitURL}>
                                 SUBMIT URL
@@ -103,10 +103,6 @@ export class WebBox extends React.Component<FieldViewProps> {
 
     @action
     toggleCollapse = () => {
-        // this.props.CollectionView.props.Document.chromeStatus = this.props.CollectionView.props.Document.chromeStatus === "enabled" ? "this.collapsed" : "enabled";
-        // if (this.props.collapse) {
-        //     this.props.collapse(this.props.CollectionView.props.Document.chromeStatus !== "enabled");
-        // }
         this.collapsed = !this.collapsed;
     }
 
-- 
cgit v1.2.3-70-g09d2


From 7e4aacb09e8c80a3452ca24145b1f094170a897b Mon Sep 17 00:00:00 2001
From: monikahedman <monika_hedman@brown.edu>
Date: Thu, 15 Aug 2019 16:44:57 -0400
Subject: cleaning up

---
 src/client/util/RichTextSchema.tsx      | 43 -------------------
 src/client/views/GlobalKeyHandler.ts    |  2 -
 src/client/views/MainOverlayTextBox.tsx |  3 --
 src/client/views/nodes/WebBox.scss      | 75 +--------------------------------
 src/client/views/nodes/WebBox.tsx       |  4 +-
 5 files changed, 4 insertions(+), 123 deletions(-)

(limited to 'src/client/views/nodes/WebBox.tsx')

diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx
index a581b7578..8a15c212d 100644
--- a/src/client/util/RichTextSchema.tsx
+++ b/src/client/util/RichTextSchema.tsx
@@ -526,49 +526,6 @@ export class ImageResizeView {
     }
 }
 
-export class CheckboxView {
-    _view: any;
-    _collapsed: HTMLElement;
-
-    constructor(node: any, view: any, getPos: any) {
-        this._collapsed = document.createElement("span");
-        this._collapsed.textContent = node.attrs.visibility ? "⬛" : "⬜";
-        this._collapsed.style.position = "relative";
-        // this._collapsed.style.width = "80px";
-        this._collapsed.style.height = "20px";
-        let self = this;
-        this._view = view;
-        const js = node.toJSON;
-        node.toJSON = function () {
-
-            return js.apply(this, arguments);
-        };
-        this._collapsed.onpointerdown = function (e: any) {
-            console.log(node.attrs.visibility)
-            if (node.attrs.visibility) {
-                let y = getPos();
-                const attrs = { ...node.attrs };
-                attrs.visibility = !attrs.visibility;
-                view.dispatch(view.state.tr.setNodeMarkup(y, undefined, attrs));
-                self._collapsed.textContent = "⬜";
-            } else {
-                let y = getPos();
-                const attrs = { ...node.attrs };
-                attrs.visibility = !attrs.visibility;
-                console.log(attrs.visibility)
-                view.dispatch(view.state.tr.setNodeMarkup(y, undefined, attrs));
-                self._collapsed.textContent = "⬛";
-            }
-            e.preventDefault();
-            e.stopPropagation();
-            console.log(node.attrs.visibility)
-
-        };
-        (this as any).dom = this._collapsed;
-    }
-
-}
-
 export class SummarizedView {
     // TODO: highlight text that is summarized. to find end of region, walk along mark
     _collapsed: HTMLElement;
diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts
index f55953bd4..833bacedb 100644
--- a/src/client/views/GlobalKeyHandler.ts
+++ b/src/client/views/GlobalKeyHandler.ts
@@ -181,8 +181,6 @@ export default class KeyManager {
                 break;
             case "a":
             case "v":
-                this.printClipboard();
-                break;
             case "x":
             case "c":
                 stopPropagation = false;
diff --git a/src/client/views/MainOverlayTextBox.tsx b/src/client/views/MainOverlayTextBox.tsx
index f315b6d59..b14a1e0ea 100644
--- a/src/client/views/MainOverlayTextBox.tsx
+++ b/src/client/views/MainOverlayTextBox.tsx
@@ -60,20 +60,17 @@ export class MainOverlayTextBox extends React.Component<MainOverlayTextBoxProps>
                         return new Transform(-sxf.translateX, -sxf.translateY, 1 / sxf.scale);
                     };
                     this.setTextDoc(box.props.fieldKey, box.CurrentDiv, xf, BoolCast(box.props.Document.autoHeight, false) || box.props.height === "min-content");
-                    console.log("makin text doc?")
                 }
                 else {
                     this.TextDoc = undefined;
                     this.TextDataDoc = undefined;
                     this.setTextDoc();
-                    console.log("deletin text doc?")
                 }
             });
     }
 
     @action
     private setTextDoc(textFieldKey?: string, div?: HTMLDivElement, tx?: () => Transform, autoHeight?: boolean) {
-        console.log("what is going on")
         if (this._textTargetDiv) {
             this._textTargetDiv.style.color = this._textColor;
         }
diff --git a/src/client/views/nodes/WebBox.scss b/src/client/views/nodes/WebBox.scss
index c37f08eca..07774263c 100644
--- a/src/client/views/nodes/WebBox.scss
+++ b/src/client/views/nodes/WebBox.scss
@@ -52,91 +52,20 @@
         padding-bottom: 10px;
         overflow: hidden;
 
-        .collectionViewBaseChrome {
+        .editorBase {
             display: flex;
 
-            .collectionViewBaseChrome-viewPicker {
-                font-size: 75%;
-                text-transform: uppercase;
-                letter-spacing: 2px;
-                background: rgb(238, 238, 238);
-                color: grey;
-                outline-color: black;
-                border: none;
-                padding: 12px 10px 11px 10px;
-                margin-left: 50px;
-            }
-
-            .collectionViewBaseChrome-viewPicker:active {
-                outline-color: black;
-            }
-
-            .collectionViewBaseChrome-collapse {
+            .editor-collapse {
                 transition: all .5s, opacity 0.3s;
                 position: absolute;
                 width: 40px;
                 transform-origin: top left;
-                // margin-top: 10px;
-            }
-
-            .collectionViewBaseChrome-viewSpecs {
-                margin-left: 10px;
-                display: grid;
-
-
-
-                .collectionViewBaseChrome-viewSpecsMenu {
-                    overflow: hidden;
-                    transition: height .5s, display .5s;
-                    position: absolute;
-                    top: 60px;
-                    z-index: 100;
-                    display: flex;
-                    flex-direction: column;
-                    background: rgb(238, 238, 238);
-                    box-shadow: grey 2px 2px 4px;
-
-                    .qs-datepicker {
-                        left: unset;
-                        right: 0;
-                    }
-
-                    .collectionViewBaseChrome-viewSpecsMenu-row {
-                        display: grid;
-                        grid-template-columns: 150px 200px 150px;
-                        margin-top: 10px;
-                        margin-right: 10px;
-
-                        .collectionViewBaseChrome-viewSpecsMenu-rowLeft,
-                        .collectionViewBaseChrome-viewSpecsMenu-rowMiddle,
-                        .collectionViewBaseChrome-viewSpecsMenu-rowRight {
-                            font-size: 75%;
-                            letter-spacing: 2px;
-                            color: grey;
-                            margin-left: 10px;
-                            padding: 5px;
-                            border: none;
-                            outline-color: black;
-                        }
-                    }
-
-                    .collectionViewBaseChrome-viewSpecsMenu-lastRow {
-                        display: grid;
-                        grid-template-columns: 1fr 1fr 1fr;
-                        grid-gap: 10px;
-                        margin: 10px;
-                    }
-                }
             }
         }
 
         button:hover {
             transform: scale(1);
         }
-
-        .collectionStackingViewChrome-sectionFilter:hover {
-            cursor: text;
-        }
     }
 }
 
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index 91170e99a..0a4af7318 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -73,8 +73,8 @@ export class WebBox extends React.Component<FieldViewProps> {
         return (
             <div className="webView-urlEditor" style={{ top: this.collapsed ? -70 : 0 }}>
                 <div className="urlEditor">
-                    <div className="collectionViewBaseChrome">
-                        <button className="collectionViewBaseChrome-collapse"
+                    <div className="editorBase">
+                        <button className="editor-collapse"
                             style={{
                                 top: this.collapsed ? 70 : 10,
                                 transform: `rotate(${this.collapsed ? 180 : 0}deg) scale(${this.collapsed ? 0.5 : 1}) translate(${this.collapsed ? "-100%, -100%" : "0, 0"})`,
-- 
cgit v1.2.3-70-g09d2


From eb2d8bdcf11459ab274196b390815e6fc4ddc26e Mon Sep 17 00:00:00 2001
From: monikahedman <monika_hedman@brown.edu>
Date: Thu, 15 Aug 2019 16:45:20 -0400
Subject: we hate lint

---
 src/client/views/nodes/WebBox.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/client/views/nodes/WebBox.tsx')

diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index 0a4af7318..302b45a9a 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -57,7 +57,7 @@ export class WebBox extends React.Component<FieldViewProps> {
 
     @action
     setURL() {
-        let urlField: FieldResult<WebField> = Cast(this.props.Document.data, WebField)
+        let urlField: FieldResult<WebField> = Cast(this.props.Document.data, WebField);
         if (urlField) this.url = urlField.url.toString();
         else this.url = "";
     }
-- 
cgit v1.2.3-70-g09d2


From 797ed4ee343a52738e8619cf336e5f94f64c69c4 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Thu, 15 Aug 2019 23:44:45 -0400
Subject: tweaks

---
 src/client/views/nodes/WebBox.tsx | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

(limited to 'src/client/views/nodes/WebBox.tsx')

diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index 302b45a9a..9b66b2431 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -1,23 +1,18 @@
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { action, observable } from "mobx";
 import { observer } from "mobx-react";
+import { FieldResult } from "../../../new_fields/Doc";
 import { HtmlField } from "../../../new_fields/HtmlField";
+import { InkTool } from "../../../new_fields/InkField";
+import { Cast, NumCast } from "../../../new_fields/Types";
 import { WebField } from "../../../new_fields/URLField";
+import { Utils } from "../../../Utils";
 import { DocumentDecorations } from "../DocumentDecorations";
 import { InkingControl } from "../InkingControl";
 import { FieldView, FieldViewProps } from './FieldView';
+import { KeyValueBox } from "./KeyValueBox";
 import "./WebBox.scss";
 import React = require("react");
-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 { observable, action, computed } from "mobx";
-import { listSpec } from "../../../new_fields/Schema";
-import { Field, FieldResult } from "../../../new_fields/Doc";
-import { RefField } from "../../../new_fields/RefField";
-import { ObjectField } from "../../../new_fields/ObjectField";
-import { updateSourceFile } from "typescript";
-import { KeyValueBox } from "./KeyValueBox";
-import { setReactionScheduler } from "mobx/lib/internal";
 
 @observer
 export class WebBox extends React.Component<FieldViewProps> {
-- 
cgit v1.2.3-70-g09d2


From b987fe6e18c4b37a1ec40abcb4d8360d57dc7d54 Mon Sep 17 00:00:00 2001
From: monikahedman <monika_hedman@brown.edu>
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/client/views/nodes/WebBox.tsx')

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<FieldViewProps> {
@@ -69,6 +75,24 @@ 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]);
+        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 (
             <div className="webView-urlEditor" style={{ top: this.collapsed ? -70 : 0 }}>
@@ -91,9 +115,18 @@ export class WebBox extends React.Component<FieldViewProps> {
                                 onChange={this.onURLChange}
                                 onKeyDown={this.onValueKeyDown}
                             />
-                            <button className="submitUrl" onClick={this.submitURL}>
-                                SUBMIT URL
+                            <div style={{
+                                display: "flex",
+                                flexDirection: "row",
+
+                            }}>
+                                <button className="submitUrl" onClick={this.submitURL}>
+                                    SUBMIT URL
                             </button>
+                                <button className="switchToText" onClick={this.switchToText} style={{ paddingLeft: 10 }} >
+                                    <FontAwesomeIcon icon={faStickyNote} size={"2x"} />
+                                </button>
+                            </div>
                         </div>
                     </div>
                 </div>
-- 
cgit v1.2.3-70-g09d2


From 9a39ac87972243787474d489856818f44b90d524 Mon Sep 17 00:00:00 2001
From: monikahedman <monika_hedman@brown.edu>
Date: Tue, 20 Aug 2019 12:12:58 -0400
Subject: send halp

---
 src/client/views/PreviewCursor.tsx |  2 +-
 src/client/views/nodes/WebBox.tsx  | 41 +++++++++++++++++++++++++++++++-------
 2 files changed, 35 insertions(+), 8 deletions(-)

(limited to 'src/client/views/nodes/WebBox.tsx')

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;
     }
 
-- 
cgit v1.2.3-70-g09d2


From 76a693012866178a3fbe037ab06cfd4482f37917 Mon Sep 17 00:00:00 2001
From: monikahedman <monika_hedman@brown.edu>
Date: Wed, 21 Aug 2019 14:22:30 -0400
Subject: djlzdkfj

---
 src/client/views/nodes/FormattedTextBox.tsx |  7 +++++++
 src/client/views/nodes/WebBox.tsx           | 26 ++++++++++++++++----------
 2 files changed, 23 insertions(+), 10 deletions(-)

(limited to 'src/client/views/nodes/WebBox.tsx')

diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index 25f611f19..d299bbf72 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -162,6 +162,13 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe
         }
     }
 
+    public setText = (text: string) => {
+        const tx = this._editorView!.state.tr.insertText(text);
+        const state = this._editorView!.state;
+        this._editorView!.dispatch(tx);
+        return new RichTextField(JSON.stringify(state.toJSON()));
+    }
+
     dispatchTransaction = (tx: Transaction) => {
         if (this._editorView) {
             const state = this._editorView.state.apply(tx);
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index c43b90f91..e7bed3bed 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -26,6 +26,8 @@ import { SelectionManager } from "../../util/SelectionManager";
 import { CollectionView } from "../collections/CollectionView";
 import { CollectionPDFView } from "../collections/CollectionPDFView";
 import { CollectionVideoView } from "../collections/CollectionVideoView";
+import { DocumentView } from "./DocumentView";
+import { FormattedTextBox } from "./FormattedTextBox";
 
 library.add(faStickyNote)
 
@@ -85,14 +87,15 @@ export class WebBox extends React.Component<FieldViewProps> {
         let field = Cast(this.props.Document[this.props.fieldKey], WebField);
         if (field) url = field.url.href;
 
-        let parent: Opt<CollectionView | CollectionPDFView | CollectionVideoView>;
+        let docView: DocumentView;
         // let parentDoc: any;
         SelectionManager.SelectedDocuments().map(dv => {
-            parent = dv.props.ContainingCollectionView;
-            // if(parent) parentDoc = parent.props.Document;
+            // docView = dv;
             dv.props.removeDocument && dv.props.removeDocument(dv.props.Document);
         });
 
+        console.log("happening")
+
         // // let newPoint = PreviewCursor._getTransform().transformPoint(PreviewCursor._clickPoint[0], PreviewCursor._clickPoint[1]);
         let newBox = Docs.Create.TextDocument({
             width: 200, height: 100,
@@ -103,13 +106,16 @@ export class WebBox extends React.Component<FieldViewProps> {
             title: url
         });
 
-        console.log(newBox)
-        if (parent) {
-            let parentDoc: Doc = parent.props.Document;
-            if (parentDoc && parentDoc.props) {
-                parentDoc.props.addDocument();
-            }
-        }
+        console.log(typeof newBox)
+
+        // const script = KeyValueBox.CompileKVPScript(`new RichTextField("{"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"${url}"}]}]},"selection":{"type":"text","anchor":1,"head":1}}")`);
+        // const script = KeyValueBox.CompileKVPScript(newBox.setText(url))
+        // console.log(script)
+        // if (!script) return;
+        // KeyValueBox.ApplyKVPScript(this.props.Document, "data", script);
+
+        console.log(newBox);
+
 
         newBox.proto!.autoHeight = true;
         // PreviewCursor._addLiveTextDoc(newBox);
-- 
cgit v1.2.3-70-g09d2


From 6604c40d02b4dd7c6a6c663f301bcaedfee6998f Mon Sep 17 00:00:00 2001
From: monikahedman <monika_hedman@brown.edu>
Date: Wed, 21 Aug 2019 17:18:02 -0400
Subject: send help oh god

---
 src/client/util/RichTextSchema.tsx  | 81 -------------------------------------
 src/client/util/TooltipTextMenu.tsx | 29 -------------
 src/client/views/nodes/WebBox.scss  | 10 +++++
 src/client/views/nodes/WebBox.tsx   | 51 +++++++----------------
 4 files changed, 25 insertions(+), 146 deletions(-)

(limited to 'src/client/views/nodes/WebBox.tsx')

diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx
index 733c50d20..1f6c2badb 100644
--- a/src/client/util/RichTextSchema.tsx
+++ b/src/client/util/RichTextSchema.tsx
@@ -111,19 +111,6 @@ export const nodes: { [index: string]: NodeSpec } = {
         //     }
         // }]
     },
-
-    checkbox: {
-        inline: true,
-        attrs: {
-            visibility: { default: false }
-        },
-        group: "inline",
-        toDOM(node) {
-            const attrs = { style: `width: 40px` };
-            return ["span", { ...node.attrs, ...attrs }];
-        },
-    },
-
     // :: NodeSpec An inline image (`<img>`) node. Supports `src`,
     // `alt`, and `href` attributes. The latter two default to the empty
     // string.
@@ -203,19 +190,6 @@ export const nodes: { [index: string]: NodeSpec } = {
         // toDOM() { return ulDOM }
     },
 
-    checkbox_list: {
-        content: 'checklist_item+',
-        marks: '_',
-        group: 'block',
-        // inline: true,
-        parseDOM: [
-            { tag: "ul" }
-        ],
-        toDOM() {
-            return ["ul", { style: 'list-style: none' }, 0];
-        },
-    },
-
     //bullet_list: {
     //  content: 'list_item+',
     // group: 'block',
@@ -228,18 +202,6 @@ export const nodes: { [index: string]: NodeSpec } = {
         ...listItem,
         content: 'paragraph block*'
     },
-
-    checklist_item: {
-        content: 'paragraph block*',
-        parseDOM: [{ tag: "li" }],
-        // toDOM() {
-        //     return ["li", { style: 'content: checkbox' }, 0];
-        // },
-        toDOM() {
-            return ["li", 0];
-        },
-        defining: true
-    }
 };
 
 const emDOM: DOMOutputSpecArray = ["em", 0];
@@ -562,49 +524,6 @@ export class ImageResizeView {
     }
 }
 
-export class CheckboxView {
-    _view: any;
-    _collapsed: HTMLElement;
-
-    constructor(node: any, view: any, getPos: any) {
-        this._collapsed = document.createElement("span");
-        this._collapsed.textContent = node.attrs.visibility ? "⬛" : "⬜";
-        this._collapsed.style.position = "relative";
-        // this._collapsed.style.width = "80px";
-        this._collapsed.style.height = "20px";
-        let self = this;
-        this._view = view;
-        const js = node.toJSON;
-        node.toJSON = function () {
-
-            return js.apply(this, arguments);
-        };
-        this._collapsed.onpointerdown = function (e: any) {
-            console.log(node.attrs.visibility)
-            if (node.attrs.visibility) {
-                let y = getPos();
-                const attrs = { ...node.attrs };
-                attrs.visibility = !attrs.visibility;
-                view.dispatch(view.state.tr.setNodeMarkup(y, undefined, attrs));
-                self._collapsed.textContent = "⬜";
-            } else {
-                let y = getPos();
-                const attrs = { ...node.attrs };
-                attrs.visibility = !attrs.visibility;
-                console.log(attrs.visibility)
-                view.dispatch(view.state.tr.setNodeMarkup(y, undefined, attrs));
-                self._collapsed.textContent = "⬛";
-            }
-            e.preventDefault();
-            e.stopPropagation();
-            console.log(node.attrs.visibility)
-
-        };
-        (this as any).dom = this._collapsed;
-    }
-
-}
-
 export class SummarizedView {
     // TODO: highlight text that is summarized. to find end of region, walk along mark
     _collapsed: HTMLElement;
diff --git a/src/client/util/TooltipTextMenu.tsx b/src/client/util/TooltipTextMenu.tsx
index 46961e416..450931b76 100644
--- a/src/client/util/TooltipTextMenu.tsx
+++ b/src/client/util/TooltipTextMenu.tsx
@@ -189,7 +189,6 @@ export class TooltipTextMenu {
         this.tooltip.appendChild(this._brushdom);
         this.tooltip.appendChild(this.createLink().render(this.view).dom);
         this.tooltip.appendChild(this.createStar().render(this.view).dom);
-        this.tooltip.appendChild(this.createCheckbox().render(this.view).dom);
 
         this.updateListItemDropdown(":", this.listTypeBtnDom);
 
@@ -441,14 +440,6 @@ export class TooltipTextMenu {
         return true;
     }
 
-    public static insertCheckbox(state: EditorState<any>, dispatch: any) {
-        let newNode = schema.nodes.checkbox.create({ visibility: false });
-        if (dispatch) {
-            dispatch(state.tr.replaceSelectionWith(newNode));
-        }
-        return true;
-    }
-
     //will display a remove-list-type button if selection is in list, otherwise will show list type dropdown
     updateListItemDropdown(label: string, listTypeBtn: any) {
         //remove old btn
@@ -461,7 +452,6 @@ export class TooltipTextMenu {
         });
         //option to remove the list formatting
         toAdd.push(this.dropdownNodeBtn("X", "color: black; width: 40px;", undefined, this.view, this.listTypes, this.changeToNodeType));
-        toAdd.push(this.dropdownNodeBtn("⬜", "color:black; width:40px;", schema.nodes.checkbox_list, this.view, this.listTypes, this.changeToNodeType))
 
         listTypeBtn = (new Dropdown(toAdd, {
             label: label,
@@ -525,11 +515,6 @@ export class TooltipTextMenu {
         liftListItem(schema.nodes.list_item)(view.state, view.dispatch);
         if (nodeType) { //add new
             wrapInList(nodeType)(view.state, view.dispatch);
-            // console.log(nodeType === schema.nodes.checkbox_list)
-            // if (nodeType === schema.nodes.checkbox_list) {
-            //     TooltipTextMenu.insertCheckbox(view.state, view.dispatch)
-            // }
-
         }
     }
 
@@ -564,20 +549,6 @@ export class TooltipTextMenu {
         });
     }
 
-    createCheckbox() {
-        return new MenuItem({
-            title: "Checkbox",
-            label: "Checkbox",
-            icon: icons.code,
-            css: "color:white",
-            class: "checkbox",
-            execEvent: "",
-            run: (state, dispatch) => {
-                TooltipTextMenu.insertCheckbox(state, dispatch);
-            }
-        })
-    }
-
     deleteLinkItem() {
         const icon = {
             height: 16, width: 16,
diff --git a/src/client/views/nodes/WebBox.scss b/src/client/views/nodes/WebBox.scss
index c37f08eca..6272d3d47 100644
--- a/src/client/views/nodes/WebBox.scss
+++ b/src/client/views/nodes/WebBox.scss
@@ -1,3 +1,5 @@
+@import "../globalCssVariables.scss";
+
 .webBox-cont,
 .webBox-cont-interactive {
     padding: 0vw;
@@ -79,6 +81,14 @@
                 // margin-top: 10px;
             }
 
+            .switchToText {
+                color: $main-accent;
+            }
+
+            .switchToText:hover {
+                color: $dark-color;
+            }
+
             .collectionViewBaseChrome-viewSpecs {
                 margin-left: 10px;
                 display: grid;
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index e7bed3bed..ef8f8c664 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -87,43 +87,21 @@ export class WebBox extends React.Component<FieldViewProps> {
         let field = Cast(this.props.Document[this.props.fieldKey], WebField);
         if (field) url = field.url.href;
 
-        let docView: DocumentView;
-        // let parentDoc: any;
-        SelectionManager.SelectedDocuments().map(dv => {
-            // docView = dv;
-            dv.props.removeDocument && dv.props.removeDocument(dv.props.Document);
-        });
-
-        console.log("happening")
-
-        // // 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: url
+            title: url,
+            width: 200,
+            height: 70,
+            documentText: "@@@" + url
         });
 
-        console.log(typeof newBox)
-
-        // const script = KeyValueBox.CompileKVPScript(`new RichTextField("{"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"${url}"}]}]},"selection":{"type":"text","anchor":1,"head":1}}")`);
-        // const script = KeyValueBox.CompileKVPScript(newBox.setText(url))
-        // console.log(script)
-        // if (!script) return;
-        // KeyValueBox.ApplyKVPScript(this.props.Document, "data", script);
-
-        console.log(newBox);
-
+        SelectionManager.SelectedDocuments().map(dv => {
+            dv.props.addDocument && dv.props.addDocument(newBox, false);
+            dv.props.removeDocument && dv.props.removeDocument(dv.props.Document);
+        });
 
-        newBox.proto!.autoHeight = true;
-        // PreviewCursor._addLiveTextDoc(newBox);
-        // if (parent && parent.props.addDocument) {
-        //     console.log("adding doc")
-        //     parent.props.addDocument(newBox);
-        // }
-        return;
+        Doc.BrushDoc(newBox);
     }
 
     urlEditor() {
@@ -151,14 +129,15 @@ export class WebBox extends React.Component<FieldViewProps> {
                             <div style={{
                                 display: "flex",
                                 flexDirection: "row",
-
+                                justifyContent: "space-between",
+                                minWidth: "100px",
                             }}>
                                 <button className="submitUrl" onClick={this.submitURL}>
-                                    SUBMIT URL
-                            </button>
-                                <button className="switchToText" onClick={this.switchToText} style={{ paddingLeft: 10 }} >
-                                    <FontAwesomeIcon icon={faStickyNote} size={"2x"} />
+                                    SUBMIT
                                 </button>
+                                <div className="switchToText" title="Convert web to text doc" onClick={this.switchToText} style={{ display: "flex", alignItems: "center", justifyContent: "center" }} >
+                                    <FontAwesomeIcon icon={faStickyNote} size={"lg"} />
+                                </div>
                             </div>
                         </div>
                     </div>
-- 
cgit v1.2.3-70-g09d2


From 656a08a130124870c9f652f7b1529b2b496cdac7 Mon Sep 17 00:00:00 2001
From: bob <bcz@cs.brown.edu>
Date: Tue, 27 Aug 2019 15:52:25 -0400
Subject: lint fixes.

---
 src/client/views/PreviewCursor.tsx                     | 2 +-
 src/client/views/collections/CollectionViewChromes.tsx | 2 ++
 src/client/views/nodes/DocumentView.tsx                | 2 +-
 src/client/views/nodes/FormattedTextBox.tsx            | 2 +-
 src/client/views/nodes/WebBox.tsx                      | 2 +-
 src/client/views/pdf/PDFViewer.tsx                     | 2 +-
 6 files changed, 7 insertions(+), 5 deletions(-)

(limited to 'src/client/views/nodes/WebBox.tsx')

diff --git a/src/client/views/PreviewCursor.tsx b/src/client/views/PreviewCursor.tsx
index d8e161ab6..1329dc02c 100644
--- a/src/client/views/PreviewCursor.tsx
+++ b/src/client/views/PreviewCursor.tsx
@@ -51,7 +51,7 @@ export class PreviewCursor extends React.Component<{}> {
                     // tests for URL and makes web document
                     let re: any = /^https?:\/\//g;
                     if (re.test(e.clipboardData.getData("text/plain"))) {
-                        const url = 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,
diff --git a/src/client/views/collections/CollectionViewChromes.tsx b/src/client/views/collections/CollectionViewChromes.tsx
index b2df0e747..4b3f7c87e 100644
--- a/src/client/views/collections/CollectionViewChromes.tsx
+++ b/src/client/views/collections/CollectionViewChromes.tsx
@@ -42,11 +42,13 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
 
     _templateCommand = {
         title: "set template", script: "this.target.childLayout = this.source ? this.source[0] : undefined", params: ["target", "source"],
+        initialize: emptyFunction,
         immediate: (draggedDocs: Doc[]) => this.props.CollectionView.props.Document.childLayout = draggedDocs.length ? draggedDocs[0] : undefined
     };
     _contentCommand = {
         // title: "set content", script: "getProto(this.target).data = aliasDocs(this.source.map(async p => await p));", params: ["target", "source"],  // bcz: doesn't look like we can do async stuff in scripting...
         title: "set content", script: "getProto(this.target).data = aliasDocs(this.source);", params: ["target", "source"],
+        initialize: emptyFunction,
         immediate: (draggedDocs: Doc[]) => Doc.GetProto(this.props.CollectionView.props.Document).data = new List<Doc>(draggedDocs.map((d: any) => Doc.MakeAlias(d)))
     };
     _viewCommand = {
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index f7ebfb75a..4d5307c88 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -600,7 +600,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
                 this.makeBtnClicked();
             }, icon: "window-restore"
         });
-        makes.push({ description: this.props.Document.ignoreClick ? "Selectable" : "Unselectable", event: () => this.props.Document.ignoreClick = !this.props.Document.ignoreClick, icon: this.props.Document.ignoreClick ? "unlock" : "lock" })
+        makes.push({ description: this.props.Document.ignoreClick ? "Selectable" : "Unselectable", event: () => this.props.Document.ignoreClick = !this.props.Document.ignoreClick, icon: this.props.Document.ignoreClick ? "unlock" : "lock" });
         !existingMake && cm.addItem({ description: "Make...", subitems: makes, icon: "hand-point-right" });
         let existing = ContextMenu.Instance.findByDescription("Layout...");
         let layoutItems: ContextMenuProps[] = existing && "subitems" in existing ? existing.subitems : [];
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index c28bf1821..49189c5f3 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -622,7 +622,7 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe
             }
         }
 
-        if (this.props.Document[Id] == FormattedTextBox.SelectOnLoad) {
+        if (this.props.Document[Id] === FormattedTextBox.SelectOnLoad) {
             FormattedTextBox.SelectOnLoad = "";
             this.props.select(false);
         }
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index f0140d04b..642f58daf 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -18,7 +18,7 @@ import { Docs } from "../../documents/Documents";
 import { faStickyNote } from "@fortawesome/free-solid-svg-icons";
 import { library } from "@fortawesome/fontawesome-svg-core";
 
-library.add(faStickyNote)
+library.add(faStickyNote);
 
 @observer
 export class WebBox extends React.Component<FieldViewProps> {
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index e3bfea237..e5917fefc 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -163,7 +163,7 @@ export class PDFViewer extends React.Component<IViewerProps> {
                         <div key={`${this.props.url}-placeholder-${i + 1}`} className="pdfviewer-placeholder"
                             style={{ width: this._pageSizes[i].width, height: this._pageSizes[i].height }}>
                             "PAGE IS LOADING... "
-                </div>)
+                </div>);
                     this.getPlaceholderPage(i);
                 }))));
             this.props.loaded(Math.max(...this._pageSizes.map(i => i.width)), this._pageSizes[0].height, this.props.pdf.numPages);
-- 
cgit v1.2.3-70-g09d2

