Skip to content

Commit 16735a8

Browse files
authored
feat: Show Paste menu item on connections. (#262)
1 parent b67f9d1 commit 16735a8

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/actions/clipboard.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,17 @@ export class Clipboard {
303303
const pasteAction: ContextMenuRegistry.RegistryItem = {
304304
displayText: (scope) => `Paste (${this.getPlatformPrefix()}V)`,
305305
preconditionFn: (scope) => {
306-
const ws = scope.block?.workspace;
306+
const ws =
307+
scope.block?.workspace ??
308+
(scope as any).connection?.getSourceBlock().workspace;
307309
if (!ws) return 'hidden';
308310

309311
return this.pastePrecondition(ws) ? 'enabled' : 'disabled';
310312
},
311313
callback: (scope) => {
312-
const ws = scope.block?.workspace;
314+
const ws =
315+
scope.block?.workspace ??
316+
(scope as any).connection?.getSourceBlock().workspace;
313317
if (!ws) return;
314318
return this.pasteCallback(ws);
315319
},

src/navigation.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,12 @@ export class Navigation {
13651365
const insertAction =
13661366
Blockly.ContextMenuRegistry.registry.getItem('insert');
13671367
if (!insertAction) throw new Error("can't find insert action");
1368-
const possibleOptions = [insertAction /* etc.*/];
1368+
1369+
const pasteAction = Blockly.ContextMenuRegistry.registry.getItem(
1370+
'blockPasteFromContextMenu',
1371+
);
1372+
if (!pasteAction) throw new Error("can't find paste action");
1373+
const possibleOptions = [insertAction, pasteAction /* etc.*/];
13691374

13701375
// Check preconditions and get menu texts.
13711376
const scope = {

0 commit comments

Comments
 (0)