aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/trails/PresBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/trails/PresBox.tsx')
-rw-r--r--src/client/views/nodes/trails/PresBox.tsx951
1 files changed, 500 insertions, 451 deletions
diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx
index 91fdb90fc..6b4f5e073 100644
--- a/src/client/views/nodes/trails/PresBox.tsx
+++ b/src/client/views/nodes/trails/PresBox.tsx
@@ -1,68 +1,45 @@
+/* eslint-disable jsx-a11y/no-static-element-interactions */
+/* eslint-disable jsx-a11y/click-events-have-key-events */
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Tooltip } from '@mui/material';
import { action, computed, IReactionDisposer, makeObservable, observable, ObservableSet, reaction, runInAction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
-import { Doc, DocListCast, Field, FieldResult, NumListCast, Opt, StrListCast } from '../../../../fields/Doc';
+import { lightOrDark, returnFalse, returnOne, setupMoveUpEvents, StopEvent } from '../../../../ClientUtils';
+import { Doc, DocListCast, Field, FieldResult, FieldType, NumListCast, Opt, StrListCast } from '../../../../fields/Doc';
import { Animation, DocData, TransitionTimer } from '../../../../fields/DocSymbols';
-import { Copy, Id } from '../../../../fields/FieldSymbols';
+import { Copy } from '../../../../fields/FieldSymbols';
import { InkField } from '../../../../fields/InkField';
import { List } from '../../../../fields/List';
import { ObjectField } from '../../../../fields/ObjectField';
import { listSpec } from '../../../../fields/Schema';
import { ComputedField, ScriptField } from '../../../../fields/ScriptField';
-import { BoolCast, Cast, DocCast, NumCast, StrCast } from '../../../../fields/Types';
-import { AudioField } from '../../../../fields/URLField';
-import { emptyFunction, emptyPath, lightOrDark, returnFalse, returnOne, setupMoveUpEvents, StopEvent, stringHash } from '../../../../Utils';
+import { BoolCast, Cast, DocCast, NumCast, StrCast, toList } from '../../../../fields/Types';
+import { emptyFunction, emptyPath, stringHash } from '../../../../Utils';
import { DocServer } from '../../../DocServer';
import { Docs } from '../../../documents/Documents';
import { CollectionViewType, DocumentType } from '../../../documents/DocumentTypes';
-import { DocumentManager } from '../../../util/DocumentManager';
-import { dropActionType } from '../../../util/DragManager';
+import { dropActionType } from '../../../util/DropActionTypes';
import { ScriptingGlobals } from '../../../util/ScriptingGlobals';
-import { SelectionManager } from '../../../util/SelectionManager';
import { SerializationHelper } from '../../../util/SerializationHelper';
-import { SettingsManager } from '../../../util/SettingsManager';
+import { SnappingManager } from '../../../util/SnappingManager';
import { undoBatch, UndoManager } from '../../../util/UndoManager';
import { CollectionDockingView } from '../../collections/CollectionDockingView';
-import { CollectionFreeFormView, MarqueeViewBounds } from '../../collections/collectionFreeForm';
-import { CollectionStackedTimeline } from '../../collections/CollectionStackedTimeline';
+import { CollectionFreeFormView } from '../../collections/collectionFreeForm';
+import { CollectionFreeFormPannableContents } from '../../collections/collectionFreeForm/CollectionFreeFormPannableContents';
import { CollectionView } from '../../collections/CollectionView';
import { TreeView } from '../../collections/TreeView';
import { ViewBoxBaseComponent } from '../../DocComponent';
import { Colors } from '../../global/globalEnums';
import { LightboxView } from '../../LightboxView';
-import { DocumentView, OpenWhere, OpenWhereMod } from '../DocumentView';
-import { FieldView, FieldViewProps, FocusViewOptions } from '../FieldView';
+import { pinDataTypes as dataTypes } from '../../PinFuncs';
+import { DocumentView } from '../DocumentView';
+import { FieldView, FieldViewProps } from '../FieldView';
+import { FocusViewOptions } from '../FocusViewOptions';
+import { OpenWhere, OpenWhereMod } from '../OpenWhere';
import { ScriptingBox } from '../ScriptingBox';
import './PresBox.scss';
import { PresEffect, PresEffectDirection, PresMovement, PresStatus } from './PresEnums';
-export interface pinDataTypes {
- scrollable?: boolean;
- dataviz?: number[];
- pannable?: boolean;
- type_collection?: boolean;
- inkable?: boolean;
- filters?: boolean;
- pivot?: boolean;
- temporal?: boolean;
- clippable?: boolean;
- datarange?: boolean;
- dataview?: boolean;
- poslayoutview?: boolean;
- dataannos?: boolean;
- map?: boolean;
-}
-export interface PinProps {
- audioRange?: boolean;
- activeFrame?: number;
- currentFrame?: number;
- hidePresBox?: boolean;
- pinViewport?: MarqueeViewBounds; // pin a specific viewport on a freeform view (use MarqueeView.CurViewBounds to compute if no region has been selected)
- pinDocLayout?: boolean; // pin layout info (width/height/x/y)
- pinAudioPlay?: boolean; // pin audio annotation
- pinData?: pinDataTypes;
-}
@observer
export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@@ -75,8 +52,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
super(props);
makeObservable(this);
if (!PresBox.navigateToDocScript) {
- PresBox.navigateToDocScript = ScriptField.MakeFunction('navigateToDoc(this.presentation_targetDoc, self)')!;
+ PresBox.navigateToDocScript = ScriptField.MakeFunction('navigateToDoc(this.presentation_targetDoc, this)')!;
}
+ CollectionFreeFormPannableContents.SetOverlayPlugin((fform: Doc) => PresBox.Instance.pathLines(fform));
}
private _disposers: { [name: string]: IReactionDisposer } = {};
@@ -86,6 +64,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
_unmounting = false; // flag that view is unmounting used to block RemFromMap from deleting things
_presTimer: NodeJS.Timeout | undefined;
+ // eslint-disable-next-line no-use-before-define
@observable public static Instance: PresBox;
@observable _isChildActive = false;
@@ -126,7 +105,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
return DocCast(this.childDocs[NumCast(this.Document._itemIndex)]);
}
@computed get targetDoc() {
- return Cast(this.activeItem?.presentation_targetDoc, Doc, null);
+ return DocCast(this.activeItem?.presentation_targetDoc);
}
public static targetRenderedDoc = (doc: Doc) => {
const targetDoc = Cast(doc?.presentation_targetDoc, Doc, null);
@@ -141,8 +120,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
return false;
}
@computed get selectedDocumentView() {
- if (SelectionManager.Views.length) return SelectionManager.Views[0];
- if (this.selectedArray.size) return DocumentManager.Instance.getDocumentView(this.Document);
+ if (DocumentView.Selected().length) return DocumentView.Selected()[0];
+ if (this.selectedArray.size) return DocumentView.getDocumentView(this.Document);
+ return undefined;
}
@computed get isPres() {
return this.selectedDoc === this.Document;
@@ -165,6 +145,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
componentDidMount() {
+ this._disposers.pause = reaction(
+ () => SnappingManager.UserPanned,
+ () => this.pauseAutoPres()
+ );
this._disposers.keyboard = reaction(
() => this.selectedDoc,
selected => {
@@ -189,7 +173,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this._unmounting = false;
this.turnOffEdit(true);
this._disposers.selection = reaction(
- () => SelectionManager.Views.slice(),
+ () => DocumentView.Selected().slice(),
views => (!PresBox.Instance || views.some(view => view.Document === this.Document)) && this.updateCurrentPresentation(),
{ fireImmediately: true }
);
@@ -197,7 +181,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
() => this.layoutDoc.presentation_status === PresStatus.Edit,
editing => editing &&
this.childDocs.filter(doc => doc.presentation_indexed !== undefined).forEach(doc => {
- this.progressivizedItems(doc)?.forEach(indexedDoc => (indexedDoc.opacity = undefined));
+ this.progressivizedItems(doc)?.forEach(indexedDoc => { indexedDoc.opacity = undefined; });
doc.presentation_indexed = Math.min(this.progressivizedItems(doc)?.length ?? 0, 1);
}) // prettier-ignore
);
@@ -214,7 +198,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
startTempMedia = (targetDoc: Doc, activeItem: Doc) => {
const duration: number = NumCast(activeItem.config_clipEnd) - NumCast(activeItem.config_clipStart);
if ([DocumentType.VID, DocumentType.AUDIO].includes(targetDoc.type as any)) {
- const targMedia = DocumentManager.Instance.getDocumentView(targetDoc);
+ const targMedia = DocumentView.getDocumentView(targetDoc);
targMedia?.ComponentView?.playFrom?.(NumCast(activeItem.config_clipStart), NumCast(activeItem.config_clipStart) + duration);
}
};
@@ -222,18 +206,18 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
stopTempMedia = (targetDocField: FieldResult) => {
const targetDoc = DocCast(DocCast(targetDocField).annotationOn) ?? DocCast(targetDocField);
if ([DocumentType.VID, DocumentType.AUDIO].includes(targetDoc.type as any)) {
- const targMedia = DocumentManager.Instance.getDocumentView(targetDoc);
+ const targMedia = DocumentView.getDocumentView(targetDoc);
targMedia?.ComponentView?.Pause?.();
}
};
- //TODO: al: it seems currently that tempMedia doesn't stop onslidechange after clicking the button; the time the tempmedia stop depends on the start & end time
+ // TODO: al: it seems currently that tempMedia doesn't stop onslidechange after clicking the button; the time the tempmedia stop depends on the start & end time
// TODO: to handle child slides (entering into subtrail and exiting), also the next() and back() functions
// No more frames in current doc and next slide is defined, therefore move to next slide
nextSlide = (slideNum?: number) => {
const nextSlideInd = slideNum ?? this.itemIndex + 1;
let curSlideInd = nextSlideInd;
- //CollectionStackedTimeline.CurrentlyPlaying?.map(clipView => clipView?.ComponentView?.Pause?.());
+ // CollectionStackedTimeline.CurrentlyPlaying?.map(clipView => clipView?.ComponentView?.Pause?.());
this.clearSelectedArray();
const doGroupWithUp =
(nextSelected: number, force = false) =>
@@ -245,7 +229,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
if (serial) {
this.gotoDocument(nextSelected, this.activeItem, true, async () => {
const waitTime = NumCast(this.activeItem.presentation_duration);
- await new Promise<void>(res => setTimeout(() => res(), Math.max(0, waitTime)));
+ await new Promise<void>(res => {
+ setTimeout(res, Math.max(0, waitTime));
+ });
doGroupWithUp(nextSelected + 1)();
});
} else {
@@ -264,14 +250,15 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const targetList = PresBox.targetRenderedDoc(doc);
if (doc.presentation_indexed !== undefined && targetList) {
const listItems = (Cast(targetList[Doc.LayoutFieldKey(targetList)], listSpec(Doc), null)?.filter(d => d instanceof Doc) as Doc[]) ?? DocListCast(targetList[Doc.LayoutFieldKey(targetList) + '_annotations']);
- return listItems.filter(doc => !doc.layout_unrendered);
+ return listItems.filter(ldoc => !ldoc.layout_unrendered);
}
+ return undefined;
};
// go to documents chain
runSubroutines = (childrenToRun: Opt<Doc[]>, normallyNextSlide: Doc) => {
if (childrenToRun && childrenToRun[0] !== normallyNextSlide) {
- childrenToRun.forEach(child => DocumentManager.Instance.showDocument(child, {}));
+ childrenToRun.forEach(child => DocumentView.showDocument(child, {}));
}
};
@@ -284,12 +271,14 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const targetRenderedDoc = PresBox.targetRenderedDoc(this.activeItem);
targetRenderedDoc._dataTransition = 'all 1s';
targetRenderedDoc.opacity = 1;
- setTimeout(() => (targetRenderedDoc._dataTransition = 'inherit'), 1000);
+ setTimeout(() => {
+ targetRenderedDoc._dataTransition = 'inherit';
+ }, 1000);
const listItems = this.progressivizedItems(this.activeItem);
if (listItems && presIndexed < listItems.length) {
if (!first) {
const listItemDoc = listItems[presIndexed];
- const targetView = listItems && DocumentManager.Instance.getFirstDocumentView(listItemDoc);
+ const targetView = listItems && DocumentView.getFirstDocumentView(listItemDoc);
Doc.linkFollowUnhighlight();
Doc.HighlightDoc(listItemDoc);
listItemDoc.presentation_effect = this.activeItem.presBulletEffect;
@@ -305,6 +294,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
return true;
}
}
+ return undefined;
};
if (progressiveReveal(false)) return true;
if (this.childDocs[this.itemIndex + 1] !== undefined) {
@@ -314,7 +304,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
// before moving onto next slide, run the subroutines :)
const currentDoc = this.childDocs[this.itemIndex];
- //could i do this.childDocs[this.itemIndex] for first arg?
+ // could i do this.childDocs[this.itemIndex] for first arg?
this.runSubroutines(TreeView.GetRunningChildren.get(currentDoc)?.(), this.childDocs[this.itemIndex + 1]);
this.nextSlide(curLast + 1 === this.childDocs.length ? (this.layoutDoc.presLoop ? 0 : curLast) : curLast + 1);
@@ -334,7 +324,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
// Called when the user activates 'back' - to move to the previous part of the pres. trail
@action
back = () => {
- const activeItem: Doc = this.activeItem;
+ const { activeItem } = this;
let prevSelected = this.itemIndex;
// Functionality for group with up
let didZoom = activeItem.presentation_movement;
@@ -353,8 +343,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
return this.itemIndex;
};
- //The function that is called when a document is clicked or reached through next or back.
- //it'll also execute the necessary actions if presentation is playing.
+ // The function that is called when a document is clicked or reached through next or back.
+ // it'll also execute the necessary actions if presentation is playing.
@undoBatch
public gotoDocument = action((index: number, from?: Doc, group?: boolean, finished?: () => void) => {
Doc.UnBrushAllDocs();
@@ -371,13 +361,13 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.startTempMedia(this.targetDoc, this.activeItem);
}
if (!group) this.clearSelectedArray();
- this.childDocs[index] && this.addToSelectedArray(this.childDocs[index]); //Update selected array
+ this.childDocs[index] && this.addToSelectedArray(this.childDocs[index]); // Update selected array
this.turnOffEdit();
- this.navigateToActiveItem(finished); //Handles movement to element only when presentationTrail is list
- this.doHideBeforeAfter(); //Handles hide after/before
+ this.navigateToActiveItem(finished); // Handles movement to element only when presentationTrail is list
+ this.doHideBeforeAfter(); // Handles hide after/before
}
});
- static pinDataTypes(target?: Doc): pinDataTypes {
+ static pinDataTypes(target?: Doc): dataTypes {
const targetType = target?.type as any;
const inkable = [DocumentType.INK].includes(targetType);
const scrollable = [DocumentType.PDF, DocumentType.RTF, DocumentType.WEB].includes(targetType) || target?._type_collection === CollectionViewType.Stacking;
@@ -388,19 +378,22 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const datarange = [DocumentType.FUNCPLOT].includes(targetType);
const dataview = [DocumentType.INK, DocumentType.COL, DocumentType.IMG, DocumentType.RTF].includes(targetType) && target?.activeFrame === undefined;
const poslayoutview = [DocumentType.COL].includes(targetType) && target?.activeFrame === undefined;
- const type_collection = targetType === DocumentType.COL;
+ const typeCollection = targetType === DocumentType.COL;
const filters = true;
const pivot = true;
const dataannos = false;
- return { scrollable, pannable, inkable, type_collection, pivot, map, filters, temporal, clippable, dataview, datarange, poslayoutview, dataannos };
+ return { scrollable, pannable, inkable, type_collection: typeCollection, pivot, map, filters, temporal, clippable, dataview, datarange, poslayoutview, dataannos };
}
@action
- playAnnotation = (anno: AudioField) => {};
+ playAnnotation = (/* anno: AudioField */) => {
+ /* empty */
+ };
@action
- static restoreTargetDocView(bestTargetView: Opt<DocumentView>, activeItem: Doc, transTime: number, pinDocLayout: boolean = BoolCast(activeItem.config_pinLayout), pinDataTypes?: pinDataTypes, targetDoc?: Doc) {
+ // eslint-disable-next-line default-param-last
+ static restoreTargetDocView(bestTargetView: Opt<DocumentView>, activeItem: Doc, transTime: number, pinDocLayout: boolean = BoolCast(activeItem.config_pinLayout), pinDataTypes?: dataTypes, targetDoc?: Doc) {
const bestTarget = bestTargetView?.Document ?? (targetDoc?.layout_unrendered ? DocCast(targetDoc?.annotationOn) : targetDoc);
- if (!bestTarget) return;
+ if (!bestTarget) return undefined;
let changed = false;
if (pinDocLayout) {
if (
@@ -417,20 +410,22 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
bestTarget.width = NumCast(activeItem.config_width, NumCast(bestTarget.width));
bestTarget.height = NumCast(activeItem.config_height, NumCast(bestTarget.height));
bestTarget[TransitionTimer] && clearTimeout(bestTarget[TransitionTimer]);
- bestTarget[TransitionTimer] = setTimeout(() => (bestTarget[TransitionTimer] = bestTarget._dataTransition = undefined), transTime + 10);
+ bestTarget[TransitionTimer] = setTimeout(() => {
+ bestTarget[TransitionTimer] = bestTarget._dataTransition = undefined;
+ }, transTime + 10);
changed = true;
}
}
const activeFrame = activeItem.config_activeFrame ?? activeItem.config_currentFrame;
if (activeFrame !== undefined) {
- const transTime = NumCast(activeItem.presentation_transition, 500);
+ const frameTime = NumCast(activeItem.presentation_transition, 500);
const acontext = activeItem.config_activeFrame !== undefined ? DocCast(DocCast(activeItem.presentation_targetDoc).embedContainer) : DocCast(activeItem.presentation_targetDoc);
const context = DocCast(acontext)?.annotationOn ? DocCast(DocCast(acontext).annotationOn) : acontext;
if (context) {
- const ffview = DocumentManager.Instance.getFirstDocumentView(context)?.CollectionFreeFormView;
+ const ffview = CollectionFreeFormView.from(DocumentView.getFirstDocumentView(context));
if (ffview?.childDocs) {
- PresBox.Instance._keyTimer = CollectionFreeFormView.gotoKeyframe(PresBox.Instance._keyTimer, ffview.childDocs, transTime);
+ PresBox.Instance._keyTimer = CollectionFreeFormView.gotoKeyframe(PresBox.Instance._keyTimer, ffview.childDocs, frameTime);
ffview.layoutDoc._currentFrame = NumCast(activeFrame);
}
}
@@ -443,12 +438,14 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
else {
const bestTargetData = bestTarget[DocData];
const current = bestTargetData[fkey];
- const hash = bestTargetData[fkey] ? stringHash(Field.toString(bestTargetData[fkey] as Field)) : undefined;
+ const hash = bestTargetData[fkey] ? stringHash(Field.toString(bestTargetData[fkey] as FieldType)) : undefined;
if (hash) bestTargetData[fkey + '_' + hash] = current instanceof ObjectField ? current[Copy]() : current;
bestTargetData[fkey] = activeItem.config_data instanceof ObjectField ? activeItem.config_data[Copy]() : activeItem.config_data;
}
bestTarget[fkey + '_usePath'] = activeItem.config_usePath;
- setTimeout(() => (bestTarget._dataTransition = undefined), transTime + 10);
+ setTimeout(() => {
+ bestTarget._dataTransition = undefined;
+ }, transTime + 10);
}
if (pinDataTypes?.datarange || (!pinDataTypes && activeItem.config_xRange !== undefined)) {
if (bestTarget.xRange !== activeItem.config_xRange) {
@@ -590,7 +587,15 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
Doc.AddDocToList(bestTarget[DocData], layoutField, doc);
}
});
- setTimeout(() => Array.from(transitioned).forEach(action(doc => (doc._dataTransition = undefined))), transTime + 10);
+ setTimeout(
+ () =>
+ Array.from(transitioned).forEach(
+ action(doc => {
+ doc._dataTransition = undefined;
+ })
+ ),
+ transTime + 10
+ );
}
if ((pinDataTypes?.pannable || (!pinDataTypes && (activeItem.config_viewBounds !== undefined || activeItem.config_panX !== undefined || activeItem.config_viewScale !== undefined))) && !bestTarget.isGroup) {
const contentBounds = Cast(activeItem.config_viewBounds, listSpec('number'));
@@ -598,132 +603,24 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const viewport = { panX: (contentBounds[0] + contentBounds[2]) / 2, panY: (contentBounds[1] + contentBounds[3]) / 2, width: contentBounds[2] - contentBounds[0], height: contentBounds[3] - contentBounds[1] };
bestTarget._freeform_panX = viewport.panX;
bestTarget._freeform_panY = viewport.panY;
- const dv = DocumentManager.Instance.getDocumentView(bestTarget);
+ const dv = DocumentView.getDocumentView(bestTarget);
if (dv) {
changed = true;
const computedScale = NumCast(activeItem.config_zoom, 1) * Math.min(dv._props.PanelWidth() / viewport.width, dv._props.PanelHeight() / viewport.height);
activeItem.presentation_movement === PresMovement.Zoom && (bestTarget._freeform_scale = computedScale);
dv.ComponentView?.brushView?.(viewport, transTime, 2500);
}
- } else {
- if (bestTarget._freeform_panX !== activeItem.config_panX || bestTarget._freeform_panY !== activeItem.config_panY || bestTarget._freeform_scale !== activeItem.config_viewScale) {
- bestTarget._freeform_panX = activeItem.config_panX ?? bestTarget._freeform_panX;
- bestTarget._freeform_panY = activeItem.config_panY ?? bestTarget._freeform_panY;
- bestTarget._freeform_scale = activeItem.config_viewScale ?? bestTarget._freeform_scale;
- changed = true;
- }
+ } else if (bestTarget._freeform_panX !== activeItem.config_panX || bestTarget._freeform_panY !== activeItem.config_panY || bestTarget._freeform_scale !== activeItem.config_viewScale) {
+ bestTarget._freeform_panX = activeItem.config_panX ?? bestTarget._freeform_panX;
+ bestTarget._freeform_panY = activeItem.config_panY ?? bestTarget._freeform_panY;
+ bestTarget._freeform_scale = activeItem.config_viewScale ?? bestTarget._freeform_scale;
+ changed = true;
}
}
if (changed) {
return bestTargetView?.setViewTransition('all', transTime);
}
- }
-
- /// copies values from the targetDoc (which is the prototype of the pinDoc) to
- /// reserved fields on the pinDoc so that those values can be restored to the
- /// target doc when navigating to it.
- @action
- static pinDocView(pinDoc: Doc, pinProps: PinProps, targetDoc: Doc) {
- pinDoc.presentation = true;
- pinDoc.config = '';
- if (pinProps.pinDocLayout) {
- pinDoc.config_pinLayout = true;
- pinDoc.config_x = NumCast(targetDoc.x);
- pinDoc.config_y = NumCast(targetDoc.y);
- pinDoc.config_rotation = NumCast(targetDoc.rotation);
- pinDoc.config_width = NumCast(targetDoc.width);
- pinDoc.config_height = NumCast(targetDoc.height);
- }
- if (pinProps.pinAudioPlay) pinDoc.presPlayAudio = true;
- if (pinProps.pinData) {
- pinDoc.config_pinData =
- pinProps.pinData.scrollable ||
- pinProps.pinData.temporal ||
- pinProps.pinData.pannable ||
- pinProps.pinData.type_collection ||
- pinProps.pinData.clippable ||
- pinProps.pinData.datarange ||
- pinProps.pinData.dataview ||
- pinProps.pinData.poslayoutview ||
- pinProps?.activeFrame !== undefined;
- const fkey = Doc.LayoutFieldKey(targetDoc);
- if (pinProps.pinData.dataview) {
- pinDoc.config_usePath = targetDoc[fkey + '_usePath'];
- pinDoc.config_data = targetDoc[fkey] instanceof ObjectField ? (targetDoc[fkey] as ObjectField)[Copy]() : targetDoc.data;
- }
- if (pinProps.pinData.dataannos) {
- const fkey = Doc.LayoutFieldKey(targetDoc);
- pinDoc.config_annotations = new List<Doc>(DocListCast(targetDoc[DocData][fkey + '_annotations']).filter(doc => !doc.layout_unrendered));
- }
- if (pinProps.pinData.inkable) {
- pinDoc.config_fillColor = targetDoc.fillColor;
- pinDoc.config_color = targetDoc.color;
- pinDoc.config_width = targetDoc._width;
- pinDoc.config_height = targetDoc._height;
- }
- if (pinProps.pinData.scrollable) pinDoc.config_scrollTop = targetDoc._layout_scrollTop;
- if (pinProps.pinData.clippable) {
- const fkey = Doc.LayoutFieldKey(targetDoc);
- pinDoc.config_clipWidth = targetDoc[fkey + '_clipWidth'];
- }
- if (pinProps.pinData.datarange) {
- pinDoc.config_xRange = undefined; //targetDoc?.xrange;
- pinDoc.config_yRange = undefined; //targetDoc?.yrange;
- }
- if (pinProps.pinData.map) {
- // pinDoc.config_latitude = targetDoc?.latitude;
- // pinDoc.config_longitude = targetDoc?.longitude;
- pinDoc.config_map_zoom = targetDoc?.map_zoom;
- pinDoc.config_map_type = targetDoc?.map_type;
- //...
- }
- if (pinProps.pinData.poslayoutview)
- pinDoc.config_pinLayoutData = new List<string>(
- DocListCast(targetDoc[fkey] as ObjectField).map(d =>
- JSON.stringify({
- id: d[Id],
- x: NumCast(d.x),
- y: NumCast(d.y),
- w: NumCast(d._width),
- h: NumCast(d._height),
- fill: StrCast(d._fillColor),
- back: StrCast(d._backgroundColor),
- data: SerializationHelper.Serialize(d.data instanceof ObjectField ? d.data[Copy]() : ''),
- text: SerializationHelper.Serialize(d.text instanceof ObjectField ? d.text[Copy]() : ''),
- })
- )
- );
- if (pinProps.pinData.type_collection) pinDoc.config_viewType = targetDoc._type_collection;
- if (pinProps.pinData.filters) pinDoc.config_docFilters = ObjectField.MakeCopy(targetDoc.childFilters as ObjectField);
- if (pinProps.pinData.pivot) pinDoc.config_pivotField = targetDoc._pivotField;
- if (pinProps.pinData.pannable) {
- pinDoc.config_panX = NumCast(targetDoc._freeform_panX);
- pinDoc.config_panY = NumCast(targetDoc._freeform_panY);
- pinDoc.config_viewScale = NumCast(targetDoc._freeform_scale, 1);
- }
- if (pinProps.pinData.temporal) {
- pinDoc.config_clipStart = targetDoc._layout_currentTimecode;
- const duration = NumCast(pinDoc[`${Doc.LayoutFieldKey(pinDoc)}_duration`], NumCast(targetDoc.config_clipStart) + 0.1);
- pinDoc.config_clipEnd = NumCast(pinDoc.config_clipStart) + NumCast(targetDoc.clipEnd, duration);
- }
- }
- if (pinProps?.pinViewport) {
- // If pinWithView option set then update scale and x / y props of slide
- const bounds = pinProps.pinViewport;
- pinDoc.config_pinView = true;
- pinDoc.config_viewScale = NumCast(targetDoc._freeform_scale, 1);
- pinDoc.config_panX = bounds.left + bounds.width / 2;
- pinDoc.config_panY = bounds.top + bounds.height / 2;
- pinDoc.config_viewBounds = new List<number>([bounds.left, bounds.top, bounds.left + bounds.width, bounds.top + bounds.height]);
- }
- }
-
- @action
- static reversePin(pinDoc: Doc, targetDoc: Doc) {
- // const fkey = Doc.LayoutFieldKey(targetDoc);
- pinDoc.config_data = targetDoc.data;
-
- console.log(pinDoc.presData);
+ return undefined;
}
/**
@@ -735,8 +632,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
* on the right.
*/
navigateToActiveItem = (afterNav?: () => void) => {
- const activeItem: Doc = this.activeItem;
- const targetDoc: Doc = this.targetDoc;
+ const { activeItem, targetDoc } = this;
const finished = () => {
afterNav?.();
targetDoc[Animation] = undefined;
@@ -746,8 +642,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const eleViewCache = Array.from(this._eleArray);
const resetSelection = action(() => {
if (!this._props.isSelected()) {
- const presDocView = DocumentManager.Instance.getDocumentView(this.Document);
- if (presDocView) SelectionManager.SelectView(presDocView, false);
+ const presDocView = DocumentView.getDocumentView(this.Document);
+ if (presDocView) DocumentView.SelectView(presDocView, false);
this.clearSelectedArray();
selViewCache.forEach(doc => this.addToSelectedArray(doc));
this._dragArray.splice(0, this._dragArray.length, ...dragViewCache);
@@ -762,7 +658,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
static NavigateToTarget(targetDoc: Doc, activeItem: Doc, finished?: () => void) {
if (activeItem.presentation_movement === PresMovement.None && targetDoc.type === DocumentType.SCRIPTING) {
- (DocumentManager.Instance.getFirstDocumentView(targetDoc)?.ComponentView as ScriptingBox)?.onRun?.();
+ (DocumentView.getFirstDocumentView(targetDoc)?.ComponentView as ScriptingBox)?.onRun?.();
return;
}
const effect = activeItem.presentation_effect && activeItem.presentation_effect !== PresEffect.None ? activeItem.presentation_effect : undefined;
@@ -775,7 +671,6 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
effect: activeItem,
noSelect: true,
openLocation: targetDoc.type === DocumentType.PRES ? ((OpenWhere.replace + ':' + PresBox.PanelName) as OpenWhere) : OpenWhere.addLeft,
- anchorDoc: activeItem,
easeFunc: StrCast(activeItem.presEaseFunc, 'ease') as any,
zoomTextSelections: BoolCast(activeItem.presentation_zoomText),
playAudio: BoolCast(activeItem.presPlayAudio),
@@ -783,19 +678,19 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
};
if (activeItem.presentation_openInLightbox) {
const context = DocCast(targetDoc.annotationOn) ?? targetDoc;
- if (!DocumentManager.Instance.getLightboxDocumentView(context)) {
+ if (!DocumentView.getLightboxDocumentView(context)) {
LightboxView.Instance.SetLightboxDoc(context);
}
}
if (targetDoc) {
if (activeItem.presentation_targetDoc instanceof Doc) activeItem.presentation_targetDoc[Animation] = undefined;
- DocumentManager.Instance.AddViewRenderedCb(LightboxView.LightboxDoc, dv => {
+ DocumentView.addViewRenderedCb(LightboxView.LightboxDoc, () => {
// if target or the doc it annotates is not in the lightbox, then close the lightbox
- if (!DocumentManager.Instance.getLightboxDocumentView(DocCast(targetDoc.annotationOn) ?? targetDoc)) {
+ if (!DocumentView.getLightboxDocumentView(DocCast(targetDoc.annotationOn) ?? targetDoc)) {
LightboxView.Instance.SetLightboxDoc(undefined);
}
- DocumentManager.Instance.showDocument(targetDoc, options, finished);
+ DocumentView.showDocument(targetDoc, options, finished);
});
} else finished?.();
}
@@ -822,7 +717,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
opacity = 0;
} else if (index === this.itemIndex || !curDoc.presentation_hideAfter) {
opacity = 1;
- setTimeout(() => (tagDoc._dataTransition = undefined), 1000);
+ setTimeout(() => {
+ tagDoc._dataTransition = undefined;
+ }, 1000);
}
}
const hidingIndAft =
@@ -848,16 +745,20 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
};
_exitTrail: Opt<() => void>;
- PlayTrail = (docs: Doc[]) => {
+ playTrail = (docs: Doc[]) => {
const savedStates = docs.map(doc => {
switch (doc.type) {
case DocumentType.COL:
- if (doc._type_collection === CollectionViewType.Freeform) return { type: CollectionViewType.Freeform, doc, x: NumCast(doc.freeform_panX), y: NumCast(doc.freeform_panY), s: NumCast(doc.freeform_scale) };
+ if (doc._type_collection === CollectionViewType.Freeform) {
+ return { type: CollectionViewType.Freeform, doc, x: NumCast(doc.freeform_panX), y: NumCast(doc.freeform_panY), s: NumCast(doc.freeform_scale) };
+ }
break;
case DocumentType.INK:
if (doc.data instanceof InkField) {
return { type: doc.type, doc, data: doc.data?.[Copy](), fillColor: doc.fillColor, color: doc.color, x: NumCast(doc.x), y: NumCast(doc.y) };
}
+ break;
+ default:
}
return undefined;
});
@@ -865,7 +766,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this._exitTrail = () => {
savedStates
.filter(savedState => savedState)
- .map(savedState => {
+ .forEach(savedState => {
switch (savedState?.type) {
case CollectionViewType.Freeform:
{
@@ -885,6 +786,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
doc.color = color;
}
break;
+ default:
}
});
LightboxView.Instance.SetLightboxDoc(undefined);
@@ -903,8 +805,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
};
- //The function that resets the presentation by removing every action done by it. It also
- //stops the presentaton.
+ // The function that resets the presentation by removing every action done by it. It also
+ // stops the presentaton.
resetPresentation = () => {
this.childDocs
.map(doc => PresBox.targetRenderedDoc(doc))
@@ -921,12 +823,14 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
// The function allows for viewing the pres path on toggle
@action togglePath = (off?: boolean) => {
this._pathBoolean = off ? false : !this._pathBoolean;
- CollectionFreeFormView.ShowPresPaths = this._pathBoolean;
+ SnappingManager.SetShowPresPaths(this._pathBoolean);
};
// The function allows for expanding the view of pres on toggle
@action toggleExpandMode = () => {
- runInAction(() => (this._expandBoolean = !this._expandBoolean));
+ runInAction(() => {
+ this._expandBoolean = !this._expandBoolean;
+ });
this.Document.expandBoolean = this._expandBoolean;
this.childDocs.forEach(doc => {
doc.presentation_expandInlineButton = this._expandBoolean;
@@ -942,7 +846,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const startInd = NumCast(doc.presentation_indexedStart);
this.progressivizedItems(doc)
?.slice(startInd)
- .forEach(indexedDoc => (indexedDoc.opacity = 0));
+ .forEach(indexedDoc => {
+ indexedDoc.opacity = 0;
+ });
doc.presentation_indexed = Math.min(this.progressivizedItems(doc)?.length ?? 0, startInd);
}
// if (doc.presentation_hide && this.childDocs.indexOf(doc) === startIndex) tagDoc.opacity = 0;
@@ -993,13 +899,13 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
public static minimizedWidth = 198;
public static OpenPresMinimized(doc: Doc, pt: number[]) {
- doc.overlayX = pt[0];
- doc.overlayY = pt[1];
+ [doc.overlayX, doc.overlayY] = pt;
doc._height = 30;
doc._width = PresBox.minimizedWidth;
Doc.AddToMyOverlay(doc);
PresBox.Instance?.initializePresState(PresBox.Instance.itemIndex);
- return (doc.presentation_status = PresStatus.Manual);
+ doc.presentation_status = PresStatus.Manual;
+ return doc.presentation_status;
}
/**
@@ -1008,12 +914,11 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
*/
@undoBatch
viewChanged = action((e: React.ChangeEvent) => {
- //@ts-ignore
- const type_collection = e.target.selectedOptions[0].value as CollectionViewType;
- this.layoutDoc.presFieldKey = this.fieldKey + (type_collection === CollectionViewType.Tree ? '-linearized' : '');
+ const typeCollection = (e.target as any).selectedOptions[0].value as CollectionViewType;
+ this.layoutDoc.presFieldKey = this.fieldKey + (typeCollection === CollectionViewType.Tree ? '-linearized' : '');
// pivot field may be set by the user in timeline view (or some other way) -- need to reset it here
- [CollectionViewType.Tree || CollectionViewType.Stacking].includes(type_collection) && (this.Document._pivotField = undefined);
- this.Document._type_collection = type_collection;
+ [CollectionViewType.Tree || CollectionViewType.Stacking].includes(typeCollection) && (this.Document._pivotField = undefined);
+ this.Document._type_collection = typeCollection;
if (this.isTreeOrStack) {
this.layoutDoc._gridGap = 0;
}
@@ -1025,10 +930,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
*/
// @undoBatch
mediaStopChanged = action((e: React.ChangeEvent) => {
- const activeItem: Doc = this.activeItem;
- //@ts-ignore
- const stopDoc = e.target.selectedOptions[0].value as string;
- const stopDocIndex: number = Number(stopDoc[0]);
+ const { activeItem } = this;
+ const stopDoc = (e.target as any).selectedOptions[0].value as string;
+ const stopDocIndex = Number(stopDoc[0]);
activeItem.mediaStopDoc = stopDocIndex;
if (this.childDocs[stopDocIndex - 1].mediaStopTriggerList) {
const list = DocListCast(this.childDocs[stopDocIndex - 1].mediaStopTriggerList);
@@ -1049,10 +953,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
return StrCast(activeItem.presentation_movement);
});
- whenChildContentsActiveChanged = action((isActive: boolean) => this._props.whenChildContentsActiveChanged((this._isChildActive = isActive)));
+ whenChildContentsActiveChanged = action((isActive: boolean) => {
+ this._props.whenChildContentsActiveChanged((this._isChildActive = isActive));
+ });
// For dragging documents into the presentation trail
addDocumentFilter = (docs: Doc[]) => {
- docs.forEach((doc, i) => {
+ const results = docs.map(doc => {
if (doc.presentation_targetDoc) return true;
if (doc.type === DocumentType.LABEL) {
const audio = Cast(doc.annotationOn, Doc, null);
@@ -1065,17 +971,22 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
return false;
}
} else if (doc.type !== DocumentType.PRES) {
+ // eslint-disable-next-line operator-assignment
if (!doc.presentation_targetDoc) doc.title = doc.title + ' - Slide';
doc.presentation_targetDoc = doc.createdFrom ?? doc; // dropped document will be a new embedding of an embedded document somewhere else.
doc.presentation_movement = PresMovement.Zoom;
if (this._expandBoolean) doc.presentation_expandInlineButton = true;
}
+ return false;
});
- return true;
+ return !results.some(r => !r);
};
childLayoutTemplate = () => Docs.Create.PresElementBoxDocument();
- removeDocument = (doc: Doc | Doc[]) => !(doc instanceof Doc ? [doc] : doc).map(d => Doc.RemoveDocFromList(this.Document, this.fieldKey, d)).some(p => !p);
+ removeDocument = (doc: Doc | Doc[]) =>
+ !toList(doc)
+ .map(d => Doc.RemoveDocFromList(this.Document, this.fieldKey, d))
+ .some(p => !p);
getTransform = () => this.ScreenToLocalBoxXf().translate(-5, -65); // listBox padding-left and pres-box-cont minHeight
panelHeight = () => this._props.PanelHeight() - 40;
/**
@@ -1092,42 +1003,46 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const tagDoc = Cast(curDoc.presentation_targetDoc, Doc, null);
if (curDoc && curDoc === this.activeItem)
return (
+ // eslint-disable-next-line react/no-array-index-key
<div key={index} className="selectedList-items">
<b>
{index + 1}. {curDoc.title}
</b>
</div>
);
- else if (tagDoc)
+ if (tagDoc)
return (
+ // eslint-disable-next-line react/no-array-index-key
<div key={index} className="selectedList-items">
{index + 1}. {curDoc.title}
</div>
);
- else if (curDoc)
+ if (curDoc)
return (
+ // eslint-disable-next-line react/no-array-index-key
<div key={index} className="selectedList-items">
{index + 1}. {curDoc.title}
</div>
);
+ return null;
});
}
@action
selectPres = () => {
- const presDocView = DocumentManager.Instance.getDocumentView(this.Document);
- presDocView && SelectionManager.SelectView(presDocView, false);
+ const presDocView = DocumentView.getDocumentView(this.Document);
+ presDocView && DocumentView.SelectView(presDocView, false);
};
- focusElement = (doc: Doc, options: FocusViewOptions) => {
+ focusElement = (doc: Doc) => {
this.selectElement(doc);
return undefined;
};
- //Regular click
+ // Regular click
@action
selectElement = (doc: Doc, noNav = false) => {
- CollectionStackedTimeline.CurrentlyPlaying?.map((clip, i) => clip?.ComponentView?.Pause?.());
+ DocumentView.CurrentlyPlaying?.map(clip => clip?.ComponentView?.Pause?.());
if (noNav) {
const index = this.childDocs.indexOf(doc);
if (index >= 0 && index < this.childDocs.length) {
@@ -1139,7 +1054,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.updateCurrentPresentation(DocCast(doc.embedContainer));
};
- //Command click
+ // Command click
@action
multiSelect = (doc: Doc, ref: HTMLElement, drag: HTMLElement) => {
if (!this.selectedArray.has(doc)) {
@@ -1154,7 +1069,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.selectPres();
};
- //Shift click
+ // Shift click
@action
shiftSelect = (doc: Doc, ref: HTMLElement, drag: HTMLElement) => {
this.clearSelectedArray();
@@ -1169,7 +1084,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.selectPres();
};
- //regular click
+ // regular click
@action
regularSelect = (doc: Doc, ref: HTMLElement, drag: HTMLElement, noNav: boolean, selectPres = true) => {
this.clearSelectedArray();
@@ -1200,9 +1115,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
if (this.layoutDoc.presentation_status === 'edit') {
undoBatch(
action(() => {
- for (const doc of this.selectedArray) {
- this.removeDocument(doc);
- }
+ Array.from(this.selectedArray).forEach(doc => this.removeDocument(doc));
this.clearSelectedArray();
this._eleArray.length = 0;
this._dragArray.length = 0;
@@ -1269,8 +1182,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.childDocs.forEach(doc => this.addToSelectedArray(doc));
handled = true;
}
- default:
break;
+ default:
}
if (handled) {
e.stopPropagation();
@@ -1285,11 +1198,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const order: JSX.Element[] = [];
const docs = new Set<Doc>();
const presCollection = collection;
- const dv = DocumentManager.Instance.getDocumentView(presCollection);
+ const dv = DocumentView.getDocumentView(presCollection);
this.childDocs.forEach((doc, index) => {
const tagDoc = PresBox.targetRenderedDoc(doc);
const srcContext = Cast(tagDoc.embedContainer, Doc, null);
const labelCreator = (top: number, left: number, edge: number, fontSize: number) => (
+ // eslint-disable-next-line react/no-array-index-key
<div className="pathOrder" key={tagDoc.id + 'pres' + index} style={{ top, left, width: edge, height: edge, fontSize }} onClick={() => this.selectElement(doc)}>
<div className="pathOrder-frame">{index + 1}</div>
</div>
@@ -1322,7 +1236,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
order.push(
<>
{labelCreator(top - indEdge / 2, left - indEdge / 2, indEdge, indFontSize)}
- <div className="pathOrder-presPinView" style={{ top, left, width, height, borderWidth: indEdge / 10 }}></div>
+ <div className="pathOrder-presPinView" style={{ top, left, width, height, borderWidth: indEdge / 10 }} />
</>
);
}
@@ -1345,17 +1259,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
.filter(doc => PresBox.targetRenderedDoc(doc)?.embedContainer === collection)
.forEach((doc, index) => {
const tagDoc = PresBox.targetRenderedDoc(doc);
- if (tagDoc) {
- const n1x = NumCast(tagDoc.x) + NumCast(tagDoc._width) / 2;
- const n1y = NumCast(tagDoc.y) + NumCast(tagDoc._height) / 2;
- if ((index = 0)) pathPoints = n1x + ',' + n1y;
- else pathPoints = pathPoints + ' ' + n1x + ',' + n1y;
- } else if (doc.config_pinView) {
- const n1x = NumCast(doc.config_panX);
- const n1y = NumCast(doc.config_panY);
- if ((index = 0)) pathPoints = n1x + ',' + n1y;
- else pathPoints = pathPoints + ' ' + n1x + ',' + n1y;
- }
+ const [n1x, n1y] = tagDoc //
+ ? [NumCast(tagDoc.x) + NumCast(tagDoc._width) / 2, NumCast(tagDoc.y) + NumCast(tagDoc._height) / 2]
+ : [NumCast(doc.config_panX), NumCast(doc.config_panY)];
+
+ if (index === 0) pathPoints = n1x + ',' + n1y;
+ else pathPoints = pathPoints + ' ' + n1x + ',' + n1y;
});
return (
<>
@@ -1401,7 +1310,14 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@undoBatch
updateTransitionTime = (number: String, change?: number) => {
- PresBox.SetTransitionTime(number, (timeInMS: number) => this.selectedArray.forEach(doc => (doc.presentation_transition = timeInMS)), change);
+ PresBox.SetTransitionTime(
+ number,
+ (timeInMS: number) =>
+ this.selectedArray.forEach(doc => {
+ doc.presentation_transition = timeInMS;
+ }),
+ change
+ );
};
// Converts seconds to ms and updates presentation_transition
@@ -1411,7 +1327,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
if (change) scale += change;
if (scale < 0.01) scale = 0.01;
if (scale > 1) scale = 1;
- this.selectedArray.forEach(doc => (doc.config_zoom = scale));
+ this.selectedArray.forEach(doc => {
+ doc.config_zoom = scale;
+ });
};
/*
@@ -1423,76 +1341,96 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
if (change) timeInMS += change;
if (timeInMS < 100) timeInMS = 100;
if (timeInMS > 20000) timeInMS = 20000;
- this.selectedArray.forEach(doc => (doc.presentation_duration = timeInMS));
+ this.selectedArray.forEach(doc => {
+ doc.presentation_duration = timeInMS;
+ });
};
@undoBatch
- updateMovement = action((movement: PresMovement, all?: boolean) => (all ? this.childDocs : this.selectedArray).forEach(doc => (doc.presentation_movement = movement)));
+ updateMovement = action((movement: PresMovement, all?: boolean) =>
+ (all ? this.childDocs : this.selectedArray).forEach(doc => {
+ doc.presentation_movement = movement;
+ })
+ );
@undoBatch
updateHideBefore = (activeItem: Doc) => {
activeItem.presentation_hideBefore = !activeItem.presentation_hideBefore;
- this.selectedArray.forEach(doc => (doc.presentation_hideBefore = activeItem.presentation_hideBefore));
+ this.selectedArray.forEach(doc => {
+ doc.presentation_hideBefore = activeItem.presentation_hideBefore;
+ });
};
@undoBatch
updateHide = (activeItem: Doc) => {
activeItem.presentation_hide = !activeItem.presentation_hide;
- this.selectedArray.forEach(doc => (doc.presentation_hide = activeItem.presentation_hide));
+ this.selectedArray.forEach(doc => {
+ doc.presentation_hide = activeItem.presentation_hide;
+ });
};
@undoBatch
updateHideAfter = (activeItem: Doc) => {
activeItem.presentation_hideAfter = !activeItem.presentation_hideAfter;
- this.selectedArray.forEach(doc => (doc.presentation_hideAfter = activeItem.presentation_hideAfter));
+ this.selectedArray.forEach(doc => {
+ doc.presentation_hideAfter = activeItem.presentation_hideAfter;
+ });
};
@undoBatch
updateOpenDoc = (activeItem: Doc) => {
activeItem.presentation_openInLightbox = !activeItem.presentation_openInLightbox;
- this.selectedArray.forEach(doc => (doc.presentation_openInLightbox = activeItem.presentation_openInLightbox));
+ this.selectedArray.forEach(doc => {
+ doc.presentation_openInLightbox = activeItem.presentation_openInLightbox;
+ });
};
@undoBatch
updateEaseFunc = (activeItem: Doc) => {
activeItem.presEaseFunc = activeItem.presEaseFunc === 'linear' ? 'ease' : 'linear';
- this.selectedArray.forEach(doc => (doc.presEaseFunc = activeItem.presEaseFunc));
+ this.selectedArray.forEach(doc => {
+ doc.presEaseFunc = activeItem.presEaseFunc;
+ });
};
@undoBatch
- updateEffectDirection = (effect: PresEffectDirection, all?: boolean) => (all ? this.childDocs : this.selectedArray).forEach(doc => (doc.presentation_effectDirection = effect));
+ updateEffectDirection = (effect: PresEffectDirection, all?: boolean) =>
+ (all ? this.childDocs : this.selectedArray).forEach(doc => {
+ doc.presentation_effectDirection = effect;
+ });
@undoBatch
- updateEffect = (effect: PresEffect, bullet: boolean, all?: boolean) => (all ? this.childDocs : this.selectedArray).forEach(doc => (bullet ? (doc.presBulletEffect = effect) : (doc.presentation_effect = effect)));
+ updateEffect = (effect: PresEffect, bullet: boolean, all?: boolean) =>
+ (all ? this.childDocs : this.selectedArray).forEach(doc => {
+ bullet ? (doc.presBulletEffect = effect) : (doc.presentation_effect = effect);
+ });
static _sliderBatch: any;
static endBatch = () => {
PresBox._sliderBatch.end();
document.removeEventListener('pointerup', PresBox.endBatch, true);
};
- public static inputter = (min: string, step: string, max: string, value: number, active: boolean, change: (val: string) => void, hmargin?: number) => {
- return (
- <input
- type="range"
- step={step}
- min={min}
- max={max}
- value={value}
- readOnly={true}
- style={{ marginLeft: hmargin, marginRight: hmargin, width: `calc(100% - ${2 * (hmargin ?? 0)}px)`, background: SettingsManager.userColor, color: SettingsManager.userVariantColor }}
- className={`toolbar-slider ${active ? '' : 'none'}`}
- onPointerDown={e => {
- PresBox._sliderBatch = UndoManager.StartBatch('pres slider');
- document.addEventListener('pointerup', PresBox.endBatch, true);
- e.stopPropagation();
- }}
- onChange={e => {
- e.stopPropagation();
- change(e.target.value);
- }}
- />
- );
- };
+ public static inputter = (min: string, step: string, max: string, value: number, active: boolean, change: (val: string) => void, hmargin?: number) => (
+ <input
+ type="range"
+ step={step}
+ min={min}
+ max={max}
+ value={value}
+ readOnly
+ style={{ marginLeft: hmargin, marginRight: hmargin, width: `calc(100% - ${2 * (hmargin ?? 0)}px)`, background: SnappingManager.userColor, color: SnappingManager.userVariantColor }}
+ className={`toolbar-slider ${active ? '' : 'none'}`}
+ onPointerDown={e => {
+ PresBox._sliderBatch = UndoManager.StartBatch('pres slider');
+ document.addEventListener('pointerup', PresBox.endBatch, true);
+ e.stopPropagation();
+ }}
+ onChange={e => {
+ e.stopPropagation();
+ change(e.target.value);
+ }}
+ />
+ );
@undoBatch
applyTo = (array: Doc[]) => {
@@ -1500,17 +1438,18 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.updateEffect(this.activeItem.presentation_effect as PresEffect, false, true);
this.updateEffect(this.activeItem.presBulletEffect as PresEffect, true, true);
this.updateEffectDirection(this.activeItem.presentation_effectDirection as PresEffectDirection, true);
- const { presentation_transition, presentation_duration, presentation_hideBefore, presentation_hideAfter } = this.activeItem;
+ // eslint-disable-next-line camelcase
+ const { presentation_transition: pt, presentation_duration: pd, presentation_hideBefore: ph, presentation_hideAfter: pa } = this.activeItem;
array.forEach(curDoc => {
- curDoc.presentation_transition = presentation_transition;
- curDoc.presentation_duration = presentation_duration;
- curDoc.presentation_hideBefore = presentation_hideBefore;
- curDoc.presentation_hideAfter = presentation_hideAfter;
+ curDoc.presentation_transition = pt;
+ curDoc.presentation_duration = pd;
+ curDoc.presentation_hideBefore = ph;
+ curDoc.presentation_hideAfter = pa;
});
};
@computed get visibilityDurationDropdown() {
- const activeItem = this.activeItem;
+ const { activeItem } = this;
if (activeItem && this.targetDoc) {
const targetType = this.targetDoc.type;
let duration = activeItem.presentation_duration ? NumCast(activeItem.presentation_duration) / 1000 : 0;
@@ -1521,36 +1460,36 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<Tooltip title={<div className="dash-tooltip">Hide before presented</div>}>
<div
className={`ribbon-toggle ${activeItem.presentation_hideBefore ? 'active' : ''}`}
- style={{ border: `solid 1px ${SettingsManager.userColor}`, color: SettingsManager.userColor, background: activeItem.presentation_hideBefore ? SettingsManager.userVariantColor : SettingsManager.userBackgroundColor }}
+ style={{ border: `solid 1px ${SnappingManager.userColor}`, color: SnappingManager.userColor, background: activeItem.presentation_hideBefore ? SnappingManager.userVariantColor : SnappingManager.userBackgroundColor }}
onClick={() => this.updateHideBefore(activeItem)}>
Hide before
</div>
</Tooltip>
- <Tooltip title={<div className="dash-tooltip">{'Hide while presented'}</div>}>
+ <Tooltip title={<div className="dash-tooltip">Hide while presented</div>}>
<div
className={`ribbon-toggle ${activeItem.presentation_hide ? 'active' : ''}`}
- style={{ border: `solid 1px ${SettingsManager.userColor}`, color: SettingsManager.userColor, background: activeItem.presentation_hide ? SettingsManager.userVariantColor : SettingsManager.userBackgroundColor }}
+ style={{ border: `solid 1px ${SnappingManager.userColor}`, color: SnappingManager.userColor, background: activeItem.presentation_hide ? SnappingManager.userVariantColor : SnappingManager.userBackgroundColor }}
onClick={() => this.updateHide(activeItem)}>
Hide
</div>
</Tooltip>
- <Tooltip title={<div className="dash-tooltip">{'Hide after presented'}</div>}>
+ <Tooltip title={<div className="dash-tooltip">Hide after presented</div>}>
<div
className={`ribbon-toggle ${activeItem.presentation_hideAfter ? 'active' : ''}`}
- style={{ border: `solid 1px ${SettingsManager.userColor}`, color: SettingsManager.userColor, background: activeItem.presentation_hideAfter ? SettingsManager.userVariantColor : SettingsManager.userBackgroundColor }}
+ style={{ border: `solid 1px ${SnappingManager.userColor}`, color: SnappingManager.userColor, background: activeItem.presentation_hideAfter ? SnappingManager.userVariantColor : SnappingManager.userBackgroundColor }}
onClick={() => this.updateHideAfter(activeItem)}>
Hide after
</div>
</Tooltip>
- <Tooltip title={<div className="dash-tooltip">{'Open in lightbox view'}</div>}>
+ <Tooltip title={<div className="dash-tooltip">Open in lightbox view</div>}>
<div
className="ribbon-toggle"
style={{
- border: `solid 1px ${SettingsManager.userColor}`,
- color: SettingsManager.userColor,
- background: activeItem.presentation_openInLightbox ? SettingsManager.userVariantColor : SettingsManager.userBackgroundColor,
+ border: `solid 1px ${SnappingManager.userColor}`,
+ color: SnappingManager.userColor,
+ background: activeItem.presentation_openInLightbox ? SnappingManager.userVariantColor : SnappingManager.userBackgroundColor,
}}
onClick={() => this.updateOpenDoc(activeItem)}>
Lightbox
@@ -1559,30 +1498,30 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<Tooltip title={<div className="dash-tooltip">Transition movement style</div>}>
<div
className="ribbon-toggle"
- style={{ border: `solid 1px ${SettingsManager.userColor}`, color: SettingsManager.userColor, background: activeItem.presEaseFunc === 'ease' ? SettingsManager.userVariantColor : SettingsManager.userBackgroundColor }}
+ style={{ border: `solid 1px ${SnappingManager.userColor}`, color: SnappingManager.userColor, background: activeItem.presEaseFunc === 'ease' ? SnappingManager.userVariantColor : SnappingManager.userBackgroundColor }}
onClick={() => this.updateEaseFunc(activeItem)}>
{`${StrCast(activeItem.presEaseFunc, 'ease')}`}
</div>
</Tooltip>
</div>
- {[DocumentType.AUDIO, DocumentType.VID].includes(targetType as any as DocumentType) ? null : (
+ {[DocumentType.AUDIO, DocumentType.VID].find(dt => dt === targetType) ? null : (
<>
<div className="ribbon-doubleButton">
<div className="presBox-subheading">Slide Duration</div>
- <div className="ribbon-property" style={{ border: `solid 1px ${SettingsManager.userColor}` }}>
- <input className="presBox-input" type="number" readOnly={true} value={duration} onKeyDown={e => e.stopPropagation()} onChange={e => this.updateDurationTime(e.target.value)} /> s
+ <div className="ribbon-property" style={{ border: `solid 1px ${SnappingManager.userColor}` }}>
+ <input className="presBox-input" type="number" readOnly value={duration} onKeyDown={e => e.stopPropagation()} onChange={e => this.updateDurationTime(e.target.value)} /> s
</div>
- <div className="ribbon-propertyUpDown" style={{ color: SettingsManager.userBackgroundColor, background: SettingsManager.userColor }}>
+ <div className="ribbon-propertyUpDown" style={{ color: SnappingManager.userBackgroundColor, background: SnappingManager.userColor }}>
<div className="ribbon-propertyUpDownItem" onClick={() => this.updateDurationTime(String(duration), 1000)}>
- <FontAwesomeIcon icon={'caret-up'} />
+ <FontAwesomeIcon icon="caret-up" />
</div>
<div className="ribbon-propertyUpDownItem" onClick={() => this.updateDurationTime(String(duration), -1000)}>
- <FontAwesomeIcon icon={'caret-down'} />
+ <FontAwesomeIcon icon="caret-down" />
</div>
</div>
</div>
{PresBox.inputter('0.1', '0.1', '20', duration, targetType !== DocumentType.AUDIO, this.updateDurationTime)}
- <div className={'slider-headers'} style={{ display: targetType === DocumentType.AUDIO ? 'none' : 'grid' }}>
+ <div className="slider-headers" style={{ display: targetType === DocumentType.AUDIO ? 'none' : 'grid' }}>
<div className="slider-text">Short</div>
<div className="slider-text">Medium</div>
<div className="slider-text">Long</div>
@@ -1592,17 +1531,18 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
);
}
+ return undefined;
}
@computed get progressivizeDropdown() {
- const activeItem = this.activeItem;
+ const { activeItem } = this;
if (activeItem && this.targetDoc) {
const effect = activeItem.presBulletEffect ? activeItem.presBulletEffect : PresMovement.None;
- const bulletEffect = (effect: PresEffect) => (
+ const bulletEffect = (presEffect: PresEffect) => (
<div
- className={`presBox-dropdownOption ${activeItem.presentation_effect === effect || (effect === PresEffect.None && !activeItem.presentation_effect) ? 'active' : ''}`}
+ className={`presBox-dropdownOption ${activeItem.presentation_effect === presEffect || (presEffect === PresEffect.None && !activeItem.presentation_effect) ? 'active' : ''}`}
onPointerDown={StopEvent}
- onClick={() => this.updateEffect(effect, true)}>
- {effect}
+ onClick={() => this.updateEffect(presEffect, true)}>
+ {presEffect}
</div>
);
return (
@@ -1611,7 +1551,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className="presBox-subheading">Progressivize Collection</div>
<input
className="presBox-checkbox"
- style={{ margin: 10, border: `solid 1px ${SettingsManager.userColor}` }}
+ style={{ margin: 10, border: `solid 1px ${SnappingManager.userColor}` }}
type="checkbox"
onChange={() => {
activeItem.presentation_indexed = activeItem.presentation_indexed === undefined ? 0 : undefined;
@@ -1622,21 +1562,23 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
// a progressivized slide doesn't have sub-slides, but rather iterates over the data list of the target being progressivized.
// to avoid creating a new slide to correspond to each of the target's data list, we create a computedField to refernce the target's data list.
let dataField = Doc.LayoutFieldKey(tagDoc);
- if (Cast(tagDoc[dataField], listSpec(Doc), null)?.filter(d => d instanceof Doc) === undefined) dataField = dataField + '_annotations';
+ if (Cast(tagDoc[dataField], listSpec(Doc), null)?.filter(d => d instanceof Doc) === undefined) dataField += '_annotations';
if (DocCast(activeItem.presentation_targetDoc).annotationOn) activeItem.data = ComputedField.MakeFunction(`this.presentation_targetDoc.annotationOn?.["${dataField}"]`);
else activeItem.data = ComputedField.MakeFunction(`this.presentation_targetDoc?.["${dataField}"]`);
}}
- checked={Cast(activeItem.presentation_indexed, 'number', null) !== undefined ? true : false}
+ checked={Cast(activeItem.presentation_indexed, 'number', null) !== undefined}
/>
</div>
<div className="ribbon-doubleButton" style={{ display: 'inline-flex' }}>
<div className="presBox-subheading">Progressivize First Bullet</div>
<input
className="presBox-checkbox"
- style={{ margin: 10, border: `solid 1px ${SettingsManager.userColor}` }}
+ style={{ margin: 10, border: `solid 1px ${SnappingManager.userColor}` }}
type="checkbox"
- onChange={() => (activeItem.presentation_indexedStart = activeItem.presentation_indexedStart ? 0 : 1)}
+ onChange={() => {
+ activeItem.presentation_indexedStart = activeItem.presentation_indexedStart ? 0 : 1;
+ }}
checked={!NumCast(activeItem.presentation_indexedStart)}
/>
</div>
@@ -1644,9 +1586,11 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className="presBox-subheading">Expand Current Bullet</div>
<input
className="presBox-checkbox"
- style={{ margin: 10, border: `solid 1px ${SettingsManager.userColor}` }}
+ style={{ margin: 10, border: `solid 1px ${SnappingManager.userColor}` }}
type="checkbox"
- onChange={() => (activeItem.presBulletExpand = !activeItem.presBulletExpand)}
+ onChange={() => {
+ activeItem.presBulletExpand = !activeItem.presBulletExpand;
+ }}
checked={BoolCast(activeItem.presBulletExpand)}
/>
</div>
@@ -1660,20 +1604,20 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this._openBulletEffectDropdown = !this._openBulletEffectDropdown;
})}
style={{
- color: SettingsManager.userColor,
- background: SettingsManager.userVariantColor,
+ color: SnappingManager.userColor,
+ background: SnappingManager.userVariantColor,
borderBottomLeftRadius: this._openBulletEffectDropdown ? 0 : 5,
- border: this._openBulletEffectDropdown ? `solid 2px ${SettingsManager.userVariantColor}` : `solid 1px ${SettingsManager.userColor}`,
+ border: this._openBulletEffectDropdown ? `solid 2px ${SnappingManager.userVariantColor}` : `solid 1px ${SnappingManager.userColor}`,
}}>
{effect?.toString()}
- <FontAwesomeIcon className="presBox-dropdownIcon" style={{ gridColumn: 2, color: this._openBulletEffectDropdown ? Colors.MEDIUM_BLUE : 'black' }} icon={'angle-down'} />
+ <FontAwesomeIcon className="presBox-dropdownIcon" style={{ gridColumn: 2, color: this._openBulletEffectDropdown ? Colors.MEDIUM_BLUE : 'black' }} icon="angle-down" />
<div
- className={'presBox-dropdownOptions'}
- style={{ display: this._openBulletEffectDropdown ? 'grid' : 'none', color: SettingsManager.userColor, background: SettingsManager.userBackgroundColor }}
+ className="presBox-dropdownOptions"
+ style={{ display: this._openBulletEffectDropdown ? 'grid' : 'none', color: SnappingManager.userColor, background: SnappingManager.userBackgroundColor }}
onPointerDown={e => e.stopPropagation()}>
{Object.values(PresEffect)
.filter(v => isNaN(Number(v)))
- .map(effect => bulletEffect(effect))}
+ .map(peffect => bulletEffect(peffect))}
</div>
</div>
</div>
@@ -1683,7 +1627,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
return null;
}
@computed get transitionDropdown() {
- const activeItem = this.activeItem;
+ const { activeItem } = this;
const preseEffect = (effect: PresEffect) => (
<div
className={`presBox-dropdownOption ${activeItem.presentation_effect === effect || (effect === PresEffect.None && !activeItem.presentation_effect) ? 'active' : ''}`}
@@ -1698,7 +1642,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
);
const presDirection = (direction: PresEffectDirection, icon: string, gridColumn: number, gridRow: number, opts: object) => {
- const color = activeItem.presentation_effectDirection === direction || (direction === PresEffectDirection.Center && !activeItem.presentation_effectDirection) ? SettingsManager.userVariantColor : SettingsManager.userColor;
+ const color = activeItem.presentation_effectDirection === direction || (direction === PresEffectDirection.Center && !activeItem.presentation_effectDirection) ? SnappingManager.userVariantColor : SnappingManager.userColor;
return (
<Tooltip title={<div className="dash-tooltip">{direction}</div>}>
<div
@@ -1733,20 +1677,20 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this._openMovementDropdown = !this._openMovementDropdown;
})}
style={{
- color: SettingsManager.userColor,
- background: SettingsManager.userVariantColor,
+ color: SnappingManager.userColor,
+ background: SnappingManager.userVariantColor,
borderBottomLeftRadius: this._openMovementDropdown ? 0 : 5,
- border: this._openMovementDropdown ? `solid 2px ${SettingsManager.userVariantColor}` : `solid 1px ${SettingsManager.userColor}`,
+ border: this._openMovementDropdown ? `solid 2px ${SnappingManager.userVariantColor}` : `solid 1px ${SnappingManager.userColor}`,
}}>
{this.movementName(activeItem)}
- <FontAwesomeIcon className="presBox-dropdownIcon" style={{ gridColumn: 2, color: this._openMovementDropdown ? Colors.MEDIUM_BLUE : 'black' }} icon={'angle-down'} />
+ <FontAwesomeIcon className="presBox-dropdownIcon" style={{ gridColumn: 2, color: this._openMovementDropdown ? Colors.MEDIUM_BLUE : 'black' }} icon="angle-down" />
<div
className="presBox-dropdownOptions"
- id={'presBoxMovementDropdown'}
+ id="presBoxMovementDropdown"
onPointerDown={StopEvent}
style={{
- color: SettingsManager.userColor,
- background: SettingsManager.userBackgroundColor,
+ color: SnappingManager.userColor,
+ background: SnappingManager.userBackgroundColor,
display: this._openMovementDropdown ? 'grid' : 'none',
}}>
{presMovement(PresMovement.None)}
@@ -1758,35 +1702,35 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
<div className="ribbon-doubleButton" style={{ display: activeItem.presentation_movement === PresMovement.Zoom ? 'inline-flex' : 'none' }}>
<div className="presBox-subheading">Zoom (% screen filled)</div>
- <div className="ribbon-property" style={{ border: `solid 1px ${SettingsManager.userColor}` }}>
- <input className="presBox-input" type="number" readOnly={true} value={zoom} onChange={e => this.updateZoom(e.target.value)} />%
+ <div className="ribbon-property" style={{ border: `solid 1px ${SnappingManager.userColor}` }}>
+ <input className="presBox-input" type="number" readOnly value={zoom} onChange={e => this.updateZoom(e.target.value)} />%
</div>
- <div className="ribbon-propertyUpDown" style={{ color: SettingsManager.userBackgroundColor, background: SettingsManager.userColor }}>
+ <div className="ribbon-propertyUpDown" style={{ color: SnappingManager.userBackgroundColor, background: SnappingManager.userColor }}>
<div className="ribbon-propertyUpDownItem" onClick={() => this.updateZoom(String(zoom), 0.1)}>
- <FontAwesomeIcon icon={'caret-up'} />
+ <FontAwesomeIcon icon="caret-up" />
</div>
<div className="ribbon-propertyUpDownItem" onClick={() => this.updateZoom(String(zoom), -0.1)}>
- <FontAwesomeIcon icon={'caret-down'} />
+ <FontAwesomeIcon icon="caret-down" />
</div>
</div>
</div>
{PresBox.inputter('0', '1', '100', zoom, activeItem.presentation_movement === PresMovement.Zoom, this.updateZoom)}
<div className="ribbon-doubleButton" style={{ display: 'inline-flex' }}>
<div className="presBox-subheading">Transition Time</div>
- <div className="ribbon-property" style={{ border: `solid 1px ${SettingsManager.userColor}` }}>
- <input className="presBox-input" type="number" readOnly={true} value={transitionSpeed} onKeyDown={e => e.stopPropagation()} onChange={action(e => this.updateTransitionTime(e.target.value))} /> s
+ <div className="ribbon-property" style={{ border: `solid 1px ${SnappingManager.userColor}` }}>
+ <input className="presBox-input" type="number" readOnly value={transitionSpeed} onKeyDown={e => e.stopPropagation()} onChange={action(e => this.updateTransitionTime(e.target.value))} /> s
</div>
- <div className="ribbon-propertyUpDown" style={{ color: SettingsManager.userBackgroundColor, background: SettingsManager.userColor }}>
+ <div className="ribbon-propertyUpDown" style={{ color: SnappingManager.userBackgroundColor, background: SnappingManager.userColor }}>
<div className="ribbon-propertyUpDownItem" onClick={() => this.updateTransitionTime(String(transitionSpeed), 1000)}>
- <FontAwesomeIcon icon={'caret-up'} />
+ <FontAwesomeIcon icon="caret-up" />
</div>
<div className="ribbon-propertyUpDownItem" onClick={() => this.updateTransitionTime(String(transitionSpeed), -1000)}>
- <FontAwesomeIcon icon={'caret-down'} />
+ <FontAwesomeIcon icon="caret-down" />
</div>
</div>
</div>
{PresBox.inputter('0.1', '0.1', '100', transitionSpeed, true, this.updateTransitionTime)}
- <div className={'slider-headers'}>
+ <div className="slider-headers">
<div className="slider-text">Fast</div>
<div className="slider-text">Medium</div>
<div className="slider-text">Slow</div>
@@ -1798,9 +1742,11 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className="presBox-subheading">Play Audio Annotation</div>
<input
className="presBox-checkbox"
- style={{ margin: 10, border: `solid 1px ${SettingsManager.userColor}` }}
+ style={{ margin: 10, border: `solid 1px ${SnappingManager.userColor}` }}
type="checkbox"
- onChange={() => (activeItem.presPlayAudio = !BoolCast(activeItem.presPlayAudio))}
+ onChange={() => {
+ activeItem.presPlayAudio = !BoolCast(activeItem.presPlayAudio);
+ }}
checked={BoolCast(activeItem.presPlayAudio)}
/>
</div>
@@ -1808,9 +1754,11 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className="presBox-subheading">Zoom Text Selections</div>
<input
className="presBox-checkbox"
- style={{ margin: 10, border: `solid 1px ${SettingsManager.userColor}` }}
+ style={{ margin: 10, border: `solid 1px ${SnappingManager.userColor}` }}
type="checkbox"
- onChange={() => (activeItem.presentation_zoomText = !BoolCast(activeItem.presentation_zoomText))}
+ onChange={() => {
+ activeItem.presentation_zoomText = !BoolCast(activeItem.presentation_zoomText);
+ }}
checked={BoolCast(activeItem.presentation_zoomText)}
/>
</div>
@@ -1821,30 +1769,30 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this._openEffectDropdown = !this._openEffectDropdown;
})}
style={{
- color: SettingsManager.userColor,
- background: SettingsManager.userVariantColor,
+ color: SnappingManager.userColor,
+ background: SnappingManager.userVariantColor,
borderBottomLeftRadius: this._openEffectDropdown ? 0 : 5,
- border: this._openEffectDropdown ? `solid 2px ${SettingsManager.userVariantColor}` : `solid 1px ${SettingsManager.userColor}`,
+ border: this._openEffectDropdown ? `solid 2px ${SnappingManager.userVariantColor}` : `solid 1px ${SnappingManager.userColor}`,
}}>
{effect?.toString()}
- <FontAwesomeIcon className="presBox-dropdownIcon" style={{ gridColumn: 2, color: this._openEffectDropdown ? Colors.MEDIUM_BLUE : 'black' }} icon={'angle-down'} />
+ <FontAwesomeIcon className="presBox-dropdownIcon" style={{ gridColumn: 2, color: this._openEffectDropdown ? Colors.MEDIUM_BLUE : 'black' }} icon="angle-down" />
<div
className="presBox-dropdownOptions"
- id={'presBoxMovementDropdown'}
+ id="presBoxMovementDropdown"
style={{
- color: SettingsManager.userColor,
- background: SettingsManager.userBackgroundColor,
+ color: SnappingManager.userColor,
+ background: SnappingManager.userBackgroundColor,
display: this._openEffectDropdown ? 'grid' : 'none',
}}
onPointerDown={e => e.stopPropagation()}>
{Object.values(PresEffect)
.filter(v => isNaN(Number(v)))
- .map(effect => preseEffect(effect))}
+ .map(presEffect => preseEffect(presEffect))}
</div>
</div>
<div className="ribbon-doubleButton" style={{ display: effect === PresEffectDirection.None ? 'none' : 'inline-flex' }}>
<div className="presBox-subheading">Effect direction</div>
- <div className="ribbon-property" style={{ border: `solid 1px ${SettingsManager.userColor}` }}>
+ <div className="ribbon-property" style={{ border: `solid 1px ${SnappingManager.userColor}` }}>
{StrCast(this.activeItem.presentation_effectDirection)}
</div>
</div>
@@ -1864,33 +1812,36 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
);
}
+ return undefined;
}
@computed get mediaOptionsDropdown() {
- const activeItem = this.activeItem;
+ const { activeItem } = this;
if (activeItem && this.targetDoc) {
const renderTarget = PresBox.targetRenderedDoc(this.activeItem);
const clipStart = NumCast(renderTarget.clipStart);
const clipEnd = NumCast(renderTarget.clipEnd, clipStart + NumCast(renderTarget[Doc.LayoutFieldKey(renderTarget) + '_duration']));
- const config_clipEnd = NumCast(activeItem.config_clipEnd) < NumCast(activeItem.config_clipStart) ? clipEnd - clipStart : NumCast(activeItem.config_clipEnd);
+ const configClipEnd = NumCast(activeItem.config_clipEnd) < NumCast(activeItem.config_clipStart) ? clipEnd - clipStart : NumCast(activeItem.config_clipEnd);
return (
- <div className={'presBox-ribbon'} onClick={e => e.stopPropagation()} onPointerUp={e => e.stopPropagation()} onPointerDown={e => e.stopPropagation()}>
+ <div className="presBox-ribbon" onClick={e => e.stopPropagation()} onPointerUp={e => e.stopPropagation()} onPointerDown={e => e.stopPropagation()}>
<div>
<div className="ribbon-box">
- Start {'&'} End Time
- <div className={'slider-headers'}>
+ Start & End Time
+ <div className="slider-headers">
<div className="slider-block">
<div className="slider-text" style={{ fontWeight: 500 }}>
Start time (s)
</div>
- <div id="startTime" className="slider-number" style={{ color: SettingsManager.userColor, backgroundColor: SettingsManager.userBackgroundColor }}>
+ <div id="startTime" className="slider-number" style={{ color: SnappingManager.userColor, backgroundColor: SnappingManager.userBackgroundColor }}>
<input
className="presBox-input"
style={{ textAlign: 'center', width: '100%', height: 15, fontSize: 10 }}
type="number"
- readOnly={true}
+ readOnly
value={NumCast(activeItem.config_clipStart).toFixed(2)}
onKeyDown={e => e.stopPropagation()}
- onChange={action(e => (activeItem.config_clipStart = Number(e.target.value)))}
+ onChange={action(e => {
+ activeItem.config_clipStart = Number(e.target.value);
+ })}
/>
</div>
</div>
@@ -1898,23 +1849,25 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className="slider-text" style={{ fontWeight: 500 }}>
Duration (s)
</div>
- <div className="slider-number" style={{ color: SettingsManager.userColor, backgroundColor: SettingsManager.userBackgroundColor }}>
- {Math.round((config_clipEnd - NumCast(activeItem.config_clipStart)) * 10) / 10}
+ <div className="slider-number" style={{ color: SnappingManager.userColor, backgroundColor: SnappingManager.userBackgroundColor }}>
+ {Math.round((configClipEnd - NumCast(activeItem.config_clipStart)) * 10) / 10}
</div>
</div>
<div className="slider-block">
<div className="slider-text" style={{ fontWeight: 500 }}>
End time (s)
</div>
- <div id="endTime" className="slider-number" style={{ color: SettingsManager.userColor, backgroundColor: SettingsManager.userBackgroundColor }}>
+ <div id="endTime" className="slider-number" style={{ color: SnappingManager.userColor, backgroundColor: SnappingManager.userBackgroundColor }}>
<input
className="presBox-input"
onKeyDown={e => e.stopPropagation()}
style={{ textAlign: 'center', width: '100%', height: 15, fontSize: 10 }}
type="number"
- readOnly={true}
- value={config_clipEnd.toFixed(2)}
- onChange={action(e => (activeItem.config_clipEnd = Number(e.target.value)))}
+ readOnly
+ value={configClipEnd.toFixed(2)}
+ onChange={action(e => {
+ activeItem.config_clipEnd = Number(e.target.value);
+ })}
/>
</div>
</div>
@@ -1925,15 +1878,15 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
step="0.1"
min={clipStart}
max={clipEnd}
- value={config_clipEnd}
- style={{ gridColumn: 1, gridRow: 1, background: SettingsManager.userColor, color: SettingsManager.userVariantColor }}
+ value={configClipEnd}
+ style={{ gridColumn: 1, gridRow: 1, background: SnappingManager.userColor, color: SnappingManager.userVariantColor }}
className={`toolbar-slider ${'end'}`}
id="toolbar-slider"
onPointerDown={e => {
this._batch = UndoManager.StartBatch('config_clipEnd');
const endBlock = document.getElementById('endTime');
if (endBlock) {
- endBlock.style.backgroundColor = SettingsManager.userVariantColor;
+ endBlock.style.backgroundColor = SnappingManager.userVariantColor ?? '';
}
e.stopPropagation();
}}
@@ -1941,7 +1894,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this._batch?.end();
const endBlock = document.getElementById('endTime');
if (endBlock) {
- endBlock.style.backgroundColor = SettingsManager.userBackgroundColor;
+ endBlock.style.backgroundColor = SnappingManager.userBackgroundColor ?? '';
}
}}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
@@ -1962,7 +1915,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this._batch = UndoManager.StartBatch('config_clipStart');
const startBlock = document.getElementById('startTime');
if (startBlock) {
- startBlock.style.backgroundColor = SettingsManager.userVariantColor;
+ startBlock.style.backgroundColor = SnappingManager.userVariantColor ?? '';
}
e.stopPropagation();
}}
@@ -1970,7 +1923,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this._batch?.end();
const startBlock = document.getElementById('startTime');
if (startBlock) {
- startBlock.style.backgroundColor = SettingsManager.userBackgroundColor;
+ startBlock.style.backgroundColor = SnappingManager.userBackgroundColor ?? '';
}
}}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
@@ -1981,7 +1934,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
<div className="slider-headers">
<div className="slider-text">{clipStart.toFixed(2)} s</div>
- <div className="slider-text"></div>
+ <div className="slider-text" />
<div className="slider-text">{clipEnd.toFixed(2)} s</div>
</div>
</div>
@@ -1993,8 +1946,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<input
className="presBox-checkbox"
type="checkbox"
- style={{ border: `solid 1px ${SettingsManager.userColor}` }}
- onChange={() => (activeItem.presentation_mediaStart = 'manual')}
+ style={{ border: `solid 1px ${SnappingManager.userColor}` }}
+ onChange={() => {
+ activeItem.presentation_mediaStart = 'manual';
+ }}
checked={activeItem.presentation_mediaStart === 'manual'}
/>
<div>On click</div>
@@ -2002,9 +1957,11 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className="checkbox-container">
<input
className="presBox-checkbox"
- style={{ border: `solid 1px ${SettingsManager.userColor}` }}
+ style={{ border: `solid 1px ${SnappingManager.userColor}` }}
type="checkbox"
- onChange={() => (activeItem.presentation_mediaStart = 'auto')}
+ onChange={() => {
+ activeItem.presentation_mediaStart = 'auto';
+ }}
checked={activeItem.presentation_mediaStart === 'auto'}
/>
<div>Automatically</div>
@@ -2016,8 +1973,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<input
className="presBox-checkbox"
type="checkbox"
- style={{ border: `solid 1px ${SettingsManager.userColor}` }}
- onChange={() => (activeItem.presentation_mediaStop = 'manual')}
+ style={{ border: `solid 1px ${SnappingManager.userColor}` }}
+ onChange={() => {
+ activeItem.presentation_mediaStop = 'manual';
+ }}
checked={activeItem.presentation_mediaStop === 'manual'}
/>
<div>At media end time</div>
@@ -2026,8 +1985,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<input
className="presBox-checkbox"
type="checkbox"
- style={{ border: `solid 1px ${SettingsManager.userColor}` }}
- onChange={() => (activeItem.presentation_mediaStop = 'auto')}
+ style={{ border: `solid 1px ${SnappingManager.userColor}` }}
+ onChange={() => {
+ activeItem.presentation_mediaStop = 'auto';
+ }}
checked={activeItem.presentation_mediaStop === 'auto'}
/>
<div>On slide change</div>
@@ -2055,6 +2016,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
);
}
+ return undefined;
}
@computed get newDocumentToolbarDropdown() {
return (
@@ -2118,9 +2080,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@computed get newDocumentDropdown() {
return (
- <div className={'presBox-ribbon'} onClick={e => e.stopPropagation()} onPointerDown={e => e.stopPropagation()}>
+ <div className="presBox-ribbon" onClick={e => e.stopPropagation()} onPointerDown={e => e.stopPropagation()}>
<div className="ribbon-box">
- Slide Title: <br></br>
+ Slide Title: <br />
<input
className="ribbon-textInput"
placeholder="..."
@@ -2129,16 +2091,31 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
onChange={e => {
e.stopPropagation();
e.preventDefault();
- runInAction(() => (this.title = e.target.value));
- }}></input>
+ runInAction(() => {
+ this.title = e.target.value;
+ });
+ }}
+ />
</div>
<div className="ribbon-box">
Choose type:
<div className="ribbon-doubleButton">
- <div title="Text" className={'ribbon-toggle'} style={{ background: this.addFreeform ? '' : Colors.LIGHT_BLUE }} onClick={action(() => (this.addFreeform = !this.addFreeform))}>
+ <div
+ title="Text"
+ className="ribbon-toggle"
+ style={{ background: this.addFreeform ? '' : Colors.LIGHT_BLUE }}
+ onClick={action(() => {
+ this.addFreeform = !this.addFreeform;
+ })}>
Text
</div>
- <div title="Freeform" className={'ribbon-toggle'} style={{ background: this.addFreeform ? Colors.LIGHT_BLUE : '' }} onClick={action(() => (this.addFreeform = !this.addFreeform))}>
+ <div
+ title="Freeform"
+ className="ribbon-toggle"
+ style={{ background: this.addFreeform ? Colors.LIGHT_BLUE : '' }}
+ onClick={action(() => {
+ this.addFreeform = !this.addFreeform;
+ })}>
Freeform
</div>
</div>
@@ -2146,23 +2123,49 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className="ribbon-box" style={{ display: this.addFreeform ? 'grid' : 'none' }}>
Preset layouts:
<div className="layout-container" style={{ height: this.openLayouts ? 'max-content' : '75px' }}>
- <div className="layout" style={{ border: this.layout === 'blank' ? `solid 2px ${Colors.MEDIUM_BLUE}` : '' }} onClick={action(() => (this.layout = 'blank'))} />
- <div className="layout" style={{ border: this.layout === 'title' ? `solid 2px ${Colors.MEDIUM_BLUE}` : '' }} onClick={action(() => (this.layout = 'title'))}>
+ <div
+ className="layout"
+ style={{ border: this.layout === 'blank' ? `solid 2px ${Colors.MEDIUM_BLUE}` : '' }}
+ onClick={action(() => {
+ this.layout = 'blank';
+ })}
+ />
+ <div
+ className="layout"
+ style={{ border: this.layout === 'title' ? `solid 2px ${Colors.MEDIUM_BLUE}` : '' }}
+ onClick={action(() => {
+ this.layout = 'title';
+ })}>
<div className="title">Title</div>
<div className="subtitle">Subtitle</div>
</div>
- <div className="layout" style={{ border: this.layout === 'header' ? `solid 2px ${Colors.MEDIUM_BLUE}` : '' }} onClick={action(() => (this.layout = 'header'))}>
+ <div
+ className="layout"
+ style={{ border: this.layout === 'header' ? `solid 2px ${Colors.MEDIUM_BLUE}` : '' }}
+ onClick={action(() => {
+ this.layout = 'header';
+ })}>
<div className="title" style={{ alignSelf: 'center', fontSize: 10 }}>
Section header
</div>
</div>
- <div className="layout" style={{ border: this.layout === 'content' ? `solid 2px ${Colors.MEDIUM_BLUE}` : '' }} onClick={action(() => (this.layout = 'content'))}>
+ <div
+ className="layout"
+ style={{ border: this.layout === 'content' ? `solid 2px ${Colors.MEDIUM_BLUE}` : '' }}
+ onClick={action(() => {
+ this.layout = 'content';
+ })}>
<div className="title" style={{ alignSelf: 'center' }}>
Title
</div>
<div className="content">Text goes here</div>
</div>
- <div className="layout" style={{ border: this.layout === 'twoColumns' ? `solid 2px ${Colors.MEDIUM_BLUE}` : '' }} onClick={action(() => (this.layout = 'twoColumns'))}>
+ <div
+ className="layout"
+ style={{ border: this.layout === 'twoColumns' ? `solid 2px ${Colors.MEDIUM_BLUE}` : '' }}
+ onClick={action(() => {
+ this.layout = 'twoColumns';
+ })}>
<div className="title" style={{ alignSelf: 'center', gridColumn: '1/3' }}>
Title
</div>
@@ -2174,8 +2177,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
</div>
</div>
- <div className="open-layout" onClick={action(() => (this.openLayouts = !this.openLayouts))}>
- <FontAwesomeIcon style={{ transition: 'all 0.3s', transform: this.openLayouts ? 'rotate(180deg)' : 'rotate(0deg)' }} icon={'caret-down'} size={'lg'} />
+ <div
+ className="open-layout"
+ onClick={action(() => {
+ this.openLayouts = !this.openLayouts;
+ })}>
+ <FontAwesomeIcon style={{ transition: 'all 0.3s', transform: this.openLayouts ? 'rotate(180deg)' : 'rotate(0deg)' }} icon="caret-down" size="lg" />
</div>
</div>
<div className="ribbon-final-box">
@@ -2190,17 +2197,17 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
createNewSlide = (layout?: string, title?: string, freeform?: boolean) => {
- let doc = undefined;
+ let doc;
if (layout) doc = this.createTemplate(layout);
if (freeform && layout) doc = this.createTemplate(layout, title);
if (!freeform && !layout) doc = Docs.Create.TextDocument('', { _nativeWidth: 400, _width: 225, title: title });
if (doc) {
const tabMap = CollectionDockingView.Instance?.tabMap;
- const tab = tabMap && Array.from(tabMap).find(tab => tab.DashDoc.type === DocumentType.COL)?.DashDoc;
- const presCollection = DocumentManager.GetContextPath(this.activeItem).reverse().lastElement().presentation_targetDoc ?? tab;
+ const docTab = tabMap && Array.from(tabMap).find(tab => tab.DashDoc.type === DocumentType.COL)?.DashDoc;
+ const presCollection = DocumentView.getContextPath(this.activeItem).reverse().lastElement().presentation_targetDoc ?? docTab;
const data = Cast(presCollection?.data, listSpec(Doc));
- const config_data = Cast(this.Document.data, listSpec(Doc));
- if (data && config_data) {
+ const configData = Cast(this.Document.data, listSpec(Doc));
+ if (data && configData) {
data.push(doc);
this._props.pinToPres(doc, {});
this.gotoDocument(this.childDocs.length, this.activeItem);
@@ -2222,12 +2229,14 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const content2 = () => Docs.Create.TextDocument('Click to change text', { title: 'Column 2', _width: 185, _height: 140, x: 205, y: 80, _text_fontSize: '14pt' });
// prettier-ignore
switch (layout) {
- case 'blank': return Docs.Create.FreeformDocument([], { title: input ? input : 'Blank slide', _width: 400, _height: 225, x, y });
- case 'title': return Docs.Create.FreeformDocument([title(), subtitle()], { title: input ? input : 'Title slide', _width: 400, _height: 225, _freeform_fitContentsToBox: true, x, y });
- case 'header': return Docs.Create.FreeformDocument([header()], { title: input ? input : 'Section header', _width: 400, _height: 225, _freeform_fitContentsToBox: true, x, y });
- case 'content': return Docs.Create.FreeformDocument([contentTitle(), content()], { title: input ? input : 'Title and content', _width: 400, _height: 225, _freeform_fitContentsToBox: true, x, y });
- case 'twoColumns': return Docs.Create.FreeformDocument([contentTitle(), content1(), content2()], { title: input ? input : 'Title and two columns', _width: 400, _height: 225, _freeform_fitContentsToBox: true, x, y })
+ case 'blank': return Docs.Create.FreeformDocument([], { title: input || 'Blank slide', _width: 400, _height: 225, x, y });
+ case 'title': return Docs.Create.FreeformDocument([title(), subtitle()], { title: input || 'Title slide', _width: 400, _height: 225, _freeform_fitContentsToBox: true, x, y });
+ case 'header': return Docs.Create.FreeformDocument([header()], { title: input || 'Section header', _width: 400, _height: 225, _freeform_fitContentsToBox: true, x, y });
+ case 'content': return Docs.Create.FreeformDocument([contentTitle(), content()], { title: input || 'Title and content', _width: 400, _height: 225, _freeform_fitContentsToBox: true, x, y });
+ case 'twoColumns': return Docs.Create.FreeformDocument([contentTitle(), content1(), content2()], { title: input || 'Title and two columns', _width: 400, _height: 225, _freeform_fitContentsToBox: true, x, y })
+ default:
}
+ return undefined;
};
// Dropdown that appears when the user wants to begin presenting (either minimize or sidebar view)
@@ -2270,17 +2279,19 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
@action
- toggleProperties = () => (SettingsManager.Instance.propertiesWidth = SettingsManager.Instance.propertiesWidth > 0 ? 0 : 250);
+ toggleProperties = () => {
+ SnappingManager.SetPropertiesWidth(SnappingManager.PropertiesWidth > 0 ? 0 : 250);
+ };
@computed get toolbar() {
- const propIcon = SettingsManager.Instance.propertiesWidth > 0 ? 'angle-double-right' : 'angle-double-left';
- const propTitle = SettingsManager.Instance.propertiesWidth > 0 ? 'Close Presentation Panel' : 'Open Presentation Panel';
+ const propIcon = SnappingManager.PropertiesWidth > 0 ? 'angle-double-right' : 'angle-double-left';
+ const propTitle = SnappingManager.PropertiesWidth > 0 ? 'Close Presentation Panel' : 'Open Presentation Panel';
const mode = StrCast(this.Document._type_collection) as CollectionViewType;
const isMini: boolean = this.toolbarWidth <= 100;
- const activeColor = SettingsManager.userVariantColor;
- const inactiveColor = lightOrDark(SettingsManager.userBackgroundColor) === Colors.WHITE ? Colors.WHITE : SettingsManager.userBackgroundColor;
+ const activeColor = SnappingManager.userVariantColor;
+ const inactiveColor = lightOrDark(SnappingManager.userBackgroundColor) === Colors.WHITE ? Colors.WHITE : SnappingManager.userBackgroundColor;
return mode === CollectionViewType.Carousel3D || Doc.IsInMyOverlay(this.Document) ? null : (
- <div id="toolbarContainer" className={'presBox-toolbar'}>
+ <div id="toolbarContainer" className="presBox-toolbar">
{/* <Tooltip title={<><div className="dash-tooltip">{"Add new slide"}</div></>}><div className={`toolbar-button ${this.newDocumentTools ? "active" : ""}`} onClick={action(() => this.newDocumentTools = !this.newDocumentTools)}>
<FontAwesomeIcon icon={"plus"} />
<FontAwesomeIcon className={`dropdown ${this.newDocumentTools ? "active" : ""}`} icon={"angle-down"} />
@@ -2290,7 +2301,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
style={{ opacity: this.childDocs.length > 1 ? 1 : 0.3, color: this._pathBoolean ? Colors.MEDIUM_BLUE : 'white', width: isMini ? '100%' : undefined }}
className="toolbar-button"
onClick={this.childDocs.length > 1 ? () => this.togglePath() : undefined}>
- <FontAwesomeIcon icon={'exchange-alt'} />
+ <FontAwesomeIcon icon="exchange-alt" />
</div>
</Tooltip>
{isMini ? null : (
@@ -2298,12 +2309,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className="toolbar-divider" />
<Tooltip title={<div className="dash-tooltip">{this._presKeyEvents ? 'Keys are active' : 'Keys are not active - click anywhere on the presentation trail to activate keys'}</div>}>
<div className="toolbar-button" style={{ cursor: this._presKeyEvents ? 'default' : 'pointer', position: 'absolute', right: 30, fontSize: 16 }}>
- <FontAwesomeIcon className={'toolbar-thumbtack'} icon={'keyboard'} style={{ color: this._presKeyEvents ? activeColor : inactiveColor }} />
+ <FontAwesomeIcon className="toolbar-thumbtack" icon="keyboard" style={{ color: this._presKeyEvents ? activeColor : inactiveColor }} />
</div>
</Tooltip>
<Tooltip title={<div className="dash-tooltip">{propTitle}</div>}>
<div className="toolbar-button" style={{ position: 'absolute', right: 4, fontSize: 16 }} onClick={this.toggleProperties}>
- <FontAwesomeIcon className={'toolbar-thumbtack'} icon={propIcon} style={{ color: SettingsManager.Instance.propertiesWidth > 0 ? activeColor : inactiveColor }} />
+ <FontAwesomeIcon className="toolbar-thumbtack" icon={propIcon} style={{ color: SnappingManager.PropertiesWidth > 0 ? activeColor : inactiveColor }} />
</div>
</Tooltip>
</>
@@ -2348,7 +2359,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.gotoDocument(this.itemIndex, this.activeItem);
}
})}>
- <FontAwesomeIcon icon={'play-circle'} />
+ <FontAwesomeIcon icon="play-circle" />
<div style={{ display: this._props.PanelWidth() > 200 ? 'inline-flex' : 'none' }}>&nbsp; Present</div>
</div>
{mode === CollectionViewType.Carousel3D || isMini ? null : (
@@ -2357,7 +2368,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
onClick={action(() => {
if (this.childDocs.length) this._presentTools = !this._presentTools;
})}>
- <FontAwesomeIcon className="dropdown" style={{ margin: 0, transform: this._presentTools ? 'rotate(180deg)' : 'rotate(0deg)' }} icon={'angle-down'} />
+ <FontAwesomeIcon className="dropdown" style={{ margin: 0, transform: this._presentTools ? 'rotate(180deg)' : 'rotate(0deg)' }} icon="angle-down" />
{this.presentDropdown}
</div>
)}
@@ -2378,12 +2389,24 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
// Case 1: There are still other frames and should go through all frames before going to next slide
return (
<div className="presPanelOverlay" style={{ display: this.layoutDoc.presentation_status !== 'edit' ? 'inline-flex' : 'none' }}>
- <Tooltip title={<div className="dash-tooltip">{'Loop'}</div>}>
+ <Tooltip title={<div className="dash-tooltip">Loop</div>}>
<div
className="presPanel-button"
style={{ color: this.layoutDoc.presLoop ? Colors.MEDIUM_BLUE : 'white' }}
- onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, emptyFunction, () => (this.layoutDoc.presLoop = !this.layoutDoc.presLoop), false, false)}>
- <FontAwesomeIcon icon={'redo-alt'} />
+ onPointerDown={e =>
+ setupMoveUpEvents(
+ this,
+ e,
+ returnFalse,
+ emptyFunction,
+ () => {
+ this.layoutDoc.presLoop = !this.layoutDoc.presLoop;
+ },
+ false,
+ false
+ )
+ }>
+ <FontAwesomeIcon icon="redo-alt" />
</div>
</Tooltip>
<div className="presPanel-divider" />
@@ -2408,7 +2431,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
false
)
}>
- <FontAwesomeIcon icon={'arrow-left'} />
+ <FontAwesomeIcon icon="arrow-left" />
</div>
<Tooltip title={<div className="dash-tooltip">{this.layoutDoc.presentation_status === PresStatus.Autoplay ? 'Pause' : 'Autoplay'}</div>}>
<div className="presPanel-button" onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, emptyFunction, () => this.startOrPause(true), false, false)}>
@@ -2436,10 +2459,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
false
)
}>
- <FontAwesomeIcon icon={'arrow-right'} />
+ <FontAwesomeIcon icon="arrow-right" />
</div>
- <div className="presPanel-divider"></div>
- <Tooltip title={<div className="dash-tooltip">{'Click to return to 1st slide'}</div>}>
+ <div className="presPanel-divider" />
+ <Tooltip title={<div className="dash-tooltip">Click to return to 1st slide</div>}>
<div
className="presPanel-button"
style={{ border: 'solid 1px white' }}
@@ -2463,7 +2486,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
{inOverlay ? '' : 'Slide'} {this.itemIndex + 1}
{this.activeItem?.presentation_indexed !== undefined ? `(${this.activeItem.presentation_indexed}/${this.progressivizedItems(this.activeItem)?.length})` : ''} / {this.childDocs.length}
</div>
- <div className="presPanel-divider"></div>
+ <div className="presPanel-divider" />
{this._props.PanelWidth() > 250 ? (
<div
className="presPanel-button-text"
@@ -2477,7 +2500,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
) : (
<div className="presPanel-button" onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, emptyFunction, this.exitClicked, false, false)}>
- <FontAwesomeIcon icon={'times'} />
+ <FontAwesomeIcon icon="times" />
</div>
)}
</div>
@@ -2492,7 +2515,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
};
@action
- prevClicked = (e: PointerEvent) => {
+ prevClicked = () => {
this.back();
if (this._presTimer) {
clearTimeout(this._presTimer);
@@ -2501,7 +2524,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
};
@action
- nextClicked = (e: PointerEvent) => {
+ nextClicked = () => {
this.next();
if (this._presTimer) {
clearTimeout(this._presTimer);
@@ -2517,7 +2540,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
AddToMap = (treeViewDoc: Doc, index: number[]) => {
if (!treeViewDoc.presentation_targetDoc) return this.childDocs; // if treeViewDoc is not a pres elements, then it's a sub-bullet of a progressivized slide which isn't added to the linearized list of pres elements since it's not really a pres element.
- var indexNum = 0;
+ let indexNum = 0;
for (let i = 0; i < index.length; i++) {
indexNum += index[i] * 10 ** -i;
}
@@ -2529,19 +2552,21 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.dataDoc[this.presFieldKey] = new List<Doc>(sorted); // this is a flat array of Docs
}
}
+ return undefined;
};
SlideIndex = (slideDoc: Doc) => DocListCast(this.dataDoc[this.presFieldKey]).indexOf(slideDoc);
- RemFromMap = (treeViewDoc: Doc, index: number[]) => {
+ RemFromMap = (treeViewDoc: Doc) => {
if (!treeViewDoc.presentation_targetDoc) return this.childDocs; // if treeViewDoc is not a pres elements, then it's a sub-bullet of a progressivized slide which isn't added to the linearized list of pres elements since it's not really a pres element.
if (!this._unmounting && this.isTree) {
this._treeViewMap.delete(treeViewDoc);
this.dataDoc[this.presFieldKey] = new List<Doc>(this.sort(this._treeViewMap));
}
+ return undefined;
};
- sort = (treeView_Map: Map<Doc, number>) => [...treeView_Map.entries()].sort((a: [Doc, number], b: [Doc, number]) => (a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0)).map(kv => kv[0]);
+ sort = (treeViewMap: Map<Doc, number>) => [...treeViewMap.entries()].sort((a: [Doc, number], b: [Doc, number]) => (a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0)).map(kv => kv[0]);
render() {
// needed to ensure that the childDocs are loaded for looking up fields
@@ -2553,21 +2578,38 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
(this.activeItem.presentation_indexed === undefined || NumCast(this.activeItem.presentation_indexed) === (this.progressivizedItems(this.activeItem)?.length ?? 0));
const presStart = !this.layoutDoc.presLoop && this.itemIndex === 0;
return this._props.addDocTab === returnFalse ? ( // bcz: hack!! - addDocTab === returnFalse only when this is being rendered by the OverlayView which means the doc is a mini player
- <div className="miniPres" onClick={e => e.stopPropagation()} onPointerEnter={action(e => (this._forceKeyEvents = true))}>
+ <div
+ className="miniPres"
+ onClick={e => e.stopPropagation()}
+ onPointerEnter={action(() => {
+ this._forceKeyEvents = true;
+ })}>
<div
className="presPanelOverlay"
style={{ display: 'inline-flex', height: 30, background: Doc.ActivePresentation === this.Document ? 'green' : '#323232', top: 0, zIndex: 3000000, boxShadow: this._presKeyEvents ? '0 0 0px 3px ' + Colors.MEDIUM_BLUE : undefined }}>
- <Tooltip title={<div className="dash-tooltip">{'Loop'}</div>}>
+ <Tooltip title={<div className="dash-tooltip">Loop</div>}>
<div
className="presPanel-button"
style={{ color: this.layoutDoc.presLoop ? Colors.MEDIUM_BLUE : undefined }}
- onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, returnFalse, () => (this.layoutDoc.presLoop = !this.layoutDoc.presLoop), false, false)}>
- <FontAwesomeIcon icon={'redo-alt'} />
+ onPointerDown={e =>
+ setupMoveUpEvents(
+ this,
+ e,
+ returnFalse,
+ returnFalse,
+ () => {
+ this.layoutDoc.presLoop = !this.layoutDoc.presLoop;
+ },
+ false,
+ false
+ )
+ }>
+ <FontAwesomeIcon icon="redo-alt" />
</div>
</Tooltip>
- <div className="presPanel-divider"></div>
+ <div className="presPanel-divider" />
<div className="presPanel-button" style={{ opacity: presStart ? 0.4 : 1 }} onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, returnFalse, this.prevClicked, false, false)}>
- <FontAwesomeIcon icon={'arrow-left'} />
+ <FontAwesomeIcon icon="arrow-left" />
</div>
<Tooltip title={<div className="dash-tooltip">{this.layoutDoc.presentation_status === PresStatus.Autoplay ? 'Pause' : 'Autoplay'}</div>}>
<div className="presPanel-button" onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, returnFalse, () => this.startOrPause(true), false, false)}>
@@ -2575,10 +2617,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
</Tooltip>
<div className="presPanel-button" style={{ opacity: presEnd ? 0.4 : 1 }} onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, returnFalse, this.nextClicked, false, false)}>
- <FontAwesomeIcon icon={'arrow-right'} />
+ <FontAwesomeIcon icon="arrow-right" />
</div>
- <div className="presPanel-divider"></div>
- <Tooltip title={<div className="dash-tooltip">{'Click to return to 1st slide'}</div>}>
+ <div className="presPanel-divider" />
+ <Tooltip title={<div className="dash-tooltip">Click to return to 1st slide</div>}>
<div className="presPanel-button" style={{ border: 'solid 1px white' }} onPointerDown={e => setupMoveUpEvents(this, e, returnFalse, returnFalse, () => this.gotoDocument(0, this.activeItem), false, false)}>
<b>1</b>
</div>
@@ -2602,27 +2644,28 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className="Slide">
{mode !== CollectionViewType.Invalid ? (
<CollectionView
+ // eslint-disable-next-line react/jsx-props-no-spreading
{...this._props}
PanelWidth={this._props.PanelWidth}
PanelHeight={this.panelHeight}
- childIgnoreNativeSize={true}
+ childIgnoreNativeSize
moveDocument={returnFalse}
- ignoreUnrendered={true}
+ ignoreUnrendered
childDragAction={dropActionType.move}
setContentViewBox={emptyFunction}
- //childLayoutFitWidth={returnTrue}
+ // childLayoutFitWidth={returnTrue}
childOpacity={returnOne}
childClickScript={PresBox.navigateToDocScript}
childLayoutTemplate={this.childLayoutTemplate}
childXPadding={Doc.IsComicStyle(this.Document) ? 20 : undefined}
filterAddDocument={this.addDocumentFilter}
removeDocument={returnFalse}
- dontRegisterView={true}
+ dontRegisterView
focus={this.focusElement}
ScreenToLocalTransform={this.getTransform}
AddToMap={this.AddToMap}
RemFromMap={this.RemFromMap}
- hierarchyIndex={emptyPath as any as number[]}
+ hierarchyIndex={emptyPath}
/>
) : null}
</div>
@@ -2641,6 +2684,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
}
+// eslint-disable-next-line prefer-arrow-callback
ScriptingGlobals.add(function navigateToDoc(bestTarget: Doc, activeItem: Doc) {
PresBox.NavigateToTarget(bestTarget, activeItem);
});
+
+Docs.Prototypes.TemplateMap.set(DocumentType.PRES, {
+ layout: { view: PresBox, dataField: 'data' },
+ options: { acl: '', defaultDoubleClick: 'ignore', hideClickBehaviors: true, layout_hideLinkAnchors: true },
+});