|
6 | 6 |
|
7 | 7 | import {Msg} from './msg.js'; |
8 | 8 | import {Toast} from './toast.js'; |
| 9 | +import {getShortActionShortcut} from './utils/shortcut_formatting.js'; |
9 | 10 | import * as userAgent from './utils/useragent.js'; |
10 | 11 | import type {WorkspaceSvg} from './workspace_svg.js'; |
11 | 12 |
|
12 | 13 | const unconstrainedMoveHintId = 'unconstrainedMoveHint'; |
13 | 14 | const constrainedMoveHintId = 'constrainedMoveHint'; |
| 15 | +const helpHintId = 'helpHint'; |
| 16 | +const blockNavigationHintId = 'blockNavigationHint'; |
| 17 | +const workspaceNavigationHintId = 'workspaceNavigationHint'; |
14 | 18 |
|
15 | 19 | /** |
16 | 20 | * Nudge the user to use unconstrained movement. |
@@ -62,3 +66,39 @@ export function clearMoveHints(workspace: WorkspaceSvg) { |
62 | 66 | Toast.hide(workspace, constrainedMoveHintId); |
63 | 67 | Toast.hide(workspace, unconstrainedMoveHintId); |
64 | 68 | } |
| 69 | + |
| 70 | +/** |
| 71 | + * Nudge the user to open the help. |
| 72 | + * |
| 73 | + * @param workspace The workspace. |
| 74 | + */ |
| 75 | +export function showHelpHint(workspace: WorkspaceSvg) { |
| 76 | + const shortcut = getShortActionShortcut('list_shortcuts'); |
| 77 | + if (!shortcut) return; |
| 78 | + |
| 79 | + const message = Msg['HELP_PROMPT'].replace('%1', shortcut); |
| 80 | + const id = helpHintId; |
| 81 | + Toast.show(workspace, {message, id}); |
| 82 | +} |
| 83 | + |
| 84 | +/** |
| 85 | + * Tell the user how to navigate inside blocks. |
| 86 | + * |
| 87 | + * @param workspace The workspace. |
| 88 | + */ |
| 89 | +export function showBlockNavigationHint(workspace: WorkspaceSvg) { |
| 90 | + const message = Msg['KEYBOARD_NAV_BLOCK_NAVIGATION_HINT']; |
| 91 | + const id = blockNavigationHintId; |
| 92 | + Toast.show(workspace, {message, id}); |
| 93 | +} |
| 94 | + |
| 95 | +/** |
| 96 | + * Tell the user how to navigate inside the workspace. |
| 97 | + * |
| 98 | + * @param workspace The workspace. |
| 99 | + */ |
| 100 | +export function showWorkspaceNavigationHint(workspace: WorkspaceSvg) { |
| 101 | + const message = Msg['KEYBOARD_NAV_WORKSPACE_NAVIGATION_HINT']; |
| 102 | + const id = workspaceNavigationHintId; |
| 103 | + Toast.show(workspace, {message, id}); |
| 104 | +} |
0 commit comments