@opensumi/ide-notebook 3.4.5-next-1730120479.0 → 3.5.1-next-1731636910.0
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.
- package/README.md +3 -2
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +2 -8
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/kernel-panel/collapse/index.d.ts.map +1 -1
- package/lib/browser/kernel-panel/collapse/index.js +10 -7
- package/lib/browser/kernel-panel/collapse/index.js.map +1 -1
- package/lib/browser/kernel-panel/collapse/page-collapse-content.d.ts.map +1 -1
- package/lib/browser/kernel-panel/collapse/page-collapse-content.js +1 -1
- package/lib/browser/kernel-panel/collapse/page-collapse-content.js.map +1 -1
- package/lib/browser/kernel-panel/kernel-panel-view.js +2 -2
- package/lib/browser/kernel-panel/kernel-panel-view.js.map +1 -1
- package/lib/browser/kernel-panel/kernel.panel.contribution.d.ts.map +1 -1
- package/lib/browser/kernel-panel/kernel.panel.contribution.js +2 -2
- package/lib/browser/kernel-panel/kernel.panel.contribution.js.map +1 -1
- package/lib/browser/libro/editor/editor-contribution.d.ts.map +1 -1
- package/lib/browser/libro/editor/editor-contribution.js +2 -1
- package/lib/browser/libro/editor/editor-contribution.js.map +1 -1
- package/lib/browser/libro/editor/index.less +0 -1
- package/lib/browser/libro/editor/keybind-handler.d.ts +1 -0
- package/lib/browser/libro/editor/keybind-handler.d.ts.map +1 -1
- package/lib/browser/libro/editor/keybind-handler.js +15 -29
- package/lib/browser/libro/editor/keybind-handler.js.map +1 -1
- package/lib/browser/libro/editor/opensumi-editor.d.ts +2 -2
- package/lib/browser/libro/editor/opensumi-editor.d.ts.map +1 -1
- package/lib/browser/libro/editor/opensumi-editor.js +7 -80
- package/lib/browser/libro/editor/opensumi-editor.js.map +1 -1
- package/lib/browser/libro/libro-opensumi-content-contribution.d.ts +1 -1
- package/lib/browser/libro/libro-opensumi-save-content-contribution.d.ts +1 -1
- package/lib/browser/libro-keybind-contribution.d.ts +1 -1
- package/lib/browser/libro-keybind-contribution.js +10 -10
- package/lib/browser/libro-keybind-contribution.js.map +1 -1
- package/lib/browser/libro-opener.d.ts +1 -0
- package/lib/browser/libro-opener.d.ts.map +1 -1
- package/lib/browser/libro-opener.js +15 -6
- package/lib/browser/libro-opener.js.map +1 -1
- package/lib/browser/libro.command.d.ts.map +1 -1
- package/lib/browser/libro.command.js +2 -1
- package/lib/browser/libro.command.js.map +1 -1
- package/lib/browser/libro.contribution.d.ts +5 -3
- package/lib/browser/libro.contribution.d.ts.map +1 -1
- package/lib/browser/libro.contribution.js +29 -13
- package/lib/browser/libro.contribution.js.map +1 -1
- package/lib/browser/libro.module.less +3 -0
- package/lib/browser/libro.service.d.ts +4 -8
- package/lib/browser/libro.service.d.ts.map +1 -1
- package/lib/browser/libro.service.js +4 -8
- package/lib/browser/libro.service.js.map +1 -1
- package/lib/browser/libro.view.d.ts.map +1 -1
- package/lib/browser/libro.view.js +12 -17
- package/lib/browser/libro.view.js.map +1 -1
- package/lib/browser/notebook-document-content-provider.d.ts +3 -4
- package/lib/browser/notebook-document-content-provider.d.ts.map +1 -1
- package/lib/browser/notebook-document-content-provider.js +3 -18
- package/lib/browser/notebook-document-content-provider.js.map +1 -1
- package/lib/browser/notebook.service.d.ts +4 -6
- package/lib/browser/notebook.service.d.ts.map +1 -1
- package/lib/browser/notebook.service.js +18 -21
- package/lib/browser/notebook.service.js.map +1 -1
- package/lib/browser/toc/toc.panel.js +2 -2
- package/lib/browser/toc/toc.panel.js.map +1 -1
- package/package.json +20 -19
- package/src/browser/index.ts +2 -8
- package/src/browser/kernel-panel/collapse/index.tsx +16 -9
- package/src/browser/kernel-panel/collapse/page-collapse-content.tsx +7 -9
- package/src/browser/kernel-panel/kernel-panel-view.tsx +2 -2
- package/src/browser/kernel-panel/kernel.panel.contribution.ts +2 -2
- package/src/browser/libro/editor/editor-contribution.ts +2 -1
- package/src/browser/libro/editor/index.less +0 -1
- package/src/browser/libro/editor/keybind-handler.ts +17 -29
- package/src/browser/libro/editor/opensumi-editor.ts +21 -103
- package/src/browser/libro-keybind-contribution.ts +2 -2
- package/src/browser/libro-opener.ts +14 -9
- package/src/browser/libro.command.ts +2 -1
- package/src/browser/libro.contribution.tsx +38 -11
- package/src/browser/libro.module.less +3 -0
- package/src/browser/libro.service.ts +4 -16
- package/src/browser/libro.view.tsx +14 -20
- package/src/browser/notebook-document-content-provider.ts +3 -29
- package/src/browser/notebook.service.ts +86 -82
- package/src/browser/toc/toc.panel.tsx +2 -2
- package/lib/browser/libro.view.tracker.d.ts +0 -6
- package/lib/browser/libro.view.tracker.d.ts.map +0 -1
- package/lib/browser/libro.view.tracker.js +0 -28
- package/lib/browser/libro.view.tracker.js.map +0 -1
- package/src/browser/libro.view.tracker.ts +0 -18
|
@@ -43,40 +43,28 @@ export class Keybindhandler implements ApplicationContribution {
|
|
|
43
43
|
return this.libroService.active instanceof LibroView;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
private registerSingleCommand(command: { id: string }) {
|
|
47
47
|
const sumiCommandRegistry: SumiCommandRegistry = this.injector.get(SumiCommandRegistry);
|
|
48
|
-
sumiCommandRegistry.registerCommand(
|
|
49
|
-
execute: () => {
|
|
50
|
-
this.commandRegistry.executeCommand(NotebookCommands['EnterCommandMode'].id);
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
sumiCommandRegistry.registerCommand(NotebookCommands['RunCell'], {
|
|
54
|
-
execute: () => {
|
|
55
|
-
this.commandRegistry.executeCommand(NotebookCommands['RunCell'].id);
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
sumiCommandRegistry.registerCommand(NotebookCommands['RunCellAndSelectNext'], {
|
|
59
|
-
execute: () => {
|
|
60
|
-
this.commandRegistry.executeCommand(NotebookCommands['RunCellAndSelectNext'].id);
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
sumiCommandRegistry.registerCommand(NotebookCommands['RunCellAndInsertBelow'], {
|
|
48
|
+
sumiCommandRegistry.registerCommand(command, {
|
|
64
49
|
execute: () => {
|
|
65
|
-
this.commandRegistry.executeCommand(
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
sumiCommandRegistry.registerCommand(NotebookCommands['SplitCellAntCursor'], {
|
|
69
|
-
execute: () => {
|
|
70
|
-
this.commandRegistry.executeCommand(NotebookCommands['SplitCellAntCursor'].id);
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
sumiCommandRegistry.registerCommand(LibroSearchToggleCommand.ShowLibroSearch, {
|
|
74
|
-
execute: () => {
|
|
75
|
-
this.commandRegistry.executeCommand(LibroSearchToggleCommand.ShowLibroSearch.id);
|
|
50
|
+
this.commandRegistry.executeCommand(command.id);
|
|
76
51
|
},
|
|
77
52
|
});
|
|
78
53
|
}
|
|
79
54
|
|
|
55
|
+
registerCommand() {
|
|
56
|
+
const commands = [
|
|
57
|
+
NotebookCommands['EnterCommandMode'],
|
|
58
|
+
NotebookCommands['RunCell'],
|
|
59
|
+
NotebookCommands['RunCellAndSelectNext'],
|
|
60
|
+
NotebookCommands['RunCellAndInsertBelow'],
|
|
61
|
+
NotebookCommands['SplitCellAntCursor'],
|
|
62
|
+
LibroSearchToggleCommand.ShowLibroSearch,
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
commands.forEach((command) => this.registerSingleCommand(command));
|
|
66
|
+
}
|
|
67
|
+
|
|
80
68
|
registerKeybind() {
|
|
81
69
|
const keybindingService: KeybindingRegistry = this.injector.get(KeybindingRegistry);
|
|
82
70
|
keybindingService.registerKeybindings(
|
|
@@ -99,7 +87,7 @@ export class Keybindhandler implements ApplicationContribution {
|
|
|
99
87
|
{
|
|
100
88
|
keybinding: 'esc',
|
|
101
89
|
command: NotebookCommands['EnterCommandMode'].id,
|
|
102
|
-
when: 'libroNotebookFocused && !editorHasSelection && !
|
|
90
|
+
when: 'libroNotebookFocused && !editorHasSelection && !editorHasMultipleSelections',
|
|
103
91
|
},
|
|
104
92
|
{
|
|
105
93
|
keybinding: 'ctrlcmd+enter',
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line import/order
|
|
2
|
-
import type {
|
|
3
|
-
CodeEditorFactory,
|
|
4
|
-
CompletionProvider,
|
|
5
|
-
EditorState,
|
|
6
|
-
ICoordinate,
|
|
7
|
-
IEditor,
|
|
8
|
-
IEditorConfig,
|
|
9
|
-
IEditorOptions,
|
|
10
|
-
IModel,
|
|
11
|
-
IModelContentChange,
|
|
12
|
-
IPosition,
|
|
13
|
-
IRange,
|
|
14
|
-
SearchMatch,
|
|
15
|
-
TooltipProvider,
|
|
16
|
-
} from '@difizen/libro-code-editor';
|
|
17
1
|
import { defaultConfig } from '@difizen/libro-code-editor';
|
|
18
2
|
import { MIME } from '@difizen/libro-common';
|
|
19
3
|
import { EditorStateFactory, IEditorStateOptions } from '@difizen/libro-jupyter/noeditor';
|
|
@@ -41,6 +25,20 @@ import { Range as MonacoRange } from '@opensumi/monaco-editor-core/esm/vs/editor
|
|
|
41
25
|
|
|
42
26
|
import { OpensumiInjector } from '../../mana';
|
|
43
27
|
|
|
28
|
+
import type {
|
|
29
|
+
CodeEditorFactory,
|
|
30
|
+
CompletionProvider,
|
|
31
|
+
EditorState,
|
|
32
|
+
IEditor,
|
|
33
|
+
IEditorConfig,
|
|
34
|
+
IEditorOptions,
|
|
35
|
+
IModel,
|
|
36
|
+
IModelContentChange,
|
|
37
|
+
IPosition,
|
|
38
|
+
IRange,
|
|
39
|
+
SearchMatch,
|
|
40
|
+
TooltipProvider,
|
|
41
|
+
} from '@difizen/libro-code-editor';
|
|
44
42
|
import type { LSPProvider } from '@difizen/libro-lsp';
|
|
45
43
|
import type { IStandaloneEditorConstructionOptions as MonacoEditorOptions } from '@opensumi/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor';
|
|
46
44
|
import './index.less';
|
|
@@ -56,9 +54,6 @@ export interface LibroOpensumiEditorConfig extends IEditorConfig {
|
|
|
56
54
|
*/
|
|
57
55
|
mimetype?: string;
|
|
58
56
|
|
|
59
|
-
// FIXME-TRANS: Handle theme localizable names
|
|
60
|
-
// themeDisplayName?: string
|
|
61
|
-
|
|
62
57
|
/**
|
|
63
58
|
* Whether to use the context-sensitive indentation that the mode provides
|
|
64
59
|
* (or just indent the same as the line before).
|
|
@@ -83,7 +78,6 @@ export interface LibroOpensumiEditorConfig extends IEditorConfig {
|
|
|
83
78
|
* Can be used to specify extra keybindings for the editor, alongside the
|
|
84
79
|
* ones defined by keyMap. Should be either null, or a valid keymap value.
|
|
85
80
|
*/
|
|
86
|
-
// extraKeys?: KeyBinding[] | null;
|
|
87
81
|
|
|
88
82
|
/**
|
|
89
83
|
* Can be used to add extra gutters (beyond or instead of the line number
|
|
@@ -193,7 +187,6 @@ export const libroOpensumiEditorDefaultConfig: Required<LibroOpensumiEditorConfi
|
|
|
193
187
|
smartIndent: true,
|
|
194
188
|
electricChars: true,
|
|
195
189
|
keyMap: 'default',
|
|
196
|
-
// extraKeys: null,
|
|
197
190
|
gutters: [],
|
|
198
191
|
fixedGutter: true,
|
|
199
192
|
showCursorWhenSelecting: false,
|
|
@@ -330,11 +323,12 @@ export class LibroOpensumiEditor implements IEditor {
|
|
|
330
323
|
this._model = options.model;
|
|
331
324
|
|
|
332
325
|
const config = options.config || {};
|
|
333
|
-
const fullConfig =
|
|
326
|
+
const fullConfig = {
|
|
334
327
|
...libroOpensumiEditorDefaultConfig,
|
|
335
328
|
...config,
|
|
336
329
|
mimetype: options.model.mimeType,
|
|
337
|
-
}
|
|
330
|
+
};
|
|
331
|
+
this._config = fullConfig;
|
|
338
332
|
|
|
339
333
|
this.completionProvider = options.completionProvider;
|
|
340
334
|
this.tooltipProvider = options.tooltipProvider;
|
|
@@ -350,9 +344,7 @@ export class LibroOpensumiEditor implements IEditor {
|
|
|
350
344
|
this.onCursorActivity();
|
|
351
345
|
|
|
352
346
|
this.toDispose.push(watch(this._model, 'mimeType', this.onMimeTypeChanged));
|
|
353
|
-
// this.toDispose.push(watch(this._model, 'value', this.onValueChange));
|
|
354
347
|
this.toDispose.push(watch(this._model, 'selections', this.onSelectionChange));
|
|
355
|
-
// this.toDispose.push(this.themeService.onDidColorThemeChange(this.onThemeChange));
|
|
356
348
|
}
|
|
357
349
|
|
|
358
350
|
get theme(): string {
|
|
@@ -366,58 +358,20 @@ export class LibroOpensumiEditor implements IEditor {
|
|
|
366
358
|
enabled: false,
|
|
367
359
|
},
|
|
368
360
|
lineHeight: editorConfig.lineHeight ?? this.defaultLineHeight,
|
|
369
|
-
// fontSize: editorConfig.fontSize ?? 13,
|
|
370
361
|
lineNumbers: editorConfig.lineNumbers ? 'on' : 'off',
|
|
371
|
-
// folding: editorConfig.codeFolding,
|
|
372
362
|
wordWrap: editorConfig.lineWrap,
|
|
373
363
|
renderLineHighlightOnlyWhenFocus: true,
|
|
374
|
-
// lineDecorationsWidth: 15,
|
|
375
|
-
// lineNumbersMinChars: 3,
|
|
376
|
-
// suggestSelection: 'first',
|
|
377
|
-
// wordBasedSuggestions: 'off',
|
|
378
|
-
// lineDecorationsWidth: 15,
|
|
379
|
-
// lineNumbersMinChars: 3,
|
|
380
|
-
// suggestSelection: 'first',
|
|
381
|
-
// wordBasedSuggestions: 'off',
|
|
382
364
|
scrollBeyondLastLine: false,
|
|
383
|
-
// overflowWidgetsDomNode: document.getElementById('monaco-editor-overflow-widgets-root')!,
|
|
384
365
|
fixedOverflowWidgets: true,
|
|
385
|
-
// suggest: { snippetsPreventQuickSuggestions: false },
|
|
386
|
-
// autoClosingQuotes: editorConfig.autoClosingBrackets ? 'always' : 'never',
|
|
387
|
-
// autoDetectHighContrast: false,
|
|
388
|
-
// suggest: { snippetsPreventQuickSuggestions: false },
|
|
389
|
-
// autoClosingQuotes: editorConfig.autoClosingBrackets ? 'always' : 'never',
|
|
390
|
-
// autoDetectHighContrast: false,
|
|
391
366
|
scrollbar: {
|
|
392
367
|
alwaysConsumeMouseWheel: false,
|
|
393
368
|
verticalScrollbarSize: 0,
|
|
394
369
|
},
|
|
395
370
|
glyphMargin: false,
|
|
396
371
|
extraEditorClassName: OpensumiEditorClassname,
|
|
397
|
-
// renderLineHighlight: 'all',
|
|
398
|
-
// renderLineHighlightOnlyWhenFocus: true,
|
|
399
|
-
// renderLineHighlight: 'all',
|
|
400
|
-
// renderLineHighlightOnlyWhenFocus: true,
|
|
401
372
|
readOnly: editorConfig.readOnly,
|
|
402
|
-
// cursorWidth: 1,
|
|
403
|
-
// tabSize: editorConfig.tabSize,
|
|
404
|
-
// insertSpaces: editorConfig.insertSpaces,
|
|
405
|
-
// matchBrackets: editorConfig.matchBrackets ? 'always' : 'never',
|
|
406
|
-
// rulers: editorConfig.rulers,
|
|
407
|
-
// wordWrapColumn: editorConfig.wordWrapColumn,
|
|
408
|
-
// 'semanticHighlighting.enabled': true,
|
|
409
|
-
// cursorWidth: 1,
|
|
410
|
-
// tabSize: editorConfig.tabSize,
|
|
411
|
-
// insertSpaces: editorConfig.insertSpaces,
|
|
412
|
-
// matchBrackets: editorConfig.matchBrackets ? 'always' : 'never',
|
|
413
|
-
// rulers: editorConfig.rulers,
|
|
414
|
-
// wordWrapColumn: editorConfig.wordWrapColumn,
|
|
415
|
-
// 'semanticHighlighting.enabled': true,
|
|
416
373
|
maxTokenizationLineLength: 10000,
|
|
417
374
|
wrappingStrategy: 'advanced',
|
|
418
|
-
// hover: {
|
|
419
|
-
// enabled: true,
|
|
420
|
-
// },
|
|
421
375
|
};
|
|
422
376
|
}
|
|
423
377
|
|
|
@@ -531,42 +485,23 @@ export class LibroOpensumiEditor implements IEditor {
|
|
|
531
485
|
}
|
|
532
486
|
}
|
|
533
487
|
|
|
534
|
-
protected onValueChange() {
|
|
535
|
-
// this.editor?.codeEditor.setValue(this.model.value);
|
|
536
|
-
}
|
|
488
|
+
protected onValueChange() {}
|
|
537
489
|
|
|
538
490
|
protected onSelectionChange() {
|
|
539
491
|
this.setSelections(this.model.selections);
|
|
540
492
|
}
|
|
541
493
|
|
|
542
|
-
// protected onThemeChange = () => {
|
|
543
|
-
// this.monacoEditor?.updateOptions({ theme: this.theme });
|
|
544
|
-
// };
|
|
545
|
-
|
|
546
494
|
/**
|
|
547
495
|
* Handles a mime type change.
|
|
548
496
|
* 切换语言
|
|
549
497
|
* cell 切换没走这里
|
|
550
498
|
*/
|
|
551
|
-
protected onMimeTypeChanged(): void {
|
|
552
|
-
// const model = this.monacoEditor?.getModel();
|
|
553
|
-
// model?.setLanguage('')
|
|
554
|
-
// if (this.languageSpec && model) {
|
|
555
|
-
// editor.setModelLanguage(model, this.languageSpec.language);
|
|
556
|
-
// }
|
|
557
|
-
}
|
|
499
|
+
protected onMimeTypeChanged(): void {}
|
|
558
500
|
|
|
559
501
|
/**
|
|
560
502
|
* Handles a cursor activity event.
|
|
561
503
|
*/
|
|
562
|
-
protected onCursorActivity(): void {
|
|
563
|
-
// Only add selections if the editor has focus. This avoids unwanted
|
|
564
|
-
// triggering of cursor activity due to collaborator actions.
|
|
565
|
-
if (this.hasFocus()) {
|
|
566
|
-
// const selections = this.getSelections();
|
|
567
|
-
// this.model.selections = selections;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
504
|
+
protected onCursorActivity(): void {}
|
|
570
505
|
|
|
571
506
|
getOption<K extends keyof LibroOpensumiEditorConfig>(option: K) {
|
|
572
507
|
return this._config[option];
|
|
@@ -582,20 +517,6 @@ export class LibroOpensumiEditor implements IEditor {
|
|
|
582
517
|
return;
|
|
583
518
|
}
|
|
584
519
|
|
|
585
|
-
// if (option === 'theme') {
|
|
586
|
-
// this._config.theme = value as NonNullable<LibroE2EditorConfig['theme']>;
|
|
587
|
-
// this.monacoEditor?.updateOptions({
|
|
588
|
-
// theme: this.theme,
|
|
589
|
-
// });
|
|
590
|
-
// }
|
|
591
|
-
|
|
592
|
-
// if (option === 'placeholder') {
|
|
593
|
-
// this._config.placeholder = value as NonNullable<
|
|
594
|
-
// LibroE2EditorConfig['placeholder']
|
|
595
|
-
// >;
|
|
596
|
-
// this.placeholder.update(value as NonNullable<LibroE2EditorConfig['placeholder']>);
|
|
597
|
-
// }
|
|
598
|
-
|
|
599
520
|
const sizeKeys = ['fontFamily', 'fontSize', 'lineHeight', 'wordWrapColumn', 'lineWrap'];
|
|
600
521
|
const monacoOptionkeys = sizeKeys.concat(['readOnly', 'insertSpaces', 'tabSize']);
|
|
601
522
|
|
|
@@ -632,8 +553,7 @@ export class LibroOpensumiEditor implements IEditor {
|
|
|
632
553
|
resizeToFit = () => {
|
|
633
554
|
this.monacoEditor?.layout();
|
|
634
555
|
};
|
|
635
|
-
|
|
636
|
-
getPositionForCoordinate = (coordinate: ICoordinate) => null;
|
|
556
|
+
getPositionForCoordinate = () => null;
|
|
637
557
|
|
|
638
558
|
protected modalChangeEmitter = new Emitter<boolean>();
|
|
639
559
|
get onModalChange() {
|
|
@@ -771,7 +691,6 @@ export class LibroOpensumiEditor implements IEditor {
|
|
|
771
691
|
return {
|
|
772
692
|
range: item,
|
|
773
693
|
options: {
|
|
774
|
-
className: 'currentFindMatch', // 当前高亮
|
|
775
694
|
description: '',
|
|
776
695
|
},
|
|
777
696
|
};
|
|
@@ -779,7 +698,6 @@ export class LibroOpensumiEditor implements IEditor {
|
|
|
779
698
|
return {
|
|
780
699
|
range: item,
|
|
781
700
|
options: {
|
|
782
|
-
className: 'findMatch', // 匹配高亮
|
|
783
701
|
description: '',
|
|
784
702
|
},
|
|
785
703
|
};
|
|
@@ -16,7 +16,7 @@ import { LIBRO_COMPONENTS_SCHEME_ID } from './libro.protocol';
|
|
|
16
16
|
import { ManaContainer } from './mana';
|
|
17
17
|
|
|
18
18
|
@Domain(ClientAppContribution)
|
|
19
|
-
export class
|
|
19
|
+
export class LibroKeybindContribution implements ClientAppContribution {
|
|
20
20
|
@Autowired(IContextKeyService) contextKeyService: IContextKeyService;
|
|
21
21
|
@Autowired(KeybindingRegistry) keybindingRegistry: KeybindingRegistry;
|
|
22
22
|
@Autowired(WorkbenchEditorService)
|
|
@@ -113,7 +113,7 @@ export class LibroKeybindContribition implements ClientAppContribution {
|
|
|
113
113
|
{
|
|
114
114
|
keybinding: 'esc',
|
|
115
115
|
command: NotebookCommands['EnterCommandMode'].id,
|
|
116
|
-
when: 'libroNotebookFocused && !editorHasSelection && !
|
|
116
|
+
when: 'libroNotebookFocused && !editorHasSelection && !editorHasMultipleSelections',
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
keybinding: 'ctrlcmd+enter',
|
|
@@ -3,7 +3,7 @@ import { CellUri, EditorCellView, ExecutableNotebookModel } from '@difizen/libro
|
|
|
3
3
|
|
|
4
4
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
5
5
|
import { IOpener, IPosition, IRange, URI } from '@opensumi/ide-core-browser';
|
|
6
|
-
import { Schemes } from '@opensumi/ide-core-common';
|
|
6
|
+
import { ILogger, Schemes } from '@opensumi/ide-core-common';
|
|
7
7
|
|
|
8
8
|
import { LibroOpensumiService } from './libro.service';
|
|
9
9
|
|
|
@@ -33,11 +33,9 @@ export const toMonacoPosition = (position: IPosition | undefined): LibroPosition
|
|
|
33
33
|
|
|
34
34
|
@Injectable()
|
|
35
35
|
export class LibroOpener implements IOpener {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
@Autowired(ILogger)
|
|
37
|
+
private readonly logger: ILogger;
|
|
38
38
|
|
|
39
|
-
// @Autowired(WorkbenchEditorService)
|
|
40
|
-
// workbenchEditorService: WorkbenchEditorService;
|
|
41
39
|
@Autowired(LibroOpensumiService)
|
|
42
40
|
libroOpensumiService: LibroOpensumiService;
|
|
43
41
|
|
|
@@ -62,7 +60,7 @@ export class LibroOpener implements IOpener {
|
|
|
62
60
|
|
|
63
61
|
protected async openCell(uri: URI, range?: IRange) {
|
|
64
62
|
const notebookUri = URI.file(uri.path.toString());
|
|
65
|
-
const libroView = await this.libroOpensumiService.
|
|
63
|
+
const libroView = await this.libroOpensumiService.getOrCreateLibroView(notebookUri);
|
|
66
64
|
|
|
67
65
|
if (!libroView) {
|
|
68
66
|
return false;
|
|
@@ -81,11 +79,18 @@ export class LibroOpener implements IOpener {
|
|
|
81
79
|
libroView.selectCell(cell);
|
|
82
80
|
let line = 0;
|
|
83
81
|
if (range) {
|
|
84
|
-
cell.editor
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
const editor = cell.editor;
|
|
83
|
+
if (!editor) {
|
|
84
|
+
this.logger.error('Editor not available for cell');
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
editor.focus();
|
|
88
|
+
editor.revealSelection(toEditorRange(range));
|
|
89
|
+
editor.setCursorPosition(toEditorRange(range).start);
|
|
90
|
+
|
|
87
91
|
line = toEditorRange(range).start.line;
|
|
88
92
|
}
|
|
93
|
+
// TODO: 优化Libro的滚动API
|
|
89
94
|
libroView.model.scrollToView(cell, (line ?? 0) * 20);
|
|
90
95
|
}
|
|
91
96
|
|
|
@@ -3,6 +3,7 @@ import { Container } from '@difizen/mana-app';
|
|
|
3
3
|
|
|
4
4
|
import { Autowired } from '@opensumi/di';
|
|
5
5
|
import { CommandContribution, CommandRegistry, Domain, EDITOR_COMMANDS } from '@opensumi/ide-core-browser';
|
|
6
|
+
import { MARKER_CONTAINER_ID } from '@opensumi/ide-core-browser/lib/common/container-id';
|
|
6
7
|
|
|
7
8
|
import { ManaContainer } from './mana';
|
|
8
9
|
|
|
@@ -43,7 +44,7 @@ export class LibroCommandContribution implements CommandContribution {
|
|
|
43
44
|
return false;
|
|
44
45
|
},
|
|
45
46
|
});
|
|
46
|
-
commands.registerHandler(
|
|
47
|
+
commands.registerHandler(MARKER_CONTAINER_ID, {
|
|
47
48
|
execute: () => {
|
|
48
49
|
const libroService = this.manaContainer.get(LibroService);
|
|
49
50
|
const libro = libroService.active;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ISettings,
|
|
3
|
+
LibroJupyterNoEditorModule,
|
|
4
|
+
ServerConnection,
|
|
5
|
+
ServerManager,
|
|
6
|
+
} from '@difizen/libro-jupyter/noeditor';
|
|
2
7
|
import { LibroTOCModule } from '@difizen/libro-toc';
|
|
3
8
|
import { Container, ManaAppPreset, ManaComponents, ThemeService } from '@difizen/mana-app';
|
|
4
9
|
import React, { useState } from 'react';
|
|
@@ -10,6 +15,7 @@ import {
|
|
|
10
15
|
ClientAppContribution,
|
|
11
16
|
CommandContribution,
|
|
12
17
|
type CommandRegistry,
|
|
18
|
+
Disposable,
|
|
13
19
|
Domain,
|
|
14
20
|
IClientApp,
|
|
15
21
|
IOpenerService,
|
|
@@ -17,9 +23,11 @@ import {
|
|
|
17
23
|
Schemes,
|
|
18
24
|
URI,
|
|
19
25
|
} from '@opensumi/ide-core-browser';
|
|
26
|
+
import { message } from '@opensumi/ide-core-browser/lib/components';
|
|
20
27
|
import {
|
|
21
28
|
BrowserEditorContribution,
|
|
22
29
|
EditorComponentRegistry,
|
|
30
|
+
INotebookService,
|
|
23
31
|
IResource,
|
|
24
32
|
ResourceService,
|
|
25
33
|
WorkbenchEditorService,
|
|
@@ -36,6 +44,7 @@ import { LIBRO_COMPONENTS_ID, LIBRO_COMPONENTS_SCHEME_ID } from './libro.protoco
|
|
|
36
44
|
import { OpensumiLibroView } from './libro.view';
|
|
37
45
|
import { ManaContainer, initLibroOpensumi, manaContainer } from './mana/index';
|
|
38
46
|
import { NotebookDocumentContentProvider } from './notebook-document-content-provider';
|
|
47
|
+
import { NotebookServiceOverride } from './notebook.service';
|
|
39
48
|
import { initTocPanelColorToken } from './toc';
|
|
40
49
|
|
|
41
50
|
const LIBRO_COMPONENTS_VIEW_COMMAND = {
|
|
@@ -64,6 +73,7 @@ const LayoutWrapper: React.FC<React.PropsWithChildren> = ({ children }) => {
|
|
|
64
73
|
OpenerContribution,
|
|
65
74
|
)
|
|
66
75
|
export class LibroContribution
|
|
76
|
+
extends Disposable
|
|
67
77
|
implements
|
|
68
78
|
ClientAppContribution,
|
|
69
79
|
BrowserEditorContribution,
|
|
@@ -83,6 +93,9 @@ export class LibroContribution
|
|
|
83
93
|
@Autowired(IThemeService)
|
|
84
94
|
protected readonly themeService: IThemeService;
|
|
85
95
|
|
|
96
|
+
@Autowired(INotebookService)
|
|
97
|
+
protected readonly notebookService: NotebookServiceOverride;
|
|
98
|
+
|
|
86
99
|
@Autowired(NotebookDocumentContentProvider)
|
|
87
100
|
protected readonly notebookDocumentContentProvider: NotebookDocumentContentProvider;
|
|
88
101
|
|
|
@@ -136,7 +149,7 @@ export class LibroContribution
|
|
|
136
149
|
if (!this.serverManagerInited && this.config.notebookServerHost) {
|
|
137
150
|
this.serverManagerInited = true;
|
|
138
151
|
// 目前直接从浏览器连接 jupyter 服务,对服务的cors等配置会有要求
|
|
139
|
-
this.connectJupyterServer(this.config.notebookServerHost);
|
|
152
|
+
this.connectJupyterServer(this.config.notebookServerHost).catch((err) => message.error(err.message));
|
|
140
153
|
}
|
|
141
154
|
results.push({
|
|
142
155
|
type: 'component',
|
|
@@ -169,21 +182,35 @@ export class LibroContribution
|
|
|
169
182
|
}
|
|
170
183
|
|
|
171
184
|
async onDidStart() {
|
|
185
|
+
this.addDispose(this.notebookService.listenLibro());
|
|
186
|
+
this.addDispose(this.notebookService.listenEditor());
|
|
187
|
+
|
|
172
188
|
const manaThemeService = this.manaContainer.get(ThemeService);
|
|
173
189
|
const curTheme = await this.themeService.getCurrentTheme();
|
|
174
190
|
manaThemeService.setCurrentTheme(curTheme.type);
|
|
175
|
-
this.
|
|
176
|
-
|
|
177
|
-
|
|
191
|
+
this.addDispose(
|
|
192
|
+
this.themeService.onThemeChange((theme) => {
|
|
193
|
+
manaThemeService.setCurrentTheme(theme.type);
|
|
194
|
+
}),
|
|
195
|
+
);
|
|
178
196
|
}
|
|
179
197
|
|
|
180
|
-
protected connectJupyterServer(serverHost: string) {
|
|
198
|
+
protected async connectJupyterServer(serverHost: string) {
|
|
181
199
|
const libroServerConnection = this.manaContainer.get(ServerConnection);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
200
|
+
const token = this.config.notebookServerToken;
|
|
201
|
+
const setting: Partial<ISettings> =
|
|
202
|
+
window.location.protocol === 'https:'
|
|
203
|
+
? {
|
|
204
|
+
baseUrl: `https://${serverHost}/`,
|
|
205
|
+
wsUrl: `wss://${serverHost}/`,
|
|
206
|
+
}
|
|
207
|
+
: {
|
|
208
|
+
baseUrl: `http://${serverHost}/`,
|
|
209
|
+
wsUrl: `ws://${serverHost}/`,
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
libroServerConnection.updateSettings({ ...setting, token });
|
|
186
213
|
const serverManager = this.manaContainer.get(ServerManager);
|
|
187
|
-
serverManager.launch();
|
|
214
|
+
await serverManager.launch();
|
|
188
215
|
}
|
|
189
216
|
}
|
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
import { CellUri, CellView, LanguageSpecRegistry, LibroService, LibroView } from '@difizen/libro-jupyter/noeditor';
|
|
2
2
|
import { Container, URI as ManaURI, getOrigin } from '@difizen/mana-app';
|
|
3
|
-
import { makeObservable } from 'mobx';
|
|
4
3
|
|
|
5
4
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
6
5
|
import { URI, WithEventBus, path } from '@opensumi/ide-core-browser';
|
|
7
6
|
import { ResourceDecorationNeedChangeEvent, WorkbenchEditorService } from '@opensumi/ide-editor';
|
|
8
7
|
|
|
9
|
-
import { LibroTracker } from './libro.view.tracker';
|
|
10
8
|
import { ContentLoaderType, ManaContainer } from './mana';
|
|
11
9
|
|
|
12
10
|
export const ILibroOpensumiService = Symbol('ILibroOpensumiService');
|
|
13
11
|
|
|
14
12
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
15
13
|
export interface ILibroOpensumiService {
|
|
16
|
-
|
|
17
|
-
libroTrackerMap: Map<string, LibroTracker>;
|
|
18
|
-
// editorService: WorkbenchEditorService;
|
|
19
|
-
getOrCreatLibroView: (uri: URI) => Promise<LibroView>;
|
|
14
|
+
getOrCreateLibroView: (uri: URI) => Promise<LibroView>;
|
|
20
15
|
updateDirtyStatus: (uri: URI, dirty: boolean) => void;
|
|
21
16
|
getCellViewByUri: (uri: URI) => Promise<CellView | undefined>;
|
|
22
|
-
|
|
17
|
+
getCellLanguage: (cell: CellView) => string | undefined;
|
|
23
18
|
}
|
|
24
19
|
|
|
25
20
|
@Injectable()
|
|
@@ -30,17 +25,12 @@ export class LibroOpensumiService extends WithEventBus implements ILibroOpensumi
|
|
|
30
25
|
@Autowired(WorkbenchEditorService)
|
|
31
26
|
protected readonly editorService: WorkbenchEditorService;
|
|
32
27
|
|
|
33
|
-
constructor() {
|
|
34
|
-
super();
|
|
35
|
-
makeObservable(this);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
28
|
get libroService() {
|
|
39
29
|
const libroService = this.manaContainer.get(LibroService);
|
|
40
30
|
return libroService;
|
|
41
31
|
}
|
|
42
32
|
|
|
43
|
-
|
|
33
|
+
getOrCreateLibroView = async (uri: URI) => {
|
|
44
34
|
const libroOption = {
|
|
45
35
|
modelId: uri.toString(),
|
|
46
36
|
resource: uri.toString(),
|
|
@@ -65,7 +55,7 @@ export class LibroOpensumiService extends WithEventBus implements ILibroOpensumi
|
|
|
65
55
|
return libroView?.model.cells.find((cell) => cell.model.id === cellId);
|
|
66
56
|
};
|
|
67
57
|
|
|
68
|
-
|
|
58
|
+
getCellLanguage = (cell: CellView) => {
|
|
69
59
|
const languageSpecRegistry = this.manaContainer.get(LanguageSpecRegistry);
|
|
70
60
|
return getOrigin(languageSpecRegistry.languageSpecs).find((item) => item.mime === cell.model.mimeType)?.language;
|
|
71
61
|
};
|
|
@@ -80,6 +70,4 @@ export class LibroOpensumiService extends WithEventBus implements ILibroOpensumi
|
|
|
80
70
|
}),
|
|
81
71
|
);
|
|
82
72
|
}
|
|
83
|
-
|
|
84
|
-
libroTrackerMap: Map<string, LibroTracker> = new Map();
|
|
85
73
|
}
|
|
@@ -1,40 +1,30 @@
|
|
|
1
|
-
|
|
2
1
|
import { DocumentCommands, LibroView } from '@difizen/libro-jupyter/noeditor';
|
|
3
|
-
import { CommandRegistry, Container, ViewRender } from '@difizen/mana-app';
|
|
2
|
+
import { CommandRegistry, Container, Disposable, ViewRender } from '@difizen/mana-app';
|
|
4
3
|
import * as React from 'react';
|
|
5
4
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { message } from '@opensumi/ide-components';
|
|
6
|
+
import { localize, useInjectable } from '@opensumi/ide-core-browser';
|
|
8
7
|
import { ReactEditorComponent } from '@opensumi/ide-editor/lib/browser/types';
|
|
9
8
|
|
|
10
9
|
import styles from './libro.module.less';
|
|
11
10
|
import { ILibroOpensumiService } from './libro.service';
|
|
12
|
-
import { LibroTracker } from './libro.view.tracker';
|
|
13
11
|
import { ManaContainer } from './mana';
|
|
14
12
|
|
|
13
|
+
const AUTO_SAVE_DELAY = 1000; // ms
|
|
14
|
+
|
|
15
15
|
export const OpensumiLibroView: ReactEditorComponent = (...params) => {
|
|
16
16
|
const libroOpensumiService = useInjectable<ILibroOpensumiService>(ILibroOpensumiService);
|
|
17
17
|
const manaContainer = useInjectable<Container>(ManaContainer);
|
|
18
18
|
const commandRegistry = manaContainer.get(CommandRegistry);
|
|
19
|
-
const injector: Injector = useInjectable(INJECTOR_TOKEN);
|
|
20
|
-
|
|
21
|
-
const [libroTracker, setLibroTracker] = React.useState<LibroTracker>();
|
|
22
19
|
|
|
23
20
|
const [libroView, setLibroView] = React.useState<LibroView | undefined>(undefined);
|
|
24
21
|
|
|
25
22
|
React.useEffect(() => {
|
|
26
|
-
if (libroTracker?.refreshTimer) {
|
|
27
|
-
libroView?.dispose();
|
|
28
|
-
}
|
|
29
23
|
let autoSaveHandle: undefined | number;
|
|
30
|
-
|
|
24
|
+
let modelChangeDisposer: undefined | Disposable;
|
|
25
|
+
libroOpensumiService.getOrCreateLibroView(params[0].resource.uri).then((libro) => {
|
|
31
26
|
setLibroView(libro);
|
|
32
|
-
|
|
33
|
-
const tracker = injector.get(LibroTracker);
|
|
34
|
-
setLibroTracker(tracker);
|
|
35
|
-
libroOpensumiService.libroTrackerMap.set((params[0].resource.uri as URI).toString(), tracker);
|
|
36
|
-
}
|
|
37
|
-
libro.model.onChanged(() => {
|
|
27
|
+
modelChangeDisposer = libro.model.onChanged(() => {
|
|
38
28
|
libroOpensumiService.updateDirtyStatus(params[0].resource.uri, true);
|
|
39
29
|
if (autoSaveHandle) {
|
|
40
30
|
window.clearTimeout(autoSaveHandle);
|
|
@@ -46,17 +36,21 @@ export const OpensumiLibroView: ReactEditorComponent = (...params) => {
|
|
|
46
36
|
if (libro) {
|
|
47
37
|
libro.model.dirty = false;
|
|
48
38
|
}
|
|
39
|
+
})
|
|
40
|
+
.catch((error) => {
|
|
41
|
+
message.error(localize('doc.saveError.failed'), error);
|
|
49
42
|
});
|
|
50
|
-
},
|
|
43
|
+
}, AUTO_SAVE_DELAY);
|
|
51
44
|
});
|
|
52
45
|
libro.onSave(() => {
|
|
53
46
|
libroOpensumiService.updateDirtyStatus(params[0].resource.uri, false);
|
|
54
47
|
});
|
|
55
48
|
});
|
|
56
49
|
return () => {
|
|
50
|
+
modelChangeDisposer?.dispose();
|
|
57
51
|
window.clearTimeout(autoSaveHandle);
|
|
58
52
|
};
|
|
59
|
-
}, [
|
|
53
|
+
}, []);
|
|
60
54
|
|
|
61
55
|
return <div className={styles.libroView}>{libroView && <ViewRender view={libroView}></ViewRender>}</div>;
|
|
62
56
|
};
|