vzcode 0.24.0 → 0.25.0
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/dist/assets/index-8628ebab.js +111 -0
- package/dist/index.html +1 -1
- package/package.json +3 -1
- package/src/client/App.tsx +78 -64
- package/src/client/CodeEditor/getOrCreateEditor.ts +3 -0
- package/src/client/CodeEditor/widgets.ts +112 -10
- package/src/client/Sidebar/Item.tsx +3 -3
- package/src/client/reducer.ts +19 -22
- package/src/client/themes/index.ts +7 -0
- package/src/client/{themes.ts → themes/themes.ts} +5 -5
- package/src/client/{useDynamicTheme.ts → themes/useDynamicTheme.ts} +1 -1
- package/src/client/themes/vizhubTheme/colors.ts +80 -0
- package/src/client/themes/vizhubTheme/index.ts +166 -0
- package/dist/assets/index-9c8bbae0.js +0 -111
- package/src/client/useTabsState.ts +0 -95
- package/src/client/vizhubTheme.js +0 -1
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import { FileId } from '../types';
|
|
3
|
-
|
|
4
|
-
// Encapsulates the state and logic for managing the list of open tabs.
|
|
5
|
-
export const useTabsState = (
|
|
6
|
-
activeFileId: FileId,
|
|
7
|
-
setActiveFileId: (fileId: FileId | null) => void,
|
|
8
|
-
tabList: Array<FileId>,
|
|
9
|
-
setTabList: (tabList: Array<FileId>) => void,
|
|
10
|
-
) => {
|
|
11
|
-
// Called when a tab is closed.
|
|
12
|
-
const closeTab = useCallback(
|
|
13
|
-
(fileIdToRemove: FileId) => {
|
|
14
|
-
let newActiveFileId: FileId = activeFileId;
|
|
15
|
-
const i = tabList.findIndex(
|
|
16
|
-
(fileId) => fileId === fileIdToRemove,
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
// Support calling `closeTab` on a fileId that is not open,
|
|
20
|
-
// such as when a file is deleted..
|
|
21
|
-
if (i !== -1) {
|
|
22
|
-
// Remove the tab from the tab list.
|
|
23
|
-
const newTabList = [
|
|
24
|
-
...tabList.slice(0, i),
|
|
25
|
-
...tabList.slice(i + 1),
|
|
26
|
-
];
|
|
27
|
-
setTabList(newTabList);
|
|
28
|
-
|
|
29
|
-
// If we are closing the active file,
|
|
30
|
-
if (activeFileId === fileIdToRemove) {
|
|
31
|
-
// set the new active file to the next tab over,
|
|
32
|
-
if (newTabList.length > 0) {
|
|
33
|
-
newActiveFileId =
|
|
34
|
-
i === 0 ? newTabList[i] : newTabList[i - 1];
|
|
35
|
-
} else {
|
|
36
|
-
// or clear out the active file
|
|
37
|
-
// if we've closed the last tab.
|
|
38
|
-
newActiveFileId = null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
setActiveFileId(newActiveFileId);
|
|
43
|
-
},
|
|
44
|
-
[tabList, activeFileId],
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
//When closing multiple tabs use this function over CloseTab()
|
|
48
|
-
const multiCloseTab = useCallback(
|
|
49
|
-
(idsToDelete: Array<FileId>) => {
|
|
50
|
-
let newTabList = [...tabList]; // Create a copy of the tabList array.
|
|
51
|
-
let newActiveFileId: FileId = activeFileId;
|
|
52
|
-
idsToDelete.forEach((id) => {
|
|
53
|
-
const i = newTabList.findIndex(
|
|
54
|
-
(fileId) => fileId === id,
|
|
55
|
-
);
|
|
56
|
-
if (i !== -1) {
|
|
57
|
-
// Remove the tab from the tab list.
|
|
58
|
-
newTabList = [
|
|
59
|
-
...newTabList.slice(0, i),
|
|
60
|
-
...newTabList.slice(i + 1),
|
|
61
|
-
];
|
|
62
|
-
|
|
63
|
-
// If we are closing the active file,
|
|
64
|
-
if (newActiveFileId === id) {
|
|
65
|
-
// set the new active file to the next tab over,
|
|
66
|
-
if (newTabList.length > 0) {
|
|
67
|
-
newActiveFileId =
|
|
68
|
-
i === 0 ? newTabList[i] : newTabList[i - 1];
|
|
69
|
-
} else {
|
|
70
|
-
// or clear out the active file if we've closed the last tab.
|
|
71
|
-
newActiveFileId = null;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
//Run setStates after doing multiple changes to the two variables. Will properly render tabList and activeFileID.
|
|
77
|
-
setActiveFileId(newActiveFileId);
|
|
78
|
-
setTabList(newTabList);
|
|
79
|
-
},
|
|
80
|
-
[tabList, activeFileId],
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
// Called when a tab is opened.
|
|
84
|
-
const openTab = useCallback(
|
|
85
|
-
(fileId: FileId) => {
|
|
86
|
-
setActiveFileId(fileId);
|
|
87
|
-
if (!tabList.includes(fileId)) {
|
|
88
|
-
setTabList([...tabList, fileId]);
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
[tabList],
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
return { tabList, closeTab, openTab, multiCloseTab };
|
|
95
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// TODO
|