aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/TabDocView.tsx
diff options
context:
space:
mode:
authorusodhi <61431818+usodhi@users.noreply.github.com>2021-02-18 16:31:21 -0500
committerusodhi <61431818+usodhi@users.noreply.github.com>2021-02-18 16:31:21 -0500
commitec18ae95005b9adc674a1ed6c3e976aa987ed7d2 (patch)
treeae991bbfad86ca6230a21c86b40c274e2cfe6607 /src/client/views/collections/TabDocView.tsx
parent546540013de0a7cb647f30f1fcb513ce52048b72 (diff)
parent0d59f6bc23c755c4eab2503add28699f5a5b1992 (diff)
merging
Diffstat (limited to 'src/client/views/collections/TabDocView.tsx')
-rw-r--r--src/client/views/collections/TabDocView.tsx34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx
index e1e1c8656..c1a1a6f04 100644
--- a/src/client/views/collections/TabDocView.tsx
+++ b/src/client/views/collections/TabDocView.tsx
@@ -14,6 +14,7 @@ import { Cast, NumCast, StrCast } from "../../../fields/Types";
import { TraceMobx } from '../../../fields/util';
import { emptyFunction, returnEmptyDoclist, returnFalse, returnTrue, setupMoveUpEvents, Utils } from "../../../Utils";
import { DocServer } from "../../DocServer";
+import { DocUtils } from '../../documents/Documents';
import { DocumentType } from '../../documents/DocumentTypes';
import { CurrentUserUtils } from '../../util/CurrentUserUtils';
import { DocumentManager } from '../../util/DocumentManager';
@@ -23,7 +24,7 @@ import { SnappingManager } from '../../util/SnappingManager';
import { Transform } from '../../util/Transform';
import { undoBatch, UndoManager } from "../../util/UndoManager";
import { LightboxView } from '../LightboxView';
-import { DocAfterFocusFunc, DocumentView, DocumentViewProps } from "../nodes/DocumentView";
+import { DocFocusOptions, DocumentView, DocumentViewProps } from "../nodes/DocumentView";
import { FieldViewProps } from '../nodes/FieldView';
import { PinProps, PresBox, PresMovement } from '../nodes/PresBox';
import { DefaultLayerProvider, DefaultStyleProvider, StyleLayers, StyleProp } from '../StyleProvider';
@@ -206,9 +207,9 @@ export class TabDocView extends React.Component<TabDocViewProps> {
const fieldKey = CollectionDockingView.Instance.props.fieldKey;
const sublists = DocListCast(dview[fieldKey]);
const tabs = Cast(sublists[0], Doc, null);
- const tabdocs = await DocListCastAsync(tabs.data);
+ const tabdocs = await DocListCastAsync(tabs?.data);
runInAction(() => {
- if (!tabdocs?.includes(curPres)) {
+ if (!pinProps?.hidePresBox && !tabdocs?.includes(curPres)) {
tabdocs?.push(curPres); // bcz: Argh! this is annoying. if multiple documents are pinned, this will get called multiple times before the presentation view is drawn. Thus it won't be in the tabdocs list and it will get created multple times. so need to explicilty add the presbox to the list of open tabs
CollectionDockingView.AddSplit(curPres, "right");
}
@@ -278,7 +279,10 @@ export class TabDocView extends React.Component<TabDocViewProps> {
case "close": return CollectionDockingView.CloseSplit(doc, locationParams);
case "fullScreen": return CollectionDockingView.OpenFullScreen(doc);
case "replace": return CollectionDockingView.ReplaceTab(doc, locationParams, this.stack);
- case "lightbox": return runInAction(() => LightboxView.LightboxDoc = doc) ? true : false;
+ case "lightbox": {
+ // TabDocView.PinDoc(doc, { hidePresBox: true });
+ return LightboxView.AddDocTab(doc, location);
+ }
case "inPlace":
case "add":
default:
@@ -333,7 +337,7 @@ export class TabDocView extends React.Component<TabDocViewProps> {
ScreenToLocalTransform={Transform.Identity}
renderDepth={0}
whenActiveChanged={emptyFunction}
- focus={emptyFunction}
+ focus={DocUtils.DefaultFocus}
styleProvider={TabDocView.miniStyleProvider}
layerProvider={undefined}
addDocTab={this.addDocTab}
@@ -341,7 +345,7 @@ export class TabDocView extends React.Component<TabDocViewProps> {
docFilters={CollectionDockingView.Instance.docFilters}
docRangeFilters={CollectionDockingView.Instance.docRangeFilters}
searchFilterDocs={CollectionDockingView.Instance.searchFilterDocs}
- fitContentsToDoc={true}
+ fitContentsToDoc={returnTrue}
/>
<div className="miniOverlay" onPointerDown={this.miniDown} >
<div className="miniThumb" style={{ width: `${miniWidth}% `, height: `${miniHeight}% `, left: `${miniLeft}% `, top: `${miniTop}% `, }} />
@@ -356,11 +360,25 @@ export class TabDocView extends React.Component<TabDocViewProps> {
</Tooltip>
</>;
}
- focusFunc = (doc: Doc, willZoom?: boolean, scale?: number, afterFocus?: DocAfterFocusFunc) => {
+ @action
+ focusFunc = (doc: Doc, options?: DocFocusOptions) => {
+ const vals = (!options?.originalTarget || options?.originalTarget === this._document) && this.view?.ComponentView?.freeformData?.(true);
+ if (vals && this._document) {
+ const focusSpeed = 1000;
+ this._document._panX = vals.panX;
+ this._document._panY = vals.panY;
+ this._document._viewScale = vals.scale;
+ this._document._viewTransition = `transform ${focusSpeed}ms`;
+ setTimeout(action(() => {
+ this._document!._viewTransition = undefined;
+ options?.afterFocus?.(false);
+ }), focusSpeed);
+ } else {
+ options?.afterFocus?.(false);
+ }
if (!this.tab.header.parent._activeContentItem || this.tab.header.parent._activeContentItem !== this.tab.contentItem) {
this.tab.header.parent.setActiveContentItem(this.tab.contentItem); // glr: Panning does not work when this is set - (this line is for trying to make a tab that is not topmost become topmost)
}
- afterFocus?.(false);
}
active = () => this._isActive;
ScreenToLocalTransform = () => {