Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Map shortcut O to ellipse and Add eraser shortcut E #4930

Merged
merged 5 commits into from Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/actions/actionCanvas.tsx
Expand Up @@ -304,12 +304,13 @@ export const actionErase = register({
commitToHistory: true,
};
},
keyTest: (event) => event.code === CODES.E,
ad1992 marked this conversation as resolved.
Show resolved Hide resolved
PanelComponent: ({ elements, appState, updateData, data }) => (
<ToolButton
type="button"
icon={eraser}
className={clsx("eraser", { active: isEraserActive(appState) })}
title={t("toolBar.eraser")}
title={`${t("toolBar.eraser")}-${getShortcutKey("E")}`}
aria-label={t("toolBar.eraser")}
onClick={() => {
updateData(null);
Expand Down
6 changes: 5 additions & 1 deletion src/components/HelpDialog.tsx
Expand Up @@ -149,7 +149,7 @@ export const HelpDialog = ({ onClose }: { onClose?: () => void }) => {
shortcuts={["R", "2"]}
/>
<Shortcut label={t("toolBar.diamond")} shortcuts={["D", "3"]} />
<Shortcut label={t("toolBar.ellipse")} shortcuts={["E", "4"]} />
<Shortcut label={t("toolBar.ellipse")} shortcuts={["O", "4"]} />
<Shortcut label={t("toolBar.arrow")} shortcuts={["A", "5"]} />
<Shortcut label={t("toolBar.line")} shortcuts={["P", "6"]} />
<Shortcut
Expand Down Expand Up @@ -406,6 +406,10 @@ export const HelpDialog = ({ onClose }: { onClose?: () => void }) => {
label={t("labels.increaseFontSize")}
shortcuts={[getShortcutKey("CtrlOrCmd+Shift+>")]}
/>
<Shortcut
label={t("toolBar.eraser")}
shortcuts={[getShortcutKey("E")]}
/>
</ShortcutIsland>
</Column>
</Columns>
Expand Down
1 change: 1 addition & 0 deletions src/keys.ts
Expand Up @@ -25,6 +25,7 @@ export const CODES = {
X: "KeyX",
Z: "KeyZ",
R: "KeyR",
E: "KeyE",
} as const;

export const KEYS = {
Expand Down
2 changes: 1 addition & 1 deletion src/shapes.tsx
Expand Up @@ -40,7 +40,7 @@ export const SHAPES = [
</svg>
),
value: "ellipse",
key: KEYS.E,
key: KEYS.O,
},
{
icon: (
Expand Down
112 changes: 56 additions & 56 deletions src/tests/__snapshots__/regressionTests.test.tsx.snap
Expand Up @@ -11510,7 +11510,7 @@ exports[`regression tests key d selects diamond tool: [end of test] number of el

exports[`regression tests key d selects diamond tool: [end of test] number of renders 1`] = `8`;

exports[`regression tests key e selects ellipse tool: [end of test] appState 1`] = `
exports[`regression tests key l selects line tool: [end of test] appState 1`] = `
Object {
"collaborators": Map {},
"currentChartType": "bar",
Expand Down Expand Up @@ -11590,35 +11590,50 @@ Object {
}
`;

exports[`regression tests key e selects ellipse tool: [end of test] element 0 1`] = `
exports[`regression tests key l selects line tool: [end of test] element 0 1`] = `
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 10,
"id": "id0",
"isDeleted": false,
"lastCommittedPoint": null,
"link": null,
"opacity": 100,
"points": Array [
Array [
0,
0,
],
Array [
10,
10,
],
],
"roughness": 1,
"seed": 337897,
"startArrowhead": null,
"startBinding": null,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeSharpness": "round",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "ellipse",
"type": "line",
"updated": 1,
"version": 2,
"versionNonce": 1278240551,
"version": 3,
"versionNonce": 449462985,
"width": 10,
"x": 10,
"y": 10,
}
`;

exports[`regression tests key e selects ellipse tool: [end of test] history 1`] = `
exports[`regression tests key l selects line tool: [end of test] history 1`] = `
Object {
"recording": false,
"redoStack": Array [],
Expand Down Expand Up @@ -11650,23 +11665,38 @@ Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 10,
"id": "id0",
"isDeleted": false,
"lastCommittedPoint": null,
"link": null,
"opacity": 100,
"points": Array [
Array [
0,
0,
],
Array [
10,
10,
],
],
"roughness": 1,
"seed": 337897,
"startArrowhead": null,
"startBinding": null,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeSharpness": "round",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "ellipse",
"type": "line",
"updated": 1,
"version": 2,
"versionNonce": 1278240551,
"version": 3,
"versionNonce": 449462985,
"width": 10,
"x": 10,
"y": 10,
Expand All @@ -11677,11 +11707,11 @@ Object {
}
`;

exports[`regression tests key e selects ellipse tool: [end of test] number of elements 1`] = `1`;
exports[`regression tests key l selects line tool: [end of test] number of elements 1`] = `1`;

exports[`regression tests key e selects ellipse tool: [end of test] number of renders 1`] = `8`;
exports[`regression tests key l selects line tool: [end of test] number of renders 1`] = `8`;

exports[`regression tests key l selects line tool: [end of test] appState 1`] = `
exports[`regression tests key o selects ellipse tool: [end of test] appState 1`] = `
Object {
"collaborators": Map {},
"currentChartType": "bar",
Expand Down Expand Up @@ -11761,50 +11791,35 @@ Object {
}
`;

exports[`regression tests key l selects line tool: [end of test] element 0 1`] = `
exports[`regression tests key o selects ellipse tool: [end of test] element 0 1`] = `
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 10,
"id": "id0",
"isDeleted": false,
"lastCommittedPoint": null,
"link": null,
"opacity": 100,
"points": Array [
Array [
0,
0,
],
Array [
10,
10,
],
],
"roughness": 1,
"seed": 337897,
"startArrowhead": null,
"startBinding": null,
"strokeColor": "#000000",
"strokeSharpness": "round",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "line",
"type": "ellipse",
"updated": 1,
"version": 3,
"versionNonce": 449462985,
"version": 2,
"versionNonce": 1278240551,
"width": 10,
"x": 10,
"y": 10,
}
`;

exports[`regression tests key l selects line tool: [end of test] history 1`] = `
exports[`regression tests key o selects ellipse tool: [end of test] history 1`] = `
Object {
"recording": false,
"redoStack": Array [],
Expand Down Expand Up @@ -11836,38 +11851,23 @@ Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 10,
"id": "id0",
"isDeleted": false,
"lastCommittedPoint": null,
"link": null,
"opacity": 100,
"points": Array [
Array [
0,
0,
],
Array [
10,
10,
],
],
"roughness": 1,
"seed": 337897,
"startArrowhead": null,
"startBinding": null,
"strokeColor": "#000000",
"strokeSharpness": "round",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "line",
"type": "ellipse",
"updated": 1,
"version": 3,
"versionNonce": 449462985,
"version": 2,
"versionNonce": 1278240551,
"width": 10,
"x": 10,
"y": 10,
Expand All @@ -11878,9 +11878,9 @@ Object {
}
`;

exports[`regression tests key l selects line tool: [end of test] number of elements 1`] = `1`;
exports[`regression tests key o selects ellipse tool: [end of test] number of elements 1`] = `1`;

exports[`regression tests key l selects line tool: [end of test] number of renders 1`] = `8`;
exports[`regression tests key o selects ellipse tool: [end of test] number of renders 1`] = `8`;

exports[`regression tests key r selects rectangle tool: [end of test] appState 1`] = `
Object {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/regressionTests.test.tsx
Expand Up @@ -135,7 +135,7 @@ describe("regression tests", () => {
for (const [keys, shape, shouldSelect] of [
[`2${KEYS.R}`, "rectangle", true],
[`3${KEYS.D}`, "diamond", true],
[`4${KEYS.E}`, "ellipse", true],
[`4${KEYS.O}`, "ellipse", true],
[`5${KEYS.A}`, "arrow", true],
[`6${KEYS.L}`, "line", true],
[`7${KEYS.X}`, "freedraw", false],
Expand Down