From 647b66c965f5896d784de0f321d31cc712937e1c Mon Sep 17 00:00:00 2001
From: eleanor-park <eleanor_park@brown.edu>
Date: Fri, 26 Jul 2024 01:23:06 -0400
Subject: Revert "Merge branch 'master' into eleanor-gptdraw"

This reverts commit decbefe23a1da35c838222bafe8a2c029c6ea794, reversing
changes made to 8ca26551622d36b7856f5c1865498fa9e5d888b5.
---
 src/client/views/collections/CollectionDockingView.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/client/views/collections/CollectionDockingView.tsx')

diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 2a36e96bf..73179a266 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -58,7 +58,7 @@ export class CollectionDockingView extends CollectionSubView() {
         return this._goldenLayout._maximisedItem !== null;
     }
     private _goldenLayout: any = null;
-    static _highlightStyleSheet = addStyleSheet();
+    static _highlightStyleSheet: any = addStyleSheet();
 
     constructor(props: any) {
         super(props);
-- 
cgit v1.2.3-70-g09d2


From 22376ded1271629974bfafc31b77e3288d593c3d Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 2 Oct 2024 12:24:11 -0400
Subject: added showTags button for cardView.  fixed unnecessary invalidations
 of TagsView based on child screenToLocal changing when its not rendered.

---
 src/ClientUtils.ts                                       |  7 ++-----
 src/client/util/CurrentUserUtils.ts                      |  5 +++--
 src/client/views/DashboardView.tsx                       |  8 ++++----
 src/client/views/TagsView.tsx                            | 10 ++++++++--
 src/client/views/collections/CollectionCardDeckView.tsx  | 10 ++++++----
 src/client/views/collections/CollectionDockingView.tsx   |  9 ++++-----
 .../views/collections/collectionFreeForm/MarqueeView.tsx |  3 +--
 src/client/views/global/globalScripts.ts                 | 16 +++++++++++++---
 src/client/views/nodes/LabelBox.tsx                      |  2 +-
 9 files changed, 42 insertions(+), 28 deletions(-)

(limited to 'src/client/views/collections/CollectionDockingView.tsx')

diff --git a/src/ClientUtils.ts b/src/ClientUtils.ts
index 01eda7e98..972910071 100644
--- a/src/ClientUtils.ts
+++ b/src/ClientUtils.ts
@@ -119,7 +119,6 @@ export namespace ClientUtils {
     }
 
     export function readUploadedFileAsText(inputFile: File) {
-        // eslint-disable-next-line no-undef
         const temporaryFileReader = new FileReader();
 
         return new Promise((resolve, reject) => {
@@ -163,7 +162,7 @@ export namespace ClientUtils {
 
     export function GetScreenTransform(ele?: HTMLElement | null): { scale: number; translateX: number; translateY: number } {
         if (!ele) {
-            return { scale: 1, translateX: 1, translateY: 1 };
+            return { scale: 0, translateX: 1, translateY: 1 };
         }
         const rect = ele.getBoundingClientRect();
         const scale = ele.offsetWidth === 0 && rect.width === 0 ? 1 : rect.width / ele.offsetWidth;
@@ -336,7 +335,7 @@ export namespace ClientUtils {
 
         try {
             document.execCommand('paste');
-        } catch (err) {
+        } catch {
             /* empty */
         }
 
@@ -575,9 +574,7 @@ export function setupMoveUpEvents(
     moveEvent: (e: PointerEvent, down: number[], delta: number[]) => boolean,
     upEvent: (e: PointerEvent, movement: number[], isClick: boolean) => void,
     clickEvent: (e: PointerEvent, doubleTap?: boolean) => unknown,
-    // eslint-disable-next-line default-param-last
     stopPropagation: boolean = true,
-    // eslint-disable-next-line default-param-last
     stopMovePropagation: boolean = true,
     noDoubleTapTimeout?: () => void
 ) {
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 96d69e7a1..556c8f072 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -693,8 +693,9 @@ pie title Minerals in my tap water
             { title: "Type",      icon:"eye",            toolTip:"Sort by document type",                          btnType: ButtonType.ToggleButton, expertMode: false, toolType:"docType",    funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}},
             { title: "Color",     icon:"palette",        toolTip:"Sort by document color",                         btnType: ButtonType.ToggleButton, expertMode: false, toolType:"color",      funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}},
             { title: "Tags",      icon:"bolt",           toolTip:"Sort by document's tags",                        btnType: ButtonType.ToggleButton, expertMode: false, toolType:"tag",        funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}},
-            { title: "Pile",      icon:"layer-group",    toolTip:"View the cards as a pile in the free form view!",btnType: ButtonType.ClickButton,  expertMode: false, toolType:"pile",       funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}},
-            { title: "Chat Popup",icon:"lightbulb",      toolTip:"Toggle the chat popup's visibility!", width: 45, btnType: ButtonType.ToggleButton, expertMode: false, toolType:"toggle-chat",funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'} },
+            { title: "Pile",      icon:"layer-group",    toolTip:"View the cards as a pile in the free form view", btnType: ButtonType.ClickButton,  expertMode: false, toolType:"pile",       funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}},
+            { title: "Chat Popup",icon:"lightbulb",      toolTip:"Toggle the chat popup's visibility", width: 45,  btnType: ButtonType.ToggleButton, expertMode: false, toolType:"toggle-chat",funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'} },
+            { title: "Show Tags", icon:"id-card",        toolTip:"Toggle tag annotation panel",         width: 45, btnType: ButtonType.ToggleButton, expertMode: false, toolType:"toggle-tags",funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'} },
 
             { title: "Sort",      icon: "sort" ,         toolTip: "Manage sort order / lock status",               btnType: ButtonType.MultiToggleButton,               toolType:"alignment", ignoreClick: true,
               subMenu: [
diff --git a/src/client/views/DashboardView.tsx b/src/client/views/DashboardView.tsx
index eced64524..448178397 100644
--- a/src/client/views/DashboardView.tsx
+++ b/src/client/views/DashboardView.tsx
@@ -433,15 +433,15 @@ export class DashboardView extends ObservableReactComponent<object> {
         dashboardDoc[DocData].myPublishedDocs = new List<Doc>();
         dashboardDoc[DocData].myTagCollections = new List<Doc>();
         dashboardDoc[DocData].myUniqueFaces = new List<Doc>();
-        dashboardDoc[DocData].myTrails = DashboardView.SetupDashboardTrails(dashboardDoc);
-        dashboardDoc[DocData].myCalendars = DashboardView.SetupDashboardCalendars(dashboardDoc);
+        dashboardDoc[DocData].myTrails = DashboardView.SetupDashboardTrails();
+        dashboardDoc[DocData].myCalendars = DashboardView.SetupDashboardCalendars();
         // open this new dashboard
         Doc.ActiveDashboard = dashboardDoc;
         Doc.ActivePage = 'dashboard';
         Doc.ActivePresentation = undefined;
     };
 
-    public static SetupDashboardCalendars(dashboardDoc: Doc) {
+    public static SetupDashboardCalendars() {
         // this section is creating the button document itself  ===  myTrails = new Button
 
         //  create a a list of calendars (as a CalendarCollectionDocument) and store it on the new dashboard
@@ -470,7 +470,7 @@ export class DashboardView extends ObservableReactComponent<object> {
         return new PrefetchProxy(myCalendars);
     }
 
-    public static SetupDashboardTrails(dashboardDoc: Doc) {
+    public static SetupDashboardTrails() {
         // this section is creating the button document itself  ===  myTrails = new Button
         const reqdBtnOpts: DocumentOptions = {
             _forceActive: true,
diff --git a/src/client/views/TagsView.tsx b/src/client/views/TagsView.tsx
index f44fd1d03..9858e7b61 100644
--- a/src/client/views/TagsView.tsx
+++ b/src/client/views/TagsView.tsx
@@ -274,12 +274,18 @@ export class TagsView extends ObservableReactComponent<TagViewProps> {
     @observable _currentInput = '';
     @observable _isEditing = !StrListCast(this.View.dataDoc.tags).length;
     _heightDisposer: IReactionDisposer | undefined;
+    _lastXf = this.View.screenToContentsTransform();
 
     componentDidMount() {
         this._heightDisposer = reaction(
             () => this.View.screenToContentsTransform(),
-            () => {
-                this._panelHeightDirty = this._panelHeightDirty + 1;
+            xf => {
+                if (xf.Scale === 0) return;
+                if (this.View.ComponentView?.isUnstyledView?.() || (!this.View.showTags && this._props.Views.length === 1)) return;
+                if (xf.TranslateX !== this._lastXf.TranslateX || xf.TranslateY !== this._lastXf.TranslateY || xf.Scale !== this._lastXf.Scale) {
+                    this._panelHeightDirty = this._panelHeightDirty + 1;
+                }
+                this._lastXf = xf;
             }
         );
     }
diff --git a/src/client/views/collections/CollectionCardDeckView.tsx b/src/client/views/collections/CollectionCardDeckView.tsx
index e5a6ebc7f..101cc8082 100644
--- a/src/client/views/collections/CollectionCardDeckView.tsx
+++ b/src/client/views/collections/CollectionCardDeckView.tsx
@@ -1,4 +1,4 @@
-import { IReactionDisposer, ObservableMap, action, computed, makeObservable, observable, reaction, trace } from 'mobx';
+import { IReactionDisposer, ObservableMap, action, computed, makeObservable, observable, reaction } from 'mobx';
 import { observer } from 'mobx-react';
 import * as React from 'react';
 import { ClientUtils, DashColor, returnFalse, returnZero } from '../../../ClientUtils';
@@ -139,7 +139,7 @@ export class CollectionCardView extends CollectionSubView() {
      * custom group
      */
     @computed get childDocsWithoutLinks() {
-        return this.childDocs.filter(l => l.type !== DocumentType.LINK);
+        return this.childDocs.filter(l => !l.layout_isSvg);
     }
 
     /**
@@ -402,7 +402,7 @@ export class CollectionCardView extends CollectionSubView() {
             PanelHeight={this.childPanelHeight}
             dontCenter="y" // Don't center it vertically, because the grid it's in is already doing that and we don't want to do it twice.
             dragAction={(this.Document.childDragAction ?? this._props.childDragAction) as dropActionType}
-            showTags={true}
+            showTags={BoolCast(this.layoutDoc.showChildTags)}
             dontHideOnDrag
         />
     );
@@ -607,6 +607,8 @@ export class CollectionCardView extends CollectionSubView() {
 
                 const dref = this._docRefs.get(doc);
                 const { translateX, translateY, scale } = ClientUtils.GetScreenTransform(dref?.ContentDiv);
+                if (!scale) return new Transform(0, 0, 0);
+
                 return new Transform(-translateX + (dref?.centeringX || 0) * scale, 
                                      -translateY + (dref?.centeringY || 0) * scale, 1)
                           .scale(1 / scale).rotate(!isSelected ? -this.rotate(amCards, calcRowIndex) : 0); // prettier-ignore
@@ -639,7 +641,7 @@ export class CollectionCardView extends CollectionSubView() {
                                     SnappingManager.SetIsResizing(undefined);
                                     this._forceChildXf++;
                                 }),
-                                600
+                                1000
                             );
                         }
                     })}
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 028133a6e..d1304b8f4 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -203,7 +203,6 @@ export class CollectionDockingView extends CollectionSubView() {
             } else if (instance._goldenLayout.root.contentItems[0].isRow) {
                 // if row
                 switch (pullSide) {
-                    // eslint-disable-next-line default-case-last
                     default:
                     case OpenWhereMod.none:
                     case OpenWhereMod.right:
@@ -299,7 +298,7 @@ export class CollectionDockingView extends CollectionSubView() {
                     this._goldenLayout.unbind('tabCreated', this.tabCreated);
                     this._goldenLayout.unbind('tabDestroyed', this.tabDestroyed);
                     this._goldenLayout.unbind('stackCreated', this.stackCreated);
-                } catch (e) {
+                } catch {
                     /* empty */
                 }
                 this.tabMap.clear();
@@ -380,7 +379,7 @@ export class CollectionDockingView extends CollectionSubView() {
         try {
             this._goldenLayout.unbind('stackCreated', this.stackCreated);
             this._goldenLayout.unbind('tabDestroyed', this.tabDestroyed);
-        } catch (e) {
+        } catch {
             /* empty */
         }
         this._goldenLayout?.destroy();
@@ -507,8 +506,8 @@ export class CollectionDockingView extends CollectionSubView() {
         dashboardDoc.myOverlayDocs = new List<Doc>();
         dashboardDoc.myPublishedDocs = new List<Doc>();
 
-        DashboardView.SetupDashboardTrails(dashboardDoc);
-        DashboardView.SetupDashboardCalendars(dashboardDoc); // Zaul TODO: needed?
+        DashboardView.SetupDashboardTrails();
+        DashboardView.SetupDashboardCalendars(); // Zaul TODO: needed?
         return DashboardView.openDashboard(dashboardDoc);
     }
 
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index b1f6815b3..10709cc00 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -685,8 +685,7 @@ export class MarqueeView extends ObservableReactComponent<SubCollectionViewProps
             <div
                 className="marqueeView"
                 ref={r => {
-                    // eslint-disable-next-line @typescript-eslint/no-explicit-any
-                    r?.addEventListener('dashDragMovePause', this.onDragMovePause as any);
+                    r?.addEventListener('dashDragMovePause', this.onDragMovePause as EventListenerOrEventListenerObject);
                     this.MarqueeRef = r;
                 }}
                 style={{
diff --git a/src/client/views/global/globalScripts.ts b/src/client/views/global/globalScripts.ts
index 0ab431740..423a2d6ef 100644
--- a/src/client/views/global/globalScripts.ts
+++ b/src/client/views/global/globalScripts.ts
@@ -18,7 +18,7 @@ import { InkTranscription } from '../InkTranscription';
 import { InkingStroke } from '../InkingStroke';
 import { MainView } from '../MainView';
 import { PropertiesView } from '../PropertiesView';
-import { CollectionFreeFormView, MarqueeView } from '../collections/collectionFreeForm';
+import { CollectionFreeFormView } from '../collections/collectionFreeForm';
 import { CollectionFreeFormDocumentView } from '../nodes/CollectionFreeFormDocumentView';
 import {
     ActiveEraserWidth,
@@ -135,7 +135,11 @@ ScriptingGlobals.add(function toggleOverlay(checkResult?: boolean) {
 });
 
 // eslint-disable-next-line prefer-arrow-callback
-ScriptingGlobals.add(function showFreeform(attr: 'hcenter' | 'vcenter' | 'grid' | 'snaplines' | 'clusters' | 'viewAll' | 'fitOnce', checkResult?: boolean, persist?: boolean) {
+ScriptingGlobals.add(function showFreeform(
+    attr: 'flashcards' | 'hcenter' | 'vcenter' | 'grid' | 'snaplines' | 'clusters' | 'viewAll' | 'fitOnce' | 'time' | 'docType' | 'color' | 'chat' | 'up' | 'down' | 'pile' | 'toggle-chat' | 'toggle-tags' | 'tag',
+    checkResult?: boolean,
+    persist?: boolean
+) {
     const selected = DocumentView.SelectedDocs().lastElement();
 
     function isAttrFiltered(attribute: string) {
@@ -143,7 +147,7 @@ ScriptingGlobals.add(function showFreeform(attr: 'hcenter' | 'vcenter' | 'grid'
     }
 
     // prettier-ignore
-    const map: Map<'flashcards' | 'hcenter' | 'vcenter' | 'grid' | 'snaplines' | 'clusters' | 'arrange' | 'viewAll' | 'fitOnce' | 'time' | 'docType' | 'color' | 'chat' | 'up' | 'down' | 'pile' | 'toggle-chat' | 'tag', 
+    const map: Map<'flashcards' | 'hcenter' | 'vcenter' | 'grid' | 'snaplines' | 'clusters' | 'viewAll' | 'fitOnce' | 'time' | 'docType' | 'color' | 'chat' | 'up' | 'down' | 'pile' | 'toggle-chat' | 'toggle-tags' | 'tag', 
     { 
         waitForRender?: boolean; 
         checkResult: (doc: Doc) => boolean; 
@@ -227,6 +231,12 @@ ScriptingGlobals.add(function showFreeform(attr: 'hcenter' | 'vcenter' | 'grid'
 
             },
         }],
+        ['toggle-tags', {
+            checkResult: (doc: Doc) => BoolCast(doc?.showChildTags),
+            setDoc: (doc: Doc, dv: DocumentView) => {
+                doc.showChildTags = !doc.showChildTags;
+            },
+        }],
         ['pile', {
             checkResult: (doc: Doc) => doc._type_collection == CollectionViewType.Freeform,
             setDoc: (doc: Doc, dv: DocumentView) => {
diff --git a/src/client/views/nodes/LabelBox.tsx b/src/client/views/nodes/LabelBox.tsx
index e39caecb6..8974cccaf 100644
--- a/src/client/views/nodes/LabelBox.tsx
+++ b/src/client/views/nodes/LabelBox.tsx
@@ -91,7 +91,7 @@ export class LabelBox extends ViewBoxBaseComponent<FieldViewProps>() {
         };
         if (r) {
             if (!r.offsetHeight || !r.offsetWidth) {
-                console.log("CAN'T FIT TO EMPTY BOX");
+                //console.log("CAN'T FIT TO EMPTY BOX");
                 this._timeout && clearTimeout(this._timeout);
                 this._timeout = setTimeout(() => this.fitTextToBox(r));
                 return textfitParams;
-- 
cgit v1.2.3-70-g09d2

