-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCanvasShortcutSettings.tsx
More file actions
37 lines (33 loc) · 1.08 KB
/
CanvasShortcutSettings.tsx
File metadata and controls
37 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React, { useMemo } from "react";
import getDiscourseNodes, {
excludeDefaultNodes,
} from "~/utils/getDiscourseNodes";
import { getPersonalSetting } from "~/components/settings/utils/accessors";
import { PersonalTextPanel } from "./components/BlockPropSettingPanels";
const CANVAS_NODE_SHORTCUTS_KEY = "Canvas node shortcuts";
const CanvasShortcutSettings = () => {
const nodes = useMemo(
() => getDiscourseNodes().filter(excludeDefaultNodes),
[],
);
return (
<div className="flex flex-col gap-4 p-1">
{nodes.map((node) => (
<PersonalTextPanel
key={node.type}
title={node.text}
description={`Default: ${node.shortcut || "none"}. Changes take effect next time a canvas is opened.`}
settingKeys={[CANVAS_NODE_SHORTCUTS_KEY, node.type]}
initialValue={
getPersonalSetting<string>([
CANVAS_NODE_SHORTCUTS_KEY,
node.type,
]) || node.shortcut
}
placeholder={node.shortcut}
/>
))}
</div>
);
};
export default CanvasShortcutSettings;