@difizen/libro-lab 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -247,7 +247,7 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
247
247
  //TODO: 保存
248
248
  },
249
249
  });
250
- commands.registerCommand(MenuCommands.UndoCellAction, {
250
+ commands.registerCommandWithContext(MenuCommands.UndoCellAction, this, {
251
251
  execute: async () => {
252
252
  if (this.libroService.active) {
253
253
  this.commandRegistry.executeCommand(
@@ -257,8 +257,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
257
257
  );
258
258
  }
259
259
  },
260
+ isEnabled: (ctx) => {
261
+ const libro = ctx.libroService.active;
262
+ if (libro && libro instanceof LibroJupyterView) {
263
+ return true;
264
+ }
265
+ return false;
266
+ },
260
267
  });
261
- commands.registerCommand(MenuCommands.RedoCellAction, {
268
+ commands.registerCommandWithContext(MenuCommands.RedoCellAction, this, {
262
269
  execute: async () => {
263
270
  if (this.libroService.active) {
264
271
  this.commandRegistry.executeCommand(
@@ -268,8 +275,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
268
275
  );
269
276
  }
270
277
  },
278
+ isEnabled: (ctx) => {
279
+ const libro = ctx.libroService.active;
280
+ if (libro && libro instanceof LibroJupyterView) {
281
+ return true;
282
+ }
283
+ return false;
284
+ },
271
285
  });
272
- commands.registerCommand(MenuCommands.CutCell, {
286
+ commands.registerCommandWithContext(MenuCommands.CutCell, this, {
273
287
  execute: async () => {
274
288
  if (this.libroService.active) {
275
289
  this.commandRegistry.executeCommand(
@@ -279,8 +293,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
279
293
  );
280
294
  }
281
295
  },
296
+ isEnabled: (ctx) => {
297
+ const libro = ctx.libroService.active;
298
+ if (libro && libro instanceof LibroJupyterView) {
299
+ return true;
300
+ }
301
+ return false;
302
+ },
282
303
  });
283
- commands.registerCommand(MenuCommands.CopyCell, {
304
+ commands.registerCommandWithContext(MenuCommands.CopyCell, this, {
284
305
  execute: async () => {
285
306
  if (this.libroService.active) {
286
307
  this.commandRegistry.executeCommand(
@@ -290,8 +311,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
290
311
  );
291
312
  }
292
313
  },
314
+ isEnabled: (ctx) => {
315
+ const libro = ctx.libroService.active;
316
+ if (libro && libro instanceof LibroJupyterView) {
317
+ return true;
318
+ }
319
+ return false;
320
+ },
293
321
  });
294
- commands.registerCommand(MenuCommands.DeleteCell, {
322
+ commands.registerCommandWithContext(MenuCommands.DeleteCell, this, {
295
323
  execute: async () => {
296
324
  if (this.libroService.active) {
297
325
  this.commandRegistry.executeCommand(
@@ -301,8 +329,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
301
329
  );
302
330
  }
303
331
  },
332
+ isEnabled: (ctx) => {
333
+ const libro = ctx.libroService.active;
334
+ if (libro && libro instanceof LibroJupyterView) {
335
+ return true;
336
+ }
337
+ return false;
338
+ },
304
339
  });
305
- commands.registerCommand(MenuCommands.PasteCellBelow, {
340
+ commands.registerCommandWithContext(MenuCommands.PasteCellBelow, this, {
306
341
  execute: async () => {
307
342
  if (this.libroService.active) {
308
343
  this.commandRegistry.executeCommand(
@@ -312,8 +347,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
312
347
  );
313
348
  }
314
349
  },
350
+ isEnabled: (ctx) => {
351
+ const libro = ctx.libroService.active;
352
+ if (libro && libro instanceof LibroJupyterView) {
353
+ return true;
354
+ }
355
+ return false;
356
+ },
315
357
  });
316
- commands.registerCommand(MenuCommands.PasteCellAbove, {
358
+ commands.registerCommandWithContext(MenuCommands.PasteCellAbove, this, {
317
359
  execute: async () => {
318
360
  if (this.libroService.active) {
319
361
  this.commandRegistry.executeCommand(
@@ -323,8 +365,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
323
365
  );
324
366
  }
325
367
  },
368
+ isEnabled: (ctx) => {
369
+ const libro = ctx.libroService.active;
370
+ if (libro && libro instanceof LibroJupyterView) {
371
+ return true;
372
+ }
373
+ return false;
374
+ },
326
375
  });
327
- commands.registerCommand(MenuCommands.PasteAndReplaceCell, {
376
+ commands.registerCommandWithContext(MenuCommands.PasteAndReplaceCell, this, {
328
377
  execute: async () => {
329
378
  if (this.libroService.active) {
330
379
  this.commandRegistry.executeCommand(
@@ -334,8 +383,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
334
383
  );
335
384
  }
336
385
  },
386
+ isEnabled: (ctx) => {
387
+ const libro = ctx.libroService.active;
388
+ if (libro && libro instanceof LibroJupyterView) {
389
+ return true;
390
+ }
391
+ return false;
392
+ },
337
393
  });
338
- commands.registerCommand(MenuCommands.SelectAll, {
394
+ commands.registerCommandWithContext(MenuCommands.SelectAll, this, {
339
395
  execute: async () => {
340
396
  if (this.libroService.active) {
341
397
  this.commandRegistry.executeCommand(
@@ -345,18 +401,25 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
345
401
  );
346
402
  }
347
403
  },
404
+ isEnabled: (ctx) => {
405
+ const libro = ctx.libroService.active;
406
+ if (libro && libro instanceof LibroJupyterView) {
407
+ return true;
408
+ }
409
+ return false;
410
+ },
348
411
  });
349
412
  // commands.registerCommand(MenuCommands.DeselectAll, {
350
413
  // execute: async () => {
351
- // if (this.libroService.active)
414
+ // if (libro)
352
415
  // this.commandRegistry.executeCommand(
353
416
  // NotebookCommands.DeselectAll.id,
354
- // this.libroService.active.activeCell,
355
- // this.libroService.active,
417
+ // libro.activeCell,
418
+ // libro,
356
419
  // );
357
420
  // },
358
421
  // });
359
- commands.registerCommand(MenuCommands.MoveCellUp, {
422
+ commands.registerCommandWithContext(MenuCommands.MoveCellUp, this, {
360
423
  execute: async () => {
361
424
  if (this.libroService.active) {
362
425
  this.commandRegistry.executeCommand(
@@ -366,8 +429,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
366
429
  );
367
430
  }
368
431
  },
432
+ isEnabled: (ctx) => {
433
+ const libro = ctx.libroService.active;
434
+ if (libro && libro instanceof LibroJupyterView) {
435
+ return true;
436
+ }
437
+ return false;
438
+ },
369
439
  });
370
- commands.registerCommand(MenuCommands.MoveCellDown, {
440
+ commands.registerCommandWithContext(MenuCommands.MoveCellDown, this, {
371
441
  execute: async () => {
372
442
  if (this.libroService.active) {
373
443
  this.commandRegistry.executeCommand(
@@ -377,8 +447,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
377
447
  );
378
448
  }
379
449
  },
450
+ isEnabled: (ctx) => {
451
+ const libro = ctx.libroService.active;
452
+ if (libro && libro instanceof LibroJupyterView) {
453
+ return true;
454
+ }
455
+ return false;
456
+ },
380
457
  });
381
- commands.registerCommand(MenuCommands.SplitCellAntCursor, {
458
+ commands.registerCommandWithContext(MenuCommands.SplitCellAntCursor, this, {
382
459
  execute: async () => {
383
460
  if (this.libroService.active) {
384
461
  this.commandRegistry.executeCommand(
@@ -388,8 +465,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
388
465
  );
389
466
  }
390
467
  },
468
+ isEnabled: (ctx) => {
469
+ const libro = ctx.libroService.active;
470
+ if (libro && libro instanceof LibroJupyterView) {
471
+ return true;
472
+ }
473
+ return false;
474
+ },
391
475
  });
392
- commands.registerCommand(MenuCommands.MergeCells, {
476
+ commands.registerCommandWithContext(MenuCommands.MergeCells, this, {
393
477
  execute: async () => {
394
478
  if (this.libroService.active) {
395
479
  this.commandRegistry.executeCommand(
@@ -399,8 +483,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
399
483
  );
400
484
  }
401
485
  },
486
+ isEnabled: (ctx) => {
487
+ const libro = ctx.libroService.active;
488
+ if (libro && libro instanceof LibroJupyterView) {
489
+ return true;
490
+ }
491
+ return false;
492
+ },
402
493
  });
403
- commands.registerCommand(MenuCommands.MergeCellAbove, {
494
+ commands.registerCommandWithContext(MenuCommands.MergeCellAbove, this, {
404
495
  execute: async () => {
405
496
  if (this.libroService.active) {
406
497
  this.commandRegistry.executeCommand(
@@ -410,8 +501,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
410
501
  );
411
502
  }
412
503
  },
504
+ isEnabled: (ctx) => {
505
+ const libro = ctx.libroService.active;
506
+ if (libro && libro instanceof LibroJupyterView) {
507
+ return true;
508
+ }
509
+ return false;
510
+ },
413
511
  });
414
- commands.registerCommand(MenuCommands.MergeCellBelow, {
512
+ commands.registerCommandWithContext(MenuCommands.MergeCellBelow, this, {
415
513
  execute: async () => {
416
514
  if (this.libroService.active) {
417
515
  this.commandRegistry.executeCommand(
@@ -421,8 +519,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
421
519
  );
422
520
  }
423
521
  },
522
+ isEnabled: (ctx) => {
523
+ const libro = ctx.libroService.active;
524
+ if (libro && libro instanceof LibroJupyterView) {
525
+ return true;
526
+ }
527
+ return false;
528
+ },
424
529
  });
425
- commands.registerCommand(MenuCommands.ClearCellOutput, {
530
+ commands.registerCommandWithContext(MenuCommands.ClearCellOutput, this, {
426
531
  execute: async () => {
427
532
  if (this.libroService.active) {
428
533
  this.commandRegistry.executeCommand(
@@ -432,8 +537,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
432
537
  );
433
538
  }
434
539
  },
540
+ isEnabled: (ctx) => {
541
+ const libro = ctx.libroService.active;
542
+ if (libro && libro instanceof LibroJupyterView) {
543
+ return true;
544
+ }
545
+ return false;
546
+ },
435
547
  });
436
- commands.registerCommand(MenuCommands.ClearAllCellOutput, {
548
+ commands.registerCommandWithContext(MenuCommands.ClearAllCellOutput, this, {
437
549
  execute: async () => {
438
550
  if (this.libroService.active) {
439
551
  this.commandRegistry.executeCommand(
@@ -443,8 +555,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
443
555
  );
444
556
  }
445
557
  },
558
+ isEnabled: (ctx) => {
559
+ const libro = ctx.libroService.active;
560
+ if (libro && libro instanceof LibroJupyterView) {
561
+ return true;
562
+ }
563
+ return false;
564
+ },
446
565
  });
447
- commands.registerCommand(MenuCommands.HideOrShowCellCode, {
566
+ commands.registerCommandWithContext(MenuCommands.HideOrShowCellCode, this, {
448
567
  execute: async () => {
449
568
  if (this.libroService.active) {
450
569
  this.commandRegistry.executeCommand(
@@ -454,8 +573,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
454
573
  );
455
574
  }
456
575
  },
576
+ isEnabled: (ctx) => {
577
+ const libro = ctx.libroService.active;
578
+ if (libro && libro instanceof LibroJupyterView) {
579
+ return true;
580
+ }
581
+ return false;
582
+ },
457
583
  });
458
- commands.registerCommand(MenuCommands.HideOrShowOutputs, {
584
+ commands.registerCommandWithContext(MenuCommands.HideOrShowOutputs, this, {
459
585
  execute: async () => {
460
586
  if (this.libroService.active) {
461
587
  this.commandRegistry.executeCommand(
@@ -465,8 +591,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
465
591
  );
466
592
  }
467
593
  },
594
+ isEnabled: (ctx) => {
595
+ const libro = ctx.libroService.active;
596
+ if (libro && libro instanceof LibroJupyterView) {
597
+ return true;
598
+ }
599
+ return false;
600
+ },
468
601
  });
469
- commands.registerCommand(MenuCommands.EnableOutputScrolling, {
602
+ commands.registerCommandWithContext(MenuCommands.EnableOutputScrolling, this, {
470
603
  execute: async () => {
471
604
  if (this.libroService.active) {
472
605
  this.commandRegistry.executeCommand(
@@ -476,8 +609,15 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
476
609
  );
477
610
  }
478
611
  },
612
+ isEnabled: (ctx) => {
613
+ const libro = ctx.libroService.active;
614
+ if (libro && libro instanceof LibroJupyterView) {
615
+ return true;
616
+ }
617
+ return false;
618
+ },
479
619
  });
480
- commands.registerCommand(MenuCommands.DisableOutputScrolling, {
620
+ commands.registerCommandWithContext(MenuCommands.DisableOutputScrolling, this, {
481
621
  execute: async () => {
482
622
  if (this.libroService.active) {
483
623
  this.commandRegistry.executeCommand(
@@ -487,6 +627,13 @@ export class HeaderMenu implements MenuContribution, CommandContribution {
487
627
  );
488
628
  }
489
629
  },
630
+ isEnabled: (ctx) => {
631
+ const libro = ctx.libroService.active;
632
+ if (libro && libro instanceof LibroJupyterView) {
633
+ return true;
634
+ }
635
+ return false;
636
+ },
490
637
  });
491
638
  commands.registerCommandWithContext(MenuCommands.RunCell, this, {
492
639
  execute: async (ctx) => {
@@ -18,7 +18,7 @@ import { BaseView } from '@difizen/mana-app';
18
18
  import { Col, Row } from 'antd';
19
19
  import { forwardRef, useEffect, useState } from 'react';
20
20
 
21
- import { KeybindIcon, PreferenceIcon, TerminalIcon } from '../common/icon.js';
21
+ import { TerminalIcon } from '../common/icon.js';
22
22
  import { MenuCommands } from '../menu/index.js';
23
23
 
24
24
  import './index.less';
@@ -145,7 +145,7 @@ export const EntryPointComponent = forwardRef(function EntryPointComponent() {
145
145
  </div>
146
146
  </Col>
147
147
  </Row> */}
148
- <div className="libro-lab-entry-point-item-title">系统设置</div>
148
+ {/* <div className="libro-lab-entry-point-item-title">系统设置</div>
149
149
  <Row>
150
150
  <Col
151
151
  className="gutter-row"
@@ -165,7 +165,7 @@ export const EntryPointComponent = forwardRef(function EntryPointComponent() {
165
165
  <span className="libro-lab-entry-point-item-config-text">快捷键设置</span>
166
166
  </div>
167
167
  </Col>
168
- </Row>
168
+ </Row> */}
169
169
  </div>
170
170
  );
171
171
  });