@theia/notebook 1.53.0-next.4 → 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 (99) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/contributions/cell-operations.d.ts.map +1 -1
  3. package/lib/browser/contributions/cell-operations.js +8 -1
  4. package/lib/browser/contributions/cell-operations.js.map +1 -1
  5. package/lib/browser/contributions/notebook-actions-contribution.d.ts +1 -0
  6. package/lib/browser/contributions/notebook-actions-contribution.d.ts.map +1 -1
  7. package/lib/browser/contributions/notebook-actions-contribution.js +31 -6
  8. package/lib/browser/contributions/notebook-actions-contribution.js.map +1 -1
  9. package/lib/browser/contributions/notebook-cell-actions-contribution.d.ts +4 -0
  10. package/lib/browser/contributions/notebook-cell-actions-contribution.d.ts.map +1 -1
  11. package/lib/browser/contributions/notebook-cell-actions-contribution.js +49 -12
  12. package/lib/browser/contributions/notebook-cell-actions-contribution.js.map +1 -1
  13. package/lib/browser/contributions/notebook-status-bar-contribution.d.ts +14 -0
  14. package/lib/browser/contributions/notebook-status-bar-contribution.d.ts.map +1 -0
  15. package/lib/browser/contributions/notebook-status-bar-contribution.js +75 -0
  16. package/lib/browser/contributions/notebook-status-bar-contribution.js.map +1 -0
  17. package/lib/browser/notebook-editor-widget.d.ts.map +1 -1
  18. package/lib/browser/notebook-editor-widget.js +3 -5
  19. package/lib/browser/notebook-editor-widget.js.map +1 -1
  20. package/lib/browser/notebook-frontend-module.d.ts.map +1 -1
  21. package/lib/browser/notebook-frontend-module.js +3 -0
  22. package/lib/browser/notebook-frontend-module.js.map +1 -1
  23. package/lib/browser/notebook-open-handler.d.ts +3 -2
  24. package/lib/browser/notebook-open-handler.d.ts.map +1 -1
  25. package/lib/browser/notebook-open-handler.js +12 -5
  26. package/lib/browser/notebook-open-handler.js.map +1 -1
  27. package/lib/browser/service/notebook-options.d.ts +1 -0
  28. package/lib/browser/service/notebook-options.d.ts.map +1 -1
  29. package/lib/browser/service/notebook-options.js +1 -0
  30. package/lib/browser/service/notebook-options.js.map +1 -1
  31. package/lib/browser/service/notebook-service.d.ts +1 -0
  32. package/lib/browser/service/notebook-service.d.ts.map +1 -1
  33. package/lib/browser/service/notebook-service.js +7 -0
  34. package/lib/browser/service/notebook-service.js.map +1 -1
  35. package/lib/browser/view/notebook-cell-editor.d.ts +1 -0
  36. package/lib/browser/view/notebook-cell-editor.d.ts.map +1 -1
  37. package/lib/browser/view/notebook-cell-editor.js +30 -16
  38. package/lib/browser/view/notebook-cell-editor.js.map +1 -1
  39. package/lib/browser/view/notebook-cell-list-view.d.ts +7 -4
  40. package/lib/browser/view/notebook-cell-list-view.d.ts.map +1 -1
  41. package/lib/browser/view/notebook-cell-list-view.js +39 -29
  42. package/lib/browser/view/notebook-cell-list-view.js.map +1 -1
  43. package/lib/browser/view-model/notebook-cell-model.d.ts +3 -0
  44. package/lib/browser/view-model/notebook-cell-model.d.ts.map +1 -1
  45. package/lib/browser/view-model/notebook-cell-model.js +5 -0
  46. package/lib/browser/view-model/notebook-cell-model.js.map +1 -1
  47. package/package.json +8 -8
  48. package/src/browser/contributions/cell-operations.ts +44 -39
  49. package/src/browser/contributions/notebook-actions-contribution.ts +379 -351
  50. package/src/browser/contributions/notebook-cell-actions-contribution.ts +525 -485
  51. package/src/browser/contributions/notebook-color-contribution.ts +268 -268
  52. package/src/browser/contributions/notebook-context-keys.ts +113 -113
  53. package/src/browser/contributions/notebook-label-provider-contribution.ts +85 -85
  54. package/src/browser/contributions/notebook-outline-contribution.ts +114 -114
  55. package/src/browser/contributions/notebook-output-action-contribution.ts +82 -82
  56. package/src/browser/contributions/notebook-preferences.ts +92 -92
  57. package/src/browser/contributions/notebook-status-bar-contribution.ts +77 -0
  58. package/src/browser/contributions/notebook-undo-redo-handler.ts +41 -41
  59. package/src/browser/index.ts +27 -27
  60. package/src/browser/notebook-cell-resource-resolver.ts +130 -130
  61. package/src/browser/notebook-editor-widget-factory.ts +82 -82
  62. package/src/browser/notebook-editor-widget.tsx +330 -331
  63. package/src/browser/notebook-frontend-module.ts +119 -115
  64. package/src/browser/notebook-open-handler.ts +120 -114
  65. package/src/browser/notebook-output-utils.ts +119 -119
  66. package/src/browser/notebook-renderer-registry.ts +85 -85
  67. package/src/browser/notebook-type-registry.ts +54 -54
  68. package/src/browser/notebook-types.ts +186 -186
  69. package/src/browser/renderers/cell-output-webview.ts +33 -33
  70. package/src/browser/service/notebook-clipboard-service.ts +43 -43
  71. package/src/browser/service/notebook-context-manager.ts +162 -162
  72. package/src/browser/service/notebook-editor-widget-service.ts +101 -101
  73. package/src/browser/service/notebook-execution-service.ts +139 -139
  74. package/src/browser/service/notebook-execution-state-service.ts +311 -311
  75. package/src/browser/service/notebook-kernel-history-service.ts +124 -124
  76. package/src/browser/service/notebook-kernel-quick-pick-service.ts +479 -479
  77. package/src/browser/service/notebook-kernel-service.ts +357 -357
  78. package/src/browser/service/notebook-model-resolver-service.ts +160 -160
  79. package/src/browser/service/notebook-monaco-text-model-service.ts +48 -48
  80. package/src/browser/service/notebook-options.ts +155 -154
  81. package/src/browser/service/notebook-renderer-messaging-service.ts +121 -121
  82. package/src/browser/service/notebook-service.ts +215 -209
  83. package/src/browser/style/index.css +483 -467
  84. package/src/browser/view/notebook-cell-editor.tsx +263 -247
  85. package/src/browser/view/notebook-cell-list-view.tsx +279 -259
  86. package/src/browser/view/notebook-cell-toolbar-factory.tsx +102 -102
  87. package/src/browser/view/notebook-cell-toolbar.tsx +74 -74
  88. package/src/browser/view/notebook-code-cell-view.tsx +350 -350
  89. package/src/browser/view/notebook-find-widget.tsx +335 -335
  90. package/src/browser/view/notebook-main-toolbar.tsx +235 -235
  91. package/src/browser/view/notebook-markdown-cell-view.tsx +208 -208
  92. package/src/browser/view/notebook-viewport-service.ts +61 -61
  93. package/src/browser/view-model/notebook-cell-model.ts +473 -466
  94. package/src/browser/view-model/notebook-cell-output-model.ts +100 -100
  95. package/src/browser/view-model/notebook-model.ts +550 -550
  96. package/src/common/index.ts +18 -18
  97. package/src/common/notebook-common.ts +337 -337
  98. package/src/common/notebook-protocol.ts +35 -35
  99. package/src/common/notebook-range.ts +30 -30
