Skip to content

开源白板工具(SaaS),一体化白板,包含思维导图、流程图、自由画等。All in one open-source whiteboard tool with mind, flowchart, freehand and etc.

fix(hotkey): assign t as hotkey to create text element (#192)

pubuzhixing8dbe3e700fb0a
diff --git a/packages/drawnix/src/components/shape-picker.tsx b/packages/drawnix/src/components/shape-picker.tsx
index 2bb37ff..4de9e0a 100644
--- a/packages/drawnix/src/components/shape-picker.tsx
+++ b/packages/drawnix/src/components/shape-picker.tsx
@@ -37,7 +37,7 @@ const SHAPES: ShapeProps[] = [
},
{
icon: TriangleIcon,
- title: 'Triangle — T',
+ title: 'Triangle',
pointer: BasicShapes.triangle,
},
{
diff --git a/packages/drawnix/src/components/toolbar/creation-toolbar.tsx b/packages/drawnix/src/components/toolbar/creation-toolbar.tsx
index 4860b86..334c05b 100644
--- a/packages/drawnix/src/components/toolbar/creation-toolbar.tsx
+++ b/packages/drawnix/src/components/toolbar/creation-toolbar.tsx
@@ -79,7 +79,7 @@ export const BUTTONS: AppToolButtonProps[] = [
{
icon: TextIcon,
pointer: BasicShapes.text,
- title: 'Text',
+ title: 'Text — T',
},
{
icon: FeltTipPenIcon,
diff --git a/packages/drawnix/src/plugins/with-hotkey.ts b/packages/drawnix/src/plugins/with-hotkey.ts
index cc378d1..9f65cba 100644
--- a/packages/drawnix/src/plugins/with-hotkey.ts
+++ b/packages/drawnix/src/plugins/with-hotkey.ts
@@ -70,9 +70,13 @@ export const buildDrawnixHotkeyPlugin = (
const keyToPointer = {
r: BasicShapes.rectangle,
o: BasicShapes.ellipse,
- t: BasicShapes.triangle,
+ t: BasicShapes.text,
};
- setCreationMode(board, BoardCreationMode.drawing);
+ if (keyToPointer[event.key] === BasicShapes.text) {
+ setCreationMode(board, BoardCreationMode.dnd);
+ } else {
+ setCreationMode(board, BoardCreationMode.drawing);
+ }
BoardTransforms.updatePointerType(board, keyToPointer[event.key]);
updateAppState({ pointer: keyToPointer[event.key] });
}