aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-02-26 19:35:26 -0500
committerBob Zeleznik <zzzman@gmail.com>2019-02-26 19:35:26 -0500
commit2d4e1ac97f87c3e5a7be58291542829d68a19669 (patch)
tree457800578c6d7ad2877e99600754319697e2faaa
parenta7dda508e0cb7b4262df19635e497bc90cccbd46 (diff)
simplified WebBox.
-rw-r--r--src/client/views/nodes/WebBox.tsx50
-rw-r--r--src/fields/Document.ts5
2 files changed, 8 insertions, 47 deletions
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index 0a198f059..2ca8d49ce 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -4,63 +4,19 @@ import { WebField } from '../../../fields/WebField';
import { FieldViewProps, FieldView } from './FieldView';
import { FieldWaiting } from '../../../fields/Field';
import { observer } from "mobx-react"
-import { observable, action, spy, computed } from 'mobx';
+import { computed } from 'mobx';
import { KeyStore } from '../../../fields/KeyStore';
-import { HtmlField } from "../../../fields/HtmlField";
@observer
export class WebBox extends React.Component<FieldViewProps> {
public static LayoutString() { return FieldView.LayoutString(WebBox); }
- private _ref: React.RefObject<HTMLDivElement>;
- private _downX: number = 0;
- private _downY: number = 0;
- private _lastTap: number = 0;
- @observable private _isOpen: boolean = false;
constructor(props: FieldViewProps) {
super(props);
-
- this._ref = React.createRef();
- this.state = {
- isOpen: false,
- };
- }
-
- componentDidMount() {
- }
-
- componentWillUnmount() {
- }
-
- onPointerDown = (e: React.PointerEvent): void => {
- if (Date.now() - this._lastTap < 300) {
- if (e.buttons === 1 && this.props.isSelected()) {
- e.stopPropagation();
- this._downX = e.clientX;
- this._downY = e.clientY;
- document.removeEventListener("pointerup", this.onPointerUp);
- document.addEventListener("pointerup", this.onPointerUp);
- }
- } else {
- this._lastTap = Date.now();
- }
- }
-
- @action
- onPointerUp = (e: PointerEvent): void => {
- document.removeEventListener("pointerup", this.onPointerUp);
- if (Math.abs(e.clientX - this._downX) < 2 && Math.abs(e.clientY - this._downY) < 2) {
- this._isOpen = true;
- }
- e.stopPropagation();
- }
-
- @computed
- get html(): string {
- return this.props.doc.GetData(KeyStore.Data, HtmlField, "" as string);
}
+ @computed get html(): string { return this.props.doc.GetHtml(KeyStore.Data, ""); }
render() {
let field = this.props.doc.Get(this.props.fieldKey);
@@ -75,7 +31,7 @@ export class WebBox extends React.Component<FieldViewProps> {
</div>;
return (
- <div className="webBox-cont" onPointerDown={this.onPointerDown} ref={this._ref} >
+ <div className="webBox-cont" >
{content}
</div>)
}
diff --git a/src/fields/Document.ts b/src/fields/Document.ts
index 6193ea56c..5b91de6ed 100644
--- a/src/fields/Document.ts
+++ b/src/fields/Document.ts
@@ -8,6 +8,7 @@ import { ListField } from "./ListField";
import { Server } from "../client/Server";
import { Types } from "../server/Message";
import { UndoManager } from "../client/util/UndoManager";
+import { HtmlField } from "./HtmlField";
export class Document extends Field {
public fields: ObservableMap<string, { key: Key, field: Field }> = new ObservableMap();
@@ -125,6 +126,10 @@ export class Document extends Field {
return vval;
}
+ GetHtml(key: Key, defaultVal: string): string {
+ return this.GetData(key, HtmlField, defaultVal);
+ }
+
GetNumber(key: Key, defaultVal: number): number {
return this.GetData(key, NumberField, defaultVal);
}