diff options
author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-01-31 23:17:10 -0500 |
---|---|---|
committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-01-31 23:17:10 -0500 |
commit | ee6e9bb0165e20e717140d2601b3de53d0c5380b (patch) | |
tree | 3ec87502e55f4dce8e97f347d957b96c2853d816 /src/views/nodes/FieldTextBox.tsx | |
parent | 4737b47badd10d4209eaf4164ee119f5fd4083ca (diff) | |
parent | 8866e324bd7ea8dd03814a840662ca7c3b1a8e0f (diff) |
Merge branch 'master' of github-tsch-brown:browngraphicslab/Dash-Web
Diffstat (limited to 'src/views/nodes/FieldTextBox.tsx')
-rw-r--r-- | src/views/nodes/FieldTextBox.tsx | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/views/nodes/FieldTextBox.tsx b/src/views/nodes/FieldTextBox.tsx index 4539bbab0..20dfde1d2 100644 --- a/src/views/nodes/FieldTextBox.tsx +++ b/src/views/nodes/FieldTextBox.tsx @@ -14,11 +14,10 @@ import { undo, redo, history } from "prosemirror-history" import { Opt } from "../../fields/Field"; import "./FieldTextBox.scss" +import { DocumentFieldViewProps } from "./DocumentView"; +import { SelectionManager } from "../../util/SelectionManager"; + -interface IProps { - fieldKey: Key; - doc: Document; -} // FieldTextBox: Displays an editable plain text node that maps to a specified Key of a Document // @@ -36,12 +35,14 @@ interface IProps { // specified Key and assigns it to an HTML input node. When changes are made tot his node, // this will edit the document and assign the new value to that field. // -export class FieldTextBox extends React.Component<IProps> { +export class FieldTextBox extends React.Component<DocumentFieldViewProps> { + + public static LayoutString() { return "<FieldTextBox doc={Document} containingDocumentView={ContainingDocumentView} fieldKey={DataKey} />"; } private _ref: React.RefObject<HTMLDivElement>; private _editorView: Opt<EditorView>; private _reactionDisposer: Opt<IReactionDisposer>; - constructor(props: IProps) { + constructor(props: DocumentFieldViewProps) { super(props); this._ref = React.createRef(); @@ -111,8 +112,13 @@ export class FieldTextBox extends React.Component<IProps> { const { fieldKey, doc } = this.props; doc.SetFieldValue(fieldKey, e.target.value, TextField); } - + onPointerDown = (e: React.PointerEvent): void => { + let me = this; + if (e.buttons === 1 && SelectionManager.IsSelected(me.props.containingDocumentView)) { + e.stopPropagation(); + } + } render() { - return (<div className="fieldTextBox-cont" ref={this._ref} />) + return (<div className="fieldTextBox-cont" onPointerDown={this.onPointerDown} ref={this._ref} />) } }
\ No newline at end of file |