@lvce-editor/settings-view 1.10.0 → 1.12.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';
@@ -1395,6 +1419,7 @@ const WordSeparators = 'Word Separators';
1395
1419
  const WordSeparatorsDescription = 'Characters that will be used as word separators when doing word related navigations or operations';
1396
1420
  const WrappingIndent = 'Wrapping Indent';
1397
1421
  const WrappingIndentDescription = 'Controls the indentation of wrapped lines';
1422
+ const UnknownSettingType = 'Unknown setting type';
1398
1423
 
1399
1424
  const autoSave = () => {
1400
1425
  return i18nString(AutoSave);
@@ -1450,6 +1475,9 @@ const formatOnSaveDescription = () => {
1450
1475
  const numberValue = () => {
1451
1476
  return i18nString(NumberValue);
1452
1477
  };
1478
+ const stringValue = () => {
1479
+ return i18nString(StringValue);
1480
+ };
1453
1481
  const searchSettings = () => {
1454
1482
  return i18nString(SearchSettings);
1455
1483
  };
@@ -2190,6 +2218,9 @@ const wrappingIndent = () => {
2190
2218
  const wrappingIndentDescription = () => {
2191
2219
  return i18nString(WrappingIndentDescription);
2192
2220
  };
2221
+ const unknownSettingType = () => {
2222
+ return i18nString(UnknownSettingType);
2223
+ };
2193
2224
 
2194
2225
  const getSettingItems = async () => {
2195
2226
  return [{
@@ -2197,10 +2228,10 @@ const getSettingItems = async () => {
2197
2228
  heading: fontSize(),
2198
2229
  description: fontSizeDescription(),
2199
2230
  type: Number$1,
2200
- value: '15px',
2231
+ value: 15,
2201
2232
  category: TextEditorTab
2202
2233
  }, {
2203
- id: 'fontFamily',
2234
+ id: 'Editor.fontFamily',
2204
2235
  heading: fontFamily(),
2205
2236
  description: fontFamilyDescription(),
2206
2237
  type: String,
@@ -2209,7 +2240,7 @@ const getSettingItems = async () => {
2209
2240
  },
2210
2241
  // Text Editor Settings
2211
2242
  {
2212
- id: 'wordWrap',
2243
+ id: 'Editor.wordWrap',
2213
2244
  heading: wordWrap(),
2214
2245
  description: wordWrapDescription(),
2215
2246
  type: Enum,
@@ -2223,7 +2254,7 @@ const getSettingItems = async () => {
2223
2254
  label: 'off' // i18n
2224
2255
  }]
2225
2256
  }, {
2226
- id: 'lineNumbers',
2257
+ id: 'Editor.lineNumbers',
2227
2258
  heading: lineNumbers(),
2228
2259
  description: lineNumbersDescription(),
2229
2260
  type: Enum,
@@ -2237,133 +2268,133 @@ const getSettingItems = async () => {
2237
2268
  label: 'off' // i18n
2238
2269
  }]
2239
2270
  }, {
2240
- id: 'minimap',
2271
+ id: 'Editor.minimap',
2241
2272
  heading: minimap(),
2242
2273
  description: minimapDescription(),
2243
2274
  type: Boolean$1,
2244
2275
  value: 'true',
2245
2276
  category: TextEditorTab
2246
2277
  }, {
2247
- id: 'scrollBeyondLastLine',
2278
+ id: 'Editor.scrollBeyondLastLine',
2248
2279
  heading: scrollBeyondLastLine(),
2249
2280
  description: scrollBeyondLastLineDescription(),
2250
2281
  type: Boolean$1,
2251
2282
  value: 'false',
2252
2283
  category: TextEditorTab
2253
2284
  }, {
2254
- id: 'smoothScrolling',
2285
+ id: 'Editor.smoothScrolling',
2255
2286
  heading: smoothScrolling(),
2256
2287
  description: smoothScrollingDescription(),
2257
2288
  type: Boolean$1,
2258
2289
  value: 'true',
2259
2290
  category: TextEditorTab
2260
2291
  }, {
2261
- id: 'cursorBlinking',
2292
+ id: 'Editor.cursorBlinking',
2262
2293
  heading: cursorBlinking(),
2263
2294
  description: cursorBlinkingDescription(),
2264
2295
  type: String,
2265
2296
  value: 'blink',
2266
2297
  category: TextEditorTab
2267
2298
  }, {
2268
- id: 'cursorStyle',
2299
+ id: 'Editor.cursorStyle',
2269
2300
  heading: cursorStyle(),
2270
2301
  description: cursorStyleDescription(),
2271
2302
  type: String,
2272
2303
  value: 'line',
2273
2304
  category: TextEditorTab
2274
2305
  }, {
2275
- id: 'cursorWidth',
2306
+ id: 'Editor.cursorWidth',
2276
2307
  heading: cursorWidth(),
2277
2308
  description: cursorWidthDescription(),
2278
2309
  type: Number$1,
2279
2310
  value: '0',
2280
2311
  category: TextEditorTab
2281
2312
  }, {
2282
- id: 'tabSize',
2313
+ id: 'Editor.tabSize',
2283
2314
  heading: tabSize(),
2284
2315
  description: tabSizeDescription(),
2285
2316
  type: Number$1,
2286
2317
  value: '4',
2287
2318
  category: TextEditorTab
2288
2319
  }, {
2289
- id: 'insertSpaces',
2320
+ id: 'Editor.insertSpaces',
2290
2321
  heading: insertSpaces(),
2291
2322
  description: insertSpacesDescription(),
2292
2323
  type: Boolean$1,
2293
2324
  value: 'true',
2294
2325
  category: TextEditorTab
2295
2326
  }, {
2296
- id: 'detectIndentation',
2327
+ id: 'Editor.detectIndentation',
2297
2328
  heading: detectIndentation(),
2298
2329
  description: detectIndentationDescription(),
2299
2330
  type: Boolean$1,
2300
2331
  value: 'true',
2301
2332
  category: TextEditorTab
2302
2333
  }, {
2303
- id: 'trimAutoWhitespace',
2334
+ id: 'Editor.trimAutoWhitespace',
2304
2335
  heading: trimAutoWhitespace(),
2305
2336
  description: trimAutoWhitespaceDescription(),
2306
2337
  type: Boolean$1,
2307
2338
  value: 'true',
2308
2339
  category: TextEditorTab
2309
2340
  }, {
2310
- id: 'largeFileOptimizations',
2341
+ id: 'Editor.largeFileOptimizations',
2311
2342
  heading: largeFileOptimizations(),
2312
2343
  description: largeFileOptimizationsDescription(),
2313
2344
  type: Boolean$1,
2314
2345
  value: 'true',
2315
2346
  category: TextEditorTab
2316
2347
  }, {
2317
- id: 'renderWhitespace',
2348
+ id: 'Editor.renderWhitespace',
2318
2349
  heading: renderWhitespace(),
2319
2350
  description: renderWhitespaceDescription(),
2320
2351
  type: String,
2321
2352
  value: 'selection',
2322
2353
  category: TextEditorTab
2323
2354
  }, {
2324
- id: 'renderControlCharacters',
2355
+ id: 'Editor.renderControlCharacters',
2325
2356
  heading: renderControlCharacters(),
2326
2357
  description: renderControlCharactersDescription(),
2327
2358
  type: Boolean$1,
2328
2359
  value: 'false',
2329
2360
  category: TextEditorTab
2330
2361
  }, {
2331
- id: 'renderLineHighlight',
2362
+ id: 'Editor.renderLineHighlight',
2332
2363
  heading: renderLineHighlight(),
2333
2364
  description: renderLineHighlightDescription(),
2334
2365
  type: String,
2335
2366
  value: 'line',
2336
2367
  category: TextEditorTab
2337
2368
  }, {
2338
- id: 'codeLens',
2369
+ id: 'Editor.codeLens',
2339
2370
  heading: codeLens(),
2340
2371
  description: codeLensDescription(),
2341
2372
  type: Boolean$1,
2342
2373
  value: 'true',
2343
2374
  category: TextEditorTab
2344
2375
  }, {
2345
- id: 'folding',
2376
+ id: 'Editor.folding',
2346
2377
  heading: folding(),
2347
2378
  description: foldingDescription(),
2348
2379
  type: Boolean$1,
2349
2380
  value: 'true',
2350
2381
  category: TextEditorTab
2351
2382
  }, {
2352
- id: 'showFoldingControls',
2383
+ id: 'Editor.showFoldingControls',
2353
2384
  heading: showFoldingControls(),
2354
2385
  description: showFoldingControlsDescription(),
2355
2386
  type: String,
2356
2387
  value: 'mouseover',
2357
2388
  category: TextEditorTab
2358
2389
  }, {
2359
- id: 'unfoldOnClickAfterEnd',
2390
+ id: 'Editor.unfoldOnClickAfterEnd',
2360
2391
  heading: unfoldOnClickAfterEnd(),
2361
2392
  description: unfoldOnClickAfterEndDescription(),
2362
2393
  type: Boolean$1,
2363
2394
  value: 'false',
2364
2395
  category: TextEditorTab
2365
2396
  }, {
2366
- id: 'links',
2397
+ id: 'Editor.links',
2367
2398
  heading: links(),
2368
2399
  description: linksDescription(),
2369
2400
  type: Boolean$1,
@@ -3196,6 +3227,13 @@ const restoreState = savedState => {
3196
3227
  };
3197
3228
  };
3198
3229
 
3230
+ const getModifiedSettings = preferences => {
3231
+ const modifiedSettings = Object.create(null);
3232
+ for (const key of Object.keys(preferences)) {
3233
+ modifiedSettings[key] = true;
3234
+ }
3235
+ return modifiedSettings;
3236
+ };
3199
3237
  const loadContent = async (state, savedState) => {
3200
3238
  const {
3201
3239
  searchValue,
@@ -3205,15 +3243,17 @@ const loadContent = async (state, savedState) => {
3205
3243
  const newTabs = getUpdatedTabs(tabs, tabId);
3206
3244
  const items = await getSettingItems();
3207
3245
  const preferences = await getPreferences();
3246
+ const modifiedSettings = getModifiedSettings(preferences);
3208
3247
  const filteredItems = getFilteredItems(items, newTabs, searchValue, preferences);
3209
3248
  return {
3210
3249
  ...state,
3211
- tabs: newTabs,
3212
- items,
3213
3250
  filteredItems,
3214
- preferences,
3215
3251
  inputSource: Script,
3216
- searchValue
3252
+ items,
3253
+ modifiedSettings,
3254
+ preferences,
3255
+ searchValue,
3256
+ tabs: newTabs
3217
3257
  };
3218
3258
  };
3219
3259
 
@@ -3273,6 +3313,7 @@ const SettingsSearchInput = 'SettingsSearchInput';
3273
3313
  const Button = 'Button';
3274
3314
  const InputButton = 'InputButton';
3275
3315
  const SearchFieldButton = 'SearchFieldButton';
3316
+ const Disabled = 'Disabled';
3276
3317
  const MaskIcon = 'MaskIcon';
3277
3318
  const MaskIconClearAll = 'MaskIconClearAll';
3278
3319
  const SettingsItem = 'SettingsItem';
@@ -3307,15 +3348,24 @@ const getSettingsInputBadgeDom = (filteredSettingsCount, hasSearchValue) => {
3307
3348
  const HandleClickClear = 'handleClickClear';
3308
3349
  const HandleClickTab = 'handleClickTab';
3309
3350
  const HandleInput = 'handleInput';
3351
+ const HandleSettingInput = 'handleSettingInput';
3352
+ const HandleSettingChecked = 'handleSettingChecked';
3353
+ const HandleSettingSelect = 'handleSettingSelect';
3310
3354
 
3311
- const getSettingsInputButtonsDom = () => {
3355
+ const getButtonClassName = hasSearchValue => {
3356
+ if (hasSearchValue) {
3357
+ return mergeClassNames(Button, InputButton, SearchFieldButton);
3358
+ }
3359
+ return mergeClassNames(Button, InputButton, SearchFieldButton, Disabled);
3360
+ };
3361
+ const getSettingsInputButtonsDom = hasSearchValue => {
3312
3362
  return [{
3313
3363
  type: VirtualDomElements.Button,
3314
- className: mergeClassNames(Button, InputButton, SearchFieldButton),
3364
+ className: getButtonClassName(hasSearchValue),
3315
3365
  childCount: 1,
3316
3366
  ariaLabel: clear(),
3317
3367
  name: Clear$1,
3318
- // TODO add click event listener
3368
+ disabled: !hasSearchValue,
3319
3369
  onClick: HandleClickClear
3320
3370
  }, {
3321
3371
  type: VirtualDomElements.Div,
@@ -3350,7 +3400,7 @@ const getSettingsHeaderDom = (filteredSettingsCount, hasSearchValue) => {
3350
3400
  type: VirtualDomElements.Div,
3351
3401
  className: SettingsInputWrapper,
3352
3402
  childCount
3353
- }, ...getSettingsInputDom(), ...getSettingsInputButtonsDom(), ...badgeDom];
3403
+ }, ...getSettingsInputDom(), ...getSettingsInputButtonsDom(hasSearchValue), ...badgeDom];
3354
3404
  };
3355
3405
 
3356
3406
  const getInputId = id => {
@@ -3367,7 +3417,8 @@ const getItemCheckBoxVirtualDom = item => {
3367
3417
  return [{
3368
3418
  type: VirtualDomElements.Div,
3369
3419
  className: SettingsItem,
3370
- childCount: 3
3420
+ childCount: 3,
3421
+ role: 'group'
3371
3422
  }, {
3372
3423
  type: VirtualDomElements.H3,
3373
3424
  childCount: 1
@@ -3378,10 +3429,11 @@ const getItemCheckBoxVirtualDom = item => {
3378
3429
  }, {
3379
3430
  type: VirtualDomElements.Input,
3380
3431
  className: CheckBox,
3381
- inputType: 'checkbox',
3382
3432
  childCount: 0,
3383
3433
  id: domId,
3384
- name: id
3434
+ inputType: 'checkbox',
3435
+ name: id,
3436
+ onChange: HandleSettingChecked
3385
3437
  }, {
3386
3438
  type: VirtualDomElements.Label,
3387
3439
  childCount: 1,
@@ -3399,7 +3451,8 @@ const getItemNumberVirtualDom = item => {
3399
3451
  return [{
3400
3452
  type: VirtualDomElements.Div,
3401
3453
  className: SettingsItem,
3402
- childCount: 3
3454
+ childCount: 3,
3455
+ role: 'group'
3403
3456
  }, {
3404
3457
  type: VirtualDomElements.H3,
3405
3458
  childCount: 1
@@ -3415,7 +3468,8 @@ const getItemNumberVirtualDom = item => {
3415
3468
  placeholder: numberValue(),
3416
3469
  childCount: 0,
3417
3470
  id: domId,
3418
- name: id
3471
+ name: id,
3472
+ onInput: HandleSettingInput
3419
3473
  }];
3420
3474
  };
3421
3475
 
@@ -3441,7 +3495,8 @@ const getItemSelectVirtualDom = item => {
3441
3495
  return [{
3442
3496
  type: VirtualDomElements.Div,
3443
3497
  className: SettingsItem,
3444
- childCount: 3
3498
+ childCount: 3,
3499
+ role: 'group'
3445
3500
  }, {
3446
3501
  type: VirtualDomElements.H3,
3447
3502
  childCount: 1
@@ -3465,7 +3520,8 @@ const getItemStringVirtualDom = item => {
3465
3520
  return [{
3466
3521
  type: VirtualDomElements.Div,
3467
3522
  className: SettingsItem,
3468
- childCount: 3
3523
+ childCount: 3,
3524
+ role: 'group'
3469
3525
  }, {
3470
3526
  type: VirtualDomElements.H3,
3471
3527
  childCount: 1
@@ -3476,12 +3532,22 @@ const getItemStringVirtualDom = item => {
3476
3532
  type: VirtualDomElements.Input,
3477
3533
  className: InputBox,
3478
3534
  inputType: 'text',
3479
- placeholder: numberValue(),
3535
+ placeholder: stringValue(),
3480
3536
  childCount: 0,
3481
- name: id
3537
+ name: id,
3538
+ onInput: HandleSettingInput
3482
3539
  }];
3483
3540
  };
3484
3541
 
3542
+ const getItemUnknownVirtualDom = () => {
3543
+ return [{
3544
+ type: VirtualDomElements.Div,
3545
+ className: SettingsItem,
3546
+ childCount: 1,
3547
+ role: 'group'
3548
+ }, text(unknownSettingType())];
3549
+ };
3550
+
3485
3551
  const getItemVirtualDom = item => {
3486
3552
  if (item.type === Number$1) {
3487
3553
  return getItemNumberVirtualDom(item);
@@ -3495,8 +3561,7 @@ const getItemVirtualDom = item => {
3495
3561
  if (item.type === Enum) {
3496
3562
  return getItemSelectVirtualDom(item);
3497
3563
  }
3498
- // TODO
3499
- return [text('unknown setting type')];
3564
+ return getItemUnknownVirtualDom();
3500
3565
  };
3501
3566
 
3502
3567
  const getSettingsNoResultsDom = searchValue => {
@@ -3604,7 +3669,8 @@ const renderSettingValues = (oldState, newState) => {
3604
3669
  filteredItems,
3605
3670
  id
3606
3671
  } = newState;
3607
- const numericSettings = filteredItems.filter(item => item.type === Number$1);
3672
+ const enabledTypes = [Number$1, String];
3673
+ const numericSettings = filteredItems.filter(item => enabledTypes.includes(item.type));
3608
3674
  const inputValues = numericSettings.map(item => ({
3609
3675
  name: item.id,
3610
3676
  value: item.value
@@ -3666,6 +3732,15 @@ const renderEventListeners = () => {
3666
3732
  }, {
3667
3733
  name: HandleClickClear,
3668
3734
  params: ['clear']
3735
+ }, {
3736
+ name: HandleSettingInput,
3737
+ params: ['handleSettingInput', 'event.target.name', 'event.target.value']
3738
+ }, {
3739
+ name: HandleSettingChecked,
3740
+ params: ['handleSettingChecked', 'event.target.name', 'event.target.value']
3741
+ }, {
3742
+ name: HandleSettingSelect,
3743
+ params: ['handleSettingSelect', 'event.target.name', 'event.target.value']
3669
3744
  }];
3670
3745
  };
3671
3746
 
@@ -3700,7 +3775,10 @@ const commandMap = {
3700
3775
  'Settings.terminate': terminate,
3701
3776
  'Settings.handleClickTab': wrapCommand(handleClickTab),
3702
3777
  'Settings.clear': wrapCommand(clear$1),
3703
- 'Settings.handleInput': wrapCommand(handleInput)
3778
+ 'Settings.handleInput': wrapCommand(handleInput),
3779
+ 'Settings.handleSettingInput': wrapCommand(handleSettingInput),
3780
+ 'Settings.handleSettingChecked': wrapCommand(handleSettingChecked),
3781
+ 'Settings.handleSettingSelect': wrapCommand(handleSettingSelect)
3704
3782
  };
3705
3783
 
3706
3784
  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.12.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",