aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/ImageBox.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-11-15 12:49:53 -0500
committerbobzel <zzzman@gmail.com>2022-11-15 12:49:53 -0500
commit19f317bd43a7cc8df0daf1c0642011cc8754e14b (patch)
tree8646b6a4a45ec877609e499a58c515010a6fa9d4 /src/client/views/nodes/ImageBox.tsx
parent6a6408b120c60a717efb90576e1f14d1ac2cde68 (diff)
made InPlace container tool button apply more settings to be more like a template. added followAllLInks flag. added image anchors to save pan zoom. added follow link button bar option for follow all links. added hideDecorations flag and property
Diffstat (limited to 'src/client/views/nodes/ImageBox.tsx')
-rw-r--r--src/client/views/nodes/ImageBox.tsx52
1 files changed, 44 insertions, 8 deletions
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index d0df41023..d67481b22 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -14,7 +14,7 @@ import { TraceMobx } from '../../../fields/util';
import { emptyFunction, OmitKeys, returnEmptyString, returnFalse, returnOne, setupMoveUpEvents, Utils } from '../../../Utils';
import { GooglePhotos } from '../../apis/google_docs/GooglePhotosClientUtils';
import { CognitiveServices, Confidence, Service, Tag } from '../../cognitive_services/CognitiveServices';
-import { DocUtils } from '../../documents/Documents';
+import { Docs, DocUtils } from '../../documents/Documents';
import { DocumentType } from '../../documents/DocumentTypes';
import { Networking } from '../../Network';
import { DragManager } from '../../util/DragManager';
@@ -49,21 +49,58 @@ export class ImageBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
return FieldView.LayoutString(ImageBox, fieldKey);
}
private _dropDisposer?: DragManager.DragDropDisposer;
+ private _transitioning: any; // timer for setting view spec properties
private _disposers: { [name: string]: IReactionDisposer } = {};
private _getAnchor: (savedAnnotations?: ObservableMap<number, HTMLDivElement[]>) => Opt<Doc> = () => undefined;
@observable _curSuffix = '';
@observable _uploadIcon = uploadIcons.idle;
+ @observable _focusViewScale: number | undefined = 1;
+ @observable _focusPanX: number | undefined = 0;
+ @observable _focusPanY: number | undefined = 0;
+ get viewScale() {
+ return this._focusViewScale || StrCast(this.layoutDoc._viewScale);
+ }
+ get panX() {
+ return this._focusPanX || StrCast(this.layoutDoc._panX);
+ }
+ get panY() {
+ return this._focusPanY || StrCast(this.layoutDoc._panY);
+ }
protected createDropTarget = (ele: HTMLDivElement) => {
this._dropDisposer?.();
ele && (this._dropDisposer = DragManager.MakeDropTarget(ele, this.drop.bind(this), this.props.Document));
};
- setViewSpec = (anchor: Doc, preview: boolean) => {}; // sets viewing information for a componentview, typically when following a link. 'preview' tells the view to use the values without writing to the document
+
+ @action
+ setViewSpec = (anchor: Doc, preview: boolean) => {
+ if (preview && anchor._viewScale !== undefined) {
+ this._focusViewScale = Cast(anchor._viewScale, 'number', null);
+ this._focusPanX = Cast(anchor._panX, 'number', null);
+ this._focusPanY = Cast(anchor._panX, 'number', null);
+ } else if (anchor._viewScale !== undefined) {
+ const smoothTime = NumCast(anchor.viewTransitionTime);
+ this.layoutDoc.viewTransition = `all ${smoothTime}ms`;
+ this.layoutDoc._panX = NumCast(anchor._panX, NumCast(this.layoutDoc._panY));
+ this.layoutDoc._panY = NumCast(anchor._panY, NumCast(this.layoutDoc._panX));
+ this.layoutDoc._viewScale = NumCast(anchor._viewScale, NumCast(this.layoutDoc._viewScale));
+ if (anchor.type === DocumentType.MARKER) {
+ this.dataDoc[this.annotationKey] = new List<Doc>(DocListCast(anchor._annotations));
+ }
+ clearTimeout(this._transitioning);
+ this._transitioning = setTimeout(() => (this.layoutDoc.viewTransition = undefined), smoothTime);
+ }
+ }; // sets viewing information for a componentview, typically when following a link. 'preview' tells the view to use the values without writing to the document
getAnchor = () => {
- const anchor = this._getAnchor?.(this._savedAnnotations);
- anchor && this.addDocument(anchor);
- return anchor ?? this.rootDoc;
+ const zoomedAnchor = () => Docs.Create.ImageanchorDocument({ viewTransitionTime: 1000, _viewScale: NumCast(this.layoutDoc._viewScale), _panX: NumCast(this.layoutDoc._panX), _panY: NumCast(this.layoutDoc._panY) });
+ const anchor = this._getAnchor?.(this._savedAnnotations) ?? (this.layoutDoc.viewScale ? zoomedAnchor() : undefined);
+ if (anchor) {
+ anchor._annotations = new List<Doc>(DocListCast(this.dataDoc[this.annotationKey]));
+ this.addDocument(anchor);
+ return anchor;
+ }
+ return this.rootDoc;
};
componentDidMount() {
@@ -90,6 +127,7 @@ export class ImageBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
}
componentWillUnmount() {
+ clearTimeout(this._transitioning);
Object.values(this._disposers).forEach(disposer => disposer?.());
}
@@ -283,9 +321,7 @@ export class ImageBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProp
setTimeout(
action(() => {
this._uploadIcon = idle;
- if (data) {
- dataDoc[this.fieldKey] = data;
- }
+ data && (dataDoc[this.fieldKey] = data);
}),
2000
);