From 5f5bdc03745a05712bf3ccd68cb59c1e814d10f2 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Sun, 27 Aug 2023 13:14:12 -0400
Subject: added ctrl-a to select all in tableBox

---
 .../views/nodes/DataVizBox/components/TableBox.tsx | 54 ++++++++++++----------
 1 file changed, 29 insertions(+), 25 deletions(-)

(limited to 'src/client/views/nodes/DataVizBox/components/TableBox.tsx')

diff --git a/src/client/views/nodes/DataVizBox/components/TableBox.tsx b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
index c416d7764..6688bcedb 100644
--- a/src/client/views/nodes/DataVizBox/components/TableBox.tsx
+++ b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
@@ -5,7 +5,7 @@ import { Doc, Field, NumListCast, StrListCast } from '../../../../../fields/Doc'
 import { List } from '../../../../../fields/List';
 import { listSpec } from '../../../../../fields/Schema';
 import { Cast, DocCast } from '../../../../../fields/Types';
-import { emptyFunction, setupMoveUpEvents, Utils } from '../../../../../Utils';
+import { emptyFunction, numberRange, setupMoveUpEvents, Utils } from '../../../../../Utils';
 import { DragManager } from '../../../../util/DragManager';
 import { LinkManager } from '../../../../util/LinkManager';
 import { DocumentView } from '../../DocumentView';
@@ -71,20 +71,18 @@ export class TableBox extends React.Component<TableBoxProps> {
     render() {
         if (this._tableData.length > 0) {
             return (
-                <div className={"tableBox"}>
-                    <div className={'selectAll-buttons'} >
-                        <Button
-                            onClick={action(() => (this.props.layoutDoc.dataViz_selectedRows = new List<number>(this._tableDataIds)))}
-                            text="Select All"
-                            type={Type.SEC}
-                            color={'black'}
-                        />
-                        <Button
-                            onClick={action(() => (this.props.layoutDoc.dataViz_selectedRows = new List<number>()))}
-                            text="Deselect All"
-                            type={Type.SEC}
-                            color={'black'}
-                        />
+                <div
+                    className="tableBox"
+                    tabIndex={0}
+                    onKeyDown={e => {
+                        if (this.props.layoutDoc && e.key === 'a' && (e.ctrlKey || e.metaKey)) {
+                            e.stopPropagation();
+                            this.props.layoutDoc.dataViz_selectedRows = new List<number>(this._tableDataIds);
+                        }
+                    }}>
+                    <div className="selectAll-buttons">
+                        <Button onClick={action(() => (this.props.layoutDoc.dataViz_selectedRows = new List<number>(this._tableDataIds)))} text="Select All" type={Type.SEC} color={'black'} />
+                        <Button onClick={action(() => (this.props.layoutDoc.dataViz_selectedRows = new List<number>()))} text="Deselect All" type={Type.SEC} color={'black'} />
                     </div>
                     <div
                         className="table-container"
@@ -132,16 +130,22 @@ export class TableBox extends React.Component<TableBoxProps> {
                                                             return embedding;
                                                         };
                                                         if (this.props.docView?.() && !Utils.isClick(e.clientX, e.clientY, downX, downY, Date.now())) {
-                                                            DragManager.StartAnchorAnnoDrag(e.target instanceof HTMLElement ? [e.target] : [], new DragManager.AnchorAnnoDragData(this.props.docView()!, sourceAnchorCreator, targetCreator), downX, downY, {
-                                                                dragComplete: e => {
-                                                                    if (!e.aborted && e.annoDragData && e.annoDragData.linkSourceDoc && e.annoDragData.dropDocument && e.linkDocument) {
-                                                                        e.linkDocument.link_displayLine = true;
-                                                                        e.linkDocument.link_matchEmbeddings = true;
-                                                                        // e.annoDragData.linkSourceDoc.followLinkToggle = e.annoDragData.dropDocument.annotationOn === this.props.rootDoc;
-                                                                        // e.annoDragData.linkSourceDoc.followLinkZoom = false;
-                                                                    }
-                                                                },
-                                                            });
+                                                            DragManager.StartAnchorAnnoDrag(
+                                                                e.target instanceof HTMLElement ? [e.target] : [],
+                                                                new DragManager.AnchorAnnoDragData(this.props.docView()!, sourceAnchorCreator, targetCreator),
+                                                                downX,
+                                                                downY,
+                                                                {
+                                                                    dragComplete: e => {
+                                                                        if (!e.aborted && e.annoDragData && e.annoDragData.linkSourceDoc && e.annoDragData.dropDocument && e.linkDocument) {
+                                                                            e.linkDocument.link_displayLine = true;
+                                                                            e.linkDocument.link_matchEmbeddings = true;
+                                                                            // e.annoDragData.linkSourceDoc.followLinkToggle = e.annoDragData.dropDocument.annotationOn === this.props.rootDoc;
+                                                                            // e.annoDragData.linkSourceDoc.followLinkZoom = false;
+                                                                        }
+                                                                    },
+                                                                }
+                                                            );
                                                             return true;
                                                         }
                                                         return false;
-- 
cgit v1.2.3-70-g09d2

