mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
change selection/line/draw shortcut defaults (#1953)
This commit is contained in:
parent
c5d37a07c8
commit
dc1f6c4d4c
4 changed files with 28 additions and 22 deletions
|
@ -11,7 +11,7 @@ export const SHAPES = [
|
|||
</svg>
|
||||
),
|
||||
value: "selection",
|
||||
key: "s",
|
||||
key: ["v", "s"],
|
||||
},
|
||||
{
|
||||
icon: (
|
||||
|
@ -68,7 +68,7 @@ export const SHAPES = [
|
|||
</svg>
|
||||
),
|
||||
value: "line",
|
||||
key: "l",
|
||||
key: ["p", "l"],
|
||||
},
|
||||
{
|
||||
icon: (
|
||||
|
@ -81,7 +81,7 @@ export const SHAPES = [
|
|||
</svg>
|
||||
),
|
||||
value: "draw",
|
||||
key: "x",
|
||||
key: ["P", "x"],
|
||||
},
|
||||
{
|
||||
icon: (
|
||||
|
@ -95,12 +95,14 @@ export const SHAPES = [
|
|||
},
|
||||
] as const;
|
||||
|
||||
export const shapesShortcutKeys = SHAPES.map((shape, index) => [
|
||||
shape.key,
|
||||
(index + 1).toString(),
|
||||
]).flat(1);
|
||||
|
||||
export const findShapeByKey = (key: string) =>
|
||||
SHAPES.find((shape, index) => {
|
||||
return shape.key === key.toLowerCase() || key === (index + 1).toString();
|
||||
})?.value || "selection";
|
||||
export const findShapeByKey = (key: string) => {
|
||||
const shape = SHAPES.find((shape, index) => {
|
||||
return (
|
||||
key === (index + 1).toString() ||
|
||||
(typeof shape.key === "string"
|
||||
? shape.key === key
|
||||
: (shape.key as readonly string[]).includes(key))
|
||||
);
|
||||
});
|
||||
return shape?.value || null;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue