@workbench-kit/react 0.0.2-prototype.0.2.6 → 0.0.2-prototype.0.2.8
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 +87 -0
- package/package.json +20 -18
- package/src/brand/TilepaperAppIcon.tsx +181 -181
- package/src/brand/index.ts +2 -2
- package/src/brand/tilepaper-app-icon-geometry.ts +201 -201
- package/src/icons/WorkbenchIcon.tsx +57 -57
- package/src/icons/WorkbenchIconContext.tsx +25 -25
- package/src/icons/file-icon.ts +154 -154
- package/src/icons/index.ts +17 -17
- package/src/icons/resolveWorkbenchIcon.ts +48 -48
- package/src/icons/types.ts +28 -28
- package/src/index.ts +735 -735
- package/src/jdw/JdwPreview.tsx +195 -195
- package/src/jdw/JdwPreviewViewport.tsx +190 -190
- package/src/jdw/JsonCodeEditorPane.tsx +425 -424
- package/src/jdw/builtins/renderBuiltinWidgetLeaf.tsx +130 -130
- package/src/jdw/createBuiltinJdwRegistry.ts +436 -436
- package/src/jdw/cssRenderBackend.tsx +223 -223
- package/src/jdw/document.ts +35 -35
- package/src/jdw/fixtures/jdw-fixtures.ts +52 -52
- package/src/jdw/fixtures/jdw-sample-screens.ts +524 -524
- package/src/jdw/index.ts +50 -50
- package/src/jdw/jdw-preview-viewport.css +41 -41
- package/src/jdw/parse.ts +1 -1
- package/src/jdw/renderJdw.tsx +73 -73
- package/src/json-config/JsonConfigWorkbench.tsx +313 -313
- package/src/json-config/index.ts +6 -6
- package/src/json-config/json-config-editor-state.ts +42 -42
- package/src/layout/ViewEmptyState.tsx +14 -14
- package/src/layout/WorkbenchCanvas.tsx +956 -956
- package/src/layout/WorkbenchFullscreen.tsx +368 -368
- package/src/layout/WorkbenchLayout.tsx +8 -8
- package/src/layout/WorkbenchLayoutBase.tsx +335 -335
- package/src/layout/WorkbenchMediaPreviewViewport.tsx +122 -122
- package/src/layout/WorkbenchPropertyOverrideLabel.tsx +90 -90
- package/src/layout/WorkbenchPropertyPanel.tsx +633 -633
- package/src/layout/WorkbenchPropertySearch.tsx +51 -51
- package/src/layout/WorkbenchTree.tsx +350 -350
- package/src/layout/canvas/canvas-drag-ghost.css +21 -21
- package/src/layout/canvas/canvas-drag-preview-frame.css +15 -15
- package/src/layout/canvas/canvas-drop-indicator.css +16 -16
- package/src/layout/canvas/canvas-frame-handle.css +37 -37
- package/src/layout/canvas/canvas-frame-surface.css +24 -24
- package/src/layout/canvas/canvas-guide-block.css +17 -17
- package/src/layout/canvas/canvas-guide-layer.css +6 -6
- package/src/layout/canvas/canvas-guide-line.css +22 -22
- package/src/layout/canvas/canvas-item-badge.css +23 -23
- package/src/layout/canvas/canvas-item-frame.css +54 -54
- package/src/layout/canvas/canvas-pane-surface.css +9 -9
- package/src/layout/canvas/canvas-placeholder.css +21 -21
- package/src/layout/canvas/canvas-resize-frame.css +9 -9
- package/src/layout/canvas/canvas-resize-handle.css +74 -74
- package/src/layout/canvas/canvas-resize-preview.css +11 -11
- package/src/layout/canvas/canvas-selection-marquee.css +14 -14
- package/src/layout/canvas/canvas-viewport.css +18 -18
- package/src/layout/canvas/index.css +19 -19
- package/src/layout/canvas/preview-canvas.css +144 -144
- package/src/layout/editor/editor-body.css +9 -9
- package/src/layout/editor/editor-bottom-panel.css +44 -44
- package/src/layout/editor/editor-frame.css +14 -14
- package/src/layout/editor/editor-viewport.css +7 -7
- package/src/layout/editor/floating-menu.css +91 -91
- package/src/layout/editor/index.css +10 -10
- package/src/layout/editor/parse-error.css +9 -9
- package/src/layout/editor/problem-item.css +52 -52
- package/src/layout/editor/problem-list.css +7 -7
- package/src/layout/editor/render-surface.css +13 -13
- package/src/layout/fillScrollContract.ts +49 -49
- package/src/layout/fullscreen/fullscreen-backdrop.css +31 -31
- package/src/layout/fullscreen/fullscreen-button.css +44 -44
- package/src/layout/fullscreen/fullscreen-carousel.css +20 -20
- package/src/layout/fullscreen/fullscreen-content.css +8 -8
- package/src/layout/fullscreen/fullscreen-empty.css +16 -16
- package/src/layout/fullscreen/fullscreen-header.css +77 -77
- package/src/layout/fullscreen/fullscreen-hero.css +41 -41
- package/src/layout/fullscreen/fullscreen-nav-button.css +29 -29
- package/src/layout/fullscreen/fullscreen-option.css +83 -83
- package/src/layout/fullscreen/fullscreen-pill-row.css +6 -6
- package/src/layout/fullscreen/fullscreen-pill.css +10 -10
- package/src/layout/fullscreen/fullscreen-root.css +11 -11
- package/src/layout/fullscreen/index.css +13 -13
- package/src/layout/index.ts +156 -156
- package/src/layout/layout-base/banner.css +32 -32
- package/src/layout/layout-base/center.css +7 -7
- package/src/layout/layout-base/column.css +7 -7
- package/src/layout/layout-base/divider.css +5 -5
- package/src/layout/layout-base/empty.css +12 -12
- package/src/layout/layout-base/fill-scroll.css +36 -36
- package/src/layout/layout-base/fill.css +18 -18
- package/src/layout/layout-base/index.css +13 -13
- package/src/layout/layout-base/pane.css +6 -6
- package/src/layout/layout-base/panel-scroll.css +5 -5
- package/src/layout/layout-base/panel-surface.css +14 -14
- package/src/layout/layout-base/root.css +9 -9
- package/src/layout/layout-base/section-title.css +8 -8
- package/src/layout/layout.css +10 -10
- package/src/layout/layoutHelpers.ts +27 -27
- package/src/layout/media/index.css +2 -2
- package/src/layout/media/media-preview-viewport.css +69 -69
- package/src/layout/panel/Panel.tsx +161 -161
- package/src/layout/panel/TemplateGallery.tsx +90 -90
- package/src/layout/panel/WorkbenchAuthoringShell.tsx +57 -57
- package/src/layout/panel/WorkbenchLabeledPane.tsx +81 -81
- package/src/layout/panel/WorkbenchSidebarStack.tsx +15 -15
- package/src/layout/panel/filter-bar.css +59 -59
- package/src/layout/panel/index.css +7 -7
- package/src/layout/panel/index.ts +70 -70
- package/src/layout/panel/preview-pane.css +63 -63
- package/src/layout/panel/template-gallery.css +131 -131
- package/src/layout/panel/workbench-authoring-shell.css +48 -48
- package/src/layout/panel/workbench-labeled-pane.css +69 -69
- package/src/layout/panel/workbench-sidebar-stack.css +18 -18
- package/src/layout/property/color-input.css +8 -8
- package/src/layout/property/color-row.css +6 -6
- package/src/layout/property/index.css +15 -15
- package/src/layout/property/property-card.css +8 -8
- package/src/layout/property/property-grid.css +24 -24
- package/src/layout/property/property-hint.css +4 -4
- package/src/layout/property/property-inline.css +10 -10
- package/src/layout/property/property-key-value.css +29 -29
- package/src/layout/property/property-override-label.css +34 -34
- package/src/layout/property/property-panel.css +20 -20
- package/src/layout/property/property-row.css +17 -17
- package/src/layout/property/property-search.css +43 -43
- package/src/layout/property/property-section.css +97 -97
- package/src/layout/property/property-stack.css +11 -11
- package/src/layout/property/property-toggle.css +14 -14
- package/src/layout/propertyFieldFilter.ts +84 -84
- package/src/layout/sidebar/SideBarViewFrame.tsx +235 -235
- package/src/layout/sidebar/SideBarViewTabStrip.tsx +60 -60
- package/src/layout/sidebar/SideBarViewTitleMenu.tsx +75 -75
- package/src/layout/sidebar/SidebarActionIconBar.tsx +242 -242
- package/src/layout/sidebar/SidebarSectionNestingContext.tsx +21 -21
- package/src/layout/sidebar/SidebarSlotChrome.tsx +32 -32
- package/src/layout/sidebar/SidebarToolbar.tsx +10 -10
- package/src/layout/sidebar/WorkbenchActionSidebar.tsx +73 -73
- package/src/layout/sidebar/WorkbenchSidebarActions.tsx +328 -328
- package/src/layout/sidebar/WorkbenchSidebarSectionStack.tsx +165 -165
- package/src/layout/sidebar/index.css +5 -5
- package/src/layout/sidebar/index.ts +55 -55
- package/src/layout/sidebar/sidebar-chrome.css +95 -95
- package/src/layout/sidebar/sidebar-section-stack.css +25 -25
- package/src/layout/sidebar/sidebar-section.css +124 -124
- package/src/layout/sidebar/sidebar-view.css +290 -290
- package/src/layout/tree/drag-preview.css +25 -25
- package/src/layout/tree/index.css +10 -10
- package/src/layout/tree/template-glyph.css +96 -96
- package/src/layout/tree/tree-action.css +20 -20
- package/src/layout/tree/tree-drag-overlay.css +13 -13
- package/src/layout/tree/tree-drop-line.css +17 -17
- package/src/layout/tree/tree-drop-zone.css +13 -13
- package/src/layout/tree/tree-expander.css +23 -23
- package/src/layout/tree/tree-item.css +93 -93
- package/src/layout/tree/tree.css +49 -49
- package/src/layout/usePreviewViewport.ts +428 -428
- package/src/modal/ConfirmDialog.tsx +61 -61
- package/src/modal/Modal.tsx +243 -213
- package/src/modal/ModalResizeHandles.tsx +40 -40
- package/src/modal/ModalTitlebar.tsx +86 -86
- package/src/modal/modal.css +291 -291
- package/src/modal/modalContainer.ts +36 -36
- package/src/modal/modalPosition.ts +36 -36
- package/src/modal/modalSize.ts +84 -84
- package/src/modal/modalTypes.ts +13 -13
- package/src/modal/useModalContainerViewport.ts +41 -41
- package/src/modal/useModalDrag.ts +118 -118
- package/src/modal/useModalFocusTrap.ts +142 -0
- package/src/modal/useModalResize.ts +122 -122
- package/src/modal/useModalWindowFrame.ts +122 -122
- package/src/overlay/ContextMenu.tsx +124 -124
- package/src/overlay/clampFixedOverlayPosition.ts +22 -22
- package/src/overlay/context-menu.css +127 -127
- package/src/overlay/index.ts +31 -31
- package/src/overlay/measureAnchoredOverlayPanel.ts +107 -107
- package/src/overlay/overlay.css +2 -2
- package/src/overlay/pointerPassthroughRegion.ts +83 -83
- package/src/overlay/useAnchoredOverlayPanel.ts +222 -222
- package/src/overlay/useClampedFixedOverlayPosition.ts +27 -27
- package/src/overlay/useContextMenuState.ts +59 -59
- package/src/overlay/useFixedOverlayDismiss.ts +49 -49
- package/src/overlay/usePointerPassthroughRegion.ts +87 -87
- package/src/primitives/absolute-box/AbsoluteBox.tsx +46 -46
- package/src/primitives/absolute-box/index.ts +1 -1
- package/src/primitives/badge/Badge.tsx +14 -14
- package/src/primitives/badge/badge.css +20 -20
- package/src/primitives/badge/index.ts +1 -1
- package/src/primitives/button/Button.tsx +45 -45
- package/src/primitives/button/button.css +76 -76
- package/src/primitives/button/index.ts +1 -1
- package/src/primitives/catalog-browse-card/CatalogBrowseCard.tsx +121 -121
- package/src/primitives/catalog-browse-card/catalog-browse-card.css +175 -175
- package/src/primitives/catalog-browse-card/index.ts +1 -1
- package/src/primitives/catalog-browse-pane/CatalogBrowseFacetChips.tsx +59 -59
- package/src/primitives/catalog-browse-pane/CatalogBrowsePane.tsx +360 -360
- package/src/primitives/catalog-browse-pane/catalog-browse-facet-chips.css +8 -8
- package/src/primitives/catalog-browse-pane/catalog-browse-pane.css +84 -84
- package/src/primitives/catalog-browse-pane/filterCatalogBrowseItems.ts +27 -27
- package/src/primitives/catalog-browse-pane/index.ts +3 -3
- package/src/primitives/catalog-filter-overlay/CatalogFilterOverlay.tsx +73 -73
- package/src/primitives/catalog-filter-overlay/catalog-filter-overlay.css +65 -65
- package/src/primitives/catalog-filter-overlay/index.ts +1 -1
- package/src/primitives/checkbox/Checkbox.tsx +40 -40
- package/src/primitives/checkbox/checkbox.css +81 -81
- package/src/primitives/checkbox/index.ts +1 -1
- package/src/primitives/chip/Chip.tsx +43 -43
- package/src/primitives/chip/chip.css +110 -110
- package/src/primitives/chip/index.ts +2 -2
- package/src/primitives/clearable-text-input/ClearableTextInput.tsx +78 -78
- package/src/primitives/clearable-text-input/clearable-text-input.css +15 -15
- package/src/primitives/clearable-text-input/index.ts +1 -1
- package/src/primitives/codicon/Codicon.tsx +20 -20
- package/src/primitives/codicon/index.ts +1 -1
- package/src/primitives/empty-state/EmptyState.tsx +33 -33
- package/src/primitives/empty-state/empty-state.css +20 -20
- package/src/primitives/empty-state/index.ts +1 -1
- package/src/primitives/external-link-button/ExternalLinkButton.tsx +56 -56
- package/src/primitives/external-link-button/index.ts +1 -1
- package/src/primitives/field/Field.tsx +39 -39
- package/src/primitives/field/field.css +51 -51
- package/src/primitives/field/index.ts +1 -1
- package/src/primitives/file-icon/FileIcon.tsx +21 -21
- package/src/primitives/file-icon/index.ts +1 -1
- package/src/primitives/icon-button/IconButton.tsx +37 -37
- package/src/primitives/icon-button/icon-button.css +46 -46
- package/src/primitives/icon-button/index.ts +1 -1
- package/src/primitives/index.ts +265 -265
- package/src/primitives/library-detail-layout/LibraryDetailLayout.tsx +135 -135
- package/src/primitives/library-detail-layout/index.ts +1 -1
- package/src/primitives/library-detail-layout/library-detail-layout.css +169 -169
- package/src/primitives/library-facet-filter-panel/LibraryFacetFilterPanel.tsx +454 -454
- package/src/primitives/library-facet-filter-panel/index.ts +1 -1
- package/src/primitives/library-facet-filter-panel/library-facet-filter-panel.css +205 -205
- package/src/primitives/library-facet-filter-strip/LibraryFacetFilterStrip.tsx +527 -527
- package/src/primitives/library-facet-filter-strip/index.ts +1 -1
- package/src/primitives/library-facet-filter-strip/library-facet-filter-strip.css +31 -31
- package/src/primitives/list/List.tsx +120 -120
- package/src/primitives/list/index.ts +1 -1
- package/src/primitives/list/list-empty-state.css +10 -10
- package/src/primitives/list/list-item.css +93 -93
- package/src/primitives/list/list.css +6 -6
- package/src/primitives/number-input/NumberInput.tsx +235 -235
- package/src/primitives/number-input/index.ts +1 -1
- package/src/primitives/number-input/number-input.css +105 -105
- package/src/primitives/panel-loading/PanelLoading.tsx +29 -29
- package/src/primitives/panel-loading/index.ts +1 -1
- package/src/primitives/panel-loading/panel-loading.css +16 -16
- package/src/primitives/panel-surface/panel-surface.css +77 -77
- package/src/primitives/primitives.css +36 -36
- package/src/primitives/record-media-hero/RecordMediaHero.tsx +81 -81
- package/src/primitives/record-media-hero/index.ts +1 -1
- package/src/primitives/record-media-hero/record-media-hero.css +84 -84
- package/src/primitives/scroll-area/ScrollArea.tsx +200 -200
- package/src/primitives/scroll-area/index.ts +1 -1
- package/src/primitives/scroll-area/scroll-area-overlay.css +69 -69
- package/src/primitives/scroll-area-infinite-load/ScrollAreaInfiniteSentinel.tsx +22 -22
- package/src/primitives/scroll-area-infinite-load/index.ts +2 -2
- package/src/primitives/scroll-area-infinite-load/scroll-area-infinite-sentinel.css +6 -6
- package/src/primitives/scroll-area-infinite-load/useScrollAreaInfiniteLoad.ts +84 -84
- package/src/primitives/searchable-multi-select/SearchableMultiSelect.tsx +378 -378
- package/src/primitives/searchable-multi-select/index.ts +9 -9
- package/src/primitives/searchable-multi-select/overlay.ts +125 -125
- package/src/primitives/searchable-multi-select/searchable-multi-select.css +129 -129
- package/src/primitives/select/Select.tsx +284 -284
- package/src/primitives/select/index.ts +2 -2
- package/src/primitives/select/options.ts +38 -38
- package/src/primitives/select/overlay.ts +82 -82
- package/src/primitives/select/select.app.css +12 -12
- package/src/primitives/select/select.css +177 -177
- package/src/primitives/select/types.ts +18 -18
- package/src/primitives/styles.css +6 -6
- package/src/primitives/tabbed-panels/TabbedPanels.tsx +68 -68
- package/src/primitives/tabbed-panels/index.ts +2 -2
- package/src/primitives/tabbed-panels/tabbed-panels.css +58 -58
- package/src/primitives/text-area/TextArea.tsx +37 -37
- package/src/primitives/text-area/index.ts +1 -1
- package/src/primitives/text-input/TextInput.tsx +34 -34
- package/src/primitives/text-input/index.ts +1 -1
- package/src/primitives/text-input/input.css +54 -54
- package/src/primitives/toolbar/Toolbar.tsx +8 -8
- package/src/primitives/toolbar/index.ts +1 -1
- package/src/primitives/visually-hidden/visually-hidden.css +11 -11
- package/src/primitives/workbench-editor/WorkbenchEditor.tsx +432 -432
- package/src/primitives/workbench-editor/button-group.css +10 -10
- package/src/primitives/workbench-editor/editor-tabs.css +201 -201
- package/src/primitives/workbench-editor/index.ts +1 -1
- package/src/primitives/workbench-editor/resizable-panels.css +53 -53
- package/src/primitives/workbench-editor/segmented-control.css +98 -98
- package/src/primitives/workbench-media-slot/WorkbenchMediaPlaceholder.tsx +25 -25
- package/src/primitives/workbench-media-slot/WorkbenchMediaSlot.tsx +60 -60
- package/src/primitives/workbench-media-slot/index.ts +2 -2
- package/src/primitives/workbench-media-slot/media-slot.css +72 -72
- package/src/primitives/workbench-thumbnail/WorkbenchThumbnail.tsx +38 -38
- package/src/primitives/workbench-thumbnail/index.ts +1 -1
- package/src/primitives/workbench-thumbnail/thumbnail.css +69 -69
- package/src/scrollbars.css +144 -144
- package/src/styles.css +16 -17
- package/src/test-utils/workbenchMonacoMock.tsx +37 -37
- package/src/utils/codicon.ts +17 -17
- package/src/utils/dragMime.ts +89 -89
- package/src/utils/useWorkbenchMediaImage.ts +37 -37
- package/src/widget-asset/WidgetAssetEditor.tsx +142 -142
- package/src/widget-asset/WidgetAssetMetadataForm.tsx +82 -82
- package/src/widget-asset/WidgetAssetModeControls.tsx +42 -42
- package/src/widget-asset/WidgetAssetSourceEditor.tsx +50 -50
- package/src/widget-asset/WidgetAssetWorkbench.tsx +111 -111
- package/src/widget-asset/index.ts +17 -17
- package/src/widget-asset/widget-asset-document.ts +37 -37
- package/src/widget-asset/widget-asset-mode.ts +3 -3
- package/src/widget-studio/builtin-widget-asset-catalog.ts +12 -12
- package/src/widget-studio/create-widget-studio-workspace-editor.tsx +78 -78
- package/src/widget-studio/index.ts +10 -10
- package/src/widget-studio/resolve-widget-studio-asset-catalog.ts +43 -43
- package/src/widget-tree/WidgetAssetPalette.tsx +105 -105
- package/src/widget-tree/WidgetInspectorPanel.tsx +316 -316
- package/src/widget-tree/WidgetSourceEditor.tsx +143 -143
- package/src/widget-tree/WidgetTreeCanvasPreview.tsx +875 -875
- package/src/widget-tree/WidgetTreeLab.tsx +600 -600
- package/src/widget-tree/WidgetTreeModeControls.tsx +73 -73
- package/src/widget-tree/WidgetTreeSidePanel.tsx +39 -39
- package/src/widget-tree/WidgetTreeView.tsx +797 -797
- package/src/widget-tree/WidgetTreeWorkbench.tsx +155 -155
- package/src/widget-tree/WidgetTreeWorkspaceShell.tsx +172 -172
- package/src/widget-tree/demo-registry.ts +32 -32
- package/src/widget-tree/demo-widget-assets.ts +4 -4
- package/src/widget-tree/index.ts +45 -45
- package/src/widget-tree/widget-placement-asset-dnd.ts +35 -35
- package/src/widget-tree/widget-tree-document.ts +14 -14
- package/src/widget-tree/widget-tree-editor-state.ts +40 -40
- package/src/widget-tree/widget-tree-layout.ts +76 -76
- package/src/widget-tree/widget-tree-mode.ts +7 -7
- package/src/widget-tree/widget-tree-play-helpers.ts +85 -85
- package/src/workbench/auth/WorkbenchAuthGate.tsx +61 -61
- package/src/workbench/auth/WorkbenchLoginView.tsx +633 -633
- package/src/workbench/auth/auth-flows.css +440 -440
- package/src/workbench/auth/auth.css +3 -3
- package/src/workbench/auth/index.ts +19 -19
- package/src/workbench/auth/profile-modals.css +115 -115
- package/src/workbench/bootstrap/WorkbenchBootstrapGate.tsx +45 -45
- package/src/workbench/bootstrap/WorkbenchBootstrapView.tsx +100 -100
- package/src/workbench/bootstrap/index.ts +12 -12
- package/src/workbench/bootstrap/useWorkbenchBootstrap.ts +130 -130
- package/src/workbench/chat/ChatCommandProposalCard.tsx +115 -115
- package/src/workbench/chat/ChatComposer.tsx +163 -163
- package/src/workbench/chat/ChatConversationBar.tsx +134 -134
- package/src/workbench/chat/ChatHistoryMenu.tsx +171 -171
- package/src/workbench/chat/ChatHistoryMenuRow.tsx +74 -74
- package/src/workbench/chat/ChatMessageCollapsible.tsx +119 -115
- package/src/workbench/chat/ChatMessageItem.tsx +376 -318
- package/src/workbench/chat/ChatMessageList.tsx +134 -134
- package/src/workbench/chat/ChatPanel.tsx +177 -168
- package/src/workbench/chat/ChatPhasedRunProgress.tsx +275 -202
- package/src/workbench/chat/ChatRenameDialog.tsx +77 -77
- package/src/workbench/chat/chat-conversation.css +273 -273
- package/src/workbench/chat/chat-ui.css +1132 -1124
- package/src/workbench/chat/chat.css +3 -3
- package/src/workbench/chat/chatConversation.ts +46 -46
- package/src/workbench/chat/chatHistoryRowMenuItems.ts +29 -29
- package/src/workbench/chat/chatMessageMeta.tsx +252 -252
- package/src/workbench/chat/chatScroll.ts +22 -22
- package/src/workbench/chat/index.ts +65 -64
- package/src/workbench/chat/slashCommand.ts +26 -26
- package/src/workbench/chat/types.ts +45 -45
- package/src/workbench/chat/useCancelRuntimeOnUnmount.ts +60 -60
- package/src/workbench/chat/useChatPrependPagination.ts +233 -233
- package/src/workbench/chat/useChatRuntimeState.ts +64 -64
- package/src/workbench/chat/useSlashCommandSuggest.ts +154 -154
- package/src/workbench/{WorkbenchModalPortal.tsx → chrome/WorkbenchModalPortal.tsx} +52 -52
- package/src/workbench/{WorkbenchPlatformContext.tsx → chrome/WorkbenchPlatformContext.tsx} +31 -31
- package/src/workbench/chrome/index.css +6 -6
- package/src/workbench/chrome/workbench-chrome.css +4 -0
- package/src/workbench/chrome/workbench-desktop-titlebar.css +60 -60
- package/src/workbench/chrome/workbench-host.css +85 -85
- package/src/workbench/chrome/workbench-layout-regions.css +42 -42
- package/src/workbench/chrome/workbench-platform-chrome.css +142 -142
- package/src/workbench/chrome/workbench-shell-titlebar.css +124 -124
- package/src/workbench/{workbenchModalViewState.ts → chrome/workbenchModalViewState.ts} +52 -52
- package/src/workbench/{workbenchOverlaysContext.tsx → chrome/workbenchOverlaysContext.tsx} +21 -21
- package/src/workbench/{workbenchPlatformChrome.ts → chrome/workbenchPlatformChrome.ts} +40 -40
- package/src/workbench/command-palette/command-palette.css +156 -156
- package/src/workbench/{CommandGroupShell.tsx → commands/CommandGroupShell.tsx} +131 -131
- package/src/workbench/{CommandList.tsx → commands/CommandList.tsx} +167 -167
- package/src/workbench/{CommandPalette.tsx → commands/CommandPalette.tsx} +391 -417
- package/src/workbench/{ConfirmationFlow.tsx → commands/ConfirmationFlow.tsx} +243 -243
- package/src/workbench/{ShortcutCommandBridge.tsx → commands/ShortcutCommandBridge.tsx} +365 -365
- package/src/workbench/{command-execution-policy.ts → commands/command-execution-policy.ts} +61 -61
- package/src/workbench/{command-model.ts → commands/command-model.ts} +279 -275
- package/src/workbench/{commands.ts → commands/commands.ts} +576 -576
- package/src/workbench/{keyboard.ts → commands/keyboard.ts} +53 -53
- package/src/workbench/{workbenchContextMenu.ts → commands/workbenchContextMenu.ts} +18 -18
- package/src/workbench/{WorkbenchEditorTabs.tsx → editor/WorkbenchEditorTabs.tsx} +52 -52
- package/src/workbench/{editor-tabs-dnd.ts → editor/editor-tabs-dnd.ts} +162 -162
- package/src/workbench/{editorTabContextMenu.ts → editor/editorTabContextMenu.ts} +111 -111
- package/src/workbench/{useEditorTabsStripDnd.ts → editor/useEditorTabsStripDnd.ts} +262 -262
- package/src/workbench/{useWorkbenchEditorTabContextMenu.tsx → editor/useWorkbenchEditorTabContextMenu.tsx} +66 -66
- package/src/workbench/editor-tabs/index.ts +22 -22
- package/src/workbench/index.ts +694 -675
- package/src/workbench/management/AccountManagementPanel.tsx +82 -82
- package/src/workbench/management/CommandInspectorPanel.tsx +127 -127
- package/src/workbench/management/CommandManagementPanel.tsx +129 -129
- package/src/workbench/management/CommandManagementSidebar.tsx +318 -318
- package/src/workbench/management/ExtensionManagementPanel.tsx +527 -498
- package/src/workbench/management/ExtensionManagementSidebar.tsx +509 -492
- package/src/workbench/management/IntegrationCommandActions.tsx +78 -78
- package/src/workbench/management/IntegrationSettingsSurface.tsx +290 -290
- package/src/workbench/management/IntegrationsShell.tsx +53 -53
- package/src/workbench/management/KeybindingCaptureField.tsx +142 -142
- package/src/workbench/management/KeybindingManagementPanel.tsx +120 -120
- package/src/workbench/management/LibraryCatalogPickerDialog.tsx +208 -208
- package/src/workbench/management/LibraryFacetFilterDialog.tsx +62 -62
- package/src/workbench/management/ManagementCard.tsx +89 -89
- package/src/workbench/management/ManagementFilterChips.tsx +41 -41
- package/src/workbench/management/ManagementGroup.tsx +56 -56
- package/src/workbench/management/ManagementPanelControls.tsx +43 -43
- package/src/workbench/management/ManagementPanelFrame.tsx +109 -109
- package/src/workbench/management/WorkbenchDialogFrame.tsx +148 -148
- package/src/workbench/management/WorkbenchNotice.tsx +211 -211
- package/src/workbench/management/build-command-management-groups.ts +157 -157
- package/src/workbench/management/command-inspector-uri.ts +26 -26
- package/src/workbench/management/extension-category-display.ts +42 -42
- package/src/workbench/management/extension-install-approval.ts +72 -0
- package/src/workbench/management/format-command-run-state.ts +19 -19
- package/src/workbench/management/index.ts +137 -130
- package/src/workbench/management/integration-command-action.ts +25 -25
- package/src/workbench/management/library-catalog-picker-dialog.css +56 -56
- package/src/workbench/management/library-facet-filter-dialog.css +8 -8
- package/src/workbench/management/management-panel.css +444 -444
- package/src/workbench/management/management.css +4 -4
- package/src/workbench/management/types.ts +139 -126
- package/src/workbench/{MarkdownPreview.tsx → markdown/MarkdownPreview.tsx} +162 -147
- package/src/workbench/markdown/markdownRemarkPlugins.ts +12 -0
- package/src/workbench/markdown/sanitizeMarkdownHref.ts +29 -0
- package/src/workbench/schema/index.ts +47 -47
- package/src/workbench/schema/workbenchDocument.ts +31 -31
- package/src/workbench/schema/workbenchDocumentActions.ts +6 -6
- package/src/workbench/schema/workbenchDocumentAdapter.ts +9 -9
- package/src/workbench/schema/workbenchDocumentPatch.ts +13 -13
- package/src/workbench/schema/workbenchDocumentRenderer.tsx +702 -702
- package/src/workbench/settings/NavigationPanel.tsx +86 -86
- package/src/workbench/settings/SchemaForm.tsx +433 -433
- package/src/workbench/settings/SectionTabPanel.tsx +172 -172
- package/src/workbench/settings/SectionedPanel.tsx +169 -169
- package/src/workbench/settings/StructuredDataForm.tsx +619 -619
- package/src/workbench/settings/StructuredDataSchemaPanel.tsx +811 -811
- package/src/workbench/settings/StructuredDataSchemaPanelEmbed.tsx +21 -21
- package/src/workbench/settings/StructuredDataSchemaPanelFrame.tsx +76 -76
- package/src/workbench/settings/StructuredDataTableView.tsx +127 -127
- package/src/workbench/settings/WorkbenchPanelRegion.tsx +46 -46
- package/src/workbench/settings/WorkbenchSettingsModal.tsx +251 -251
- package/src/workbench/settings/WorkbenchSettingsNav.tsx +57 -57
- package/src/workbench/settings/WorkbenchSettingsSection.tsx +30 -30
- package/src/workbench/settings/extensionSettingsForm.ts +34 -34
- package/src/workbench/settings/index.ts +177 -177
- package/src/workbench/settings/navigation-panel.css +59 -59
- package/src/workbench/settings/panel-region.css +22 -22
- package/src/workbench/settings/schema-form.css +36 -36
- package/src/workbench/settings/schemaFormSettingSpec.ts +177 -177
- package/src/workbench/settings/schemaFormSettingsCategory.tsx +21 -21
- package/src/workbench/settings/section-tab-panel.css +157 -157
- package/src/workbench/settings/sectionScrollSpyDom.ts +139 -139
- package/src/workbench/settings/sectioned-panel.css +162 -162
- package/src/workbench/settings/sectionedPanelScrollSpy.ts +273 -273
- package/src/workbench/settings/settings-responsive.css +58 -58
- package/src/workbench/settings/settings.css +11 -11
- package/src/workbench/settings/settingsCommit.tsx +55 -55
- package/src/workbench/settings/structured-data-form.css +114 -114
- package/src/workbench/settings/structured-data-schema-panel.css +344 -344
- package/src/workbench/settings/structured-data-table-view.css +85 -85
- package/src/workbench/settings/structuredDataFormModel.ts +140 -140
- package/src/workbench/settings/structuredDataSchema.ts +339 -339
- package/src/workbench/settings/structuredDataSchemaDate.ts +197 -197
- package/src/workbench/settings/structuredDataSchemaField.ts +105 -105
- package/src/workbench/settings/structuredDataSchemaSection.ts +74 -74
- package/src/workbench/settings/structuredDataSchemaTable.ts +120 -120
- package/src/workbench/settings/structuredDataSchemaTypes.ts +308 -308
- package/src/workbench/settings/structuredDataSchemaValidation.ts +166 -166
- package/src/workbench/settings/types.ts +16 -16
- package/src/workbench/settings/useSectionScrollSpy.ts +420 -420
- package/src/workbench/settings/workbench-settings-modal.css +273 -273
- package/src/workbench/{ActivityBar.tsx → shell/ActivityBar.tsx} +159 -159
- package/src/workbench/{ArtifactShell.tsx → shell/ArtifactShell.tsx} +397 -397
- package/src/workbench/{SplitView.tsx → shell/SplitView.tsx} +485 -485
- package/src/workbench/{StatusBar.tsx → shell/StatusBar.tsx} +180 -180
- package/src/workbench/{StructuredArtifactEditor.tsx → shell/StructuredArtifactEditor.tsx} +205 -205
- package/src/workbench/{Timeline.tsx → shell/Timeline.tsx} +297 -297
- package/src/workbench/{WorkbenchCanvasShell.defaults.ts → shell/WorkbenchCanvasShell.defaults.ts} +106 -106
- package/src/workbench/{WorkbenchCanvasShell.model.ts → shell/WorkbenchCanvasShell.model.ts} +46 -46
- package/src/workbench/{WorkbenchCanvasShell.tsx → shell/WorkbenchCanvasShell.tsx} +827 -827
- package/src/workbench/{WorkbenchDesktopTitleBar.tsx → shell/WorkbenchDesktopTitleBar.tsx} +126 -126
- package/src/workbench/{WorkbenchShell.tsx → shell/WorkbenchShell.tsx} +192 -192
- package/src/workbench/{WorkbenchShellTitleBarLayoutControls.tsx → shell/WorkbenchShellTitleBarLayoutControls.tsx} +80 -80
- package/src/workbench/{WorkbenchStandaloneShell.tsx → shell/WorkbenchStandaloneShell.tsx} +604 -604
- package/src/workbench/{WorkbenchViewEditor.tsx → shell/WorkbenchViewEditor.tsx} +75 -75
- package/src/workbench/{WorkbenchViewSidebar.tsx → shell/WorkbenchViewSidebar.tsx} +85 -85
- package/src/workbench/{WorkbenchWindowChromeControls.tsx → shell/WorkbenchWindowChromeControls.tsx} +293 -290
- package/src/workbench/shell/activity-bar.css +245 -245
- package/src/workbench/{activityBarOrder.ts → shell/activityBarOrder.ts} +98 -98
- package/src/workbench/{appearanceLabels.ts → shell/appearanceLabels.ts} +28 -28
- package/src/workbench/shell/confirmation-flow.css +87 -87
- package/src/workbench/{hardReset.ts → shell/hardReset.ts} +64 -64
- package/src/workbench/shell/index.css +5 -5
- package/src/workbench/{shell.ts → shell/shell.ts} +152 -146
- package/src/workbench/{shellPresets.ts → shell/shellPresets.ts} +36 -36
- package/src/workbench/{shellState.ts → shell/shellState.ts} +196 -196
- package/src/workbench/{shellViewModel.ts → shell/shellViewModel.ts} +160 -160
- package/src/workbench/{sidebarViewPlacementDnd.ts → shell/sidebarViewPlacementDnd.ts} +61 -61
- package/src/workbench/shell/split-view.css +188 -188
- package/src/workbench/{standalone.ts → shell/standalone.ts} +101 -101
- package/src/workbench/shell/status-bar.css +141 -141
- package/src/workbench/{status.ts → shell/status.ts} +133 -133
- package/src/workbench/{useDeferredWorkbenchMount.ts → shell/useDeferredWorkbenchMount.ts} +71 -71
- package/src/workbench/{useWorkbenchAppearanceDocumentSync.tsx → shell/useWorkbenchAppearanceDocumentSync.tsx} +17 -17
- package/src/workbench/{useWorkbenchSidebarActionBarDnd.ts → shell/useWorkbenchSidebarActionBarDnd.ts} +227 -227
- package/src/workbench/{useWorkbenchSidebarLayout.tsx → shell/useWorkbenchSidebarLayout.tsx} +232 -232
- package/src/workbench/{useWorkbenchSidebarViewPlacementDropZone.ts → shell/useWorkbenchSidebarViewPlacementDropZone.ts} +194 -194
- package/src/workbench/{useWorkbenchStandaloneShellStateSync.tsx → shell/useWorkbenchStandaloneShellStateSync.tsx} +112 -112
- package/src/workbench/{workbenchSidebarLayoutContext.ts → shell/workbenchSidebarLayoutContext.ts} +46 -46
- package/src/workbench/{workbenchStandaloneShellReactContext.tsx → shell/workbenchStandaloneShellReactContext.tsx} +80 -80
- package/src/workbench/{workbenchViewRouteState.ts → shell/workbenchViewRouteState.ts} +151 -151
- package/src/workbench/{WorkbenchThemeProvider.tsx → theme/WorkbenchThemeProvider.tsx} +142 -142
- package/src/workbench/{theme.ts → theme/theme.ts} +50 -50
- package/src/workbench/{themePresets.ts → theme/themePresets.ts} +191 -191
- package/src/workbench/views/action-list.css +144 -144
- package/src/workbench/views/artifact-preview.css +184 -184
- package/src/workbench/views/command-inspector.css +98 -98
- package/src/workbench/views/command-list.css +356 -356
- package/src/workbench/views/commands-sidebar.css +51 -51
- package/src/workbench/views/extensions-sidebar.css +175 -175
- package/src/workbench/views/multi-provider-explorer.css +182 -182
- package/src/workbench/views/search.css +10 -10
- package/src/workbench/views/timeline.css +239 -239
- package/src/workbench/views/view-hosts.css +37 -37
- package/src/workbench/views/view-sidebar.css +21 -21
- package/src/workbench/views/views.css +12 -12
- package/src/workbench/widgets/widget-tree.css +598 -598
- package/src/workbench/widgets/widgets.css +2 -2
- package/src/workbench/workspace/WorkspaceDraftsContext.tsx +99 -99
- package/src/workbench/workspace/WorkspaceEditor.tsx +165 -165
- package/src/workbench/workspace/WorkspaceEditorPanel.tsx +393 -393
- package/src/workbench/workspace/WorkspaceExplorer.tsx +630 -630
- package/src/workbench/workspace/WorkspaceExplorerPanel.tsx +73 -73
- package/src/workbench/workspace/WorkspaceFileIcon.tsx +23 -23
- package/src/workbench/workspace/WorkspaceHighlightedText.tsx +22 -22
- package/src/workbench/workspace/WorkspacePathLabel.tsx +42 -42
- package/src/workbench/workspace/WorkspaceSearchPanel.tsx +116 -116
- package/src/workbench/workspace/WorkspaceSearchResults.tsx +51 -51
- package/src/workbench/workspace/build-workspace-explorer-nodes.ts +44 -44
- package/src/workbench/workspace/createVirtualWorkspaceExplorerPort.ts +141 -141
- package/src/workbench/workspace/explorer-tree-style.ts +18 -18
- package/src/workbench/workspace/index.ts +169 -169
- package/src/workbench/workspace/json-config-workbench.css +57 -57
- package/src/workbench/workspace/mimeType.ts +45 -45
- package/src/workbench/workspace/monaco-panel.css +71 -71
- package/src/workbench/workspace/path.ts +12 -12
- package/src/workbench/workspace/search.ts +6 -6
- package/src/workbench/workspace/tree.ts +1 -1
- package/src/workbench/workspace/types.ts +10 -10
- package/src/workbench/workspace/useVirtualWorkspace.ts +111 -111
- package/src/workbench/workspace/useWorkspaceExplorerController.ts +490 -490
- package/src/workbench/workspace/workspace-editor.css +235 -235
- package/src/workbench/workspace/workspace-explorer-panel.css +33 -33
- package/src/workbench/workspace/workspace.css +5 -5
- package/src/workbench/workspace/workspaceExplorerController.ts +193 -193
- package/src/workbench/workspace/workspaceJsonDiagnostics.ts +84 -83
- package/src/workbench-menu-surfaces.css +57 -57
- package/src/workbench/jdw/jdw-editors.css +0 -4
- package/src/workbench/jdw/jdw.css +0 -2
- package/src/workbench/markdownRemarkPlugins.ts +0 -4
- package/src/workbench/workbench-chrome.css +0 -4
|
@@ -1,576 +1,576 @@
|
|
|
1
|
-
import {
|
|
2
|
-
commandMenuEntries,
|
|
3
|
-
commandMenuEntry,
|
|
4
|
-
commandMenuSeparator,
|
|
5
|
-
resolveCommandMenuItems,
|
|
6
|
-
type CommandDefinition,
|
|
7
|
-
type CommandMenuEntry,
|
|
8
|
-
type CommandMenuItem,
|
|
9
|
-
type CommandRegistry,
|
|
10
|
-
type CommandValue,
|
|
11
|
-
} from '@workbench-kit/platform';
|
|
12
|
-
|
|
13
|
-
import type { ContextMenuItem } from '
|
|
14
|
-
|
|
15
|
-
export const WORKBENCH_OPEN_SETTINGS_COMMAND_ID = 'workbench.openSettings';
|
|
16
|
-
export const WORKBENCH_TOGGLE_PRIMARY_SIDEBAR_COMMAND_ID = 'workbench.togglePrimarySidebar';
|
|
17
|
-
export const WORKBENCH_EDITOR_SAVE_COMMAND_ID = 'editor.save';
|
|
18
|
-
export const WORKBENCH_EDITOR_DISCARD_CHANGES_COMMAND_ID = 'editor.discardChanges';
|
|
19
|
-
export const WORKBENCH_EDITOR_COPY_PATH_COMMAND_ID = 'editor.copyPath';
|
|
20
|
-
export const WORKBENCH_EDITOR_TOGGLE_PINNED_COMMAND_ID = 'editor.togglePinned';
|
|
21
|
-
export const WORKBENCH_EDITOR_SPLIT_RIGHT_COMMAND_ID = 'editor.splitRight';
|
|
22
|
-
export const WORKBENCH_EDITOR_SPLIT_DOWN_COMMAND_ID = 'editor.splitDown';
|
|
23
|
-
export const WORKBENCH_EDITOR_CLOSE_COMMAND_ID = 'editor.close';
|
|
24
|
-
export const WORKBENCH_EDITOR_CLOSE_OTHERS_COMMAND_ID = 'editor.closeOthers';
|
|
25
|
-
export const WORKBENCH_EDITOR_CLOSE_ALL_COMMAND_ID = 'editor.closeAll';
|
|
26
|
-
export const WORKBENCH_EDITOR_DELETE_COMMAND_ID = 'editor.delete';
|
|
27
|
-
export const WORKBENCH_WORKSPACE_NEW_FILE_COMMAND_ID = 'workspace.newFile';
|
|
28
|
-
export const WORKBENCH_WORKSPACE_NEW_FOLDER_COMMAND_ID = 'workspace.newFolder';
|
|
29
|
-
export const WORKBENCH_WORKSPACE_OPEN_COMMAND_ID = 'workspace.open';
|
|
30
|
-
export const WORKBENCH_WORKSPACE_COPY_PATH_COMMAND_ID = 'workspace.copyPath';
|
|
31
|
-
export const WORKBENCH_WORKSPACE_RENAME_COMMAND_ID = 'workspace.rename';
|
|
32
|
-
export const WORKBENCH_WORKSPACE_DELETE_COMMAND_ID = 'workspace.delete';
|
|
33
|
-
export const WORKBENCH_SEARCH_OPEN_RESULT_COMMAND_ID = 'search.openResult';
|
|
34
|
-
export const WORKBENCH_SEARCH_COPY_RESULT_PATH_COMMAND_ID = 'search.copyResultPath';
|
|
35
|
-
export const WORKBENCH_SEARCH_DELETE_RESULT_COMMAND_ID = 'search.deleteResult';
|
|
36
|
-
|
|
37
|
-
export const WORKBENCH_COMMAND_SURFACE_ACTIVITY_BAR = 'activityBar';
|
|
38
|
-
export const WORKBENCH_COMMAND_SURFACE_EDITOR = 'editor';
|
|
39
|
-
export const WORKBENCH_COMMAND_SURFACE_SEARCH = 'search';
|
|
40
|
-
export const WORKBENCH_COMMAND_SURFACE_SETTINGS = 'settings';
|
|
41
|
-
export const WORKBENCH_COMMAND_SURFACE_WORKSPACE = 'workspace';
|
|
42
|
-
|
|
43
|
-
export type WorkbenchCommandSurface =
|
|
44
|
-
| typeof WORKBENCH_COMMAND_SURFACE_ACTIVITY_BAR
|
|
45
|
-
| typeof WORKBENCH_COMMAND_SURFACE_EDITOR
|
|
46
|
-
| typeof WORKBENCH_COMMAND_SURFACE_SEARCH
|
|
47
|
-
| typeof WORKBENCH_COMMAND_SURFACE_SETTINGS
|
|
48
|
-
| typeof WORKBENCH_COMMAND_SURFACE_WORKSPACE;
|
|
49
|
-
|
|
50
|
-
export interface WorkbenchShellCommandActivity<TActivityId extends string = string> {
|
|
51
|
-
icon?: string | undefined;
|
|
52
|
-
id: TActivityId;
|
|
53
|
-
label: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface WorkbenchShellCommandContext<TActivityId extends string = string> {
|
|
57
|
-
isPrimarySidebarVisible: boolean;
|
|
58
|
-
openSettings: () => void;
|
|
59
|
-
showActivity: (activityId: TActivityId) => void;
|
|
60
|
-
togglePrimarySidebar: () => void;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface WorkbenchCommandOverride<TContext = void> {
|
|
64
|
-
icon?: CommandValue<TContext, string | undefined>;
|
|
65
|
-
label?: CommandValue<TContext, string>;
|
|
66
|
-
shortcut?: CommandValue<TContext, string | undefined>;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export type WorkbenchCommandOverrides<TContext = void> = Partial<
|
|
70
|
-
Record<string, WorkbenchCommandOverride<TContext>>
|
|
71
|
-
>;
|
|
72
|
-
|
|
73
|
-
interface WorkbenchCommandPresetOptions<TContext = void> {
|
|
74
|
-
commandOverrides?: WorkbenchCommandOverrides<TContext> | undefined;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function applyWorkbenchCommandOverrides<TContext>(
|
|
78
|
-
commands: CommandDefinition<TContext>[],
|
|
79
|
-
options: WorkbenchCommandPresetOptions<TContext> = {},
|
|
80
|
-
): CommandDefinition<TContext>[] {
|
|
81
|
-
const { commandOverrides } = options;
|
|
82
|
-
if (!commandOverrides) return commands;
|
|
83
|
-
|
|
84
|
-
return commands.map((command) => {
|
|
85
|
-
const override = commandOverrides[command.id];
|
|
86
|
-
if (!override) return command;
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
...command,
|
|
90
|
-
icon: override.icon ?? command.icon,
|
|
91
|
-
label: override.label ?? command.label,
|
|
92
|
-
shortcut: override.shortcut ?? command.shortcut,
|
|
93
|
-
};
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface WorkbenchShellCommandPresetOptions<TActivityId extends string = string> {
|
|
98
|
-
activities: WorkbenchShellCommandActivity<TActivityId>[];
|
|
99
|
-
includeSettings?: boolean | undefined;
|
|
100
|
-
includeSidebarToggle?: boolean | undefined;
|
|
101
|
-
menuSeparatorId?: string | undefined;
|
|
102
|
-
settingsIcon?: string | undefined;
|
|
103
|
-
settingsLabel?: string | undefined;
|
|
104
|
-
sidebarIcon?: string | undefined;
|
|
105
|
-
commandOverrides?:
|
|
106
|
-
WorkbenchCommandOverrides<WorkbenchShellCommandContext<TActivityId>> | undefined;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface WorkbenchEditorCommandContext {
|
|
110
|
-
canCloseAll: boolean;
|
|
111
|
-
canCloseOthers: boolean;
|
|
112
|
-
canClosePath: boolean;
|
|
113
|
-
canCopyPath: boolean;
|
|
114
|
-
canDeletePath: boolean;
|
|
115
|
-
canDiscardFile: boolean;
|
|
116
|
-
canSaveFile: boolean;
|
|
117
|
-
canSplitDown: boolean;
|
|
118
|
-
canSplitRight: boolean;
|
|
119
|
-
canTogglePinned: boolean;
|
|
120
|
-
closeAll: () => void;
|
|
121
|
-
closeOthers: () => void;
|
|
122
|
-
closePath: () => void;
|
|
123
|
-
copyPath: () => void;
|
|
124
|
-
deletePath: () => void;
|
|
125
|
-
discardFile: () => void;
|
|
126
|
-
filePath?: string | undefined;
|
|
127
|
-
hasMultipleOpenFiles: boolean;
|
|
128
|
-
hasOpenFiles: boolean;
|
|
129
|
-
hasUnsavedChanges: boolean;
|
|
130
|
-
isPinned: boolean;
|
|
131
|
-
saveFile: () => void;
|
|
132
|
-
splitDown: () => void;
|
|
133
|
-
splitRight: () => void;
|
|
134
|
-
togglePinned: () => void;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export interface WorkbenchWorkspaceCommandContext {
|
|
138
|
-
copyWorkspaceTarget: () => void;
|
|
139
|
-
createWorkspaceFile: () => void;
|
|
140
|
-
createWorkspaceFolder: () => void;
|
|
141
|
-
deleteWorkspaceTarget: () => void;
|
|
142
|
-
fileActionPaths: string[];
|
|
143
|
-
multiFileAction: boolean;
|
|
144
|
-
openWorkspaceTarget: () => void;
|
|
145
|
-
renameWorkspaceTarget: () => void;
|
|
146
|
-
targetPaths: string[];
|
|
147
|
-
workspaceTargetKind: 'file' | 'folder';
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export interface WorkbenchSearchResultCommandContext {
|
|
151
|
-
copyPath: () => void;
|
|
152
|
-
deleteResult: () => void;
|
|
153
|
-
openResult: () => void;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export function getWorkbenchShowActivityCommandId(activityId: string) {
|
|
157
|
-
return `workbench.showActivity.${activityId}`;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export function createWorkbenchShellCommands<TActivityId extends string>({
|
|
161
|
-
activities,
|
|
162
|
-
includeSettings = true,
|
|
163
|
-
includeSidebarToggle = true,
|
|
164
|
-
settingsIcon = 'codicon-settings-gear',
|
|
165
|
-
settingsLabel = 'Settings',
|
|
166
|
-
sidebarIcon = 'codicon-layout-sidebar-left',
|
|
167
|
-
commandOverrides,
|
|
168
|
-
}: WorkbenchShellCommandPresetOptions<TActivityId>): CommandDefinition<
|
|
169
|
-
WorkbenchShellCommandContext<TActivityId>
|
|
170
|
-
>[] {
|
|
171
|
-
const activityCommands = activities.map<
|
|
172
|
-
CommandDefinition<WorkbenchShellCommandContext<TActivityId>>
|
|
173
|
-
>((activity) => ({
|
|
174
|
-
id: getWorkbenchShowActivityCommandId(activity.id),
|
|
175
|
-
icon: activity.icon,
|
|
176
|
-
label: activity.label,
|
|
177
|
-
run: ({ showActivity }) => showActivity(activity.id),
|
|
178
|
-
}));
|
|
179
|
-
|
|
180
|
-
const shellCommands: CommandDefinition<WorkbenchShellCommandContext<TActivityId>>[] = [];
|
|
181
|
-
|
|
182
|
-
if (includeSidebarToggle) {
|
|
183
|
-
shellCommands.push({
|
|
184
|
-
id: WORKBENCH_TOGGLE_PRIMARY_SIDEBAR_COMMAND_ID,
|
|
185
|
-
icon: sidebarIcon,
|
|
186
|
-
label: ({ isPrimarySidebarVisible }) =>
|
|
187
|
-
isPrimarySidebarVisible ? 'Hide primary sidebar' : 'Show primary sidebar',
|
|
188
|
-
run: ({ togglePrimarySidebar }) => togglePrimarySidebar(),
|
|
189
|
-
title: 'Toggle primary sidebar',
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (includeSettings) {
|
|
194
|
-
shellCommands.push({
|
|
195
|
-
id: WORKBENCH_OPEN_SETTINGS_COMMAND_ID,
|
|
196
|
-
icon: settingsIcon,
|
|
197
|
-
label: settingsLabel,
|
|
198
|
-
run: ({ openSettings }) => openSettings(),
|
|
199
|
-
title: settingsLabel,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return applyWorkbenchCommandOverrides([...activityCommands, ...shellCommands], {
|
|
204
|
-
commandOverrides,
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export function createWorkbenchShellMenuEntries<TActivityId extends string>({
|
|
209
|
-
activities,
|
|
210
|
-
includeSettings = true,
|
|
211
|
-
includeSidebarToggle = true,
|
|
212
|
-
menuSeparatorId = 'workbench-shell-separator',
|
|
213
|
-
}: WorkbenchShellCommandPresetOptions<TActivityId>): CommandMenuEntry<
|
|
214
|
-
WorkbenchShellCommandContext<TActivityId>
|
|
215
|
-
>[] {
|
|
216
|
-
const activityEntries = activities.map<
|
|
217
|
-
CommandMenuEntry<WorkbenchShellCommandContext<TActivityId>>
|
|
218
|
-
>((activity) =>
|
|
219
|
-
commandMenuEntry<WorkbenchShellCommandContext<TActivityId>>(
|
|
220
|
-
getWorkbenchShowActivityCommandId(activity.id),
|
|
221
|
-
{ surfaces: [WORKBENCH_COMMAND_SURFACE_ACTIVITY_BAR] },
|
|
222
|
-
),
|
|
223
|
-
);
|
|
224
|
-
const shellEntries: CommandMenuEntry<WorkbenchShellCommandContext<TActivityId>>[] = [];
|
|
225
|
-
|
|
226
|
-
if (includeSidebarToggle) {
|
|
227
|
-
shellEntries.push(
|
|
228
|
-
commandMenuEntry<WorkbenchShellCommandContext<TActivityId>>(
|
|
229
|
-
WORKBENCH_TOGGLE_PRIMARY_SIDEBAR_COMMAND_ID,
|
|
230
|
-
{ surfaces: [WORKBENCH_COMMAND_SURFACE_ACTIVITY_BAR] },
|
|
231
|
-
),
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (includeSettings) {
|
|
236
|
-
shellEntries.push(
|
|
237
|
-
commandMenuEntry<WorkbenchShellCommandContext<TActivityId>>(
|
|
238
|
-
WORKBENCH_OPEN_SETTINGS_COMMAND_ID,
|
|
239
|
-
{ surfaces: [WORKBENCH_COMMAND_SURFACE_ACTIVITY_BAR] },
|
|
240
|
-
),
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
if (!shellEntries.length) return activityEntries;
|
|
245
|
-
return [...activityEntries, commandMenuSeparator(menuSeparatorId), ...shellEntries];
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export interface WorkbenchEditorCommandPresetOptions {
|
|
249
|
-
commandOverrides?: WorkbenchCommandOverrides<WorkbenchEditorCommandContext> | undefined;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
export function createWorkbenchEditorCommands({
|
|
253
|
-
commandOverrides,
|
|
254
|
-
}: WorkbenchEditorCommandPresetOptions = {}): CommandDefinition<WorkbenchEditorCommandContext>[] {
|
|
255
|
-
return applyWorkbenchCommandOverrides(
|
|
256
|
-
[
|
|
257
|
-
{
|
|
258
|
-
id: WORKBENCH_EDITOR_SAVE_COMMAND_ID,
|
|
259
|
-
icon: 'codicon-save',
|
|
260
|
-
isEnabled: ({ canSaveFile, hasUnsavedChanges }) => canSaveFile && hasUnsavedChanges,
|
|
261
|
-
label: 'Save',
|
|
262
|
-
run: ({ saveFile }) => saveFile(),
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
id: WORKBENCH_EDITOR_DISCARD_CHANGES_COMMAND_ID,
|
|
266
|
-
icon: 'codicon-discard',
|
|
267
|
-
isEnabled: ({ canDiscardFile, hasUnsavedChanges }) => canDiscardFile && hasUnsavedChanges,
|
|
268
|
-
label: 'Discard changes',
|
|
269
|
-
run: ({ discardFile }) => discardFile(),
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
id: WORKBENCH_EDITOR_COPY_PATH_COMMAND_ID,
|
|
273
|
-
icon: 'codicon-copy',
|
|
274
|
-
isEnabled: ({ canCopyPath, filePath }) => Boolean(filePath && canCopyPath),
|
|
275
|
-
label: 'Copy path',
|
|
276
|
-
run: ({ copyPath }) => copyPath(),
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
id: WORKBENCH_EDITOR_TOGGLE_PINNED_COMMAND_ID,
|
|
280
|
-
icon: 'codicon-pinned',
|
|
281
|
-
isEnabled: ({ canTogglePinned, filePath }) => Boolean(filePath && canTogglePinned),
|
|
282
|
-
isVisible: ({ canTogglePinned, filePath }) => Boolean(filePath && canTogglePinned),
|
|
283
|
-
label: ({ isPinned }) => (isPinned ? 'Unpin' : 'Pin'),
|
|
284
|
-
run: ({ togglePinned }) => togglePinned(),
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
id: WORKBENCH_EDITOR_SPLIT_RIGHT_COMMAND_ID,
|
|
288
|
-
icon: 'codicon-split-horizontal',
|
|
289
|
-
isEnabled: ({ canSplitRight, filePath }) => Boolean(filePath && canSplitRight),
|
|
290
|
-
isVisible: ({ canSplitRight, filePath }) => Boolean(filePath && canSplitRight),
|
|
291
|
-
label: 'Split Right',
|
|
292
|
-
run: ({ splitRight }) => splitRight(),
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
id: WORKBENCH_EDITOR_SPLIT_DOWN_COMMAND_ID,
|
|
296
|
-
icon: 'codicon-split-vertical',
|
|
297
|
-
isEnabled: ({ canSplitDown, filePath }) => Boolean(filePath && canSplitDown),
|
|
298
|
-
isVisible: ({ canSplitDown, filePath }) => Boolean(filePath && canSplitDown),
|
|
299
|
-
label: 'Split Down',
|
|
300
|
-
run: ({ splitDown }) => splitDown(),
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
id: WORKBENCH_EDITOR_CLOSE_COMMAND_ID,
|
|
304
|
-
icon: 'codicon-close',
|
|
305
|
-
isEnabled: ({ canClosePath, filePath }) => Boolean(filePath && canClosePath),
|
|
306
|
-
label: 'Close',
|
|
307
|
-
run: ({ closePath }) => closePath(),
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
id: WORKBENCH_EDITOR_CLOSE_OTHERS_COMMAND_ID,
|
|
311
|
-
icon: 'codicon-close-all',
|
|
312
|
-
isEnabled: ({ canCloseOthers, filePath, hasMultipleOpenFiles }) =>
|
|
313
|
-
Boolean(filePath && canCloseOthers && hasMultipleOpenFiles),
|
|
314
|
-
label: 'Close others',
|
|
315
|
-
run: ({ closeOthers }) => closeOthers(),
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
id: WORKBENCH_EDITOR_CLOSE_ALL_COMMAND_ID,
|
|
319
|
-
icon: 'codicon-close-all',
|
|
320
|
-
isEnabled: ({ canCloseAll, hasOpenFiles }) => canCloseAll && hasOpenFiles,
|
|
321
|
-
label: 'Close all',
|
|
322
|
-
run: ({ closeAll }) => closeAll(),
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
id: WORKBENCH_EDITOR_DELETE_COMMAND_ID,
|
|
326
|
-
danger: true,
|
|
327
|
-
icon: 'codicon-trash',
|
|
328
|
-
isEnabled: ({ canDeletePath, filePath }) => Boolean(filePath && canDeletePath),
|
|
329
|
-
label: 'Delete',
|
|
330
|
-
run: ({ deletePath }) => deletePath(),
|
|
331
|
-
},
|
|
332
|
-
],
|
|
333
|
-
{ commandOverrides },
|
|
334
|
-
);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
export function createWorkbenchEditorTabListMenuEntries(): CommandMenuEntry<WorkbenchEditorCommandContext>[] {
|
|
338
|
-
return [
|
|
339
|
-
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_CLOSE_ALL_COMMAND_ID, {
|
|
340
|
-
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
341
|
-
}),
|
|
342
|
-
];
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
export function createWorkbenchEditorTabMenuEntries(): CommandMenuEntry<WorkbenchEditorCommandContext>[] {
|
|
346
|
-
return [
|
|
347
|
-
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_TOGGLE_PINNED_COMMAND_ID, {
|
|
348
|
-
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
349
|
-
}),
|
|
350
|
-
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_SPLIT_RIGHT_COMMAND_ID, {
|
|
351
|
-
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
352
|
-
}),
|
|
353
|
-
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_SPLIT_DOWN_COMMAND_ID, {
|
|
354
|
-
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
355
|
-
}),
|
|
356
|
-
commandMenuSeparator('tab-layout-separator'),
|
|
357
|
-
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_COPY_PATH_COMMAND_ID, {
|
|
358
|
-
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
359
|
-
}),
|
|
360
|
-
commandMenuSeparator('tab-file-separator'),
|
|
361
|
-
...createWorkbenchStandaloneEditorTabMenuEntries(),
|
|
362
|
-
commandMenuSeparator('tab-danger-separator'),
|
|
363
|
-
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_DELETE_COMMAND_ID, {
|
|
364
|
-
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
365
|
-
}),
|
|
366
|
-
];
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Close-only tab menu entries for chrome hosts that own tab state without pin,
|
|
371
|
-
* split, copy-path, or delete actions (for example `WorkbenchStandaloneShell`
|
|
372
|
-
* secondary areas using `WorkbenchEditorTabs`).
|
|
373
|
-
*/
|
|
374
|
-
export function createWorkbenchStandaloneEditorTabMenuEntries(): CommandMenuEntry<WorkbenchEditorCommandContext>[] {
|
|
375
|
-
return [
|
|
376
|
-
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_CLOSE_COMMAND_ID, {
|
|
377
|
-
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
378
|
-
}),
|
|
379
|
-
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_CLOSE_OTHERS_COMMAND_ID, {
|
|
380
|
-
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
381
|
-
}),
|
|
382
|
-
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_CLOSE_ALL_COMMAND_ID, {
|
|
383
|
-
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
384
|
-
}),
|
|
385
|
-
];
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
export function createWorkbenchWorkspaceCommands<
|
|
389
|
-
TContext extends WorkbenchWorkspaceCommandContext = WorkbenchWorkspaceCommandContext,
|
|
390
|
-
>({
|
|
391
|
-
commandOverrides,
|
|
392
|
-
}: WorkbenchCommandPresetOptions<TContext> = {}): CommandDefinition<TContext>[] {
|
|
393
|
-
const commands: CommandDefinition<TContext>[] = [
|
|
394
|
-
{
|
|
395
|
-
id: WORKBENCH_WORKSPACE_NEW_FILE_COMMAND_ID,
|
|
396
|
-
icon: 'codicon-new-file',
|
|
397
|
-
label: 'New file',
|
|
398
|
-
run: ({ createWorkspaceFile }) => createWorkspaceFile(),
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
id: WORKBENCH_WORKSPACE_NEW_FOLDER_COMMAND_ID,
|
|
402
|
-
icon: 'codicon-new-folder',
|
|
403
|
-
label: 'New folder',
|
|
404
|
-
run: ({ createWorkspaceFolder }) => createWorkspaceFolder(),
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
id: WORKBENCH_WORKSPACE_OPEN_COMMAND_ID,
|
|
408
|
-
icon: ({ workspaceTargetKind }) =>
|
|
409
|
-
workspaceTargetKind === 'folder' ? 'codicon-folder-opened' : 'codicon-go-to-file',
|
|
410
|
-
label: ({ multiFileAction, workspaceTargetKind }) =>
|
|
411
|
-
workspaceTargetKind === 'folder'
|
|
412
|
-
? 'Reveal folder'
|
|
413
|
-
: multiFileAction
|
|
414
|
-
? 'Open selected files'
|
|
415
|
-
: 'Open file',
|
|
416
|
-
run: ({ openWorkspaceTarget }) => openWorkspaceTarget(),
|
|
417
|
-
when: 'workspace.hasSelection',
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
id: WORKBENCH_WORKSPACE_COPY_PATH_COMMAND_ID,
|
|
421
|
-
icon: 'codicon-copy',
|
|
422
|
-
label: ({ targetPaths }) => (targetPaths.length > 1 ? 'Copy paths' : 'Copy path'),
|
|
423
|
-
run: ({ copyWorkspaceTarget }) => copyWorkspaceTarget(),
|
|
424
|
-
when: 'workspace.hasSelection',
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
id: WORKBENCH_WORKSPACE_RENAME_COMMAND_ID,
|
|
428
|
-
icon: 'codicon-edit',
|
|
429
|
-
isEnabled: ({ targetPaths }) => targetPaths.length === 1,
|
|
430
|
-
label: 'Rename',
|
|
431
|
-
run: ({ renameWorkspaceTarget }) => renameWorkspaceTarget(),
|
|
432
|
-
shortcut: 'F2',
|
|
433
|
-
when: 'workspace.hasSelection && !workspace.multiSelection',
|
|
434
|
-
},
|
|
435
|
-
{
|
|
436
|
-
id: WORKBENCH_WORKSPACE_DELETE_COMMAND_ID,
|
|
437
|
-
danger: true,
|
|
438
|
-
icon: 'codicon-trash',
|
|
439
|
-
isEnabled: ({ fileActionPaths, workspaceTargetKind }) =>
|
|
440
|
-
workspaceTargetKind === 'folder' || fileActionPaths.length > 0,
|
|
441
|
-
label: ({ fileActionPaths, multiFileAction, workspaceTargetKind }) =>
|
|
442
|
-
workspaceTargetKind === 'folder'
|
|
443
|
-
? 'Delete folder'
|
|
444
|
-
: multiFileAction
|
|
445
|
-
? `Delete ${fileActionPaths.length} files`
|
|
446
|
-
: 'Delete',
|
|
447
|
-
run: ({ deleteWorkspaceTarget }) => deleteWorkspaceTarget(),
|
|
448
|
-
shortcut: 'Del',
|
|
449
|
-
when: 'workspace.hasSelection',
|
|
450
|
-
},
|
|
451
|
-
];
|
|
452
|
-
|
|
453
|
-
return applyWorkbenchCommandOverrides(commands, { commandOverrides });
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
export function createWorkbenchWorkspaceCreateMenuEntries<
|
|
457
|
-
TContext extends WorkbenchWorkspaceCommandContext = WorkbenchWorkspaceCommandContext,
|
|
458
|
-
>(): CommandMenuEntry<TContext>[] {
|
|
459
|
-
return commandMenuEntries<TContext>(
|
|
460
|
-
WORKBENCH_WORKSPACE_NEW_FILE_COMMAND_ID,
|
|
461
|
-
WORKBENCH_WORKSPACE_NEW_FOLDER_COMMAND_ID,
|
|
462
|
-
).map((entry) => ({ ...entry, surfaces: [WORKBENCH_COMMAND_SURFACE_WORKSPACE] }));
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
export function createWorkbenchWorkspaceTargetMenuEntries<
|
|
466
|
-
TContext extends WorkbenchWorkspaceCommandContext = WorkbenchWorkspaceCommandContext,
|
|
467
|
-
>(): CommandMenuEntry<TContext>[] {
|
|
468
|
-
return [
|
|
469
|
-
...commandMenuEntries<TContext>(
|
|
470
|
-
WORKBENCH_WORKSPACE_OPEN_COMMAND_ID,
|
|
471
|
-
WORKBENCH_WORKSPACE_COPY_PATH_COMMAND_ID,
|
|
472
|
-
).map((entry) => ({ ...entry, surfaces: [WORKBENCH_COMMAND_SURFACE_WORKSPACE] })),
|
|
473
|
-
commandMenuSeparator('workspace-separator'),
|
|
474
|
-
...commandMenuEntries<TContext>(
|
|
475
|
-
WORKBENCH_WORKSPACE_RENAME_COMMAND_ID,
|
|
476
|
-
WORKBENCH_WORKSPACE_DELETE_COMMAND_ID,
|
|
477
|
-
).map((entry) => ({ ...entry, surfaces: [WORKBENCH_COMMAND_SURFACE_WORKSPACE] })),
|
|
478
|
-
];
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
export function createWorkbenchWorkspaceFolderMenuEntries<
|
|
482
|
-
TContext extends WorkbenchWorkspaceCommandContext = WorkbenchWorkspaceCommandContext,
|
|
483
|
-
>(): CommandMenuEntry<TContext>[] {
|
|
484
|
-
return [
|
|
485
|
-
...createWorkbenchWorkspaceCreateMenuEntries(),
|
|
486
|
-
commandMenuSeparator('workspace-create-separator'),
|
|
487
|
-
...createWorkbenchWorkspaceTargetMenuEntries(),
|
|
488
|
-
];
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
export function createWorkbenchSearchResultCommands<
|
|
492
|
-
TContext extends WorkbenchSearchResultCommandContext = WorkbenchSearchResultCommandContext,
|
|
493
|
-
>({
|
|
494
|
-
commandOverrides,
|
|
495
|
-
}: WorkbenchCommandPresetOptions<TContext> = {}): CommandDefinition<TContext>[] {
|
|
496
|
-
const commands: CommandDefinition<TContext>[] = [
|
|
497
|
-
{
|
|
498
|
-
id: WORKBENCH_SEARCH_OPEN_RESULT_COMMAND_ID,
|
|
499
|
-
icon: 'codicon-folder-opened',
|
|
500
|
-
label: 'Open',
|
|
501
|
-
run: ({ openResult }) => openResult(),
|
|
502
|
-
shortcut: 'Enter',
|
|
503
|
-
},
|
|
504
|
-
{
|
|
505
|
-
id: WORKBENCH_SEARCH_COPY_RESULT_PATH_COMMAND_ID,
|
|
506
|
-
icon: 'codicon-copy',
|
|
507
|
-
label: 'Copy path',
|
|
508
|
-
run: ({ copyPath }) => copyPath(),
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
id: WORKBENCH_SEARCH_DELETE_RESULT_COMMAND_ID,
|
|
512
|
-
danger: true,
|
|
513
|
-
icon: 'codicon-trash',
|
|
514
|
-
label: 'Delete',
|
|
515
|
-
run: ({ deleteResult }) => deleteResult(),
|
|
516
|
-
},
|
|
517
|
-
];
|
|
518
|
-
|
|
519
|
-
return applyWorkbenchCommandOverrides(commands, { commandOverrides });
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
export function createWorkbenchSearchResultMenuEntries<
|
|
523
|
-
TContext extends WorkbenchSearchResultCommandContext = WorkbenchSearchResultCommandContext,
|
|
524
|
-
>(): CommandMenuEntry<TContext>[] {
|
|
525
|
-
return [
|
|
526
|
-
...commandMenuEntries<TContext>(
|
|
527
|
-
WORKBENCH_SEARCH_OPEN_RESULT_COMMAND_ID,
|
|
528
|
-
WORKBENCH_SEARCH_COPY_RESULT_PATH_COMMAND_ID,
|
|
529
|
-
).map((entry) => ({ ...entry, surfaces: [WORKBENCH_COMMAND_SURFACE_SEARCH] })),
|
|
530
|
-
commandMenuSeparator('result-menu-separator'),
|
|
531
|
-
commandMenuEntry<TContext>(WORKBENCH_SEARCH_DELETE_RESULT_COMMAND_ID, {
|
|
532
|
-
surfaces: [WORKBENCH_COMMAND_SURFACE_SEARCH],
|
|
533
|
-
}),
|
|
534
|
-
];
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
export function resolveWorkbenchCommandMenuItems<TContext>({
|
|
538
|
-
registry,
|
|
539
|
-
entries,
|
|
540
|
-
context,
|
|
541
|
-
surface,
|
|
542
|
-
contextKeys,
|
|
543
|
-
}: {
|
|
544
|
-
registry: CommandRegistry<TContext>;
|
|
545
|
-
entries: CommandMenuEntry<TContext>[];
|
|
546
|
-
context: TContext;
|
|
547
|
-
surface?: string;
|
|
548
|
-
contextKeys?: object;
|
|
549
|
-
}): CommandMenuItem[] {
|
|
550
|
-
return resolveCommandMenuItems({
|
|
551
|
-
context,
|
|
552
|
-
contextKeys,
|
|
553
|
-
entries,
|
|
554
|
-
registry,
|
|
555
|
-
surface,
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
export function commandMenuItemsToContextMenuItems(
|
|
560
|
-
items: CommandMenuItem[],
|
|
561
|
-
onSelectCommand: (commandId: string) => void,
|
|
562
|
-
): ContextMenuItem[] {
|
|
563
|
-
return items.map((item) =>
|
|
564
|
-
item.type === 'separator'
|
|
565
|
-
? { id: item.id, type: 'separator' }
|
|
566
|
-
: {
|
|
567
|
-
id: item.id,
|
|
568
|
-
label: item.label,
|
|
569
|
-
icon: item.icon,
|
|
570
|
-
shortcut: item.shortcut,
|
|
571
|
-
disabled: item.disabled,
|
|
572
|
-
danger: item.danger,
|
|
573
|
-
onSelect: () => onSelectCommand(item.commandId),
|
|
574
|
-
},
|
|
575
|
-
);
|
|
576
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
commandMenuEntries,
|
|
3
|
+
commandMenuEntry,
|
|
4
|
+
commandMenuSeparator,
|
|
5
|
+
resolveCommandMenuItems,
|
|
6
|
+
type CommandDefinition,
|
|
7
|
+
type CommandMenuEntry,
|
|
8
|
+
type CommandMenuItem,
|
|
9
|
+
type CommandRegistry,
|
|
10
|
+
type CommandValue,
|
|
11
|
+
} from '@workbench-kit/platform';
|
|
12
|
+
|
|
13
|
+
import type { ContextMenuItem } from '../../overlay/ContextMenu';
|
|
14
|
+
|
|
15
|
+
export const WORKBENCH_OPEN_SETTINGS_COMMAND_ID = 'workbench.openSettings';
|
|
16
|
+
export const WORKBENCH_TOGGLE_PRIMARY_SIDEBAR_COMMAND_ID = 'workbench.togglePrimarySidebar';
|
|
17
|
+
export const WORKBENCH_EDITOR_SAVE_COMMAND_ID = 'editor.save';
|
|
18
|
+
export const WORKBENCH_EDITOR_DISCARD_CHANGES_COMMAND_ID = 'editor.discardChanges';
|
|
19
|
+
export const WORKBENCH_EDITOR_COPY_PATH_COMMAND_ID = 'editor.copyPath';
|
|
20
|
+
export const WORKBENCH_EDITOR_TOGGLE_PINNED_COMMAND_ID = 'editor.togglePinned';
|
|
21
|
+
export const WORKBENCH_EDITOR_SPLIT_RIGHT_COMMAND_ID = 'editor.splitRight';
|
|
22
|
+
export const WORKBENCH_EDITOR_SPLIT_DOWN_COMMAND_ID = 'editor.splitDown';
|
|
23
|
+
export const WORKBENCH_EDITOR_CLOSE_COMMAND_ID = 'editor.close';
|
|
24
|
+
export const WORKBENCH_EDITOR_CLOSE_OTHERS_COMMAND_ID = 'editor.closeOthers';
|
|
25
|
+
export const WORKBENCH_EDITOR_CLOSE_ALL_COMMAND_ID = 'editor.closeAll';
|
|
26
|
+
export const WORKBENCH_EDITOR_DELETE_COMMAND_ID = 'editor.delete';
|
|
27
|
+
export const WORKBENCH_WORKSPACE_NEW_FILE_COMMAND_ID = 'workspace.newFile';
|
|
28
|
+
export const WORKBENCH_WORKSPACE_NEW_FOLDER_COMMAND_ID = 'workspace.newFolder';
|
|
29
|
+
export const WORKBENCH_WORKSPACE_OPEN_COMMAND_ID = 'workspace.open';
|
|
30
|
+
export const WORKBENCH_WORKSPACE_COPY_PATH_COMMAND_ID = 'workspace.copyPath';
|
|
31
|
+
export const WORKBENCH_WORKSPACE_RENAME_COMMAND_ID = 'workspace.rename';
|
|
32
|
+
export const WORKBENCH_WORKSPACE_DELETE_COMMAND_ID = 'workspace.delete';
|
|
33
|
+
export const WORKBENCH_SEARCH_OPEN_RESULT_COMMAND_ID = 'search.openResult';
|
|
34
|
+
export const WORKBENCH_SEARCH_COPY_RESULT_PATH_COMMAND_ID = 'search.copyResultPath';
|
|
35
|
+
export const WORKBENCH_SEARCH_DELETE_RESULT_COMMAND_ID = 'search.deleteResult';
|
|
36
|
+
|
|
37
|
+
export const WORKBENCH_COMMAND_SURFACE_ACTIVITY_BAR = 'activityBar';
|
|
38
|
+
export const WORKBENCH_COMMAND_SURFACE_EDITOR = 'editor';
|
|
39
|
+
export const WORKBENCH_COMMAND_SURFACE_SEARCH = 'search';
|
|
40
|
+
export const WORKBENCH_COMMAND_SURFACE_SETTINGS = 'settings';
|
|
41
|
+
export const WORKBENCH_COMMAND_SURFACE_WORKSPACE = 'workspace';
|
|
42
|
+
|
|
43
|
+
export type WorkbenchCommandSurface =
|
|
44
|
+
| typeof WORKBENCH_COMMAND_SURFACE_ACTIVITY_BAR
|
|
45
|
+
| typeof WORKBENCH_COMMAND_SURFACE_EDITOR
|
|
46
|
+
| typeof WORKBENCH_COMMAND_SURFACE_SEARCH
|
|
47
|
+
| typeof WORKBENCH_COMMAND_SURFACE_SETTINGS
|
|
48
|
+
| typeof WORKBENCH_COMMAND_SURFACE_WORKSPACE;
|
|
49
|
+
|
|
50
|
+
export interface WorkbenchShellCommandActivity<TActivityId extends string = string> {
|
|
51
|
+
icon?: string | undefined;
|
|
52
|
+
id: TActivityId;
|
|
53
|
+
label: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface WorkbenchShellCommandContext<TActivityId extends string = string> {
|
|
57
|
+
isPrimarySidebarVisible: boolean;
|
|
58
|
+
openSettings: () => void;
|
|
59
|
+
showActivity: (activityId: TActivityId) => void;
|
|
60
|
+
togglePrimarySidebar: () => void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface WorkbenchCommandOverride<TContext = void> {
|
|
64
|
+
icon?: CommandValue<TContext, string | undefined>;
|
|
65
|
+
label?: CommandValue<TContext, string>;
|
|
66
|
+
shortcut?: CommandValue<TContext, string | undefined>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type WorkbenchCommandOverrides<TContext = void> = Partial<
|
|
70
|
+
Record<string, WorkbenchCommandOverride<TContext>>
|
|
71
|
+
>;
|
|
72
|
+
|
|
73
|
+
interface WorkbenchCommandPresetOptions<TContext = void> {
|
|
74
|
+
commandOverrides?: WorkbenchCommandOverrides<TContext> | undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function applyWorkbenchCommandOverrides<TContext>(
|
|
78
|
+
commands: CommandDefinition<TContext>[],
|
|
79
|
+
options: WorkbenchCommandPresetOptions<TContext> = {},
|
|
80
|
+
): CommandDefinition<TContext>[] {
|
|
81
|
+
const { commandOverrides } = options;
|
|
82
|
+
if (!commandOverrides) return commands;
|
|
83
|
+
|
|
84
|
+
return commands.map((command) => {
|
|
85
|
+
const override = commandOverrides[command.id];
|
|
86
|
+
if (!override) return command;
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
...command,
|
|
90
|
+
icon: override.icon ?? command.icon,
|
|
91
|
+
label: override.label ?? command.label,
|
|
92
|
+
shortcut: override.shortcut ?? command.shortcut,
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface WorkbenchShellCommandPresetOptions<TActivityId extends string = string> {
|
|
98
|
+
activities: WorkbenchShellCommandActivity<TActivityId>[];
|
|
99
|
+
includeSettings?: boolean | undefined;
|
|
100
|
+
includeSidebarToggle?: boolean | undefined;
|
|
101
|
+
menuSeparatorId?: string | undefined;
|
|
102
|
+
settingsIcon?: string | undefined;
|
|
103
|
+
settingsLabel?: string | undefined;
|
|
104
|
+
sidebarIcon?: string | undefined;
|
|
105
|
+
commandOverrides?:
|
|
106
|
+
WorkbenchCommandOverrides<WorkbenchShellCommandContext<TActivityId>> | undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface WorkbenchEditorCommandContext {
|
|
110
|
+
canCloseAll: boolean;
|
|
111
|
+
canCloseOthers: boolean;
|
|
112
|
+
canClosePath: boolean;
|
|
113
|
+
canCopyPath: boolean;
|
|
114
|
+
canDeletePath: boolean;
|
|
115
|
+
canDiscardFile: boolean;
|
|
116
|
+
canSaveFile: boolean;
|
|
117
|
+
canSplitDown: boolean;
|
|
118
|
+
canSplitRight: boolean;
|
|
119
|
+
canTogglePinned: boolean;
|
|
120
|
+
closeAll: () => void;
|
|
121
|
+
closeOthers: () => void;
|
|
122
|
+
closePath: () => void;
|
|
123
|
+
copyPath: () => void;
|
|
124
|
+
deletePath: () => void;
|
|
125
|
+
discardFile: () => void;
|
|
126
|
+
filePath?: string | undefined;
|
|
127
|
+
hasMultipleOpenFiles: boolean;
|
|
128
|
+
hasOpenFiles: boolean;
|
|
129
|
+
hasUnsavedChanges: boolean;
|
|
130
|
+
isPinned: boolean;
|
|
131
|
+
saveFile: () => void;
|
|
132
|
+
splitDown: () => void;
|
|
133
|
+
splitRight: () => void;
|
|
134
|
+
togglePinned: () => void;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface WorkbenchWorkspaceCommandContext {
|
|
138
|
+
copyWorkspaceTarget: () => void;
|
|
139
|
+
createWorkspaceFile: () => void;
|
|
140
|
+
createWorkspaceFolder: () => void;
|
|
141
|
+
deleteWorkspaceTarget: () => void;
|
|
142
|
+
fileActionPaths: string[];
|
|
143
|
+
multiFileAction: boolean;
|
|
144
|
+
openWorkspaceTarget: () => void;
|
|
145
|
+
renameWorkspaceTarget: () => void;
|
|
146
|
+
targetPaths: string[];
|
|
147
|
+
workspaceTargetKind: 'file' | 'folder';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface WorkbenchSearchResultCommandContext {
|
|
151
|
+
copyPath: () => void;
|
|
152
|
+
deleteResult: () => void;
|
|
153
|
+
openResult: () => void;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function getWorkbenchShowActivityCommandId(activityId: string) {
|
|
157
|
+
return `workbench.showActivity.${activityId}`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function createWorkbenchShellCommands<TActivityId extends string>({
|
|
161
|
+
activities,
|
|
162
|
+
includeSettings = true,
|
|
163
|
+
includeSidebarToggle = true,
|
|
164
|
+
settingsIcon = 'codicon-settings-gear',
|
|
165
|
+
settingsLabel = 'Settings',
|
|
166
|
+
sidebarIcon = 'codicon-layout-sidebar-left',
|
|
167
|
+
commandOverrides,
|
|
168
|
+
}: WorkbenchShellCommandPresetOptions<TActivityId>): CommandDefinition<
|
|
169
|
+
WorkbenchShellCommandContext<TActivityId>
|
|
170
|
+
>[] {
|
|
171
|
+
const activityCommands = activities.map<
|
|
172
|
+
CommandDefinition<WorkbenchShellCommandContext<TActivityId>>
|
|
173
|
+
>((activity) => ({
|
|
174
|
+
id: getWorkbenchShowActivityCommandId(activity.id),
|
|
175
|
+
icon: activity.icon,
|
|
176
|
+
label: activity.label,
|
|
177
|
+
run: ({ showActivity }) => showActivity(activity.id),
|
|
178
|
+
}));
|
|
179
|
+
|
|
180
|
+
const shellCommands: CommandDefinition<WorkbenchShellCommandContext<TActivityId>>[] = [];
|
|
181
|
+
|
|
182
|
+
if (includeSidebarToggle) {
|
|
183
|
+
shellCommands.push({
|
|
184
|
+
id: WORKBENCH_TOGGLE_PRIMARY_SIDEBAR_COMMAND_ID,
|
|
185
|
+
icon: sidebarIcon,
|
|
186
|
+
label: ({ isPrimarySidebarVisible }) =>
|
|
187
|
+
isPrimarySidebarVisible ? 'Hide primary sidebar' : 'Show primary sidebar',
|
|
188
|
+
run: ({ togglePrimarySidebar }) => togglePrimarySidebar(),
|
|
189
|
+
title: 'Toggle primary sidebar',
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (includeSettings) {
|
|
194
|
+
shellCommands.push({
|
|
195
|
+
id: WORKBENCH_OPEN_SETTINGS_COMMAND_ID,
|
|
196
|
+
icon: settingsIcon,
|
|
197
|
+
label: settingsLabel,
|
|
198
|
+
run: ({ openSettings }) => openSettings(),
|
|
199
|
+
title: settingsLabel,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return applyWorkbenchCommandOverrides([...activityCommands, ...shellCommands], {
|
|
204
|
+
commandOverrides,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function createWorkbenchShellMenuEntries<TActivityId extends string>({
|
|
209
|
+
activities,
|
|
210
|
+
includeSettings = true,
|
|
211
|
+
includeSidebarToggle = true,
|
|
212
|
+
menuSeparatorId = 'workbench-shell-separator',
|
|
213
|
+
}: WorkbenchShellCommandPresetOptions<TActivityId>): CommandMenuEntry<
|
|
214
|
+
WorkbenchShellCommandContext<TActivityId>
|
|
215
|
+
>[] {
|
|
216
|
+
const activityEntries = activities.map<
|
|
217
|
+
CommandMenuEntry<WorkbenchShellCommandContext<TActivityId>>
|
|
218
|
+
>((activity) =>
|
|
219
|
+
commandMenuEntry<WorkbenchShellCommandContext<TActivityId>>(
|
|
220
|
+
getWorkbenchShowActivityCommandId(activity.id),
|
|
221
|
+
{ surfaces: [WORKBENCH_COMMAND_SURFACE_ACTIVITY_BAR] },
|
|
222
|
+
),
|
|
223
|
+
);
|
|
224
|
+
const shellEntries: CommandMenuEntry<WorkbenchShellCommandContext<TActivityId>>[] = [];
|
|
225
|
+
|
|
226
|
+
if (includeSidebarToggle) {
|
|
227
|
+
shellEntries.push(
|
|
228
|
+
commandMenuEntry<WorkbenchShellCommandContext<TActivityId>>(
|
|
229
|
+
WORKBENCH_TOGGLE_PRIMARY_SIDEBAR_COMMAND_ID,
|
|
230
|
+
{ surfaces: [WORKBENCH_COMMAND_SURFACE_ACTIVITY_BAR] },
|
|
231
|
+
),
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (includeSettings) {
|
|
236
|
+
shellEntries.push(
|
|
237
|
+
commandMenuEntry<WorkbenchShellCommandContext<TActivityId>>(
|
|
238
|
+
WORKBENCH_OPEN_SETTINGS_COMMAND_ID,
|
|
239
|
+
{ surfaces: [WORKBENCH_COMMAND_SURFACE_ACTIVITY_BAR] },
|
|
240
|
+
),
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (!shellEntries.length) return activityEntries;
|
|
245
|
+
return [...activityEntries, commandMenuSeparator(menuSeparatorId), ...shellEntries];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface WorkbenchEditorCommandPresetOptions {
|
|
249
|
+
commandOverrides?: WorkbenchCommandOverrides<WorkbenchEditorCommandContext> | undefined;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function createWorkbenchEditorCommands({
|
|
253
|
+
commandOverrides,
|
|
254
|
+
}: WorkbenchEditorCommandPresetOptions = {}): CommandDefinition<WorkbenchEditorCommandContext>[] {
|
|
255
|
+
return applyWorkbenchCommandOverrides(
|
|
256
|
+
[
|
|
257
|
+
{
|
|
258
|
+
id: WORKBENCH_EDITOR_SAVE_COMMAND_ID,
|
|
259
|
+
icon: 'codicon-save',
|
|
260
|
+
isEnabled: ({ canSaveFile, hasUnsavedChanges }) => canSaveFile && hasUnsavedChanges,
|
|
261
|
+
label: 'Save',
|
|
262
|
+
run: ({ saveFile }) => saveFile(),
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
id: WORKBENCH_EDITOR_DISCARD_CHANGES_COMMAND_ID,
|
|
266
|
+
icon: 'codicon-discard',
|
|
267
|
+
isEnabled: ({ canDiscardFile, hasUnsavedChanges }) => canDiscardFile && hasUnsavedChanges,
|
|
268
|
+
label: 'Discard changes',
|
|
269
|
+
run: ({ discardFile }) => discardFile(),
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
id: WORKBENCH_EDITOR_COPY_PATH_COMMAND_ID,
|
|
273
|
+
icon: 'codicon-copy',
|
|
274
|
+
isEnabled: ({ canCopyPath, filePath }) => Boolean(filePath && canCopyPath),
|
|
275
|
+
label: 'Copy path',
|
|
276
|
+
run: ({ copyPath }) => copyPath(),
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
id: WORKBENCH_EDITOR_TOGGLE_PINNED_COMMAND_ID,
|
|
280
|
+
icon: 'codicon-pinned',
|
|
281
|
+
isEnabled: ({ canTogglePinned, filePath }) => Boolean(filePath && canTogglePinned),
|
|
282
|
+
isVisible: ({ canTogglePinned, filePath }) => Boolean(filePath && canTogglePinned),
|
|
283
|
+
label: ({ isPinned }) => (isPinned ? 'Unpin' : 'Pin'),
|
|
284
|
+
run: ({ togglePinned }) => togglePinned(),
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
id: WORKBENCH_EDITOR_SPLIT_RIGHT_COMMAND_ID,
|
|
288
|
+
icon: 'codicon-split-horizontal',
|
|
289
|
+
isEnabled: ({ canSplitRight, filePath }) => Boolean(filePath && canSplitRight),
|
|
290
|
+
isVisible: ({ canSplitRight, filePath }) => Boolean(filePath && canSplitRight),
|
|
291
|
+
label: 'Split Right',
|
|
292
|
+
run: ({ splitRight }) => splitRight(),
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
id: WORKBENCH_EDITOR_SPLIT_DOWN_COMMAND_ID,
|
|
296
|
+
icon: 'codicon-split-vertical',
|
|
297
|
+
isEnabled: ({ canSplitDown, filePath }) => Boolean(filePath && canSplitDown),
|
|
298
|
+
isVisible: ({ canSplitDown, filePath }) => Boolean(filePath && canSplitDown),
|
|
299
|
+
label: 'Split Down',
|
|
300
|
+
run: ({ splitDown }) => splitDown(),
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
id: WORKBENCH_EDITOR_CLOSE_COMMAND_ID,
|
|
304
|
+
icon: 'codicon-close',
|
|
305
|
+
isEnabled: ({ canClosePath, filePath }) => Boolean(filePath && canClosePath),
|
|
306
|
+
label: 'Close',
|
|
307
|
+
run: ({ closePath }) => closePath(),
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
id: WORKBENCH_EDITOR_CLOSE_OTHERS_COMMAND_ID,
|
|
311
|
+
icon: 'codicon-close-all',
|
|
312
|
+
isEnabled: ({ canCloseOthers, filePath, hasMultipleOpenFiles }) =>
|
|
313
|
+
Boolean(filePath && canCloseOthers && hasMultipleOpenFiles),
|
|
314
|
+
label: 'Close others',
|
|
315
|
+
run: ({ closeOthers }) => closeOthers(),
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
id: WORKBENCH_EDITOR_CLOSE_ALL_COMMAND_ID,
|
|
319
|
+
icon: 'codicon-close-all',
|
|
320
|
+
isEnabled: ({ canCloseAll, hasOpenFiles }) => canCloseAll && hasOpenFiles,
|
|
321
|
+
label: 'Close all',
|
|
322
|
+
run: ({ closeAll }) => closeAll(),
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
id: WORKBENCH_EDITOR_DELETE_COMMAND_ID,
|
|
326
|
+
danger: true,
|
|
327
|
+
icon: 'codicon-trash',
|
|
328
|
+
isEnabled: ({ canDeletePath, filePath }) => Boolean(filePath && canDeletePath),
|
|
329
|
+
label: 'Delete',
|
|
330
|
+
run: ({ deletePath }) => deletePath(),
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
{ commandOverrides },
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export function createWorkbenchEditorTabListMenuEntries(): CommandMenuEntry<WorkbenchEditorCommandContext>[] {
|
|
338
|
+
return [
|
|
339
|
+
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_CLOSE_ALL_COMMAND_ID, {
|
|
340
|
+
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
341
|
+
}),
|
|
342
|
+
];
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export function createWorkbenchEditorTabMenuEntries(): CommandMenuEntry<WorkbenchEditorCommandContext>[] {
|
|
346
|
+
return [
|
|
347
|
+
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_TOGGLE_PINNED_COMMAND_ID, {
|
|
348
|
+
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
349
|
+
}),
|
|
350
|
+
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_SPLIT_RIGHT_COMMAND_ID, {
|
|
351
|
+
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
352
|
+
}),
|
|
353
|
+
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_SPLIT_DOWN_COMMAND_ID, {
|
|
354
|
+
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
355
|
+
}),
|
|
356
|
+
commandMenuSeparator('tab-layout-separator'),
|
|
357
|
+
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_COPY_PATH_COMMAND_ID, {
|
|
358
|
+
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
359
|
+
}),
|
|
360
|
+
commandMenuSeparator('tab-file-separator'),
|
|
361
|
+
...createWorkbenchStandaloneEditorTabMenuEntries(),
|
|
362
|
+
commandMenuSeparator('tab-danger-separator'),
|
|
363
|
+
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_DELETE_COMMAND_ID, {
|
|
364
|
+
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
365
|
+
}),
|
|
366
|
+
];
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Close-only tab menu entries for chrome hosts that own tab state without pin,
|
|
371
|
+
* split, copy-path, or delete actions (for example `WorkbenchStandaloneShell`
|
|
372
|
+
* secondary areas using `WorkbenchEditorTabs`).
|
|
373
|
+
*/
|
|
374
|
+
export function createWorkbenchStandaloneEditorTabMenuEntries(): CommandMenuEntry<WorkbenchEditorCommandContext>[] {
|
|
375
|
+
return [
|
|
376
|
+
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_CLOSE_COMMAND_ID, {
|
|
377
|
+
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
378
|
+
}),
|
|
379
|
+
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_CLOSE_OTHERS_COMMAND_ID, {
|
|
380
|
+
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
381
|
+
}),
|
|
382
|
+
commandMenuEntry<WorkbenchEditorCommandContext>(WORKBENCH_EDITOR_CLOSE_ALL_COMMAND_ID, {
|
|
383
|
+
surfaces: [WORKBENCH_COMMAND_SURFACE_EDITOR],
|
|
384
|
+
}),
|
|
385
|
+
];
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export function createWorkbenchWorkspaceCommands<
|
|
389
|
+
TContext extends WorkbenchWorkspaceCommandContext = WorkbenchWorkspaceCommandContext,
|
|
390
|
+
>({
|
|
391
|
+
commandOverrides,
|
|
392
|
+
}: WorkbenchCommandPresetOptions<TContext> = {}): CommandDefinition<TContext>[] {
|
|
393
|
+
const commands: CommandDefinition<TContext>[] = [
|
|
394
|
+
{
|
|
395
|
+
id: WORKBENCH_WORKSPACE_NEW_FILE_COMMAND_ID,
|
|
396
|
+
icon: 'codicon-new-file',
|
|
397
|
+
label: 'New file',
|
|
398
|
+
run: ({ createWorkspaceFile }) => createWorkspaceFile(),
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
id: WORKBENCH_WORKSPACE_NEW_FOLDER_COMMAND_ID,
|
|
402
|
+
icon: 'codicon-new-folder',
|
|
403
|
+
label: 'New folder',
|
|
404
|
+
run: ({ createWorkspaceFolder }) => createWorkspaceFolder(),
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
id: WORKBENCH_WORKSPACE_OPEN_COMMAND_ID,
|
|
408
|
+
icon: ({ workspaceTargetKind }) =>
|
|
409
|
+
workspaceTargetKind === 'folder' ? 'codicon-folder-opened' : 'codicon-go-to-file',
|
|
410
|
+
label: ({ multiFileAction, workspaceTargetKind }) =>
|
|
411
|
+
workspaceTargetKind === 'folder'
|
|
412
|
+
? 'Reveal folder'
|
|
413
|
+
: multiFileAction
|
|
414
|
+
? 'Open selected files'
|
|
415
|
+
: 'Open file',
|
|
416
|
+
run: ({ openWorkspaceTarget }) => openWorkspaceTarget(),
|
|
417
|
+
when: 'workspace.hasSelection',
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
id: WORKBENCH_WORKSPACE_COPY_PATH_COMMAND_ID,
|
|
421
|
+
icon: 'codicon-copy',
|
|
422
|
+
label: ({ targetPaths }) => (targetPaths.length > 1 ? 'Copy paths' : 'Copy path'),
|
|
423
|
+
run: ({ copyWorkspaceTarget }) => copyWorkspaceTarget(),
|
|
424
|
+
when: 'workspace.hasSelection',
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
id: WORKBENCH_WORKSPACE_RENAME_COMMAND_ID,
|
|
428
|
+
icon: 'codicon-edit',
|
|
429
|
+
isEnabled: ({ targetPaths }) => targetPaths.length === 1,
|
|
430
|
+
label: 'Rename',
|
|
431
|
+
run: ({ renameWorkspaceTarget }) => renameWorkspaceTarget(),
|
|
432
|
+
shortcut: 'F2',
|
|
433
|
+
when: 'workspace.hasSelection && !workspace.multiSelection',
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
id: WORKBENCH_WORKSPACE_DELETE_COMMAND_ID,
|
|
437
|
+
danger: true,
|
|
438
|
+
icon: 'codicon-trash',
|
|
439
|
+
isEnabled: ({ fileActionPaths, workspaceTargetKind }) =>
|
|
440
|
+
workspaceTargetKind === 'folder' || fileActionPaths.length > 0,
|
|
441
|
+
label: ({ fileActionPaths, multiFileAction, workspaceTargetKind }) =>
|
|
442
|
+
workspaceTargetKind === 'folder'
|
|
443
|
+
? 'Delete folder'
|
|
444
|
+
: multiFileAction
|
|
445
|
+
? `Delete ${fileActionPaths.length} files`
|
|
446
|
+
: 'Delete',
|
|
447
|
+
run: ({ deleteWorkspaceTarget }) => deleteWorkspaceTarget(),
|
|
448
|
+
shortcut: 'Del',
|
|
449
|
+
when: 'workspace.hasSelection',
|
|
450
|
+
},
|
|
451
|
+
];
|
|
452
|
+
|
|
453
|
+
return applyWorkbenchCommandOverrides(commands, { commandOverrides });
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export function createWorkbenchWorkspaceCreateMenuEntries<
|
|
457
|
+
TContext extends WorkbenchWorkspaceCommandContext = WorkbenchWorkspaceCommandContext,
|
|
458
|
+
>(): CommandMenuEntry<TContext>[] {
|
|
459
|
+
return commandMenuEntries<TContext>(
|
|
460
|
+
WORKBENCH_WORKSPACE_NEW_FILE_COMMAND_ID,
|
|
461
|
+
WORKBENCH_WORKSPACE_NEW_FOLDER_COMMAND_ID,
|
|
462
|
+
).map((entry) => ({ ...entry, surfaces: [WORKBENCH_COMMAND_SURFACE_WORKSPACE] }));
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
export function createWorkbenchWorkspaceTargetMenuEntries<
|
|
466
|
+
TContext extends WorkbenchWorkspaceCommandContext = WorkbenchWorkspaceCommandContext,
|
|
467
|
+
>(): CommandMenuEntry<TContext>[] {
|
|
468
|
+
return [
|
|
469
|
+
...commandMenuEntries<TContext>(
|
|
470
|
+
WORKBENCH_WORKSPACE_OPEN_COMMAND_ID,
|
|
471
|
+
WORKBENCH_WORKSPACE_COPY_PATH_COMMAND_ID,
|
|
472
|
+
).map((entry) => ({ ...entry, surfaces: [WORKBENCH_COMMAND_SURFACE_WORKSPACE] })),
|
|
473
|
+
commandMenuSeparator('workspace-separator'),
|
|
474
|
+
...commandMenuEntries<TContext>(
|
|
475
|
+
WORKBENCH_WORKSPACE_RENAME_COMMAND_ID,
|
|
476
|
+
WORKBENCH_WORKSPACE_DELETE_COMMAND_ID,
|
|
477
|
+
).map((entry) => ({ ...entry, surfaces: [WORKBENCH_COMMAND_SURFACE_WORKSPACE] })),
|
|
478
|
+
];
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export function createWorkbenchWorkspaceFolderMenuEntries<
|
|
482
|
+
TContext extends WorkbenchWorkspaceCommandContext = WorkbenchWorkspaceCommandContext,
|
|
483
|
+
>(): CommandMenuEntry<TContext>[] {
|
|
484
|
+
return [
|
|
485
|
+
...createWorkbenchWorkspaceCreateMenuEntries(),
|
|
486
|
+
commandMenuSeparator('workspace-create-separator'),
|
|
487
|
+
...createWorkbenchWorkspaceTargetMenuEntries(),
|
|
488
|
+
];
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export function createWorkbenchSearchResultCommands<
|
|
492
|
+
TContext extends WorkbenchSearchResultCommandContext = WorkbenchSearchResultCommandContext,
|
|
493
|
+
>({
|
|
494
|
+
commandOverrides,
|
|
495
|
+
}: WorkbenchCommandPresetOptions<TContext> = {}): CommandDefinition<TContext>[] {
|
|
496
|
+
const commands: CommandDefinition<TContext>[] = [
|
|
497
|
+
{
|
|
498
|
+
id: WORKBENCH_SEARCH_OPEN_RESULT_COMMAND_ID,
|
|
499
|
+
icon: 'codicon-folder-opened',
|
|
500
|
+
label: 'Open',
|
|
501
|
+
run: ({ openResult }) => openResult(),
|
|
502
|
+
shortcut: 'Enter',
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
id: WORKBENCH_SEARCH_COPY_RESULT_PATH_COMMAND_ID,
|
|
506
|
+
icon: 'codicon-copy',
|
|
507
|
+
label: 'Copy path',
|
|
508
|
+
run: ({ copyPath }) => copyPath(),
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
id: WORKBENCH_SEARCH_DELETE_RESULT_COMMAND_ID,
|
|
512
|
+
danger: true,
|
|
513
|
+
icon: 'codicon-trash',
|
|
514
|
+
label: 'Delete',
|
|
515
|
+
run: ({ deleteResult }) => deleteResult(),
|
|
516
|
+
},
|
|
517
|
+
];
|
|
518
|
+
|
|
519
|
+
return applyWorkbenchCommandOverrides(commands, { commandOverrides });
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
export function createWorkbenchSearchResultMenuEntries<
|
|
523
|
+
TContext extends WorkbenchSearchResultCommandContext = WorkbenchSearchResultCommandContext,
|
|
524
|
+
>(): CommandMenuEntry<TContext>[] {
|
|
525
|
+
return [
|
|
526
|
+
...commandMenuEntries<TContext>(
|
|
527
|
+
WORKBENCH_SEARCH_OPEN_RESULT_COMMAND_ID,
|
|
528
|
+
WORKBENCH_SEARCH_COPY_RESULT_PATH_COMMAND_ID,
|
|
529
|
+
).map((entry) => ({ ...entry, surfaces: [WORKBENCH_COMMAND_SURFACE_SEARCH] })),
|
|
530
|
+
commandMenuSeparator('result-menu-separator'),
|
|
531
|
+
commandMenuEntry<TContext>(WORKBENCH_SEARCH_DELETE_RESULT_COMMAND_ID, {
|
|
532
|
+
surfaces: [WORKBENCH_COMMAND_SURFACE_SEARCH],
|
|
533
|
+
}),
|
|
534
|
+
];
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
export function resolveWorkbenchCommandMenuItems<TContext>({
|
|
538
|
+
registry,
|
|
539
|
+
entries,
|
|
540
|
+
context,
|
|
541
|
+
surface,
|
|
542
|
+
contextKeys,
|
|
543
|
+
}: {
|
|
544
|
+
registry: CommandRegistry<TContext>;
|
|
545
|
+
entries: CommandMenuEntry<TContext>[];
|
|
546
|
+
context: TContext;
|
|
547
|
+
surface?: string;
|
|
548
|
+
contextKeys?: object;
|
|
549
|
+
}): CommandMenuItem[] {
|
|
550
|
+
return resolveCommandMenuItems({
|
|
551
|
+
context,
|
|
552
|
+
contextKeys,
|
|
553
|
+
entries,
|
|
554
|
+
registry,
|
|
555
|
+
surface,
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
export function commandMenuItemsToContextMenuItems(
|
|
560
|
+
items: CommandMenuItem[],
|
|
561
|
+
onSelectCommand: (commandId: string) => void,
|
|
562
|
+
): ContextMenuItem[] {
|
|
563
|
+
return items.map((item) =>
|
|
564
|
+
item.type === 'separator'
|
|
565
|
+
? { id: item.id, type: 'separator' }
|
|
566
|
+
: {
|
|
567
|
+
id: item.id,
|
|
568
|
+
label: item.label,
|
|
569
|
+
icon: item.icon,
|
|
570
|
+
shortcut: item.shortcut,
|
|
571
|
+
disabled: item.disabled,
|
|
572
|
+
danger: item.danger,
|
|
573
|
+
onSelect: () => onSelectCommand(item.commandId),
|
|
574
|
+
},
|
|
575
|
+
);
|
|
576
|
+
}
|