From 2e0e34df0db385acfcd4079fae6e01fd4a2234fa Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 27 Aug 2020 19:59:14 -0400 Subject: added undo for deleting presentation view items. fixed scroll height of mainView sidebar. --- src/client/views/AntimodeMenu.tsx | 2 +- src/client/views/MainView.scss | 2 +- src/client/views/MainView.tsx | 13 ++++++------- src/client/views/collections/CollectionMenu.tsx | 6 +++--- .../collections/collectionFreeForm/FormatShapePane.tsx | 4 ++-- .../views/collections/collectionFreeForm/MarqueeView.tsx | 2 +- src/client/views/nodes/formattedText/RichTextMenu.tsx | 2 +- src/client/views/presentationview/PresElementBox.tsx | 2 ++ 8 files changed, 17 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/client/views/AntimodeMenu.tsx b/src/client/views/AntimodeMenu.tsx index 32fb24b32..3b0c56adc 100644 --- a/src/client/views/AntimodeMenu.tsx +++ b/src/client/views/AntimodeMenu.tsx @@ -86,7 +86,7 @@ export abstract class AntimodeMenu extends React.Co @action protected togglePin = (e: React.MouseEvent) => { - this.Pinned = !this.Pinned; + runInAction(() => this.Pinned = !this.Pinned); } protected dragStart = (e: React.PointerEvent) => { diff --git a/src/client/views/MainView.scss b/src/client/views/MainView.scss index aebb7a19a..05a8b5c80 100644 --- a/src/client/views/MainView.scss +++ b/src/client/views/MainView.scss @@ -23,7 +23,7 @@ // add nodes menu. Note that the + button is actually an input label, not an actual button. .mainView-docButtons { position: absolute; - bottom: 35px; + bottom: 10px; left: calc(100% + 5px); z-index: 1; } diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index d107b74f0..0bdfa0cdd 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -94,7 +94,7 @@ export class MainView extends React.Component { } else { return undefined; } } - propertiesWidth = () => Math.max(0, Math.min(this._panelWidth - 50, CurrentUserUtils.propertiesWidth)); + propertiesWidth = () => Math.max(0, Math.min(this._panelWidth - 50, CurrentUserUtils.propertiesWidth || 0)); @computed get propertiesIcon() { if (this.propertiesWidth() < 10) { @@ -147,8 +147,6 @@ export class MainView extends React.Component { CurrentUserUtils._urlState = HistoryUtil.parseUrl(window.location) || {} as any; // causes errors to be generated when modifying an observable outside of an action - CurrentUserUtils.propertiesWidth = 0; - configure({ enforceActions: "observed" }); if (window.location.pathname !== "/home") { const pathname = window.location.pathname.substr(1).split("/"); @@ -352,7 +350,7 @@ export class MainView extends React.Component { TraceMobx(); const mainContainer = this.mainContainer; const width = this.flyoutWidth + this.propertiesWidth(); - return
+ return
{!mainContainer ? (null) : this.mainDocView}
; } @@ -383,6 +381,7 @@ export class MainView extends React.Component { } } + @computed get topOffset() { return (CollectionMenu.Instance?.Pinned ? 35 : 0) + Number(SEARCH_PANEL_HEIGHT.replace("px", "")); } flyoutWidthFunc = () => this.flyoutWidth; addDocTabFunc = (doc: Doc, where: string, libraryPath?: Doc[]): boolean => { return where === "close" ? CollectionDockingView.CloseRightSplit(doc) : @@ -395,7 +394,7 @@ export class MainView extends React.Component { @computed get flyout() { if (!this.sidebarContent) return null; return
-
+
{/* {this.flyoutWidth > 0 ?
@@ -575,8 +574,8 @@ export class MainView extends React.Component { } @computed get mainContent() { - const n = (CollectionMenu.Instance?.Pinned ? 1 : 0); - const height = `calc(100% - ${n * Number(ANTIMODEMENU_HEIGHT.replace("px", ""))}px)`; + const height = `calc(100% - ${this.topOffset}px)`; + console.log("Height = " + height); const pinned = FormatShapePane.Instance?.Pinned; const innerContent = this.mainInnerContent; return !this.userDoc ? (null) : ( diff --git a/src/client/views/collections/CollectionMenu.tsx b/src/client/views/collections/CollectionMenu.tsx index 6f93bd12a..f5d64ba0d 100644 --- a/src/client/views/collections/CollectionMenu.tsx +++ b/src/client/views/collections/CollectionMenu.tsx @@ -36,7 +36,7 @@ import { PresBox } from "../nodes/PresBox"; @observer export class CollectionMenu extends AntimodeMenu { - static Instance: CollectionMenu; + @observable static Instance: CollectionMenu; @observable SelectedCollection: DocumentView | undefined; @observable FieldKey: string; @@ -44,9 +44,9 @@ export class CollectionMenu extends AntimodeMenu { constructor(props: any) { super(props); this.FieldKey = ""; - CollectionMenu.Instance = this; + runInAction(() => CollectionMenu.Instance = this); this._canFade = false; // don't let the inking menu fade away - this.Pinned = Cast(Doc.UserDoc()["menuCollections-pinned"], "boolean", true); + runInAction(() => this.Pinned = Cast(Doc.UserDoc()["menuCollections-pinned"], "boolean", true)); this.jumpTo(300, 300); } diff --git a/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx b/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx index 91efe139e..e6ec274f0 100644 --- a/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx +++ b/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx @@ -1,7 +1,7 @@ import React = require("react"); import { IconProp } from '@fortawesome/fontawesome-svg-core'; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { action, computed, observable } from "mobx"; +import { action, computed, observable, runInAction } from "mobx"; import { observer } from "mobx-react"; import { Doc, Field, Opt } from "../../../../fields/Doc"; import { Document } from "../../../../fields/documentSchemas"; @@ -91,7 +91,7 @@ export class FormatShapePane extends AntimodeMenu { super(props); FormatShapePane.Instance = this; this._canFade = false; - this.Pinned = BoolCast(Doc.UserDoc()["menuFormatShape-pinned"]); + runInAction(() => this.Pinned = BoolCast(Doc.UserDoc()["menuFormatShape-pinned"])); } @action diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx index 00ddebfd2..f2934f0e6 100644 --- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx +++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx @@ -783,7 +783,7 @@ export class MarqueeView extends React.Component e.preventDefault()} onScroll={(e) => e.currentTarget.scrollTop = e.currentTarget.scrollLeft = 0} onClick={this.onClick} onPointerDown={this.onPointerDown}> {this._visible ? this.marqueeDiv : null} diff --git a/src/client/views/nodes/formattedText/RichTextMenu.tsx b/src/client/views/nodes/formattedText/RichTextMenu.tsx index a0e2d4351..3812e878f 100644 --- a/src/client/views/nodes/formattedText/RichTextMenu.tsx +++ b/src/client/views/nodes/formattedText/RichTextMenu.tsx @@ -75,7 +75,7 @@ export class RichTextMenu extends AntimodeMenu { RichTextMenu.Instance = this; this._canFade = false; //this.Pinned = BoolCast(Doc.UserDoc()["menuRichText-pinned"]); - this.Pinned = true; + runInAction(() => this.Pinned = true); this.fontSizeOptions = [ { mark: schema.marks.pFontSize.create({ fontSize: 7 }), title: "Set font size", label: "7pt", command: this.changeFontSize }, diff --git a/src/client/views/presentationview/PresElementBox.tsx b/src/client/views/presentationview/PresElementBox.tsx index e965ac656..e1b97887a 100644 --- a/src/client/views/presentationview/PresElementBox.tsx +++ b/src/client/views/presentationview/PresElementBox.tsx @@ -20,6 +20,7 @@ import { DocumentType } from "../../documents/DocumentTypes"; import { Tooltip } from "@material-ui/core"; import { DragManager } from "../../util/DragManager"; import { CurrentUserUtils } from "../../util/CurrentUserUtils"; +import { undoBatch } from "../../util/UndoManager"; export const presSchema = createSchema({ presentationTargetDoc: Doc, @@ -206,6 +207,7 @@ export class PresElementBox extends ViewBoxBaseComponent { this.props.removeDocument?.(this.rootDoc); -- cgit v1.2.3-70-g09d2