@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.
@@ -290,7 +290,7 @@ export var HeaderMenu = (_dec = singleton({
290
290
  return execute;
291
291
  }()
292
292
  });
293
- commands.registerCommand(MenuCommands.UndoCellAction, {
293
+ commands.registerCommandWithContext(MenuCommands.UndoCellAction, this, {
294
294
  execute: function () {
295
295
  var _execute3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
296
296
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
@@ -309,9 +309,16 @@ export var HeaderMenu = (_dec = singleton({
309
309
  return _execute3.apply(this, arguments);
310
310
  }
311
311
  return execute;
312
- }()
312
+ }(),
313
+ isEnabled: function isEnabled(ctx) {
314
+ var libro = ctx.libroService.active;
315
+ if (libro && libro instanceof LibroJupyterView) {
316
+ return true;
317
+ }
318
+ return false;
319
+ }
313
320
  });
314
- commands.registerCommand(MenuCommands.RedoCellAction, {
321
+ commands.registerCommandWithContext(MenuCommands.RedoCellAction, this, {
315
322
  execute: function () {
316
323
  var _execute4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
317
324
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
@@ -330,9 +337,16 @@ export var HeaderMenu = (_dec = singleton({
330
337
  return _execute4.apply(this, arguments);
331
338
  }
332
339
  return execute;
333
- }()
340
+ }(),
341
+ isEnabled: function isEnabled(ctx) {
342
+ var libro = ctx.libroService.active;
343
+ if (libro && libro instanceof LibroJupyterView) {
344
+ return true;
345
+ }
346
+ return false;
347
+ }
334
348
  });
335
- commands.registerCommand(MenuCommands.CutCell, {
349
+ commands.registerCommandWithContext(MenuCommands.CutCell, this, {
336
350
  execute: function () {
337
351
  var _execute5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
338
352
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
@@ -351,9 +365,16 @@ export var HeaderMenu = (_dec = singleton({
351
365
  return _execute5.apply(this, arguments);
352
366
  }
353
367
  return execute;
354
- }()
368
+ }(),
369
+ isEnabled: function isEnabled(ctx) {
370
+ var libro = ctx.libroService.active;
371
+ if (libro && libro instanceof LibroJupyterView) {
372
+ return true;
373
+ }
374
+ return false;
375
+ }
355
376
  });
356
- commands.registerCommand(MenuCommands.CopyCell, {
377
+ commands.registerCommandWithContext(MenuCommands.CopyCell, this, {
357
378
  execute: function () {
358
379
  var _execute6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
359
380
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
@@ -372,9 +393,16 @@ export var HeaderMenu = (_dec = singleton({
372
393
  return _execute6.apply(this, arguments);
373
394
  }
374
395
  return execute;
375
- }()
396
+ }(),
397
+ isEnabled: function isEnabled(ctx) {
398
+ var libro = ctx.libroService.active;
399
+ if (libro && libro instanceof LibroJupyterView) {
400
+ return true;
401
+ }
402
+ return false;
403
+ }
376
404
  });
377
- commands.registerCommand(MenuCommands.DeleteCell, {
405
+ commands.registerCommandWithContext(MenuCommands.DeleteCell, this, {
378
406
  execute: function () {
379
407
  var _execute7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
380
408
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
@@ -393,9 +421,16 @@ export var HeaderMenu = (_dec = singleton({
393
421
  return _execute7.apply(this, arguments);
394
422
  }
395
423
  return execute;
396
- }()
424
+ }(),
425
+ isEnabled: function isEnabled(ctx) {
426
+ var libro = ctx.libroService.active;
427
+ if (libro && libro instanceof LibroJupyterView) {
428
+ return true;
429
+ }
430
+ return false;
431
+ }
397
432
  });
398
- commands.registerCommand(MenuCommands.PasteCellBelow, {
433
+ commands.registerCommandWithContext(MenuCommands.PasteCellBelow, this, {
399
434
  execute: function () {
400
435
  var _execute8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
401
436
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
@@ -414,9 +449,16 @@ export var HeaderMenu = (_dec = singleton({
414
449
  return _execute8.apply(this, arguments);
415
450
  }
416
451
  return execute;
417
- }()
452
+ }(),
453
+ isEnabled: function isEnabled(ctx) {
454
+ var libro = ctx.libroService.active;
455
+ if (libro && libro instanceof LibroJupyterView) {
456
+ return true;
457
+ }
458
+ return false;
459
+ }
418
460
  });
419
- commands.registerCommand(MenuCommands.PasteCellAbove, {
461
+ commands.registerCommandWithContext(MenuCommands.PasteCellAbove, this, {
420
462
  execute: function () {
421
463
  var _execute9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
422
464
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
@@ -435,9 +477,16 @@ export var HeaderMenu = (_dec = singleton({
435
477
  return _execute9.apply(this, arguments);
436
478
  }
437
479
  return execute;
438
- }()
480
+ }(),
481
+ isEnabled: function isEnabled(ctx) {
482
+ var libro = ctx.libroService.active;
483
+ if (libro && libro instanceof LibroJupyterView) {
484
+ return true;
485
+ }
486
+ return false;
487
+ }
439
488
  });
440
- commands.registerCommand(MenuCommands.PasteAndReplaceCell, {
489
+ commands.registerCommandWithContext(MenuCommands.PasteAndReplaceCell, this, {
441
490
  execute: function () {
442
491
  var _execute10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
443
492
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
@@ -456,9 +505,16 @@ export var HeaderMenu = (_dec = singleton({
456
505
  return _execute10.apply(this, arguments);
457
506
  }
458
507
  return execute;
459
- }()
508
+ }(),
509
+ isEnabled: function isEnabled(ctx) {
510
+ var libro = ctx.libroService.active;
511
+ if (libro && libro instanceof LibroJupyterView) {
512
+ return true;
513
+ }
514
+ return false;
515
+ }
460
516
  });
461
- commands.registerCommand(MenuCommands.SelectAll, {
517
+ commands.registerCommandWithContext(MenuCommands.SelectAll, this, {
462
518
  execute: function () {
463
519
  var _execute11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
464
520
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
@@ -477,19 +533,26 @@ export var HeaderMenu = (_dec = singleton({
477
533
  return _execute11.apply(this, arguments);
478
534
  }
479
535
  return execute;
480
- }()
536
+ }(),
537
+ isEnabled: function isEnabled(ctx) {
538
+ var libro = ctx.libroService.active;
539
+ if (libro && libro instanceof LibroJupyterView) {
540
+ return true;
541
+ }
542
+ return false;
543
+ }
481
544
  });
482
545
  // commands.registerCommand(MenuCommands.DeselectAll, {
483
546
  // execute: async () => {
484
- // if (this.libroService.active)
547
+ // if (libro)
485
548
  // this.commandRegistry.executeCommand(
486
549
  // NotebookCommands.DeselectAll.id,
487
- // this.libroService.active.activeCell,
488
- // this.libroService.active,
550
+ // libro.activeCell,
551
+ // libro,
489
552
  // );
490
553
  // },
491
554
  // });
492
- commands.registerCommand(MenuCommands.MoveCellUp, {
555
+ commands.registerCommandWithContext(MenuCommands.MoveCellUp, this, {
493
556
  execute: function () {
494
557
  var _execute12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
495
558
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
@@ -508,9 +571,16 @@ export var HeaderMenu = (_dec = singleton({
508
571
  return _execute12.apply(this, arguments);
509
572
  }
510
573
  return execute;
511
- }()
574
+ }(),
575
+ isEnabled: function isEnabled(ctx) {
576
+ var libro = ctx.libroService.active;
577
+ if (libro && libro instanceof LibroJupyterView) {
578
+ return true;
579
+ }
580
+ return false;
581
+ }
512
582
  });
513
- commands.registerCommand(MenuCommands.MoveCellDown, {
583
+ commands.registerCommandWithContext(MenuCommands.MoveCellDown, this, {
514
584
  execute: function () {
515
585
  var _execute13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
516
586
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
@@ -529,9 +599,16 @@ export var HeaderMenu = (_dec = singleton({
529
599
  return _execute13.apply(this, arguments);
530
600
  }
531
601
  return execute;
532
- }()
602
+ }(),
603
+ isEnabled: function isEnabled(ctx) {
604
+ var libro = ctx.libroService.active;
605
+ if (libro && libro instanceof LibroJupyterView) {
606
+ return true;
607
+ }
608
+ return false;
609
+ }
533
610
  });
534
- commands.registerCommand(MenuCommands.SplitCellAntCursor, {
611
+ commands.registerCommandWithContext(MenuCommands.SplitCellAntCursor, this, {
535
612
  execute: function () {
536
613
  var _execute14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
537
614
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
@@ -550,9 +627,16 @@ export var HeaderMenu = (_dec = singleton({
550
627
  return _execute14.apply(this, arguments);
551
628
  }
552
629
  return execute;
553
- }()
630
+ }(),
631
+ isEnabled: function isEnabled(ctx) {
632
+ var libro = ctx.libroService.active;
633
+ if (libro && libro instanceof LibroJupyterView) {
634
+ return true;
635
+ }
636
+ return false;
637
+ }
554
638
  });
555
- commands.registerCommand(MenuCommands.MergeCells, {
639
+ commands.registerCommandWithContext(MenuCommands.MergeCells, this, {
556
640
  execute: function () {
557
641
  var _execute15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
558
642
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
@@ -571,9 +655,16 @@ export var HeaderMenu = (_dec = singleton({
571
655
  return _execute15.apply(this, arguments);
572
656
  }
573
657
  return execute;
574
- }()
658
+ }(),
659
+ isEnabled: function isEnabled(ctx) {
660
+ var libro = ctx.libroService.active;
661
+ if (libro && libro instanceof LibroJupyterView) {
662
+ return true;
663
+ }
664
+ return false;
665
+ }
575
666
  });
576
- commands.registerCommand(MenuCommands.MergeCellAbove, {
667
+ commands.registerCommandWithContext(MenuCommands.MergeCellAbove, this, {
577
668
  execute: function () {
578
669
  var _execute16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
579
670
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
@@ -592,9 +683,16 @@ export var HeaderMenu = (_dec = singleton({
592
683
  return _execute16.apply(this, arguments);
593
684
  }
594
685
  return execute;
595
- }()
686
+ }(),
687
+ isEnabled: function isEnabled(ctx) {
688
+ var libro = ctx.libroService.active;
689
+ if (libro && libro instanceof LibroJupyterView) {
690
+ return true;
691
+ }
692
+ return false;
693
+ }
596
694
  });
597
- commands.registerCommand(MenuCommands.MergeCellBelow, {
695
+ commands.registerCommandWithContext(MenuCommands.MergeCellBelow, this, {
598
696
  execute: function () {
599
697
  var _execute17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
600
698
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
@@ -613,9 +711,16 @@ export var HeaderMenu = (_dec = singleton({
613
711
  return _execute17.apply(this, arguments);
614
712
  }
615
713
  return execute;
616
- }()
714
+ }(),
715
+ isEnabled: function isEnabled(ctx) {
716
+ var libro = ctx.libroService.active;
717
+ if (libro && libro instanceof LibroJupyterView) {
718
+ return true;
719
+ }
720
+ return false;
721
+ }
617
722
  });
618
- commands.registerCommand(MenuCommands.ClearCellOutput, {
723
+ commands.registerCommandWithContext(MenuCommands.ClearCellOutput, this, {
619
724
  execute: function () {
620
725
  var _execute18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
621
726
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
@@ -634,9 +739,16 @@ export var HeaderMenu = (_dec = singleton({
634
739
  return _execute18.apply(this, arguments);
635
740
  }
636
741
  return execute;
637
- }()
742
+ }(),
743
+ isEnabled: function isEnabled(ctx) {
744
+ var libro = ctx.libroService.active;
745
+ if (libro && libro instanceof LibroJupyterView) {
746
+ return true;
747
+ }
748
+ return false;
749
+ }
638
750
  });
639
- commands.registerCommand(MenuCommands.ClearAllCellOutput, {
751
+ commands.registerCommandWithContext(MenuCommands.ClearAllCellOutput, this, {
640
752
  execute: function () {
641
753
  var _execute19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
642
754
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
@@ -655,9 +767,16 @@ export var HeaderMenu = (_dec = singleton({
655
767
  return _execute19.apply(this, arguments);
656
768
  }
657
769
  return execute;
658
- }()
770
+ }(),
771
+ isEnabled: function isEnabled(ctx) {
772
+ var libro = ctx.libroService.active;
773
+ if (libro && libro instanceof LibroJupyterView) {
774
+ return true;
775
+ }
776
+ return false;
777
+ }
659
778
  });
660
- commands.registerCommand(MenuCommands.HideOrShowCellCode, {
779
+ commands.registerCommandWithContext(MenuCommands.HideOrShowCellCode, this, {
661
780
  execute: function () {
662
781
  var _execute20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
663
782
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
@@ -676,9 +795,16 @@ export var HeaderMenu = (_dec = singleton({
676
795
  return _execute20.apply(this, arguments);
677
796
  }
678
797
  return execute;
679
- }()
798
+ }(),
799
+ isEnabled: function isEnabled(ctx) {
800
+ var libro = ctx.libroService.active;
801
+ if (libro && libro instanceof LibroJupyterView) {
802
+ return true;
803
+ }
804
+ return false;
805
+ }
680
806
  });
681
- commands.registerCommand(MenuCommands.HideOrShowOutputs, {
807
+ commands.registerCommandWithContext(MenuCommands.HideOrShowOutputs, this, {
682
808
  execute: function () {
683
809
  var _execute21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
684
810
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
@@ -697,9 +823,16 @@ export var HeaderMenu = (_dec = singleton({
697
823
  return _execute21.apply(this, arguments);
698
824
  }
699
825
  return execute;
700
- }()
826
+ }(),
827
+ isEnabled: function isEnabled(ctx) {
828
+ var libro = ctx.libroService.active;
829
+ if (libro && libro instanceof LibroJupyterView) {
830
+ return true;
831
+ }
832
+ return false;
833
+ }
701
834
  });
702
- commands.registerCommand(MenuCommands.EnableOutputScrolling, {
835
+ commands.registerCommandWithContext(MenuCommands.EnableOutputScrolling, this, {
703
836
  execute: function () {
704
837
  var _execute22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
705
838
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
@@ -718,9 +851,16 @@ export var HeaderMenu = (_dec = singleton({
718
851
  return _execute22.apply(this, arguments);
719
852
  }
720
853
  return execute;
721
- }()
854
+ }(),
855
+ isEnabled: function isEnabled(ctx) {
856
+ var libro = ctx.libroService.active;
857
+ if (libro && libro instanceof LibroJupyterView) {
858
+ return true;
859
+ }
860
+ return false;
861
+ }
722
862
  });
723
- commands.registerCommand(MenuCommands.DisableOutputScrolling, {
863
+ commands.registerCommandWithContext(MenuCommands.DisableOutputScrolling, this, {
724
864
  execute: function () {
725
865
  var _execute23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
726
866
  return _regeneratorRuntime().wrap(function _callee23$(_context23) {
@@ -739,7 +879,14 @@ export var HeaderMenu = (_dec = singleton({
739
879
  return _execute23.apply(this, arguments);
740
880
  }
741
881
  return execute;
742
- }()
882
+ }(),
883
+ isEnabled: function isEnabled(ctx) {
884
+ var libro = ctx.libroService.active;
885
+ if (libro && libro instanceof LibroJupyterView) {
886
+ return true;
887
+ }
888
+ return false;
889
+ }
743
890
  });
744
891
  commands.registerCommandWithContext(MenuCommands.RunCell, this, {
745
892
  execute: function () {
@@ -23,7 +23,7 @@ import { CommandRegistry, ModalService, singleton, useInject, view, ViewManager
23
23
  import { BaseView } from '@difizen/mana-app';
24
24
  import { Col, Row } from 'antd';
25
25
  import { forwardRef, useEffect, useState } from 'react';
26
- import { KeybindIcon, PreferenceIcon, TerminalIcon } from "../common/icon.js";
26
+ import { TerminalIcon } from "../common/icon.js";
27
27
  import { MenuCommands } from "../menu/index.js";
28
28
  import "./index.less";
29
29
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -154,37 +154,6 @@ export var EntryPointComponent = /*#__PURE__*/forwardRef(function EntryPointComp
154
154
  })]
155
155
  })
156
156
  })
157
- }), /*#__PURE__*/_jsx("div", {
158
- className: "libro-lab-entry-point-item-title",
159
- children: "\u7CFB\u7EDF\u8BBE\u7F6E"
160
- }), /*#__PURE__*/_jsxs(Row, {
161
- children: [/*#__PURE__*/_jsx(Col, {
162
- className: "gutter-row",
163
- style: {
164
- paddingLeft: 'unset',
165
- paddingRight: '24px'
166
- },
167
- children: /*#__PURE__*/_jsxs("div", {
168
- className: "libro-lab-entry-point-item-config",
169
- children: [/*#__PURE__*/_jsx(PreferenceIcon, {}), /*#__PURE__*/_jsx("span", {
170
- className: "libro-lab-entry-point-item-config-text",
171
- children: "\u504F\u597D\u8BBE\u7F6E"
172
- })]
173
- })
174
- }), /*#__PURE__*/_jsx(Col, {
175
- className: "gutter-row",
176
- style: {
177
- paddingLeft: 'unset',
178
- paddingRight: '24px'
179
- },
180
- children: /*#__PURE__*/_jsxs("div", {
181
- className: "libro-lab-entry-point-item-config",
182
- children: [/*#__PURE__*/_jsx(KeybindIcon, {}), /*#__PURE__*/_jsx("span", {
183
- className: "libro-lab-entry-point-item-config-text",
184
- children: "\u5FEB\u6377\u952E\u8BBE\u7F6E"
185
- })]
186
- })
187
- })]
188
157
  })]
189
158
  });
190
159
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-lab",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -34,13 +34,13 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@ant-design/icons": "^5.1.0",
37
- "@difizen/libro-core": "^0.1.7",
38
- "@difizen/libro-jupyter": "^0.1.7",
39
- "@difizen/libro-kernel": "^0.1.7",
40
- "@difizen/libro-prompt-cell": "^0.1.7",
41
- "@difizen/libro-terminal": "^0.1.7",
42
- "@difizen/libro-toc": "^0.1.7",
43
- "@difizen/libro-cofine-editor-core": "^0.1.7",
37
+ "@difizen/libro-core": "^0.1.9",
38
+ "@difizen/libro-jupyter": "^0.1.9",
39
+ "@difizen/libro-kernel": "^0.1.9",
40
+ "@difizen/libro-prompt-cell": "^0.1.9",
41
+ "@difizen/libro-terminal": "^0.1.9",
42
+ "@difizen/libro-toc": "^0.1.9",
43
+ "@difizen/libro-cofine-editor-core": "^0.1.9",
44
44
  "@difizen/mana-app": "latest",
45
45
  "@difizen/mana-react": "latest",
46
46
  "classnames": "^2.3.2",
@@ -66,6 +66,6 @@
66
66
  "coverage:jest": "jest --coverage",
67
67
  "lint": ": Note: lint task is delegated to lint:* scripts",
68
68
  "lint:eslint": "eslint src",
69
- "lint:tsc": "tsc --noEmit"
69
+ "typecheck:tsc": "tsc --noEmit"
70
70
  }
71
71
  }
@@ -111,7 +111,7 @@ export class CodeEditorViewer extends BaseView implements NavigatableView, Savea
111
111
  return;
112
112
  }
113
113
  const content = await getOrigin(this.fileService).read(this.filePath);
114
- if (typeof content !== 'string' || !this.languageSpec) {
114
+ if (typeof content !== 'string') {
115
115
  return;
116
116
  }
117
117
  if (!this.codeRef || !this.codeRef.current) {
@@ -119,13 +119,13 @@ export class CodeEditorViewer extends BaseView implements NavigatableView, Savea
119
119
  }
120
120
 
121
121
  await MonacoEnvironment.init();
122
- await this.languageSpec.beforeEditorInit?.();
122
+ await this.languageSpec?.beforeEditorInit?.();
123
123
  const editorPorvider =
124
124
  MonacoEnvironment.container.get<EditorProvider>(EditorProvider);
125
125
 
126
126
  const uri = MonacoUri.from({
127
127
  scheme: LibroLabE2URIScheme,
128
- path: `${this.filePath}${this.languageSpec.ext[0]}`,
128
+ path: `${this.filePath}${this.languageSpec?.ext[0]}`,
129
129
  });
130
130
 
131
131
  const options: MonacoEditorOptions = {
@@ -133,7 +133,7 @@ export class CodeEditorViewer extends BaseView implements NavigatableView, Savea
133
133
  * language ia an uri:
134
134
  */
135
135
  theme: 'libro-light',
136
- language: this.languageSpec.language,
136
+ language: this.languageSpec?.language || 'markdown',
137
137
  uri,
138
138
  value: content,
139
139
  };
@@ -3,6 +3,11 @@
3
3
  .libro-lab-footer-right {
4
4
  padding: 0 24px;
5
5
  }
6
+
7
+ .libro-lab-footer-right {
8
+ display: flex;
9
+ justify-content: end;
10
+ }
6
11
  }
7
12
 
8
13
  .libro-lab-current-file-footer,
@@ -1,4 +1,6 @@
1
+ import { LibroNavigatableView, LibroService } from '@difizen/libro-jupyter';
1
2
  import type { View, ViewOpenHandlerOptions } from '@difizen/mana-app';
3
+ import { observable } from '@difizen/mana-app';
2
4
  import {
3
5
  DefaultSlotView,
4
6
  inject,
@@ -14,7 +16,17 @@ export type VisibilityMap = Record<LibroLabLayoutSlotsType, boolean>;
14
16
 
15
17
  @singleton()
16
18
  export class LayoutService {
17
- @inject(SlotViewManager) protected readonly slotViewManager: SlotViewManager;
19
+ protected readonly slotViewManager: SlotViewManager;
20
+ protected readonly libroService: LibroService;
21
+
22
+ constructor(
23
+ @inject(SlotViewManager) slotViewManager: SlotViewManager,
24
+ @inject(LibroService) libroService: LibroService,
25
+ ) {
26
+ this.slotViewManager = slotViewManager;
27
+ this.libroService = libroService;
28
+ this.onOpenSlotActiveChange();
29
+ }
18
30
 
19
31
  @prop()
20
32
  serverSatus: StatusType = 'loading';
@@ -62,4 +74,24 @@ export class LayoutService {
62
74
  }
63
75
  return undefined;
64
76
  }
77
+
78
+ async onOpenSlotActiveChange() {
79
+ if (this.isAreaVisible(LibroLabLayoutSlots.content)) {
80
+ const slotView = await this.slotViewManager.getOrCreateSlotView(
81
+ LibroLabLayoutSlots.content,
82
+ );
83
+ observable(slotView);
84
+ if (slotView instanceof DefaultSlotView) {
85
+ slotView.onActiveChange(() => {
86
+ const active = slotView.active;
87
+ if (active instanceof LibroNavigatableView) {
88
+ active.libroView?.focus();
89
+ this.libroService.active = active.libroView;
90
+ } else {
91
+ this.libroService.active = undefined;
92
+ }
93
+ });
94
+ }
95
+ }
96
+ }
65
97
  }
@@ -11,37 +11,35 @@ import type { VisibilityMap } from './layout-service.js';
11
11
  import { LayoutService } from './layout-service.js';
12
12
  import { LibroLabLayoutSlots } from './protocol.js';
13
13
 
14
- export const LibroLabLayoutComponent = forwardRef(
15
- function LibroLabLayoutComponent() {
16
- const layoutService = useInject(LayoutService);
17
-
18
- return (
19
- <div className="libro-lab-layout">
20
- <BoxPanel direction="top-to-bottom">
21
- {layoutService.isAreaVisible(LibroLabLayoutSlots.header) && (
22
- <BoxPanel.Pane className="libro-lab-layout-header">
23
- <Slot name={LibroLabLayoutSlots.header} />
24
- </BoxPanel.Pane>
25
- )}
26
- {layoutService.isAreaVisible(LibroLabLayoutSlots.alert) && (
27
- <Alert
28
- message="服务启动中,请稍后,待容器启动完成后即可编辑文件。"
29
- type="info"
30
- banner
31
- closable
32
- icon={<Loadding className="libro-lab-loadding" />}
33
- />
34
- )}
35
- {layoutService.isAreaVisible(LibroLabLayoutSlots.container) && (
36
- <BoxPanel.Pane className="libro-lab-layout-container" flex={1}>
37
- <Slot name={LibroLabLayoutSlots.container} />
38
- </BoxPanel.Pane>
39
- )}
40
- </BoxPanel>
41
- </div>
42
- );
43
- },
44
- );
14
+ export const LibroLabLayoutComponent = forwardRef(function LibroLabLayoutComponent() {
15
+ const layoutService = useInject(LayoutService);
16
+
17
+ return (
18
+ <div className="libro-lab-layout">
19
+ <BoxPanel direction="top-to-bottom">
20
+ {layoutService.isAreaVisible(LibroLabLayoutSlots.header) && (
21
+ <BoxPanel.Pane className="libro-lab-layout-header">
22
+ <Slot name={LibroLabLayoutSlots.header} />
23
+ </BoxPanel.Pane>
24
+ )}
25
+ {layoutService.isAreaVisible(LibroLabLayoutSlots.alert) && (
26
+ <Alert
27
+ message="服务启动中,请稍后,待服务启动完成后即可编辑文件。"
28
+ type="info"
29
+ banner
30
+ closable
31
+ icon={<Loadding className="libro-lab-loadding" />}
32
+ />
33
+ )}
34
+ {layoutService.isAreaVisible(LibroLabLayoutSlots.container) && (
35
+ <BoxPanel.Pane className="libro-lab-layout-container" flex={1}>
36
+ <Slot name={LibroLabLayoutSlots.container} />
37
+ </BoxPanel.Pane>
38
+ )}
39
+ </BoxPanel>
40
+ </div>
41
+ );
42
+ });
45
43
 
46
44
  @singleton()
47
45
  @view('libro-lab-layout')