@lvce-editor/settings-view 1.13.0 → 1.15.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/README.md +13 -0
- package/dist/settingsViewWorkerMain.js +283 -54
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
# Settings View
|
|
2
2
|
|
|
3
3
|
WebWorker for the Settings View functionality in Lvce Editor.
|
|
4
|
+
|
|
5
|
+
## Contributing
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
git clone git@github.com:lvce-editor/settings-view.git &&
|
|
9
|
+
cd settings-view &&
|
|
10
|
+
npm ci &&
|
|
11
|
+
npm test
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Gitpod
|
|
15
|
+
|
|
16
|
+
[](https://gitpod.io/#https://github.com/lvce-editor/settings-view)
|
|
@@ -946,6 +946,8 @@ const getFilteredItems = (items, tabs, searchValue = '', preferences = {}) => {
|
|
|
946
946
|
const User = 1;
|
|
947
947
|
const Script = 2;
|
|
948
948
|
|
|
949
|
+
const FocusSettingsInput = 2199;
|
|
950
|
+
|
|
949
951
|
const clear$1 = state => {
|
|
950
952
|
const {
|
|
951
953
|
items,
|
|
@@ -956,9 +958,19 @@ const clear$1 = state => {
|
|
|
956
958
|
const filteredItems = getFilteredItems(items, tabs, newSearchValue, preferences);
|
|
957
959
|
return {
|
|
958
960
|
...state,
|
|
959
|
-
|
|
961
|
+
filteredItems,
|
|
962
|
+
focus: FocusSettingsInput,
|
|
963
|
+
focusSource: Script,
|
|
960
964
|
inputSource: Script,
|
|
961
|
-
|
|
965
|
+
searchValue: newSearchValue
|
|
966
|
+
};
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
const clearHistory = state => {
|
|
970
|
+
return {
|
|
971
|
+
...state,
|
|
972
|
+
history: [],
|
|
973
|
+
historyIndex: -1
|
|
962
974
|
};
|
|
963
975
|
};
|
|
964
976
|
|
|
@@ -991,19 +1003,25 @@ const create$1 = (id, uri, x, y, width, height) => {
|
|
|
991
1003
|
scrollOffset: 0,
|
|
992
1004
|
filteredItemsCount: 0,
|
|
993
1005
|
history: [],
|
|
994
|
-
|
|
1006
|
+
historyIndex: -1,
|
|
1007
|
+
modifiedSettings: {},
|
|
1008
|
+
focusSource: 0
|
|
995
1009
|
};
|
|
996
1010
|
set$1(id, state, state);
|
|
997
1011
|
};
|
|
998
1012
|
|
|
999
|
-
const isEqual$
|
|
1013
|
+
const isEqual$4 = (oldState, newState) => {
|
|
1000
1014
|
return oldState.focus === newState.focus;
|
|
1001
1015
|
};
|
|
1002
1016
|
|
|
1003
|
-
const isEqual$
|
|
1017
|
+
const isEqual$3 = (oldState, newState) => {
|
|
1004
1018
|
return oldState.filteredItems === newState.filteredItems;
|
|
1005
1019
|
};
|
|
1006
1020
|
|
|
1021
|
+
const isEqual$2 = (oldState, newState) => {
|
|
1022
|
+
return newState.inputSource === User || oldState.scrollOffset === newState.scrollOffset;
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1007
1025
|
const isEqual$1 = (oldState, newState) => {
|
|
1008
1026
|
return oldState.filteredItems === newState.filteredItems;
|
|
1009
1027
|
};
|
|
@@ -1012,13 +1030,15 @@ const RenderItems = 1;
|
|
|
1012
1030
|
const RenderFocus = 2;
|
|
1013
1031
|
const RenderValue = 3;
|
|
1014
1032
|
const RenderSettingValues = 10;
|
|
1033
|
+
const RenderScrollOffset = 11;
|
|
1034
|
+
const RenderFocusContext = 12;
|
|
1015
1035
|
|
|
1016
1036
|
const isEqual = (oldState, newState) => {
|
|
1017
1037
|
return newState.inputSource === User || oldState.searchValue === newState.searchValue;
|
|
1018
1038
|
};
|
|
1019
1039
|
|
|
1020
|
-
const modules = [isEqual$
|
|
1021
|
-
const numbers = [RenderFocus, RenderItems, RenderValue, RenderSettingValues];
|
|
1040
|
+
const modules = [isEqual$4, isEqual$3, isEqual, isEqual$1, isEqual$2];
|
|
1041
|
+
const numbers = [RenderFocus, RenderItems, RenderValue, RenderSettingValues, RenderScrollOffset];
|
|
1022
1042
|
|
|
1023
1043
|
const diff = (oldState, newState) => {
|
|
1024
1044
|
const diffResult = [];
|
|
@@ -1040,6 +1060,15 @@ const diff2 = uid => {
|
|
|
1040
1060
|
return diffResult;
|
|
1041
1061
|
};
|
|
1042
1062
|
|
|
1063
|
+
const getKeyBindings = () => {
|
|
1064
|
+
return [];
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
const getName = () => {
|
|
1068
|
+
// TODO i18n string
|
|
1069
|
+
return 'Settings';
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1043
1072
|
const getSelectedTabId = tabs => {
|
|
1044
1073
|
for (const tab of tabs) {
|
|
1045
1074
|
if (tab.selected) {
|
|
@@ -1080,69 +1109,111 @@ const handleClickTab = (state, name) => {
|
|
|
1080
1109
|
};
|
|
1081
1110
|
};
|
|
1082
1111
|
|
|
1112
|
+
const addToHistory = (history, value) => {
|
|
1113
|
+
let newHistory = history;
|
|
1114
|
+
let newHistoryIndex = -1;
|
|
1115
|
+
if (value && value.trim() && !history.includes(value)) {
|
|
1116
|
+
newHistory = [...history, value];
|
|
1117
|
+
newHistoryIndex = newHistory.length - 1;
|
|
1118
|
+
} else if (value && value.trim()) {
|
|
1119
|
+
// If value already exists in history, find its index
|
|
1120
|
+
newHistoryIndex = history.indexOf(value);
|
|
1121
|
+
}
|
|
1122
|
+
return {
|
|
1123
|
+
newHistory,
|
|
1124
|
+
newHistoryIndex
|
|
1125
|
+
};
|
|
1126
|
+
};
|
|
1127
|
+
|
|
1083
1128
|
const handleInput = (state, value, inputSource = User) => {
|
|
1084
1129
|
const {
|
|
1085
1130
|
items,
|
|
1086
1131
|
tabs,
|
|
1087
|
-
preferences
|
|
1132
|
+
preferences,
|
|
1133
|
+
history
|
|
1088
1134
|
} = state;
|
|
1089
1135
|
const filteredItems = getFilteredItems(items, tabs, value, preferences);
|
|
1136
|
+
const {
|
|
1137
|
+
newHistory,
|
|
1138
|
+
newHistoryIndex
|
|
1139
|
+
} = addToHistory(history, value);
|
|
1090
1140
|
return {
|
|
1091
1141
|
...state,
|
|
1092
1142
|
searchValue: value,
|
|
1093
1143
|
filteredItems,
|
|
1144
|
+
history: newHistory,
|
|
1145
|
+
historyIndex: newHistoryIndex,
|
|
1094
1146
|
inputSource
|
|
1095
1147
|
};
|
|
1096
1148
|
};
|
|
1097
1149
|
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
} = state;
|
|
1105
|
-
const newModifiedSettings = {
|
|
1106
|
-
...modifiedSettings,
|
|
1107
|
-
[name]: true
|
|
1150
|
+
const SearchInput = 1;
|
|
1151
|
+
|
|
1152
|
+
const handleInputFocus = state => {
|
|
1153
|
+
return {
|
|
1154
|
+
...state,
|
|
1155
|
+
focus: SearchInput
|
|
1108
1156
|
};
|
|
1109
|
-
|
|
1157
|
+
};
|
|
1110
1158
|
|
|
1111
|
-
|
|
1159
|
+
const handleScroll = (state, scrollTop, inputSource = User) => {
|
|
1112
1160
|
return {
|
|
1113
1161
|
...state,
|
|
1114
|
-
|
|
1115
|
-
|
|
1162
|
+
scrollOffset: scrollTop,
|
|
1163
|
+
inputSource
|
|
1116
1164
|
};
|
|
1117
1165
|
};
|
|
1118
1166
|
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1167
|
+
const getNewFilteredItems = (oldModifiedSetings, newModifiedSettings, items, tabs, searchValue, oldFilteredItems) => {
|
|
1168
|
+
if (oldModifiedSetings === newModifiedSettings) {
|
|
1169
|
+
return oldFilteredItems;
|
|
1170
|
+
}
|
|
1171
|
+
return getFilteredItems(items, tabs, searchValue, newModifiedSettings);
|
|
1172
|
+
};
|
|
1173
|
+
|
|
1174
|
+
const getNewModifiedSettings = (modifiedSettings, name) => {
|
|
1175
|
+
if (name in modifiedSettings) {
|
|
1176
|
+
return modifiedSettings;
|
|
1177
|
+
}
|
|
1178
|
+
return {
|
|
1179
|
+
...modifiedSettings,
|
|
1180
|
+
[name]: true
|
|
1181
|
+
};
|
|
1182
|
+
};
|
|
1183
|
+
|
|
1184
|
+
const handleSettingUpdate = (state, name, value, inputSource) => {
|
|
1121
1185
|
const {
|
|
1122
1186
|
modifiedSettings,
|
|
1123
1187
|
items,
|
|
1124
1188
|
tabs,
|
|
1125
|
-
searchValue
|
|
1189
|
+
searchValue,
|
|
1190
|
+
preferences,
|
|
1191
|
+
filteredItems
|
|
1126
1192
|
} = state;
|
|
1127
|
-
const newModifiedSettings =
|
|
1128
|
-
|
|
1129
|
-
|
|
1193
|
+
const newModifiedSettings = getNewModifiedSettings(modifiedSettings, name);
|
|
1194
|
+
const newPreferences = {
|
|
1195
|
+
...preferences,
|
|
1196
|
+
[name]: value
|
|
1130
1197
|
};
|
|
1131
|
-
|
|
1132
|
-
// TODO don't need to update items if it was already modified
|
|
1133
|
-
const filteredItems = getFilteredItems(items, tabs, searchValue, newModifiedSettings);
|
|
1198
|
+
const newFilteredItems = getNewFilteredItems(modifiedSettings, newModifiedSettings, items, tabs, searchValue, filteredItems);
|
|
1134
1199
|
return {
|
|
1135
1200
|
...state,
|
|
1136
1201
|
inputSource,
|
|
1137
|
-
filteredItems
|
|
1202
|
+
filteredItems: newFilteredItems,
|
|
1203
|
+
preferences: newPreferences
|
|
1138
1204
|
};
|
|
1139
1205
|
};
|
|
1140
1206
|
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1207
|
+
const handleSettingChecked = (state, name, value, source = User) => {
|
|
1208
|
+
return handleSettingUpdate(state, name, value, source);
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1211
|
+
const handleSettingInput = (state, name, value, inputSource = User) => {
|
|
1212
|
+
return handleSettingUpdate(state, name, value, inputSource);
|
|
1213
|
+
};
|
|
1214
|
+
|
|
1215
|
+
const handleSettingSelect = (state, name, value, source = User) => {
|
|
1216
|
+
return handleSettingUpdate(state, name, value, source);
|
|
1146
1217
|
};
|
|
1147
1218
|
|
|
1148
1219
|
const initialize = async () => {
|
|
@@ -1167,6 +1238,7 @@ const Enum = 1;
|
|
|
1167
1238
|
const String = 2;
|
|
1168
1239
|
const Boolean$1 = 3;
|
|
1169
1240
|
const Number$1 = 5;
|
|
1241
|
+
const Color = 6;
|
|
1170
1242
|
|
|
1171
1243
|
const emptyObject = {};
|
|
1172
1244
|
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
@@ -1231,6 +1303,7 @@ const CursorBlinking = 'Cursor Blinking';
|
|
|
1231
1303
|
const CursorBlinkingDescription = 'Controls how the cursor should blink';
|
|
1232
1304
|
const CursorStyle = 'Cursor Style';
|
|
1233
1305
|
const CursorStyleDescription = 'Controls the cursor style';
|
|
1306
|
+
const ColorValue = 'Color value';
|
|
1234
1307
|
const CursorWidth = 'Cursor Width';
|
|
1235
1308
|
const CursorWidthDescription = 'Controls the width of the cursor';
|
|
1236
1309
|
const TabSize = 'Tab Size';
|
|
@@ -1503,6 +1576,9 @@ const formatOnSaveDescription = () => {
|
|
|
1503
1576
|
const numberValue = () => {
|
|
1504
1577
|
return i18nString(NumberValue);
|
|
1505
1578
|
};
|
|
1579
|
+
const colorValue = () => {
|
|
1580
|
+
return i18nString(ColorValue);
|
|
1581
|
+
};
|
|
1506
1582
|
const stringValue = () => {
|
|
1507
1583
|
return i18nString(StringValue);
|
|
1508
1584
|
};
|
|
@@ -3018,6 +3094,13 @@ const getSettingItems = async () => {
|
|
|
3018
3094
|
type: Boolean$1,
|
|
3019
3095
|
value: 'true',
|
|
3020
3096
|
category: TextEditorTab
|
|
3097
|
+
}, {
|
|
3098
|
+
id: 'Editor.background',
|
|
3099
|
+
heading: 'Editor background',
|
|
3100
|
+
description: 'Editor background color',
|
|
3101
|
+
type: Color,
|
|
3102
|
+
value: '#567567',
|
|
3103
|
+
category: TextEditorTab
|
|
3021
3104
|
}, {
|
|
3022
3105
|
id: 'showUnused',
|
|
3023
3106
|
heading: showUnused(),
|
|
@@ -3231,6 +3314,12 @@ const getSavedTabId = savedState => {
|
|
|
3231
3314
|
}
|
|
3232
3315
|
return '';
|
|
3233
3316
|
};
|
|
3317
|
+
const getSavedScrollOffset = savedState => {
|
|
3318
|
+
if (savedState && typeof savedState === 'object' && 'scrollOffset' in savedState && typeof savedState.scrollOffset === 'number') {
|
|
3319
|
+
return savedState.scrollOffset;
|
|
3320
|
+
}
|
|
3321
|
+
return 0;
|
|
3322
|
+
};
|
|
3234
3323
|
const restoreState = savedState => {
|
|
3235
3324
|
if (!savedState) {
|
|
3236
3325
|
return {
|
|
@@ -3238,7 +3327,8 @@ const restoreState = savedState => {
|
|
|
3238
3327
|
minLineY: 0,
|
|
3239
3328
|
deltaY: 0,
|
|
3240
3329
|
tabId: '',
|
|
3241
|
-
searchValue: ''
|
|
3330
|
+
searchValue: '',
|
|
3331
|
+
scrollOffset: 0
|
|
3242
3332
|
};
|
|
3243
3333
|
}
|
|
3244
3334
|
const root = getSavedWorkspacePath(savedState);
|
|
@@ -3246,12 +3336,14 @@ const restoreState = savedState => {
|
|
|
3246
3336
|
const deltaY = getSavedDeltaY(savedState);
|
|
3247
3337
|
const tabId = getSavedTabId(savedState);
|
|
3248
3338
|
const searchValue = getSavedSearchValue(savedState);
|
|
3339
|
+
const scrollOffset = getSavedScrollOffset(savedState);
|
|
3249
3340
|
return {
|
|
3250
3341
|
root,
|
|
3251
3342
|
minLineY,
|
|
3252
3343
|
deltaY,
|
|
3253
3344
|
tabId,
|
|
3254
|
-
searchValue
|
|
3345
|
+
searchValue,
|
|
3346
|
+
scrollOffset
|
|
3255
3347
|
};
|
|
3256
3348
|
};
|
|
3257
3349
|
|
|
@@ -3265,7 +3357,8 @@ const getModifiedSettings = preferences => {
|
|
|
3265
3357
|
const loadContent = async (state, savedState) => {
|
|
3266
3358
|
const {
|
|
3267
3359
|
searchValue,
|
|
3268
|
-
tabId
|
|
3360
|
+
tabId,
|
|
3361
|
+
scrollOffset
|
|
3269
3362
|
} = restoreState(savedState);
|
|
3270
3363
|
const tabs = getTabs();
|
|
3271
3364
|
const newTabs = getUpdatedTabs(tabs, tabId);
|
|
@@ -3280,11 +3373,25 @@ const loadContent = async (state, savedState) => {
|
|
|
3280
3373
|
items,
|
|
3281
3374
|
modifiedSettings,
|
|
3282
3375
|
preferences,
|
|
3376
|
+
scrollOffset,
|
|
3283
3377
|
searchValue,
|
|
3284
3378
|
tabs: newTabs
|
|
3285
3379
|
};
|
|
3286
3380
|
};
|
|
3287
3381
|
|
|
3382
|
+
const renderFocus = (oldState, newState) => {
|
|
3383
|
+
const {
|
|
3384
|
+
id
|
|
3385
|
+
} = newState;
|
|
3386
|
+
const selector = `[name="${SettingsSearch}"]`;
|
|
3387
|
+
return ['Viewlet.focusSelector', id, selector];
|
|
3388
|
+
};
|
|
3389
|
+
|
|
3390
|
+
const renderFocusContext = (oldState, newState) => {
|
|
3391
|
+
const focusKey = FocusSettingsInput;
|
|
3392
|
+
return ['Viewlet.setFocusContext', focusKey];
|
|
3393
|
+
};
|
|
3394
|
+
|
|
3288
3395
|
const Tab$1 = 'tab';
|
|
3289
3396
|
const TabList = 'tablist';
|
|
3290
3397
|
const AriaRoles = {
|
|
@@ -3378,7 +3485,9 @@ const HandleClickTab = 'handleClickTab';
|
|
|
3378
3485
|
const HandleInput = 'handleInput';
|
|
3379
3486
|
const HandleSettingInput = 'handleSettingInput';
|
|
3380
3487
|
const HandleSettingChecked = 'handleSettingChecked';
|
|
3488
|
+
const HandleScroll = 'handleScroll';
|
|
3381
3489
|
const HandleSettingSelect = 'handleSettingSelect';
|
|
3490
|
+
const HandleInputFocus = 'handleInputFocus';
|
|
3382
3491
|
|
|
3383
3492
|
const getButtonClassName = hasSearchValue => {
|
|
3384
3493
|
if (hasSearchValue) {
|
|
@@ -3410,7 +3519,8 @@ const getSettingsInputDom = () => {
|
|
|
3410
3519
|
placeholder,
|
|
3411
3520
|
childCount: 0,
|
|
3412
3521
|
name: SettingsSearch,
|
|
3413
|
-
onInput: HandleInput
|
|
3522
|
+
onInput: HandleInput,
|
|
3523
|
+
onFocus: HandleInputFocus
|
|
3414
3524
|
}];
|
|
3415
3525
|
};
|
|
3416
3526
|
|
|
@@ -3449,7 +3559,7 @@ const getItemCheckBoxVirtualDom = item => {
|
|
|
3449
3559
|
className: SettingsItem,
|
|
3450
3560
|
childCount: 3,
|
|
3451
3561
|
role: 'group',
|
|
3452
|
-
|
|
3562
|
+
'data-modified': isModified
|
|
3453
3563
|
}, {
|
|
3454
3564
|
type: VirtualDomElements.H3,
|
|
3455
3565
|
childCount: 1
|
|
@@ -3488,18 +3598,52 @@ const getItemLabelDom = (domId, label) => {
|
|
|
3488
3598
|
}, text(label)];
|
|
3489
3599
|
};
|
|
3490
3600
|
|
|
3601
|
+
const getItemColorVirtualDom = item => {
|
|
3602
|
+
const {
|
|
3603
|
+
heading,
|
|
3604
|
+
description,
|
|
3605
|
+
id,
|
|
3606
|
+
modified
|
|
3607
|
+
} = item;
|
|
3608
|
+
const domId = getInputId(id);
|
|
3609
|
+
const isModified = modified || false;
|
|
3610
|
+
return [{
|
|
3611
|
+
type: VirtualDomElements.Div,
|
|
3612
|
+
className: SettingsItem,
|
|
3613
|
+
childCount: 3,
|
|
3614
|
+
role: 'group',
|
|
3615
|
+
'data-modified': isModified
|
|
3616
|
+
}, ...getItemHeadingDom(heading), {
|
|
3617
|
+
type: VirtualDomElements.Div,
|
|
3618
|
+
className: SettingsItemCheckBox,
|
|
3619
|
+
childCount: 2
|
|
3620
|
+
}, {
|
|
3621
|
+
type: VirtualDomElements.Input,
|
|
3622
|
+
className: mergeClassNames('ColorInput'),
|
|
3623
|
+
inputType: 'color',
|
|
3624
|
+
placeholder: colorValue(),
|
|
3625
|
+
childCount: 0,
|
|
3626
|
+
id: domId,
|
|
3627
|
+
name: id,
|
|
3628
|
+
onInput: HandleSettingInput
|
|
3629
|
+
}, ...getItemLabelDom(domId, description)];
|
|
3630
|
+
};
|
|
3631
|
+
|
|
3491
3632
|
const getItemNumberVirtualDom = item => {
|
|
3492
3633
|
const {
|
|
3493
3634
|
heading,
|
|
3494
3635
|
description,
|
|
3495
|
-
id
|
|
3636
|
+
id,
|
|
3637
|
+
modified
|
|
3496
3638
|
} = item;
|
|
3497
3639
|
const domId = getInputId(id);
|
|
3640
|
+
const isModified = modified || false;
|
|
3498
3641
|
return [{
|
|
3499
3642
|
type: VirtualDomElements.Div,
|
|
3500
3643
|
className: SettingsItem,
|
|
3501
3644
|
childCount: 3,
|
|
3502
|
-
role: 'group'
|
|
3645
|
+
role: 'group',
|
|
3646
|
+
'data-modified': isModified
|
|
3503
3647
|
}, ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
|
|
3504
3648
|
type: VirtualDomElements.Input,
|
|
3505
3649
|
className: InputBox,
|
|
@@ -3541,6 +3685,7 @@ const getItemSelectVirtualDom = item => {
|
|
|
3541
3685
|
type: VirtualDomElements.Select,
|
|
3542
3686
|
className: Select,
|
|
3543
3687
|
childCount: options.length,
|
|
3688
|
+
id: domId,
|
|
3544
3689
|
name: id,
|
|
3545
3690
|
onChange: HandleSettingSelect
|
|
3546
3691
|
}, ...options.flatMap(getOptionDom)];
|
|
@@ -3596,6 +3741,9 @@ const getItemVirtualDom = item => {
|
|
|
3596
3741
|
if (item.type === Enum) {
|
|
3597
3742
|
return getItemSelectVirtualDom(item);
|
|
3598
3743
|
}
|
|
3744
|
+
if (item.type === Color) {
|
|
3745
|
+
return getItemColorVirtualDom(item);
|
|
3746
|
+
}
|
|
3599
3747
|
return getItemUnknownVirtualDom();
|
|
3600
3748
|
};
|
|
3601
3749
|
|
|
@@ -3628,7 +3776,8 @@ const getSettingsContentDom = (items, tabs, searchValue) => {
|
|
|
3628
3776
|
return [{
|
|
3629
3777
|
type: VirtualDomElements.Div,
|
|
3630
3778
|
className: SettingsContent,
|
|
3631
|
-
childCount: 2
|
|
3779
|
+
childCount: 2,
|
|
3780
|
+
onScroll: HandleScroll
|
|
3632
3781
|
}, {
|
|
3633
3782
|
type: VirtualDomElements.H1,
|
|
3634
3783
|
className: SettingsContentHeading,
|
|
@@ -3699,12 +3848,22 @@ const renderItems = (oldState, newState) => {
|
|
|
3699
3848
|
return ['Viewlet.setDom2', newState.id, dom];
|
|
3700
3849
|
};
|
|
3701
3850
|
|
|
3851
|
+
const renderScrollOffset = (oldState, newState) => {
|
|
3852
|
+
const {
|
|
3853
|
+
id,
|
|
3854
|
+
scrollOffset
|
|
3855
|
+
} = newState;
|
|
3856
|
+
const selector = '.SettingsContent';
|
|
3857
|
+
const property = 'scrollTop';
|
|
3858
|
+
return ['Viewlet.setProperty', id, selector, property, scrollOffset];
|
|
3859
|
+
};
|
|
3860
|
+
|
|
3861
|
+
const enabledTypes = [Number$1, String, Color];
|
|
3702
3862
|
const renderSettingValues = (oldState, newState) => {
|
|
3703
3863
|
const {
|
|
3704
3864
|
filteredItems,
|
|
3705
3865
|
id
|
|
3706
3866
|
} = newState;
|
|
3707
|
-
const enabledTypes = [Number$1, String];
|
|
3708
3867
|
const numericSettings = filteredItems.filter(item => enabledTypes.includes(item.type));
|
|
3709
3868
|
const inputValues = numericSettings.map(item => ({
|
|
3710
3869
|
name: item.id,
|
|
@@ -3729,6 +3888,12 @@ const getRenderer = diffType => {
|
|
|
3729
3888
|
return renderValue;
|
|
3730
3889
|
case RenderSettingValues:
|
|
3731
3890
|
return renderSettingValues;
|
|
3891
|
+
case RenderScrollOffset:
|
|
3892
|
+
return renderScrollOffset;
|
|
3893
|
+
case RenderFocusContext:
|
|
3894
|
+
return renderFocusContext;
|
|
3895
|
+
case RenderFocus:
|
|
3896
|
+
return renderFocus;
|
|
3732
3897
|
default:
|
|
3733
3898
|
throw new Error('unknown renderer');
|
|
3734
3899
|
}
|
|
@@ -3773,16 +3938,25 @@ const renderEventListeners = () => {
|
|
|
3773
3938
|
}, {
|
|
3774
3939
|
name: HandleSettingChecked,
|
|
3775
3940
|
params: ['handleSettingChecked', 'event.target.name', 'event.target.value']
|
|
3941
|
+
}, {
|
|
3942
|
+
name: HandleScroll,
|
|
3943
|
+
params: ['handleScroll', 'event.target.scrollTop'],
|
|
3944
|
+
passive: true
|
|
3776
3945
|
}, {
|
|
3777
3946
|
name: HandleSettingSelect,
|
|
3778
3947
|
params: ['handleSettingSelect', 'event.target.name', 'event.target.value']
|
|
3948
|
+
}, {
|
|
3949
|
+
name: HandleInputFocus,
|
|
3950
|
+
params: ['handleInputFocus']
|
|
3779
3951
|
}];
|
|
3780
3952
|
};
|
|
3781
3953
|
|
|
3782
3954
|
const saveState = state => {
|
|
3783
3955
|
const {
|
|
3784
3956
|
tabs,
|
|
3785
|
-
searchValue
|
|
3957
|
+
searchValue,
|
|
3958
|
+
scrollOffset,
|
|
3959
|
+
focus
|
|
3786
3960
|
} = state;
|
|
3787
3961
|
const selectedTab = getSelectedTabId(tabs);
|
|
3788
3962
|
return {
|
|
@@ -3792,15 +3966,73 @@ const saveState = state => {
|
|
|
3792
3966
|
maxLineY: 0,
|
|
3793
3967
|
deltaY: 0,
|
|
3794
3968
|
searchValue,
|
|
3795
|
-
selectedTab
|
|
3969
|
+
selectedTab,
|
|
3970
|
+
scrollOffset,
|
|
3971
|
+
focus
|
|
3972
|
+
};
|
|
3973
|
+
};
|
|
3974
|
+
|
|
3975
|
+
const useNextSearchValue = state => {
|
|
3976
|
+
const {
|
|
3977
|
+
history,
|
|
3978
|
+
historyIndex,
|
|
3979
|
+
items,
|
|
3980
|
+
tabs,
|
|
3981
|
+
preferences
|
|
3982
|
+
} = state;
|
|
3983
|
+
if (history.length === 0 || historyIndex >= history.length - 1) {
|
|
3984
|
+
return state;
|
|
3985
|
+
}
|
|
3986
|
+
const newHistoryIndex = historyIndex + 1;
|
|
3987
|
+
const newSearchValue = history[newHistoryIndex];
|
|
3988
|
+
const filteredItems = getFilteredItems(items, tabs, newSearchValue, preferences);
|
|
3989
|
+
return {
|
|
3990
|
+
...state,
|
|
3991
|
+
searchValue: newSearchValue,
|
|
3992
|
+
historyIndex: newHistoryIndex,
|
|
3993
|
+
filteredItems,
|
|
3994
|
+
inputSource: Script
|
|
3995
|
+
};
|
|
3996
|
+
};
|
|
3997
|
+
|
|
3998
|
+
const usePreviousSearchValue = state => {
|
|
3999
|
+
const {
|
|
4000
|
+
history,
|
|
4001
|
+
historyIndex,
|
|
4002
|
+
items,
|
|
4003
|
+
tabs,
|
|
4004
|
+
preferences
|
|
4005
|
+
} = state;
|
|
4006
|
+
if (history.length === 0 || historyIndex <= 0) {
|
|
4007
|
+
return state;
|
|
4008
|
+
}
|
|
4009
|
+
const newHistoryIndex = historyIndex - 1;
|
|
4010
|
+
const newSearchValue = history[newHistoryIndex];
|
|
4011
|
+
const filteredItems = getFilteredItems(items, tabs, newSearchValue, preferences);
|
|
4012
|
+
return {
|
|
4013
|
+
...state,
|
|
4014
|
+
searchValue: newSearchValue,
|
|
4015
|
+
historyIndex: newHistoryIndex,
|
|
4016
|
+
filteredItems,
|
|
4017
|
+
inputSource: Script
|
|
3796
4018
|
};
|
|
3797
4019
|
};
|
|
3798
4020
|
|
|
3799
4021
|
const commandMap = {
|
|
3800
4022
|
'Initialize.initialize': initialize,
|
|
4023
|
+
'Settings.clear': wrapCommand(clear$1),
|
|
4024
|
+
'Settings.clearHistory': wrapCommand(clearHistory),
|
|
3801
4025
|
'Settings.create': create$1,
|
|
3802
4026
|
'Settings.diff2': diff2,
|
|
4027
|
+
'Settings.getName': getName,
|
|
3803
4028
|
'Settings.getCommandIds': getCommandIds,
|
|
4029
|
+
'Settings.handleClickTab': wrapCommand(handleClickTab),
|
|
4030
|
+
'Settings.handleInput': wrapCommand(handleInput),
|
|
4031
|
+
'Settings.handleScroll': wrapCommand(handleScroll),
|
|
4032
|
+
'Settings.handleSettingChecked': wrapCommand(handleSettingChecked),
|
|
4033
|
+
'Settings.handleSettingInput': wrapCommand(handleSettingInput),
|
|
4034
|
+
'Settings.handleInputFocus': wrapCommand(handleInputFocus),
|
|
4035
|
+
'Settings.handleSettingSelect': wrapCommand(handleSettingSelect),
|
|
3804
4036
|
'Settings.loadContent': wrapCommand(loadContent),
|
|
3805
4037
|
'Settings.render2': render2,
|
|
3806
4038
|
'Settings.renderActions': renderActions,
|
|
@@ -3808,12 +4040,9 @@ const commandMap = {
|
|
|
3808
4040
|
'Settings.restoreState': restoreState,
|
|
3809
4041
|
'Settings.saveState': wrapGetter(saveState),
|
|
3810
4042
|
'Settings.terminate': terminate,
|
|
3811
|
-
'Settings.
|
|
3812
|
-
'Settings.
|
|
3813
|
-
'Settings.
|
|
3814
|
-
'Settings.handleSettingInput': wrapCommand(handleSettingInput),
|
|
3815
|
-
'Settings.handleSettingChecked': wrapCommand(handleSettingChecked),
|
|
3816
|
-
'Settings.handleSettingSelect': wrapCommand(handleSettingSelect)
|
|
4043
|
+
'Settings.useNextSearchValue': wrapCommand(useNextSearchValue),
|
|
4044
|
+
'Settings.usePreviousSearchValue': wrapCommand(usePreviousSearchValue),
|
|
4045
|
+
'Settings.getKeyBindings': getKeyBindings
|
|
3817
4046
|
};
|
|
3818
4047
|
|
|
3819
4048
|
const rpcs = Object.create(null);
|