@lvce-editor/settings-view 2.26.0 → 2.26.2
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 +292 -130
- package/package.json +1 -1
|
@@ -1194,6 +1194,18 @@ const filterByTab = (items, tabs) => {
|
|
|
1194
1194
|
return items.filter(item => item.category === selectedTab.id);
|
|
1195
1195
|
};
|
|
1196
1196
|
|
|
1197
|
+
const parseFilterQuery = searchValue => {
|
|
1198
|
+
const words = searchValue.split(/\s+/);
|
|
1199
|
+
const modified = words.includes('@modified');
|
|
1200
|
+
const query = words.filter(word => word !== '@modified').join(' ').trim();
|
|
1201
|
+
return {
|
|
1202
|
+
id: '',
|
|
1203
|
+
language: '',
|
|
1204
|
+
modified,
|
|
1205
|
+
query
|
|
1206
|
+
};
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1197
1209
|
const isItemModified = (item, preferences) => {
|
|
1198
1210
|
return item.id in preferences;
|
|
1199
1211
|
};
|
|
@@ -1220,10 +1232,11 @@ const validateSettings = (items, modifiedSettings, preferences) => {
|
|
|
1220
1232
|
};
|
|
1221
1233
|
|
|
1222
1234
|
const getFilteredItems = (items, tabs, searchValue, modifiedSettings, preferences) => {
|
|
1235
|
+
const parsedQuery = parseFilterQuery(searchValue);
|
|
1223
1236
|
const tabFilteredItems = filterByTab(items, tabs);
|
|
1224
|
-
const searchFilteredItems = filterBySearch(tabFilteredItems,
|
|
1237
|
+
const searchFilteredItems = filterBySearch(tabFilteredItems, parsedQuery.query);
|
|
1225
1238
|
const validated = validateSettings(searchFilteredItems, modifiedSettings, preferences);
|
|
1226
|
-
return validated;
|
|
1239
|
+
return parsedQuery.modified ? validated.filter(item => item.modified) : validated;
|
|
1227
1240
|
};
|
|
1228
1241
|
|
|
1229
1242
|
const User = 1;
|
|
@@ -1376,6 +1389,159 @@ const diff2 = uid => {
|
|
|
1376
1389
|
return diffResult;
|
|
1377
1390
|
};
|
|
1378
1391
|
|
|
1392
|
+
const addToHistory = (history, value) => {
|
|
1393
|
+
let newHistory = history;
|
|
1394
|
+
let newHistoryIndex = -1;
|
|
1395
|
+
if (!value || !value.trim()) {
|
|
1396
|
+
return {
|
|
1397
|
+
newHistory,
|
|
1398
|
+
newHistoryIndex
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
const trimmedValue = value.trim();
|
|
1402
|
+
|
|
1403
|
+
// Check if this value is already in history
|
|
1404
|
+
const existingIndex = history.indexOf(trimmedValue);
|
|
1405
|
+
if (existingIndex !== -1) {
|
|
1406
|
+
newHistoryIndex = existingIndex;
|
|
1407
|
+
return {
|
|
1408
|
+
newHistory,
|
|
1409
|
+
newHistoryIndex
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
// Check if this value is a prefix of any existing history item
|
|
1414
|
+
// If it is, don't add it to history yet (it's still being typed)
|
|
1415
|
+
const isPrefixOfExisting = history.some(historyItem => historyItem.startsWith(trimmedValue) && historyItem !== trimmedValue);
|
|
1416
|
+
if (isPrefixOfExisting) {
|
|
1417
|
+
// Don't add to history, but find the closest match for index
|
|
1418
|
+
const closestMatch = history.find(historyItem => historyItem.startsWith(trimmedValue));
|
|
1419
|
+
if (closestMatch) {
|
|
1420
|
+
newHistoryIndex = history.indexOf(closestMatch);
|
|
1421
|
+
}
|
|
1422
|
+
return {
|
|
1423
|
+
newHistory,
|
|
1424
|
+
newHistoryIndex
|
|
1425
|
+
};
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
// Check if any existing history items are prefixes of this value
|
|
1429
|
+
// If so, remove all prefix items and add the complete value at the first prefix position
|
|
1430
|
+
const prefixItems = history.filter(historyItem => trimmedValue.startsWith(historyItem) && historyItem !== trimmedValue);
|
|
1431
|
+
if (prefixItems.length > 0) {
|
|
1432
|
+
// Find the position of the first prefix item
|
|
1433
|
+
const firstPrefixIndex = history.findIndex(historyItem => trimmedValue.startsWith(historyItem) && historyItem !== trimmedValue);
|
|
1434
|
+
|
|
1435
|
+
// Remove all prefix items and add the complete value at the first prefix position
|
|
1436
|
+
|
|
1437
|
+
// Insert the new value at the position where the first prefix was
|
|
1438
|
+
const beforePrefix = history.slice(0, firstPrefixIndex);
|
|
1439
|
+
const afterPrefix = history.slice(firstPrefixIndex).filter(historyItem => !trimmedValue.startsWith(historyItem) || historyItem === trimmedValue);
|
|
1440
|
+
newHistory = [...beforePrefix, trimmedValue, ...afterPrefix];
|
|
1441
|
+
newHistoryIndex = firstPrefixIndex;
|
|
1442
|
+
} else {
|
|
1443
|
+
// Add as new item
|
|
1444
|
+
newHistory = [...history, trimmedValue];
|
|
1445
|
+
newHistoryIndex = newHistory.length - 1;
|
|
1446
|
+
}
|
|
1447
|
+
return {
|
|
1448
|
+
newHistory,
|
|
1449
|
+
newHistoryIndex
|
|
1450
|
+
};
|
|
1451
|
+
};
|
|
1452
|
+
|
|
1453
|
+
const handleInput = (state, value, inputSource = User) => {
|
|
1454
|
+
const {
|
|
1455
|
+
height,
|
|
1456
|
+
history,
|
|
1457
|
+
itemHeight,
|
|
1458
|
+
items,
|
|
1459
|
+
modifiedSettings,
|
|
1460
|
+
preferences,
|
|
1461
|
+
tabs
|
|
1462
|
+
} = state;
|
|
1463
|
+
const filteredItems = getFilteredItems(items, tabs, value, modifiedSettings, preferences);
|
|
1464
|
+
// Reset scroll when filter value changes so the user sees results from the top
|
|
1465
|
+
const nextScrollOffset = 0;
|
|
1466
|
+
const {
|
|
1467
|
+
maxLineY,
|
|
1468
|
+
minLineY,
|
|
1469
|
+
visibleItems
|
|
1470
|
+
} = computeVisibleItems(filteredItems, height, nextScrollOffset, itemHeight);
|
|
1471
|
+
const {
|
|
1472
|
+
scrollBarMinHeight
|
|
1473
|
+
} = state;
|
|
1474
|
+
const {
|
|
1475
|
+
thumbHeight,
|
|
1476
|
+
thumbTop
|
|
1477
|
+
} = computeScrollBar(height, filteredItems.length, itemHeight, nextScrollOffset, scrollBarMinHeight);
|
|
1478
|
+
const {
|
|
1479
|
+
newHistory,
|
|
1480
|
+
newHistoryIndex
|
|
1481
|
+
} = addToHistory(history, value);
|
|
1482
|
+
return {
|
|
1483
|
+
...state,
|
|
1484
|
+
deltaY: 0,
|
|
1485
|
+
filteredItems,
|
|
1486
|
+
history: newHistory,
|
|
1487
|
+
historyIndex: newHistoryIndex,
|
|
1488
|
+
inputSource,
|
|
1489
|
+
maxLineY,
|
|
1490
|
+
minLineY,
|
|
1491
|
+
scrollBarThumbHeight: thumbHeight,
|
|
1492
|
+
scrollBarThumbTop: thumbTop,
|
|
1493
|
+
scrollOffset: nextScrollOffset,
|
|
1494
|
+
searchValue: value,
|
|
1495
|
+
visibleItems
|
|
1496
|
+
};
|
|
1497
|
+
};
|
|
1498
|
+
|
|
1499
|
+
const applyFilter = (state, searchValue) => {
|
|
1500
|
+
const newState = handleInput(state, searchValue, Script);
|
|
1501
|
+
return {
|
|
1502
|
+
...newState,
|
|
1503
|
+
focus: FocusSettingsInput,
|
|
1504
|
+
focusSource: Script
|
|
1505
|
+
};
|
|
1506
|
+
};
|
|
1507
|
+
const appendFilter = (state, filter) => {
|
|
1508
|
+
const {
|
|
1509
|
+
searchValue: currentSearchValue
|
|
1510
|
+
} = state;
|
|
1511
|
+
const searchValue = currentSearchValue.trimEnd();
|
|
1512
|
+
const newSearchValue = searchValue ? `${searchValue} ${filter}` : filter;
|
|
1513
|
+
return applyFilter(state, newSearchValue);
|
|
1514
|
+
};
|
|
1515
|
+
const toggleFilter = (state, filter) => {
|
|
1516
|
+
const {
|
|
1517
|
+
searchValue
|
|
1518
|
+
} = state;
|
|
1519
|
+
const words = searchValue.split(' ');
|
|
1520
|
+
const newSearchValue = words.includes(filter) ? words.filter(word => word !== filter).join(' ') : [...words.filter(Boolean), filter].join(' ');
|
|
1521
|
+
return applyFilter(state, newSearchValue);
|
|
1522
|
+
};
|
|
1523
|
+
const toggleExclusiveFilter = (state, filter, excludedFilters) => {
|
|
1524
|
+
const {
|
|
1525
|
+
searchValue
|
|
1526
|
+
} = state;
|
|
1527
|
+
const words = searchValue.split(' ');
|
|
1528
|
+
if (words.includes(filter)) {
|
|
1529
|
+
return applyFilter(state, words.filter(word => word !== filter).join(' '));
|
|
1530
|
+
}
|
|
1531
|
+
const newSearchValue = [...words.filter(word => word && word !== filter && !excludedFilters.includes(word)), filter].join(' ');
|
|
1532
|
+
return applyFilter(state, newSearchValue);
|
|
1533
|
+
};
|
|
1534
|
+
const filterAdvanced = state => toggleFilter(state, '@tag:advanced');
|
|
1535
|
+
const filterExperimental = state => toggleExclusiveFilter(state, '@tag:experimental', ['@stable', '@tag:preview']);
|
|
1536
|
+
const filterExtensionId = state => appendFilter(state, '@ext:');
|
|
1537
|
+
const filterFeature = state => appendFilter(state, '@feature:');
|
|
1538
|
+
const filterLanguage = state => appendFilter(state, '@lang:');
|
|
1539
|
+
const filterModified = state => toggleFilter(state, '@modified');
|
|
1540
|
+
const filterPreview = state => toggleExclusiveFilter(state, '@tag:preview', ['@stable', '@tag:experimental']);
|
|
1541
|
+
const filterSettingId = state => appendFilter(state, '@id:');
|
|
1542
|
+
const filterStable = state => toggleExclusiveFilter(state, '@stable', ['@tag:preview', '@tag:experimental']);
|
|
1543
|
+
const filterTag = state => appendFilter(state, '@tag:');
|
|
1544
|
+
|
|
1379
1545
|
const Group = 'group';
|
|
1380
1546
|
const Tab$1 = 'tab';
|
|
1381
1547
|
const TabList = 'tablist';
|
|
@@ -1873,9 +2039,11 @@ const TargetValue = 'event.target.value';
|
|
|
1873
2039
|
const UpArrow = 14;
|
|
1874
2040
|
const DownArrow = 16;
|
|
1875
2041
|
|
|
2042
|
+
const Settings$1 = 12;
|
|
1876
2043
|
const SettingsFilter = 94;
|
|
1877
2044
|
|
|
1878
2045
|
const None$1 = 0;
|
|
2046
|
+
const Disabled = 5;
|
|
1879
2047
|
|
|
1880
2048
|
const SetCss = 'Viewlet.setCss';
|
|
1881
2049
|
|
|
@@ -1927,6 +2095,7 @@ const Modified = 'Modified';
|
|
|
1927
2095
|
const NoSettingsMatching = 'No settings matching "{PH1}" found';
|
|
1928
2096
|
const NumberValue = 'number value';
|
|
1929
2097
|
const Preview = 'Preview';
|
|
2098
|
+
const ResetSetting = 'Reset Setting';
|
|
1930
2099
|
const SearchSettings = 'Search Settings';
|
|
1931
2100
|
const SettingId = 'Setting Id';
|
|
1932
2101
|
const SettingsContent$1 = 'Settings Content';
|
|
@@ -1956,6 +2125,7 @@ const noSettingsMatching = searchTerm => {
|
|
|
1956
2125
|
};
|
|
1957
2126
|
const numberValue = () => i18nString(NumberValue);
|
|
1958
2127
|
const preview = () => i18nString(Preview);
|
|
2128
|
+
const resetSetting$1 = () => i18nString(ResetSetting);
|
|
1959
2129
|
const searchSettings = () => i18nString(SearchSettings);
|
|
1960
2130
|
const settingId = () => i18nString(SettingId);
|
|
1961
2131
|
const settingsContent = () => i18nString(SettingsContent$1);
|
|
@@ -1966,60 +2136,77 @@ const unknownSettingType = () => i18nString(UnknownSettingType);
|
|
|
1966
2136
|
|
|
1967
2137
|
const getMenuEntries = () => {
|
|
1968
2138
|
return [{
|
|
1969
|
-
command: 'Settings.
|
|
2139
|
+
command: 'Settings.filterAdvanced',
|
|
1970
2140
|
flags: None$1,
|
|
1971
2141
|
id: 'filter-advanced',
|
|
1972
2142
|
label: advanced()
|
|
1973
2143
|
}, {
|
|
1974
|
-
command: 'Settings.
|
|
2144
|
+
command: 'Settings.filterExperimental',
|
|
1975
2145
|
flags: None$1,
|
|
1976
2146
|
id: 'filter-experimental',
|
|
1977
2147
|
label: experimental()
|
|
1978
2148
|
}, {
|
|
1979
|
-
command: 'Settings.
|
|
2149
|
+
command: 'Settings.filterExtensionId',
|
|
1980
2150
|
flags: None$1,
|
|
1981
2151
|
id: 'filter-extensionId',
|
|
1982
2152
|
label: extensionId()
|
|
1983
2153
|
}, {
|
|
1984
|
-
command: 'Settings.
|
|
2154
|
+
command: 'Settings.filterFeature',
|
|
1985
2155
|
flags: None$1,
|
|
1986
2156
|
id: 'filter-feature',
|
|
1987
2157
|
label: feature()
|
|
1988
2158
|
}, {
|
|
1989
|
-
command: 'Settings.
|
|
2159
|
+
command: 'Settings.filterLanguage',
|
|
1990
2160
|
flags: None$1,
|
|
1991
2161
|
id: 'filter-language',
|
|
1992
2162
|
label: language()
|
|
1993
2163
|
}, {
|
|
1994
|
-
command: 'Settings.
|
|
2164
|
+
command: 'Settings.filterModified',
|
|
1995
2165
|
flags: None$1,
|
|
1996
2166
|
id: 'filter-modified',
|
|
1997
2167
|
label: modified()
|
|
1998
2168
|
}, {
|
|
1999
|
-
command: 'Settings.
|
|
2169
|
+
command: 'Settings.filterPreview',
|
|
2000
2170
|
flags: None$1,
|
|
2001
2171
|
id: 'filter-preview',
|
|
2002
2172
|
label: preview()
|
|
2003
2173
|
}, {
|
|
2004
|
-
command: 'Settings.
|
|
2174
|
+
command: 'Settings.filterSettingId',
|
|
2005
2175
|
flags: None$1,
|
|
2006
2176
|
id: 'filter-settingId',
|
|
2007
2177
|
label: settingId()
|
|
2008
2178
|
}, {
|
|
2009
|
-
command: 'Settings.
|
|
2179
|
+
command: 'Settings.filterStable',
|
|
2010
2180
|
flags: None$1,
|
|
2011
2181
|
id: 'filter-stable',
|
|
2012
2182
|
label: stable()
|
|
2013
2183
|
}, {
|
|
2014
|
-
command: 'Settings.
|
|
2184
|
+
command: 'Settings.filterTag',
|
|
2015
2185
|
flags: None$1,
|
|
2016
2186
|
id: 'filter-tag',
|
|
2017
2187
|
label: tag()
|
|
2018
2188
|
}];
|
|
2019
2189
|
};
|
|
2020
2190
|
|
|
2191
|
+
const getMenuEntries2 = (state, props) => {
|
|
2192
|
+
if (props.menuId === SettingsFilter) {
|
|
2193
|
+
return getMenuEntries();
|
|
2194
|
+
}
|
|
2195
|
+
const {
|
|
2196
|
+
modifiedSettings
|
|
2197
|
+
} = state;
|
|
2198
|
+
const modified = props.settingId in modifiedSettings;
|
|
2199
|
+
return [{
|
|
2200
|
+
args: [props.settingId],
|
|
2201
|
+
command: 'Settings.resetSetting',
|
|
2202
|
+
flags: modified ? None$1 : Disabled,
|
|
2203
|
+
id: 'resetSetting',
|
|
2204
|
+
label: resetSetting$1()
|
|
2205
|
+
}];
|
|
2206
|
+
};
|
|
2207
|
+
|
|
2021
2208
|
const getMenuIds = () => {
|
|
2022
|
-
return [SettingsFilter];
|
|
2209
|
+
return [SettingsFilter, Settings$1];
|
|
2023
2210
|
};
|
|
2024
2211
|
|
|
2025
2212
|
const getName = () => {
|
|
@@ -2132,11 +2319,29 @@ const show2 = async (uid, menuId, x, y, args) => {
|
|
|
2132
2319
|
await showContextMenu2(uid, menuId, x, y, args);
|
|
2133
2320
|
};
|
|
2134
2321
|
|
|
2135
|
-
const
|
|
2322
|
+
const filterButtonWidth = 20;
|
|
2323
|
+
const searchFieldHeight = 26;
|
|
2324
|
+
const settingsHeaderPaddingRight = 24;
|
|
2325
|
+
const settingsHeaderPaddingTop = 14;
|
|
2326
|
+
const getMenuPosition = (state, eventX, eventY) => {
|
|
2327
|
+
if (eventX !== 0 || eventY !== 0) {
|
|
2328
|
+
return [eventX, eventY];
|
|
2329
|
+
}
|
|
2330
|
+
const {
|
|
2331
|
+
width,
|
|
2332
|
+
x,
|
|
2333
|
+
y
|
|
2334
|
+
} = state;
|
|
2335
|
+
const menuX = x + width - settingsHeaderPaddingRight - filterButtonWidth / 2;
|
|
2336
|
+
const menuY = y + settingsHeaderPaddingTop + searchFieldHeight / 2;
|
|
2337
|
+
return [menuX, menuY];
|
|
2338
|
+
};
|
|
2339
|
+
const handleClickFilterButton = async (state, eventX, eventY) => {
|
|
2136
2340
|
const {
|
|
2137
2341
|
id
|
|
2138
2342
|
} = state;
|
|
2139
|
-
|
|
2343
|
+
const [menuX, menuY] = getMenuPosition(state, eventX, eventY);
|
|
2344
|
+
await show2(id, SettingsFilter, menuX, menuY, {
|
|
2140
2345
|
menuId: SettingsFilter
|
|
2141
2346
|
});
|
|
2142
2347
|
return state;
|
|
@@ -2203,111 +2408,19 @@ const handleClickTab = (state, name) => {
|
|
|
2203
2408
|
};
|
|
2204
2409
|
};
|
|
2205
2410
|
|
|
2206
|
-
const
|
|
2207
|
-
let newHistory = history;
|
|
2208
|
-
let newHistoryIndex = -1;
|
|
2209
|
-
if (!value || !value.trim()) {
|
|
2210
|
-
return {
|
|
2211
|
-
newHistory,
|
|
2212
|
-
newHistoryIndex
|
|
2213
|
-
};
|
|
2214
|
-
}
|
|
2215
|
-
const trimmedValue = value.trim();
|
|
2216
|
-
|
|
2217
|
-
// Check if this value is already in history
|
|
2218
|
-
const existingIndex = history.indexOf(trimmedValue);
|
|
2219
|
-
if (existingIndex !== -1) {
|
|
2220
|
-
newHistoryIndex = existingIndex;
|
|
2221
|
-
return {
|
|
2222
|
-
newHistory,
|
|
2223
|
-
newHistoryIndex
|
|
2224
|
-
};
|
|
2225
|
-
}
|
|
2226
|
-
|
|
2227
|
-
// Check if this value is a prefix of any existing history item
|
|
2228
|
-
// If it is, don't add it to history yet (it's still being typed)
|
|
2229
|
-
const isPrefixOfExisting = history.some(historyItem => historyItem.startsWith(trimmedValue) && historyItem !== trimmedValue);
|
|
2230
|
-
if (isPrefixOfExisting) {
|
|
2231
|
-
// Don't add to history, but find the closest match for index
|
|
2232
|
-
const closestMatch = history.find(historyItem => historyItem.startsWith(trimmedValue));
|
|
2233
|
-
if (closestMatch) {
|
|
2234
|
-
newHistoryIndex = history.indexOf(closestMatch);
|
|
2235
|
-
}
|
|
2236
|
-
return {
|
|
2237
|
-
newHistory,
|
|
2238
|
-
newHistoryIndex
|
|
2239
|
-
};
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
|
-
// Check if any existing history items are prefixes of this value
|
|
2243
|
-
// If so, remove all prefix items and add the complete value at the first prefix position
|
|
2244
|
-
const prefixItems = history.filter(historyItem => trimmedValue.startsWith(historyItem) && historyItem !== trimmedValue);
|
|
2245
|
-
if (prefixItems.length > 0) {
|
|
2246
|
-
// Find the position of the first prefix item
|
|
2247
|
-
const firstPrefixIndex = history.findIndex(historyItem => trimmedValue.startsWith(historyItem) && historyItem !== trimmedValue);
|
|
2248
|
-
|
|
2249
|
-
// Remove all prefix items and add the complete value at the first prefix position
|
|
2250
|
-
|
|
2251
|
-
// Insert the new value at the position where the first prefix was
|
|
2252
|
-
const beforePrefix = history.slice(0, firstPrefixIndex);
|
|
2253
|
-
const afterPrefix = history.slice(firstPrefixIndex).filter(historyItem => !trimmedValue.startsWith(historyItem) || historyItem === trimmedValue);
|
|
2254
|
-
newHistory = [...beforePrefix, trimmedValue, ...afterPrefix];
|
|
2255
|
-
newHistoryIndex = firstPrefixIndex;
|
|
2256
|
-
} else {
|
|
2257
|
-
// Add as new item
|
|
2258
|
-
newHistory = [...history, trimmedValue];
|
|
2259
|
-
newHistoryIndex = newHistory.length - 1;
|
|
2260
|
-
}
|
|
2261
|
-
return {
|
|
2262
|
-
newHistory,
|
|
2263
|
-
newHistoryIndex
|
|
2264
|
-
};
|
|
2265
|
-
};
|
|
2266
|
-
|
|
2267
|
-
const handleInput = (state, value, inputSource = User) => {
|
|
2268
|
-
const {
|
|
2269
|
-
height,
|
|
2270
|
-
history,
|
|
2271
|
-
itemHeight,
|
|
2272
|
-
items,
|
|
2273
|
-
modifiedSettings,
|
|
2274
|
-
preferences,
|
|
2275
|
-
tabs
|
|
2276
|
-
} = state;
|
|
2277
|
-
const filteredItems = getFilteredItems(items, tabs, value, modifiedSettings, preferences);
|
|
2278
|
-
// Reset scroll when filter value changes so the user sees results from the top
|
|
2279
|
-
const nextScrollOffset = 0;
|
|
2411
|
+
const handleContextMenu = async (state, settingId, x, y) => {
|
|
2280
2412
|
const {
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
visibleItems
|
|
2284
|
-
} = computeVisibleItems(filteredItems, height, nextScrollOffset, itemHeight);
|
|
2285
|
-
const {
|
|
2286
|
-
scrollBarMinHeight
|
|
2413
|
+
id,
|
|
2414
|
+
items
|
|
2287
2415
|
} = state;
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
return {
|
|
2297
|
-
...state,
|
|
2298
|
-
deltaY: 0,
|
|
2299
|
-
filteredItems,
|
|
2300
|
-
history: newHistory,
|
|
2301
|
-
historyIndex: newHistoryIndex,
|
|
2302
|
-
inputSource,
|
|
2303
|
-
maxLineY,
|
|
2304
|
-
minLineY,
|
|
2305
|
-
scrollBarThumbHeight: thumbHeight,
|
|
2306
|
-
scrollBarThumbTop: thumbTop,
|
|
2307
|
-
scrollOffset: nextScrollOffset,
|
|
2308
|
-
searchValue: value,
|
|
2309
|
-
visibleItems
|
|
2310
|
-
};
|
|
2416
|
+
if (items.every(item => item.id !== settingId)) {
|
|
2417
|
+
return state;
|
|
2418
|
+
}
|
|
2419
|
+
await show2(id, Settings$1, x, y, {
|
|
2420
|
+
menuId: Settings$1,
|
|
2421
|
+
settingId
|
|
2422
|
+
});
|
|
2423
|
+
return state;
|
|
2311
2424
|
};
|
|
2312
2425
|
|
|
2313
2426
|
const None = 0;
|
|
@@ -2428,6 +2541,7 @@ const handleSettingUpdate = (state, name, value, inputSource) => {
|
|
|
2428
2541
|
...state,
|
|
2429
2542
|
filteredItems: newFilteredItems,
|
|
2430
2543
|
inputSource,
|
|
2544
|
+
modifiedSettings: newModifiedSettings,
|
|
2431
2545
|
preferences: newPreferences
|
|
2432
2546
|
};
|
|
2433
2547
|
};
|
|
@@ -2672,8 +2786,7 @@ const loadContent = async (state, savedState) => {
|
|
|
2672
2786
|
} = restoreState(savedState);
|
|
2673
2787
|
const tabs = await getTabs();
|
|
2674
2788
|
const newTabs = getUpdatedTabs(tabs, tabId);
|
|
2675
|
-
const items = await getSettingItems();
|
|
2676
|
-
const preferences = await getPreferences();
|
|
2789
|
+
const [items, preferences] = await Promise.all([getSettingItems(), getPreferences()]);
|
|
2677
2790
|
const modifiedSettings = getModifiedSettings(preferences);
|
|
2678
2791
|
const filteredItems = getFilteredItems(items, newTabs, searchValue, modifiedSettings, preferences);
|
|
2679
2792
|
const {
|
|
@@ -2811,6 +2924,7 @@ const getSettingsInputBadgeDom = (filteredSettingsCount, hasSearchValue) => {
|
|
|
2811
2924
|
const HandleClickClear = 'handleClickClear';
|
|
2812
2925
|
const HandleClickFilterButton = 'handleClickFilterButton';
|
|
2813
2926
|
const HandleClickTab = 'handleClickTab';
|
|
2927
|
+
const HandleContextMenu = 'handleContextMenu';
|
|
2814
2928
|
const HandleInput = 'handleInput';
|
|
2815
2929
|
const HandleSettingInput = 'handleSettingInput';
|
|
2816
2930
|
const HandleSettingChecked = 'handleSettingChecked';
|
|
@@ -2998,6 +3112,7 @@ const getItemCheckBoxVirtualDom = item => {
|
|
|
2998
3112
|
childCount: 2 + errorChildCount,
|
|
2999
3113
|
className: SettingsItem,
|
|
3000
3114
|
'data-modified': modified,
|
|
3115
|
+
name: id,
|
|
3001
3116
|
role: Group,
|
|
3002
3117
|
type: Div
|
|
3003
3118
|
}, ...getItemHeadingDom(heading), checkBoxWrapperNode, {
|
|
@@ -3032,6 +3147,7 @@ const getItemColorVirtualDom = item => {
|
|
|
3032
3147
|
childCount: 3 + errorChildCount,
|
|
3033
3148
|
className: SettingsItem,
|
|
3034
3149
|
'data-modified': modified,
|
|
3150
|
+
name: id,
|
|
3035
3151
|
role: Group,
|
|
3036
3152
|
type: Div
|
|
3037
3153
|
}, ...getItemHeadingDom(heading), colorInputWrapperNode, {
|
|
@@ -3086,6 +3202,7 @@ const getItemNumberVirtualDom = item => {
|
|
|
3086
3202
|
childCount,
|
|
3087
3203
|
className: SettingsItem,
|
|
3088
3204
|
'data-modified': modified,
|
|
3205
|
+
name: id,
|
|
3089
3206
|
role: Group,
|
|
3090
3207
|
type: Div
|
|
3091
3208
|
}, ...getSettingsModifiedIndicatorDom(modified), ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
|
|
@@ -3127,6 +3244,7 @@ const getItemSelectVirtualDom = item => {
|
|
|
3127
3244
|
return [{
|
|
3128
3245
|
childCount: 3 + errorChildCount,
|
|
3129
3246
|
className: SettingsItem,
|
|
3247
|
+
name: id,
|
|
3130
3248
|
role: Group,
|
|
3131
3249
|
type: Div
|
|
3132
3250
|
}, ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
|
|
@@ -3153,6 +3271,7 @@ const getItemStringVirtualDom = item => {
|
|
|
3153
3271
|
return [{
|
|
3154
3272
|
childCount: 3 + errorChildCount,
|
|
3155
3273
|
className: SettingsItem,
|
|
3274
|
+
name: id,
|
|
3156
3275
|
role: Group,
|
|
3157
3276
|
type: Div
|
|
3158
3277
|
}, ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
|
|
@@ -3167,14 +3286,14 @@ const getItemStringVirtualDom = item => {
|
|
|
3167
3286
|
}, ...getErrorMessageDom(errorMessage)];
|
|
3168
3287
|
};
|
|
3169
3288
|
|
|
3170
|
-
const
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3289
|
+
const getItemUnknownVirtualDom = item => {
|
|
3290
|
+
return [{
|
|
3291
|
+
childCount: 1,
|
|
3292
|
+
className: SettingsItem,
|
|
3293
|
+
name: item.id,
|
|
3294
|
+
role: Group,
|
|
3295
|
+
type: Div
|
|
3296
|
+
}, text(unknownSettingType())];
|
|
3178
3297
|
};
|
|
3179
3298
|
|
|
3180
3299
|
const getItemUrlVirtualDom = item => {
|
|
@@ -3193,6 +3312,7 @@ const getItemUrlVirtualDom = item => {
|
|
|
3193
3312
|
childCount: 3 + errorChildCount,
|
|
3194
3313
|
className: SettingsItem,
|
|
3195
3314
|
'data-modified': modified,
|
|
3315
|
+
name: id,
|
|
3196
3316
|
role: Group,
|
|
3197
3317
|
type: Div
|
|
3198
3318
|
}, ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
|
|
@@ -3234,6 +3354,7 @@ const getItemVirtualDom = item => {
|
|
|
3234
3354
|
const settingsItemsNode = {
|
|
3235
3355
|
childCount: 1,
|
|
3236
3356
|
className: SettingsItems,
|
|
3357
|
+
onContextMenu: HandleContextMenu,
|
|
3237
3358
|
type: Div
|
|
3238
3359
|
};
|
|
3239
3360
|
const noResultsNode = {
|
|
@@ -3252,6 +3373,7 @@ const getSettingsItemsDom = (items, searchValue) => {
|
|
|
3252
3373
|
return [{
|
|
3253
3374
|
childCount: items.length,
|
|
3254
3375
|
className: SettingsItems,
|
|
3376
|
+
onContextMenu: HandleContextMenu,
|
|
3255
3377
|
type: Div
|
|
3256
3378
|
}, ...items.flatMap(getItemVirtualDom)];
|
|
3257
3379
|
};
|
|
@@ -3353,7 +3475,7 @@ const renderSettingValues = (oldState, newState) => {
|
|
|
3353
3475
|
} = newState;
|
|
3354
3476
|
const enabledSettings = filteredItems.filter(item => enabledTypes.includes(item.type));
|
|
3355
3477
|
const inputValues = enabledSettings.map(item => {
|
|
3356
|
-
const value = preferences[item.id]
|
|
3478
|
+
const value = preferences[item.id] ?? item.value;
|
|
3357
3479
|
return {
|
|
3358
3480
|
name: item.id,
|
|
3359
3481
|
value
|
|
@@ -3432,6 +3554,10 @@ const renderEventListeners = () => {
|
|
|
3432
3554
|
}, {
|
|
3433
3555
|
name: HandleClickFilterButton,
|
|
3434
3556
|
params: ['handleClickFilterButton', ClientX, ClientY]
|
|
3557
|
+
}, {
|
|
3558
|
+
name: HandleContextMenu,
|
|
3559
|
+
params: ['handleContextMenu', TargetName, ClientX, ClientY],
|
|
3560
|
+
preventDefault: true
|
|
3435
3561
|
}, {
|
|
3436
3562
|
name: HandleSettingInput,
|
|
3437
3563
|
params: ['handleSettingInput', TargetName, TargetValue]
|
|
@@ -3467,6 +3593,30 @@ const renderEventListeners = () => {
|
|
|
3467
3593
|
}];
|
|
3468
3594
|
};
|
|
3469
3595
|
|
|
3596
|
+
const resetSetting = (state, settingId) => {
|
|
3597
|
+
const {
|
|
3598
|
+
filteredItems,
|
|
3599
|
+
items,
|
|
3600
|
+
modifiedSettings,
|
|
3601
|
+
preferences,
|
|
3602
|
+
searchValue,
|
|
3603
|
+
tabs
|
|
3604
|
+
} = state;
|
|
3605
|
+
if (!(settingId in modifiedSettings)) {
|
|
3606
|
+
return state;
|
|
3607
|
+
}
|
|
3608
|
+
const newModifiedSettings = Object.fromEntries(Object.entries(modifiedSettings).filter(([key]) => key !== settingId));
|
|
3609
|
+
const newPreferences = Object.fromEntries(Object.entries(preferences).filter(([key]) => key !== settingId));
|
|
3610
|
+
const newFilteredItems = getNewFilteredItems(modifiedSettings, newModifiedSettings, items, tabs, searchValue, filteredItems, preferences, newPreferences);
|
|
3611
|
+
return {
|
|
3612
|
+
...state,
|
|
3613
|
+
filteredItems: newFilteredItems,
|
|
3614
|
+
inputSource: Script,
|
|
3615
|
+
modifiedSettings: newModifiedSettings,
|
|
3616
|
+
preferences: newPreferences
|
|
3617
|
+
};
|
|
3618
|
+
};
|
|
3619
|
+
|
|
3470
3620
|
const saveState = state => {
|
|
3471
3621
|
const {
|
|
3472
3622
|
focus,
|
|
@@ -3547,13 +3697,24 @@ const commandMap = {
|
|
|
3547
3697
|
'Settings.clearHistory': wrapCommand(clearHistory),
|
|
3548
3698
|
'Settings.create': create$1,
|
|
3549
3699
|
'Settings.diff2': diff2,
|
|
3700
|
+
'Settings.filterAdvanced': wrapCommand(filterAdvanced),
|
|
3701
|
+
'Settings.filterExperimental': wrapCommand(filterExperimental),
|
|
3702
|
+
'Settings.filterExtensionId': wrapCommand(filterExtensionId),
|
|
3703
|
+
'Settings.filterFeature': wrapCommand(filterFeature),
|
|
3704
|
+
'Settings.filterLanguage': wrapCommand(filterLanguage),
|
|
3705
|
+
'Settings.filterModified': wrapCommand(filterModified),
|
|
3706
|
+
'Settings.filterPreview': wrapCommand(filterPreview),
|
|
3707
|
+
'Settings.filterSettingId': wrapCommand(filterSettingId),
|
|
3708
|
+
'Settings.filterStable': wrapCommand(filterStable),
|
|
3709
|
+
'Settings.filterTag': wrapCommand(filterTag),
|
|
3550
3710
|
'Settings.getCommandIds': getCommandIds,
|
|
3551
3711
|
'Settings.getKeyBindings': getKeyBindings,
|
|
3552
|
-
'Settings.getMenuEntries':
|
|
3712
|
+
'Settings.getMenuEntries': wrapGetter(getMenuEntries2),
|
|
3553
3713
|
'Settings.getMenuIds': getMenuIds,
|
|
3554
3714
|
'Settings.getName': getName,
|
|
3555
3715
|
'Settings.handleClickFilterButton': wrapCommand(handleClickFilterButton),
|
|
3556
3716
|
'Settings.handleClickTab': wrapCommand(handleClickTab),
|
|
3717
|
+
'Settings.handleContextMenu': wrapCommand(handleContextMenu),
|
|
3557
3718
|
'Settings.handleInput': wrapCommand(handleInput),
|
|
3558
3719
|
'Settings.handleInputBlur': wrapCommand(handleInputBlur),
|
|
3559
3720
|
'Settings.handleInputFocus': wrapCommand(handleInputFocus),
|
|
@@ -3570,6 +3731,7 @@ const commandMap = {
|
|
|
3570
3731
|
'Settings.render2': render2,
|
|
3571
3732
|
'Settings.renderActions': renderActions,
|
|
3572
3733
|
'Settings.renderEventListeners': renderEventListeners,
|
|
3734
|
+
'Settings.resetSetting': wrapCommand(resetSetting),
|
|
3573
3735
|
'Settings.restoreState': restoreState,
|
|
3574
3736
|
'Settings.saveState': wrapGetter(saveState),
|
|
3575
3737
|
'Settings.terminate': terminate,
|