Add numeric hotkeys (#380)
* Add numeric hotkeys * Nit: add space after comma
This commit is contained in:
parent
a3aa57d98b
commit
2a8e562e98
@ -433,14 +433,14 @@ export class App extends React.Component<{}, AppState> {
|
|||||||
private renderShapesSwitcher() {
|
private renderShapesSwitcher() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{SHAPES.map(({ value, icon }) => (
|
{SHAPES.map(({ value, icon }, index) => (
|
||||||
<ToolIcon
|
<ToolIcon
|
||||||
key={value}
|
key={value}
|
||||||
type="radio"
|
type="radio"
|
||||||
icon={icon}
|
icon={icon}
|
||||||
checked={this.state.elementType === value}
|
checked={this.state.elementType === value}
|
||||||
name="editor-current-shape"
|
name="editor-current-shape"
|
||||||
title={`${capitalizeString(value)} — ${capitalizeString(value)[0]}`}
|
title={`${capitalizeString(value)} — ${capitalizeString(value)[0]}, ${index + 1}`}
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
this.setState({ elementType: value });
|
this.setState({ elementType: value });
|
||||||
elements = clearSelection(elements);
|
elements = clearSelection(elements);
|
||||||
|
@ -74,12 +74,14 @@ export const SHAPES = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
export const shapesShortcutKeys = SHAPES.map(shape => shape.value[0]);
|
export const shapesShortcutKeys = SHAPES.map((shape, index) => [
|
||||||
|
shape.value[0], (index + 1).toString()]
|
||||||
|
).flat(1);
|
||||||
|
|
||||||
export function findShapeByKey(key: string) {
|
export function findShapeByKey(key: string) {
|
||||||
const defaultElement = "selection";
|
const defaultElement = "selection";
|
||||||
return SHAPES.reduce((element, shape) => {
|
return SHAPES.reduce((element, shape, index) => {
|
||||||
if (shape.value[0] !== key) return element;
|
if (shape.value[0] !== key && key !== (index + 1).toString()) return element;
|
||||||
|
|
||||||
return shape.value;
|
return shape.value;
|
||||||
}, defaultElement);
|
}, defaultElement);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user