@codingame/monaco-vscode-api 1.85.0 → 1.85.1
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 +19 -10
- package/contributions.js +1 -0
- package/missing-services.js +91 -5
- package/monaco-editor-treemending.patch +957 -950
- package/package.json +6 -6
- package/vscode/src/vs/base/common/jsonFormatter.js +8 -1
- package/vscode/src/vs/platform/actions/browser/buttonbar.js +128 -0
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagement.js +2 -1
- package/vscode/src/vs/platform/layout/browser/zIndexRegistry.js +58 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.js +56 -1
- package/vscode/src/vs/workbench/browser/actions/layoutActions.js +186 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +191 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatActions.js +238 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.js +75 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +205 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorInput.js +168 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatFollowups.js +35 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatInputPart.js +340 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatListRenderer.js +1195 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.js +115 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatOptions.js +81 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.js +62 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatWidget.js +583 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.js +290 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables.js +167 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatContextKeys.js +6 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatModel.js +562 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatParserTypes.js +31 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatProvider.js +24 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatRequestParser.js +193 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatService.js +22 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +52 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatViewModel.js +258 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +37 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatWordCounter.js +25 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.js +388 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentColors.js +61 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentFormActions.js +49 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentNode.js +647 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentReply.js +300 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadAdditionalActions.js +60 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadBody.js +249 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadHeader.js +107 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadWidget.js +333 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/media/review.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/reactionsAction.js +99 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/timestamp.js +55 -0
- package/vscode/src/vs/workbench/contrib/comments/common/commentsConfiguration.js +2 -0
- package/vscode/src/vs/workbench/contrib/contextmenu/browser/contextmenu.contribution.js +20 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.js +855 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointWidget.js +410 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointsView.js +1591 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/callStackEditorContribution.js +178 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/media/breakpointWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/media/callStackEditorContribution.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/debug/common/debugModel.js +1485 -0
- package/vscode/src/vs/workbench/contrib/debug/common/debugSource.js +125 -0
- package/vscode/src/vs/workbench/contrib/debug/common/disassemblyViewInput.js +29 -0
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsInput.js +41 -0
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsUtils.js +102 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.js +988 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget.js +431 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.js +417 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.js +806 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.js +915 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/utils.js +19 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChat.js +129 -10
- package/vscode/src/vs/workbench/contrib/markdown/browser/markdownDocumentRenderer.js +205 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.js +150 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInputModel.js +480 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.js +5 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/diffComputer.js +90 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/editing.js +54 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/lineRange.js +108 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mapping.js +258 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.js +614 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.js +307 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/rangeUtils.js +44 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.js +165 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/telemetry.js +78 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/utils.js +169 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/common/mergeEditor.js +64 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/cellOutputClipboard.js +49 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findFilters.js +70 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel.js +120 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.js +416 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.js +663 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.js +593 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOutputActions.js +72 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/coreActions.js +326 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +539 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/foldingController.js +265 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +348 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebook.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellChat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellEditorHint.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellInsertToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellOutput.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellStatusBar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellTitleToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookDnd.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookEditorStickyScroll.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookFocusIndicator.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookFolding.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookKernelActionViewItem.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookOutline.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookBrowser.js +95 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditor.js +437 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditorExtensions.js +29 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +2730 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookIcons.js +139 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookLogger.js +17 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookOptions.js +564 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookViewEvents.js +27 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellPart.js +119 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellActionView.js +27 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellComments.js +135 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellContextKeys.js +178 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDecorations.js +35 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDnd.js +377 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDragRenderer.js +97 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellEditorOptions.js +194 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellExecution.js +71 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocus.js +20 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocusIndicator.js +85 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellOutput.js +652 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellProgressBar.js +59 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellStatusPart.js +303 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbarStickyScroll.js +24 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbars.js +228 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatActions.js +302 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatController.js +438 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatPart.js +45 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.js +435 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellExecutionIcon.js +95 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellRunToolbar.js +107 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/collapsedCellInput.js +29 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/collapsedCellOutput.js +59 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/foldedCellHint.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.js +430 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellAnchor.js +54 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.js +1131 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellListView.js +21 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.js +1591 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.js +341 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.js +2155 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewThemeMapping.js +65 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/OutlineEntry.js +95 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.js +507 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellEditorOptions.js +85 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellOutputViewModel.js +47 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellSelectionCollection.js +40 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.js +435 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher.js +31 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/foldingModel.js +257 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel.js +239 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +103 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProvider.js +211 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.js +808 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/viewContext.js +8 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll.js +381 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorToolbar.js +527 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys.js +163 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelQuickPickStrategy.js +651 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelView.js +173 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookOverviewRuler.js +98 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookTopCellToolbar.js +62 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookCellOutputTextModel.js +101 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.js +346 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookCommon.js +152 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookContextKeys.js +39 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorInput.js +296 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.js +261 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookExecutionService.js +3 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookKernelService.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookKeymapService.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookLoggingService.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookPerformance.js +16 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookRange.js +66 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookWorkerService.js +4 -0
- package/vscode/src/vs/workbench/contrib/preferences/common/settingsEditorColorRegistry.js +130 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/media/tunnelView.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteExplorer.js +847 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteIcons.js +89 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/tunnelView.js +1942 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/urlFinder.js +107 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsBase.js +49 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsFind.js +387 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchModel.js +2 -2
- package/vscode/src/vs/workbench/contrib/search/common/constants.js +66 -0
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/constants.js +11 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions.js +24 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/fileTemplateSnippets.js +95 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminal.js +4 -1
- package/vscode/src/vs/workbench/contrib/terminal/common/terminal.js +2 -1
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/featuredExtensionService.js +159 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedExtensionPoint.js +375 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.js +563 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/common/gettingStartedContent.js +932 -0
- package/vscode/src/vs/workbench/services/layout/browser/layoutService.js +15 -1
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.d.ts +2 -2
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.js +190 -2
- package/vscode/src/vs/workbench/services/workingCopy/common/resourceWorkingCopy.js +77 -0
- package/assets/break.mp3 +0 -0
- package/assets/chatRequestSent.mp3 +0 -0
- package/assets/chatResponsePending.mp3 +0 -0
- package/assets/chatResponseReceived1.mp3 +0 -0
- package/assets/chatResponseReceived2.mp3 +0 -0
- package/assets/chatResponseReceived3.mp3 +0 -0
- package/assets/chatResponseReceived4.mp3 +0 -0
- package/assets/clear.mp3 +0 -0
- package/assets/defaultIcon.png +0 -0
- package/assets/diffLineDeleted.mp3 +0 -0
- package/assets/diffLineInserted.mp3 +0 -0
- package/assets/diffLineModified.mp3 +0 -0
- package/assets/error.mp3 +0 -0
- package/assets/fake.html +0 -10
- package/assets/foldedAreas.mp3 +0 -0
- package/assets/format.mp3 +0 -0
- package/assets/index-no-csp.html +0 -1226
- package/assets/index.html +0 -1227
- package/assets/quickFixes.mp3 +0 -0
- package/assets/save.mp3 +0 -0
- package/assets/service-worker.js +0 -457
- package/assets/taskCompleted.mp3 +0 -0
- package/assets/taskFailed.mp3 +0 -0
- package/assets/terminalBell.mp3 +0 -0
- package/assets/warning.mp3 +0 -0
- package/assets/webWorkerExtensionHostIframe.html +0 -123
- package/override/vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel.js +0 -2
- package/override/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +0 -2
- package/override/vs/workbench/contrib/notebook/common/notebookEditorInput.js +0 -5
|
@@ -0,0 +1,2730 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import './media/notebook.css.js';
|
|
3
|
+
import './media/notebookCellChat.css.js';
|
|
4
|
+
import './media/notebookCellEditorHint.css.js';
|
|
5
|
+
import './media/notebookCellInsertToolbar.css.js';
|
|
6
|
+
import './media/notebookCellStatusBar.css.js';
|
|
7
|
+
import './media/notebookCellTitleToolbar.css.js';
|
|
8
|
+
import './media/notebookFocusIndicator.css.js';
|
|
9
|
+
import './media/notebookToolbar.css.js';
|
|
10
|
+
import './media/notebookDnd.css.js';
|
|
11
|
+
import './media/notebookFolding.css.js';
|
|
12
|
+
import './media/notebookCellOutput.css.js';
|
|
13
|
+
import './media/notebookEditorStickyScroll.css.js';
|
|
14
|
+
import './media/notebookKernelActionViewItem.css.js';
|
|
15
|
+
import './media/notebookOutline.css.js';
|
|
16
|
+
import { PixelRatio } from 'monaco-editor/esm/vs/base/browser/browser.js';
|
|
17
|
+
import * as dom from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
18
|
+
import { SequencerByKey, DeferredPromise } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
19
|
+
import { Color, RGBA } from 'monaco-editor/esm/vs/base/common/color.js';
|
|
20
|
+
import { onUnexpectedError } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
21
|
+
import { Emitter, Event } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
22
|
+
import { Disposable, DisposableStore, combinedDisposable, dispose, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
23
|
+
import { setTimeout0 } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
24
|
+
import { isEqual, extname } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
25
|
+
import { generateUuid } from 'monaco-editor/esm/vs/base/common/uuid.js';
|
|
26
|
+
import { FontMeasurements } from 'monaco-editor/esm/vs/editor/browser/config/fontMeasurements.js';
|
|
27
|
+
import { BareFontInfo } from 'monaco-editor/esm/vs/editor/common/config/fontInfo.js';
|
|
28
|
+
import { Range } from 'monaco-editor/esm/vs/editor/common/core/range.js';
|
|
29
|
+
import { SuggestController } from 'monaco-editor/esm/vs/editor/contrib/suggest/browser/suggestController.js';
|
|
30
|
+
import * as nls from 'monaco-editor/esm/vs/nls.js';
|
|
31
|
+
import { MenuId } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
|
|
32
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
33
|
+
import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
34
|
+
import { IContextMenuService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextView.js';
|
|
35
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
36
|
+
import { ServiceCollection } from 'monaco-editor/esm/vs/platform/instantiation/common/serviceCollection.js';
|
|
37
|
+
import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
|
|
38
|
+
import { registerZIndex, ZIndex } from '../../../../platform/layout/browser/zIndexRegistry.js';
|
|
39
|
+
import { IEditorProgressService } from 'monaco-editor/esm/vs/platform/progress/common/progress.js';
|
|
40
|
+
import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
|
|
41
|
+
import { registerColor, transparent, listInactiveSelectionBackground, focusBorder, errorForeground, foreground, contrastBorder, scrollbarSliderBackground, scrollbarSliderHoverBackground, scrollbarSliderActiveBackground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
|
|
42
|
+
import { PANEL_BORDER, SIDE_BAR_BACKGROUND, EDITOR_PANE_BACKGROUND } from '../../../common/theme.js';
|
|
43
|
+
import { debugIconStartForeground } from '../../debug/browser/debugColors.js';
|
|
44
|
+
import { CellEditState, CellFocusMode, CellRevealRangeType, ScrollToRevealBehavior } from './notebookBrowser.js';
|
|
45
|
+
import { NotebookEditorExtensionsRegistry } from './notebookEditorExtensions.js';
|
|
46
|
+
import { INotebookEditorService } from './services/notebookEditorService.js';
|
|
47
|
+
import { notebookDebug } from './notebookLogger.js';
|
|
48
|
+
import { NotebookLayoutChangedEvent } from './notebookViewEvents.js';
|
|
49
|
+
import { CellContextKeyManager } from './view/cellParts/cellContextKeys.js';
|
|
50
|
+
import { CellDragAndDropController } from './view/cellParts/cellDnd.js';
|
|
51
|
+
import { NotebookCellList, ListViewInfoAccessor, NOTEBOOK_WEBVIEW_BOUNDARY } from './view/notebookCellList.js';
|
|
52
|
+
import { BackLayerWebView } from './view/renderers/backLayerWebView.js';
|
|
53
|
+
import { CodeCellRenderer, MarkupCellRenderer, NotebookCellListDelegate } from './view/renderers/cellRenderer.js';
|
|
54
|
+
import { outputDisplayLimit, CodeCellViewModel } from './viewModel/codeCellViewModel.js';
|
|
55
|
+
import { NotebookEventDispatcher } from './viewModel/eventDispatcher.js';
|
|
56
|
+
import { MarkupCellViewModel } from './viewModel/markupCellViewModel.js';
|
|
57
|
+
import { NotebookViewModel } from './viewModel/notebookViewModelImpl.js';
|
|
58
|
+
import { ViewContext } from './viewModel/viewContext.js';
|
|
59
|
+
import { NotebookEditorWorkbenchToolbar } from './viewParts/notebookEditorToolbar.js';
|
|
60
|
+
import { NotebookEditorContextKeys } from './viewParts/notebookEditorWidgetContextKeys.js';
|
|
61
|
+
import { NotebookOverviewRuler } from './viewParts/notebookOverviewRuler.js';
|
|
62
|
+
import { ListTopCellToolbar } from './viewParts/notebookTopCellToolbar.js';
|
|
63
|
+
import { SelectionStateType, CellKind, RENDERER_NOT_AVAILABLE } from '../common/notebookCommon.js';
|
|
64
|
+
import { NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_OUTPUT_FOCUSED, NOTEBOOK_OUPTUT_INPUT_FOCUSED, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_CURSOR_NAVIGATION_MODE } from '../common/notebookContextKeys.js';
|
|
65
|
+
import { INotebookExecutionService } from '../common/notebookExecutionService.js';
|
|
66
|
+
import { INotebookExecutionStateService } from '../common/notebookExecutionStateService.js';
|
|
67
|
+
import { INotebookKernelService } from '../common/notebookKernelService.js';
|
|
68
|
+
import { NotebookOptions, OutputInnerContainerTopPadding } from './notebookOptions.js';
|
|
69
|
+
import { INotebookRendererMessagingService } from '../common/notebookRendererMessagingService.js';
|
|
70
|
+
import { INotebookService } from '../common/notebookService.js';
|
|
71
|
+
import { EditorExtensionsRegistry } from 'monaco-editor/esm/vs/editor/browser/editorExtensions.js';
|
|
72
|
+
import { IEditorGroupsService } from '../../../services/editor/common/editorGroupsService.js';
|
|
73
|
+
import { BaseCellEditorOptions } from './viewModel/cellEditorOptions.js';
|
|
74
|
+
import { FloatingEditorClickMenu } from '../../../browser/codeeditor.js';
|
|
75
|
+
import { CellFindMatchModel } from './contrib/find/findModel.js';
|
|
76
|
+
import { INotebookLoggingService } from '../common/notebookLoggingService.js';
|
|
77
|
+
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
78
|
+
import { DropIntoEditorController } from 'monaco-editor/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController.js';
|
|
79
|
+
import { CopyPasteController } from 'monaco-editor/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.js';
|
|
80
|
+
import { NotebookStickyScroll } from './viewParts/notebookEditorStickyScroll.js';
|
|
81
|
+
import { NotebookCellOutlineProvider } from './viewModel/notebookOutlineProvider.js';
|
|
82
|
+
import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
|
|
83
|
+
const $ = dom.$;
|
|
84
|
+
function getDefaultNotebookCreationOptions() {
|
|
85
|
+
const skipContributions = [
|
|
86
|
+
'editor.contrib.review',
|
|
87
|
+
FloatingEditorClickMenu.ID,
|
|
88
|
+
'editor.contrib.dirtydiff',
|
|
89
|
+
'editor.contrib.testingOutputPeek',
|
|
90
|
+
'editor.contrib.testingDecorations',
|
|
91
|
+
'store.contrib.stickyScrollController',
|
|
92
|
+
'editor.contrib.findController',
|
|
93
|
+
'editor.contrib.emptyTextEditorHint'
|
|
94
|
+
];
|
|
95
|
+
const contributions = EditorExtensionsRegistry.getEditorContributions().filter(c => skipContributions.indexOf(c.id) === -1);
|
|
96
|
+
return {
|
|
97
|
+
menuIds: {
|
|
98
|
+
notebookToolbar: MenuId.NotebookToolbar,
|
|
99
|
+
cellTitleToolbar: MenuId.NotebookCellTitle,
|
|
100
|
+
cellDeleteToolbar: MenuId.NotebookCellDelete,
|
|
101
|
+
cellInsertToolbar: MenuId.NotebookCellBetween,
|
|
102
|
+
cellTopInsertToolbar: MenuId.NotebookCellListTop,
|
|
103
|
+
cellExecuteToolbar: MenuId.NotebookCellExecute,
|
|
104
|
+
cellExecutePrimary: MenuId.NotebookCellExecutePrimary,
|
|
105
|
+
},
|
|
106
|
+
cellEditorContributions: contributions
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
let NotebookEditorWidget = class NotebookEditorWidget extends Disposable {
|
|
110
|
+
get isVisible() {
|
|
111
|
+
return this._isVisible;
|
|
112
|
+
}
|
|
113
|
+
get isDisposed() {
|
|
114
|
+
return this._isDisposed;
|
|
115
|
+
}
|
|
116
|
+
set viewModel(newModel) {
|
|
117
|
+
this._onWillChangeModel.fire(this._notebookViewModel?.notebookDocument);
|
|
118
|
+
this._notebookViewModel = newModel;
|
|
119
|
+
this._onDidChangeModel.fire(newModel?.notebookDocument);
|
|
120
|
+
}
|
|
121
|
+
get viewModel() {
|
|
122
|
+
return this._notebookViewModel;
|
|
123
|
+
}
|
|
124
|
+
get textModel() {
|
|
125
|
+
return this._notebookViewModel?.notebookDocument;
|
|
126
|
+
}
|
|
127
|
+
get isReadOnly() {
|
|
128
|
+
return this._notebookViewModel?.options.isReadOnly ?? false;
|
|
129
|
+
}
|
|
130
|
+
get activeCodeEditor() {
|
|
131
|
+
if (this._isDisposed) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const [focused] = this._list.getFocusedElements();
|
|
135
|
+
return this._renderedEditors.get(focused);
|
|
136
|
+
}
|
|
137
|
+
get codeEditors() {
|
|
138
|
+
return [...this._renderedEditors];
|
|
139
|
+
}
|
|
140
|
+
get visibleRanges() {
|
|
141
|
+
return this._list.visibleRanges || [];
|
|
142
|
+
}
|
|
143
|
+
get notebookOptions() {
|
|
144
|
+
return this._notebookOptions;
|
|
145
|
+
}
|
|
146
|
+
constructor(creationOptions, dimension, instantiationService, editorGroupsService, notebookRendererMessaging, notebookEditorService, notebookKernelService, _notebookService, configurationService, contextKeyService, layoutService, contextMenuService, telemetryService, notebookExecutionService, notebookExecutionStateService, editorProgressService, logService, keybindingService) {
|
|
147
|
+
super();
|
|
148
|
+
this.creationOptions = creationOptions;
|
|
149
|
+
this.notebookRendererMessaging = notebookRendererMessaging;
|
|
150
|
+
this.notebookEditorService = notebookEditorService;
|
|
151
|
+
this.notebookKernelService = notebookKernelService;
|
|
152
|
+
this._notebookService = _notebookService;
|
|
153
|
+
this.configurationService = configurationService;
|
|
154
|
+
this.layoutService = layoutService;
|
|
155
|
+
this.contextMenuService = contextMenuService;
|
|
156
|
+
this.telemetryService = telemetryService;
|
|
157
|
+
this.notebookExecutionService = notebookExecutionService;
|
|
158
|
+
this.editorProgressService = editorProgressService;
|
|
159
|
+
this.logService = logService;
|
|
160
|
+
this.keybindingService = keybindingService;
|
|
161
|
+
this._onDidChangeCellState = this._register(( new Emitter()));
|
|
162
|
+
this.onDidChangeCellState = this._onDidChangeCellState.event;
|
|
163
|
+
this._onDidChangeViewCells = this._register(( new Emitter()));
|
|
164
|
+
this.onDidChangeViewCells = this._onDidChangeViewCells.event;
|
|
165
|
+
this._onWillChangeModel = this._register(( new Emitter()));
|
|
166
|
+
this.onWillChangeModel = this._onWillChangeModel.event;
|
|
167
|
+
this._onDidChangeModel = this._register(( new Emitter()));
|
|
168
|
+
this.onDidChangeModel = this._onDidChangeModel.event;
|
|
169
|
+
this._onDidAttachViewModel = this._register(( new Emitter()));
|
|
170
|
+
this.onDidAttachViewModel = this._onDidAttachViewModel.event;
|
|
171
|
+
this._onDidChangeOptions = this._register(( new Emitter()));
|
|
172
|
+
this.onDidChangeOptions = this._onDidChangeOptions.event;
|
|
173
|
+
this._onDidChangeDecorations = this._register(( new Emitter()));
|
|
174
|
+
this.onDidChangeDecorations = this._onDidChangeDecorations.event;
|
|
175
|
+
this._onDidScroll = this._register(( new Emitter()));
|
|
176
|
+
this.onDidScroll = this._onDidScroll.event;
|
|
177
|
+
this._onDidChangeActiveCell = this._register(( new Emitter()));
|
|
178
|
+
this.onDidChangeActiveCell = this._onDidChangeActiveCell.event;
|
|
179
|
+
this._onDidChangeSelection = this._register(( new Emitter()));
|
|
180
|
+
this.onDidChangeSelection = this._onDidChangeSelection.event;
|
|
181
|
+
this._onDidChangeVisibleRanges = this._register(( new Emitter()));
|
|
182
|
+
this.onDidChangeVisibleRanges = this._onDidChangeVisibleRanges.event;
|
|
183
|
+
this._onDidFocusEmitter = this._register(( new Emitter()));
|
|
184
|
+
this.onDidFocusWidget = this._onDidFocusEmitter.event;
|
|
185
|
+
this._onDidBlurEmitter = this._register(( new Emitter()));
|
|
186
|
+
this.onDidBlurWidget = this._onDidBlurEmitter.event;
|
|
187
|
+
this._onDidChangeActiveEditor = this._register(( new Emitter()));
|
|
188
|
+
this.onDidChangeActiveEditor = this._onDidChangeActiveEditor.event;
|
|
189
|
+
this._onDidChangeActiveKernel = this._register(( new Emitter()));
|
|
190
|
+
this.onDidChangeActiveKernel = this._onDidChangeActiveKernel.event;
|
|
191
|
+
this._onMouseUp = this._register(( new Emitter()));
|
|
192
|
+
this.onMouseUp = this._onMouseUp.event;
|
|
193
|
+
this._onMouseDown = this._register(( new Emitter()));
|
|
194
|
+
this.onMouseDown = this._onMouseDown.event;
|
|
195
|
+
this._onDidReceiveMessage = this._register(( new Emitter()));
|
|
196
|
+
this.onDidReceiveMessage = this._onDidReceiveMessage.event;
|
|
197
|
+
this._onDidRenderOutput = this._register(( new Emitter()));
|
|
198
|
+
this.onDidRenderOutput = this._onDidRenderOutput.event;
|
|
199
|
+
this._onDidRemoveOutput = this._register(( new Emitter()));
|
|
200
|
+
this.onDidRemoveOutput = this._onDidRemoveOutput.event;
|
|
201
|
+
this._onDidResizeOutputEmitter = this._register(( new Emitter()));
|
|
202
|
+
this.onDidResizeOutput = this._onDidResizeOutputEmitter.event;
|
|
203
|
+
this._webview = null;
|
|
204
|
+
this._webviewResolvePromise = null;
|
|
205
|
+
this._webviewTransparentCover = null;
|
|
206
|
+
this._listDelegate = null;
|
|
207
|
+
this._dndController = null;
|
|
208
|
+
this._listTopCellToolbar = null;
|
|
209
|
+
this._renderedEditors = ( new Map());
|
|
210
|
+
this._localStore = this._register(( new DisposableStore()));
|
|
211
|
+
this._localCellStateListeners = [];
|
|
212
|
+
this._shadowElementViewInfo = null;
|
|
213
|
+
this._contributions = ( new Map());
|
|
214
|
+
this._insetModifyQueueByOutputId = ( new SequencerByKey());
|
|
215
|
+
this._cellContextKeyManager = null;
|
|
216
|
+
this._uuid = generateUuid();
|
|
217
|
+
this._webviewFocused = false;
|
|
218
|
+
this._isVisible = false;
|
|
219
|
+
this._isDisposed = false;
|
|
220
|
+
this._baseCellEditorOptions = ( new Map());
|
|
221
|
+
this._debugFlag = false;
|
|
222
|
+
this._backgroundMarkdownRenderRunning = false;
|
|
223
|
+
this._lastCellWithEditorFocus = null;
|
|
224
|
+
this._pendingLayouts = ( new WeakMap());
|
|
225
|
+
this._pendingOutputHeightAcks = ( new Map());
|
|
226
|
+
this._dimension = dimension;
|
|
227
|
+
this.isEmbedded = creationOptions.isEmbedded ?? false;
|
|
228
|
+
this._readOnly = creationOptions.isReadOnly ?? false;
|
|
229
|
+
this._notebookOptions = creationOptions.options ?? ( new NotebookOptions(this.configurationService, notebookExecutionStateService, this._readOnly));
|
|
230
|
+
this._register(this._notebookOptions);
|
|
231
|
+
this._viewContext = ( new ViewContext(this._notebookOptions, ( new NotebookEventDispatcher()), language => this.getBaseCellEditorOptions(language)));
|
|
232
|
+
this._register(this._viewContext.eventDispatcher.onDidChangeCellState(e => {
|
|
233
|
+
this._onDidChangeCellState.fire(e);
|
|
234
|
+
}));
|
|
235
|
+
this._overlayContainer = document.createElement('div');
|
|
236
|
+
this.scopedContextKeyService = contextKeyService.createScoped(this._overlayContainer);
|
|
237
|
+
this.instantiationService = instantiationService.createChild(( new ServiceCollection([IContextKeyService, this.scopedContextKeyService])));
|
|
238
|
+
this._register(_notebookService.onDidChangeOutputRenderers(() => {
|
|
239
|
+
this._updateOutputRenderers();
|
|
240
|
+
}));
|
|
241
|
+
this._register(this.instantiationService.createInstance(NotebookEditorContextKeys, this));
|
|
242
|
+
this._notebookOutline = this._register(this.instantiationService.createInstance(NotebookCellOutlineProvider, this, 4 ));
|
|
243
|
+
this._register(notebookKernelService.onDidChangeSelectedNotebooks(e => {
|
|
244
|
+
if (isEqual(e.notebook, this.viewModel?.uri)) {
|
|
245
|
+
this._loadKernelPreloads();
|
|
246
|
+
this._onDidChangeActiveKernel.fire();
|
|
247
|
+
}
|
|
248
|
+
}));
|
|
249
|
+
this._scrollBeyondLastLine = this.configurationService.getValue('editor.scrollBeyondLastLine');
|
|
250
|
+
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
|
251
|
+
if (e.affectsConfiguration('editor.scrollBeyondLastLine')) {
|
|
252
|
+
this._scrollBeyondLastLine = this.configurationService.getValue('editor.scrollBeyondLastLine');
|
|
253
|
+
if (this._dimension && this._isVisible) {
|
|
254
|
+
this.layout(this._dimension);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}));
|
|
258
|
+
this._register(this._notebookOptions.onDidChangeOptions(e => {
|
|
259
|
+
if (e.cellStatusBarVisibility || e.cellToolbarLocation || e.cellToolbarInteraction) {
|
|
260
|
+
this._updateForNotebookConfiguration();
|
|
261
|
+
}
|
|
262
|
+
if (e.fontFamily) {
|
|
263
|
+
this._generateFontInfo();
|
|
264
|
+
}
|
|
265
|
+
if (e.compactView
|
|
266
|
+
|| e.focusIndicator
|
|
267
|
+
|| e.insertToolbarPosition
|
|
268
|
+
|| e.cellToolbarLocation
|
|
269
|
+
|| e.dragAndDropEnabled
|
|
270
|
+
|| e.fontSize
|
|
271
|
+
|| e.markupFontSize
|
|
272
|
+
|| e.fontFamily
|
|
273
|
+
|| e.insertToolbarAlignment
|
|
274
|
+
|| e.outputFontSize
|
|
275
|
+
|| e.outputLineHeight
|
|
276
|
+
|| e.outputFontFamily
|
|
277
|
+
|| e.outputWordWrap
|
|
278
|
+
|| e.outputScrolling) {
|
|
279
|
+
this._styleElement?.remove();
|
|
280
|
+
this._createLayoutStyles();
|
|
281
|
+
this._webview?.updateOptions({
|
|
282
|
+
...this.notebookOptions.computeWebviewOptions(),
|
|
283
|
+
fontFamily: this._generateFontFamily()
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
if (this._dimension && this._isVisible) {
|
|
287
|
+
this.layout(this._dimension);
|
|
288
|
+
}
|
|
289
|
+
}));
|
|
290
|
+
this._register(editorGroupsService.activePart.onDidScroll(e => {
|
|
291
|
+
if (!this._shadowElement || !this._isVisible) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
this.updateShadowElement(this._shadowElement, this._dimension);
|
|
295
|
+
this.layoutContainerOverShadowElement(this._dimension, this._position);
|
|
296
|
+
}));
|
|
297
|
+
this.notebookEditorService.addNotebookEditor(this);
|
|
298
|
+
const id = generateUuid();
|
|
299
|
+
this._overlayContainer.id = `notebook-${id}`;
|
|
300
|
+
this._overlayContainer.className = 'notebookOverlay';
|
|
301
|
+
this._overlayContainer.classList.add('notebook-editor');
|
|
302
|
+
this._overlayContainer.style.visibility = 'hidden';
|
|
303
|
+
this.layoutService.mainContainer.appendChild(this._overlayContainer);
|
|
304
|
+
this._createBody(this._overlayContainer);
|
|
305
|
+
this._generateFontInfo();
|
|
306
|
+
this._isVisible = true;
|
|
307
|
+
this._editorFocus = NOTEBOOK_EDITOR_FOCUSED.bindTo(this.scopedContextKeyService);
|
|
308
|
+
this._outputFocus = NOTEBOOK_OUTPUT_FOCUSED.bindTo(this.scopedContextKeyService);
|
|
309
|
+
this._outputInputFocus = NOTEBOOK_OUPTUT_INPUT_FOCUSED.bindTo(this.scopedContextKeyService);
|
|
310
|
+
this._editorEditable = NOTEBOOK_EDITOR_EDITABLE.bindTo(this.scopedContextKeyService);
|
|
311
|
+
this._cursorNavMode = NOTEBOOK_CURSOR_NAVIGATION_MODE.bindTo(this.scopedContextKeyService);
|
|
312
|
+
this._editorEditable.set(!creationOptions.isReadOnly);
|
|
313
|
+
let contributions;
|
|
314
|
+
if (Array.isArray(this.creationOptions.contributions)) {
|
|
315
|
+
contributions = this.creationOptions.contributions;
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
contributions = NotebookEditorExtensionsRegistry.getEditorContributions();
|
|
319
|
+
}
|
|
320
|
+
for (const desc of contributions) {
|
|
321
|
+
let contribution;
|
|
322
|
+
try {
|
|
323
|
+
contribution = this.instantiationService.createInstance(desc.ctor, this);
|
|
324
|
+
}
|
|
325
|
+
catch (err) {
|
|
326
|
+
onUnexpectedError(err);
|
|
327
|
+
}
|
|
328
|
+
if (contribution) {
|
|
329
|
+
if (!( this._contributions.has(desc.id))) {
|
|
330
|
+
this._contributions.set(desc.id, contribution);
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
contribution.dispose();
|
|
334
|
+
throw new Error(`DUPLICATE notebook editor contribution: '${desc.id}'`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
this._updateForNotebookConfiguration();
|
|
339
|
+
}
|
|
340
|
+
_debug(...args) {
|
|
341
|
+
if (!this._debugFlag) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
notebookDebug(...args);
|
|
345
|
+
}
|
|
346
|
+
getId() {
|
|
347
|
+
return this._uuid;
|
|
348
|
+
}
|
|
349
|
+
getViewModel() {
|
|
350
|
+
return this.viewModel;
|
|
351
|
+
}
|
|
352
|
+
getLength() {
|
|
353
|
+
return this.viewModel?.length ?? 0;
|
|
354
|
+
}
|
|
355
|
+
getSelections() {
|
|
356
|
+
return this.viewModel?.getSelections() ?? [];
|
|
357
|
+
}
|
|
358
|
+
setSelections(selections) {
|
|
359
|
+
if (!this.viewModel) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const focus = this.viewModel.getFocus();
|
|
363
|
+
this.viewModel.updateSelectionsState({
|
|
364
|
+
kind: SelectionStateType.Index,
|
|
365
|
+
focus: focus,
|
|
366
|
+
selections: selections
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
getFocus() {
|
|
370
|
+
return this.viewModel?.getFocus() ?? { start: 0, end: 0 };
|
|
371
|
+
}
|
|
372
|
+
setFocus(focus) {
|
|
373
|
+
if (!this.viewModel) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
const selections = this.viewModel.getSelections();
|
|
377
|
+
this.viewModel.updateSelectionsState({
|
|
378
|
+
kind: SelectionStateType.Index,
|
|
379
|
+
focus: focus,
|
|
380
|
+
selections: selections
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
getSelectionViewModels() {
|
|
384
|
+
if (!this.viewModel) {
|
|
385
|
+
return [];
|
|
386
|
+
}
|
|
387
|
+
const cellsSet = ( new Set());
|
|
388
|
+
return ( this.viewModel.getSelections().map(range => this.viewModel.viewCells.slice(range.start, range.end))).reduce((a, b) => {
|
|
389
|
+
b.forEach(cell => {
|
|
390
|
+
if (!( cellsSet.has(cell.handle))) {
|
|
391
|
+
cellsSet.add(cell.handle);
|
|
392
|
+
a.push(cell);
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
return a;
|
|
396
|
+
}, []);
|
|
397
|
+
}
|
|
398
|
+
hasModel() {
|
|
399
|
+
return !!this._notebookViewModel;
|
|
400
|
+
}
|
|
401
|
+
showProgress() {
|
|
402
|
+
this._currentProgress = this.editorProgressService.show(true);
|
|
403
|
+
}
|
|
404
|
+
hideProgress() {
|
|
405
|
+
if (this._currentProgress) {
|
|
406
|
+
this._currentProgress.done();
|
|
407
|
+
this._currentProgress = undefined;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
getBaseCellEditorOptions(language) {
|
|
411
|
+
const existingOptions = this._baseCellEditorOptions.get(language);
|
|
412
|
+
if (existingOptions) {
|
|
413
|
+
return existingOptions;
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
const options = ( new BaseCellEditorOptions(this, this.notebookOptions, this.configurationService, language));
|
|
417
|
+
this._baseCellEditorOptions.set(language, options);
|
|
418
|
+
return options;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
_updateForNotebookConfiguration() {
|
|
422
|
+
if (!this._overlayContainer) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
this._overlayContainer.classList.remove('cell-title-toolbar-left');
|
|
426
|
+
this._overlayContainer.classList.remove('cell-title-toolbar-right');
|
|
427
|
+
this._overlayContainer.classList.remove('cell-title-toolbar-hidden');
|
|
428
|
+
const cellToolbarLocation = this._notebookOptions.computeCellToolbarLocation(this.viewModel?.viewType);
|
|
429
|
+
this._overlayContainer.classList.add(`cell-title-toolbar-${cellToolbarLocation}`);
|
|
430
|
+
const cellToolbarInteraction = this._notebookOptions.getDisplayOptions().cellToolbarInteraction;
|
|
431
|
+
let cellToolbarInteractionState = 'hover';
|
|
432
|
+
this._overlayContainer.classList.remove('cell-toolbar-hover');
|
|
433
|
+
this._overlayContainer.classList.remove('cell-toolbar-click');
|
|
434
|
+
if (cellToolbarInteraction === 'hover' || cellToolbarInteraction === 'click') {
|
|
435
|
+
cellToolbarInteractionState = cellToolbarInteraction;
|
|
436
|
+
}
|
|
437
|
+
this._overlayContainer.classList.add(`cell-toolbar-${cellToolbarInteractionState}`);
|
|
438
|
+
}
|
|
439
|
+
_generateFontInfo() {
|
|
440
|
+
const editorOptions = this.configurationService.getValue('editor');
|
|
441
|
+
this._fontInfo = FontMeasurements.readFontInfo(BareFontInfo.createFromRawSettings(editorOptions, PixelRatio.value));
|
|
442
|
+
}
|
|
443
|
+
_createBody(parent) {
|
|
444
|
+
this._notebookTopToolbarContainer = document.createElement('div');
|
|
445
|
+
this._notebookTopToolbarContainer.classList.add('notebook-toolbar-container');
|
|
446
|
+
this._notebookTopToolbarContainer.style.display = 'none';
|
|
447
|
+
dom.append(parent, this._notebookTopToolbarContainer);
|
|
448
|
+
this._notebookStickyScrollContainer = document.createElement('div');
|
|
449
|
+
this._notebookStickyScrollContainer.classList.add('notebook-sticky-scroll-container');
|
|
450
|
+
dom.append(parent, this._notebookStickyScrollContainer);
|
|
451
|
+
this._body = document.createElement('div');
|
|
452
|
+
dom.append(parent, this._body);
|
|
453
|
+
this._body.classList.add('cell-list-container');
|
|
454
|
+
this._createLayoutStyles();
|
|
455
|
+
this._createCellList();
|
|
456
|
+
this._notebookOverviewRulerContainer = document.createElement('div');
|
|
457
|
+
this._notebookOverviewRulerContainer.classList.add('notebook-overview-ruler-container');
|
|
458
|
+
this._list.scrollableElement.appendChild(this._notebookOverviewRulerContainer);
|
|
459
|
+
this._registerNotebookOverviewRuler();
|
|
460
|
+
this._overflowContainer = document.createElement('div');
|
|
461
|
+
this._overflowContainer.classList.add('notebook-overflow-widget-container', 'monaco-editor');
|
|
462
|
+
dom.append(parent, this._overflowContainer);
|
|
463
|
+
}
|
|
464
|
+
_generateFontFamily() {
|
|
465
|
+
return this._fontInfo?.fontFamily ?? `"SF Mono", Monaco, Menlo, Consolas, "Ubuntu Mono", "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace`;
|
|
466
|
+
}
|
|
467
|
+
_createLayoutStyles() {
|
|
468
|
+
this._styleElement = dom.createStyleSheet(this._body);
|
|
469
|
+
const { cellRightMargin, cellTopMargin, cellRunGutter, cellBottomMargin, codeCellLeftMargin, markdownCellGutter, markdownCellLeftMargin, markdownCellBottomMargin, markdownCellTopMargin, collapsedIndicatorHeight, focusIndicator, insertToolbarPosition, outputFontSize, focusIndicatorLeftMargin, focusIndicatorGap } = this._notebookOptions.getLayoutConfiguration();
|
|
470
|
+
const { insertToolbarAlignment, compactView, fontSize } = this._notebookOptions.getDisplayOptions();
|
|
471
|
+
const getCellEditorContainerLeftMargin = this._notebookOptions.getCellEditorContainerLeftMargin();
|
|
472
|
+
const { bottomToolbarGap, bottomToolbarHeight } = this._notebookOptions.computeBottomToolbarDimensions(this.viewModel?.viewType);
|
|
473
|
+
const styleSheets = [];
|
|
474
|
+
if (!this._fontInfo) {
|
|
475
|
+
this._generateFontInfo();
|
|
476
|
+
}
|
|
477
|
+
const fontFamily = this._generateFontFamily();
|
|
478
|
+
styleSheets.push(`
|
|
479
|
+
.notebook-editor {
|
|
480
|
+
--notebook-cell-output-font-size: ${outputFontSize}px;
|
|
481
|
+
--notebook-cell-input-preview-font-size: ${fontSize}px;
|
|
482
|
+
--notebook-cell-input-preview-font-family: ${fontFamily};
|
|
483
|
+
}
|
|
484
|
+
`);
|
|
485
|
+
if (compactView) {
|
|
486
|
+
styleSheets.push(`.notebookOverlay .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .markdown-cell-row div.cell.code { margin-left: ${getCellEditorContainerLeftMargin}px; }`);
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
styleSheets.push(`.notebookOverlay .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .markdown-cell-row div.cell.code { margin-left: ${codeCellLeftMargin}px; }`);
|
|
490
|
+
}
|
|
491
|
+
if (focusIndicator === 'border') {
|
|
492
|
+
styleSheets.push(`
|
|
493
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row .cell-focus-indicator-top:before,
|
|
494
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row .cell-focus-indicator-bottom:before,
|
|
495
|
+
.monaco-workbench .notebookOverlay .monaco-list .markdown-cell-row .cell-inner-container:before,
|
|
496
|
+
.monaco-workbench .notebookOverlay .monaco-list .markdown-cell-row .cell-inner-container:after {
|
|
497
|
+
content: "";
|
|
498
|
+
position: absolute;
|
|
499
|
+
width: 100%;
|
|
500
|
+
height: 1px;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row .cell-focus-indicator-left:before,
|
|
504
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row .cell-focus-indicator-right:before {
|
|
505
|
+
content: "";
|
|
506
|
+
position: absolute;
|
|
507
|
+
width: 1px;
|
|
508
|
+
height: 100%;
|
|
509
|
+
z-index: 10;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/* top border */
|
|
513
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row .cell-focus-indicator-top:before {
|
|
514
|
+
border-top: 1px solid transparent;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/* left border */
|
|
518
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row .cell-focus-indicator-left:before {
|
|
519
|
+
border-left: 1px solid transparent;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/* bottom border */
|
|
523
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row .cell-focus-indicator-bottom:before {
|
|
524
|
+
border-bottom: 1px solid transparent;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/* right border */
|
|
528
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row .cell-focus-indicator-right:before {
|
|
529
|
+
border-right: 1px solid transparent;
|
|
530
|
+
}
|
|
531
|
+
`);
|
|
532
|
+
styleSheets.push(`
|
|
533
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row.code-cell-row.focused .cell-focus-indicator-left:before,
|
|
534
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row.code-cell-row.focused .cell-focus-indicator-right:before,
|
|
535
|
+
.monaco-workbench .notebookOverlay .monaco-list.selection-multiple .monaco-list-row.code-cell-row.selected .cell-focus-indicator-left:before,
|
|
536
|
+
.monaco-workbench .notebookOverlay .monaco-list.selection-multiple .monaco-list-row.code-cell-row.selected .cell-focus-indicator-right:before {
|
|
537
|
+
top: -${cellTopMargin}px; height: calc(100% + ${cellTopMargin + cellBottomMargin}px)
|
|
538
|
+
}`);
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
styleSheets.push(`
|
|
542
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row .cell-focus-indicator-left .codeOutput-focus-indicator {
|
|
543
|
+
border-left: 3px solid transparent;
|
|
544
|
+
border-radius: 4px;
|
|
545
|
+
width: 0px;
|
|
546
|
+
margin-left: ${focusIndicatorLeftMargin}px;
|
|
547
|
+
border-color: var(--vscode-notebook-inactiveFocusedCellBorder) !important;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row.focused .cell-focus-indicator-left .codeOutput-focus-indicator-container,
|
|
551
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row .cell-output-hover .cell-focus-indicator-left .codeOutput-focus-indicator-container,
|
|
552
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row .markdown-cell-hover .cell-focus-indicator-left .codeOutput-focus-indicator-container,
|
|
553
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row:hover .cell-focus-indicator-left .codeOutput-focus-indicator-container {
|
|
554
|
+
display: block;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row .cell-focus-indicator-left .codeOutput-focus-indicator-container:hover .codeOutput-focus-indicator {
|
|
558
|
+
border-left: 5px solid transparent;
|
|
559
|
+
margin-left: ${focusIndicatorLeftMargin - 1}px;
|
|
560
|
+
}
|
|
561
|
+
`);
|
|
562
|
+
styleSheets.push(`
|
|
563
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row.focused .cell-inner-container.cell-output-focus .cell-focus-indicator-left .codeOutput-focus-indicator,
|
|
564
|
+
.monaco-workbench .notebookOverlay .monaco-list:focus-within .monaco-list-row.focused .cell-inner-container .cell-focus-indicator-left .codeOutput-focus-indicator {
|
|
565
|
+
border-color: var(--vscode-notebook-focusedCellBorder) !important;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
.monaco-workbench .notebookOverlay .monaco-list .monaco-list-row .cell-inner-container .cell-focus-indicator-left .output-focus-indicator {
|
|
569
|
+
margin-top: ${focusIndicatorGap}px;
|
|
570
|
+
}
|
|
571
|
+
`);
|
|
572
|
+
}
|
|
573
|
+
if (insertToolbarPosition === 'betweenCells' || insertToolbarPosition === 'both') {
|
|
574
|
+
styleSheets.push(`.monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .cell-bottom-toolbar-container { display: flex; }`);
|
|
575
|
+
styleSheets.push(`.monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .cell-list-top-cell-toolbar-container { display: flex; }`);
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
styleSheets.push(`.monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .cell-bottom-toolbar-container { display: none; }`);
|
|
579
|
+
styleSheets.push(`.monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .cell-list-top-cell-toolbar-container { display: none; }`);
|
|
580
|
+
}
|
|
581
|
+
if (insertToolbarAlignment === 'left') {
|
|
582
|
+
styleSheets.push(`
|
|
583
|
+
.monaco-workbench .notebookOverlay .cell-list-top-cell-toolbar-container .action-item:first-child,
|
|
584
|
+
.monaco-workbench .notebookOverlay .cell-list-top-cell-toolbar-container .action-item:first-child, .monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .cell-bottom-toolbar-container .action-item:first-child {
|
|
585
|
+
margin-right: 0px !important;
|
|
586
|
+
}`);
|
|
587
|
+
styleSheets.push(`
|
|
588
|
+
.monaco-workbench .notebookOverlay .cell-list-top-cell-toolbar-container .monaco-toolbar .action-label,
|
|
589
|
+
.monaco-workbench .notebookOverlay .cell-list-top-cell-toolbar-container .monaco-toolbar .action-label, .monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .cell-bottom-toolbar-container .monaco-toolbar .action-label {
|
|
590
|
+
padding: 0px !important;
|
|
591
|
+
justify-content: center;
|
|
592
|
+
border-radius: 4px;
|
|
593
|
+
}`);
|
|
594
|
+
styleSheets.push(`
|
|
595
|
+
.monaco-workbench .notebookOverlay .cell-list-top-cell-toolbar-container,
|
|
596
|
+
.monaco-workbench .notebookOverlay .cell-list-top-cell-toolbar-container, .monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .cell-bottom-toolbar-container {
|
|
597
|
+
align-items: flex-start;
|
|
598
|
+
justify-content: left;
|
|
599
|
+
margin: 0 16px 0 ${8 + codeCellLeftMargin}px;
|
|
600
|
+
}`);
|
|
601
|
+
styleSheets.push(`
|
|
602
|
+
.monaco-workbench .notebookOverlay .cell-list-top-cell-toolbar-container,
|
|
603
|
+
.notebookOverlay .cell-bottom-toolbar-container .action-item {
|
|
604
|
+
border: 0px;
|
|
605
|
+
}`);
|
|
606
|
+
}
|
|
607
|
+
styleSheets.push(`.notebookOverlay .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .code-cell-row div.cell.code { margin-left: ${getCellEditorContainerLeftMargin}px; }`);
|
|
608
|
+
styleSheets.push(`.notebookOverlay .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row div.cell { margin-right: ${cellRightMargin}px; }`);
|
|
609
|
+
styleSheets.push(`.notebookOverlay .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row > .cell-inner-container { padding-top: ${cellTopMargin}px; }`);
|
|
610
|
+
styleSheets.push(`.notebookOverlay .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .markdown-cell-row > .cell-inner-container { padding-bottom: ${markdownCellBottomMargin}px; padding-top: ${markdownCellTopMargin}px; }`);
|
|
611
|
+
styleSheets.push(`.notebookOverlay .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .markdown-cell-row > .cell-inner-container.webview-backed-markdown-cell { padding: 0; }`);
|
|
612
|
+
styleSheets.push(`.notebookOverlay .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .markdown-cell-row > .webview-backed-markdown-cell.markdown-cell-edit-mode .cell.code { padding-bottom: ${markdownCellBottomMargin}px; padding-top: ${markdownCellTopMargin}px; }`);
|
|
613
|
+
styleSheets.push(`.notebookOverlay .output { margin: 0px ${cellRightMargin}px 0px ${getCellEditorContainerLeftMargin}px; }`);
|
|
614
|
+
styleSheets.push(`.notebookOverlay .output { width: calc(100% - ${getCellEditorContainerLeftMargin + cellRightMargin}px); }`);
|
|
615
|
+
styleSheets.push(`.notebookOverlay .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .cell-comment-container { left: ${getCellEditorContainerLeftMargin}px; }`);
|
|
616
|
+
styleSheets.push(`.notebookOverlay .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .cell-comment-container { width: calc(100% - ${getCellEditorContainerLeftMargin + cellRightMargin}px); }`);
|
|
617
|
+
styleSheets.push(`.monaco-workbench .notebookOverlay .output .output-collapse-container .expandButton { left: -${cellRunGutter}px; }`);
|
|
618
|
+
styleSheets.push(`.monaco-workbench .notebookOverlay .output .output-collapse-container .expandButton {
|
|
619
|
+
position: absolute;
|
|
620
|
+
width: ${cellRunGutter}px;
|
|
621
|
+
padding: 6px 0px;
|
|
622
|
+
}`);
|
|
623
|
+
styleSheets.push(`.notebookOverlay .output-show-more-container { margin: 0px ${cellRightMargin}px 0px ${getCellEditorContainerLeftMargin}px; }`);
|
|
624
|
+
styleSheets.push(`.notebookOverlay .output-show-more-container { width: calc(100% - ${getCellEditorContainerLeftMargin + cellRightMargin}px); }`);
|
|
625
|
+
styleSheets.push(`.notebookOverlay .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row div.cell.markdown { padding-left: ${cellRunGutter}px; }`);
|
|
626
|
+
styleSheets.push(`.monaco-workbench .notebookOverlay > .cell-list-container .notebook-folding-indicator { left: ${(markdownCellGutter - 20) / 2 + markdownCellLeftMargin}px; }`);
|
|
627
|
+
styleSheets.push(`.notebookOverlay > .cell-list-container .notebook-folded-hint { left: ${markdownCellGutter + markdownCellLeftMargin + 8}px; }`);
|
|
628
|
+
styleSheets.push(`.notebookOverlay .monaco-list .monaco-list-row :not(.webview-backed-markdown-cell) .cell-focus-indicator-top { height: ${cellTopMargin}px; }`);
|
|
629
|
+
styleSheets.push(`.notebookOverlay .monaco-list .monaco-list-row .cell-focus-indicator-side { bottom: ${bottomToolbarGap}px; }`);
|
|
630
|
+
styleSheets.push(`.notebookOverlay .monaco-list .monaco-list-row.code-cell-row .cell-focus-indicator-left { width: ${getCellEditorContainerLeftMargin}px; }`);
|
|
631
|
+
styleSheets.push(`.notebookOverlay .monaco-list .monaco-list-row.markdown-cell-row .cell-focus-indicator-left { width: ${codeCellLeftMargin}px; }`);
|
|
632
|
+
styleSheets.push(`.notebookOverlay .monaco-list .monaco-list-row .cell-focus-indicator.cell-focus-indicator-right { width: ${cellRightMargin}px; }`);
|
|
633
|
+
styleSheets.push(`.notebookOverlay .monaco-list .monaco-list-row .cell-focus-indicator-bottom { height: ${cellBottomMargin}px; }`);
|
|
634
|
+
styleSheets.push(`.notebookOverlay .monaco-list .monaco-list-row .cell-shadow-container-bottom { top: ${cellBottomMargin}px; }`);
|
|
635
|
+
styleSheets.push(`
|
|
636
|
+
.notebookOverlay .monaco-list .monaco-list-row:has(+ .monaco-list-row.selected) .cell-focus-indicator-bottom {
|
|
637
|
+
height: ${bottomToolbarGap + cellBottomMargin}px;
|
|
638
|
+
}
|
|
639
|
+
`);
|
|
640
|
+
styleSheets.push(`
|
|
641
|
+
.monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .input-collapse-container .cell-collapse-preview {
|
|
642
|
+
line-height: ${collapsedIndicatorHeight}px;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
.monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .input-collapse-container .cell-collapse-preview .monaco-tokenized-source {
|
|
646
|
+
max-height: ${collapsedIndicatorHeight}px;
|
|
647
|
+
}
|
|
648
|
+
`);
|
|
649
|
+
styleSheets.push(`.monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .cell-bottom-toolbar-container .monaco-toolbar { height: ${bottomToolbarHeight}px }`);
|
|
650
|
+
styleSheets.push(`.monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .cell-list-top-cell-toolbar-container .monaco-toolbar { height: ${bottomToolbarHeight}px }`);
|
|
651
|
+
styleSheets.push(`.monaco-workbench .notebookOverlay.cell-title-toolbar-right > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .cell-title-toolbar {
|
|
652
|
+
right: ${cellRightMargin + 26}px;
|
|
653
|
+
}
|
|
654
|
+
.monaco-workbench .notebookOverlay.cell-title-toolbar-left > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .cell-title-toolbar {
|
|
655
|
+
left: ${getCellEditorContainerLeftMargin + 16}px;
|
|
656
|
+
}
|
|
657
|
+
.monaco-workbench .notebookOverlay.cell-title-toolbar-hidden > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .cell-title-toolbar {
|
|
658
|
+
display: none;
|
|
659
|
+
}`);
|
|
660
|
+
styleSheets.push(`
|
|
661
|
+
.monaco-workbench .notebookOverlay .output > div.foreground.output-inner-container {
|
|
662
|
+
padding: ${OutputInnerContainerTopPadding}px 8px;
|
|
663
|
+
}
|
|
664
|
+
.monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .output-collapse-container {
|
|
665
|
+
padding: ${OutputInnerContainerTopPadding}px 8px;
|
|
666
|
+
}
|
|
667
|
+
`);
|
|
668
|
+
styleSheets.push(`
|
|
669
|
+
.monaco-workbench .notebookOverlay .cell-chat-part {
|
|
670
|
+
margin: 0 ${cellRightMargin}px 6px 6px;
|
|
671
|
+
}
|
|
672
|
+
`);
|
|
673
|
+
this._styleElement.textContent = styleSheets.join('\n');
|
|
674
|
+
}
|
|
675
|
+
_createCellList() {
|
|
676
|
+
this._body.classList.add('cell-list-container');
|
|
677
|
+
this._dndController = this._register(( new CellDragAndDropController(this, this._body)));
|
|
678
|
+
const getScopedContextKeyService = (container) => this._list.contextKeyService.createScoped(container);
|
|
679
|
+
const renderers = [
|
|
680
|
+
this.instantiationService.createInstance(CodeCellRenderer, this, this._renderedEditors, this._dndController, getScopedContextKeyService),
|
|
681
|
+
this.instantiationService.createInstance(MarkupCellRenderer, this, this._dndController, this._renderedEditors, getScopedContextKeyService),
|
|
682
|
+
];
|
|
683
|
+
renderers.forEach(renderer => {
|
|
684
|
+
this._register(renderer);
|
|
685
|
+
});
|
|
686
|
+
this._listDelegate = this.instantiationService.createInstance(NotebookCellListDelegate);
|
|
687
|
+
this._register(this._listDelegate);
|
|
688
|
+
const createNotebookAriaLabel = () => {
|
|
689
|
+
const keybinding = this.keybindingService.lookupKeybinding("editor.action.accessibilityHelp" )?.getLabel();
|
|
690
|
+
if (this.configurationService.getValue("accessibility.verbosity.notebook" )) {
|
|
691
|
+
return keybinding
|
|
692
|
+
? ( nls.localizeWithPath(
|
|
693
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
694
|
+
'notebookTreeAriaLabelHelp',
|
|
695
|
+
"Notebook\nUse {0} for accessibility help",
|
|
696
|
+
keybinding
|
|
697
|
+
))
|
|
698
|
+
: ( nls.localizeWithPath(
|
|
699
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
700
|
+
'notebookTreeAriaLabelHelpNoKb',
|
|
701
|
+
"Notebook\nRun the Open Accessibility Help command for more information",
|
|
702
|
+
keybinding
|
|
703
|
+
));
|
|
704
|
+
}
|
|
705
|
+
return ( nls.localizeWithPath(
|
|
706
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
707
|
+
'notebookTreeAriaLabel',
|
|
708
|
+
"Notebook"
|
|
709
|
+
));
|
|
710
|
+
};
|
|
711
|
+
this._list = this.instantiationService.createInstance(NotebookCellList, 'NotebookCellList', this._body, this._viewContext.notebookOptions, this._listDelegate, renderers, this.scopedContextKeyService, {
|
|
712
|
+
setRowLineHeight: false,
|
|
713
|
+
setRowHeight: false,
|
|
714
|
+
supportDynamicHeights: true,
|
|
715
|
+
horizontalScrolling: false,
|
|
716
|
+
keyboardSupport: false,
|
|
717
|
+
mouseSupport: true,
|
|
718
|
+
multipleSelectionSupport: true,
|
|
719
|
+
selectionNavigation: true,
|
|
720
|
+
typeNavigationEnabled: true,
|
|
721
|
+
paddingTop: this._notebookOptions.computeTopInsertToolbarHeight(this.viewModel?.viewType),
|
|
722
|
+
paddingBottom: 0,
|
|
723
|
+
transformOptimization: false,
|
|
724
|
+
initialSize: this._dimension,
|
|
725
|
+
styleController: (_suffix) => { return this._list; },
|
|
726
|
+
overrideStyles: {
|
|
727
|
+
listBackground: notebookEditorBackground,
|
|
728
|
+
listActiveSelectionBackground: notebookEditorBackground,
|
|
729
|
+
listActiveSelectionForeground: foreground,
|
|
730
|
+
listFocusAndSelectionBackground: notebookEditorBackground,
|
|
731
|
+
listFocusAndSelectionForeground: foreground,
|
|
732
|
+
listFocusBackground: notebookEditorBackground,
|
|
733
|
+
listFocusForeground: foreground,
|
|
734
|
+
listHoverForeground: foreground,
|
|
735
|
+
listHoverBackground: notebookEditorBackground,
|
|
736
|
+
listHoverOutline: focusBorder,
|
|
737
|
+
listFocusOutline: focusBorder,
|
|
738
|
+
listInactiveSelectionBackground: notebookEditorBackground,
|
|
739
|
+
listInactiveSelectionForeground: foreground,
|
|
740
|
+
listInactiveFocusBackground: notebookEditorBackground,
|
|
741
|
+
listInactiveFocusOutline: notebookEditorBackground,
|
|
742
|
+
},
|
|
743
|
+
accessibilityProvider: {
|
|
744
|
+
getAriaLabel: (element) => {
|
|
745
|
+
if (!this.viewModel) {
|
|
746
|
+
return '';
|
|
747
|
+
}
|
|
748
|
+
const index = this.viewModel.getCellIndex(element);
|
|
749
|
+
if (index >= 0) {
|
|
750
|
+
return `Cell ${index}, ${element.cellKind === CellKind.Markup ? 'markdown' : 'code'} cell`;
|
|
751
|
+
}
|
|
752
|
+
return '';
|
|
753
|
+
},
|
|
754
|
+
getWidgetAriaLabel: createNotebookAriaLabel
|
|
755
|
+
},
|
|
756
|
+
});
|
|
757
|
+
this._dndController.setList(this._list);
|
|
758
|
+
this._register(this._list);
|
|
759
|
+
this._listViewInfoAccessor = ( new ListViewInfoAccessor(this._list));
|
|
760
|
+
this._register(this._listViewInfoAccessor);
|
|
761
|
+
this._register(combinedDisposable(...renderers));
|
|
762
|
+
this._listTopCellToolbar = this._register(this.instantiationService.createInstance(ListTopCellToolbar, this, this.scopedContextKeyService, this._list.rowsContainer));
|
|
763
|
+
this._webviewTransparentCover = dom.append(this._list.rowsContainer, $('.webview-cover'));
|
|
764
|
+
this._webviewTransparentCover.style.display = 'none';
|
|
765
|
+
this._register(dom.addStandardDisposableGenericMouseDownListener(this._overlayContainer, (e) => {
|
|
766
|
+
if (e.target.classList.contains('slider') && this._webviewTransparentCover) {
|
|
767
|
+
this._webviewTransparentCover.style.display = 'block';
|
|
768
|
+
}
|
|
769
|
+
}));
|
|
770
|
+
this._register(dom.addStandardDisposableGenericMouseUpListener(this._overlayContainer, () => {
|
|
771
|
+
if (this._webviewTransparentCover) {
|
|
772
|
+
this._webviewTransparentCover.style.display = 'none';
|
|
773
|
+
}
|
|
774
|
+
}));
|
|
775
|
+
this._register(this._list.onMouseDown(e => {
|
|
776
|
+
if (e.element) {
|
|
777
|
+
this._onMouseDown.fire({ event: e.browserEvent, target: e.element });
|
|
778
|
+
}
|
|
779
|
+
}));
|
|
780
|
+
this._register(this._list.onMouseUp(e => {
|
|
781
|
+
if (e.element) {
|
|
782
|
+
this._onMouseUp.fire({ event: e.browserEvent, target: e.element });
|
|
783
|
+
}
|
|
784
|
+
}));
|
|
785
|
+
this._register(this._list.onDidChangeFocus(_e => {
|
|
786
|
+
this._onDidChangeActiveEditor.fire(this);
|
|
787
|
+
this._onDidChangeActiveCell.fire();
|
|
788
|
+
this._cursorNavMode.set(false);
|
|
789
|
+
}));
|
|
790
|
+
this._register(this._list.onContextMenu(e => {
|
|
791
|
+
this.showListContextMenu(e);
|
|
792
|
+
}));
|
|
793
|
+
this._register(this._list.onDidChangeVisibleRanges(() => {
|
|
794
|
+
this._onDidChangeVisibleRanges.fire();
|
|
795
|
+
}));
|
|
796
|
+
this._register(this._list.onDidScroll((e) => {
|
|
797
|
+
this._onDidScroll.fire();
|
|
798
|
+
if (e.scrollTop !== e.oldScrollTop) {
|
|
799
|
+
this.clearActiveCellWidgets();
|
|
800
|
+
}
|
|
801
|
+
}));
|
|
802
|
+
this._focusTracker = this._register(dom.trackFocus(this.getDomNode()));
|
|
803
|
+
this._register(this._focusTracker.onDidBlur(() => {
|
|
804
|
+
this._editorFocus.set(false);
|
|
805
|
+
this.viewModel?.setEditorFocus(false);
|
|
806
|
+
this._onDidBlurEmitter.fire();
|
|
807
|
+
}));
|
|
808
|
+
this._register(this._focusTracker.onDidFocus(() => {
|
|
809
|
+
this._editorFocus.set(true);
|
|
810
|
+
this.viewModel?.setEditorFocus(true);
|
|
811
|
+
this._onDidFocusEmitter.fire();
|
|
812
|
+
}));
|
|
813
|
+
this._registerNotebookActionsToolbar();
|
|
814
|
+
this._registerNotebookStickyScroll();
|
|
815
|
+
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
|
816
|
+
if (e.affectsConfiguration("accessibility.verbosity.notebook" )) {
|
|
817
|
+
this._list.ariaLabel = createNotebookAriaLabel();
|
|
818
|
+
}
|
|
819
|
+
}));
|
|
820
|
+
}
|
|
821
|
+
showListContextMenu(e) {
|
|
822
|
+
this.contextMenuService.showContextMenu({
|
|
823
|
+
menuId: MenuId.NotebookCellTitle,
|
|
824
|
+
contextKeyService: this.scopedContextKeyService,
|
|
825
|
+
getAnchor: () => e.anchor
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
_registerNotebookOverviewRuler() {
|
|
829
|
+
this._notebookOverviewRuler = this._register(this.instantiationService.createInstance(NotebookOverviewRuler, this, this._notebookOverviewRulerContainer));
|
|
830
|
+
}
|
|
831
|
+
_registerNotebookActionsToolbar() {
|
|
832
|
+
this._notebookTopToolbar = this._register(this.instantiationService.createInstance(NotebookEditorWorkbenchToolbar, this, this.scopedContextKeyService, this._notebookOptions, this._notebookTopToolbarContainer));
|
|
833
|
+
this._register(this._notebookTopToolbar.onDidChangeVisibility(() => {
|
|
834
|
+
if (this._dimension && this._isVisible) {
|
|
835
|
+
this.layout(this._dimension);
|
|
836
|
+
}
|
|
837
|
+
}));
|
|
838
|
+
}
|
|
839
|
+
_registerNotebookStickyScroll() {
|
|
840
|
+
this._notebookStickyScroll = this._register(this.instantiationService.createInstance(NotebookStickyScroll, this._notebookStickyScrollContainer, this, this._notebookOutline, this._list));
|
|
841
|
+
}
|
|
842
|
+
_updateOutputRenderers() {
|
|
843
|
+
if (!this.viewModel || !this._webview) {
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
this._webview.updateOutputRenderers();
|
|
847
|
+
this.viewModel.viewCells.forEach(cell => {
|
|
848
|
+
cell.outputsViewModels.forEach(output => {
|
|
849
|
+
if (output.pickedMimeType?.rendererId === RENDERER_NOT_AVAILABLE) {
|
|
850
|
+
output.resetRenderer();
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
getDomNode() {
|
|
856
|
+
return this._overlayContainer;
|
|
857
|
+
}
|
|
858
|
+
getOverflowContainerDomNode() {
|
|
859
|
+
return this._overflowContainer;
|
|
860
|
+
}
|
|
861
|
+
getInnerWebview() {
|
|
862
|
+
return this._webview?.webview;
|
|
863
|
+
}
|
|
864
|
+
setEditorProgressService(editorProgressService) {
|
|
865
|
+
this.editorProgressService = editorProgressService;
|
|
866
|
+
}
|
|
867
|
+
setParentContextKeyService(parentContextKeyService) {
|
|
868
|
+
this.scopedContextKeyService.updateParent(parentContextKeyService);
|
|
869
|
+
}
|
|
870
|
+
async setModel(textModel, viewState, perf) {
|
|
871
|
+
if (this.viewModel === undefined || !this.viewModel.equal(textModel)) {
|
|
872
|
+
const oldTopInsertToolbarHeight = this._notebookOptions.computeTopInsertToolbarHeight(this.viewModel?.viewType);
|
|
873
|
+
const oldBottomToolbarDimensions = this._notebookOptions.computeBottomToolbarDimensions(this.viewModel?.viewType);
|
|
874
|
+
this._detachModel();
|
|
875
|
+
await this._attachModel(textModel, viewState, perf);
|
|
876
|
+
const newTopInsertToolbarHeight = this._notebookOptions.computeTopInsertToolbarHeight(this.viewModel?.viewType);
|
|
877
|
+
const newBottomToolbarDimensions = this._notebookOptions.computeBottomToolbarDimensions(this.viewModel?.viewType);
|
|
878
|
+
if (oldTopInsertToolbarHeight !== newTopInsertToolbarHeight
|
|
879
|
+
|| oldBottomToolbarDimensions.bottomToolbarGap !== newBottomToolbarDimensions.bottomToolbarGap
|
|
880
|
+
|| oldBottomToolbarDimensions.bottomToolbarHeight !== newBottomToolbarDimensions.bottomToolbarHeight) {
|
|
881
|
+
this._styleElement?.remove();
|
|
882
|
+
this._createLayoutStyles();
|
|
883
|
+
this._webview?.updateOptions({
|
|
884
|
+
...this.notebookOptions.computeWebviewOptions(),
|
|
885
|
+
fontFamily: this._generateFontFamily()
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
this.telemetryService.publicLog2('notebook/editorOpened', {
|
|
889
|
+
scheme: textModel.uri.scheme,
|
|
890
|
+
ext: extname(textModel.uri),
|
|
891
|
+
viewType: textModel.viewType
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
else {
|
|
895
|
+
this.restoreListViewState(viewState);
|
|
896
|
+
}
|
|
897
|
+
this._restoreSelectedKernel(viewState);
|
|
898
|
+
this._loadKernelPreloads();
|
|
899
|
+
this._dndController?.clearGlobalDragState();
|
|
900
|
+
this._localStore.add(this._list.onDidChangeFocus(() => {
|
|
901
|
+
this.updateContextKeysOnFocusChange();
|
|
902
|
+
}));
|
|
903
|
+
this.updateContextKeysOnFocusChange();
|
|
904
|
+
this._backgroundMarkdownRendering();
|
|
905
|
+
}
|
|
906
|
+
_backgroundMarkdownRendering() {
|
|
907
|
+
if (this._backgroundMarkdownRenderRunning) {
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
this._backgroundMarkdownRenderRunning = true;
|
|
911
|
+
dom.runWhenWindowIdle(dom.getWindow(this.getDomNode()), (deadline) => {
|
|
912
|
+
this._backgroundMarkdownRenderingWithDeadline(deadline);
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
_backgroundMarkdownRenderingWithDeadline(deadline) {
|
|
916
|
+
const endTime = Date.now() + deadline.timeRemaining();
|
|
917
|
+
const execute = () => {
|
|
918
|
+
try {
|
|
919
|
+
this._backgroundMarkdownRenderRunning = true;
|
|
920
|
+
if (this._isDisposed) {
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
if (!this.viewModel) {
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
const firstMarkupCell = this.viewModel.viewCells.find(cell => cell.cellKind === CellKind.Markup && !this._webview?.markupPreviewMapping.has(cell.id) && !this.cellIsHidden(cell));
|
|
927
|
+
if (!firstMarkupCell) {
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
this.createMarkupPreview(firstMarkupCell);
|
|
931
|
+
}
|
|
932
|
+
finally {
|
|
933
|
+
this._backgroundMarkdownRenderRunning = false;
|
|
934
|
+
}
|
|
935
|
+
if (Date.now() < endTime) {
|
|
936
|
+
setTimeout0(execute);
|
|
937
|
+
}
|
|
938
|
+
else {
|
|
939
|
+
this._backgroundMarkdownRendering();
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
execute();
|
|
943
|
+
}
|
|
944
|
+
updateContextKeysOnFocusChange() {
|
|
945
|
+
if (!this.viewModel) {
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
const focused = this._list.getFocusedElements()[0];
|
|
949
|
+
if (focused) {
|
|
950
|
+
if (!this._cellContextKeyManager) {
|
|
951
|
+
this._cellContextKeyManager = this._localStore.add(this.instantiationService.createInstance(CellContextKeyManager, this, focused));
|
|
952
|
+
}
|
|
953
|
+
this._cellContextKeyManager.updateForElement(focused);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
async setOptions(options) {
|
|
957
|
+
if (options?.isReadOnly !== undefined) {
|
|
958
|
+
this._readOnly = options?.isReadOnly;
|
|
959
|
+
}
|
|
960
|
+
if (!this.viewModel) {
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
this.viewModel.updateOptions({ isReadOnly: this._readOnly });
|
|
964
|
+
this.notebookOptions.updateOptions(this._readOnly);
|
|
965
|
+
const cellOptions = options?.cellOptions ?? this._parseIndexedCellOptions(options);
|
|
966
|
+
if (cellOptions) {
|
|
967
|
+
const cell = this.viewModel.viewCells.find(cell => ( cell.uri.toString()) === ( cellOptions.resource.toString()));
|
|
968
|
+
if (cell) {
|
|
969
|
+
this.focusElement(cell);
|
|
970
|
+
const selection = cellOptions.options?.selection;
|
|
971
|
+
if (selection) {
|
|
972
|
+
cell.updateEditState(CellEditState.Editing, 'setOptions');
|
|
973
|
+
cell.focusMode = CellFocusMode.Editor;
|
|
974
|
+
await this.revealRangeInCenterIfOutsideViewportAsync(cell, ( new Range(
|
|
975
|
+
selection.startLineNumber,
|
|
976
|
+
selection.startColumn,
|
|
977
|
+
selection.endLineNumber || selection.startLineNumber,
|
|
978
|
+
selection.endColumn || selection.startColumn
|
|
979
|
+
)));
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
this._list.revealCell(cell, options?.cellRevealType ?? 4 );
|
|
983
|
+
}
|
|
984
|
+
const editor = this._renderedEditors.get(cell);
|
|
985
|
+
if (editor) {
|
|
986
|
+
if (cellOptions.options?.selection) {
|
|
987
|
+
const { selection } = cellOptions.options;
|
|
988
|
+
const editorSelection = ( new Range(
|
|
989
|
+
selection.startLineNumber,
|
|
990
|
+
selection.startColumn,
|
|
991
|
+
selection.endLineNumber || selection.startLineNumber,
|
|
992
|
+
selection.endColumn || selection.startColumn
|
|
993
|
+
));
|
|
994
|
+
editor.setSelection(editorSelection);
|
|
995
|
+
editor.revealPositionInCenterIfOutsideViewport({
|
|
996
|
+
lineNumber: selection.startLineNumber,
|
|
997
|
+
column: selection.startColumn
|
|
998
|
+
});
|
|
999
|
+
await this.revealRangeInCenterIfOutsideViewportAsync(cell, editorSelection);
|
|
1000
|
+
}
|
|
1001
|
+
if (!cellOptions.options?.preserveFocus) {
|
|
1002
|
+
editor.focus();
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
if (options?.cellSelections) {
|
|
1008
|
+
const focusCellIndex = options.cellSelections[0].start;
|
|
1009
|
+
const focusedCell = this.viewModel.cellAt(focusCellIndex);
|
|
1010
|
+
if (focusedCell) {
|
|
1011
|
+
this.viewModel.updateSelectionsState({
|
|
1012
|
+
kind: SelectionStateType.Index,
|
|
1013
|
+
focus: { start: focusCellIndex, end: focusCellIndex + 1 },
|
|
1014
|
+
selections: options.cellSelections
|
|
1015
|
+
});
|
|
1016
|
+
this.revealInCenterIfOutsideViewport(focusedCell);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
this._updateForOptions();
|
|
1020
|
+
this._onDidChangeOptions.fire();
|
|
1021
|
+
}
|
|
1022
|
+
_parseIndexedCellOptions(options) {
|
|
1023
|
+
if (options?.indexedCellOptions) {
|
|
1024
|
+
const cell = this.cellAt(options.indexedCellOptions.index);
|
|
1025
|
+
if (cell) {
|
|
1026
|
+
return {
|
|
1027
|
+
resource: cell.uri,
|
|
1028
|
+
options: {
|
|
1029
|
+
selection: options.indexedCellOptions.selection,
|
|
1030
|
+
preserveFocus: false
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
return undefined;
|
|
1036
|
+
}
|
|
1037
|
+
_detachModel() {
|
|
1038
|
+
this._localStore.clear();
|
|
1039
|
+
dispose(this._localCellStateListeners);
|
|
1040
|
+
this._list.detachViewModel();
|
|
1041
|
+
this.viewModel?.dispose();
|
|
1042
|
+
this.viewModel = undefined;
|
|
1043
|
+
this._webview?.dispose();
|
|
1044
|
+
this._webview?.element.remove();
|
|
1045
|
+
this._webview = null;
|
|
1046
|
+
this._list.clear();
|
|
1047
|
+
}
|
|
1048
|
+
_updateForOptions() {
|
|
1049
|
+
if (!this.viewModel) {
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
this._editorEditable.set(!this.viewModel.options.isReadOnly);
|
|
1053
|
+
this._overflowContainer.classList.toggle('notebook-editor-editable', !this.viewModel.options.isReadOnly);
|
|
1054
|
+
this.getDomNode().classList.toggle('notebook-editor-editable', !this.viewModel.options.isReadOnly);
|
|
1055
|
+
}
|
|
1056
|
+
async _resolveWebview() {
|
|
1057
|
+
if (!this.textModel) {
|
|
1058
|
+
return null;
|
|
1059
|
+
}
|
|
1060
|
+
if (this._webviewResolvePromise) {
|
|
1061
|
+
return this._webviewResolvePromise;
|
|
1062
|
+
}
|
|
1063
|
+
if (!this._webview) {
|
|
1064
|
+
this._ensureWebview(this.getId(), this.textModel.viewType, this.textModel.uri);
|
|
1065
|
+
}
|
|
1066
|
+
this._webviewResolvePromise = (async () => {
|
|
1067
|
+
if (!this._webview) {
|
|
1068
|
+
throw new Error('Notebook output webview object is not created successfully.');
|
|
1069
|
+
}
|
|
1070
|
+
await this._webview.createWebview();
|
|
1071
|
+
if (!this._webview.webview) {
|
|
1072
|
+
throw new Error('Notebook output webview element was not created successfully.');
|
|
1073
|
+
}
|
|
1074
|
+
this._localStore.add(this._webview.webview.onDidBlur(() => {
|
|
1075
|
+
this._outputFocus.set(false);
|
|
1076
|
+
this._webviewFocused = false;
|
|
1077
|
+
this.updateEditorFocus();
|
|
1078
|
+
this.updateCellFocusMode();
|
|
1079
|
+
}));
|
|
1080
|
+
this._localStore.add(this._webview.webview.onDidFocus(() => {
|
|
1081
|
+
this._outputFocus.set(true);
|
|
1082
|
+
this.updateEditorFocus();
|
|
1083
|
+
this._webviewFocused = true;
|
|
1084
|
+
}));
|
|
1085
|
+
this._localStore.add(this._webview.onMessage(e => {
|
|
1086
|
+
this._onDidReceiveMessage.fire(e);
|
|
1087
|
+
}));
|
|
1088
|
+
return this._webview;
|
|
1089
|
+
})();
|
|
1090
|
+
return this._webviewResolvePromise;
|
|
1091
|
+
}
|
|
1092
|
+
_ensureWebview(id, viewType, resource) {
|
|
1093
|
+
if (this._webview) {
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
const that = this;
|
|
1097
|
+
this._webview = this.instantiationService.createInstance(BackLayerWebView, {
|
|
1098
|
+
get creationOptions() { return that.creationOptions; },
|
|
1099
|
+
setScrollTop(scrollTop) { that._list.scrollTop = scrollTop; },
|
|
1100
|
+
triggerScroll(event) { that._list.triggerScrollFromMouseWheelEvent(event); },
|
|
1101
|
+
getCellByInfo: that.getCellByInfo.bind(that),
|
|
1102
|
+
getCellById: that._getCellById.bind(that),
|
|
1103
|
+
toggleNotebookCellSelection: that._toggleNotebookCellSelection.bind(that),
|
|
1104
|
+
focusNotebookCell: that.focusNotebookCell.bind(that),
|
|
1105
|
+
focusNextNotebookCell: that.focusNextNotebookCell.bind(that),
|
|
1106
|
+
updateOutputHeight: that._updateOutputHeight.bind(that),
|
|
1107
|
+
scheduleOutputHeightAck: that._scheduleOutputHeightAck.bind(that),
|
|
1108
|
+
updateMarkupCellHeight: that._updateMarkupCellHeight.bind(that),
|
|
1109
|
+
setMarkupCellEditState: that._setMarkupCellEditState.bind(that),
|
|
1110
|
+
didStartDragMarkupCell: that._didStartDragMarkupCell.bind(that),
|
|
1111
|
+
didDragMarkupCell: that._didDragMarkupCell.bind(that),
|
|
1112
|
+
didDropMarkupCell: that._didDropMarkupCell.bind(that),
|
|
1113
|
+
didEndDragMarkupCell: that._didEndDragMarkupCell.bind(that),
|
|
1114
|
+
didResizeOutput: that._didResizeOutput.bind(that),
|
|
1115
|
+
updatePerformanceMetadata: that._updatePerformanceMetadata.bind(that),
|
|
1116
|
+
didFocusOutputInputChange: that._didFocusOutputInputChange.bind(that),
|
|
1117
|
+
}, id, viewType, resource, {
|
|
1118
|
+
...this._notebookOptions.computeWebviewOptions(),
|
|
1119
|
+
fontFamily: this._generateFontFamily()
|
|
1120
|
+
}, this.notebookRendererMessaging.getScoped(this._uuid));
|
|
1121
|
+
this._webview.element.style.width = '100%';
|
|
1122
|
+
this._list.attachWebview(this._webview.element);
|
|
1123
|
+
}
|
|
1124
|
+
async _attachModel(textModel, viewState, perf) {
|
|
1125
|
+
this._ensureWebview(this.getId(), textModel.viewType, textModel.uri);
|
|
1126
|
+
this.viewModel = this.instantiationService.createInstance(NotebookViewModel, textModel.viewType, textModel, this._viewContext, this.getLayoutInfo(), { isReadOnly: this._readOnly });
|
|
1127
|
+
this._viewContext.eventDispatcher.emit([( new NotebookLayoutChangedEvent({ width: true, fontInfo: true }, this.getLayoutInfo()))]);
|
|
1128
|
+
this.notebookOptions.updateOptions(this._readOnly);
|
|
1129
|
+
this._updateForOptions();
|
|
1130
|
+
this._updateForNotebookConfiguration();
|
|
1131
|
+
{
|
|
1132
|
+
this.viewModel.restoreEditorViewState(viewState);
|
|
1133
|
+
const contributionsState = viewState?.contributionsState || {};
|
|
1134
|
+
for (const [id, contribution] of this._contributions) {
|
|
1135
|
+
if (typeof contribution.restoreViewState === 'function') {
|
|
1136
|
+
contribution.restoreViewState(contributionsState[id]);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
this._localStore.add(this.viewModel.onDidChangeViewCells(e => {
|
|
1141
|
+
this._onDidChangeViewCells.fire(e);
|
|
1142
|
+
}));
|
|
1143
|
+
this._localStore.add(this.viewModel.onDidChangeSelection(() => {
|
|
1144
|
+
this._onDidChangeSelection.fire();
|
|
1145
|
+
this.updateSelectedMarkdownPreviews();
|
|
1146
|
+
}));
|
|
1147
|
+
this._localStore.add(this._list.onWillScroll(e => {
|
|
1148
|
+
if (this._webview?.isResolved()) {
|
|
1149
|
+
this._webviewTransparentCover.style.transform = `translateY(${e.scrollTop})`;
|
|
1150
|
+
}
|
|
1151
|
+
}));
|
|
1152
|
+
let hasPendingChangeContentHeight = false;
|
|
1153
|
+
this._localStore.add(this._list.onDidChangeContentHeight(() => {
|
|
1154
|
+
if (hasPendingChangeContentHeight) {
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1157
|
+
hasPendingChangeContentHeight = true;
|
|
1158
|
+
this._localStore.add(dom.scheduleAtNextAnimationFrame(dom.getWindow(this.getDomNode()), () => {
|
|
1159
|
+
hasPendingChangeContentHeight = false;
|
|
1160
|
+
this._updateScrollHeight();
|
|
1161
|
+
}, 100));
|
|
1162
|
+
}));
|
|
1163
|
+
this._localStore.add(this._list.onDidRemoveOutputs(outputs => {
|
|
1164
|
+
outputs.forEach(output => this.removeInset(output));
|
|
1165
|
+
}));
|
|
1166
|
+
this._localStore.add(this._list.onDidHideOutputs(outputs => {
|
|
1167
|
+
outputs.forEach(output => this.hideInset(output));
|
|
1168
|
+
}));
|
|
1169
|
+
this._localStore.add(this._list.onDidRemoveCellsFromView(cells => {
|
|
1170
|
+
const hiddenCells = [];
|
|
1171
|
+
const deletedCells = [];
|
|
1172
|
+
for (const cell of cells) {
|
|
1173
|
+
if (cell.cellKind === CellKind.Markup) {
|
|
1174
|
+
const mdCell = cell;
|
|
1175
|
+
if (this.viewModel?.viewCells.find(cell => cell.handle === mdCell.handle)) {
|
|
1176
|
+
hiddenCells.push(mdCell);
|
|
1177
|
+
}
|
|
1178
|
+
else {
|
|
1179
|
+
deletedCells.push(mdCell);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
this.hideMarkupPreviews(hiddenCells);
|
|
1184
|
+
this.deleteMarkupPreviews(deletedCells);
|
|
1185
|
+
}));
|
|
1186
|
+
await this._warmupWithMarkdownRenderer(this.viewModel, viewState);
|
|
1187
|
+
perf?.mark('customMarkdownLoaded');
|
|
1188
|
+
this._localCellStateListeners = ( this.viewModel.viewCells.map(cell => this._bindCellListener(cell)));
|
|
1189
|
+
this._lastCellWithEditorFocus = this.viewModel.viewCells.find(viewCell => this.getActiveCell() === viewCell && viewCell.focusMode === CellFocusMode.Editor) ?? null;
|
|
1190
|
+
this._localStore.add(this.viewModel.onDidChangeViewCells((e) => {
|
|
1191
|
+
if (this._isDisposed) {
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
[...e.splices].reverse().forEach(splice => {
|
|
1195
|
+
const [start, deleted, newCells] = splice;
|
|
1196
|
+
const deletedCells = this._localCellStateListeners.splice(start, deleted, ...( newCells.map(cell => this._bindCellListener(cell))));
|
|
1197
|
+
dispose(deletedCells);
|
|
1198
|
+
});
|
|
1199
|
+
if (( e.splices.some(s => ( s[2].some(cell => cell.cellKind === CellKind.Markup))))) {
|
|
1200
|
+
this._backgroundMarkdownRendering();
|
|
1201
|
+
}
|
|
1202
|
+
}));
|
|
1203
|
+
if (this._dimension) {
|
|
1204
|
+
this._list.layout(this.getBodyHeight(this._dimension.height), this._dimension.width);
|
|
1205
|
+
}
|
|
1206
|
+
else {
|
|
1207
|
+
this._list.layout();
|
|
1208
|
+
}
|
|
1209
|
+
this._dndController?.clearGlobalDragState();
|
|
1210
|
+
this.restoreListViewState(viewState);
|
|
1211
|
+
}
|
|
1212
|
+
_bindCellListener(cell) {
|
|
1213
|
+
const store = ( new DisposableStore());
|
|
1214
|
+
store.add(cell.onDidChangeLayout(e => {
|
|
1215
|
+
if (e.totalHeight || e.outerWidth) {
|
|
1216
|
+
this.layoutNotebookCell(cell, cell.layoutInfo.totalHeight, e.context);
|
|
1217
|
+
}
|
|
1218
|
+
}));
|
|
1219
|
+
if (cell.cellKind === CellKind.Code) {
|
|
1220
|
+
store.add(cell.onDidRemoveOutputs((outputs) => {
|
|
1221
|
+
outputs.forEach(output => this.removeInset(output));
|
|
1222
|
+
}));
|
|
1223
|
+
}
|
|
1224
|
+
store.add(cell.onDidChangeState(e => {
|
|
1225
|
+
if (e.inputCollapsedChanged && cell.isInputCollapsed && cell.cellKind === CellKind.Markup) {
|
|
1226
|
+
this.hideMarkupPreviews([cell]);
|
|
1227
|
+
}
|
|
1228
|
+
if (e.outputCollapsedChanged && cell.isOutputCollapsed && cell.cellKind === CellKind.Code) {
|
|
1229
|
+
cell.outputsViewModels.forEach(output => this.hideInset(output));
|
|
1230
|
+
}
|
|
1231
|
+
if (e.focusModeChanged) {
|
|
1232
|
+
this._validateCellFocusMode(cell);
|
|
1233
|
+
}
|
|
1234
|
+
}));
|
|
1235
|
+
return store;
|
|
1236
|
+
}
|
|
1237
|
+
_validateCellFocusMode(cell) {
|
|
1238
|
+
if (cell.focusMode !== CellFocusMode.Editor) {
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1241
|
+
if (this._lastCellWithEditorFocus && this._lastCellWithEditorFocus !== cell) {
|
|
1242
|
+
this._lastCellWithEditorFocus.focusMode = CellFocusMode.Container;
|
|
1243
|
+
}
|
|
1244
|
+
this._lastCellWithEditorFocus = cell;
|
|
1245
|
+
}
|
|
1246
|
+
async _warmupWithMarkdownRenderer(viewModel, viewState) {
|
|
1247
|
+
this.logService.debug('NotebookEditorWidget', 'warmup ' + this.viewModel?.uri.toString());
|
|
1248
|
+
await this._resolveWebview();
|
|
1249
|
+
this.logService.debug('NotebookEditorWidget', 'warmup - webview resolved');
|
|
1250
|
+
this._webview.element.style.visibility = 'hidden';
|
|
1251
|
+
await this._warmupViewportMarkdownCells(viewModel, viewState);
|
|
1252
|
+
this.logService.debug('NotebookEditorWidget', 'warmup - viewport warmed up');
|
|
1253
|
+
this._list.layout(0, 0);
|
|
1254
|
+
this._list.attachViewModel(viewModel);
|
|
1255
|
+
this._list.scrollTop = viewState?.scrollPosition?.top ?? 0;
|
|
1256
|
+
this._debug('finish initial viewport warmup and view state restore.');
|
|
1257
|
+
this._webview.element.style.visibility = 'visible';
|
|
1258
|
+
this.logService.debug('NotebookEditorWidget', 'warmup - list view model attached, set to visible');
|
|
1259
|
+
this._onDidAttachViewModel.fire();
|
|
1260
|
+
}
|
|
1261
|
+
async _warmupViewportMarkdownCells(viewModel, viewState) {
|
|
1262
|
+
if (viewState && viewState.cellTotalHeights) {
|
|
1263
|
+
const totalHeightCache = viewState.cellTotalHeights;
|
|
1264
|
+
const scrollTop = viewState.scrollPosition?.top ?? 0;
|
|
1265
|
+
const scrollBottom = scrollTop + Math.max(this._dimension?.height ?? 0, 1080);
|
|
1266
|
+
let offset = 0;
|
|
1267
|
+
const requests = [];
|
|
1268
|
+
for (let i = 0; i < viewModel.length; i++) {
|
|
1269
|
+
const cell = viewModel.cellAt(i);
|
|
1270
|
+
const cellHeight = totalHeightCache[i] ?? 0;
|
|
1271
|
+
if (offset + cellHeight < scrollTop) {
|
|
1272
|
+
offset += cellHeight;
|
|
1273
|
+
continue;
|
|
1274
|
+
}
|
|
1275
|
+
if (cell.cellKind === CellKind.Markup) {
|
|
1276
|
+
requests.push([cell, offset]);
|
|
1277
|
+
}
|
|
1278
|
+
offset += cellHeight;
|
|
1279
|
+
if (offset > scrollBottom) {
|
|
1280
|
+
break;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
await this._webview.initializeMarkup(( requests.map(([model, offset]) => this.createMarkupCellInitialization(model, offset))));
|
|
1284
|
+
}
|
|
1285
|
+
else {
|
|
1286
|
+
const initRequests = ( viewModel.viewCells
|
|
1287
|
+
.filter(cell => cell.cellKind === CellKind.Markup)
|
|
1288
|
+
.slice(0, 5)
|
|
1289
|
+
.map(cell => this.createMarkupCellInitialization(cell, -10000)));
|
|
1290
|
+
await this._webview.initializeMarkup(initRequests);
|
|
1291
|
+
let offset = 0;
|
|
1292
|
+
const offsetUpdateRequests = [];
|
|
1293
|
+
const scrollBottom = Math.max(this._dimension?.height ?? 0, 1080);
|
|
1294
|
+
for (const cell of viewModel.viewCells) {
|
|
1295
|
+
if (cell.cellKind === CellKind.Markup) {
|
|
1296
|
+
offsetUpdateRequests.push({ id: cell.id, top: offset });
|
|
1297
|
+
}
|
|
1298
|
+
offset += cell.getHeight(this.getLayoutInfo().fontInfo.lineHeight);
|
|
1299
|
+
if (offset > scrollBottom) {
|
|
1300
|
+
break;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
this._webview?.updateScrollTops([], offsetUpdateRequests);
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
createMarkupCellInitialization(model, offset) {
|
|
1307
|
+
return ({
|
|
1308
|
+
mime: model.mime,
|
|
1309
|
+
cellId: model.id,
|
|
1310
|
+
cellHandle: model.handle,
|
|
1311
|
+
content: model.getText(),
|
|
1312
|
+
offset: offset,
|
|
1313
|
+
visible: false,
|
|
1314
|
+
metadata: model.metadata,
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
restoreListViewState(viewState) {
|
|
1318
|
+
if (!this.viewModel) {
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
if (viewState?.scrollPosition !== undefined) {
|
|
1322
|
+
this._list.scrollTop = viewState.scrollPosition.top;
|
|
1323
|
+
this._list.scrollLeft = viewState.scrollPosition.left;
|
|
1324
|
+
}
|
|
1325
|
+
else {
|
|
1326
|
+
this._list.scrollTop = 0;
|
|
1327
|
+
this._list.scrollLeft = 0;
|
|
1328
|
+
}
|
|
1329
|
+
const focusIdx = typeof viewState?.focus === 'number' ? viewState.focus : 0;
|
|
1330
|
+
if (focusIdx < this.viewModel.length) {
|
|
1331
|
+
const element = this.viewModel.cellAt(focusIdx);
|
|
1332
|
+
if (element) {
|
|
1333
|
+
this.viewModel?.updateSelectionsState({
|
|
1334
|
+
kind: SelectionStateType.Handle,
|
|
1335
|
+
primary: element.handle,
|
|
1336
|
+
selections: [element.handle]
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
else if (this._list.length > 0) {
|
|
1341
|
+
this.viewModel.updateSelectionsState({
|
|
1342
|
+
kind: SelectionStateType.Index,
|
|
1343
|
+
focus: { start: 0, end: 1 },
|
|
1344
|
+
selections: [{ start: 0, end: 1 }]
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
if (viewState?.editorFocused) {
|
|
1348
|
+
const cell = this.viewModel.cellAt(focusIdx);
|
|
1349
|
+
if (cell) {
|
|
1350
|
+
cell.focusMode = CellFocusMode.Editor;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
_restoreSelectedKernel(viewState) {
|
|
1355
|
+
if (viewState?.selectedKernelId && this.textModel) {
|
|
1356
|
+
const matching = this.notebookKernelService.getMatchingKernel(this.textModel);
|
|
1357
|
+
const kernel = matching.all.find(k => k.id === viewState.selectedKernelId);
|
|
1358
|
+
if (kernel && !matching.selected) {
|
|
1359
|
+
this.notebookKernelService.selectKernelForNotebook(kernel, this.textModel);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
getEditorViewState() {
|
|
1364
|
+
const state = this.viewModel?.getEditorViewState();
|
|
1365
|
+
if (!state) {
|
|
1366
|
+
return {
|
|
1367
|
+
editingCells: {},
|
|
1368
|
+
cellLineNumberStates: {},
|
|
1369
|
+
editorViewStates: {},
|
|
1370
|
+
collapsedInputCells: {},
|
|
1371
|
+
collapsedOutputCells: {},
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
if (this._list) {
|
|
1375
|
+
state.scrollPosition = { left: this._list.scrollLeft, top: this._list.scrollTop };
|
|
1376
|
+
const cellHeights = {};
|
|
1377
|
+
for (let i = 0; i < this.viewModel.length; i++) {
|
|
1378
|
+
const elm = this.viewModel.cellAt(i);
|
|
1379
|
+
cellHeights[i] = elm.layoutInfo.totalHeight;
|
|
1380
|
+
}
|
|
1381
|
+
state.cellTotalHeights = cellHeights;
|
|
1382
|
+
if (this.viewModel) {
|
|
1383
|
+
const focusRange = this.viewModel.getFocus();
|
|
1384
|
+
const element = this.viewModel.cellAt(focusRange.start);
|
|
1385
|
+
if (element) {
|
|
1386
|
+
const itemDOM = this._list.domElementOfElement(element);
|
|
1387
|
+
const editorFocused = element.getEditState() === CellEditState.Editing && !!(itemDOM && itemDOM.ownerDocument.activeElement && itemDOM.contains(itemDOM.ownerDocument.activeElement));
|
|
1388
|
+
state.editorFocused = editorFocused;
|
|
1389
|
+
state.focus = focusRange.start;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
const contributionsState = {};
|
|
1394
|
+
for (const [id, contribution] of this._contributions) {
|
|
1395
|
+
if (typeof contribution.saveViewState === 'function') {
|
|
1396
|
+
contributionsState[id] = contribution.saveViewState();
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
state.contributionsState = contributionsState;
|
|
1400
|
+
if (this.textModel?.uri.scheme === Schemas.untitled) {
|
|
1401
|
+
state.selectedKernelId = this.activeKernel?.id;
|
|
1402
|
+
}
|
|
1403
|
+
return state;
|
|
1404
|
+
}
|
|
1405
|
+
_allowScrollBeyondLastLine() {
|
|
1406
|
+
return this._scrollBeyondLastLine && !this.isEmbedded;
|
|
1407
|
+
}
|
|
1408
|
+
getBodyHeight(dimensionHeight) {
|
|
1409
|
+
return Math.max(dimensionHeight - (this._notebookTopToolbar?.useGlobalToolbar ? 26 : 0), 0);
|
|
1410
|
+
}
|
|
1411
|
+
layout(dimension, shadowElement, position) {
|
|
1412
|
+
if (!shadowElement && this._shadowElementViewInfo === null) {
|
|
1413
|
+
this._dimension = dimension;
|
|
1414
|
+
this._position = position;
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
if (dimension.width <= 0 || dimension.height <= 0) {
|
|
1418
|
+
this.onWillHide();
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
if (shadowElement) {
|
|
1422
|
+
this.updateShadowElement(shadowElement, dimension, position);
|
|
1423
|
+
}
|
|
1424
|
+
if (this._shadowElementViewInfo && this._shadowElementViewInfo.width <= 0 && this._shadowElementViewInfo.height <= 0) {
|
|
1425
|
+
this.onWillHide();
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1428
|
+
this._dimension = dimension;
|
|
1429
|
+
this._position = position;
|
|
1430
|
+
const newBodyHeight = this.getBodyHeight(dimension.height);
|
|
1431
|
+
dom.size(this._body, dimension.width, newBodyHeight);
|
|
1432
|
+
const topInserToolbarHeight = this._notebookOptions.computeTopInsertToolbarHeight(this.viewModel?.viewType);
|
|
1433
|
+
const newCellListHeight = newBodyHeight;
|
|
1434
|
+
if (this._list.getRenderHeight() < newCellListHeight) {
|
|
1435
|
+
this._list.updateOptions({ paddingBottom: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : 0, paddingTop: topInserToolbarHeight });
|
|
1436
|
+
this._list.layout(newCellListHeight, dimension.width);
|
|
1437
|
+
}
|
|
1438
|
+
else {
|
|
1439
|
+
this._list.layout(newCellListHeight, dimension.width);
|
|
1440
|
+
this._list.updateOptions({ paddingBottom: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : 0, paddingTop: topInserToolbarHeight });
|
|
1441
|
+
}
|
|
1442
|
+
this._overlayContainer.style.visibility = 'visible';
|
|
1443
|
+
this._overlayContainer.style.display = 'block';
|
|
1444
|
+
this._overlayContainer.style.position = 'absolute';
|
|
1445
|
+
this._overlayContainer.style.overflow = 'hidden';
|
|
1446
|
+
this.layoutContainerOverShadowElement(dimension, position);
|
|
1447
|
+
if (this._webviewTransparentCover) {
|
|
1448
|
+
this._webviewTransparentCover.style.height = `${dimension.height}px`;
|
|
1449
|
+
this._webviewTransparentCover.style.width = `${dimension.width}px`;
|
|
1450
|
+
}
|
|
1451
|
+
this._notebookTopToolbar.layout(this._dimension);
|
|
1452
|
+
this._notebookOverviewRuler.layout();
|
|
1453
|
+
this._viewContext?.eventDispatcher.emit([( new NotebookLayoutChangedEvent({ width: true, fontInfo: true }, this.getLayoutInfo()))]);
|
|
1454
|
+
}
|
|
1455
|
+
updateShadowElement(shadowElement, dimension, position) {
|
|
1456
|
+
this._shadowElement = shadowElement;
|
|
1457
|
+
if (dimension && position) {
|
|
1458
|
+
this._shadowElementViewInfo = {
|
|
1459
|
+
height: dimension.height,
|
|
1460
|
+
width: dimension.width,
|
|
1461
|
+
top: position.top,
|
|
1462
|
+
left: position.left,
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
else {
|
|
1466
|
+
const containerRect = shadowElement.getBoundingClientRect();
|
|
1467
|
+
this._shadowElementViewInfo = {
|
|
1468
|
+
height: containerRect.height,
|
|
1469
|
+
width: containerRect.width,
|
|
1470
|
+
top: containerRect.top,
|
|
1471
|
+
left: containerRect.left
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
layoutContainerOverShadowElement(dimension, position) {
|
|
1476
|
+
if (dimension && position) {
|
|
1477
|
+
this._overlayContainer.style.top = `${position.top}px`;
|
|
1478
|
+
this._overlayContainer.style.left = `${position.left}px`;
|
|
1479
|
+
this._overlayContainer.style.width = `${dimension.width}px`;
|
|
1480
|
+
this._overlayContainer.style.height = `${dimension.height}px`;
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
if (!this._shadowElementViewInfo) {
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
const elementContainerRect = this._overlayContainer.parentElement?.getBoundingClientRect();
|
|
1487
|
+
this._overlayContainer.style.top = `${this._shadowElementViewInfo.top - (elementContainerRect?.top || 0)}px`;
|
|
1488
|
+
this._overlayContainer.style.left = `${this._shadowElementViewInfo.left - (elementContainerRect?.left || 0)}px`;
|
|
1489
|
+
this._overlayContainer.style.width = `${dimension ? dimension.width : this._shadowElementViewInfo.width}px`;
|
|
1490
|
+
this._overlayContainer.style.height = `${dimension ? dimension.height : this._shadowElementViewInfo.height}px`;
|
|
1491
|
+
}
|
|
1492
|
+
focus() {
|
|
1493
|
+
this._isVisible = true;
|
|
1494
|
+
this._editorFocus.set(true);
|
|
1495
|
+
if (this._webviewFocused) {
|
|
1496
|
+
this._webview?.focusWebview();
|
|
1497
|
+
}
|
|
1498
|
+
else {
|
|
1499
|
+
if (this.viewModel) {
|
|
1500
|
+
const focusRange = this.viewModel.getFocus();
|
|
1501
|
+
const element = this.viewModel.cellAt(focusRange.start);
|
|
1502
|
+
if (!this.hasEditorFocus()) {
|
|
1503
|
+
this.focusContainer();
|
|
1504
|
+
this.updateEditorFocus();
|
|
1505
|
+
}
|
|
1506
|
+
if (element && element.focusMode === CellFocusMode.Editor) {
|
|
1507
|
+
element.updateEditState(CellEditState.Editing, 'editorWidget.focus');
|
|
1508
|
+
element.focusMode = CellFocusMode.Editor;
|
|
1509
|
+
this.focusEditor(element);
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
this._list.domFocus();
|
|
1514
|
+
}
|
|
1515
|
+
if (this._currentProgress) {
|
|
1516
|
+
this.showProgress();
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
onShow() {
|
|
1520
|
+
this._isVisible = true;
|
|
1521
|
+
}
|
|
1522
|
+
focusEditor(activeElement) {
|
|
1523
|
+
for (const [element, editor] of this._renderedEditors.entries()) {
|
|
1524
|
+
if (element === activeElement) {
|
|
1525
|
+
editor.focus();
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
focusContainer() {
|
|
1531
|
+
if (this._webviewFocused) {
|
|
1532
|
+
this._webview?.focusWebview();
|
|
1533
|
+
}
|
|
1534
|
+
else {
|
|
1535
|
+
this._list.focusContainer();
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
onWillHide() {
|
|
1539
|
+
this._isVisible = false;
|
|
1540
|
+
this._editorFocus.set(false);
|
|
1541
|
+
this._overlayContainer.style.visibility = 'hidden';
|
|
1542
|
+
this._overlayContainer.style.left = '-50000px';
|
|
1543
|
+
this._notebookTopToolbarContainer.style.display = 'none';
|
|
1544
|
+
this.clearActiveCellWidgets();
|
|
1545
|
+
}
|
|
1546
|
+
clearActiveCellWidgets() {
|
|
1547
|
+
this._renderedEditors.forEach((editor, cell) => {
|
|
1548
|
+
if (this.getActiveCell() === cell && editor) {
|
|
1549
|
+
SuggestController.get(editor)?.cancelSuggestWidget();
|
|
1550
|
+
DropIntoEditorController.get(editor)?.clearWidgets();
|
|
1551
|
+
CopyPasteController.get(editor)?.clearWidgets();
|
|
1552
|
+
}
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
editorHasDomFocus() {
|
|
1556
|
+
return dom.isAncestorOfActiveElement(this.getDomNode());
|
|
1557
|
+
}
|
|
1558
|
+
updateEditorFocus() {
|
|
1559
|
+
this._focusTracker.refreshState();
|
|
1560
|
+
const focused = this.editorHasDomFocus();
|
|
1561
|
+
this._editorFocus.set(focused);
|
|
1562
|
+
this.viewModel?.setEditorFocus(focused);
|
|
1563
|
+
}
|
|
1564
|
+
updateCellFocusMode() {
|
|
1565
|
+
const activeCell = this.getActiveCell();
|
|
1566
|
+
if (activeCell?.focusMode === CellFocusMode.Output && !this._webviewFocused) {
|
|
1567
|
+
activeCell.focusMode = CellFocusMode.Container;
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
hasEditorFocus() {
|
|
1571
|
+
this.updateEditorFocus();
|
|
1572
|
+
return this.editorHasDomFocus();
|
|
1573
|
+
}
|
|
1574
|
+
hasWebviewFocus() {
|
|
1575
|
+
return this._webviewFocused;
|
|
1576
|
+
}
|
|
1577
|
+
hasOutputTextSelection() {
|
|
1578
|
+
if (!this.hasEditorFocus()) {
|
|
1579
|
+
return false;
|
|
1580
|
+
}
|
|
1581
|
+
const windowSelection = dom.getWindow(this.getDomNode()).getSelection();
|
|
1582
|
+
if (windowSelection?.rangeCount !== 1) {
|
|
1583
|
+
return false;
|
|
1584
|
+
}
|
|
1585
|
+
const activeSelection = windowSelection.getRangeAt(0);
|
|
1586
|
+
if (activeSelection.startContainer === activeSelection.endContainer && activeSelection.endOffset - activeSelection.startOffset === 0) {
|
|
1587
|
+
return false;
|
|
1588
|
+
}
|
|
1589
|
+
let container = activeSelection.commonAncestorContainer;
|
|
1590
|
+
if (!this._body.contains(container)) {
|
|
1591
|
+
return false;
|
|
1592
|
+
}
|
|
1593
|
+
while (container
|
|
1594
|
+
&&
|
|
1595
|
+
container !== this._body) {
|
|
1596
|
+
if (container.classList && container.classList.contains('output')) {
|
|
1597
|
+
return true;
|
|
1598
|
+
}
|
|
1599
|
+
container = container.parentNode;
|
|
1600
|
+
}
|
|
1601
|
+
return false;
|
|
1602
|
+
}
|
|
1603
|
+
_didFocusOutputInputChange(hasFocus) {
|
|
1604
|
+
this._outputInputFocus.set(hasFocus);
|
|
1605
|
+
}
|
|
1606
|
+
focusElement(cell) {
|
|
1607
|
+
this.viewModel?.updateSelectionsState({
|
|
1608
|
+
kind: SelectionStateType.Handle,
|
|
1609
|
+
primary: cell.handle,
|
|
1610
|
+
selections: [cell.handle]
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
get scrollTop() {
|
|
1614
|
+
return this._list.scrollTop;
|
|
1615
|
+
}
|
|
1616
|
+
getAbsoluteTopOfElement(cell) {
|
|
1617
|
+
return this._list.getCellViewScrollTop(cell);
|
|
1618
|
+
}
|
|
1619
|
+
scrollToBottom() {
|
|
1620
|
+
this._list.scrollToBottom();
|
|
1621
|
+
}
|
|
1622
|
+
setScrollTop(scrollTop) {
|
|
1623
|
+
this._list.scrollTop = scrollTop;
|
|
1624
|
+
}
|
|
1625
|
+
revealCellRangeInView(range) {
|
|
1626
|
+
return this._list.revealCells(range);
|
|
1627
|
+
}
|
|
1628
|
+
revealInView(cell) {
|
|
1629
|
+
return this._list.revealCell(cell, 1 );
|
|
1630
|
+
}
|
|
1631
|
+
revealInViewAtTop(cell) {
|
|
1632
|
+
this._list.revealCell(cell, 2 );
|
|
1633
|
+
}
|
|
1634
|
+
revealInCenter(cell) {
|
|
1635
|
+
this._list.revealCell(cell, 3 );
|
|
1636
|
+
}
|
|
1637
|
+
async revealInCenterIfOutsideViewport(cell) {
|
|
1638
|
+
await this._list.revealCell(cell, 4 );
|
|
1639
|
+
}
|
|
1640
|
+
revealFirstLineIfOutsideViewport(cell) {
|
|
1641
|
+
this._list.revealCell(cell, 6 );
|
|
1642
|
+
}
|
|
1643
|
+
async revealLineInViewAsync(cell, line) {
|
|
1644
|
+
return this._list.revealRangeInCell(cell, ( new Range(line, 1, line, 1)), CellRevealRangeType.Default);
|
|
1645
|
+
}
|
|
1646
|
+
async revealLineInCenterAsync(cell, line) {
|
|
1647
|
+
return this._list.revealRangeInCell(cell, ( new Range(line, 1, line, 1)), CellRevealRangeType.Center);
|
|
1648
|
+
}
|
|
1649
|
+
async revealLineInCenterIfOutsideViewportAsync(cell, line) {
|
|
1650
|
+
return this._list.revealRangeInCell(cell, ( new Range(line, 1, line, 1)), CellRevealRangeType.CenterIfOutsideViewport);
|
|
1651
|
+
}
|
|
1652
|
+
async revealRangeInViewAsync(cell, range) {
|
|
1653
|
+
return this._list.revealRangeInCell(cell, range, CellRevealRangeType.Default);
|
|
1654
|
+
}
|
|
1655
|
+
async revealRangeInCenterAsync(cell, range) {
|
|
1656
|
+
return this._list.revealRangeInCell(cell, range, CellRevealRangeType.Center);
|
|
1657
|
+
}
|
|
1658
|
+
async revealRangeInCenterIfOutsideViewportAsync(cell, range) {
|
|
1659
|
+
return this._list.revealRangeInCell(cell, range, CellRevealRangeType.CenterIfOutsideViewport);
|
|
1660
|
+
}
|
|
1661
|
+
revealCellOffsetInCenter(cell, offset) {
|
|
1662
|
+
return this._list.revealCellOffsetInCenter(cell, offset);
|
|
1663
|
+
}
|
|
1664
|
+
getViewIndexByModelIndex(index) {
|
|
1665
|
+
if (!this._listViewInfoAccessor) {
|
|
1666
|
+
return -1;
|
|
1667
|
+
}
|
|
1668
|
+
const cell = this.viewModel?.viewCells[index];
|
|
1669
|
+
if (!cell) {
|
|
1670
|
+
return -1;
|
|
1671
|
+
}
|
|
1672
|
+
return this._listViewInfoAccessor.getViewIndex(cell);
|
|
1673
|
+
}
|
|
1674
|
+
getViewHeight(cell) {
|
|
1675
|
+
if (!this._listViewInfoAccessor) {
|
|
1676
|
+
return -1;
|
|
1677
|
+
}
|
|
1678
|
+
return this._listViewInfoAccessor.getViewHeight(cell);
|
|
1679
|
+
}
|
|
1680
|
+
getCellRangeFromViewRange(startIndex, endIndex) {
|
|
1681
|
+
return this._listViewInfoAccessor.getCellRangeFromViewRange(startIndex, endIndex);
|
|
1682
|
+
}
|
|
1683
|
+
getCellsInRange(range) {
|
|
1684
|
+
return this._listViewInfoAccessor.getCellsInRange(range);
|
|
1685
|
+
}
|
|
1686
|
+
setCellEditorSelection(cell, range) {
|
|
1687
|
+
this._list.setCellEditorSelection(cell, range);
|
|
1688
|
+
}
|
|
1689
|
+
setHiddenAreas(_ranges) {
|
|
1690
|
+
return this._list.setHiddenAreas(_ranges, true);
|
|
1691
|
+
}
|
|
1692
|
+
getVisibleRangesPlusViewportAboveAndBelow() {
|
|
1693
|
+
return this._listViewInfoAccessor.getVisibleRangesPlusViewportAboveAndBelow();
|
|
1694
|
+
}
|
|
1695
|
+
deltaCellDecorations(oldDecorations, newDecorations) {
|
|
1696
|
+
const ret = this.viewModel?.deltaCellDecorations(oldDecorations, newDecorations) || [];
|
|
1697
|
+
this._onDidChangeDecorations.fire();
|
|
1698
|
+
return ret;
|
|
1699
|
+
}
|
|
1700
|
+
deltaCellContainerClassNames(cellId, added, removed) {
|
|
1701
|
+
this._webview?.deltaCellContainerClassNames(cellId, added, removed);
|
|
1702
|
+
}
|
|
1703
|
+
changeModelDecorations(callback) {
|
|
1704
|
+
return this.viewModel?.changeModelDecorations(callback) || null;
|
|
1705
|
+
}
|
|
1706
|
+
async _loadKernelPreloads() {
|
|
1707
|
+
if (!this.hasModel()) {
|
|
1708
|
+
return;
|
|
1709
|
+
}
|
|
1710
|
+
const { selected } = this.notebookKernelService.getMatchingKernel(this.textModel);
|
|
1711
|
+
if (!this._webview?.isResolved()) {
|
|
1712
|
+
await this._resolveWebview();
|
|
1713
|
+
}
|
|
1714
|
+
this._webview?.updateKernelPreloads(selected);
|
|
1715
|
+
}
|
|
1716
|
+
get activeKernel() {
|
|
1717
|
+
return this.textModel && this.notebookKernelService.getSelectedOrSuggestedKernel(this.textModel);
|
|
1718
|
+
}
|
|
1719
|
+
async cancelNotebookCells(cells) {
|
|
1720
|
+
if (!this.viewModel || !this.hasModel()) {
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1723
|
+
if (!cells) {
|
|
1724
|
+
cells = this.viewModel.viewCells;
|
|
1725
|
+
}
|
|
1726
|
+
return this.notebookExecutionService.cancelNotebookCellHandles(this.textModel, ( Array.from(cells).map(cell => cell.handle)));
|
|
1727
|
+
}
|
|
1728
|
+
async executeNotebookCells(cells) {
|
|
1729
|
+
if (!this.viewModel || !this.hasModel()) {
|
|
1730
|
+
this.logService.info('notebookEditorWidget', 'No NotebookViewModel, cannot execute cells');
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
if (!cells) {
|
|
1734
|
+
cells = this.viewModel.viewCells;
|
|
1735
|
+
}
|
|
1736
|
+
return this.notebookExecutionService.executeNotebookCells(this.textModel, ( Array.from(cells).map(c => c.model)), this.scopedContextKeyService);
|
|
1737
|
+
}
|
|
1738
|
+
async layoutNotebookCell(cell, height, context) {
|
|
1739
|
+
this._debug('layout cell', cell.handle, height);
|
|
1740
|
+
const viewIndex = this._list.getViewIndex(cell);
|
|
1741
|
+
if (viewIndex === undefined) {
|
|
1742
|
+
return;
|
|
1743
|
+
}
|
|
1744
|
+
if (this._pendingLayouts?.has(cell)) {
|
|
1745
|
+
this._pendingLayouts?.get(cell).dispose();
|
|
1746
|
+
}
|
|
1747
|
+
const deferred = ( new DeferredPromise());
|
|
1748
|
+
const doLayout = () => {
|
|
1749
|
+
if (this._isDisposed) {
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
if (!this.viewModel?.hasCell(cell)) {
|
|
1753
|
+
return;
|
|
1754
|
+
}
|
|
1755
|
+
if (this._list.elementHeight(cell) === height) {
|
|
1756
|
+
return;
|
|
1757
|
+
}
|
|
1758
|
+
this._pendingLayouts?.delete(cell);
|
|
1759
|
+
if (!this.hasEditorFocus()) {
|
|
1760
|
+
const cellIndex = this.viewModel?.getCellIndex(cell);
|
|
1761
|
+
const visibleRanges = this.visibleRanges;
|
|
1762
|
+
if (cellIndex !== undefined
|
|
1763
|
+
&& visibleRanges && visibleRanges.length && visibleRanges[0].start === cellIndex
|
|
1764
|
+
&& this._list.scrollTop > this.getAbsoluteTopOfElement(cell)) {
|
|
1765
|
+
return this._list.updateElementHeight2(cell, height, Math.min(cellIndex + 1, this.getLength() - 1));
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
this._list.updateElementHeight2(cell, height);
|
|
1769
|
+
deferred.complete(undefined);
|
|
1770
|
+
};
|
|
1771
|
+
if (this._list.inRenderingTransaction) {
|
|
1772
|
+
const layoutDisposable = dom.scheduleAtNextAnimationFrame(dom.getWindow(this.getDomNode()), doLayout);
|
|
1773
|
+
this._pendingLayouts?.set(cell, toDisposable(() => {
|
|
1774
|
+
layoutDisposable.dispose();
|
|
1775
|
+
deferred.complete(undefined);
|
|
1776
|
+
}));
|
|
1777
|
+
}
|
|
1778
|
+
else {
|
|
1779
|
+
doLayout();
|
|
1780
|
+
}
|
|
1781
|
+
return deferred.p;
|
|
1782
|
+
}
|
|
1783
|
+
getActiveCell() {
|
|
1784
|
+
const elements = this._list.getFocusedElements();
|
|
1785
|
+
if (elements && elements.length) {
|
|
1786
|
+
return elements[0];
|
|
1787
|
+
}
|
|
1788
|
+
return undefined;
|
|
1789
|
+
}
|
|
1790
|
+
_toggleNotebookCellSelection(selectedCell, selectFromPrevious) {
|
|
1791
|
+
const currentSelections = this._list.getSelectedElements();
|
|
1792
|
+
const isSelected = currentSelections.includes(selectedCell);
|
|
1793
|
+
const previousSelection = selectFromPrevious ? currentSelections[currentSelections.length - 1] ?? selectedCell : selectedCell;
|
|
1794
|
+
const selectedIndex = this._list.getViewIndex(selectedCell);
|
|
1795
|
+
const previousIndex = this._list.getViewIndex(previousSelection);
|
|
1796
|
+
const cellsInSelectionRange = this.getCellsInViewRange(selectedIndex, previousIndex);
|
|
1797
|
+
if (isSelected) {
|
|
1798
|
+
this._list.selectElements(currentSelections.filter(current => !cellsInSelectionRange.includes(current)));
|
|
1799
|
+
}
|
|
1800
|
+
else {
|
|
1801
|
+
this.focusElement(selectedCell);
|
|
1802
|
+
this._list.selectElements([...currentSelections.filter(current => !cellsInSelectionRange.includes(current)), ...cellsInSelectionRange]);
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
getCellsInViewRange(fromInclusive, toInclusive) {
|
|
1806
|
+
const selectedCellsInRange = [];
|
|
1807
|
+
for (let index = 0; index < this._list.length; ++index) {
|
|
1808
|
+
const cell = this._list.element(index);
|
|
1809
|
+
if (cell) {
|
|
1810
|
+
if ((index >= fromInclusive && index <= toInclusive) || (index >= toInclusive && index <= fromInclusive)) {
|
|
1811
|
+
selectedCellsInRange.push(cell);
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
return selectedCellsInRange;
|
|
1816
|
+
}
|
|
1817
|
+
async focusNotebookCell(cell, focusItem, options) {
|
|
1818
|
+
if (this._isDisposed) {
|
|
1819
|
+
return;
|
|
1820
|
+
}
|
|
1821
|
+
if (focusItem === 'editor') {
|
|
1822
|
+
this.focusElement(cell);
|
|
1823
|
+
this._list.focusView();
|
|
1824
|
+
cell.updateEditState(CellEditState.Editing, 'focusNotebookCell');
|
|
1825
|
+
cell.focusMode = CellFocusMode.Editor;
|
|
1826
|
+
if (!options?.skipReveal) {
|
|
1827
|
+
if (typeof options?.focusEditorLine === 'number') {
|
|
1828
|
+
this._cursorNavMode.set(true);
|
|
1829
|
+
await this.revealLineInViewAsync(cell, options.focusEditorLine);
|
|
1830
|
+
const editor = this._renderedEditors.get(cell);
|
|
1831
|
+
const focusEditorLine = options.focusEditorLine;
|
|
1832
|
+
editor?.setSelection({
|
|
1833
|
+
startLineNumber: focusEditorLine,
|
|
1834
|
+
startColumn: 1,
|
|
1835
|
+
endLineNumber: focusEditorLine,
|
|
1836
|
+
endColumn: 1
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
else {
|
|
1840
|
+
const selectionsStartPosition = cell.getSelectionsStartPosition();
|
|
1841
|
+
if (selectionsStartPosition?.length) {
|
|
1842
|
+
const firstSelectionPosition = selectionsStartPosition[0];
|
|
1843
|
+
await this.revealRangeInViewAsync(cell, Range.fromPositions(firstSelectionPosition, firstSelectionPosition));
|
|
1844
|
+
}
|
|
1845
|
+
else {
|
|
1846
|
+
await this.revealInView(cell);
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
else if (focusItem === 'output') {
|
|
1852
|
+
this.focusElement(cell);
|
|
1853
|
+
if (!this.hasEditorFocus()) {
|
|
1854
|
+
this._list.focusView();
|
|
1855
|
+
}
|
|
1856
|
+
if (!this._webview) {
|
|
1857
|
+
return;
|
|
1858
|
+
}
|
|
1859
|
+
const focusElementId = options?.outputId ?? cell.id;
|
|
1860
|
+
this._webview.focusOutput(focusElementId, options?.altOutputId, this._webviewFocused);
|
|
1861
|
+
cell.updateEditState(CellEditState.Preview, 'focusNotebookCell');
|
|
1862
|
+
cell.focusMode = CellFocusMode.Output;
|
|
1863
|
+
if (!options?.skipReveal) {
|
|
1864
|
+
this.revealInCenterIfOutsideViewport(cell);
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
else {
|
|
1868
|
+
const itemDOM = this._list.domElementOfElement(cell);
|
|
1869
|
+
if (itemDOM && itemDOM.ownerDocument.activeElement && itemDOM.contains(itemDOM.ownerDocument.activeElement)) {
|
|
1870
|
+
itemDOM.ownerDocument.activeElement.blur();
|
|
1871
|
+
}
|
|
1872
|
+
cell.updateEditState(CellEditState.Preview, 'focusNotebookCell');
|
|
1873
|
+
cell.focusMode = CellFocusMode.Container;
|
|
1874
|
+
this.focusElement(cell);
|
|
1875
|
+
if (!options?.skipReveal) {
|
|
1876
|
+
if (typeof options?.focusEditorLine === 'number') {
|
|
1877
|
+
this._cursorNavMode.set(true);
|
|
1878
|
+
await this.revealInView(cell);
|
|
1879
|
+
}
|
|
1880
|
+
else if (options?.revealBehavior === ScrollToRevealBehavior.firstLine) {
|
|
1881
|
+
this.revealFirstLineIfOutsideViewport(cell);
|
|
1882
|
+
}
|
|
1883
|
+
else if (options?.revealBehavior === ScrollToRevealBehavior.fullCell) {
|
|
1884
|
+
await this.revealInView(cell);
|
|
1885
|
+
}
|
|
1886
|
+
else {
|
|
1887
|
+
await this.revealInCenterIfOutsideViewport(cell);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
this._list.focusView();
|
|
1891
|
+
this.updateEditorFocus();
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
async focusNextNotebookCell(cell, focusItem) {
|
|
1895
|
+
const idx = this.viewModel?.getCellIndex(cell);
|
|
1896
|
+
if (typeof idx !== 'number') {
|
|
1897
|
+
return;
|
|
1898
|
+
}
|
|
1899
|
+
const newCell = this.viewModel?.cellAt(idx + 1);
|
|
1900
|
+
if (!newCell) {
|
|
1901
|
+
return;
|
|
1902
|
+
}
|
|
1903
|
+
await this.focusNotebookCell(newCell, focusItem);
|
|
1904
|
+
}
|
|
1905
|
+
async _warmupCell(viewCell) {
|
|
1906
|
+
if (viewCell.isOutputCollapsed) {
|
|
1907
|
+
return;
|
|
1908
|
+
}
|
|
1909
|
+
const outputs = viewCell.outputsViewModels;
|
|
1910
|
+
for (const output of outputs.slice(0, outputDisplayLimit)) {
|
|
1911
|
+
const [mimeTypes, pick] = output.resolveMimeTypes(this.textModel, undefined);
|
|
1912
|
+
if (!mimeTypes.find(mimeType => mimeType.isTrusted) || mimeTypes.length === 0) {
|
|
1913
|
+
continue;
|
|
1914
|
+
}
|
|
1915
|
+
const pickedMimeTypeRenderer = mimeTypes[pick];
|
|
1916
|
+
if (!pickedMimeTypeRenderer) {
|
|
1917
|
+
return;
|
|
1918
|
+
}
|
|
1919
|
+
const renderer = this._notebookService.getRendererInfo(pickedMimeTypeRenderer.rendererId);
|
|
1920
|
+
if (!renderer) {
|
|
1921
|
+
return;
|
|
1922
|
+
}
|
|
1923
|
+
const result = { type: 1 , renderer, source: output, mimeType: pickedMimeTypeRenderer.mimeType };
|
|
1924
|
+
const inset = this._webview?.insetMapping.get(result.source);
|
|
1925
|
+
if (!inset || !inset.initialized) {
|
|
1926
|
+
const p = ( new Promise(resolve => {
|
|
1927
|
+
this._register(Event.any(this.onDidRenderOutput, this.onDidRemoveOutput)(e => {
|
|
1928
|
+
if (e.model === result.source.model) {
|
|
1929
|
+
resolve();
|
|
1930
|
+
}
|
|
1931
|
+
}));
|
|
1932
|
+
}));
|
|
1933
|
+
this.createOutput(viewCell, result, 0, false);
|
|
1934
|
+
await p;
|
|
1935
|
+
}
|
|
1936
|
+
else {
|
|
1937
|
+
this.createOutput(viewCell, result, 0, false);
|
|
1938
|
+
}
|
|
1939
|
+
return;
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
async _warmupAll(includeOutput) {
|
|
1943
|
+
if (!this.hasModel() || !this.viewModel) {
|
|
1944
|
+
return;
|
|
1945
|
+
}
|
|
1946
|
+
const cells = this.viewModel.viewCells;
|
|
1947
|
+
const requests = [];
|
|
1948
|
+
for (let i = 0; i < cells.length; i++) {
|
|
1949
|
+
if (cells[i].cellKind === CellKind.Markup && !( this._webview.markupPreviewMapping.has(cells[i].id))) {
|
|
1950
|
+
requests.push(this.createMarkupPreview(cells[i]));
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
if (includeOutput && this._list) {
|
|
1954
|
+
for (let i = 0; i < this._list.length; i++) {
|
|
1955
|
+
const cell = this._list.element(i);
|
|
1956
|
+
if (cell?.cellKind === CellKind.Code) {
|
|
1957
|
+
requests.push(this._warmupCell(cell));
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
return Promise.all(requests);
|
|
1962
|
+
}
|
|
1963
|
+
async find(query, options, token, skipWarmup = false, shouldGetSearchPreviewInfo = false, ownerID) {
|
|
1964
|
+
if (!this._notebookViewModel) {
|
|
1965
|
+
return [];
|
|
1966
|
+
}
|
|
1967
|
+
if (!ownerID) {
|
|
1968
|
+
ownerID = this.getId();
|
|
1969
|
+
}
|
|
1970
|
+
const findMatches = this._notebookViewModel.find(query, options).filter(match => match.length > 0);
|
|
1971
|
+
if (!options.includeMarkupPreview && !options.includeOutput) {
|
|
1972
|
+
this._webview?.findStop(ownerID);
|
|
1973
|
+
return findMatches;
|
|
1974
|
+
}
|
|
1975
|
+
const matchMap = {};
|
|
1976
|
+
findMatches.forEach(match => {
|
|
1977
|
+
matchMap[match.cell.id] = match;
|
|
1978
|
+
});
|
|
1979
|
+
if (this._webview) {
|
|
1980
|
+
const start = Date.now();
|
|
1981
|
+
await this._warmupAll(!!options.includeOutput);
|
|
1982
|
+
const end = Date.now();
|
|
1983
|
+
this.logService.debug('Find', `Warmup time: ${end - start}ms`);
|
|
1984
|
+
if (token.isCancellationRequested) {
|
|
1985
|
+
return [];
|
|
1986
|
+
}
|
|
1987
|
+
const webviewMatches = await this._webview.find(query, { caseSensitive: options.caseSensitive, wholeWord: options.wholeWord, includeMarkup: !!options.includeMarkupPreview, includeOutput: !!options.includeOutput, shouldGetSearchPreviewInfo, ownerID });
|
|
1988
|
+
if (token.isCancellationRequested) {
|
|
1989
|
+
return [];
|
|
1990
|
+
}
|
|
1991
|
+
webviewMatches.forEach(match => {
|
|
1992
|
+
const cell = this._notebookViewModel.viewCells.find(cell => cell.id === match.cellId);
|
|
1993
|
+
if (!cell) {
|
|
1994
|
+
return;
|
|
1995
|
+
}
|
|
1996
|
+
if (match.type === 'preview') {
|
|
1997
|
+
if (cell.getEditState() === CellEditState.Preview && !options.includeMarkupPreview) {
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
if (cell.getEditState() === CellEditState.Editing && options.includeMarkupInput) {
|
|
2001
|
+
return;
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
else {
|
|
2005
|
+
if (!options.includeOutput) {
|
|
2006
|
+
return;
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
const exisitingMatch = matchMap[match.cellId];
|
|
2010
|
+
if (exisitingMatch) {
|
|
2011
|
+
exisitingMatch.webviewMatches.push(match);
|
|
2012
|
+
}
|
|
2013
|
+
else {
|
|
2014
|
+
matchMap[match.cellId] = ( new CellFindMatchModel(
|
|
2015
|
+
this._notebookViewModel.viewCells.find(cell => cell.id === match.cellId),
|
|
2016
|
+
this._notebookViewModel.viewCells.findIndex(cell => cell.id === match.cellId),
|
|
2017
|
+
[],
|
|
2018
|
+
[match]
|
|
2019
|
+
));
|
|
2020
|
+
}
|
|
2021
|
+
});
|
|
2022
|
+
}
|
|
2023
|
+
const ret = [];
|
|
2024
|
+
this._notebookViewModel.viewCells.forEach((cell, index) => {
|
|
2025
|
+
if (matchMap[cell.id]) {
|
|
2026
|
+
ret.push(( new CellFindMatchModel(
|
|
2027
|
+
cell,
|
|
2028
|
+
index,
|
|
2029
|
+
matchMap[cell.id].contentMatches,
|
|
2030
|
+
matchMap[cell.id].webviewMatches
|
|
2031
|
+
)));
|
|
2032
|
+
}
|
|
2033
|
+
});
|
|
2034
|
+
return ret;
|
|
2035
|
+
}
|
|
2036
|
+
async findHighlightCurrent(matchIndex, ownerID) {
|
|
2037
|
+
if (!this._webview) {
|
|
2038
|
+
return 0;
|
|
2039
|
+
}
|
|
2040
|
+
return this._webview?.findHighlightCurrent(matchIndex, ownerID ?? this.getId());
|
|
2041
|
+
}
|
|
2042
|
+
async findUnHighlightCurrent(matchIndex, ownerID) {
|
|
2043
|
+
if (!this._webview) {
|
|
2044
|
+
return;
|
|
2045
|
+
}
|
|
2046
|
+
return this._webview?.findUnHighlightCurrent(matchIndex, ownerID ?? this.getId());
|
|
2047
|
+
}
|
|
2048
|
+
findStop(ownerID) {
|
|
2049
|
+
this._webview?.findStop(ownerID ?? this.getId());
|
|
2050
|
+
}
|
|
2051
|
+
getLayoutInfo() {
|
|
2052
|
+
if (!this._list) {
|
|
2053
|
+
throw new Error('Editor is not initalized successfully');
|
|
2054
|
+
}
|
|
2055
|
+
if (!this._fontInfo) {
|
|
2056
|
+
this._generateFontInfo();
|
|
2057
|
+
}
|
|
2058
|
+
return {
|
|
2059
|
+
width: this._dimension?.width ?? 0,
|
|
2060
|
+
height: this._dimension?.height ?? 0,
|
|
2061
|
+
scrollHeight: this._list?.getScrollHeight() ?? 0,
|
|
2062
|
+
fontInfo: this._fontInfo,
|
|
2063
|
+
stickyHeight: this._notebookStickyScroll?.getCurrentStickyHeight() ?? 0
|
|
2064
|
+
};
|
|
2065
|
+
}
|
|
2066
|
+
async createMarkupPreview(cell) {
|
|
2067
|
+
if (!this._webview) {
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
if (!this._webview.isResolved()) {
|
|
2071
|
+
await this._resolveWebview();
|
|
2072
|
+
}
|
|
2073
|
+
if (!this._webview || !this._list.webviewElement) {
|
|
2074
|
+
return;
|
|
2075
|
+
}
|
|
2076
|
+
if (!this.viewModel || !this._list.viewModel) {
|
|
2077
|
+
return;
|
|
2078
|
+
}
|
|
2079
|
+
if (this.viewModel.getCellIndex(cell) === -1) {
|
|
2080
|
+
return;
|
|
2081
|
+
}
|
|
2082
|
+
if (this.cellIsHidden(cell)) {
|
|
2083
|
+
return;
|
|
2084
|
+
}
|
|
2085
|
+
const webviewTop = parseInt(this._list.webviewElement.domNode.style.top, 10);
|
|
2086
|
+
const top = !!webviewTop ? (0 - webviewTop) : 0;
|
|
2087
|
+
const cellTop = this._list.getCellViewScrollTop(cell);
|
|
2088
|
+
await this._webview.showMarkupPreview({
|
|
2089
|
+
mime: cell.mime,
|
|
2090
|
+
cellHandle: cell.handle,
|
|
2091
|
+
cellId: cell.id,
|
|
2092
|
+
content: cell.getText(),
|
|
2093
|
+
offset: cellTop + top,
|
|
2094
|
+
visible: true,
|
|
2095
|
+
metadata: cell.metadata,
|
|
2096
|
+
});
|
|
2097
|
+
}
|
|
2098
|
+
cellIsHidden(cell) {
|
|
2099
|
+
const modelIndex = this.viewModel.getCellIndex(cell);
|
|
2100
|
+
const foldedRanges = this.viewModel.getHiddenRanges();
|
|
2101
|
+
return ( foldedRanges.some(range => modelIndex >= range.start && modelIndex <= range.end));
|
|
2102
|
+
}
|
|
2103
|
+
async unhideMarkupPreviews(cells) {
|
|
2104
|
+
if (!this._webview) {
|
|
2105
|
+
return;
|
|
2106
|
+
}
|
|
2107
|
+
if (!this._webview.isResolved()) {
|
|
2108
|
+
await this._resolveWebview();
|
|
2109
|
+
}
|
|
2110
|
+
await this._webview?.unhideMarkupPreviews(( cells.map(cell => cell.id)));
|
|
2111
|
+
}
|
|
2112
|
+
async hideMarkupPreviews(cells) {
|
|
2113
|
+
if (!this._webview || !cells.length) {
|
|
2114
|
+
return;
|
|
2115
|
+
}
|
|
2116
|
+
if (!this._webview.isResolved()) {
|
|
2117
|
+
await this._resolveWebview();
|
|
2118
|
+
}
|
|
2119
|
+
await this._webview?.hideMarkupPreviews(( cells.map(cell => cell.id)));
|
|
2120
|
+
}
|
|
2121
|
+
async deleteMarkupPreviews(cells) {
|
|
2122
|
+
if (!this._webview) {
|
|
2123
|
+
return;
|
|
2124
|
+
}
|
|
2125
|
+
if (!this._webview.isResolved()) {
|
|
2126
|
+
await this._resolveWebview();
|
|
2127
|
+
}
|
|
2128
|
+
await this._webview?.deleteMarkupPreviews(( cells.map(cell => cell.id)));
|
|
2129
|
+
}
|
|
2130
|
+
async updateSelectedMarkdownPreviews() {
|
|
2131
|
+
if (!this._webview) {
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
if (!this._webview.isResolved()) {
|
|
2135
|
+
await this._resolveWebview();
|
|
2136
|
+
}
|
|
2137
|
+
const selectedCells = ( this.getSelectionViewModels().map(cell => cell.id));
|
|
2138
|
+
await this._webview?.updateMarkupPreviewSelections(selectedCells.length > 1 ? selectedCells : []);
|
|
2139
|
+
}
|
|
2140
|
+
async createOutput(cell, output, offset, createWhenIdle) {
|
|
2141
|
+
this._insetModifyQueueByOutputId.queue(output.source.model.outputId, async () => {
|
|
2142
|
+
if (this._isDisposed || !this._webview) {
|
|
2143
|
+
return;
|
|
2144
|
+
}
|
|
2145
|
+
if (!this._webview.isResolved()) {
|
|
2146
|
+
await this._resolveWebview();
|
|
2147
|
+
}
|
|
2148
|
+
if (!this._webview) {
|
|
2149
|
+
return;
|
|
2150
|
+
}
|
|
2151
|
+
if (!this._list.webviewElement) {
|
|
2152
|
+
return;
|
|
2153
|
+
}
|
|
2154
|
+
if (output.type === 1 ) {
|
|
2155
|
+
this.notebookRendererMessaging.prepare(output.renderer.id);
|
|
2156
|
+
}
|
|
2157
|
+
const webviewTop = parseInt(this._list.webviewElement.domNode.style.top, 10);
|
|
2158
|
+
const top = !!webviewTop ? (0 - webviewTop) : 0;
|
|
2159
|
+
const cellTop = this._list.getCellViewScrollTop(cell) + top;
|
|
2160
|
+
const existingOutput = this._webview.insetMapping.get(output.source);
|
|
2161
|
+
if (!existingOutput
|
|
2162
|
+
|| ((!existingOutput.renderer && output.type === 1) )) {
|
|
2163
|
+
if (createWhenIdle) {
|
|
2164
|
+
this._webview.requestCreateOutputWhenWebviewIdle({ cellId: cell.id, cellHandle: cell.handle, cellUri: cell.uri, executionId: cell.internalMetadata.executionId }, output, cellTop, offset);
|
|
2165
|
+
}
|
|
2166
|
+
else {
|
|
2167
|
+
this._webview.createOutput({ cellId: cell.id, cellHandle: cell.handle, cellUri: cell.uri, executionId: cell.internalMetadata.executionId }, output, cellTop, offset);
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
else if (existingOutput.renderer
|
|
2171
|
+
&& output.type === 1
|
|
2172
|
+
&& existingOutput.renderer.id !== output.renderer.id) {
|
|
2173
|
+
this._webview.removeInsets([output.source]);
|
|
2174
|
+
this._webview.createOutput({ cellId: cell.id, cellHandle: cell.handle, cellUri: cell.uri }, output, cellTop, offset);
|
|
2175
|
+
}
|
|
2176
|
+
else if (existingOutput.versionId !== output.source.model.versionId) {
|
|
2177
|
+
this._webview.updateOutput({ cellId: cell.id, cellHandle: cell.handle, cellUri: cell.uri, executionId: cell.internalMetadata.executionId }, output, cellTop, offset);
|
|
2178
|
+
}
|
|
2179
|
+
else {
|
|
2180
|
+
const outputIndex = cell.outputsViewModels.indexOf(output.source);
|
|
2181
|
+
const outputOffset = cell.getOutputOffset(outputIndex);
|
|
2182
|
+
this._webview.updateScrollTops([{
|
|
2183
|
+
cell,
|
|
2184
|
+
output: output.source,
|
|
2185
|
+
cellTop,
|
|
2186
|
+
outputOffset,
|
|
2187
|
+
forceDisplay: !cell.isOutputCollapsed,
|
|
2188
|
+
}], []);
|
|
2189
|
+
}
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
2192
|
+
async updateOutput(cell, output, offset) {
|
|
2193
|
+
this._insetModifyQueueByOutputId.queue(output.source.model.outputId, async () => {
|
|
2194
|
+
if (this._isDisposed || !this._webview) {
|
|
2195
|
+
return;
|
|
2196
|
+
}
|
|
2197
|
+
if (!this._webview.isResolved()) {
|
|
2198
|
+
await this._resolveWebview();
|
|
2199
|
+
}
|
|
2200
|
+
if (!this._webview || !this._list.webviewElement) {
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2203
|
+
if (!( this._webview.insetMapping.has(output.source))) {
|
|
2204
|
+
return this.createOutput(cell, output, offset, false);
|
|
2205
|
+
}
|
|
2206
|
+
if (output.type === 1 ) {
|
|
2207
|
+
this.notebookRendererMessaging.prepare(output.renderer.id);
|
|
2208
|
+
}
|
|
2209
|
+
const webviewTop = parseInt(this._list.webviewElement.domNode.style.top, 10);
|
|
2210
|
+
const top = !!webviewTop ? (0 - webviewTop) : 0;
|
|
2211
|
+
const cellTop = this._list.getCellViewScrollTop(cell) + top;
|
|
2212
|
+
this._webview.updateOutput({ cellId: cell.id, cellHandle: cell.handle, cellUri: cell.uri }, output, cellTop, offset);
|
|
2213
|
+
});
|
|
2214
|
+
}
|
|
2215
|
+
async copyOutputImage(cellOutput) {
|
|
2216
|
+
this._webview?.copyImage(cellOutput);
|
|
2217
|
+
}
|
|
2218
|
+
removeInset(output) {
|
|
2219
|
+
this._insetModifyQueueByOutputId.queue(output.model.outputId, async () => {
|
|
2220
|
+
if (this._isDisposed || !this._webview) {
|
|
2221
|
+
return;
|
|
2222
|
+
}
|
|
2223
|
+
if (this._webview?.isResolved()) {
|
|
2224
|
+
this._webview.removeInsets([output]);
|
|
2225
|
+
}
|
|
2226
|
+
this._onDidRemoveOutput.fire(output);
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
hideInset(output) {
|
|
2230
|
+
this._insetModifyQueueByOutputId.queue(output.model.outputId, async () => {
|
|
2231
|
+
if (this._isDisposed || !this._webview) {
|
|
2232
|
+
return;
|
|
2233
|
+
}
|
|
2234
|
+
if (this._webview?.isResolved()) {
|
|
2235
|
+
this._webview.hideInset(output);
|
|
2236
|
+
}
|
|
2237
|
+
});
|
|
2238
|
+
}
|
|
2239
|
+
postMessage(message) {
|
|
2240
|
+
if (this._webview?.isResolved()) {
|
|
2241
|
+
this._webview.postKernelMessage(message);
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
addClassName(className) {
|
|
2245
|
+
this._overlayContainer.classList.add(className);
|
|
2246
|
+
}
|
|
2247
|
+
removeClassName(className) {
|
|
2248
|
+
this._overlayContainer.classList.remove(className);
|
|
2249
|
+
}
|
|
2250
|
+
cellAt(index) {
|
|
2251
|
+
return this.viewModel?.cellAt(index);
|
|
2252
|
+
}
|
|
2253
|
+
getCellByInfo(cellInfo) {
|
|
2254
|
+
const { cellHandle } = cellInfo;
|
|
2255
|
+
return this.viewModel?.viewCells.find(vc => vc.handle === cellHandle);
|
|
2256
|
+
}
|
|
2257
|
+
getCellByHandle(handle) {
|
|
2258
|
+
return this.viewModel?.getCellByHandle(handle);
|
|
2259
|
+
}
|
|
2260
|
+
getCellIndex(cell) {
|
|
2261
|
+
return this.viewModel?.getCellIndexByHandle(cell.handle);
|
|
2262
|
+
}
|
|
2263
|
+
getNextVisibleCellIndex(index) {
|
|
2264
|
+
return this.viewModel?.getNextVisibleCellIndex(index);
|
|
2265
|
+
}
|
|
2266
|
+
getPreviousVisibleCellIndex(index) {
|
|
2267
|
+
return this.viewModel?.getPreviousVisibleCellIndex(index);
|
|
2268
|
+
}
|
|
2269
|
+
_updateScrollHeight() {
|
|
2270
|
+
if (this._isDisposed || !this._webview?.isResolved()) {
|
|
2271
|
+
return;
|
|
2272
|
+
}
|
|
2273
|
+
if (!this._list.webviewElement) {
|
|
2274
|
+
return;
|
|
2275
|
+
}
|
|
2276
|
+
const scrollHeight = this._list.scrollHeight;
|
|
2277
|
+
this._webview.element.style.height = `${scrollHeight + NOTEBOOK_WEBVIEW_BOUNDARY * 2}px`;
|
|
2278
|
+
const webviewTop = parseInt(this._list.webviewElement.domNode.style.top, 10);
|
|
2279
|
+
const top = !!webviewTop ? (0 - webviewTop) : 0;
|
|
2280
|
+
const updateItems = [];
|
|
2281
|
+
const removedItems = [];
|
|
2282
|
+
this._webview?.insetMapping.forEach((value, key) => {
|
|
2283
|
+
const cell = this.viewModel?.getCellByHandle(value.cellInfo.cellHandle);
|
|
2284
|
+
if (!cell || !(cell instanceof CodeCellViewModel)) {
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
this.viewModel?.viewCells.find(cell => cell.handle === value.cellInfo.cellHandle);
|
|
2288
|
+
const viewIndex = this._list.getViewIndex(cell);
|
|
2289
|
+
if (viewIndex === undefined) {
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
if (cell.outputsViewModels.indexOf(key) < 0) {
|
|
2293
|
+
removedItems.push(key);
|
|
2294
|
+
}
|
|
2295
|
+
const cellTop = this._list.getCellViewScrollTop(cell);
|
|
2296
|
+
const outputIndex = cell.outputsViewModels.indexOf(key);
|
|
2297
|
+
const outputOffset = cell.getOutputOffset(outputIndex);
|
|
2298
|
+
updateItems.push({
|
|
2299
|
+
cell,
|
|
2300
|
+
output: key,
|
|
2301
|
+
cellTop: cellTop + top,
|
|
2302
|
+
outputOffset,
|
|
2303
|
+
forceDisplay: false,
|
|
2304
|
+
});
|
|
2305
|
+
});
|
|
2306
|
+
this._webview.removeInsets(removedItems);
|
|
2307
|
+
const markdownUpdateItems = [];
|
|
2308
|
+
for (const cellId of ( this._webview.markupPreviewMapping.keys())) {
|
|
2309
|
+
const cell = this.viewModel?.viewCells.find(cell => cell.id === cellId);
|
|
2310
|
+
if (cell) {
|
|
2311
|
+
const cellTop = this._list.getCellViewScrollTop(cell);
|
|
2312
|
+
markdownUpdateItems.push({ id: cellId, top: cellTop + top });
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
if (markdownUpdateItems.length || updateItems.length) {
|
|
2316
|
+
this._debug('_list.onDidChangeContentHeight/markdown', markdownUpdateItems);
|
|
2317
|
+
this._webview?.updateScrollTops(updateItems, markdownUpdateItems);
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
_updateOutputHeight(cellInfo, output, outputHeight, isInit, source) {
|
|
2321
|
+
const cell = this.viewModel?.viewCells.find(vc => vc.handle === cellInfo.cellHandle);
|
|
2322
|
+
if (cell && cell instanceof CodeCellViewModel) {
|
|
2323
|
+
const outputIndex = cell.outputsViewModels.indexOf(output);
|
|
2324
|
+
this._debug('update cell output', cell.handle, outputHeight);
|
|
2325
|
+
cell.updateOutputHeight(outputIndex, outputHeight, source);
|
|
2326
|
+
this.layoutNotebookCell(cell, cell.layoutInfo.totalHeight);
|
|
2327
|
+
if (isInit) {
|
|
2328
|
+
this._onDidRenderOutput.fire(output);
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
_scheduleOutputHeightAck(cellInfo, outputId, height) {
|
|
2333
|
+
const wasEmpty = this._pendingOutputHeightAcks.size === 0;
|
|
2334
|
+
this._pendingOutputHeightAcks.set(outputId, { cellId: cellInfo.cellId, outputId, height });
|
|
2335
|
+
if (wasEmpty) {
|
|
2336
|
+
dom.scheduleAtNextAnimationFrame(dom.getWindow(this.getDomNode()), () => {
|
|
2337
|
+
this._debug('ack height');
|
|
2338
|
+
this._updateScrollHeight();
|
|
2339
|
+
this._webview?.ackHeight([...( this._pendingOutputHeightAcks.values())]);
|
|
2340
|
+
this._pendingOutputHeightAcks.clear();
|
|
2341
|
+
}, -1);
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
_getCellById(cellId) {
|
|
2345
|
+
return this.viewModel?.viewCells.find(vc => vc.id === cellId);
|
|
2346
|
+
}
|
|
2347
|
+
_updateMarkupCellHeight(cellId, height, isInit) {
|
|
2348
|
+
const cell = this._getCellById(cellId);
|
|
2349
|
+
if (cell && cell instanceof MarkupCellViewModel) {
|
|
2350
|
+
const { bottomToolbarGap } = this._notebookOptions.computeBottomToolbarDimensions(this.viewModel?.viewType);
|
|
2351
|
+
this._debug('updateMarkdownCellHeight', cell.handle, height + bottomToolbarGap, isInit);
|
|
2352
|
+
cell.renderedMarkdownHeight = height;
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
_setMarkupCellEditState(cellId, editState) {
|
|
2356
|
+
const cell = this._getCellById(cellId);
|
|
2357
|
+
if (cell instanceof MarkupCellViewModel) {
|
|
2358
|
+
this.revealInView(cell);
|
|
2359
|
+
cell.updateEditState(editState, 'setMarkdownCellEditState');
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
_didStartDragMarkupCell(cellId, event) {
|
|
2363
|
+
const cell = this._getCellById(cellId);
|
|
2364
|
+
if (cell instanceof MarkupCellViewModel) {
|
|
2365
|
+
const webviewOffset = this._list.webviewElement ? -parseInt(this._list.webviewElement.domNode.style.top, 10) : 0;
|
|
2366
|
+
this._dndController?.startExplicitDrag(cell, event.dragOffsetY - webviewOffset);
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
_didDragMarkupCell(cellId, event) {
|
|
2370
|
+
const cell = this._getCellById(cellId);
|
|
2371
|
+
if (cell instanceof MarkupCellViewModel) {
|
|
2372
|
+
const webviewOffset = this._list.webviewElement ? -parseInt(this._list.webviewElement.domNode.style.top, 10) : 0;
|
|
2373
|
+
this._dndController?.explicitDrag(cell, event.dragOffsetY - webviewOffset);
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
_didDropMarkupCell(cellId, event) {
|
|
2377
|
+
const cell = this._getCellById(cellId);
|
|
2378
|
+
if (cell instanceof MarkupCellViewModel) {
|
|
2379
|
+
const webviewOffset = this._list.webviewElement ? -parseInt(this._list.webviewElement.domNode.style.top, 10) : 0;
|
|
2380
|
+
event.dragOffsetY -= webviewOffset;
|
|
2381
|
+
this._dndController?.explicitDrop(cell, event);
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
_didEndDragMarkupCell(cellId) {
|
|
2385
|
+
const cell = this._getCellById(cellId);
|
|
2386
|
+
if (cell instanceof MarkupCellViewModel) {
|
|
2387
|
+
this._dndController?.endExplicitDrag(cell);
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
_didResizeOutput(cellId) {
|
|
2391
|
+
const cell = this._getCellById(cellId);
|
|
2392
|
+
if (cell) {
|
|
2393
|
+
this._onDidResizeOutputEmitter.fire(cell);
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
_updatePerformanceMetadata(cellId, executionId, duration, rendererId) {
|
|
2397
|
+
if (!this.hasModel()) {
|
|
2398
|
+
return;
|
|
2399
|
+
}
|
|
2400
|
+
const cell = this._getCellById(cellId);
|
|
2401
|
+
const cellIndex = !cell ? undefined : this.getCellIndex(cell);
|
|
2402
|
+
if (cell?.internalMetadata.executionId === executionId && cellIndex !== undefined) {
|
|
2403
|
+
const renderDurationMap = cell.internalMetadata.renderDuration || {};
|
|
2404
|
+
renderDurationMap[rendererId] = (renderDurationMap[rendererId] ?? 0) + duration;
|
|
2405
|
+
this.textModel.applyEdits([
|
|
2406
|
+
{
|
|
2407
|
+
editType: 9 ,
|
|
2408
|
+
index: cellIndex,
|
|
2409
|
+
internalMetadata: {
|
|
2410
|
+
executionId: executionId,
|
|
2411
|
+
renderDuration: renderDurationMap
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
], true, undefined, () => undefined, undefined, false);
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
getContribution(id) {
|
|
2418
|
+
return (this._contributions.get(id) || null);
|
|
2419
|
+
}
|
|
2420
|
+
dispose() {
|
|
2421
|
+
this._isDisposed = true;
|
|
2422
|
+
this._webview?.dispose();
|
|
2423
|
+
this._webview = null;
|
|
2424
|
+
this.notebookEditorService.removeNotebookEditor(this);
|
|
2425
|
+
dispose(( this._contributions.values()));
|
|
2426
|
+
this._contributions.clear();
|
|
2427
|
+
this._localStore.clear();
|
|
2428
|
+
dispose(this._localCellStateListeners);
|
|
2429
|
+
this._list.dispose();
|
|
2430
|
+
this._listTopCellToolbar?.dispose();
|
|
2431
|
+
this._overlayContainer.remove();
|
|
2432
|
+
this.viewModel?.dispose();
|
|
2433
|
+
this._renderedEditors.clear();
|
|
2434
|
+
this._baseCellEditorOptions.forEach(v => v.dispose());
|
|
2435
|
+
this._baseCellEditorOptions.clear();
|
|
2436
|
+
this._notebookOverviewRulerContainer.remove();
|
|
2437
|
+
super.dispose();
|
|
2438
|
+
this._webview = null;
|
|
2439
|
+
this._webviewResolvePromise = null;
|
|
2440
|
+
this._webviewTransparentCover = null;
|
|
2441
|
+
this._dndController = null;
|
|
2442
|
+
this._listTopCellToolbar = null;
|
|
2443
|
+
this._notebookViewModel = undefined;
|
|
2444
|
+
this._cellContextKeyManager = null;
|
|
2445
|
+
this._notebookTopToolbar = null;
|
|
2446
|
+
this._list = null;
|
|
2447
|
+
this._listViewInfoAccessor = null;
|
|
2448
|
+
this._pendingLayouts = null;
|
|
2449
|
+
this._listDelegate = null;
|
|
2450
|
+
}
|
|
2451
|
+
toJSON() {
|
|
2452
|
+
return {
|
|
2453
|
+
notebookUri: this.viewModel?.uri,
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
};
|
|
2457
|
+
NotebookEditorWidget = ( __decorate([
|
|
2458
|
+
( __param(2, IInstantiationService)),
|
|
2459
|
+
( __param(3, IEditorGroupsService)),
|
|
2460
|
+
( __param(4, INotebookRendererMessagingService)),
|
|
2461
|
+
( __param(5, INotebookEditorService)),
|
|
2462
|
+
( __param(6, INotebookKernelService)),
|
|
2463
|
+
( __param(7, INotebookService)),
|
|
2464
|
+
( __param(8, IConfigurationService)),
|
|
2465
|
+
( __param(9, IContextKeyService)),
|
|
2466
|
+
( __param(10, ILayoutService)),
|
|
2467
|
+
( __param(11, IContextMenuService)),
|
|
2468
|
+
( __param(12, ITelemetryService)),
|
|
2469
|
+
( __param(13, INotebookExecutionService)),
|
|
2470
|
+
( __param(14, INotebookExecutionStateService)),
|
|
2471
|
+
( __param(15, IEditorProgressService)),
|
|
2472
|
+
( __param(16, INotebookLoggingService)),
|
|
2473
|
+
( __param(17, IKeybindingService))
|
|
2474
|
+
], NotebookEditorWidget));
|
|
2475
|
+
registerZIndex(ZIndex.Base, 5, 'notebook-progress-bar');
|
|
2476
|
+
registerZIndex(ZIndex.Base, 10, 'notebook-list-insertion-indicator');
|
|
2477
|
+
registerZIndex(ZIndex.Base, 20, 'notebook-cell-editor-outline');
|
|
2478
|
+
registerZIndex(ZIndex.Base, 25, 'notebook-scrollbar');
|
|
2479
|
+
registerZIndex(ZIndex.Base, 26, 'notebook-cell-status');
|
|
2480
|
+
registerZIndex(ZIndex.Base, 26, 'notebook-folding-indicator');
|
|
2481
|
+
registerZIndex(ZIndex.Base, 27, 'notebook-output');
|
|
2482
|
+
registerZIndex(ZIndex.Base, 28, 'notebook-cell-bottom-toolbar-container');
|
|
2483
|
+
registerZIndex(ZIndex.Base, 29, 'notebook-run-button-container');
|
|
2484
|
+
registerZIndex(ZIndex.Base, 29, 'notebook-input-collapse-condicon');
|
|
2485
|
+
registerZIndex(ZIndex.Base, 30, 'notebook-cell-output-toolbar');
|
|
2486
|
+
registerZIndex(ZIndex.Base, 31, 'notebook-sticky-scroll');
|
|
2487
|
+
registerZIndex(ZIndex.Sash, 1, 'notebook-cell-expand-part-button');
|
|
2488
|
+
registerZIndex(ZIndex.Sash, 2, 'notebook-cell-toolbar');
|
|
2489
|
+
registerZIndex(ZIndex.Sash, 3, 'notebook-cell-toolbar-dropdown-active');
|
|
2490
|
+
const notebookCellBorder = registerColor('notebook.cellBorderColor', {
|
|
2491
|
+
dark: ( transparent(listInactiveSelectionBackground, 1)),
|
|
2492
|
+
light: ( transparent(listInactiveSelectionBackground, 1)),
|
|
2493
|
+
hcDark: PANEL_BORDER,
|
|
2494
|
+
hcLight: PANEL_BORDER
|
|
2495
|
+
}, ( nls.localizeWithPath(
|
|
2496
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2497
|
+
'notebook.cellBorderColor',
|
|
2498
|
+
"The border color for notebook cells."
|
|
2499
|
+
)));
|
|
2500
|
+
registerColor('notebook.focusedEditorBorder', {
|
|
2501
|
+
light: focusBorder,
|
|
2502
|
+
dark: focusBorder,
|
|
2503
|
+
hcDark: focusBorder,
|
|
2504
|
+
hcLight: focusBorder
|
|
2505
|
+
}, ( nls.localizeWithPath(
|
|
2506
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2507
|
+
'notebook.focusedEditorBorder',
|
|
2508
|
+
"The color of the notebook cell editor border."
|
|
2509
|
+
)));
|
|
2510
|
+
const cellStatusIconSuccess = registerColor('notebookStatusSuccessIcon.foreground', {
|
|
2511
|
+
light: debugIconStartForeground,
|
|
2512
|
+
dark: debugIconStartForeground,
|
|
2513
|
+
hcDark: debugIconStartForeground,
|
|
2514
|
+
hcLight: debugIconStartForeground
|
|
2515
|
+
}, ( nls.localizeWithPath(
|
|
2516
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2517
|
+
'notebookStatusSuccessIcon.foreground',
|
|
2518
|
+
"The error icon color of notebook cells in the cell status bar."
|
|
2519
|
+
)));
|
|
2520
|
+
const runningCellRulerDecorationColor = registerColor('notebookEditorOverviewRuler.runningCellForeground', {
|
|
2521
|
+
light: debugIconStartForeground,
|
|
2522
|
+
dark: debugIconStartForeground,
|
|
2523
|
+
hcDark: debugIconStartForeground,
|
|
2524
|
+
hcLight: debugIconStartForeground
|
|
2525
|
+
}, ( nls.localizeWithPath(
|
|
2526
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2527
|
+
'notebookEditorOverviewRuler.runningCellForeground',
|
|
2528
|
+
"The color of the running cell decoration in the notebook editor overview ruler."
|
|
2529
|
+
)));
|
|
2530
|
+
const cellStatusIconError = registerColor('notebookStatusErrorIcon.foreground', {
|
|
2531
|
+
light: errorForeground,
|
|
2532
|
+
dark: errorForeground,
|
|
2533
|
+
hcDark: errorForeground,
|
|
2534
|
+
hcLight: errorForeground
|
|
2535
|
+
}, ( nls.localizeWithPath(
|
|
2536
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2537
|
+
'notebookStatusErrorIcon.foreground',
|
|
2538
|
+
"The error icon color of notebook cells in the cell status bar."
|
|
2539
|
+
)));
|
|
2540
|
+
registerColor('notebookStatusRunningIcon.foreground', {
|
|
2541
|
+
light: foreground,
|
|
2542
|
+
dark: foreground,
|
|
2543
|
+
hcDark: foreground,
|
|
2544
|
+
hcLight: foreground
|
|
2545
|
+
}, ( nls.localizeWithPath(
|
|
2546
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2547
|
+
'notebookStatusRunningIcon.foreground',
|
|
2548
|
+
"The running icon color of notebook cells in the cell status bar."
|
|
2549
|
+
)));
|
|
2550
|
+
registerColor('notebook.outputContainerBorderColor', {
|
|
2551
|
+
dark: null,
|
|
2552
|
+
light: null,
|
|
2553
|
+
hcDark: null,
|
|
2554
|
+
hcLight: null
|
|
2555
|
+
}, ( nls.localizeWithPath(
|
|
2556
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2557
|
+
'notebook.outputContainerBorderColor',
|
|
2558
|
+
"The border color of the notebook output container."
|
|
2559
|
+
)));
|
|
2560
|
+
registerColor('notebook.outputContainerBackgroundColor', {
|
|
2561
|
+
dark: null,
|
|
2562
|
+
light: null,
|
|
2563
|
+
hcDark: null,
|
|
2564
|
+
hcLight: null
|
|
2565
|
+
}, ( nls.localizeWithPath(
|
|
2566
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2567
|
+
'notebook.outputContainerBackgroundColor',
|
|
2568
|
+
"The color of the notebook output container background."
|
|
2569
|
+
)));
|
|
2570
|
+
registerColor('notebook.cellToolbarSeparator', {
|
|
2571
|
+
dark: ( ( Color.fromHex('#808080')).transparent(0.35)),
|
|
2572
|
+
light: ( ( Color.fromHex('#808080')).transparent(0.35)),
|
|
2573
|
+
hcDark: contrastBorder,
|
|
2574
|
+
hcLight: contrastBorder
|
|
2575
|
+
}, ( nls.localizeWithPath(
|
|
2576
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2577
|
+
'notebook.cellToolbarSeparator',
|
|
2578
|
+
"The color of the separator in the cell bottom toolbar"
|
|
2579
|
+
)));
|
|
2580
|
+
const focusedCellBackground = registerColor('notebook.focusedCellBackground', {
|
|
2581
|
+
dark: null,
|
|
2582
|
+
light: null,
|
|
2583
|
+
hcDark: null,
|
|
2584
|
+
hcLight: null
|
|
2585
|
+
}, ( nls.localizeWithPath(
|
|
2586
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2587
|
+
'focusedCellBackground',
|
|
2588
|
+
"The background color of a cell when the cell is focused."
|
|
2589
|
+
)));
|
|
2590
|
+
registerColor('notebook.selectedCellBackground', {
|
|
2591
|
+
dark: listInactiveSelectionBackground,
|
|
2592
|
+
light: listInactiveSelectionBackground,
|
|
2593
|
+
hcDark: null,
|
|
2594
|
+
hcLight: null
|
|
2595
|
+
}, ( nls.localizeWithPath(
|
|
2596
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2597
|
+
'selectedCellBackground',
|
|
2598
|
+
"The background color of a cell when the cell is selected."
|
|
2599
|
+
)));
|
|
2600
|
+
registerColor('notebook.cellHoverBackground', {
|
|
2601
|
+
dark: ( transparent(focusedCellBackground, .5)),
|
|
2602
|
+
light: ( transparent(focusedCellBackground, .7)),
|
|
2603
|
+
hcDark: null,
|
|
2604
|
+
hcLight: null
|
|
2605
|
+
}, ( nls.localizeWithPath(
|
|
2606
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2607
|
+
'notebook.cellHoverBackground',
|
|
2608
|
+
"The background color of a cell when the cell is hovered."
|
|
2609
|
+
)));
|
|
2610
|
+
registerColor('notebook.selectedCellBorder', {
|
|
2611
|
+
dark: notebookCellBorder,
|
|
2612
|
+
light: notebookCellBorder,
|
|
2613
|
+
hcDark: contrastBorder,
|
|
2614
|
+
hcLight: contrastBorder
|
|
2615
|
+
}, ( nls.localizeWithPath(
|
|
2616
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2617
|
+
'notebook.selectedCellBorder',
|
|
2618
|
+
"The color of the cell's top and bottom border when the cell is selected but not focused."
|
|
2619
|
+
)));
|
|
2620
|
+
registerColor('notebook.inactiveSelectedCellBorder', {
|
|
2621
|
+
dark: null,
|
|
2622
|
+
light: null,
|
|
2623
|
+
hcDark: focusBorder,
|
|
2624
|
+
hcLight: focusBorder
|
|
2625
|
+
}, ( nls.localizeWithPath(
|
|
2626
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2627
|
+
'notebook.inactiveSelectedCellBorder',
|
|
2628
|
+
"The color of the cell's borders when multiple cells are selected."
|
|
2629
|
+
)));
|
|
2630
|
+
registerColor('notebook.focusedCellBorder', {
|
|
2631
|
+
dark: focusBorder,
|
|
2632
|
+
light: focusBorder,
|
|
2633
|
+
hcDark: focusBorder,
|
|
2634
|
+
hcLight: focusBorder
|
|
2635
|
+
}, ( nls.localizeWithPath(
|
|
2636
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2637
|
+
'notebook.focusedCellBorder',
|
|
2638
|
+
"The color of the cell's focus indicator borders when the cell is focused."
|
|
2639
|
+
)));
|
|
2640
|
+
registerColor('notebook.inactiveFocusedCellBorder', {
|
|
2641
|
+
dark: notebookCellBorder,
|
|
2642
|
+
light: notebookCellBorder,
|
|
2643
|
+
hcDark: notebookCellBorder,
|
|
2644
|
+
hcLight: notebookCellBorder
|
|
2645
|
+
}, ( nls.localizeWithPath(
|
|
2646
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2647
|
+
'notebook.inactiveFocusedCellBorder',
|
|
2648
|
+
"The color of the cell's top and bottom border when a cell is focused while the primary focus is outside of the editor."
|
|
2649
|
+
)));
|
|
2650
|
+
registerColor('notebook.cellStatusBarItemHoverBackground', {
|
|
2651
|
+
light: ( new Color(( new RGBA(0, 0, 0, 0.08)))),
|
|
2652
|
+
dark: ( new Color(( new RGBA(255, 255, 255, 0.15)))),
|
|
2653
|
+
hcDark: ( new Color(( new RGBA(255, 255, 255, 0.15)))),
|
|
2654
|
+
hcLight: ( new Color(( new RGBA(0, 0, 0, 0.08)))),
|
|
2655
|
+
}, ( nls.localizeWithPath(
|
|
2656
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2657
|
+
'notebook.cellStatusBarItemHoverBackground',
|
|
2658
|
+
"The background color of notebook cell status bar items."
|
|
2659
|
+
)));
|
|
2660
|
+
registerColor('notebook.cellInsertionIndicator', {
|
|
2661
|
+
light: focusBorder,
|
|
2662
|
+
dark: focusBorder,
|
|
2663
|
+
hcDark: focusBorder,
|
|
2664
|
+
hcLight: focusBorder
|
|
2665
|
+
}, ( nls.localizeWithPath(
|
|
2666
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2667
|
+
'notebook.cellInsertionIndicator',
|
|
2668
|
+
"The color of the notebook cell insertion indicator."
|
|
2669
|
+
)));
|
|
2670
|
+
registerColor('notebookScrollbarSlider.background', {
|
|
2671
|
+
dark: scrollbarSliderBackground,
|
|
2672
|
+
light: scrollbarSliderBackground,
|
|
2673
|
+
hcDark: scrollbarSliderBackground,
|
|
2674
|
+
hcLight: scrollbarSliderBackground
|
|
2675
|
+
}, ( nls.localizeWithPath(
|
|
2676
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2677
|
+
'notebookScrollbarSliderBackground',
|
|
2678
|
+
"Notebook scrollbar slider background color."
|
|
2679
|
+
)));
|
|
2680
|
+
registerColor('notebookScrollbarSlider.hoverBackground', {
|
|
2681
|
+
dark: scrollbarSliderHoverBackground,
|
|
2682
|
+
light: scrollbarSliderHoverBackground,
|
|
2683
|
+
hcDark: scrollbarSliderHoverBackground,
|
|
2684
|
+
hcLight: scrollbarSliderHoverBackground
|
|
2685
|
+
}, ( nls.localizeWithPath(
|
|
2686
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2687
|
+
'notebookScrollbarSliderHoverBackground',
|
|
2688
|
+
"Notebook scrollbar slider background color when hovering."
|
|
2689
|
+
)));
|
|
2690
|
+
registerColor('notebookScrollbarSlider.activeBackground', {
|
|
2691
|
+
dark: scrollbarSliderActiveBackground,
|
|
2692
|
+
light: scrollbarSliderActiveBackground,
|
|
2693
|
+
hcDark: scrollbarSliderActiveBackground,
|
|
2694
|
+
hcLight: scrollbarSliderActiveBackground
|
|
2695
|
+
}, ( nls.localizeWithPath(
|
|
2696
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2697
|
+
'notebookScrollbarSliderActiveBackground',
|
|
2698
|
+
"Notebook scrollbar slider background color when clicked on."
|
|
2699
|
+
)));
|
|
2700
|
+
registerColor('notebook.symbolHighlightBackground', {
|
|
2701
|
+
dark: ( Color.fromHex('#ffffff0b')),
|
|
2702
|
+
light: ( Color.fromHex('#fdff0033')),
|
|
2703
|
+
hcDark: null,
|
|
2704
|
+
hcLight: null
|
|
2705
|
+
}, ( nls.localizeWithPath(
|
|
2706
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2707
|
+
'notebook.symbolHighlightBackground',
|
|
2708
|
+
"Background color of highlighted cell"
|
|
2709
|
+
)));
|
|
2710
|
+
registerColor('notebook.cellEditorBackground', {
|
|
2711
|
+
light: SIDE_BAR_BACKGROUND,
|
|
2712
|
+
dark: SIDE_BAR_BACKGROUND,
|
|
2713
|
+
hcDark: null,
|
|
2714
|
+
hcLight: null
|
|
2715
|
+
}, ( nls.localizeWithPath(
|
|
2716
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2717
|
+
'notebook.cellEditorBackground',
|
|
2718
|
+
"Cell editor background color."
|
|
2719
|
+
)));
|
|
2720
|
+
const notebookEditorBackground = registerColor('notebook.editorBackground', {
|
|
2721
|
+
light: EDITOR_PANE_BACKGROUND,
|
|
2722
|
+
dark: EDITOR_PANE_BACKGROUND,
|
|
2723
|
+
hcDark: null,
|
|
2724
|
+
hcLight: null
|
|
2725
|
+
}, ( nls.localizeWithPath(
|
|
2726
|
+
'vs/workbench/contrib/notebook/browser/notebookEditorWidget',
|
|
2727
|
+
'notebook.editorBackground',
|
|
2728
|
+
"Notebook background color."
|
|
2729
|
+
)));
|
|
2730
|
+
export { NotebookEditorWidget, cellStatusIconError, cellStatusIconSuccess, focusedCellBackground, getDefaultNotebookCreationOptions, notebookCellBorder, runningCellRulerDecorationColor };
|