diff options
| author | monikahedman <monika_hedman@brown.edu> | 2019-08-23 16:40:52 -0400 |
|---|---|---|
| committer | monikahedman <monika_hedman@brown.edu> | 2019-08-23 16:40:52 -0400 |
| commit | e138dc74aaff258e9598d65244c85f1ab0c5fb17 (patch) | |
| tree | 264b78adae65cc7d06f3a15027b3f7e4007634d9 /src/client/views/nodes | |
| parent | ed7f9a9cd3255f7b774268cfda35685ddacfe2e9 (diff) | |
| parent | bdb132d92eafc43f04bf6f002b8082d233ccafc3 (diff) | |
pulled from master
Diffstat (limited to 'src/client/views/nodes')
| -rw-r--r-- | src/client/views/nodes/ButtonBox.scss | 19 | ||||
| -rw-r--r-- | src/client/views/nodes/ButtonBox.tsx | 42 | ||||
| -rw-r--r-- | src/client/views/nodes/FormattedTextBox.tsx | 5 | ||||
| -rw-r--r-- | src/client/views/nodes/WebBox.scss | 10 | ||||
| -rw-r--r-- | src/client/views/nodes/WebBox.tsx | 42 |
5 files changed, 76 insertions, 42 deletions
diff --git a/src/client/views/nodes/ButtonBox.scss b/src/client/views/nodes/ButtonBox.scss index 5ed435505..75a790667 100644 --- a/src/client/views/nodes/ButtonBox.scss +++ b/src/client/views/nodes/ButtonBox.scss @@ -3,14 +3,29 @@ height: 100%; pointer-events: all; border-radius: inherit; - display:table; + display:flex; + flex-direction: column; } .buttonBox-mainButton { width: 100%; height: 100%; border-radius: inherit; + text-align: center; + display: table; +} +.buttonBox-mainButtonCenter { + height: 100%; display:table-cell; vertical-align: middle; - text-align: center; +} + +.buttonBox-params { + display:flex; + flex-direction: row; +} + +.buttonBox-missingParam { + width:100%; + background: lightgray; }
\ No newline at end of file diff --git a/src/client/views/nodes/ButtonBox.tsx b/src/client/views/nodes/ButtonBox.tsx index ca5f0acc2..54848344b 100644 --- a/src/client/views/nodes/ButtonBox.tsx +++ b/src/client/views/nodes/ButtonBox.tsx @@ -1,25 +1,19 @@ -import * as React from 'react'; -import { FieldViewProps, FieldView } from './FieldView'; -import { createSchema, makeInterface } from '../../../new_fields/Schema'; -import { ScriptField } from '../../../new_fields/ScriptField'; -import { DocComponent } from '../DocComponent'; -import { ContextMenu } from '../ContextMenu'; import { library } from '@fortawesome/fontawesome-svg-core'; import { faEdit } from '@fortawesome/free-regular-svg-icons'; -import { emptyFunction } from '../../../Utils'; -import { ScriptBox } from '../ScriptBox'; -import { CompileScript } from '../../util/Scripting'; -import { OverlayView } from '../OverlayView'; -import { Doc } from '../../../new_fields/Doc'; - -import './ButtonBox.scss'; +import { action, computed } from 'mobx'; import { observer } from 'mobx-react'; -import { DocumentIconContainer } from './DocumentIcon'; -import { StrCast, BoolCast } from '../../../new_fields/Types'; +import * as React from 'react'; +import { Doc, DocListCastAsync } from '../../../new_fields/Doc'; +import { List } from '../../../new_fields/List'; +import { createSchema, makeInterface, listSpec } from '../../../new_fields/Schema'; +import { ScriptField } from '../../../new_fields/ScriptField'; +import { BoolCast, StrCast, Cast } from '../../../new_fields/Types'; import { DragManager } from '../../util/DragManager'; import { undoBatch } from '../../util/UndoManager'; -import { action, computed } from 'mobx'; -import { List } from '../../../new_fields/List'; +import { DocComponent } from '../DocComponent'; +import './ButtonBox.scss'; +import { FieldView, FieldViewProps } from './FieldView'; + library.add(faEdit as any); @@ -52,12 +46,24 @@ export class ButtonBox extends DocComponent<FieldViewProps, ButtonDocument>(Butt drop = (e: Event, de: DragManager.DropEvent) => { if (de.data instanceof DragManager.DocumentDragData) { Doc.GetProto(this.dataDoc).source = new List<Doc>(de.data.droppedDocuments); + e.stopPropagation(); } } + // (!missingParams || !missingParams.length ? "" : "(" + missingParams.map(m => m + ":").join(" ") + ")") render() { + let params = Cast(this.props.Document.buttonParams, listSpec("string")); + let missingParams = params && params.filter(p => this.props.Document[p] === undefined); + params && params.map(async p => await DocListCastAsync(this.props.Document[p])); // bcz: really hacky form of prefetching ... return ( <div className="buttonBox-outerDiv" ref={this.createDropTarget} > - <div className="buttonBox-mainButton" style={{ background: StrCast(this.props.Document.backgroundColor), color: StrCast(this.props.Document.color, "black") }} >{this.Document.text || this.Document.title}</div> + <div className="buttonBox-mainButton" style={{ background: StrCast(this.props.Document.backgroundColor), color: StrCast(this.props.Document.color, "black") }} > + <div className="buttonBox-mainButtonCenter"> + {(this.Document.text || this.Document.title)} + </div> + </div> + <div className="buttonBox-params" > + {!missingParams || !missingParams.length ? (null) : missingParams.map(m => <div key={m} className="buttonBox-missingParam">{m}</div>)} + </div> </div> ); } diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index 467f10ab8..0e04bacf7 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -34,16 +34,12 @@ import "./FormattedTextBox.scss"; import React = require("react"); import { GoogleApiClientUtils, Pulls, Pushes } from '../../apis/google_docs/GoogleApiClientUtils'; import { DocumentDecorations } from '../DocumentDecorations'; -import { MainOverlayTextBox } from '../MainOverlayTextBox'; import { DictationManager } from '../../util/DictationManager'; import { ReplaceStep } from 'prosemirror-transform'; library.add(faEdit); library.add(faSmile, faTextHeight, faUpload); -// FormattedTextBox: Displays an editable plain text node that maps to a specified Key of a Document -// - export const Blank = `{"doc":{"type":"doc","content":[]},"selection":{"type":"text","anchor":0,"head":0}}`; export interface FormattedTextBoxProps { @@ -146,7 +142,6 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe paste = (e: ClipboardEvent) => { - //this is throwing a ton of erros so i had to comment it out if (e.clipboardData && this._editorView) { // let pdfPasteText = `${Utils.GenerateDeterministicGuid("pdf paste")}`; // for (let i = 0; i < e.clipboardData.items.length; i++) { diff --git a/src/client/views/nodes/WebBox.scss b/src/client/views/nodes/WebBox.scss index 07774263c..43220df71 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; @@ -61,6 +63,14 @@ width: 40px; transform-origin: top left; } + + .switchToText { + color: $main-accent; + } + + .switchToText:hover { + color: $dark-color; + } } button:hover { diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx index 1b54472e5..095b0094e 100644 --- a/src/client/views/nodes/WebBox.tsx +++ b/src/client/views/nodes/WebBox.tsx @@ -1,4 +1,5 @@ import { observer } from "mobx-react"; +import { FieldResult, Doc, Field } from "../../../new_fields/Doc"; import { HtmlField } from "../../../new_fields/HtmlField"; import { WebField } from "../../../new_fields/URLField"; import { DocumentDecorations } from "../DocumentDecorations"; @@ -13,17 +14,17 @@ 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 { 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"; import { library } from "@fortawesome/fontawesome-svg-core"; +import { SelectionManager } from "../../util/SelectionManager"; import { Docs } from "../../documents/Documents"; -import { PreviewCursor } from "../PreviewCursor"; library.add(faStickyNote); +library.add(faStickyNote) @observer export class WebBox extends React.Component<FieldViewProps> { @@ -75,21 +76,27 @@ export class WebBox extends React.Component<FieldViewProps> { } } - switchToText() { - 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 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, + width: 200, + height: 70, + documentText: "@@@" + url }); - newBox.proto!.autoHeight = true; - PreviewCursor._addLiveTextDoc(newBox); - return; + SelectionManager.SelectedDocuments().map(dv => { + dv.props.addDocument && dv.props.addDocument(newBox, false); + dv.props.removeDocument && dv.props.removeDocument(dv.props.Document); + }); + + Doc.BrushDoc(newBox); } urlEditor() { @@ -117,14 +124,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> |
