@theia/notebook 1.53.0-next.5 → 1.53.0-next.55

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.
Files changed (88) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/contributions/notebook-actions-contribution.d.ts +1 -0
  3. package/lib/browser/contributions/notebook-actions-contribution.d.ts.map +1 -1
  4. package/lib/browser/contributions/notebook-actions-contribution.js +31 -5
  5. package/lib/browser/contributions/notebook-actions-contribution.js.map +1 -1
  6. package/lib/browser/contributions/notebook-cell-actions-contribution.d.ts +2 -0
  7. package/lib/browser/contributions/notebook-cell-actions-contribution.d.ts.map +1 -1
  8. package/lib/browser/contributions/notebook-cell-actions-contribution.js +41 -7
  9. package/lib/browser/contributions/notebook-cell-actions-contribution.js.map +1 -1
  10. package/lib/browser/contributions/notebook-status-bar-contribution.d.ts +14 -0
  11. package/lib/browser/contributions/notebook-status-bar-contribution.d.ts.map +1 -0
  12. package/lib/browser/contributions/notebook-status-bar-contribution.js +75 -0
  13. package/lib/browser/contributions/notebook-status-bar-contribution.js.map +1 -0
  14. package/lib/browser/notebook-editor-widget.d.ts.map +1 -1
  15. package/lib/browser/notebook-editor-widget.js +3 -5
  16. package/lib/browser/notebook-editor-widget.js.map +1 -1
  17. package/lib/browser/notebook-frontend-module.d.ts.map +1 -1
  18. package/lib/browser/notebook-frontend-module.js +3 -0
  19. package/lib/browser/notebook-frontend-module.js.map +1 -1
  20. package/lib/browser/notebook-open-handler.d.ts +3 -2
  21. package/lib/browser/notebook-open-handler.d.ts.map +1 -1
  22. package/lib/browser/notebook-open-handler.js +12 -5
  23. package/lib/browser/notebook-open-handler.js.map +1 -1
  24. package/lib/browser/view/notebook-cell-editor.d.ts +1 -0
  25. package/lib/browser/view/notebook-cell-editor.d.ts.map +1 -1
  26. package/lib/browser/view/notebook-cell-editor.js +30 -16
  27. package/lib/browser/view/notebook-cell-editor.js.map +1 -1
  28. package/lib/browser/view/notebook-cell-list-view.d.ts +6 -4
  29. package/lib/browser/view/notebook-cell-list-view.d.ts.map +1 -1
  30. package/lib/browser/view/notebook-cell-list-view.js +20 -13
  31. package/lib/browser/view/notebook-cell-list-view.js.map +1 -1
  32. package/lib/browser/view-model/notebook-cell-model.d.ts +3 -0
  33. package/lib/browser/view-model/notebook-cell-model.d.ts.map +1 -1
  34. package/lib/browser/view-model/notebook-cell-model.js +5 -0
  35. package/lib/browser/view-model/notebook-cell-model.js.map +1 -1
  36. package/package.json +8 -8
  37. package/src/browser/contributions/cell-operations.ts +44 -44
  38. package/src/browser/contributions/notebook-actions-contribution.ts +379 -350
  39. package/src/browser/contributions/notebook-cell-actions-contribution.ts +525 -487
  40. package/src/browser/contributions/notebook-color-contribution.ts +268 -268
  41. package/src/browser/contributions/notebook-context-keys.ts +113 -113
  42. package/src/browser/contributions/notebook-label-provider-contribution.ts +85 -85
  43. package/src/browser/contributions/notebook-outline-contribution.ts +114 -114
  44. package/src/browser/contributions/notebook-output-action-contribution.ts +82 -82
  45. package/src/browser/contributions/notebook-preferences.ts +92 -92
  46. package/src/browser/contributions/notebook-status-bar-contribution.ts +77 -0
  47. package/src/browser/contributions/notebook-undo-redo-handler.ts +41 -41
  48. package/src/browser/index.ts +27 -27
  49. package/src/browser/notebook-cell-resource-resolver.ts +130 -130
  50. package/src/browser/notebook-editor-widget-factory.ts +82 -82
  51. package/src/browser/notebook-editor-widget.tsx +330 -331
  52. package/src/browser/notebook-frontend-module.ts +119 -115
  53. package/src/browser/notebook-open-handler.ts +120 -114
  54. package/src/browser/notebook-output-utils.ts +119 -119
  55. package/src/browser/notebook-renderer-registry.ts +85 -85
  56. package/src/browser/notebook-type-registry.ts +54 -54
  57. package/src/browser/notebook-types.ts +186 -186
  58. package/src/browser/renderers/cell-output-webview.ts +33 -33
  59. package/src/browser/service/notebook-clipboard-service.ts +43 -43
  60. package/src/browser/service/notebook-context-manager.ts +162 -162
  61. package/src/browser/service/notebook-editor-widget-service.ts +101 -101
  62. package/src/browser/service/notebook-execution-service.ts +139 -139
  63. package/src/browser/service/notebook-execution-state-service.ts +311 -311
  64. package/src/browser/service/notebook-kernel-history-service.ts +124 -124
  65. package/src/browser/service/notebook-kernel-quick-pick-service.ts +479 -479
  66. package/src/browser/service/notebook-kernel-service.ts +357 -357
  67. package/src/browser/service/notebook-model-resolver-service.ts +160 -160
  68. package/src/browser/service/notebook-monaco-text-model-service.ts +48 -48
  69. package/src/browser/service/notebook-options.ts +155 -155
  70. package/src/browser/service/notebook-renderer-messaging-service.ts +121 -121
  71. package/src/browser/service/notebook-service.ts +215 -215
  72. package/src/browser/style/index.css +483 -471
  73. package/src/browser/view/notebook-cell-editor.tsx +263 -247
  74. package/src/browser/view/notebook-cell-list-view.tsx +279 -262
  75. package/src/browser/view/notebook-cell-toolbar-factory.tsx +102 -102
  76. package/src/browser/view/notebook-cell-toolbar.tsx +74 -74
  77. package/src/browser/view/notebook-code-cell-view.tsx +350 -350
  78. package/src/browser/view/notebook-find-widget.tsx +335 -335
  79. package/src/browser/view/notebook-main-toolbar.tsx +235 -235
  80. package/src/browser/view/notebook-markdown-cell-view.tsx +208 -208
  81. package/src/browser/view/notebook-viewport-service.ts +61 -61
  82. package/src/browser/view-model/notebook-cell-model.ts +473 -466
  83. package/src/browser/view-model/notebook-cell-output-model.ts +100 -100
  84. package/src/browser/view-model/notebook-model.ts +550 -550
  85. package/src/common/index.ts +18 -18
  86. package/src/common/notebook-common.ts +337 -337
  87. package/src/common/notebook-protocol.ts +35 -35
  88. package/src/common/notebook-range.ts +30 -30
