diff options
author | bob <bcz@cs.brown.edu> | 2020-01-23 18:43:53 -0500 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2020-01-23 18:43:53 -0500 |
commit | 846e1c7eba28f042509ec84c31afe2bcbb5a2283 (patch) | |
tree | db437ee134566925173456d19aeb2b1a6fbaf61b | |
parent | c23d9ba83c87511a626bfe8d1da5dd981e311262 (diff) |
imagebox fixes
-rw-r--r-- | src/client/documents/Documents.ts | 2 | ||||
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 4 | ||||
-rw-r--r-- | src/client/views/nodes/ImageBox.tsx | 12 |
3 files changed, 12 insertions, 6 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index c665a7fd3..88f48488a 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -703,7 +703,7 @@ export namespace Docs { created = Docs.Create.StackingDocument(DocListCast(field), resolved); layout = CollectionView.LayoutString; } else { - created = Docs.Create.TextDocument({ ...{ width: 200, height: 25, autoHeight: true }, ...resolved }); + created = Docs.Create.TextDocument({ ...{ _width: 200, _height: 25, autoHeight: true }, ...resolved }); layout = FormattedTextBox.LayoutString; } created.layout = layout?.(fieldKey); diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 5663e5e3c..120bc4fd1 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -524,8 +524,8 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu const batch = UndoManager.StartBatch("CustomViewClicked"); const customName = "layout-" + name; if (doc[customName] === undefined) { - const _width = NumCast(doc.width); - const _height = NumCast(doc.height); + const _width = NumCast(doc._width); + const _height = NumCast(doc._height); const options = { title: "data", _width, x: -_width / 2, y: - _height / 2, }; let fieldTemplate: Doc; diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx index 1a07c1598..7b06d323f 100644 --- a/src/client/views/nodes/ImageBox.tsx +++ b/src/client/views/nodes/ImageBox.tsx @@ -214,7 +214,7 @@ export class ImageBox extends DocAnnotatableComponent<FieldViewProps, ImageDocum _resized = ""; resize = (imgPath: string) => { - if (!this.dataDoc[this.props.fieldKey + "-nativeHeight"]) + if (!this.dataDoc[this.props.fieldKey + "-nativeHeight"]) { requestImageSize(imgPath) .then((size: any) => { const rotation = NumCast(this.dataDoc[this.props.fieldKey + "-rotation"]) % 180; @@ -225,13 +225,19 @@ export class ImageBox extends DocAnnotatableComponent<FieldViewProps, ImageDocum if (this.paths[NumCast(this.props.Document.curPage)] === imgPath && (!this.layoutDoc.isTemplateDoc || this.dataDoc !== this.layoutDoc)) { this._resized = imgPath; this.Document._height = this.Document[WidthSym]() * aspect; - this.dataDoc[this.props.fieldKey + "-nativeHeight"] = this.dataDoc._nativeHeight = realsize.height; - this.dataDoc[this.props.fieldKey + "-nativeWidth"] = this.dataDoc._nativeWidth = realsize.width; + this.dataDoc[this.props.fieldKey + "-nativeHeight"] = this.Document._nativeHeight = realsize.height; + this.dataDoc[this.props.fieldKey + "-nativeWidth"] = this.Document._nativeWidth = realsize.width; } }), 0); } else this._resized = imgPath; }) .catch((err: any) => console.log(err)); + } else { + setTimeout(() => { + this.Document._nativeHeight = NumCast(this.dataDoc[this.props.fieldKey + "-nativeHeight"]); + this.Document._nativeWidth = NumCast(this.dataDoc[this.props.fieldKey + "-nativeWidth"]); + }, 0); + } } @action |