aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/ScreenshotBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/ScreenshotBox.tsx')
-rw-r--r--src/client/views/nodes/ScreenshotBox.tsx65
1 files changed, 38 insertions, 27 deletions
diff --git a/src/client/views/nodes/ScreenshotBox.tsx b/src/client/views/nodes/ScreenshotBox.tsx
index 1e3933ac3..3be50f5e6 100644
--- a/src/client/views/nodes/ScreenshotBox.tsx
+++ b/src/client/views/nodes/ScreenshotBox.tsx
@@ -1,33 +1,37 @@
+/* eslint-disable jsx-a11y/media-has-caption */
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import * as React from 'react';
// import { Canvas } from '@react-three/fiber';
import { computed, makeObservable, observable, runInAction } from 'mobx';
import { observer } from 'mobx-react';
// import { BufferAttribute, Camera, Vector2, Vector3 } from 'three';
+import { returnFalse, returnOne, returnZero } from '../../../ClientUtils';
+import { emptyFunction } from '../../../Utils';
import { DateField } from '../../../fields/DateField';
import { Doc } from '../../../fields/Doc';
+import { DocData } from '../../../fields/DocSymbols';
import { Id } from '../../../fields/FieldSymbols';
import { ComputedField } from '../../../fields/ScriptField';
import { Cast, DocCast, NumCast } from '../../../fields/Types';
import { AudioField, VideoField } from '../../../fields/URLField';
import { TraceMobx } from '../../../fields/util';
-import { emptyFunction, returnFalse, returnOne, returnZero } from '../../../Utils';
-import { DocUtils } from '../../documents/Documents';
-import { DocumentType } from '../../documents/DocumentTypes';
import { Networking } from '../../Network';
+import { DocUtils } from '../../documents/DocUtils';
+import { DocumentType } from '../../documents/DocumentTypes';
+import { Docs } from '../../documents/Documents';
import { CaptureManager } from '../../util/CaptureManager';
import { SettingsManager } from '../../util/SettingsManager';
import { TrackMovements } from '../../util/TrackMovements';
-import { CollectionFreeFormView } from '../collections/collectionFreeForm/CollectionFreeFormView';
-import { CollectionStackedTimeline } from '../collections/CollectionStackedTimeline';
import { ContextMenu } from '../ContextMenu';
import { ViewBoxAnnotatableComponent } from '../DocComponent';
-import { media_state } from './AudioBox';
+import { DocViewUtils } from '../DocViewUtils';
+import { CollectionStackedTimeline } from '../collections/CollectionStackedTimeline';
+import { CollectionFreeFormView } from '../collections/collectionFreeForm/CollectionFreeFormView';
+import { mediaState } from './AudioBox';
import { FieldView, FieldViewProps } from './FieldView';
-import { FormattedTextBox } from './formattedText/FormattedTextBox';
import './ScreenshotBox.scss';
import { VideoBox } from './VideoBox';
-import { DocData } from '../../../fields/DocSymbols';
+import { FormattedTextBox } from './formattedText/FormattedTextBox';
declare class MediaRecorder {
constructor(e: any, options?: any); // whatever MediaRecorder has
@@ -158,11 +162,11 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
// });
}
componentWillUnmount() {
- const ind = DocUtils.ActiveRecordings.indexOf(this);
- ind !== -1 && DocUtils.ActiveRecordings.splice(ind, 1);
+ const ind = DocViewUtils.ActiveRecordings.indexOf(this);
+ ind !== -1 && DocViewUtils.ActiveRecordings.splice(ind, 1);
}
- specificContextMenu = (e: React.MouseEvent): void => {
+ specificContextMenu = (): void => {
const subitems = [{ description: 'Screen Capture', event: this.toggleRecording, icon: 'expand-arrows-alt' as any }];
ContextMenu.Instance.addItem({ description: 'Options...', subitems, icon: 'video' });
};
@@ -170,12 +174,12 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
@computed get content() {
return (
<video
- className={'videoBox-content'}
+ className="videoBox-content"
key="video"
ref={r => {
this._videoRef = r;
setTimeout(() => {
- if (this.layoutDoc.mediaState === media_state.PendingRecording && this._videoRef) {
+ if (this.layoutDoc.mediaState === mediaState.PendingRecording && this._videoRef) {
this.toggleRecording();
}
}, 100);
@@ -183,7 +187,7 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
autoPlay={this._screenCapture}
style={{ width: this._screenCapture ? '100%' : undefined, height: this._screenCapture ? '100%' : undefined }}
onCanPlay={this.videoLoad}
- controls={true}
+ controls
onClick={e => e.preventDefault()}>
<source type="video/mp4" />
Not supported.
@@ -220,23 +224,23 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
toggleRecording = async () => {
if (!this._screenCapture) {
this._audioRec = new MediaRecorder(await navigator.mediaDevices.getUserMedia({ audio: true }));
- const aud_chunks: any = [];
- this._audioRec.ondataavailable = (e: any) => aud_chunks.push(e.data);
- this._audioRec.onstop = async (e: any) => {
- const [{ result }] = await Networking.UploadFilesToServer(aud_chunks.map((file: any) => ({ file })));
+ const audChunks: any = [];
+ this._audioRec.ondataavailable = (e: any) => audChunks.push(e.data);
+ this._audioRec.onstop = async () => {
+ const [{ result }] = await Networking.UploadFilesToServer(audChunks.map((file: any) => ({ file })));
if (!(result instanceof Error)) {
this.dataDoc[this._props.fieldKey + '_audio'] = new AudioField(result.accessPaths.agnostic.client);
}
};
this._videoRef!.srcObject = await (navigator.mediaDevices as any).getDisplayMedia({ video: true });
this._videoRec = new MediaRecorder(this._videoRef!.srcObject);
- const vid_chunks: any = [];
+ const vidChunks: any = [];
this._videoRec.onstart = () => {
if (this.dataDoc[this._props.fieldKey + '_trackScreen']) TrackMovements.Instance.start();
this.dataDoc[this._props.fieldKey + '_recordingStart'] = new DateField(new Date());
};
- this._videoRec.ondataavailable = (e: any) => vid_chunks.push(e.data);
- this._videoRec.onstop = async (e: any) => {
+ this._videoRec.ondataavailable = (e: any) => vidChunks.push(e.data);
+ this._videoRec.onstop = async () => {
const presentation = TrackMovements.Instance.yieldPresentation();
if (presentation?.movements) {
const presCopy = { ...presentation };
@@ -244,7 +248,7 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
this.dataDoc[this.fieldKey + '_presentation'] = JSON.stringify(presCopy);
}
TrackMovements.Instance.finish();
- const file = new File(vid_chunks, `${this.Document[Id]}.mkv`, { type: vid_chunks[0].type, lastModified: Date.now() });
+ const file = new File(vidChunks, `${this.Document[Id]}.mkv`, { type: vidChunks[0].type, lastModified: Date.now() });
const [{ result }] = await Networking.UploadFilesToServer({ file });
this.dataDoc[this.fieldKey + '_duration'] = (new Date().getTime() - this.recordingStart!) / 1000;
if (!(result instanceof Error)) {
@@ -262,7 +266,7 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
this._screenCapture = true;
this.dataDoc.mediaState = 'recording';
});
- DocUtils.ActiveRecordings.push(this);
+ DocViewUtils.ActiveRecordings.push(this);
} else {
this._audioRec?.stop();
this._videoRec?.stop();
@@ -270,8 +274,8 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
this._screenCapture = false;
this.dataDoc.mediaState = 'paused';
});
- const ind = DocUtils.ActiveRecordings.indexOf(this);
- ind !== -1 && DocUtils.ActiveRecordings.splice(ind, 1);
+ const ind = DocViewUtils.ActiveRecordings.indexOf(this);
+ ind !== -1 && DocViewUtils.ActiveRecordings.splice(ind, 1);
CaptureManager.Instance.open(this.Document);
}
@@ -297,6 +301,7 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
<div className="videoBox-viewer">
<div style={{ position: 'relative', height: this.videoPanelHeight() }}>
<CollectionFreeFormView
+ // eslint-disable-next-line react/jsx-props-no-spreading
{...this._props}
setContentViewBox={emptyFunction}
NativeWidth={returnZero}
@@ -305,7 +310,7 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
PanelWidth={this._props.PanelWidth}
focus={this._props.focus}
isSelected={this._props.isSelected}
- isAnnotationOverlay={true}
+ isAnnotationOverlay
select={emptyFunction}
isContentActive={returnFalse}
NativeDimScaling={returnOne}
@@ -324,9 +329,10 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
<div style={{ background: SettingsManager.userColor, position: 'relative', height: this.formattedPanelHeight() }}>
{!(this.dataDoc[this.fieldKey + '_dictation'] instanceof Doc) ? null : (
<FormattedTextBox
+ // eslint-disable-next-line react/jsx-props-no-spreading
{...this._props}
Document={DocCast(this.dataDoc[this.fieldKey + '_dictation'])}
- fieldKey={'text'}
+ fieldKey="text"
PanelHeight={this.formattedPanelHeight}
select={emptyFunction}
isContentActive={emptyFunction}
@@ -353,3 +359,8 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
);
}
}
+
+Docs.Prototypes.TemplateMap.set(DocumentType.SCREENSHOT, {
+ layout: { view: ScreenshotBox, dataField: 'data' },
+ options: { acl: '', _layout_nativeDimEditable: true, systemIcon: 'BsCameraFill' },
+});