@lvce-editor/extension-search-view 2.6.0 → 2.8.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.
@@ -1176,8 +1176,8 @@ const clearSearchResults = state => {
1176
1176
  return handleInput(state, '');
1177
1177
  };
1178
1178
 
1179
- const closeSuggest = () => {
1180
- // TODO
1179
+ const closeSuggest = state => {
1180
+ return state;
1181
1181
  };
1182
1182
 
1183
1183
  const states = Object.create(null);
@@ -1216,7 +1216,8 @@ const create = (id, uri, x, y, width, height, platform, assetDir) => {
1216
1216
  size: 0,
1217
1217
  width,
1218
1218
  x,
1219
- y
1219
+ y,
1220
+ focused: false
1220
1221
  };
1221
1222
  set$1(id, state, state);
1222
1223
  };
@@ -1362,7 +1363,7 @@ const focusNext = state => {
1362
1363
  return focusIndex(state, nextIndex);
1363
1364
  };
1364
1365
 
1365
- const focusNextPage = async state => {
1366
+ const focusNextPage = state => {
1366
1367
  const {
1367
1368
  focusedIndex,
1368
1369
  items,
@@ -1376,7 +1377,7 @@ const focusNextPage = async state => {
1376
1377
  return focusIndex(state, indexNextPage);
1377
1378
  };
1378
1379
 
1379
- const focusPreviousPage = async state => {
1380
+ const focusPreviousPage = state => {
1380
1381
  const {
1381
1382
  focusedIndex,
1382
1383
  minLineY,
@@ -1410,7 +1411,7 @@ const getActions = () => {
1410
1411
  }];
1411
1412
  };
1412
1413
 
1413
- const commandIds = ['clearSearchResults', 'closeSuggest', 'closeSuggest', 'focusFirst', 'focusLast', 'focusNext', 'focusNextPage', 'focusPrevious', 'focusPreviousPage', 'handleBlur', 'handleBlur', 'handleBlur', 'handleContextMenu', 'handleDisable', 'handleFocus', 'handleFocus', 'handleInput', 'handleInstall', 'handleScrollBarCaptureLost', 'handleScrollBarClick', 'handleScrollBarMove', 'handleUninstall', 'handleWheel', 'openSuggest', 'openSuggest', 'render', 'saveState', 'scrollDown', 'selectIndex', 'setDeltaY', 'toggleSuggest', 'toggleSuggest'];
1414
+ const commandIds = ['clearSearchResults', 'closeSuggest', 'focusFirst', 'focusLast', 'focusNext', 'focusNextPage', 'focusPrevious', 'focusPreviousPage', 'handleBlur', 'handleClick', 'handleContextMenu', 'handleDisable', 'handleFocus', 'handleInput', 'handleInstall', 'handleScrollBarCaptureLost', 'handleScrollBarClick', 'handleScrollBarMove', 'handleUninstall', 'handleWheel', 'openSuggest', 'render', 'saveState', 'scrollDown', 'selectIndex', 'setDeltaY', 'toggleSuggest'];
1414
1415
 
1415
1416
  const getCommandIds = () => {
1416
1417
  return commandIds;
@@ -1473,8 +1474,8 @@ const getKeyBindings = () => {
1473
1474
  }];
1474
1475
  };
1475
1476
 
1476
- const handleBlur = () => {
1477
- // TODO
1477
+ const handleBlur = state => {
1478
+ return state;
1478
1479
  };
1479
1480
 
1480
1481
  const RendererWorker = 1;
@@ -1509,6 +1510,30 @@ const handleClick = async (state, index) => {
1509
1510
  return focusIndex(state, actualIndex);
1510
1511
  };
1511
1512
 
1513
+ const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight) => {
1514
+ const relativeY = eventY - y + deltaY;
1515
+ const index = Math.floor(relativeY / itemHeight);
1516
+ return index;
1517
+ };
1518
+
1519
+ const selectIndex = (state, index) => {
1520
+ return {
1521
+ ...state,
1522
+ focusedIndex: index
1523
+ };
1524
+ };
1525
+
1526
+ const handleClickAt = async (state, eventX, eventY) => {
1527
+ const {
1528
+ x,
1529
+ y,
1530
+ itemHeight,
1531
+ deltaY
1532
+ } = state;
1533
+ const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight);
1534
+ return selectIndex(state, index);
1535
+ };
1536
+
1512
1537
  const handleClickCurrent = state => {
1513
1538
  const {
1514
1539
  focusedIndex
@@ -1539,23 +1564,26 @@ const handleContextMenu = async (state, button, x, y) => {
1539
1564
  };
1540
1565
 
1541
1566
  const handleDisable = (state, id) => {
1567
+ return state;
1542
1568
  // TODO
1543
1569
  };
1544
1570
 
1545
1571
  const handleEnable = (state, id) => {
1546
- // TODO
1572
+ return state;
1547
1573
  };
1548
1574
 
1549
1575
  const setFocus = async focusId => {
1550
1576
  await invoke('Focus.setFocus', focusId);
1551
1577
  };
1552
1578
 
1553
- const handleFocus = async () => {
1579
+ const handleFocus = async state => {
1554
1580
  await setFocus(FocusExtensions);
1581
+ return state;
1555
1582
  };
1556
1583
 
1557
1584
  // TODO show error / warning when installment fails / times out
1558
1585
  const handleInstall = async (state, id) => {
1586
+ return state;
1559
1587
  // TODO
1560
1588
  };
1561
1589
 
@@ -1686,7 +1714,7 @@ const handleScrollBarMove = (state, eventY) => {
1686
1714
 
1687
1715
  // TODO show error / warning when installment fails / times out
1688
1716
  const handleUninstall = async (state, id) => {
1689
- // TODO
1717
+ return state;
1690
1718
  };
1691
1719
 
1692
1720
  const handleWheel = (state, deltaMode, deltaY) => {
@@ -1751,8 +1779,8 @@ const loadContent = async (uid, savedState) => {
1751
1779
  set$1(uid, newState, updatedState);
1752
1780
  };
1753
1781
 
1754
- const openSuggest = () => {
1755
- // TODO
1782
+ const openSuggest = state => {
1783
+ return state;
1756
1784
  };
1757
1785
 
1758
1786
  const Actions = 'Actions';
@@ -2295,15 +2323,8 @@ const scrollDown = state => {
2295
2323
  return setDeltaY(state, newDeltaY);
2296
2324
  };
2297
2325
 
2298
- const selectIndex = (state, index) => {
2299
- return {
2300
- ...state,
2301
- focusedIndex: index
2302
- };
2303
- };
2304
-
2305
- const toggleSuggest = () => {
2306
- // TODO
2326
+ const toggleSuggest = state => {
2327
+ return state;
2307
2328
  };
2308
2329
 
2309
2330
  const wrapCommand = fn => {
@@ -2329,16 +2350,18 @@ const commandMap = {
2329
2350
  'SearchExtensions.focusNextPage': wrapCommand(focusNextPage),
2330
2351
  'SearchExtensions.focusPreviousPage': wrapCommand(focusPreviousPage),
2331
2352
  'SearchExtensions.getActions': getActions,
2353
+ 'SearchExtensions.getCommandIds': getCommandIds,
2332
2354
  'SearchExtensions.getKeyBindings': getKeyBindings,
2333
2355
  'SearchExtensions.handleBlur': wrapCommand(handleBlur),
2334
- 'SearchExtensions.handleInput': wrapCommand(handleInput),
2335
2356
  'SearchExtensions.handleClick': wrapCommand(handleClick),
2357
+ 'SearchExtensions.handleClickAt': wrapCommand(handleClickAt),
2336
2358
  'SearchExtensions.handleClickCurrent': wrapCommand(handleClickCurrent),
2337
2359
  'SearchExtensions.handleClickCurrentButKeepFocus': wrapCommand(handleClickCurrentButKeepFocus),
2338
2360
  'SearchExtensions.handleContextMenu': wrapCommand(handleContextMenu),
2339
2361
  'SearchExtensions.handleDisable': wrapCommand(handleDisable),
2340
2362
  'SearchExtensions.handleEnable': wrapCommand(handleEnable),
2341
2363
  'SearchExtensions.handleFocus': wrapCommand(handleFocus),
2364
+ 'SearchExtensions.handleInput': wrapCommand(handleInput),
2342
2365
  'SearchExtensions.handleInstall': wrapCommand(handleInstall),
2343
2366
  'SearchExtensions.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
2344
2367
  'SearchExtensions.handleScrollBarClick': wrapCommand(handleScrollBarClick),
@@ -2346,7 +2369,6 @@ const commandMap = {
2346
2369
  'SearchExtensions.handleUninstall': wrapCommand(handleUninstall),
2347
2370
  'SearchExtensions.handleWheel': wrapCommand(handleWheel),
2348
2371
  'SearchExtensions.loadContent': loadContent,
2349
- 'SearchExtensions.getCommandIds': getCommandIds,
2350
2372
  'SearchExtensions.openSuggest': wrapCommand(openSuggest),
2351
2373
  'SearchExtensions.render': doRender,
2352
2374
  'SearchExtensions.render2': render2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "2.6.0",
3
+ "version": "2.8.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "license": "MIT",
6
6
  "author": "Lvce Editor",