66 * SPDX-License-Identifier: Apache-2.0
77 */
88
9- import { WorkspaceSvg } from 'blockly' ;
9+ import { WorkspaceSvg , Toast } from 'blockly' ;
1010import { SHORTCUT_NAMES } from './constants' ;
1111import { getShortActionShortcut } from './shortcut_formatting' ;
12- import { clearToast , toast } from './toast' ;
1312
1413const unconstrainedMoveHintId = 'unconstrainedMoveHint' ;
1514const constrainedMoveHintId = 'constrainedMoveHint' ;
1615const copiedHintId = 'copiedHint' ;
16+ const cutHintId = 'cutHint' ;
1717const helpHintId = 'helpHint' ;
1818
1919/**
@@ -29,7 +29,7 @@ export function showUnconstrainedMoveHint(
2929 const enter = getShortActionShortcut ( SHORTCUT_NAMES . EDIT_OR_CONFIRM ) ;
3030 const modifier = navigator . platform . startsWith ( 'Mac' ) ? '⌥' : 'Ctrl' ;
3131 const message = `Hold ${ modifier } and use arrow keys to move freely, then ${ enter } to accept the position` ;
32- toast ( workspace , {
32+ Toast . show ( workspace , {
3333 message,
3434 id : unconstrainedMoveHintId ,
3535 oncePerSession : ! force ,
@@ -44,7 +44,11 @@ export function showUnconstrainedMoveHint(
4444export function showConstrainedMovementHint ( workspace : WorkspaceSvg ) {
4545 const enter = getShortActionShortcut ( SHORTCUT_NAMES . EDIT_OR_CONFIRM ) ;
4646 const message = `Use the arrow keys to move, then ${ enter } to accept the position` ;
47- toast ( workspace , { message, id : constrainedMoveHintId , oncePerSession : true } ) ;
47+ Toast . show ( workspace , {
48+ message,
49+ id : constrainedMoveHintId ,
50+ oncePerSession : true ,
51+ } ) ;
4852}
4953
5054/**
@@ -53,8 +57,8 @@ export function showConstrainedMovementHint(workspace: WorkspaceSvg) {
5357 * @param workspace The workspace.
5458 */
5559export function clearMoveHints ( workspace : WorkspaceSvg ) {
56- clearToast ( workspace , constrainedMoveHintId ) ;
57- clearToast ( workspace , unconstrainedMoveHintId ) ;
60+ Toast . hide ( workspace , constrainedMoveHintId ) ;
61+ Toast . hide ( workspace , unconstrainedMoveHintId ) ;
5862}
5963
6064/**
@@ -63,21 +67,34 @@ export function clearMoveHints(workspace: WorkspaceSvg) {
6367 * @param workspace Workspace.
6468 */
6569export function showCopiedHint ( workspace : WorkspaceSvg ) {
66- toast ( workspace , {
70+ Toast . show ( workspace , {
6771 message : `Copied. Press ${ getShortActionShortcut ( 'paste' ) } to paste.` ,
6872 duration : 7000 ,
6973 id : copiedHintId ,
7074 } ) ;
7175}
7276
77+ /**
78+ * Nudge the user to paste after a cut.
79+ *
80+ * @param workspace Workspace.
81+ */
82+ export function showCutHint ( workspace : WorkspaceSvg ) {
83+ Toast . show ( workspace , {
84+ message : `Cut. Press ${ getShortActionShortcut ( 'paste' ) } to paste.` ,
85+ duration : 7000 ,
86+ id : cutHintId ,
87+ } ) ;
88+ }
89+
7390/**
7491 * Clear active paste-related hints, if any.
7592 *
7693 * @param workspace The workspace.
7794 */
7895export function clearPasteHints ( workspace : WorkspaceSvg ) {
79- // TODO: cut?
80- clearToast ( workspace , copiedHintId ) ;
96+ Toast . hide ( workspace , cutHintId ) ;
97+ Toast . hide ( workspace , copiedHintId ) ;
8198}
8299
83100/**
@@ -89,7 +106,7 @@ export function showHelpHint(workspace: WorkspaceSvg) {
89106 const shortcut = getShortActionShortcut ( 'list_shortcuts' ) ;
90107 const message = `Press ${ shortcut } for help on keyboard controls` ;
91108 const id = helpHintId ;
92- toast ( workspace , { message, id} ) ;
109+ Toast . show ( workspace , { message, id} ) ;
93110}
94111
95112/**
@@ -100,5 +117,5 @@ export function showHelpHint(workspace: WorkspaceSvg) {
100117export function clearHelpHint ( workspace : WorkspaceSvg ) {
101118 // TODO: We'd like to do this in MakeCode too as we override.
102119 // Could have an option for showing help in the plugin?
103- clearToast ( workspace , helpHintId ) ;
120+ Toast . hide ( workspace , helpHintId ) ;
104121}
0 commit comments