@lvce-editor/settings-view 1.10.0 → 1.11.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.
@@ -990,7 +990,8 @@ const create$1 = (id, uri, x, y, width, height) => {
990
990
  inputSource: 0,
991
991
  scrollOffset: 0,
992
992
  filteredItemsCount: 0,
993
- history: []
993
+ history: [],
994
+ modifiedSettings: {}
994
995
  };
995
996
  set$1(id, state, state);
996
997
  };
@@ -1000,7 +1001,7 @@ const isEqual$3 = (oldState, newState) => {
1000
1001
  };
1001
1002
 
1002
1003
  const isEqual$2 = (oldState, newState) => {
1003
- return oldState === newState;
1004
+ return oldState.filteredItems === newState.filteredItems;
1004
1005
  };
1005
1006
 
1006
1007
  const isEqual$1 = (oldState, newState) => {
@@ -1079,7 +1080,7 @@ const handleClickTab = (state, name) => {
1079
1080
  };
1080
1081
  };
1081
1082
 
1082
- const handleInput = (state, value) => {
1083
+ const handleInput = (state, value, inputSource = User) => {
1083
1084
  const {
1084
1085
  items,
1085
1086
  tabs,
@@ -1090,7 +1091,29 @@ const handleInput = (state, value) => {
1090
1091
  ...state,
1091
1092
  searchValue: value,
1092
1093
  filteredItems,
1093
- inputSource: User
1094
+ inputSource
1095
+ };
1096
+ };
1097
+
1098
+ const handleSettingChecked = (state, name, value) => {
1099
+ // TODO update value
1100
+ return {
1101
+ ...state
1102
+ };
1103
+ };
1104
+
1105
+ const handleSettingInput = (state, name, value, inputSource = User) => {
1106
+ // TODO update value
1107
+ return {
1108
+ ...state,
1109
+ inputSource
1110
+ };
1111
+ };
1112
+
1113
+ const handleSettingSelect = (state, name, value) => {
1114
+ // TODO update value
1115
+ return {
1116
+ ...state
1094
1117
  };
1095
1118
  };
1096
1119
 
@@ -1147,6 +1170,7 @@ const FontSizeDescription = 'The font size of the editor';
1147
1170
  const FormatOnSave = 'Format on Save';
1148
1171
  const FormatOnSaveDescription = 'Format code when saving';
1149
1172
  const NumberValue = 'number value';
1173
+ const StringValue = 'string value';
1150
1174
  const SearchSettings = 'Search Settings';
1151
1175
  const SettingsContent$1 = 'Settings Content';
1152
1176
  const SidebarPosition = 'Sidebar Position';
@@ -1450,6 +1474,9 @@ const formatOnSaveDescription = () => {
1450
1474
  const numberValue = () => {
1451
1475
  return i18nString(NumberValue);
1452
1476
  };
1477
+ const stringValue = () => {
1478
+ return i18nString(StringValue);
1479
+ };
1453
1480
  const searchSettings = () => {
1454
1481
  return i18nString(SearchSettings);
1455
1482
  };
@@ -2197,10 +2224,10 @@ const getSettingItems = async () => {
2197
2224
  heading: fontSize(),
2198
2225
  description: fontSizeDescription(),
2199
2226
  type: Number$1,
2200
- value: '15px',
2227
+ value: 15,
2201
2228
  category: TextEditorTab
2202
2229
  }, {
2203
- id: 'fontFamily',
2230
+ id: 'Editor.fontFamily',
2204
2231
  heading: fontFamily(),
2205
2232
  description: fontFamilyDescription(),
2206
2233
  type: String,
@@ -2209,7 +2236,7 @@ const getSettingItems = async () => {
2209
2236
  },
2210
2237
  // Text Editor Settings
2211
2238
  {
2212
- id: 'wordWrap',
2239
+ id: 'Editor.wordWrap',
2213
2240
  heading: wordWrap(),
2214
2241
  description: wordWrapDescription(),
2215
2242
  type: Enum,
@@ -2223,7 +2250,7 @@ const getSettingItems = async () => {
2223
2250
  label: 'off' // i18n
2224
2251
  }]
2225
2252
  }, {
2226
- id: 'lineNumbers',
2253
+ id: 'Editor.lineNumbers',
2227
2254
  heading: lineNumbers(),
2228
2255
  description: lineNumbersDescription(),
2229
2256
  type: Enum,
@@ -2237,133 +2264,133 @@ const getSettingItems = async () => {
2237
2264
  label: 'off' // i18n
2238
2265
  }]
2239
2266
  }, {
2240
- id: 'minimap',
2267
+ id: 'Editor.minimap',
2241
2268
  heading: minimap(),
2242
2269
  description: minimapDescription(),
2243
2270
  type: Boolean$1,
2244
2271
  value: 'true',
2245
2272
  category: TextEditorTab
2246
2273
  }, {
2247
- id: 'scrollBeyondLastLine',
2274
+ id: 'Editor.scrollBeyondLastLine',
2248
2275
  heading: scrollBeyondLastLine(),
2249
2276
  description: scrollBeyondLastLineDescription(),
2250
2277
  type: Boolean$1,
2251
2278
  value: 'false',
2252
2279
  category: TextEditorTab
2253
2280
  }, {
2254
- id: 'smoothScrolling',
2281
+ id: 'Editor.smoothScrolling',
2255
2282
  heading: smoothScrolling(),
2256
2283
  description: smoothScrollingDescription(),
2257
2284
  type: Boolean$1,
2258
2285
  value: 'true',
2259
2286
  category: TextEditorTab
2260
2287
  }, {
2261
- id: 'cursorBlinking',
2288
+ id: 'Editor.cursorBlinking',
2262
2289
  heading: cursorBlinking(),
2263
2290
  description: cursorBlinkingDescription(),
2264
2291
  type: String,
2265
2292
  value: 'blink',
2266
2293
  category: TextEditorTab
2267
2294
  }, {
2268
- id: 'cursorStyle',
2295
+ id: 'Editor.cursorStyle',
2269
2296
  heading: cursorStyle(),
2270
2297
  description: cursorStyleDescription(),
2271
2298
  type: String,
2272
2299
  value: 'line',
2273
2300
  category: TextEditorTab
2274
2301
  }, {
2275
- id: 'cursorWidth',
2302
+ id: 'Editor.cursorWidth',
2276
2303
  heading: cursorWidth(),
2277
2304
  description: cursorWidthDescription(),
2278
2305
  type: Number$1,
2279
2306
  value: '0',
2280
2307
  category: TextEditorTab
2281
2308
  }, {
2282
- id: 'tabSize',
2309
+ id: 'Editor.tabSize',
2283
2310
  heading: tabSize(),
2284
2311
  description: tabSizeDescription(),
2285
2312
  type: Number$1,
2286
2313
  value: '4',
2287
2314
  category: TextEditorTab
2288
2315
  }, {
2289
- id: 'insertSpaces',
2316
+ id: 'Editor.insertSpaces',
2290
2317
  heading: insertSpaces(),
2291
2318
  description: insertSpacesDescription(),
2292
2319
  type: Boolean$1,
2293
2320
  value: 'true',
2294
2321
  category: TextEditorTab
2295
2322
  }, {
2296
- id: 'detectIndentation',
2323
+ id: 'Editor.detectIndentation',
2297
2324
  heading: detectIndentation(),
2298
2325
  description: detectIndentationDescription(),
2299
2326
  type: Boolean$1,
2300
2327
  value: 'true',
2301
2328
  category: TextEditorTab
2302
2329
  }, {
2303
- id: 'trimAutoWhitespace',
2330
+ id: 'Editor.trimAutoWhitespace',
2304
2331
  heading: trimAutoWhitespace(),
2305
2332
  description: trimAutoWhitespaceDescription(),
2306
2333
  type: Boolean$1,
2307
2334
  value: 'true',
2308
2335
  category: TextEditorTab
2309
2336
  }, {
2310
- id: 'largeFileOptimizations',
2337
+ id: 'Editor.largeFileOptimizations',
2311
2338
  heading: largeFileOptimizations(),
2312
2339
  description: largeFileOptimizationsDescription(),
2313
2340
  type: Boolean$1,
2314
2341
  value: 'true',
2315
2342
  category: TextEditorTab
2316
2343
  }, {
2317
- id: 'renderWhitespace',
2344
+ id: 'Editor.renderWhitespace',
2318
2345
  heading: renderWhitespace(),
2319
2346
  description: renderWhitespaceDescription(),
2320
2347
  type: String,
2321
2348
  value: 'selection',
2322
2349
  category: TextEditorTab
2323
2350
  }, {
2324
- id: 'renderControlCharacters',
2351
+ id: 'Editor.renderControlCharacters',
2325
2352
  heading: renderControlCharacters(),
2326
2353
  description: renderControlCharactersDescription(),
2327
2354
  type: Boolean$1,
2328
2355
  value: 'false',
2329
2356
  category: TextEditorTab
2330
2357
  }, {
2331
- id: 'renderLineHighlight',
2358
+ id: 'Editor.renderLineHighlight',
2332
2359
  heading: renderLineHighlight(),
2333
2360
  description: renderLineHighlightDescription(),
2334
2361
  type: String,
2335
2362
  value: 'line',
2336
2363
  category: TextEditorTab
2337
2364
  }, {
2338
- id: 'codeLens',
2365
+ id: 'Editor.codeLens',
2339
2366
  heading: codeLens(),
2340
2367
  description: codeLensDescription(),
2341
2368
  type: Boolean$1,
2342
2369
  value: 'true',
2343
2370
  category: TextEditorTab
2344
2371
  }, {
2345
- id: 'folding',
2372
+ id: 'Editor.folding',
2346
2373
  heading: folding(),
2347
2374
  description: foldingDescription(),
2348
2375
  type: Boolean$1,
2349
2376
  value: 'true',
2350
2377
  category: TextEditorTab
2351
2378
  }, {
2352
- id: 'showFoldingControls',
2379
+ id: 'Editor.showFoldingControls',
2353
2380
  heading: showFoldingControls(),
2354
2381
  description: showFoldingControlsDescription(),
2355
2382
  type: String,
2356
2383
  value: 'mouseover',
2357
2384
  category: TextEditorTab
2358
2385
  }, {
2359
- id: 'unfoldOnClickAfterEnd',
2386
+ id: 'Editor.unfoldOnClickAfterEnd',
2360
2387
  heading: unfoldOnClickAfterEnd(),
2361
2388
  description: unfoldOnClickAfterEndDescription(),
2362
2389
  type: Boolean$1,
2363
2390
  value: 'false',
2364
2391
  category: TextEditorTab
2365
2392
  }, {
2366
- id: 'links',
2393
+ id: 'Editor.links',
2367
2394
  heading: links(),
2368
2395
  description: linksDescription(),
2369
2396
  type: Boolean$1,
@@ -3196,6 +3223,13 @@ const restoreState = savedState => {
3196
3223
  };
3197
3224
  };
3198
3225
 
3226
+ const getModifiedSettings = preferences => {
3227
+ const modifiedSettings = Object.create(null);
3228
+ for (const key of Object.keys(preferences)) {
3229
+ modifiedSettings[key] = true;
3230
+ }
3231
+ return modifiedSettings;
3232
+ };
3199
3233
  const loadContent = async (state, savedState) => {
3200
3234
  const {
3201
3235
  searchValue,
@@ -3205,15 +3239,17 @@ const loadContent = async (state, savedState) => {
3205
3239
  const newTabs = getUpdatedTabs(tabs, tabId);
3206
3240
  const items = await getSettingItems();
3207
3241
  const preferences = await getPreferences();
3242
+ const modifiedSettings = getModifiedSettings(preferences);
3208
3243
  const filteredItems = getFilteredItems(items, newTabs, searchValue, preferences);
3209
3244
  return {
3210
3245
  ...state,
3211
- tabs: newTabs,
3212
- items,
3213
3246
  filteredItems,
3214
- preferences,
3215
3247
  inputSource: Script,
3216
- searchValue
3248
+ items,
3249
+ modifiedSettings,
3250
+ preferences,
3251
+ searchValue,
3252
+ tabs: newTabs
3217
3253
  };
3218
3254
  };
3219
3255
 
@@ -3307,6 +3343,9 @@ const getSettingsInputBadgeDom = (filteredSettingsCount, hasSearchValue) => {
3307
3343
  const HandleClickClear = 'handleClickClear';
3308
3344
  const HandleClickTab = 'handleClickTab';
3309
3345
  const HandleInput = 'handleInput';
3346
+ const HandleSettingInput = 'handleSettingInput';
3347
+ const HandleSettingChecked = 'handleSettingChecked';
3348
+ const HandleSettingSelect = 'handleSettingSelect';
3310
3349
 
3311
3350
  const getSettingsInputButtonsDom = () => {
3312
3351
  return [{
@@ -3415,7 +3454,8 @@ const getItemNumberVirtualDom = item => {
3415
3454
  placeholder: numberValue(),
3416
3455
  childCount: 0,
3417
3456
  id: domId,
3418
- name: id
3457
+ name: id,
3458
+ onInput: HandleSettingInput
3419
3459
  }];
3420
3460
  };
3421
3461
 
@@ -3476,12 +3516,21 @@ const getItemStringVirtualDom = item => {
3476
3516
  type: VirtualDomElements.Input,
3477
3517
  className: InputBox,
3478
3518
  inputType: 'text',
3479
- placeholder: numberValue(),
3519
+ placeholder: stringValue(),
3480
3520
  childCount: 0,
3481
- name: id
3521
+ name: id,
3522
+ onInput: HandleSettingInput
3482
3523
  }];
3483
3524
  };
3484
3525
 
3526
+ const getItemUnknownVirtualDom = () => {
3527
+ return [{
3528
+ type: VirtualDomElements.Div,
3529
+ className: SettingsItem,
3530
+ childCount: 1
3531
+ }, text('unknown setting type')];
3532
+ };
3533
+
3485
3534
  const getItemVirtualDom = item => {
3486
3535
  if (item.type === Number$1) {
3487
3536
  return getItemNumberVirtualDom(item);
@@ -3495,8 +3544,7 @@ const getItemVirtualDom = item => {
3495
3544
  if (item.type === Enum) {
3496
3545
  return getItemSelectVirtualDom(item);
3497
3546
  }
3498
- // TODO
3499
- return [text('unknown setting type')];
3547
+ return getItemUnknownVirtualDom();
3500
3548
  };
3501
3549
 
3502
3550
  const getSettingsNoResultsDom = searchValue => {
@@ -3604,7 +3652,8 @@ const renderSettingValues = (oldState, newState) => {
3604
3652
  filteredItems,
3605
3653
  id
3606
3654
  } = newState;
3607
- const numericSettings = filteredItems.filter(item => item.type === Number$1);
3655
+ const enabledTypes = [Number$1, String];
3656
+ const numericSettings = filteredItems.filter(item => enabledTypes.includes(item.type));
3608
3657
  const inputValues = numericSettings.map(item => ({
3609
3658
  name: item.id,
3610
3659
  value: item.value
@@ -3666,6 +3715,15 @@ const renderEventListeners = () => {
3666
3715
  }, {
3667
3716
  name: HandleClickClear,
3668
3717
  params: ['clear']
3718
+ }, {
3719
+ name: HandleSettingInput,
3720
+ params: ['handleSettingInput', 'event.target.name', 'event.target.value']
3721
+ }, {
3722
+ name: HandleSettingChecked,
3723
+ params: ['handleSettingInput', 'event.target.name', 'event.target.value']
3724
+ }, {
3725
+ name: HandleSettingSelect,
3726
+ params: ['handleSettingInput', 'event.target.name', 'event.target.value']
3669
3727
  }];
3670
3728
  };
3671
3729
 
@@ -3700,7 +3758,10 @@ const commandMap = {
3700
3758
  'Settings.terminate': terminate,
3701
3759
  'Settings.handleClickTab': wrapCommand(handleClickTab),
3702
3760
  'Settings.clear': wrapCommand(clear$1),
3703
- 'Settings.handleInput': wrapCommand(handleInput)
3761
+ 'Settings.handleInput': wrapCommand(handleInput),
3762
+ 'Settings.handleSettingInput': wrapCommand(handleSettingInput),
3763
+ 'Settings.handleSettingChecked': wrapCommand(handleSettingChecked),
3764
+ 'Settings.handleSettingSelect': wrapCommand(handleSettingSelect)
3704
3765
  };
3705
3766
 
3706
3767
  const rpcs = Object.create(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/settings-view",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",