@workbench-kit/shell-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 +41 -0
- package/package.json +9 -9
- package/src/{chat-ai-mock-proposals.ts → chat/ai-mock-proposals.ts} +39 -39
- package/src/{chat-command-input.ts → chat/command-input.ts} +52 -52
- package/src/{chat-command-policy.ts → chat/command-policy.ts} +54 -54
- package/src/{chat-command-surface.tsx → chat/command-surface.tsx} +155 -155
- package/src/{use-workbench-chat-command-proposals.ts → chat/use-chat-command-proposals.ts} +194 -194
- package/src/{chat-view-data.ts → chat/view-data.ts} +20 -20
- package/src/{chat-view.tsx → chat/view.tsx} +220 -220
- package/src/{command-inspector-surface.tsx → commands/inspector-surface.tsx} +46 -46
- package/src/{use-workbench-command-descriptors.ts → commands/use-command-descriptors.ts} +41 -41
- package/src/{use-context-key-revision.ts → commands/use-context-key-revision.ts} +18 -18
- package/src/{commands-view-data.ts → commands/view-data.ts} +17 -17
- package/src/{commands-view.tsx → commands/view.tsx} +43 -43
- package/src/devtools/WorkbenchDevtoolsPanel.tsx +124 -124
- package/src/devtools/WorkbenchDevtoolsShell.tsx +17 -17
- package/src/devtools/index.ts +11 -11
- package/src/devtools/use-workbench-devtools-snapshot.ts +84 -84
- package/src/devtools/workbench-devtools-snapshot.ts +140 -140
- package/src/devtools/workbench-devtools.css +82 -82
- package/src/{editor-area-dnd.ts → editor/area-dnd.ts} +69 -69
- package/src/{editor-area-model.ts → editor/area-model.ts} +71 -71
- package/src/{editor-area.css → editor/area.css} +454 -454
- package/src/{editor-area.tsx → editor/area.tsx} +676 -676
- package/src/{editor-host-surface.tsx → editor/host-surface.tsx} +631 -634
- package/src/{editor-pane-visibility.ts → editor/pane-visibility.ts} +130 -130
- package/src/{editor-resource.ts → editor/resource.ts} +36 -36
- package/src/{editor-state-storage.ts → editor/state-storage.ts} +182 -193
- package/src/{editor-tab-context-menu.ts → editor/tab-context-menu.ts} +118 -118
- package/src/{use-editor.ts → editor/use-editor.ts} +114 -107
- package/src/{editor-view-providers.tsx → editor/view-providers.tsx} +552 -552
- package/src/{editor-workspace-file-availability.ts → editor/workspace-file-availability.ts} +15 -15
- package/src/{editor-workspace-reconcile.tsx → editor/workspace-reconcile.tsx} +31 -28
- package/src/{explorer-context-menu.ts → explorer/context-menu.ts} +114 -114
- package/src/{createCommandWorkspaceExplorerPort.ts → explorer/create-command-workspace-explorer-port.ts} +86 -86
- package/src/{explorer-reveal.ts → explorer/reveal.ts} +112 -112
- package/src/{search-view-data.ts → explorer/search-view-data.ts} +15 -15
- package/src/{search-view.tsx → explorer/search-view.tsx} +65 -62
- package/src/{use-active-workspace-path.ts → explorer/use-active-workspace-path.ts} +15 -15
- package/src/{explorer-view-data.ts → explorer/view-data.ts} +58 -58
- package/src/{explorer-view.tsx → explorer/view.tsx} +227 -224
- package/src/{extension-context-menu.ts → extensions/context-menu.ts} +52 -52
- package/src/{extension-management-model.ts → extensions/management-model.ts} +313 -313
- package/src/{use-extension-management.ts → extensions/use-extension-management.ts} +241 -193
- package/src/{extensions-view-data.ts → extensions/view-data.ts} +19 -19
- package/src/{extensions-view.tsx → extensions/view.tsx} +63 -38
- package/src/{field-remap-demo.tsx → field-remap/demo.tsx} +18 -18
- package/src/{field-remap-editor-surface.tsx → field-remap/editor-surface.tsx} +36 -36
- package/src/{field-remap-flow-adapter.ts → field-remap/flow-adapter.ts} +240 -240
- package/src/{field-remap-flow.tsx → field-remap/flow.tsx} +369 -369
- package/src/{field-remap-graph.tsx → field-remap/graph.tsx} +559 -559
- package/src/field-remap/jsonata-transform.ts +166 -0
- package/src/{field-remap-panel.tsx → field-remap/panel.tsx} +193 -175
- package/src/{field-remap-samples.ts → field-remap/samples.ts} +352 -352
- package/src/{table-mapping-adapter.ts → field-remap/table-mapping-adapter.ts} +59 -59
- package/src/{field-remap-tree.tsx → field-remap/tree.tsx} +404 -404
- package/src/{field-remap-view-data.ts → field-remap/view-data.ts} +16 -16
- package/src/{field-remap-view.css → field-remap/view.css} +676 -676
- package/src/{field-remap-view.tsx → field-remap/view.tsx} +86 -86
- package/src/index.ts +212 -199
- package/src/{json-form-source-patch.ts → jdw/json-form-source-patch.ts} +323 -323
- package/src/{jdw-lab-view-data.ts → jdw/lab-view-data.ts} +25 -25
- package/src/{jdw-lab-view.css → jdw/lab-view.css} +21 -21
- package/src/{jdw-lab-view.tsx → jdw/lab-view.tsx} +79 -79
- package/src/{jdw-widget-form-view.tsx → jdw/widget-form-view.tsx} +68 -65
- package/src/{jdw-widget-preview-view.tsx → jdw/widget-preview-view.tsx} +54 -51
- package/src/{keybinding-overrides-storage.ts → management/keybinding-overrides-storage.ts} +49 -57
- package/src/{keybinding-management-settings.tsx → management/keybinding-settings.tsx} +16 -16
- package/src/{management-palette-commands.ts → management/palette-commands.ts} +38 -38
- package/src/{preference-settings-storage.ts → management/preference-settings-storage.ts} +50 -58
- package/src/{management-settings-ids.ts → management/settings-ids.ts} +12 -12
- package/src/{management-settings.tsx → management/settings.tsx} +96 -75
- package/src/{use-command-management.ts → management/use-command-management.ts} +191 -191
- package/src/{use-keybinding-management.ts → management/use-keybinding-management.ts} +130 -130
- package/src/{shell-model.tsx → shell/model.tsx} +149 -149
- package/src/{provider.tsx → shell/provider.tsx} +603 -573
- package/src/{shell-secondary-actions.tsx → shell/secondary-actions.tsx} +59 -59
- package/src/{shell-settings-constants.ts → shell/settings-constants.ts} +9 -9
- package/src/{shell-settings.tsx → shell/settings.tsx} +599 -599
- package/src/{shell.tsx → shell/shell.tsx} +680 -649
- package/src/{shell-titlebar-layout-controls.tsx → shell/titlebar-layout-controls.tsx} +4 -4
- package/src/{shell-view-host.tsx → shell/view-host.tsx} +212 -199
- package/src/{workbench-appearance-storage.ts → workbench/appearance-storage.ts} +107 -115
- package/src/{workbench-command-host.tsx → workbench/command-host.tsx} +243 -243
- package/src/{workbench-command-palette.ts → workbench/command-palette.ts} +208 -208
- package/src/{workbench-keybinding-bridge.ts → workbench/keybinding-bridge.ts} +54 -54
- package/src/{workbench-layout-storage.ts → workbench/layout-storage.ts} +134 -145
- package/src/{workbench-profile-modal.tsx → workbench/profile-modal.tsx} +118 -118
- package/src/{workbench-shell-command-registration.ts → workbench/shell-command-registration.ts} +58 -58
- package/src/{workbench-startup-gate.tsx → workbench/startup-gate.tsx} +136 -136
- package/src/{workbench-status-sections.ts → workbench/status-sections.ts} +43 -43
- package/src/{use-persisted-workbench-appearance.ts → workbench/use-persisted-appearance.ts} +33 -33
- package/src/{workbench-user-commands.ts → workbench/user-commands.ts} +46 -46
- package/src/{workspace-view-state.ts → workbench/workspace-view-state.ts} +35 -35
- package/src/jsonata-transform.ts +0 -36
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
export type EditorViewMode = 'code' | 'form' | 'preview';
|
|
2
|
-
|
|
3
|
-
export type EditorPaneKind = 'code' | 'form' | 'preview';
|
|
4
|
-
|
|
5
|
-
export interface EditorPaneVisibility {
|
|
6
|
-
readonly code: boolean;
|
|
7
|
-
readonly form: boolean;
|
|
8
|
-
readonly preview: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const DEFAULT_EDITOR_PANE_VISIBILITY: EditorPaneVisibility = {
|
|
12
|
-
code: true,
|
|
13
|
-
form: false,
|
|
14
|
-
preview: false,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export function editorViewModeToPaneVisibility(mode: EditorViewMode): EditorPaneVisibility {
|
|
18
|
-
switch (mode) {
|
|
19
|
-
case 'form':
|
|
20
|
-
return {
|
|
21
|
-
code: false,
|
|
22
|
-
form: true,
|
|
23
|
-
preview: false,
|
|
24
|
-
};
|
|
25
|
-
case 'preview':
|
|
26
|
-
return {
|
|
27
|
-
code: false,
|
|
28
|
-
form: false,
|
|
29
|
-
preview: true,
|
|
30
|
-
};
|
|
31
|
-
case 'code':
|
|
32
|
-
default:
|
|
33
|
-
return DEFAULT_EDITOR_PANE_VISIBILITY;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function resolveDefaultEditorPaneVisibility(
|
|
38
|
-
defaultViewMode: EditorViewMode | undefined,
|
|
39
|
-
options: { readonly formEligible?: boolean | undefined } = {},
|
|
40
|
-
): EditorPaneVisibility {
|
|
41
|
-
if (defaultViewMode !== undefined) {
|
|
42
|
-
return editorViewModeToPaneVisibility(defaultViewMode);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (options.formEligible) {
|
|
46
|
-
return editorViewModeToPaneVisibility('form');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return DEFAULT_EDITOR_PANE_VISIBILITY;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Maps pane visibility to the exclusive icon-select value (viewport).
|
|
54
|
-
* If multiple panes are somehow visible, prefers preview → form → code.
|
|
55
|
-
*/
|
|
56
|
-
export function paneVisibilityToPrimaryViewMode(visibility: EditorPaneVisibility): EditorViewMode {
|
|
57
|
-
const exclusive =
|
|
58
|
-
Number(visibility.code) + Number(visibility.form) + Number(visibility.preview) === 1;
|
|
59
|
-
if (exclusive) {
|
|
60
|
-
if (visibility.preview) return 'preview';
|
|
61
|
-
if (visibility.form) return 'form';
|
|
62
|
-
return 'code';
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (visibility.preview) return 'preview';
|
|
66
|
-
if (visibility.form) return 'form';
|
|
67
|
-
return 'code';
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function countVisibleEditorPanes(visibility: EditorPaneVisibility): number {
|
|
71
|
-
return Number(visibility.code) + Number(visibility.form) + Number(visibility.preview);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function toggleEditorPaneVisibility(
|
|
75
|
-
visibility: EditorPaneVisibility,
|
|
76
|
-
pane: EditorPaneKind,
|
|
77
|
-
): EditorPaneVisibility {
|
|
78
|
-
const nextValue = !visibility[pane];
|
|
79
|
-
|
|
80
|
-
if (!nextValue && countVisibleEditorPanes(visibility) <= 1) {
|
|
81
|
-
return visibility;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
...visibility,
|
|
86
|
-
[pane]: nextValue,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function sanitizeEditorPaneVisibility(
|
|
91
|
-
visibility: EditorPaneVisibility,
|
|
92
|
-
options: { formEligible: boolean; previewEligible: boolean },
|
|
93
|
-
): EditorPaneVisibility {
|
|
94
|
-
return resolveEffectiveEditorPaneVisibility(visibility, options);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function resolveEffectiveEditorPaneVisibility(
|
|
98
|
-
preference: EditorPaneVisibility,
|
|
99
|
-
options: { formEligible: boolean; previewEligible: boolean },
|
|
100
|
-
): EditorPaneVisibility {
|
|
101
|
-
const effective: EditorPaneVisibility = {
|
|
102
|
-
code: preference.code,
|
|
103
|
-
form: preference.form && options.formEligible,
|
|
104
|
-
preview: preference.preview && options.previewEligible,
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
if (countVisibleEditorPanes(effective) === 0) {
|
|
108
|
-
return DEFAULT_EDITOR_PANE_VISIBILITY;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return effective;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function getVisibleEditorPaneKinds(visibility: EditorPaneVisibility): EditorPaneKind[] {
|
|
115
|
-
const kinds: EditorPaneKind[] = [];
|
|
116
|
-
|
|
117
|
-
if (visibility.code) {
|
|
118
|
-
kinds.push('code');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (visibility.form) {
|
|
122
|
-
kinds.push('form');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (visibility.preview) {
|
|
126
|
-
kinds.push('preview');
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return kinds;
|
|
130
|
-
}
|
|
1
|
+
export type EditorViewMode = 'code' | 'form' | 'preview';
|
|
2
|
+
|
|
3
|
+
export type EditorPaneKind = 'code' | 'form' | 'preview';
|
|
4
|
+
|
|
5
|
+
export interface EditorPaneVisibility {
|
|
6
|
+
readonly code: boolean;
|
|
7
|
+
readonly form: boolean;
|
|
8
|
+
readonly preview: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const DEFAULT_EDITOR_PANE_VISIBILITY: EditorPaneVisibility = {
|
|
12
|
+
code: true,
|
|
13
|
+
form: false,
|
|
14
|
+
preview: false,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function editorViewModeToPaneVisibility(mode: EditorViewMode): EditorPaneVisibility {
|
|
18
|
+
switch (mode) {
|
|
19
|
+
case 'form':
|
|
20
|
+
return {
|
|
21
|
+
code: false,
|
|
22
|
+
form: true,
|
|
23
|
+
preview: false,
|
|
24
|
+
};
|
|
25
|
+
case 'preview':
|
|
26
|
+
return {
|
|
27
|
+
code: false,
|
|
28
|
+
form: false,
|
|
29
|
+
preview: true,
|
|
30
|
+
};
|
|
31
|
+
case 'code':
|
|
32
|
+
default:
|
|
33
|
+
return DEFAULT_EDITOR_PANE_VISIBILITY;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function resolveDefaultEditorPaneVisibility(
|
|
38
|
+
defaultViewMode: EditorViewMode | undefined,
|
|
39
|
+
options: { readonly formEligible?: boolean | undefined } = {},
|
|
40
|
+
): EditorPaneVisibility {
|
|
41
|
+
if (defaultViewMode !== undefined) {
|
|
42
|
+
return editorViewModeToPaneVisibility(defaultViewMode);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (options.formEligible) {
|
|
46
|
+
return editorViewModeToPaneVisibility('form');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return DEFAULT_EDITOR_PANE_VISIBILITY;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Maps pane visibility to the exclusive icon-select value (viewport).
|
|
54
|
+
* If multiple panes are somehow visible, prefers preview → form → code.
|
|
55
|
+
*/
|
|
56
|
+
export function paneVisibilityToPrimaryViewMode(visibility: EditorPaneVisibility): EditorViewMode {
|
|
57
|
+
const exclusive =
|
|
58
|
+
Number(visibility.code) + Number(visibility.form) + Number(visibility.preview) === 1;
|
|
59
|
+
if (exclusive) {
|
|
60
|
+
if (visibility.preview) return 'preview';
|
|
61
|
+
if (visibility.form) return 'form';
|
|
62
|
+
return 'code';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (visibility.preview) return 'preview';
|
|
66
|
+
if (visibility.form) return 'form';
|
|
67
|
+
return 'code';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function countVisibleEditorPanes(visibility: EditorPaneVisibility): number {
|
|
71
|
+
return Number(visibility.code) + Number(visibility.form) + Number(visibility.preview);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function toggleEditorPaneVisibility(
|
|
75
|
+
visibility: EditorPaneVisibility,
|
|
76
|
+
pane: EditorPaneKind,
|
|
77
|
+
): EditorPaneVisibility {
|
|
78
|
+
const nextValue = !visibility[pane];
|
|
79
|
+
|
|
80
|
+
if (!nextValue && countVisibleEditorPanes(visibility) <= 1) {
|
|
81
|
+
return visibility;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
...visibility,
|
|
86
|
+
[pane]: nextValue,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function sanitizeEditorPaneVisibility(
|
|
91
|
+
visibility: EditorPaneVisibility,
|
|
92
|
+
options: { formEligible: boolean; previewEligible: boolean },
|
|
93
|
+
): EditorPaneVisibility {
|
|
94
|
+
return resolveEffectiveEditorPaneVisibility(visibility, options);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function resolveEffectiveEditorPaneVisibility(
|
|
98
|
+
preference: EditorPaneVisibility,
|
|
99
|
+
options: { formEligible: boolean; previewEligible: boolean },
|
|
100
|
+
): EditorPaneVisibility {
|
|
101
|
+
const effective: EditorPaneVisibility = {
|
|
102
|
+
code: preference.code,
|
|
103
|
+
form: preference.form && options.formEligible,
|
|
104
|
+
preview: preference.preview && options.previewEligible,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
if (countVisibleEditorPanes(effective) === 0) {
|
|
108
|
+
return DEFAULT_EDITOR_PANE_VISIBILITY;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return effective;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function getVisibleEditorPaneKinds(visibility: EditorPaneVisibility): EditorPaneKind[] {
|
|
115
|
+
const kinds: EditorPaneKind[] = [];
|
|
116
|
+
|
|
117
|
+
if (visibility.code) {
|
|
118
|
+
kinds.push('code');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (visibility.form) {
|
|
122
|
+
kinds.push('form');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (visibility.preview) {
|
|
126
|
+
kinds.push('preview');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return kinds;
|
|
130
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
JDW_SCHEMA_DOCUMENT_FILE_EXTENSION,
|
|
3
|
-
JDW_SCHEMA_DOCUMENT_MIME,
|
|
4
|
-
JDW_WIDGET_DOCUMENT_FILE_EXTENSION,
|
|
5
|
-
JDW_WIDGET_DOCUMENT_MIME,
|
|
6
|
-
} from '@workbench-kit/react/jdw/document';
|
|
7
|
-
import { parseWorkspaceResourceUri } from '@workbench-kit/workspace';
|
|
8
|
-
|
|
9
|
-
export function pathForResource(resourceUri: string): string {
|
|
10
|
-
const workspaceUri = parseWorkspaceResourceUri(resourceUri);
|
|
11
|
-
return workspaceUri?.kind === 'file' ? workspaceUri.path : resourceUri;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function copyResourcePath(resourceUri: string): void {
|
|
15
|
-
const path = pathForResource(resourceUri);
|
|
16
|
-
const clipboard = globalThis.navigator?.clipboard;
|
|
17
|
-
if (!clipboard) return;
|
|
18
|
-
|
|
19
|
-
void clipboard.writeText(path).catch(() => undefined);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function mimeTypeForResource(resourceUri: string): string | undefined {
|
|
23
|
-
const path = pathForResource(resourceUri).toLowerCase();
|
|
24
|
-
|
|
25
|
-
if (path.endsWith(JDW_SCHEMA_DOCUMENT_FILE_EXTENSION)) return JDW_SCHEMA_DOCUMENT_MIME;
|
|
26
|
-
if (path.endsWith(JDW_WIDGET_DOCUMENT_FILE_EXTENSION)) return JDW_WIDGET_DOCUMENT_MIME;
|
|
27
|
-
if (path.endsWith('.json')) return 'application/json';
|
|
28
|
-
if (path.endsWith('.ts') || path.endsWith('.tsx')) return 'text/typescript';
|
|
29
|
-
if (path.endsWith('.js') || path.endsWith('.jsx')) return 'text/javascript';
|
|
30
|
-
if (path.endsWith('.css')) return 'text/css';
|
|
31
|
-
if (path.endsWith('.html')) return 'text/html';
|
|
32
|
-
if (path.endsWith('.md') || path.endsWith('.mdx')) return 'text/markdown';
|
|
33
|
-
if (path.endsWith('.yml') || path.endsWith('.yaml')) return 'text/yaml';
|
|
34
|
-
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
JDW_SCHEMA_DOCUMENT_FILE_EXTENSION,
|
|
3
|
+
JDW_SCHEMA_DOCUMENT_MIME,
|
|
4
|
+
JDW_WIDGET_DOCUMENT_FILE_EXTENSION,
|
|
5
|
+
JDW_WIDGET_DOCUMENT_MIME,
|
|
6
|
+
} from '@workbench-kit/react/jdw/document';
|
|
7
|
+
import { parseWorkspaceResourceUri } from '@workbench-kit/workspace';
|
|
8
|
+
|
|
9
|
+
export function pathForResource(resourceUri: string): string {
|
|
10
|
+
const workspaceUri = parseWorkspaceResourceUri(resourceUri);
|
|
11
|
+
return workspaceUri?.kind === 'file' ? workspaceUri.path : resourceUri;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function copyResourcePath(resourceUri: string): void {
|
|
15
|
+
const path = pathForResource(resourceUri);
|
|
16
|
+
const clipboard = globalThis.navigator?.clipboard;
|
|
17
|
+
if (!clipboard) return;
|
|
18
|
+
|
|
19
|
+
void clipboard.writeText(path).catch(() => undefined);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function mimeTypeForResource(resourceUri: string): string | undefined {
|
|
23
|
+
const path = pathForResource(resourceUri).toLowerCase();
|
|
24
|
+
|
|
25
|
+
if (path.endsWith(JDW_SCHEMA_DOCUMENT_FILE_EXTENSION)) return JDW_SCHEMA_DOCUMENT_MIME;
|
|
26
|
+
if (path.endsWith(JDW_WIDGET_DOCUMENT_FILE_EXTENSION)) return JDW_WIDGET_DOCUMENT_MIME;
|
|
27
|
+
if (path.endsWith('.json')) return 'application/json';
|
|
28
|
+
if (path.endsWith('.ts') || path.endsWith('.tsx')) return 'text/typescript';
|
|
29
|
+
if (path.endsWith('.js') || path.endsWith('.jsx')) return 'text/javascript';
|
|
30
|
+
if (path.endsWith('.css')) return 'text/css';
|
|
31
|
+
if (path.endsWith('.html')) return 'text/html';
|
|
32
|
+
if (path.endsWith('.md') || path.endsWith('.mdx')) return 'text/markdown';
|
|
33
|
+
if (path.endsWith('.yml') || path.endsWith('.yaml')) return 'text/yaml';
|
|
34
|
+
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|