From d3ecf7bdacd925fcd293a300c53206b12bee8ce9 Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 16 May 2023 20:41:37 -0400 Subject: cleaned up UndoStack a bit to be available with the undo/redo buttons (using Long Press). --- src/client/views/UndoStack.scss | 29 ++++++++++++++++++ src/client/views/UndoStack.tsx | 35 ++++++++++++++++------ .../views/collections/CollectionDockingView.tsx | 9 ++++-- .../collectionLinear/CollectionLinearView.tsx | 11 +++++-- src/client/views/nodes/DocumentView.tsx | 2 +- 5 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 src/client/views/UndoStack.scss (limited to 'src/client/views') diff --git a/src/client/views/UndoStack.scss b/src/client/views/UndoStack.scss new file mode 100644 index 000000000..ab21e6d7e --- /dev/null +++ b/src/client/views/UndoStack.scss @@ -0,0 +1,29 @@ +.undoStack-outerContainer { + height: 100%; + display: flex; + flex-direction: column; + position: relative; + pointer-events: all; + padding-left: 4px; +} + +.undoStack-resultContainer { + border-radius: 5px; +} + +.undoStack-commandInput { + width: 100%; +} + +.undoStack-commandResult, +.undoStack-commandString { + overflow-wrap: break-word; +} + +.undoStack-commandsContainer { + background-color: whitesmoke; + flex: 1 1 auto; + overflow-y: scroll; + height: 30px; + border-radius: 5px; +} diff --git a/src/client/views/UndoStack.tsx b/src/client/views/UndoStack.tsx index 01e184d6b..f5af09e5b 100644 --- a/src/client/views/UndoStack.tsx +++ b/src/client/views/UndoStack.tsx @@ -1,24 +1,41 @@ +import { action, observable } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; import { UndoManager } from '../util/UndoManager'; -import './ScriptingRepl.scss'; +import './UndoStack.scss'; +interface UndoStackProps { + width?: number; + height?: number; + inline?: boolean; +} @observer -export class UndoStack extends React.Component { +export class UndoStack extends React.Component { + @observable static HideInline: boolean; + @observable static Expand: boolean; render() { - return ( -
-
r?.scroll({ behavior: 'auto', top: r?.scrollHeight + 20 })} style={{ background: UndoManager.batchCounter.get() ? 'yellow' : undefined }}> + return this.props.inline && UndoStack.HideInline ? null : ( +
(UndoStack.Expand = !UndoStack.Expand))} + onDoubleClick={action(e => (UndoStack.Expand = UndoStack.HideInline = false))}> +
r?.scroll({ behavior: 'auto', top: r?.scrollHeight + 20 })} style={{ background: UndoManager.batchCounter.get() ? 'yellow' : undefined }}> +
+
+ Undo/Redo Stack +
+
{UndoManager.undoStackNames.map((name, i) => ( -
-
{name.replace(/[^\.]*\./, '')}
+
+
{name.replace(/[^\.]*\./, '')}
))} {Array.from(UndoManager.redoStackNames) .reverse() .map((name, i) => ( -
-
+
+
{name.replace(/[^\.]*\./, '')}
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx index 4ae24af60..76dadc76d 100644 --- a/src/client/views/collections/CollectionDockingView.tsx +++ b/src/client/views/collections/CollectionDockingView.tsx @@ -23,6 +23,7 @@ import { LightboxView } from '../LightboxView'; import { OpenWhere, OpenWhereMod } from '../nodes/DocumentView'; import { OverlayView } from '../OverlayView'; import { ScriptingRepl } from '../ScriptingRepl'; +import { UndoStack } from '../UndoStack'; import './CollectionDockingView.scss'; import { CollectionFreeFormView } from './collectionFreeForm'; import { CollectionSubView, SubCollectionViewProps } from './CollectionSubView'; @@ -587,8 +588,12 @@ ScriptingGlobals.add( case OpenWhere.addRight: return CollectionDockingView.AddSplit(doc, OpenWhereMod.right); case OpenWhere.overlay: - if (doc === 'repl') OverlayView.Instance.addWindow(, { x: 300, y: 100, width: 200, height: 200, title: 'Scripting REPL' }); - else Doc.AddDocToList(Doc.MyOverlayDocs, undefined, doc); + // prettier-ignore + switch (doc) { + case '': return OverlayView.Instance.addWindow(, { x: 300, y: 100, width: 200, height: 200, title: 'Scripting REPL' }); + case "": return OverlayView.Instance.addWindow(, { x: 300, y: 100, width: 200, height: 200, title: 'Scripting REPL' }); + } + Doc.AddDocToList(Doc.MyOverlayDocs, undefined, doc); } }, 'opens up document in location specified', diff --git a/src/client/views/collections/collectionLinear/CollectionLinearView.tsx b/src/client/views/collections/collectionLinear/CollectionLinearView.tsx index 9d82e3198..e0c294da4 100644 --- a/src/client/views/collections/collectionLinear/CollectionLinearView.tsx +++ b/src/client/views/collections/collectionLinear/CollectionLinearView.tsx @@ -15,6 +15,7 @@ import { DocumentLinksButton } from '../../nodes/DocumentLinksButton'; import { DocumentView } from '../../nodes/DocumentView'; import { LinkDescriptionPopup } from '../../nodes/LinkDescriptionPopup'; import { StyleProp } from '../../StyleProvider'; +import { UndoStack } from '../../UndoStack'; import { CollectionStackedTimeline } from '../CollectionStackedTimeline'; import { CollectionSubView } from '../CollectionSubView'; import './CollectionLinearView.scss'; @@ -161,9 +162,15 @@ export class CollectionLinearView extends CollectionSubView() { ); }; + getDisplayDoc = (doc: Doc, preview: boolean = false) => { - if (doc.icon === 'linkui') return this.getLinkUI(); - if (doc.icon === 'currentlyplayingui') return this.getCurrentlyPlayingUI(); + // hack to avoid overhead of making UndoStack,etc into DocumentView style Boxes. If the UndoStack is ever intended to become part of the persisten state of the dashboard, then this would have to change. + // prettier-ignore + switch (doc.layout) { + case '': return this.getLinkUI(); + case '': return this.getCurrentlyPlayingUI(); + case '': return ; + } const nested = doc._type_collection === CollectionViewType.Linear; const hidden = doc.hidden === true; diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 52eee84ac..10ef1e6af 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -506,7 +506,7 @@ export class DocumentViewInternal extends DocComponent { if (DocumentView.LongPress) { if (this.rootDoc.dontUndo) { - OverlayView.Instance.addWindow(, { x: 300, y: 100, width: 200, height: 200, title: 'Undo Stack' }); + runInAction(() => (UndoStack.HideInline = !UndoStack.HideInline)); } else { this.props.select(false); } -- cgit v1.2.3-70-g09d2