@@ -1,82 +1,82 @@
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 { Command, CommandContribution, CommandRegistry } from '@theia/core';
18
- import { inject, injectable } from '@theia/core/shared/inversify';
19
- import { NotebookEditorWidgetService } from '../service/notebook-editor-widget-service';
20
- import { CellOutput, CellUri } from '../../common';
21
- import { NotebookCellModel } from '../view-model/notebook-cell-model';
22
- import { EditorManager } from '@theia/editor/lib/browser';
23
-
24
- export namespace NotebookOutputCommands {
25
- export const ENABLE_SCROLLING = Command.toDefaultLocalizedCommand({
26
- id: 'cellOutput.enableScrolling',
27
- });
28
-
29
- export const OPEN_LARGE_OUTPUT = Command.toDefaultLocalizedCommand({
30
- id: 'workbench.action.openLargeOutput',
31
- label: 'Open Large Output'
32
- });
33
- }
34
-
35
- @injectable()
36
- export class NotebookOutputActionContribution implements CommandContribution {
37
-
38
- @inject(NotebookEditorWidgetService)
39
- protected readonly notebookEditorService: NotebookEditorWidgetService;
40
-
41
- @inject(EditorManager)
42
- protected readonly editorManager: EditorManager;
43
-
44
- registerCommands(commands: CommandRegistry): void {
45
- commands.registerCommand(NotebookOutputCommands.ENABLE_SCROLLING, {
46
- execute: outputId => {
47
- const [cell, output] = this.findOutputAndCell(outputId) ?? [];
48
- if (cell && output?.metadata) {
49
- output.metadata['scrollable'] = true;
50
- cell.restartOutputRenderer(output.outputId);
51
- }
52
- }
53
- });
54
-
55
- commands.registerCommand(NotebookOutputCommands.OPEN_LARGE_OUTPUT, {
56
- execute: outputId => {
57
- const [cell, output] = this.findOutputAndCell(outputId) ?? [];
58
- if (cell && output) {
59
- this.editorManager.open(CellUri.generateCellOutputUri(CellUri.parse(cell.uri)!.notebook, output.outputId));
60
- }
61
- }
62
- });
63
- }
64
-
65
- protected findOutputAndCell(output: string): [NotebookCellModel, CellOutput] | undefined {
66
- const model = this.notebookEditorService.focusedEditor?.model;
67
- if (!model) {
68
- return undefined;
69
- }
70
-
71
- const outputId = output.slice(0, output.lastIndexOf('-'));
72
-
73
- for (const cell of model.cells) {
74
- for (const outputModel of cell.outputs) {
75
- if (outputModel.outputId === outputId) {
76
- return [cell, outputModel];
77
- }
78
- }
79
- }
80
- }
81
-
82
- }
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 { Command, CommandContribution, CommandRegistry } from '@theia/core';
18
+ import { inject, injectable } from '@theia/core/shared/inversify';
19
+ import { NotebookEditorWidgetService } from '../service/notebook-editor-widget-service';
20
+ import { CellOutput, CellUri } from '../../common';
21
+ import { NotebookCellModel } from '../view-model/notebook-cell-model';
22
+ import { EditorManager } from '@theia/editor/lib/browser';
23
+
24
+ export namespace NotebookOutputCommands {
25
+ export const ENABLE_SCROLLING = Command.toDefaultLocalizedCommand({
26
+ id: 'cellOutput.enableScrolling',
27
+ });
28
+
29
+ export const OPEN_LARGE_OUTPUT = Command.toDefaultLocalizedCommand({
30
+ id: 'workbench.action.openLargeOutput',
31
+ label: 'Open Large Output'
32
+ });
33
+ }
34
+
35
+ @injectable()
36
+ export class NotebookOutputActionContribution implements CommandContribution {
37
+
38
+ @inject(NotebookEditorWidgetService)
39
+ protected readonly notebookEditorService: NotebookEditorWidgetService;
40
+
41
+ @inject(EditorManager)
42
+ protected readonly editorManager: EditorManager;
43
+
44
+ registerCommands(commands: CommandRegistry): void {
45
+ commands.registerCommand(NotebookOutputCommands.ENABLE_SCROLLING, {
46
+ execute: outputId => {
47
+ const [cell, output] = this.findOutputAndCell(outputId) ?? [];
48
+ if (cell && output?.metadata) {
49
+ output.metadata['scrollable'] = true;
50
+ cell.restartOutputRenderer(output.outputId);
51
+ }
52
+ }
53
+ });
54
+
55
+ commands.registerCommand(NotebookOutputCommands.OPEN_LARGE_OUTPUT, {
56
+ execute: outputId => {
57
+ const [cell, output] = this.findOutputAndCell(outputId) ?? [];
58
+ if (cell && output) {
59
+ this.editorManager.open(CellUri.generateCellOutputUri(CellUri.parse(cell.uri)!.notebook, output.outputId));
60
+ }
61
+ }
62
+ });
63
+ }
64
+
65
+ protected findOutputAndCell(output: string): [NotebookCellModel, CellOutput] | undefined {
66
+ const model = this.notebookEditorService.focusedEditor?.model;
67
+ if (!model) {
68
+ return undefined;
69
+ }
70
+
71
+ const outputId = output.slice(0, output.lastIndexOf('-'));
72
+
73
+ for (const cell of model.cells) {
74
+ for (const outputModel of cell.outputs) {
75
+ if (outputModel.outputId === outputId) {
76
+ return [cell, outputModel];
77
+ }
78
+ }
79
+ }
80
+ }
81
+
82
+ }
@@ -1,92 +1,92 @@
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
- * 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 { nls } from '@theia/core';
22
- import { interfaces } from '@theia/core/shared/inversify';
23
- import { PreferenceContribution, PreferenceSchema } from '@theia/core/lib/browser';
24
-
25
- export namespace NotebookPreferences {
26
- export const NOTEBOOK_LINE_NUMBERS = 'notebook.lineNumbers';
27
- export const OUTPUT_LINE_HEIGHT = 'notebook.output.lineHeight';
28
- export const OUTPUT_FONT_SIZE = 'notebook.output.fontSize';
29
- export const OUTPUT_FONT_FAMILY = 'notebook.output.fontFamily';
30
- export const OUTPUT_SCROLLING = 'notebook.output.scrolling';
31
- export const OUTPUT_WORD_WRAP = 'notebook.output.wordWrap';
32
- export const OUTPUT_LINE_LIMIT = 'notebook.output.textLineLimit';
33
- }
34
-
35
- export const notebookPreferenceSchema: PreferenceSchema = {
36
- properties: {
37
- [NotebookPreferences.NOTEBOOK_LINE_NUMBERS]: {
38
- type: 'string',
39
- enum: ['on', 'off'],
40
- default: 'off',
41
- description: nls.localizeByDefault('Controls the display of line numbers in the cell editor.')
42
- },
43
- [NotebookPreferences.OUTPUT_LINE_HEIGHT]: {
44
- // eslint-disable-next-line max-len
45
- markdownDescription: nls.localizeByDefault('Line height of the output text within notebook cells.\n - When set to 0, editor line height is used.\n - Values between 0 and 8 will be used as a multiplier with the font size.\n - Values greater than or equal to 8 will be used as effective values.'),
46
- type: 'number',
47
- default: 0,
48
- tags: ['notebookLayout', 'notebookOutputLayout']
49
- },
50
- [NotebookPreferences.OUTPUT_FONT_SIZE]: {
51
- markdownDescription: nls.localizeByDefault('Font size for the output text within notebook cells. When set to 0, {0} is used.', '`#editor.fontSize#`'),
52
- type: 'number',
53
- default: 0,
54
- tags: ['notebookLayout', 'notebookOutputLayout']
55
- },
56
- [NotebookPreferences.OUTPUT_FONT_FAMILY]: {
57
- markdownDescription: nls.localizeByDefault('The font family of the output text within notebook cells. When set to empty, the {0} is used.', '`#editor.fontFamily#`'),
58
- type: 'string',
59
- tags: ['notebookLayout', 'notebookOutputLayout']
60
- },
61
- [NotebookPreferences.OUTPUT_SCROLLING]: {
62
- markdownDescription: nls.localizeByDefault('Initially render notebook outputs in a scrollable region when longer than the limit.'),
63
- type: 'boolean',
64
- tags: ['notebookLayout', 'notebookOutputLayout'],
65
- default: false
66
- },
67
- [NotebookPreferences.OUTPUT_WORD_WRAP]: {
68
- markdownDescription: nls.localizeByDefault('Controls whether the lines in output should wrap.'),
69
- type: 'boolean',
70
- tags: ['notebookLayout', 'notebookOutputLayout'],
71
- default: false
72
- },
73
- [NotebookPreferences.OUTPUT_LINE_LIMIT]: {
74
- markdownDescription: nls.localizeByDefault(
75
- 'Controls how many lines of text are displayed in a text output. If {0} is enabled, this setting is used to determine the scroll height of the output.',
76
- '`#notebook.output.scrolling#`'),
77
- type: 'number',
78
- default: 30,
79
- tags: ['notebookLayout', 'notebookOutputLayout'],
80
- minimum: 1,
81
- },
82
-
83
- }
84
- };
85
-
86
- export const NotebookPreferenceContribution = Symbol('NotebookPreferenceContribution');
87
-
88
- export function bindNotebookPreferences(bind: interfaces.Bind): void {
89
- // We don't need a NotebookPreferenceConfiguration class, so there's no preference proxy to bind
90
- bind(NotebookPreferenceContribution).toConstantValue({ schema: notebookPreferenceSchema });
91
- bind(PreferenceContribution).toService(NotebookPreferenceContribution);
92
- }
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
+ * 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 { nls } from '@theia/core';
22
+ import { interfaces } from '@theia/core/shared/inversify';
23
+ import { PreferenceContribution, PreferenceSchema } from '@theia/core/lib/browser';
24
+
25
+ export namespace NotebookPreferences {
26
+ export const NOTEBOOK_LINE_NUMBERS = 'notebook.lineNumbers';
27
+ export const OUTPUT_LINE_HEIGHT = 'notebook.output.lineHeight';
28
+ export const OUTPUT_FONT_SIZE = 'notebook.output.fontSize';
29
+ export const OUTPUT_FONT_FAMILY = 'notebook.output.fontFamily';
30
+ export const OUTPUT_SCROLLING = 'notebook.output.scrolling';
31
+ export const OUTPUT_WORD_WRAP = 'notebook.output.wordWrap';
32
+ export const OUTPUT_LINE_LIMIT = 'notebook.output.textLineLimit';
33
+ }
34
+
35
+ export const notebookPreferenceSchema: PreferenceSchema = {
36
+ properties: {
37
+ [NotebookPreferences.NOTEBOOK_LINE_NUMBERS]: {
38
+ type: 'string',
39
+ enum: ['on', 'off'],
40
+ default: 'off',
41
+ description: nls.localizeByDefault('Controls the display of line numbers in the cell editor.')
42
+ },
43
+ [NotebookPreferences.OUTPUT_LINE_HEIGHT]: {
44
+ // eslint-disable-next-line max-len
45
+ markdownDescription: nls.localizeByDefault('Line height of the output text within notebook cells.\n - When set to 0, editor line height is used.\n - Values between 0 and 8 will be used as a multiplier with the font size.\n - Values greater than or equal to 8 will be used as effective values.'),
46
+ type: 'number',
47
+ default: 0,
48
+ tags: ['notebookLayout', 'notebookOutputLayout']
49
+ },
50
+ [NotebookPreferences.OUTPUT_FONT_SIZE]: {
51
+ markdownDescription: nls.localizeByDefault('Font size for the output text within notebook cells. When set to 0, {0} is used.', '`#editor.fontSize#`'),
52
+ type: 'number',
53
+ default: 0,
54
+ tags: ['notebookLayout', 'notebookOutputLayout']
55
+ },
56
+ [NotebookPreferences.OUTPUT_FONT_FAMILY]: {
57
+ markdownDescription: nls.localizeByDefault('The font family of the output text within notebook cells. When set to empty, the {0} is used.', '`#editor.fontFamily#`'),
58
+ type: 'string',
59
+ tags: ['notebookLayout', 'notebookOutputLayout']
60
+ },
61
+ [NotebookPreferences.OUTPUT_SCROLLING]: {
62
+ markdownDescription: nls.localizeByDefault('Initially render notebook outputs in a scrollable region when longer than the limit.'),
63
+ type: 'boolean',
64
+ tags: ['notebookLayout', 'notebookOutputLayout'],
65
+ default: false
66
+ },
67
+ [NotebookPreferences.OUTPUT_WORD_WRAP]: {
68
+ markdownDescription: nls.localizeByDefault('Controls whether the lines in output should wrap.'),
69
+ type: 'boolean',
70
+ tags: ['notebookLayout', 'notebookOutputLayout'],
71
+ default: false
72
+ },
73
+ [NotebookPreferences.OUTPUT_LINE_LIMIT]: {
74
+ markdownDescription: nls.localizeByDefault(
75
+ 'Controls how many lines of text are displayed in a text output. If {0} is enabled, this setting is used to determine the scroll height of the output.',
76
+ '`#notebook.output.scrolling#`'),
77
+ type: 'number',
78
+ default: 30,
79
+ tags: ['notebookLayout', 'notebookOutputLayout'],
80
+ minimum: 1,
81
+ },
82
+
83
+ }
84
+ };
85
+
86
+ export const NotebookPreferenceContribution = Symbol('NotebookPreferenceContribution');
87
+
88
+ export function bindNotebookPreferences(bind: interfaces.Bind): void {
89
+ // We don't need a NotebookPreferenceConfiguration class, so there's no preference proxy to bind
90
+ bind(NotebookPreferenceContribution).toConstantValue({ schema: notebookPreferenceSchema });
91
+ bind(PreferenceContribution).toService(NotebookPreferenceContribution);
92
+ }
@@ -0,0 +1,77 @@
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 { FrontendApplicationContribution, StatusBar, StatusBarAlignment } from '@theia/core/lib/browser';
19
+ import { Disposable } from '@theia/core/lib/common';
20
+ import { NotebookEditorWidgetService } from '../service/notebook-editor-widget-service';
21
+ import { NotebookEditorWidget } from '../notebook-editor-widget';
22
+ import { nls } from '@theia/core';
23
+ import { NotebookCommands } from './notebook-actions-contribution';
24
+
25
+ export const NOTEBOOK_CELL_SELECTION_STATUS_BAR_ID = 'notebook-cell-selection-position';
26
+
27
+ @injectable()
28
+ export class NotebookStatusBarContribution implements FrontendApplicationContribution {
29
+
30
+ @inject(StatusBar) protected readonly statusBar: StatusBar;
31
+ @inject(NotebookEditorWidgetService) protected readonly editorWidgetService: NotebookEditorWidgetService;
32
+
33
+ protected currentCellSelectionListener: Disposable | undefined;
34
+ protected lastFocusedEditor: NotebookEditorWidget | undefined;
35
+
36
+ onStart(): void {
37
+ this.editorWidgetService.onDidChangeFocusedEditor(editor => {
38
+ this.currentCellSelectionListener?.dispose();
39
+ this.currentCellSelectionListener = editor?.model?.onDidChangeSelectedCell(() =>
40
+ this.updateStatusbar(editor)
41
+ );
42
+ editor?.onDidDispose(() => {
43
+ this.lastFocusedEditor = undefined;
44
+ this.updateStatusbar();
45
+ });
46
+ this.updateStatusbar(editor);
47
+ this.lastFocusedEditor = editor;
48
+ });
49
+ if (this.editorWidgetService.focusedEditor) {
50
+ this.updateStatusbar();
51
+ }
52
+ }
53
+
54
+ protected async updateStatusbar(editor?: NotebookEditorWidget): Promise<void> {
55
+ if ((!editor && !this.lastFocusedEditor?.isVisible) || editor?.model?.cells.length === 0) {
56
+ this.statusBar.removeElement(NOTEBOOK_CELL_SELECTION_STATUS_BAR_ID);
57
+ return;
58
+ }
59
+
60
+ await editor?.ready;
61
+ if (!editor?.model) {
62
+ return;
63
+ }
64
+
65
+ const selectedCellIndex = editor.model.selectedCell ? editor.model.cells.indexOf(editor.model.selectedCell) + 1 : '';
66
+
67
+ this.statusBar.setElement(NOTEBOOK_CELL_SELECTION_STATUS_BAR_ID, {
68
+ text: nls.localizeByDefault('Cell {0} of {1}', selectedCellIndex, editor.model.cells.length),
69
+ alignment: StatusBarAlignment.RIGHT,
70
+ priority: 100,
71
+ command: NotebookCommands.CENTER_ACTIVE_CELL.id,
72
+ arguments: [editor]
73
+ });
74
+
75
+ }
76
+
77
+ }
@@ -1,41 +1,41 @@
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 { ApplicationShell, UndoRedoHandler } from '@theia/core/lib/browser';
19
- import { NotebookEditorWidget } from '../notebook-editor-widget';
20
-
21
- @injectable()
22
- export class NotebookUndoRedoHandler implements UndoRedoHandler<NotebookEditorWidget> {
23
-
24
- @inject(ApplicationShell)
25
- protected readonly applicationShell: ApplicationShell;
26
-
27
- priority = 200;
28
- select(): NotebookEditorWidget | undefined {
29
- const current = this.applicationShell.currentWidget;
30
- if (current instanceof NotebookEditorWidget) {
31
- return current;
32
- }
33
- return undefined;
34
- }
35
- undo(item: NotebookEditorWidget): void {
36
- item.undo();
37
- }
38
- redo(item: NotebookEditorWidget): void {
39
- item.redo();
40
- }
41
- }
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 { ApplicationShell, UndoRedoHandler } from '@theia/core/lib/browser';
19
+ import { NotebookEditorWidget } from '../notebook-editor-widget';
20
+
21
+ @injectable()
22
+ export class NotebookUndoRedoHandler implements UndoRedoHandler<NotebookEditorWidget> {
23
+
24
+ @inject(ApplicationShell)
25
+ protected readonly applicationShell: ApplicationShell;
26
+
27
+ priority = 200;
28
+ select(): NotebookEditorWidget | undefined {
29
+ const current = this.applicationShell.currentWidget;
30
+ if (current instanceof NotebookEditorWidget) {
31
+ return current;
32
+ }
33
+ return undefined;
34
+ }
35
+ undo(item: NotebookEditorWidget): void {
36
+ item.undo();
37
+ }
38
+ redo(item: NotebookEditorWidget): void {
39
+ item.redo();
40
+ }
41
+ }
@@ -1,27 +1,27 @@
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
- export * from './notebook-type-registry';
18
- export * from './notebook-renderer-registry';
19
- export * from './notebook-editor-widget';
20
- export * from './service/notebook-service';
21
- export * from './service/notebook-editor-widget-service';
22
- export * from './service/notebook-kernel-service';
23
- export * from './service/notebook-execution-state-service';
24
- export * from './service/notebook-model-resolver-service';
25
- export * from './service/notebook-renderer-messaging-service';
26
- export * from './renderers/cell-output-webview';
27
- export * from './notebook-types';
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
+ export * from './notebook-type-registry';
18
+ export * from './notebook-renderer-registry';
19
+ export * from './notebook-editor-widget';
20
+ export * from './service/notebook-service';
21
+ export * from './service/notebook-editor-widget-service';
22
+ export * from './service/notebook-kernel-service';
23
+ export * from './service/notebook-execution-state-service';
24
+ export * from './service/notebook-model-resolver-service';
25
+ export * from './service/notebook-renderer-messaging-service';
26
+ export * from './renderers/cell-output-webview';
27
+ export * from './notebook-types';