From d1fad65d5f3bfb2ed7d2b94af2c3c609a2090545 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 29 Aug 2024 23:38:12 -0400 Subject: made smartDraw autoFocus and be available from : menu --- src/client/documents/DocUtils.ts | 7 +++++++ src/client/views/ContextMenuItem.tsx | 2 +- .../collections/collectionFreeForm/CollectionFreeFormView.tsx | 6 +++--- src/client/views/smartdraw/SmartDrawHandler.tsx | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/client/documents/DocUtils.ts b/src/client/documents/DocUtils.ts index 30b71a09b..dcb5e1fe3 100644 --- a/src/client/documents/DocUtils.ts +++ b/src/client/documents/DocUtils.ts @@ -34,6 +34,8 @@ import { OpenWhere } from '../views/nodes/OpenWhere'; import { TaskCompletionBox } from '../views/nodes/TaskCompletedBox'; import { DocumentType } from './DocumentTypes'; import { Docs, DocumentOptions } from './Documents'; +import { DocumentView } from '../views/nodes/DocumentView'; +import { CollectionFreeFormView } from '../views/collections/collectionFreeForm'; // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports const { DFLT_IMAGE_NATIVE_DIM } = require('../views/global/globalCssVariables.module.scss'); // prettier-ignore @@ -378,6 +380,11 @@ export namespace DocUtils { }, StrCast(dragDoc.title)), icon: Doc.toIcon(dragDoc), })) as ContextMenuProps[]; + documentList.push({ + description: ':Smart Drawing', + event: e => (DocumentView.Selected().lastElement().ComponentView as CollectionFreeFormView)?.showSmartDraw(e?.x || 0, e?.y || 0), + icon: 'file', + }); ContextMenu.Instance.addItem({ description: 'Create document', subitems: documentList, diff --git a/src/client/views/ContextMenuItem.tsx b/src/client/views/ContextMenuItem.tsx index 5b4eb704b..5d31173e1 100644 --- a/src/client/views/ContextMenuItem.tsx +++ b/src/client/views/ContextMenuItem.tsx @@ -18,7 +18,7 @@ export interface ContextMenuProps { noexpand?: boolean; // whether to render the submenu items as a flyout from this item, or inline in place of this item undoable?: boolean; // whether to wrap the event callback in an UndoBatch or not - event?: (stuff?: unknown) => void; + event?: (stuff?: { x: number; y: number }) => void; } @observer diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 76549a423..880d1cd74 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -510,7 +510,7 @@ export class CollectionFreeFormView extends CollectionSubView this.showSmartDraw(e.pageX, e.pageY), hit !== -1); e.stopPropagation(); case InkTool.None: if (!(this._props.layoutEngine?.() || StrCast(this.layoutDoc._layoutEngine))) { @@ -1229,11 +1229,11 @@ export class CollectionFreeFormView extends CollectionSubView { + showSmartDraw = (x: number, y: number) => { SmartDrawHandler.Instance.CreateDrawingDoc = this.createDrawingDoc; SmartDrawHandler.Instance.RemoveDrawing = this.removeDrawing; SmartDrawHandler.Instance.AddDrawing = this.addDrawing; - SmartDrawHandler.Instance.displaySmartDrawHandler(e.pageX, e.pageY); + SmartDrawHandler.Instance.displaySmartDrawHandler(x, y); }; _drawing: Doc[] = []; diff --git a/src/client/views/smartdraw/SmartDrawHandler.tsx b/src/client/views/smartdraw/SmartDrawHandler.tsx index 59d362d26..879358742 100644 --- a/src/client/views/smartdraw/SmartDrawHandler.tsx +++ b/src/client/views/smartdraw/SmartDrawHandler.tsx @@ -325,6 +325,7 @@ export class SmartDrawHandler extends ObservableReactComponent { aria-label="Smart Draw Input" className="smartdraw-input" type="text" + autoFocus style={{ color: 'black' }} value={this._userInput} onChange={action(e => this._canInteract && (this._userInput = e.target.value))} -- cgit v1.2.3-70-g09d2