aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-02-11 17:37:03 -0500
committerbob <bcz@cs.brown.edu>2019-02-11 17:37:03 -0500
commit9f8653ab3d7f82a5d82b925bf339bef8d6723f5c (patch)
tree2bfab025912bb9e14dc304302bf583915fcc871f
parent400a14c03c10f07f3e4cfedd1df963d9263e98c8 (diff)
added framework for annotation overlays -- see ImageBox
-rw-r--r--src/client/documents/Documents.ts14
-rw-r--r--src/client/views/Main.tsx12
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx4
-rw-r--r--src/client/views/collections/CollectionFreeFormView.tsx69
-rw-r--r--src/client/views/collections/CollectionSchemaView.tsx14
-rw-r--r--src/client/views/collections/CollectionViewBase.tsx1
-rw-r--r--src/client/views/nodes/CollectionFreeFormDocumentView.tsx3
-rw-r--r--src/client/views/nodes/DocumentView.tsx20
-rw-r--r--src/client/views/nodes/ImageBox.scss1
-rw-r--r--src/client/views/nodes/ImageBox.tsx10
-rw-r--r--src/fields/Key.ts3
11 files changed, 101 insertions, 50 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 6925234fe..12eddaec9 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -115,11 +115,13 @@ export namespace Documents {
imageProto.Set(KeyStore.Title, new TextField("IMAGE PROTO"));
imageProto.Set(KeyStore.X, new NumberField(0));
imageProto.Set(KeyStore.Y, new NumberField(0));
- imageProto.Set(KeyStore.Width, new NumberField(300));
- imageProto.Set(KeyStore.Height, new NumberField(300));
- imageProto.Set(KeyStore.Layout, new TextField(ImageBox.LayoutString()));
+ imageProto.Set(KeyStore.NativeWidth, new NumberField(606));
+ imageProto.Set(KeyStore.Width, new NumberField(606));
+ imageProto.Set(KeyStore.Height, new NumberField(446));
+ imageProto.Set(KeyStore.Layout, new TextField("<CollectionFreeFormView DocumentForCollection={Document} CollectionFieldKey={AnnotationsKey} BackgroundView={BackgroundView} ContainingDocumentView={DocumentView} />"));
+ imageProto.Set(KeyStore.AnnotatedLayout, new TextField(ImageBox.LayoutString()));
// imageProto.SetField(KeyStore.Layout, new TextField('<div style={"background-image: " + {Data}} />'));
- imageProto.Set(KeyStore.LayoutKeys, new ListField([KeyStore.Data]));
+ imageProto.Set(KeyStore.LayoutKeys, new ListField([KeyStore.Data, KeyStore.Annotations]));
Server.AddDocument(imageProto);
return imageProto;
}
@@ -130,6 +132,10 @@ export namespace Documents {
let doc = GetImagePrototype().MakeDelegate();
setupOptions(doc, options);
doc.Set(KeyStore.Data, new ImageField(new URL(url)));
+
+ let annotation = Documents.TextDocument({ title: "hello" });
+ Server.AddDocument(annotation);
+ doc.Set(KeyStore.Annotations, new ListField([annotation]));
Server.AddDocument(doc);
var sdoc = Server.GetField(doc.Id) as Document;
return sdoc;
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index 9a359e868..31a709744 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -43,11 +43,11 @@ document.addEventListener("pointerdown", action(function (e: PointerEvent) {
let doc2 = doc1.MakeDelegate();
doc2.Set(KS.X, new NumberField(150));
doc2.Set(KS.Y, new NumberField(20));
- let doc3 = Documents.ImageDocument("https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg", {
+ let doc3 = Documents.ImageDocument("https://psmag.com/.image/t_share/MTMyNzc2NzM1MDY1MjgzMDM4/shutterstock_151341212jpg.jpg", {
x: 450, y: 100, title: "cat 1"
});
- doc3.Set(KeyStore.Data, new ImageField);
- const schemaDocs = Array.from(Array(5).keys()).map(v => Documents.ImageDocument("https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg", {
+ //doc3.Set(KeyStore.Data, new ImageField);
+ const schemaDocs = Array.from(Array(5).keys()).map(v => Documents.ImageDocument("https://psmag.com/.image/t_share/MTMyNzc2NzM1MDY1MjgzMDM4/shutterstock_151341212jpg.jpg", {
x: 50 + 100 * v, y: 50, width: 100, height: 100, title: "cat" + v
}));
schemaDocs[0].SetData(KS.Author, "Tyler", TextField);
@@ -61,7 +61,7 @@ document.addEventListener("pointerdown", action(function (e: PointerEvent) {
// let doc5 = Documents.ImageDocument("https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg", {
// x: 650, y: 500, width: 600, height: 600, title: "cat 2"
// });
- let docset2 = new Array<Document>(doc4);//, doc1, doc3);
+ let docset2 = [doc4, doc1, doc3];
let doc6 = Documents.CollectionDocument(docset2, {
x: 350, y: 100, width: 600, height: 600, title: "docking collection"
});
@@ -76,7 +76,7 @@ document.addEventListener("pointerdown", action(function (e: PointerEvent) {
// mainNodes.Data.push(doc5);
// mainNodes.Data.push(doc1);
//mainNodes.Data.push(doc2);
- //mainNodes.Data.push(doc6);
+ mainNodes.Data.push(doc6);
mainContainer.Set(KeyStore.Data, mainNodes);
}
//}
@@ -84,7 +84,7 @@ document.addEventListener("pointerdown", action(function (e: PointerEvent) {
ReactDOM.render((
<div style={{ position: "absolute", width: "100%", height: "100%" }}>
- <DocumentView Document={mainContainer} ContainingCollectionView={undefined} DocumentView={undefined} />
+ <DocumentView Document={mainContainer} Scaling={1} ContainingCollectionView={undefined} DocumentView={undefined} />
<DocumentDecorations />
<ContextMenu />
</div>),
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 9aee9c10f..037b85712 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -95,7 +95,7 @@ export class CollectionDockingView extends CollectionViewBase {
const value: Document[] = Document.GetData(fieldKey, ListField, []);
for (var i: number = 0; i < value.length; i++) {
if (value[i].Id === component) {
- return (<DocumentView key={value[i].Id} ContainingCollectionView={this} Document={value[i]} DocumentView={undefined} />);
+ return (<DocumentView key={value[i].Id} Scaling={1} ContainingCollectionView={this} Document={value[i]} DocumentView={undefined} />);
}
}
if (component === "text") {
@@ -236,7 +236,7 @@ export class CollectionDockingView extends CollectionViewBase {
container.getElement().html("<div id='" + containingDiv + "'></div>");
setTimeout(function () {
ReactDOM.render((
- <DocumentView key={state.doc.Id} Document={state.doc} ContainingCollectionView={me} DocumentView={undefined} />
+ <DocumentView key={state.doc.Id} Scaling={1} Document={state.doc} ContainingCollectionView={me} DocumentView={undefined} />
),
document.getElementById(containingDiv)
);
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx
index 9cf29d000..9cf8f2e35 100644
--- a/src/client/views/collections/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/CollectionFreeFormView.tsx
@@ -22,11 +22,25 @@ export class CollectionFreeFormView extends CollectionViewBase {
private _nodeContainerRef = React.createRef<HTMLDivElement>();
private _lastX: number = 0;
private _lastY: number = 0;
+ private _downX: number = 0;
+ private _downY: number = 0;
constructor(props: CollectionViewProps) {
super(props);
}
+ @computed
+ get isAnnotationOverlay() { return this.props.CollectionFieldKey == KeyStore.Annotations; }
+
+ @computed
+ get nativeWidth() { return this.props.DocumentForCollection.GetNumber(KeyStore.NativeWidth, 0); }
+
+ @computed
+ get zoomScaling() { return this.props.DocumentForCollection.GetNumber(KeyStore.Scale, 1); }
+
+ @computed
+ get resizeScaling() { return this.isAnnotationOverlay ? this.props.DocumentForCollection.GetNumber(KeyStore.Width, 0) / this.nativeWidth : 1; }
+
@action
drop = (e: Event, de: DragManager.DropEvent) => {
const doc = de.data["document"];
@@ -38,12 +52,12 @@ export class CollectionFreeFormView extends CollectionViewBase {
}
const xOffset = de.data["xOffset"] as number || 0;
const yOffset = de.data["yOffset"] as number || 0;
- const { scale, translateX, translateY } = Utils.GetScreenTransform(this._canvasRef.current!);
- let sscale = this.props.ContainingDocumentView!.props.Document.GetData(KeyStore.Scale, NumberField, Number(1))
+ const { translateX, translateY } = Utils.GetScreenTransform(this._canvasRef.current!);
+ const currScale = this.resizeScaling * this.zoomScaling * this.props.ContainingDocumentView!.ScalingToScreenSpace;
const screenX = de.x - xOffset;
const screenY = de.y - yOffset;
- const docX = (screenX - translateX) / sscale / scale;
- const docY = (screenY - translateY) / sscale / scale;
+ const docX = (screenX - translateX) / currScale;
+ const docY = (screenY - translateY) / currScale;
doc.x = docX;
doc.y = docY;
this.bringToFront(doc);
@@ -69,8 +83,8 @@ export class CollectionFreeFormView extends CollectionViewBase {
document.addEventListener("pointermove", this.onPointerMove);
document.removeEventListener("pointerup", this.onPointerUp);
document.addEventListener("pointerup", this.onPointerUp);
- this._lastX = e.pageX;
- this._lastY = e.pageY;
+ this._downX = this._lastX = e.pageX;
+ this._downY = this._lastY = e.pageY;
}
}
@@ -79,20 +93,23 @@ export class CollectionFreeFormView extends CollectionViewBase {
document.removeEventListener("pointermove", this.onPointerMove);
document.removeEventListener("pointerup", this.onPointerUp);
e.stopPropagation();
- SelectionManager.DeselectAll();
+ if (Math.abs(this._downX - e.clientX) < 3 && Math.abs(this._downY - e.clientY) < 3) {
+ if (!SelectionManager.IsSelected(this.props.ContainingDocumentView as CollectionFreeFormDocumentView)) {
+ SelectionManager.SelectDoc(this.props.ContainingDocumentView as CollectionFreeFormDocumentView, false);
+ }
+ }
}
@action
onPointerMove = (e: PointerEvent): void => {
- var me = this;
if (!e.cancelBubble && this.active) {
e.preventDefault();
e.stopPropagation();
let currScale: number = this.props.ContainingDocumentView!.ScalingToScreenSpace;
- let x = this.props.DocumentForCollection.GetData(KeyStore.PanX, NumberField, Number(0));
- let y = this.props.DocumentForCollection.GetData(KeyStore.PanY, NumberField, Number(0));
- this.props.DocumentForCollection.SetData(KeyStore.PanX, x + (e.pageX - this._lastX) / currScale, NumberField);
- this.props.DocumentForCollection.SetData(KeyStore.PanY, y + (e.pageY - this._lastY) / currScale, NumberField);
+ let x = this.props.DocumentForCollection.GetNumber(KeyStore.PanX, 0);
+ let y = this.props.DocumentForCollection.GetNumber(KeyStore.PanY, 0);
+
+ this.SetPan(x + (e.pageX - this._lastX) / currScale, y + (e.pageY - this._lastY) / currScale);
}
this._lastX = e.pageX;
this._lastY = e.pageY;
@@ -105,16 +122,18 @@ export class CollectionFreeFormView extends CollectionViewBase {
let { LocalX, Ss, Panxx, Xx, LocalY, Panyy, Yy, ContainerX, ContainerY } = this.props.ContainingDocumentView!.TransformToLocalPoint(e.pageX, e.pageY);
var deltaScale = (1 - (e.deltaY / 1000)) * Ss;
+ var newDeltaScale = this.isAnnotationOverlay ? Math.max(1, deltaScale) : deltaScale;
- var newContainerX = LocalX * deltaScale + Panxx + Xx;
- var newContainerY = LocalY * deltaScale + Panyy + Yy;
-
- let dx = ContainerX - newContainerX;
- let dy = ContainerY - newContainerY;
+ this.props.DocumentForCollection.SetNumber(KeyStore.Scale, newDeltaScale);
+ this.SetPan(ContainerX - (LocalX * newDeltaScale + Xx), ContainerY - (LocalY * newDeltaScale + Yy));
+ }
- this.props.DocumentForCollection.Set(KeyStore.Scale, new NumberField(deltaScale));
- this.props.DocumentForCollection.SetData(KeyStore.PanX, Panxx + dx, NumberField);
- this.props.DocumentForCollection.SetData(KeyStore.PanY, Panyy + dy, NumberField);
+ @action
+ private SetPan(panX: number, panY: number) {
+ const newPanX = Math.max(-(this.resizeScaling * this.zoomScaling - this.resizeScaling) * this.nativeWidth, Math.min(0, panX));
+ const newPanY = Math.min(0, panY);
+ this.props.DocumentForCollection.SetNumber(KeyStore.PanX, this.isAnnotationOverlay ? newPanX : panX);
+ this.props.DocumentForCollection.SetNumber(KeyStore.PanY, this.isAnnotationOverlay ? newPanY : panY);
}
@action
@@ -173,11 +192,10 @@ export class CollectionFreeFormView extends CollectionViewBase {
}
render() {
- const { CollectionFieldKey: fieldKey, DocumentForCollection: Document } = this.props;
- const value: Document[] = Document.GetList<Document>(fieldKey, []);
+ const Document: Document = this.props.DocumentForCollection;
+ const value: Document[] = Document.GetList<Document>(this.props.CollectionFieldKey, []);
const panx: number = Document.GetNumber(KeyStore.PanX, 0);
const pany: number = Document.GetNumber(KeyStore.PanY, 0);
- const currScale: number = Document.GetNumber(KeyStore.Scale, 1);
return (
<div className="border" style={{
@@ -190,11 +208,12 @@ export class CollectionFreeFormView extends CollectionViewBase {
onDrop={this.onDrop}
onDragOver={this.onDragOver}
ref={this._containerRef}>
- <div className="collectionfreeformview" style={{ transform: `translate(${panx}px, ${pany}px) scale(${currScale}, ${currScale})`, transformOrigin: `left, top` }} ref={this._canvasRef}>
+ <div className="collectionfreeformview" style={{ transform: `translate(${panx}px, ${pany}px) scale(${this.zoomScaling}, ${this.zoomScaling})`, transformOrigin: `left, top` }} ref={this._canvasRef}>
<div className="node-container" ref={this._nodeContainerRef}>
+ {this.props.BackgroundView}
{value.map(doc => {
- return (<CollectionFreeFormDocumentView key={doc.Id} ContainingCollectionView={this} Document={doc} DocumentView={undefined} />);
+ return (<CollectionFreeFormDocumentView Scaling={this.resizeScaling} key={doc.Id} ContainingCollectionView={this} Document={doc} DocumentView={undefined} />);
})}
</div>
</div>
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 2d5bd6c99..b2ee2f5f2 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -86,10 +86,11 @@ export class CollectionSchemaView extends CollectionViewBase {
if (target.tagName == "SPAN" && target.className.includes("Resizer")) {
e.stopPropagation();
}
- if (e.button === 2 && this.active) {
- e.stopPropagation();
- e.preventDefault();
- } else {
+ // if (e.button === 2 && this.active) {
+ // e.stopPropagation();
+ // e.preventDefault();
+ // } else
+ {
if (e.buttons === 1 && this.active) {
e.stopPropagation();
}
@@ -104,7 +105,7 @@ export class CollectionSchemaView extends CollectionViewBase {
let content;
if (this.selectedIndex != -1) {
content = (
- <DocumentView Document={children[this.selectedIndex]} DocumentView={undefined} ContainingCollectionView={this} />
+ <DocumentView Scaling={1} Document={children[this.selectedIndex]} DocumentView={undefined} ContainingCollectionView={this} />
)
} else {
content = <div />
@@ -119,7 +120,8 @@ export class CollectionSchemaView extends CollectionViewBase {
page={0}
showPagination={false}
style={{
- display: "inline-block"
+ display: "inline-block",
+ width: "100%"
}}
columns={columns.map(col => {
return (
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx
index 09e8ec729..e854d3077 100644
--- a/src/client/views/collections/CollectionViewBase.tsx
+++ b/src/client/views/collections/CollectionViewBase.tsx
@@ -16,6 +16,7 @@ export interface CollectionViewProps {
CollectionFieldKey: Key;
DocumentForCollection: Document;
ContainingDocumentView: Opt<DocumentView>;
+ BackgroundView: Opt<DocumentView>;
}
export const COLLECTION_BORDER_WIDTH = 2;
diff --git a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
index 1d53cedc4..a183db828 100644
--- a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
+++ b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
@@ -48,7 +48,7 @@ export class CollectionFreeFormDocumentView extends DocumentView {
@computed
get transform(): string {
- return `translate(${this.x}px, ${this.y}px)`;
+ return `scale(${this.props.Scaling}, ${this.props.Scaling}) translate(${this.x}px, ${this.y}px)`;
}
@computed
@@ -207,6 +207,7 @@ export class CollectionFreeFormDocumentView extends DocumentView {
var freestyling = this.props.ContainingCollectionView instanceof CollectionFreeFormView;
return (
<div className="node" ref={this._mainCont} style={{
+ transformOrigin: "left top",
transform: freestyling ? this.transform : "",
width: freestyling ? this.width : "100%",
height: freestyling ? this.height : "100%",
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 730ce62f2..bba5becc3 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -21,6 +21,7 @@ export interface DocumentViewProps {
Document: Document;
DocumentView: Opt<DocumentView> // needed only to set ContainingDocumentView on CollectionViewProps when invoked from JsxParser -- is there a better way?
ContainingCollectionView: Opt<CollectionViewBase>;
+ Scaling: number;
}
@observer
export class DocumentView extends React.Component<DocumentViewProps> {
@@ -35,6 +36,11 @@ export class DocumentView extends React.Component<DocumentViewProps> {
}
@computed
+ get annotatedlayout(): string {
+ return this.props.Document.GetData(KeyStore.AnnotatedLayout, TextField, String("<p>Error loading layout data</p>"));
+ }
+
+ @computed
get layoutKeys(): Key[] {
return this.props.Document.GetData(KeyStore.LayoutKeys, ListField, new Array<Key>());
}
@@ -51,7 +57,7 @@ export class DocumentView extends React.Component<DocumentViewProps> {
public get ScalingToScreenSpace(): number {
if (this.props.ContainingCollectionView != undefined &&
this.props.ContainingCollectionView.props.ContainingDocumentView != undefined) {
- let ss = this.props.ContainingCollectionView.props.DocumentForCollection.GetData(KeyStore.Scale, NumberField, Number(1));
+ let ss = this.props.ContainingCollectionView.props.DocumentForCollection.GetNumber(KeyStore.Scale, 1);
return this.props.ContainingCollectionView.props.ContainingDocumentView.ScalingToScreenSpace * ss;
}
return 1;
@@ -81,7 +87,7 @@ export class DocumentView extends React.Component<DocumentViewProps> {
Yy = ry - COLLECTION_BORDER_WIDTH;
}
- let Ss = this.props.Document.GetData(KeyStore.Scale, NumberField, Number(1));
+ let Ss = this.props.Document.GetNumber(KeyStore.Scale, 1);
let Panxx = this.props.Document.GetData(KeyStore.PanX, NumberField, Number(0));
let Panyy = this.props.Document.GetData(KeyStore.PanY, NumberField, Number(0));
let LocalX = (ContainerX - (Xx + Panxx)) / Ss;
@@ -115,7 +121,7 @@ export class DocumentView extends React.Component<DocumentViewProps> {
// first transform the local point into the parent collection's coordinate space.
let containingDocView = this.props.ContainingCollectionView != undefined ? this.props.ContainingCollectionView.props.ContainingDocumentView : undefined;
if (containingDocView != undefined) {
- let ss = containingDocView.props.Document.GetData(KeyStore.Scale, NumberField, Number(1));
+ let ss = containingDocView.props.Document.GetNumber(KeyStore.Scale, 1) * this.props.Scaling;
let panxx = containingDocView.props.Document.GetData(KeyStore.PanX, NumberField, Number(0)) + COLLECTION_BORDER_WIDTH * ss;
let panyy = containingDocView.props.Document.GetData(KeyStore.PanY, NumberField, Number(0)) + COLLECTION_BORDER_WIDTH * ss;
let { ScreenX, ScreenY } = containingDocView.TransformToScreenPoint(parentX, parentY, ss, panxx, panyy);
@@ -138,6 +144,14 @@ export class DocumentView extends React.Component<DocumentViewProps> {
if (bindings.DocumentView === undefined) {
bindings.DocumentView = this; // set the DocumentView to this if it hasn't already been set by a sub-class during its render method.
}
+ var annotated = <JsxParser
+ components={{ FormattedTextBox: FormattedTextBox, ImageBox, CollectionFreeFormView, CollectionDockingView, CollectionSchemaView }}
+ bindings={bindings}
+ jsx={this.annotatedlayout}
+ showWarnings={true}
+ onError={(test: any) => { console.log(test) }}
+ />;
+ bindings["BackgroundView"] = this.annotatedlayout ? annotated : null;
return (
<div className="node" ref={this._mainCont} style={{ width: "100%", height: "100%", }}>
<JsxParser
diff --git a/src/client/views/nodes/ImageBox.scss b/src/client/views/nodes/ImageBox.scss
index 136fda1d0..83392311b 100644
--- a/src/client/views/nodes/ImageBox.scss
+++ b/src/client/views/nodes/ImageBox.scss
@@ -1,6 +1,7 @@
.imageBox-cont {
padding: 0vw;
+ position: absolute
}
.imageBox-button {
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index ab20f140c..b96e717ed 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -9,7 +9,8 @@ import { FieldViewProps, FieldView } from './FieldView';
import { CollectionFreeFormDocumentView } from './CollectionFreeFormDocumentView';
import { FieldWaiting } from '../../../fields/Field';
import { observer } from "mobx-react"
-import { observable, action } from 'mobx';
+import { observable, action, spy } from 'mobx';
+import { KeyStore } from '../../../fields/Key';
@observer
export class ImageBox extends React.Component<FieldViewProps> {
@@ -67,7 +68,9 @@ export class ImageBox extends React.Component<FieldViewProps> {
mainSrc={images[this._photoIndex]}
nextSrc={images[(this._photoIndex + 1) % images.length]}
prevSrc={images[(this._photoIndex + images.length - 1) % images.length]}
- onCloseRequest={() => this.setState({ isOpen: false })}
+ onCloseRequest={action(() =>
+ this._isOpen = false
+ )}
onMovePrevRequest={action(() =>
this._photoIndex = (this._photoIndex + images.length - 1) % images.length
)}
@@ -82,10 +85,11 @@ export class ImageBox extends React.Component<FieldViewProps> {
let field = this.props.doc.Get(this.props.fieldKey);
let path = field == FieldWaiting ? "https://image.flaticon.com/icons/svg/66/66163.svg" :
field instanceof ImageField ? field.Data.href : "http://www.cs.brown.edu/~bcz/face.gif";
+ let width = this.props.doc.GetNumber(KeyStore.Width, 1);
return (
<div className="imageBox-cont" onPointerDown={this.onPointerDown} ref={this._ref} >
- <img src={path} width="100%" alt="Image not found" />
+ <img src={path} width={width} alt="Image not found" />
{this.lightbox(path)}
</div>)
}
diff --git a/src/fields/Key.ts b/src/fields/Key.ts
index 993102613..67a5f86fb 100644
--- a/src/fields/Key.ts
+++ b/src/fields/Key.ts
@@ -42,11 +42,14 @@ export namespace KeyStore {
export const PanX = new Key("PanX");
export const PanY = new Key("PanY");
export const Scale = new Key("Scale");
+ export const NativeWidth = new Key("NativeWidth");
export const Width = new Key("Width");
export const Height = new Key("Height");
export const ZIndex = new Key("ZIndex");
export const Data = new Key("Data");
+ export const Annotations = new Key("Annotations");
export const Layout = new Key("Layout");
+ export const AnnotatedLayout = new Key("AnnotatedLayout");
export const LayoutKeys = new Key("LayoutKeys");
export const LayoutFields = new Key("LayoutFields");
export const ColumnsKey = new Key("SchemaColumns");