@lvce-editor/settings-view 1.4.0 → 1.5.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/settingsViewWorkerMain.js +156 -30
- package/package.json +1 -1
|
@@ -926,7 +926,8 @@ const {
|
|
|
926
926
|
set: set$1,
|
|
927
927
|
wrapCommand,
|
|
928
928
|
getCommandIds,
|
|
929
|
-
registerCommands
|
|
929
|
+
registerCommands,
|
|
930
|
+
wrapGetter
|
|
930
931
|
} = create$2();
|
|
931
932
|
|
|
932
933
|
const create$1 = (id, uri, x, y, width, height) => {
|
|
@@ -942,7 +943,8 @@ const create$1 = (id, uri, x, y, width, height) => {
|
|
|
942
943
|
height,
|
|
943
944
|
tabs: [],
|
|
944
945
|
items: [],
|
|
945
|
-
searchValue: ''
|
|
946
|
+
searchValue: '',
|
|
947
|
+
filteredItems: []
|
|
946
948
|
};
|
|
947
949
|
set$1(id, state, state);
|
|
948
950
|
};
|
|
@@ -981,6 +983,14 @@ const diff2 = uid => {
|
|
|
981
983
|
return diffResult;
|
|
982
984
|
};
|
|
983
985
|
|
|
986
|
+
const getFilteredItems = (items, tabs) => {
|
|
987
|
+
const selectedTab = tabs.find(tab => tab.selected);
|
|
988
|
+
if (!selectedTab) {
|
|
989
|
+
return items;
|
|
990
|
+
}
|
|
991
|
+
return items.filter(item => item.category === selectedTab.id);
|
|
992
|
+
};
|
|
993
|
+
|
|
984
994
|
const getSelectedTabId = tabs => {
|
|
985
995
|
for (const tab of tabs) {
|
|
986
996
|
if (tab.selected) {
|
|
@@ -989,6 +999,7 @@ const getSelectedTabId = tabs => {
|
|
|
989
999
|
}
|
|
990
1000
|
return '';
|
|
991
1001
|
};
|
|
1002
|
+
|
|
992
1003
|
const getUpdatedTabs = (tabs, selectedTabId) => {
|
|
993
1004
|
// Check if the clicked tab is already selected
|
|
994
1005
|
const clickedTabId = getSelectedTabId(tabs);
|
|
@@ -1005,9 +1016,12 @@ const handleClickTab = (state, name) => {
|
|
|
1005
1016
|
if (!name) {
|
|
1006
1017
|
return state;
|
|
1007
1018
|
}
|
|
1019
|
+
const updatedTabs = getUpdatedTabs(state.tabs, name);
|
|
1020
|
+
const filteredItems = getFilteredItems(state.items, updatedTabs);
|
|
1008
1021
|
return {
|
|
1009
1022
|
...state,
|
|
1010
|
-
tabs:
|
|
1023
|
+
tabs: updatedTabs,
|
|
1024
|
+
filteredItems
|
|
1011
1025
|
};
|
|
1012
1026
|
};
|
|
1013
1027
|
|
|
@@ -1022,7 +1036,18 @@ const initialize = async () => {
|
|
|
1022
1036
|
// TODO
|
|
1023
1037
|
};
|
|
1024
1038
|
|
|
1039
|
+
const ApplicationsTab = 'applications';
|
|
1040
|
+
const Clear = 'Clear';
|
|
1041
|
+
const ExtensionsTab = 'extensions';
|
|
1042
|
+
const FeaturesTab = 'features';
|
|
1043
|
+
const SecurityTab = 'security';
|
|
1044
|
+
const SettingsSearch = 'SettingsSearch';
|
|
1045
|
+
const TextEditorTab = 'text-editor';
|
|
1046
|
+
const WindowTab = 'window';
|
|
1047
|
+
const WorkbenchTab = 'workbench';
|
|
1048
|
+
|
|
1025
1049
|
const String = 2;
|
|
1050
|
+
const Boolean$1 = 3;
|
|
1026
1051
|
const Number$1 = 5;
|
|
1027
1052
|
|
|
1028
1053
|
const getSettingItems = async () => {
|
|
@@ -1031,43 +1056,129 @@ const getSettingItems = async () => {
|
|
|
1031
1056
|
heading: 'Font Size',
|
|
1032
1057
|
description: 'The font size of the editor',
|
|
1033
1058
|
type: Number$1,
|
|
1034
|
-
value: '15px'
|
|
1059
|
+
value: '15px',
|
|
1060
|
+
category: TextEditorTab
|
|
1035
1061
|
}, {
|
|
1036
1062
|
id: 'fontFamily',
|
|
1037
1063
|
heading: 'Font Family',
|
|
1038
1064
|
description: 'The font family of the editor',
|
|
1039
1065
|
type: String,
|
|
1040
|
-
value: 'Fira Code'
|
|
1066
|
+
value: 'Fira Code',
|
|
1067
|
+
category: TextEditorTab
|
|
1068
|
+
}, {
|
|
1069
|
+
id: 'theme',
|
|
1070
|
+
heading: 'Theme',
|
|
1071
|
+
description: 'The color theme of the workbench',
|
|
1072
|
+
type: String,
|
|
1073
|
+
value: 'Dark',
|
|
1074
|
+
category: WorkbenchTab
|
|
1075
|
+
}, {
|
|
1076
|
+
id: 'sidebarPosition',
|
|
1077
|
+
heading: 'Sidebar Position',
|
|
1078
|
+
description: 'The position of the sidebar',
|
|
1079
|
+
type: String,
|
|
1080
|
+
value: 'Left',
|
|
1081
|
+
category: WorkbenchTab
|
|
1082
|
+
}, {
|
|
1083
|
+
id: 'windowTitle',
|
|
1084
|
+
heading: 'Window Title',
|
|
1085
|
+
description: 'The title shown in the window',
|
|
1086
|
+
type: String,
|
|
1087
|
+
value: 'Settings View',
|
|
1088
|
+
category: WindowTab
|
|
1089
|
+
}, {
|
|
1090
|
+
id: 'windowSize',
|
|
1091
|
+
heading: 'Window Size',
|
|
1092
|
+
description: 'The default window size',
|
|
1093
|
+
type: String,
|
|
1094
|
+
value: '1024x768',
|
|
1095
|
+
category: WindowTab
|
|
1096
|
+
}, {
|
|
1097
|
+
id: 'autoSave',
|
|
1098
|
+
heading: 'Auto Save',
|
|
1099
|
+
description: 'Automatically save files',
|
|
1100
|
+
type: Boolean$1,
|
|
1101
|
+
value: 'true',
|
|
1102
|
+
category: FeaturesTab
|
|
1103
|
+
}, {
|
|
1104
|
+
id: 'formatOnSave',
|
|
1105
|
+
heading: 'Format on Save',
|
|
1106
|
+
description: 'Format code when saving',
|
|
1107
|
+
type: Boolean$1,
|
|
1108
|
+
value: 'false',
|
|
1109
|
+
category: FeaturesTab
|
|
1110
|
+
}, {
|
|
1111
|
+
id: 'telemetry',
|
|
1112
|
+
heading: 'Telemetry',
|
|
1113
|
+
description: 'Enable telemetry collection',
|
|
1114
|
+
type: Boolean$1,
|
|
1115
|
+
value: 'true',
|
|
1116
|
+
category: ApplicationsTab
|
|
1117
|
+
}, {
|
|
1118
|
+
id: 'updates',
|
|
1119
|
+
heading: 'Auto Updates',
|
|
1120
|
+
description: 'Automatically check for updates',
|
|
1121
|
+
type: Boolean$1,
|
|
1122
|
+
value: 'true',
|
|
1123
|
+
category: ApplicationsTab
|
|
1124
|
+
}, {
|
|
1125
|
+
id: 'encryption',
|
|
1126
|
+
heading: 'File Encryption',
|
|
1127
|
+
description: 'Encrypt sensitive files',
|
|
1128
|
+
type: Boolean$1,
|
|
1129
|
+
value: 'false',
|
|
1130
|
+
category: SecurityTab
|
|
1131
|
+
}, {
|
|
1132
|
+
id: 'twoFactor',
|
|
1133
|
+
heading: 'Two Factor Auth',
|
|
1134
|
+
description: 'Enable two factor authentication',
|
|
1135
|
+
type: Boolean$1,
|
|
1136
|
+
value: 'false',
|
|
1137
|
+
category: SecurityTab
|
|
1138
|
+
}, {
|
|
1139
|
+
id: 'extensionsAutoUpdate',
|
|
1140
|
+
heading: 'Auto Update Extensions',
|
|
1141
|
+
description: 'Automatically update extensions',
|
|
1142
|
+
type: Boolean$1,
|
|
1143
|
+
value: 'true',
|
|
1144
|
+
category: ExtensionsTab
|
|
1145
|
+
}, {
|
|
1146
|
+
id: 'extensionRecommendations',
|
|
1147
|
+
heading: 'Extension Recommendations',
|
|
1148
|
+
description: 'Show extension recommendations',
|
|
1149
|
+
type: Boolean$1,
|
|
1150
|
+
value: 'true',
|
|
1151
|
+
category: ExtensionsTab
|
|
1041
1152
|
}];
|
|
1042
1153
|
};
|
|
1043
1154
|
|
|
1044
1155
|
const getTabs = () => {
|
|
1045
1156
|
const tabs = [{
|
|
1046
|
-
id:
|
|
1157
|
+
id: TextEditorTab,
|
|
1047
1158
|
label: 'Text Editor',
|
|
1048
1159
|
selected: true
|
|
1049
1160
|
}, {
|
|
1050
|
-
id:
|
|
1161
|
+
id: WorkbenchTab,
|
|
1051
1162
|
label: 'Workbench',
|
|
1052
1163
|
selected: false
|
|
1053
1164
|
}, {
|
|
1054
|
-
id:
|
|
1165
|
+
id: WindowTab,
|
|
1055
1166
|
label: 'Window',
|
|
1056
1167
|
selected: false
|
|
1057
1168
|
}, {
|
|
1058
|
-
id:
|
|
1169
|
+
id: FeaturesTab,
|
|
1059
1170
|
label: 'Features',
|
|
1060
1171
|
selected: false
|
|
1061
1172
|
}, {
|
|
1062
|
-
id:
|
|
1173
|
+
id: ApplicationsTab,
|
|
1063
1174
|
label: 'Applications',
|
|
1064
1175
|
selected: false
|
|
1065
1176
|
}, {
|
|
1066
|
-
id:
|
|
1177
|
+
id: SecurityTab,
|
|
1067
1178
|
label: 'Security',
|
|
1068
1179
|
selected: false
|
|
1069
1180
|
}, {
|
|
1070
|
-
id:
|
|
1181
|
+
id: ExtensionsTab,
|
|
1071
1182
|
label: 'Extensions',
|
|
1072
1183
|
selected: false
|
|
1073
1184
|
}];
|
|
@@ -1077,10 +1188,12 @@ const getTabs = () => {
|
|
|
1077
1188
|
const loadContent = async (state, savedState) => {
|
|
1078
1189
|
const tabs = getTabs();
|
|
1079
1190
|
const items = await getSettingItems();
|
|
1191
|
+
const filteredItems = getFilteredItems(items, tabs);
|
|
1080
1192
|
return {
|
|
1081
1193
|
...state,
|
|
1082
1194
|
tabs,
|
|
1083
|
-
items
|
|
1195
|
+
items,
|
|
1196
|
+
filteredItems
|
|
1084
1197
|
};
|
|
1085
1198
|
};
|
|
1086
1199
|
|
|
@@ -1105,7 +1218,6 @@ const Text = 12;
|
|
|
1105
1218
|
const H2 = 22;
|
|
1106
1219
|
const H3 = 23;
|
|
1107
1220
|
const Aside = 28;
|
|
1108
|
-
const Li = 48;
|
|
1109
1221
|
const P = 50;
|
|
1110
1222
|
const Ul = 60;
|
|
1111
1223
|
const VirtualDomElements = {
|
|
@@ -1117,7 +1229,6 @@ const VirtualDomElements = {
|
|
|
1117
1229
|
H2,
|
|
1118
1230
|
H3,
|
|
1119
1231
|
Input,
|
|
1120
|
-
Li,
|
|
1121
1232
|
P,
|
|
1122
1233
|
Ul};
|
|
1123
1234
|
const text = data => {
|
|
@@ -1132,9 +1243,6 @@ const {
|
|
|
1132
1243
|
Viewlet} = ClassNames;
|
|
1133
1244
|
const Settings = 'Settings';
|
|
1134
1245
|
|
|
1135
|
-
const SettingsSearch = 'SettingsSearch';
|
|
1136
|
-
const Clear = 'Clear';
|
|
1137
|
-
|
|
1138
1246
|
const getSettingsInputDom = () => {
|
|
1139
1247
|
const placeholder = 'Search Settings';
|
|
1140
1248
|
return [{
|
|
@@ -1198,7 +1306,9 @@ const getSettingsItemsDom = items => {
|
|
|
1198
1306
|
}, ...items.flatMap(getItemNumberVirtualDom)];
|
|
1199
1307
|
};
|
|
1200
1308
|
|
|
1201
|
-
const getSettingsContentDom = items => {
|
|
1309
|
+
const getSettingsContentDom = (items, tabs) => {
|
|
1310
|
+
const selectedTab = tabs.find(tab => tab.selected);
|
|
1311
|
+
const headerText = selectedTab ? selectedTab.label : 'Settings Content';
|
|
1202
1312
|
return [{
|
|
1203
1313
|
type: VirtualDomElements.Div,
|
|
1204
1314
|
className: 'SettingsContent',
|
|
@@ -1206,22 +1316,28 @@ const getSettingsContentDom = items => {
|
|
|
1206
1316
|
}, {
|
|
1207
1317
|
type: VirtualDomElements.H1,
|
|
1208
1318
|
childCount: 1
|
|
1209
|
-
}, text(
|
|
1319
|
+
}, text(headerText), ...getSettingsItemsDom(items)];
|
|
1210
1320
|
};
|
|
1211
1321
|
|
|
1322
|
+
// TODo use numeric ids
|
|
1323
|
+
const HandleClickClear = 'handleClickClear';
|
|
1212
1324
|
const HandleClickTab = 'handleClickTab';
|
|
1213
1325
|
const HandleInput = 'handleInput';
|
|
1214
1326
|
|
|
1215
|
-
|
|
1327
|
+
const getTabClassName = tab => {
|
|
1328
|
+
return tab.selected ? mergeClassNames('Tab', 'TabSelected') : 'Tab';
|
|
1329
|
+
};
|
|
1216
1330
|
|
|
1217
1331
|
const getTabVirtualDom = tab => {
|
|
1218
|
-
const className = tab
|
|
1332
|
+
const className = getTabClassName(tab);
|
|
1219
1333
|
return [{
|
|
1220
|
-
type: VirtualDomElements.
|
|
1334
|
+
type: VirtualDomElements.Button,
|
|
1221
1335
|
className,
|
|
1222
1336
|
childCount: 1,
|
|
1223
1337
|
role: AriaRoles.Tab,
|
|
1224
|
-
name: tab.id
|
|
1338
|
+
name: tab.id,
|
|
1339
|
+
id: tab.id,
|
|
1340
|
+
ariaSelected: tab.selected
|
|
1225
1341
|
}, text(tab.label)];
|
|
1226
1342
|
};
|
|
1227
1343
|
|
|
@@ -1253,19 +1369,19 @@ const getSettingsMainDom = (tabs, items) => {
|
|
|
1253
1369
|
type: VirtualDomElements.Div,
|
|
1254
1370
|
className: 'SettingsMain',
|
|
1255
1371
|
childCount: 2
|
|
1256
|
-
}, ...getSettingsSideBarDom(tabs), ...getSettingsContentDom(items)];
|
|
1372
|
+
}, ...getSettingsSideBarDom(tabs), ...getSettingsContentDom(items, tabs)];
|
|
1257
1373
|
};
|
|
1258
1374
|
|
|
1259
1375
|
const getSettingsDom = state => {
|
|
1260
1376
|
const {
|
|
1261
1377
|
tabs,
|
|
1262
|
-
|
|
1378
|
+
filteredItems
|
|
1263
1379
|
} = state;
|
|
1264
1380
|
return [{
|
|
1265
1381
|
type: VirtualDomElements.Div,
|
|
1266
1382
|
childCount: 2,
|
|
1267
1383
|
className: mergeClassNames(Viewlet, Settings)
|
|
1268
|
-
}, ...getSettingsHeaderDom(), ...getSettingsMainDom(tabs,
|
|
1384
|
+
}, ...getSettingsHeaderDom(), ...getSettingsMainDom(tabs, filteredItems)];
|
|
1269
1385
|
};
|
|
1270
1386
|
|
|
1271
1387
|
const renderItems = (oldState, newState) => {
|
|
@@ -1312,6 +1428,9 @@ const renderEventListeners = () => {
|
|
|
1312
1428
|
}, {
|
|
1313
1429
|
name: HandleInput,
|
|
1314
1430
|
params: ['handleInput', 'event.target.value']
|
|
1431
|
+
}, {
|
|
1432
|
+
name: HandleClickClear,
|
|
1433
|
+
params: ['clear']
|
|
1315
1434
|
}];
|
|
1316
1435
|
};
|
|
1317
1436
|
|
|
@@ -1351,13 +1470,20 @@ const restoreState = savedState => {
|
|
|
1351
1470
|
};
|
|
1352
1471
|
};
|
|
1353
1472
|
|
|
1354
|
-
const saveState =
|
|
1473
|
+
const saveState = state => {
|
|
1474
|
+
const {
|
|
1475
|
+
tabs,
|
|
1476
|
+
searchValue
|
|
1477
|
+
} = state;
|
|
1478
|
+
const selectedTab = getSelectedTabId(tabs);
|
|
1355
1479
|
return {
|
|
1356
1480
|
expandedPaths: [],
|
|
1357
1481
|
root: '',
|
|
1358
1482
|
minLineY: 0,
|
|
1359
1483
|
maxLineY: 0,
|
|
1360
|
-
deltaY: 0
|
|
1484
|
+
deltaY: 0,
|
|
1485
|
+
searchValue,
|
|
1486
|
+
selectedTab
|
|
1361
1487
|
};
|
|
1362
1488
|
};
|
|
1363
1489
|
|
|
@@ -1371,7 +1497,7 @@ const commandMap = {
|
|
|
1371
1497
|
'Settings.renderActions': renderActions,
|
|
1372
1498
|
'Settings.renderEventListeners': renderEventListeners,
|
|
1373
1499
|
'Settings.restoreState': restoreState,
|
|
1374
|
-
'Settings.saveState': saveState,
|
|
1500
|
+
'Settings.saveState': wrapGetter(saveState),
|
|
1375
1501
|
'Settings.terminate': terminate,
|
|
1376
1502
|
'Settings.handleClickTab': wrapCommand(handleClickTab),
|
|
1377
1503
|
'Settings.clear': wrapCommand(clear),
|