feat: introduces new TextBox tool

This commit is contained in:
Mark Mankarious
2023-08-29 18:23:52 +01:00
parent ac4e9e8563
commit 23d3bdaae0
3 changed files with 25 additions and 3 deletions

View File

@@ -0,0 +1,14 @@
import { setWindowCursor } from 'src/utils';
import { ModeActions } from 'src/types';
export const TextBox: ModeActions = {
entry: () => {
setWindowCursor('crosshair');
},
exit: () => {
setWindowCursor('default');
},
mousemove: () => {},
mousedown: () => {},
mouseup: () => {}
};

View File

@@ -9,6 +9,7 @@ import { DrawRectangle } from './modes/Rectangle/DrawRectangle';
import { Connector } from './modes/Connector';
import { Pan } from './modes/Pan';
import { PlaceElement } from './modes/PlaceElement';
import { TextBox } from './modes/TextBox';
const modes: { [k in string]: ModeActions } = {
CURSOR: Cursor,
@@ -16,7 +17,8 @@ const modes: { [k in string]: ModeActions } = {
'RECTANGLE.DRAW': DrawRectangle,
CONNECTOR: Connector,
PAN: Pan,
PLACE_ELEMENT: PlaceElement
PLACE_ELEMENT: PlaceElement,
TEXTBOX: TextBox
};
export const useInteractionManager = () => {

View File

@@ -43,7 +43,7 @@ export interface Mouse {
} | null;
}
// Begin mode types
// Mode types
export interface InteractionsDisabled {
type: 'INTERACTIONS_DISABLED';
showCursor: boolean;
@@ -94,6 +94,11 @@ export interface ResizeRectangleMode {
id: string;
}
export interface TextBoxMode {
type: 'TEXTBOX';
showCursor: boolean;
}
export type Mode =
| InteractionsDisabled
| CursorMode
@@ -102,7 +107,8 @@ export type Mode =
| ConnectorMode
| DrawRectangleMode
| ResizeRectangleMode
| DragItemsMode;
| DragItemsMode
| TextBoxMode;
// End mode types
export type ContextMenu =