@lvce-editor/settings-view 1.7.0 → 1.9.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 +42 -15
- package/package.json +1 -1
|
@@ -914,17 +914,33 @@ const terminate = () => {
|
|
|
914
914
|
globalThis.close();
|
|
915
915
|
};
|
|
916
916
|
|
|
917
|
-
const
|
|
917
|
+
const isItemModified = (item, preferences) => {
|
|
918
|
+
return item.id in preferences;
|
|
919
|
+
};
|
|
920
|
+
const addModifiedProperty = (items, preferences) => {
|
|
921
|
+
return items.map(item => ({
|
|
922
|
+
...item,
|
|
923
|
+
modified: isItemModified(item, preferences)
|
|
924
|
+
}));
|
|
925
|
+
};
|
|
926
|
+
const filterByTab = (items, tabs) => {
|
|
918
927
|
const selectedTab = tabs.find(tab => tab.selected);
|
|
919
928
|
if (!selectedTab) {
|
|
920
929
|
return items;
|
|
921
930
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
931
|
+
return items.filter(item => item.category === selectedTab.id);
|
|
932
|
+
};
|
|
933
|
+
const filterBySearch = (items, searchValue) => {
|
|
934
|
+
if (!searchValue || !searchValue.trim()) {
|
|
935
|
+
return items;
|
|
925
936
|
}
|
|
926
937
|
const normalizedSearchValue = searchValue.toLowerCase().trim();
|
|
927
|
-
return
|
|
938
|
+
return items.filter(item => item.heading.toLowerCase().includes(normalizedSearchValue));
|
|
939
|
+
};
|
|
940
|
+
const getFilteredItems = (items, tabs, searchValue = '', preferences = {}) => {
|
|
941
|
+
const tabFilteredItems = filterByTab(items, tabs);
|
|
942
|
+
const itemsWithModifiedProperty = addModifiedProperty(tabFilteredItems, preferences);
|
|
943
|
+
return filterBySearch(itemsWithModifiedProperty, searchValue);
|
|
928
944
|
};
|
|
929
945
|
|
|
930
946
|
const User = 1;
|
|
@@ -933,10 +949,11 @@ const Script = 2;
|
|
|
933
949
|
const clear$1 = state => {
|
|
934
950
|
const {
|
|
935
951
|
items,
|
|
936
|
-
tabs
|
|
952
|
+
tabs,
|
|
953
|
+
preferences
|
|
937
954
|
} = state;
|
|
938
955
|
const newSearchValue = '';
|
|
939
|
-
const filteredItems = getFilteredItems(items, tabs, newSearchValue);
|
|
956
|
+
const filteredItems = getFilteredItems(items, tabs, newSearchValue, preferences);
|
|
940
957
|
return {
|
|
941
958
|
...state,
|
|
942
959
|
searchValue: newSearchValue,
|
|
@@ -1044,10 +1061,11 @@ const handleClickTab = (state, name) => {
|
|
|
1044
1061
|
const {
|
|
1045
1062
|
items,
|
|
1046
1063
|
tabs,
|
|
1047
|
-
searchValue
|
|
1064
|
+
searchValue,
|
|
1065
|
+
preferences
|
|
1048
1066
|
} = state;
|
|
1049
1067
|
const updatedTabs = getUpdatedTabs(tabs, name);
|
|
1050
|
-
const filteredItems = getFilteredItems(items, updatedTabs, searchValue);
|
|
1068
|
+
const filteredItems = getFilteredItems(items, updatedTabs, searchValue, preferences);
|
|
1051
1069
|
return {
|
|
1052
1070
|
...state,
|
|
1053
1071
|
tabs: updatedTabs,
|
|
@@ -1058,9 +1076,10 @@ const handleClickTab = (state, name) => {
|
|
|
1058
1076
|
const handleInput = (state, value) => {
|
|
1059
1077
|
const {
|
|
1060
1078
|
items,
|
|
1061
|
-
tabs
|
|
1079
|
+
tabs,
|
|
1080
|
+
preferences
|
|
1062
1081
|
} = state;
|
|
1063
|
-
const filteredItems = getFilteredItems(items, tabs, value);
|
|
1082
|
+
const filteredItems = getFilteredItems(items, tabs, value, preferences);
|
|
1064
1083
|
return {
|
|
1065
1084
|
...state,
|
|
1066
1085
|
searchValue: value,
|
|
@@ -3173,8 +3192,8 @@ const loadContent = async (state, savedState) => {
|
|
|
3173
3192
|
const tabs = getTabs();
|
|
3174
3193
|
const newTabs = getUpdatedTabs(tabs, tabId);
|
|
3175
3194
|
const items = await getSettingItems();
|
|
3176
|
-
const filteredItems = getFilteredItems(items, newTabs, searchValue);
|
|
3177
3195
|
const preferences = await getPreferences();
|
|
3196
|
+
const filteredItems = getFilteredItems(items, newTabs, searchValue, preferences);
|
|
3178
3197
|
return {
|
|
3179
3198
|
...state,
|
|
3180
3199
|
tabs: newTabs,
|
|
@@ -3278,11 +3297,17 @@ const getSettingsHeaderDom = () => {
|
|
|
3278
3297
|
}, ...getSettingsInputDom()];
|
|
3279
3298
|
};
|
|
3280
3299
|
|
|
3300
|
+
const getInputId = id => {
|
|
3301
|
+
return id.replaceAll('.', '\\.');
|
|
3302
|
+
};
|
|
3303
|
+
|
|
3281
3304
|
const getItemCheckBoxVirtualDom = item => {
|
|
3282
3305
|
const {
|
|
3283
3306
|
heading,
|
|
3284
|
-
description
|
|
3307
|
+
description,
|
|
3308
|
+
id
|
|
3285
3309
|
} = item;
|
|
3310
|
+
const domId = getInputId(id);
|
|
3286
3311
|
return [{
|
|
3287
3312
|
type: VirtualDomElements.Div,
|
|
3288
3313
|
className: 'SettingsItem',
|
|
@@ -3298,10 +3323,12 @@ const getItemCheckBoxVirtualDom = item => {
|
|
|
3298
3323
|
type: VirtualDomElements.Input,
|
|
3299
3324
|
className: 'CheckBox',
|
|
3300
3325
|
inputType: 'checkbox',
|
|
3301
|
-
childCount: 0
|
|
3326
|
+
childCount: 0,
|
|
3327
|
+
id: domId
|
|
3302
3328
|
}, {
|
|
3303
3329
|
type: VirtualDomElements.Label,
|
|
3304
|
-
childCount: 1
|
|
3330
|
+
childCount: 1,
|
|
3331
|
+
htmlFor: domId
|
|
3305
3332
|
}, text(description)];
|
|
3306
3333
|
};
|
|
3307
3334
|
|