@@ -1,113 +1,113 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
- /*---------------------------------------------------------------------------------------------
17
- * Copyright (c) Microsoft Corporation. All rights reserved.
18
- * Licensed under the MIT License. See License.txt in the project root for license information.
19
- *--------------------------------------------------------------------------------------------*/
20
-
21
- import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
22
-
23
- export type NotebookCellExecutionStateContext = 'idle' | 'pending' | 'executing' | 'succeeded' | 'failed';
24
-
25
- /**
26
- * Context Keys for the Notebook Editor as defined by vscode in https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts
27
- */
28
- export const HAS_OPENED_NOTEBOOK = 'userHasOpenedNotebook';
29
- export const KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED = 'notebookFindWidgetFocused';
30
- export const NOTEBOOK_EDITOR_FOCUSED = 'notebookEditorFocused';
31
- export const NOTEBOOK_CELL_LIST_FOCUSED = 'notebookCellListFocused';
32
- export const NOTEBOOK_OUTPUT_FOCUSED = 'notebookOutputFocused';
33
- export const NOTEBOOK_OUTPUT_INPUT_FOCUSED = 'notebookOutputInputFocused';
34
- export const NOTEBOOK_EDITOR_EDITABLE = 'notebookEditable';
35
- export const NOTEBOOK_HAS_RUNNING_CELL = 'notebookHasRunningCell';
36
- export const NOTEBOOK_USE_CONSOLIDATED_OUTPUT_BUTTON = 'notebookUseConsolidatedOutputButton';
37
- export const NOTEBOOK_BREAKPOINT_MARGIN_ACTIVE = 'notebookBreakpointMargin';
38
- export const NOTEBOOK_CELL_TOOLBAR_LOCATION = 'notebookCellToolbarLocation';
39
- export const NOTEBOOK_CURSOR_NAVIGATION_MODE = 'notebookCursorNavigationMode';
40
- export const NOTEBOOK_LAST_CELL_FAILED = 'notebookLastCellFailed';
41
- export const NOTEBOOK_VIEW_TYPE = 'notebookType';
42
- export const NOTEBOOK_CELL_TYPE = 'notebookCellType';
43
- export const NOTEBOOK_CELL_EDITABLE = 'notebookCellEditable';
44
- export const NOTEBOOK_CELL_FOCUSED = 'notebookCellFocused';
45
- export const NOTEBOOK_CELL_EDITOR_FOCUSED = 'notebookCellEditorFocused';
46
- export const NOTEBOOK_CELL_MARKDOWN_EDIT_MODE = 'notebookCellMarkdownEditMode';
47
- export const NOTEBOOK_CELL_LINE_NUMBERS = 'notebookCellLineNumbers';
48
- export const NOTEBOOK_CELL_EXECUTION_STATE = 'notebookCellExecutionState';
49
- export const NOTEBOOK_CELL_EXECUTING = 'notebookCellExecuting';
50
- export const NOTEBOOK_CELL_HAS_OUTPUTS = 'notebookCellHasOutputs';
51
- export const NOTEBOOK_CELL_INPUT_COLLAPSED = 'notebookCellInputIsCollapsed';
52
- export const NOTEBOOK_CELL_OUTPUT_COLLAPSED = 'notebookCellOutputIsCollapsed';
53
- export const NOTEBOOK_CELL_RESOURCE = 'notebookCellResource';
54
- export const NOTEBOOK_KERNEL = 'notebookKernel';
55
- export const NOTEBOOK_KERNEL_COUNT = 'notebookKernelCount';
56
- export const NOTEBOOK_KERNEL_SOURCE_COUNT = 'notebookKernelSourceCount';
57
- export const NOTEBOOK_KERNEL_SELECTED = 'notebookKernelSelected';
58
- export const NOTEBOOK_INTERRUPTIBLE_KERNEL = 'notebookInterruptibleKernel';
59
- export const NOTEBOOK_MISSING_KERNEL_EXTENSION = 'notebookMissingKernelExtension';
60
- export const NOTEBOOK_HAS_OUTPUTS = 'notebookHasOutputs';
61
-
62
- export const NOTEBOOK_CELL_CURSOR_FIRST_LINE = 'cellEditorCursorPositionFirstLine';
63
- export const NOTEBOOK_CELL_CURSOR_LAST_LINE = 'cellEditorCursorPositionLastLine';
64
-
65
- export namespace NotebookContextKeys {
66
- export function initNotebookContextKeys(service: ContextKeyService): void {
67
- service.createKey(HAS_OPENED_NOTEBOOK, false);
68
- service.createKey(KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED, false);
69
-
70
- // // Is Notebook
71
- // export const NOTEBOOK_IS_ACTIVE_EDITOR = ContextKeyExpr.equals('activeEditor', NOTEBOOK_EDITOR_ID);
72
- // export const INTERACTIVE_WINDOW_IS_ACTIVE_EDITOR = ContextKeyExpr.equals('activeEditor', INTERACTIVE_WINDOW_EDITOR_ID);
73
-
74
- // Editor keys
75
- service.createKey(NOTEBOOK_EDITOR_FOCUSED, false);
76
- service.createKey(NOTEBOOK_CELL_LIST_FOCUSED, false);
77
- service.createKey(NOTEBOOK_OUTPUT_FOCUSED, false);
78
- service.createKey(NOTEBOOK_OUTPUT_INPUT_FOCUSED, false);
79
- service.createKey(NOTEBOOK_EDITOR_EDITABLE, true);
80
- service.createKey(NOTEBOOK_HAS_RUNNING_CELL, false);
81
- service.createKey(NOTEBOOK_USE_CONSOLIDATED_OUTPUT_BUTTON, false);
82
- service.createKey(NOTEBOOK_BREAKPOINT_MARGIN_ACTIVE, false);
83
- service.createKey(NOTEBOOK_CELL_TOOLBAR_LOCATION, 'left');
84
- service.createKey(NOTEBOOK_CURSOR_NAVIGATION_MODE, false);
85
- service.createKey(NOTEBOOK_LAST_CELL_FAILED, false);
86
-
87
- // Cell keys
88
- service.createKey(NOTEBOOK_VIEW_TYPE, undefined);
89
- service.createKey(NOTEBOOK_CELL_TYPE, undefined);
90
- service.createKey(NOTEBOOK_CELL_EDITABLE, false);
91
- service.createKey(NOTEBOOK_CELL_FOCUSED, false);
92
- service.createKey(NOTEBOOK_CELL_EDITOR_FOCUSED, false);
93
- service.createKey(NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, false);
94
- service.createKey(NOTEBOOK_CELL_LINE_NUMBERS, 'inherit');
95
- service.createKey(NOTEBOOK_CELL_EXECUTION_STATE, undefined);
96
- service.createKey(NOTEBOOK_CELL_EXECUTING, false);
97
- service.createKey(NOTEBOOK_CELL_HAS_OUTPUTS, false);
98
- service.createKey(NOTEBOOK_CELL_INPUT_COLLAPSED, false);
99
- service.createKey(NOTEBOOK_CELL_OUTPUT_COLLAPSED, false);
100
- service.createKey(NOTEBOOK_CELL_RESOURCE, '');
101
- service.createKey(NOTEBOOK_CELL_CURSOR_FIRST_LINE, false);
102
- service.createKey(NOTEBOOK_CELL_CURSOR_LAST_LINE, false);
103
-
104
- // Kernels
105
- service.createKey(NOTEBOOK_KERNEL, undefined);
106
- service.createKey(NOTEBOOK_KERNEL_COUNT, 0);
107
- service.createKey(NOTEBOOK_KERNEL_SOURCE_COUNT, 0);
108
- service.createKey(NOTEBOOK_KERNEL_SELECTED, false);
109
- service.createKey(NOTEBOOK_INTERRUPTIBLE_KERNEL, false);
110
- service.createKey(NOTEBOOK_MISSING_KERNEL_EXTENSION, false);
111
- service.createKey(NOTEBOOK_HAS_OUTPUTS, false);
112
- }
113
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+ /*---------------------------------------------------------------------------------------------
17
+ * Copyright (c) Microsoft Corporation. All rights reserved.
18
+ * Licensed under the MIT License. See License.txt in the project root for license information.
19
+ *--------------------------------------------------------------------------------------------*/
20
+
21
+ import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
22
+
23
+ export type NotebookCellExecutionStateContext = 'idle' | 'pending' | 'executing' | 'succeeded' | 'failed';
24
+
25
+ /**
26
+ * Context Keys for the Notebook Editor as defined by vscode in https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts
27
+ */
28
+ export const HAS_OPENED_NOTEBOOK = 'userHasOpenedNotebook';
29
+ export const KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED = 'notebookFindWidgetFocused';
30
+ export const NOTEBOOK_EDITOR_FOCUSED = 'notebookEditorFocused';
31
+ export const NOTEBOOK_CELL_LIST_FOCUSED = 'notebookCellListFocused';
32
+ export const NOTEBOOK_OUTPUT_FOCUSED = 'notebookOutputFocused';
33
+ export const NOTEBOOK_OUTPUT_INPUT_FOCUSED = 'notebookOutputInputFocused';
34
+ export const NOTEBOOK_EDITOR_EDITABLE = 'notebookEditable';
35
+ export const NOTEBOOK_HAS_RUNNING_CELL = 'notebookHasRunningCell';
36
+ export const NOTEBOOK_USE_CONSOLIDATED_OUTPUT_BUTTON = 'notebookUseConsolidatedOutputButton';
37
+ export const NOTEBOOK_BREAKPOINT_MARGIN_ACTIVE = 'notebookBreakpointMargin';
38
+ export const NOTEBOOK_CELL_TOOLBAR_LOCATION = 'notebookCellToolbarLocation';
39
+ export const NOTEBOOK_CURSOR_NAVIGATION_MODE = 'notebookCursorNavigationMode';
40
+ export const NOTEBOOK_LAST_CELL_FAILED = 'notebookLastCellFailed';
41
+ export const NOTEBOOK_VIEW_TYPE = 'notebookType';
42
+ export const NOTEBOOK_CELL_TYPE = 'notebookCellType';
43
+ export const NOTEBOOK_CELL_EDITABLE = 'notebookCellEditable';
44
+ export const NOTEBOOK_CELL_FOCUSED = 'notebookCellFocused';
45
+ export const NOTEBOOK_CELL_EDITOR_FOCUSED = 'notebookCellEditorFocused';
46
+ export const NOTEBOOK_CELL_MARKDOWN_EDIT_MODE = 'notebookCellMarkdownEditMode';
47
+ export const NOTEBOOK_CELL_LINE_NUMBERS = 'notebookCellLineNumbers';
48
+ export const NOTEBOOK_CELL_EXECUTION_STATE = 'notebookCellExecutionState';
49
+ export const NOTEBOOK_CELL_EXECUTING = 'notebookCellExecuting';
50
+ export const NOTEBOOK_CELL_HAS_OUTPUTS = 'notebookCellHasOutputs';
51
+ export const NOTEBOOK_CELL_INPUT_COLLAPSED = 'notebookCellInputIsCollapsed';
52
+ export const NOTEBOOK_CELL_OUTPUT_COLLAPSED = 'notebookCellOutputIsCollapsed';
53
+ export const NOTEBOOK_CELL_RESOURCE = 'notebookCellResource';
54
+ export const NOTEBOOK_KERNEL = 'notebookKernel';
55
+ export const NOTEBOOK_KERNEL_COUNT = 'notebookKernelCount';
56
+ export const NOTEBOOK_KERNEL_SOURCE_COUNT = 'notebookKernelSourceCount';
57
+ export const NOTEBOOK_KERNEL_SELECTED = 'notebookKernelSelected';
58
+ export const NOTEBOOK_INTERRUPTIBLE_KERNEL = 'notebookInterruptibleKernel';
59
+ export const NOTEBOOK_MISSING_KERNEL_EXTENSION = 'notebookMissingKernelExtension';
60
+ export const NOTEBOOK_HAS_OUTPUTS = 'notebookHasOutputs';
61
+
62
+ export const NOTEBOOK_CELL_CURSOR_FIRST_LINE = 'cellEditorCursorPositionFirstLine';
63
+ export const NOTEBOOK_CELL_CURSOR_LAST_LINE = 'cellEditorCursorPositionLastLine';
64
+
65
+ export namespace NotebookContextKeys {
66
+ export function initNotebookContextKeys(service: ContextKeyService): void {
67
+ service.createKey(HAS_OPENED_NOTEBOOK, false);
68
+ service.createKey(KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED, false);
69
+
70
+ // // Is Notebook
71
+ // export const NOTEBOOK_IS_ACTIVE_EDITOR = ContextKeyExpr.equals('activeEditor', NOTEBOOK_EDITOR_ID);
72
+ // export const INTERACTIVE_WINDOW_IS_ACTIVE_EDITOR = ContextKeyExpr.equals('activeEditor', INTERACTIVE_WINDOW_EDITOR_ID);
73
+
74
+ // Editor keys
75
+ service.createKey(NOTEBOOK_EDITOR_FOCUSED, false);
76
+ service.createKey(NOTEBOOK_CELL_LIST_FOCUSED, false);
77
+ service.createKey(NOTEBOOK_OUTPUT_FOCUSED, false);
78
+ service.createKey(NOTEBOOK_OUTPUT_INPUT_FOCUSED, false);
79
+ service.createKey(NOTEBOOK_EDITOR_EDITABLE, true);
80
+ service.createKey(NOTEBOOK_HAS_RUNNING_CELL, false);
81
+ service.createKey(NOTEBOOK_USE_CONSOLIDATED_OUTPUT_BUTTON, false);
82
+ service.createKey(NOTEBOOK_BREAKPOINT_MARGIN_ACTIVE, false);
83
+ service.createKey(NOTEBOOK_CELL_TOOLBAR_LOCATION, 'left');
84
+ service.createKey(NOTEBOOK_CURSOR_NAVIGATION_MODE, false);
85
+ service.createKey(NOTEBOOK_LAST_CELL_FAILED, false);
86
+
87
+ // Cell keys
88
+ service.createKey(NOTEBOOK_VIEW_TYPE, undefined);
89
+ service.createKey(NOTEBOOK_CELL_TYPE, undefined);
90
+ service.createKey(NOTEBOOK_CELL_EDITABLE, false);
91
+ service.createKey(NOTEBOOK_CELL_FOCUSED, false);
92
+ service.createKey(NOTEBOOK_CELL_EDITOR_FOCUSED, false);
93
+ service.createKey(NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, false);
94
+ service.createKey(NOTEBOOK_CELL_LINE_NUMBERS, 'inherit');
95
+ service.createKey(NOTEBOOK_CELL_EXECUTION_STATE, undefined);
96
+ service.createKey(NOTEBOOK_CELL_EXECUTING, false);
97
+ service.createKey(NOTEBOOK_CELL_HAS_OUTPUTS, false);
98
+ service.createKey(NOTEBOOK_CELL_INPUT_COLLAPSED, false);
99
+ service.createKey(NOTEBOOK_CELL_OUTPUT_COLLAPSED, false);
100
+ service.createKey(NOTEBOOK_CELL_RESOURCE, '');
101
+ service.createKey(NOTEBOOK_CELL_CURSOR_FIRST_LINE, false);
102
+ service.createKey(NOTEBOOK_CELL_CURSOR_LAST_LINE, false);
103
+
104
+ // Kernels
105
+ service.createKey(NOTEBOOK_KERNEL, undefined);
106
+ service.createKey(NOTEBOOK_KERNEL_COUNT, 0);
107
+ service.createKey(NOTEBOOK_KERNEL_SOURCE_COUNT, 0);
108
+ service.createKey(NOTEBOOK_KERNEL_SELECTED, false);
109
+ service.createKey(NOTEBOOK_INTERRUPTIBLE_KERNEL, false);
110
+ service.createKey(NOTEBOOK_MISSING_KERNEL_EXTENSION, false);
111
+ service.createKey(NOTEBOOK_HAS_OUTPUTS, false);
112
+ }
113
+ }
@@ -1,85 +1,85 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2024 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { codicon, LabelProvider, LabelProviderContribution } from '@theia/core/lib/browser';
18
- import { inject, injectable } from '@theia/core/shared/inversify';
19
- import { CellKind, CellUri } from '../../common';
20
- import { NotebookService } from '../service/notebook-service';
21
- import { NotebookCellOutlineNode } from './notebook-outline-contribution';
22
- import type Token = require('markdown-it/lib/token');
23
- import markdownit = require('@theia/core/shared/markdown-it');
24
- import { NotebookCellModel } from '../view-model/notebook-cell-model';
25
- import { URI } from '@theia/core';
26
-
27
- @injectable()
28
- export class NotebookLabelProviderContribution implements LabelProviderContribution {
29
-
30
- @inject(NotebookService)
31
- protected readonly notebookService: NotebookService;
32
-
33
- @inject(LabelProvider)
34
- protected readonly labelProvider: LabelProvider;
35
-
36
- protected markdownIt = markdownit();
37
-
38
- canHandle(element: object): number {
39
- if (NotebookCellOutlineNode.is(element)) {
40
- return 200;
41
- }
42
- return 0;
43
- }
44
-
45
- getIcon(element: NotebookCellOutlineNode): string {
46
- const cell = this.findCellByUri(element.uri);
47
- if (cell) {
48
- return cell.cellKind === CellKind.Markup ? codicon('markdown') : codicon('code');
49
- }
50
- return '';
51
- }
52
-
53
- getName(element: NotebookCellOutlineNode): string {
54
- const cell = this.findCellByUri(element.uri);
55
- if (cell) {
56
- return cell.cellKind === CellKind.Code ?
57
- cell.text.split('\n')[0] :
58
- this.extractPlaintext(this.markdownIt.parse(cell.text.split('\n')[0], {}));
59
- }
60
- return '';
61
- }
62
-
63
- getLongName(element: NotebookCellOutlineNode): string {
64
- const cell = this.findCellByUri(element.uri);
65
- if (cell) {
66
- return cell.cellKind === CellKind.Code ?
67
- cell.text.split('\n')[0] :
68
- this.extractPlaintext(this.markdownIt.parse(cell.text.split('\n')[0], {}));
69
- }
70
- return '';
71
- }
72
-
73
- extractPlaintext(parsedMarkdown: Token[]): string {
74
- return parsedMarkdown.map(token => token.children ? this.extractPlaintext(token.children) : token.content).join('');
75
- }
76
-
77
- findCellByUri(uri: URI): NotebookCellModel | undefined {
78
- const parsed = CellUri.parse(uri);
79
- if (parsed) {
80
- return this.notebookService.getNotebookEditorModel(parsed.notebook)?.cells.find(cell => cell.handle === parsed?.handle);
81
- }
82
- return undefined;
83
- }
84
-
85
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { codicon, LabelProvider, LabelProviderContribution } from '@theia/core/lib/browser';
18
+ import { inject, injectable } from '@theia/core/shared/inversify';
19
+ import { CellKind, CellUri } from '../../common';
20
+ import { NotebookService } from '../service/notebook-service';
21
+ import { NotebookCellOutlineNode } from './notebook-outline-contribution';
22
+ import type Token = require('markdown-it/lib/token');
23
+ import markdownit = require('@theia/core/shared/markdown-it');
24
+ import { NotebookCellModel } from '../view-model/notebook-cell-model';
25
+ import { URI } from '@theia/core';
26
+
27
+ @injectable()
28
+ export class NotebookLabelProviderContribution implements LabelProviderContribution {
29
+
30
+ @inject(NotebookService)
31
+ protected readonly notebookService: NotebookService;
32
+
33
+ @inject(LabelProvider)
34
+ protected readonly labelProvider: LabelProvider;
35
+
36
+ protected markdownIt = markdownit();
37
+
38
+ canHandle(element: object): number {
39
+ if (NotebookCellOutlineNode.is(element)) {
40
+ return 200;
41
+ }
42
+ return 0;
43
+ }
44
+
45
+ getIcon(element: NotebookCellOutlineNode): string {
46
+ const cell = this.findCellByUri(element.uri);
47
+ if (cell) {
48
+ return cell.cellKind === CellKind.Markup ? codicon('markdown') : codicon('code');
49
+ }
50
+ return '';
51
+ }
52
+
53
+ getName(element: NotebookCellOutlineNode): string {
54
+ const cell = this.findCellByUri(element.uri);
55
+ if (cell) {
56
+ return cell.cellKind === CellKind.Code ?
57
+ cell.text.split('\n')[0] :
58
+ this.extractPlaintext(this.markdownIt.parse(cell.text.split('\n')[0], {}));
59
+ }
60
+ return '';
61
+ }
62
+
63
+ getLongName(element: NotebookCellOutlineNode): string {
64
+ const cell = this.findCellByUri(element.uri);
65
+ if (cell) {
66
+ return cell.cellKind === CellKind.Code ?
67
+ cell.text.split('\n')[0] :
68
+ this.extractPlaintext(this.markdownIt.parse(cell.text.split('\n')[0], {}));
69
+ }
70
+ return '';
71
+ }
72
+
73
+ extractPlaintext(parsedMarkdown: Token[]): string {
74
+ return parsedMarkdown.map(token => token.children ? this.extractPlaintext(token.children) : token.content).join('');
75
+ }
76
+
77
+ findCellByUri(uri: URI): NotebookCellModel | undefined {
78
+ const parsed = CellUri.parse(uri);
79
+ if (parsed) {
80
+ return this.notebookService.getNotebookEditorModel(parsed.notebook)?.cells.find(cell => cell.handle === parsed?.handle);
81
+ }
82
+ return undefined;
83
+ }
84
+
85
+ }
@@ -1,114 +1,114 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2024 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { inject, injectable } from '@theia/core/shared/inversify';
18
- import { codicon, FrontendApplicationContribution, LabelProvider, TreeNode } from '@theia/core/lib/browser';
19
- import { NotebookEditorWidgetService } from '../service/notebook-editor-widget-service';
20
- import { OutlineViewService } from '@theia/outline-view/lib/browser/outline-view-service';
21
- import { NotebookModel } from '../view-model/notebook-model';
22
- import { OutlineSymbolInformationNode } from '@theia/outline-view/lib/browser/outline-view-widget';
23
- import { NotebookEditorWidget } from '../notebook-editor-widget';
24
- import { DisposableCollection, isObject, URI } from '@theia/core';
25
- import { CellKind, CellUri } from '../../common';
26
- import { NotebookService } from '../service/notebook-service';
27
- export interface NotebookCellOutlineNode extends OutlineSymbolInformationNode {
28
- uri: URI;
29
- }
30
-
31
- export namespace NotebookCellOutlineNode {
32
- export function is(element: object): element is NotebookCellOutlineNode {
33
- return TreeNode.is(element)
34
- && OutlineSymbolInformationNode.is(element)
35
- && isObject<NotebookCellOutlineNode>(element)
36
- && element.uri instanceof URI
37
- && element.uri.scheme === CellUri.cellUriScheme;
38
- }
39
- }
40
-
41
- @injectable()
42
- export class NotebookOutlineContribution implements FrontendApplicationContribution {
43
-
44
- @inject(NotebookEditorWidgetService)
45
- protected readonly notebookEditorWidgetService: NotebookEditorWidgetService;
46
-
47
- @inject(OutlineViewService)
48
- protected readonly outlineViewService: OutlineViewService;
49
-
50
- @inject(LabelProvider)
51
- protected readonly labelProvider: LabelProvider;
52
-
53
- @inject(NotebookService)
54
- protected readonly notebookService: NotebookService;
55
-
56
- protected currentEditor?: NotebookEditorWidget;
57
-
58
- protected editorListeners: DisposableCollection = new DisposableCollection();
59
- protected editorModelListeners: DisposableCollection = new DisposableCollection();
60
-
61
- onStart(): void {
62
- this.notebookEditorWidgetService.onDidChangeFocusedEditor(editor => this.updateOutline(editor));
63
-
64
- this.outlineViewService.onDidSelect(node => this.selectCell(node));
65
- this.outlineViewService.onDidTapNode(node => this.selectCell(node));
66
- }
67
-
68
- protected async updateOutline(editor: NotebookEditorWidget | undefined): Promise<void> {
69
- if (editor && !editor.isDisposed) {
70
- await editor.ready;
71
- this.currentEditor = editor;
72
- this.editorListeners.dispose();
73
- this.editorListeners.push(editor.onDidChangeVisibility(() => {
74
- if (this.currentEditor === editor && !editor.isVisible) {
75
- this.outlineViewService.publish([]);
76
- }
77
- }));
78
- if (editor.model) {
79
- this.editorModelListeners.dispose();
80
- this.editorModelListeners.push(editor.model.onDidChangeSelectedCell(() => {
81
- if (editor === this.currentEditor) {
82
- this.updateOutline(editor);
83
- }
84
- }));
85
- const roots = editor && editor.model && await this.createRoots(editor.model);
86
- this.outlineViewService.publish(roots || []);
87
- }
88
- }
89
- }
90
-
91
- protected async createRoots(model: NotebookModel): Promise<OutlineSymbolInformationNode[] | undefined> {
92
- return model.cells.map(cell => ({
93
- id: cell.uri.toString(),
94
- iconClass: cell.cellKind === CellKind.Markup ? codicon('markdown') : codicon('code'),
95
- parent: undefined,
96
- children: [],
97
- selected: model.selectedCell === cell,
98
- expanded: false,
99
- uri: cell.uri,
100
- } as NotebookCellOutlineNode));
101
- }
102
-
103
- selectCell(node: object): void {
104
- if (NotebookCellOutlineNode.is(node)) {
105
- const parsed = CellUri.parse(node.uri);
106
- const model = parsed && this.notebookService.getNotebookEditorModel(parsed.notebook);
107
- const cell = model?.cells.find(c => c.handle === parsed?.handle);
108
- if (model && cell) {
109
- model.setSelectedCell(cell);
110
- }
111
- }
112
- }
113
-
114
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { inject, injectable } from '@theia/core/shared/inversify';
18
+ import { codicon, FrontendApplicationContribution, LabelProvider, TreeNode } from '@theia/core/lib/browser';
19
+ import { NotebookEditorWidgetService } from '../service/notebook-editor-widget-service';
20
+ import { OutlineViewService } from '@theia/outline-view/lib/browser/outline-view-service';
21
+ import { NotebookModel } from '../view-model/notebook-model';
22
+ import { OutlineSymbolInformationNode } from '@theia/outline-view/lib/browser/outline-view-widget';
23
+ import { NotebookEditorWidget } from '../notebook-editor-widget';
24
+ import { DisposableCollection, isObject, URI } from '@theia/core';
25
+ import { CellKind, CellUri } from '../../common';
26
+ import { NotebookService } from '../service/notebook-service';
27
+ export interface NotebookCellOutlineNode extends OutlineSymbolInformationNode {
28
+ uri: URI;
29
+ }
30
+
31
+ export namespace NotebookCellOutlineNode {
32
+ export function is(element: object): element is NotebookCellOutlineNode {
33
+ return TreeNode.is(element)
34
+ && OutlineSymbolInformationNode.is(element)
35
+ && isObject<NotebookCellOutlineNode>(element)
36
+ && element.uri instanceof URI
37
+ && element.uri.scheme === CellUri.cellUriScheme;
38
+ }
39
+ }
40
+
41
+ @injectable()
42
+ export class NotebookOutlineContribution implements FrontendApplicationContribution {
43
+
44
+ @inject(NotebookEditorWidgetService)
45
+ protected readonly notebookEditorWidgetService: NotebookEditorWidgetService;
46
+
47
+ @inject(OutlineViewService)
48
+ protected readonly outlineViewService: OutlineViewService;
49
+
50
+ @inject(LabelProvider)
51
+ protected readonly labelProvider: LabelProvider;
52
+
53
+ @inject(NotebookService)
54
+ protected readonly notebookService: NotebookService;
55
+
56
+ protected currentEditor?: NotebookEditorWidget;
57
+
58
+ protected editorListeners: DisposableCollection = new DisposableCollection();
59
+ protected editorModelListeners: DisposableCollection = new DisposableCollection();
60
+
61
+ onStart(): void {
62
+ this.notebookEditorWidgetService.onDidChangeFocusedEditor(editor => this.updateOutline(editor));
63
+
64
+ this.outlineViewService.onDidSelect(node => this.selectCell(node));
65
+ this.outlineViewService.onDidTapNode(node => this.selectCell(node));
66
+ }
67
+
68
+ protected async updateOutline(editor: NotebookEditorWidget | undefined): Promise<void> {
69
+ if (editor && !editor.isDisposed) {
70
+ await editor.ready;
71
+ this.currentEditor = editor;
72
+ this.editorListeners.dispose();
73
+ this.editorListeners.push(editor.onDidChangeVisibility(() => {
74
+ if (this.currentEditor === editor && !editor.isVisible) {
75
+ this.outlineViewService.publish([]);
76
+ }
77
+ }));
78
+ if (editor.model) {
79
+ this.editorModelListeners.dispose();
80
+ this.editorModelListeners.push(editor.model.onDidChangeSelectedCell(() => {
81
+ if (editor === this.currentEditor) {
82
+ this.updateOutline(editor);
83
+ }
84
+ }));
85
+ const roots = editor && editor.model && await this.createRoots(editor.model);
86
+ this.outlineViewService.publish(roots || []);
87
+ }
88
+ }
89
+ }
90
+
91
+ protected async createRoots(model: NotebookModel): Promise<OutlineSymbolInformationNode[] | undefined> {
92
+ return model.cells.map(cell => ({
93
+ id: cell.uri.toString(),
94
+ iconClass: cell.cellKind === CellKind.Markup ? codicon('markdown') : codicon('code'),
95
+ parent: undefined,
96
+ children: [],
97
+ selected: model.selectedCell === cell,
98
+ expanded: false,
99
+ uri: cell.uri,
100
+ } as NotebookCellOutlineNode));
101
+ }
102
+
103
+ selectCell(node: object): void {
104
+ if (NotebookCellOutlineNode.is(node)) {
105
+ const parsed = CellUri.parse(node.uri);
106
+ const model = parsed && this.notebookService.getNotebookEditorModel(parsed.notebook);
107
+ const cell = model?.cells.find(c => c.handle === parsed?.handle);
108
+ if (model && cell) {
109
+ model.setSelectedCell(cell);
110
+ }
111
+ }
112
+ }
113
+
114
+ }