aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/util/CurrentUserUtils.ts2
-rw-r--r--src/client/util/DragManager.ts55
-rw-r--r--src/client/views/nodes/RecordingBox/RecordingBox.tsx25
3 files changed, 73 insertions, 9 deletions
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 1d63e90f0..99a8ee571 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -720,7 +720,7 @@ export class CurrentUserUtils {
{ title: "Play Rec",icon: "play", toolTip: "Play recording", btnType: ButtonType.ToggleButton, expertMode: false, funcs: {hidden: `!getIsRecPlayback()`}, ignoreClick: true, scripts: { onClick: `return playWorkspaceRec(getCurrentRecording())`}},
{ title: "Pause Rec",icon: "pause", toolTip: "Pause recording", btnType: ButtonType.ToggleButton, expertMode: false, funcs: {hidden: `!getIsRecPlayback()`}, ignoreClick: true, scripts: { onClick: `return pauseWorkspaceRec(getCurrentRecording())`}},
{ title: "Stop Rec", icon: "stop", toolTip: "Stop recording", btnType: ButtonType.ToggleButton, expertMode: false, funcs: {hidden: `!getIsRecPlayback()`}, ignoreClick: true, scripts: { onClick: `return closeWorkspaceRec(getCurrentRecording())`}},
- { title: "Add doc", icon: "down", toolTip: "add to doc", btnType: ButtonType.ToggleButton, expertMode: false, funcs: {hidden: `!getIsRecPlayback()`}, ignoreClick: true, scripts: { onClick: `console.log("heya")`}},
+ { title: "Add doc", icon: "down", toolTip: "add to doc", btnType: ButtonType.ToggleButton, expertMode: false, funcs: {hidden: `!getIsRecPlayback()`}, ignoreClick: true, scripts: { onClick: `addRectoWorkspace(getCurrentRecording())`}},
];
}
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index f4ff38515..f06d4a0e7 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -4,7 +4,7 @@ import { Doc, Field, Opt, StrListCast } from '../../fields/Doc';
import { List } from '../../fields/List';
import { PrefetchProxy } from '../../fields/Proxy';
import { ScriptField } from '../../fields/ScriptField';
-import { BoolCast, ScriptCast, StrCast } from '../../fields/Types';
+import { BoolCast, Cast, ScriptCast, StrCast } from '../../fields/Types';
import { emptyFunction, Utils } from '../../Utils';
import { Docs, DocUtils } from '../documents/Documents';
import * as globalCssVariables from '../views/global/globalCssVariables.scss';
@@ -14,6 +14,7 @@ import { ScriptingGlobals } from './ScriptingGlobals';
import { SelectionManager } from './SelectionManager';
import { SnappingManager } from './SnappingManager';
import { UndoManager } from './UndoManager';
+import { listSpec } from '../../fields/Schema';
export type dropActionType = 'embed' | 'copy' | 'move' | 'add' | 'same' | 'proto' | 'none' | undefined; // undefined = move, "same" = move but don't call dropPropertiesToRemove
@@ -241,6 +242,58 @@ export namespace DragManager {
return true;
}
+ export function StartDropdownDrag(eles: HTMLElement[], dragData: DocumentDragData, downX: number, downY: number, recordingIndex: number, options?: DragOptions, dropEvent?: () => any,) {
+
+ const addAudioTag = (dropDoc: any) => {
+ dropDoc && !dropDoc.author_date && (dropDoc.author_date = new DateField());
+ dropDoc instanceof Doc && DocUtils.MakeLinkToActiveAudio(() => dropDoc);
+ return dropDoc;
+ };
+ const finishDrag = async (e: DragCompleteEvent) => {
+ Doc.UserDoc().isAddRecToDocMode = false;
+ Doc.RemFromMyOverlay(Doc.UserDoc().currentRecording);
+ Doc.UserDoc().currentRecording = undefined;
+ Doc.UserDoc().isRecPlayback = false;
+ Cast(Doc.UserDoc().workspaceRecordings, listSpec(Doc), null)?.splice(recordingIndex, 1);
+ const docDragData = e.docDragData;
+ dropEvent?.(); // glr: optional additional function to be called - in this case with presentation trails
+ if (docDragData && !docDragData.droppedDocuments.length) {
+ docDragData.dropAction = dragData.userDropAction || dragData.dropAction;
+ docDragData.droppedDocuments = (
+ await Promise.all(
+ dragData.draggedDocuments.map(async d =>
+ !dragData.isDocDecorationMove && !dragData.userDropAction && ScriptCast(d.onDragStart)
+ ? addAudioTag(ScriptCast(d.onDragStart).script.run({ this: d }).result)
+ : docDragData.dropAction === 'embed'
+ ? Doc.BestEmbedding(d)
+ : docDragData.dropAction === 'add'
+ ? d
+ : docDragData.dropAction === 'proto'
+ ? Doc.GetProto(d)
+ : docDragData.dropAction === 'copy'
+ ? (
+ await Doc.MakeClone(d)
+ ).clone
+ : d
+ )
+ )
+ ).filter(d => d);
+ !['same', 'proto'].includes(docDragData.dropAction as any) &&
+ docDragData.droppedDocuments
+ // .filter(drop => !drop.dragOnlyWithinContainer || ['embed', 'copy'].includes(docDragData.dropAction as any))
+ .forEach((drop: Doc, i: number) => {
+ const dragProps = StrListCast(dragData.draggedDocuments[i].dropPropertiesToRemove);
+ const remProps = (dragData?.dropPropertiesToRemove || []).concat(Array.from(dragProps));
+ [...remProps, 'dropPropertiesToRemove'].map(prop => (drop[prop] = undefined));
+ });
+ }
+ return e;
+ };
+ dragData.draggedDocuments.map(d => d.dragFactory); // does this help? trying to make sure the dragFactory Doc is loaded
+ StartDrag(eles, dragData, downX, downY, options, finishDrag);
+ return true;
+ }
+
// drag a button template and drop a new button
export function StartButtonDrag(eles: HTMLElement[], script: string, title: string, vars: { [name: string]: Field }, params: string[], initialize: (button: Doc) => void, downX: number, downY: number, options?: DragOptions) {
const finishDrag = (e: DragCompleteEvent) => {
diff --git a/src/client/views/nodes/RecordingBox/RecordingBox.tsx b/src/client/views/nodes/RecordingBox/RecordingBox.tsx
index 5502a1e08..d6e4bd304 100644
--- a/src/client/views/nodes/RecordingBox/RecordingBox.tsx
+++ b/src/client/views/nodes/RecordingBox/RecordingBox.tsx
@@ -11,7 +11,7 @@ import { DocumentType } from '../../../documents/DocumentTypes';
import { Presentation } from '../../../util/TrackMovements';
import { Doc, DocListCast } from '../../../../fields/Doc';
import { Id } from '../../../../fields/FieldSymbols';
-import { BoolCast, DocCast } from '../../../../fields/Types';
+import { BoolCast, Cast, DocCast } from '../../../../fields/Types';
import { ScriptingGlobals } from '../../../util/ScriptingGlobals';
import { DocumentManager } from '../../../util/DocumentManager';
import { Docs } from '../../../documents/Documents';
@@ -22,6 +22,8 @@ import { SettingsManager } from '../../../util/SettingsManager';
import { PropertiesView } from '../../PropertiesView';
import { PropertiesSection } from '../../PropertiesSection';
import { PropertiesDocContextSelector } from '../../PropertiesDocContextSelector';
+import { listSpec } from '../../../../fields/Schema';
+import { DragManager } from '../../../util/DragManager';
@observer
export class RecordingBox extends ViewBoxBaseComponent<FieldViewProps>() {
@@ -146,17 +148,26 @@ ScriptingGlobals.add(function toggleRecPlayback(value: Doc) {
console.log(value)
value.overlayX = 100;
value.overlayY = 100;
+ if (!Doc.UserDoc().isAddRecToDocMode) {
Doc.AddToMyOverlay(value);
- DocumentManager.Instance.AddViewRenderedCb(value, docView => {
- docval =
- Doc.UserDoc().currentRecording = docView.ComponentView as VideoBox;
- // docval.Play();
- })
+ DocumentManager.Instance.AddViewRenderedCb(value, docView => {
+ docval =
+ Doc.UserDoc().currentRecording = docView.ComponentView as VideoBox;
+ // docval.Play();
+ })} else {
+ let recordingIndex = Array.from(Doc.UserDoc().workspaceRecordings).indexOf(value);
+ DragManager.StartDropdownDrag([document.createElement('div')],new DragManager.DocumentDragData([value]), 1, 1, recordingIndex);
+
+ }
+
// let ffView = Array.from(DocumentManager.Instance.DocumentViews).find(view => view.ComponentView instanceof CollectionFreeFormView);
// (ffView?.ComponentView as CollectionFreeFormView).props.addDocument?.(value);
});
-ScriptingGlobals.add(function addRectoWorkspace() {
+ScriptingGlobals.add(function addRectoWorkspace(value: VideoBox) {
console.log("adding rec to doc");
+ console.log(value.rootDoc);
+ Doc.UserDoc().isAddRecToDocMode = true;
+
})
ScriptingGlobals.add(function playWorkspaceRec(value: VideoBox) {