@lvce-editor/title-bar-worker 4.13.0 → 4.14.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 CHANGED
@@ -10,7 +10,3 @@ cd text-search-worker &&
10
10
  npm ci &&
11
11
  npm test
12
12
  ```
13
-
14
- ## Gitpod
15
-
16
- [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/lvce-editor/title-bar-worker)
@@ -1134,6 +1134,7 @@ const create$2 = rpcId => {
1134
1134
  };
1135
1135
  };
1136
1136
 
1137
+ const Button$2 = 'button';
1137
1138
  const ContentInfo = 'contentinfo';
1138
1139
  const Menu$1 = 'menu';
1139
1140
  const MenuBar$1 = 'menubar';
@@ -1314,6 +1315,7 @@ const VirtualDomElements = {
1314
1315
  const Button = 'event.button';
1315
1316
  const ClientX = 'event.clientX';
1316
1317
  const ClientY = 'event.clientY';
1318
+ const Key = 'event.key';
1317
1319
  const TargetName = 'event.target.name';
1318
1320
 
1319
1321
  const Backspace$1 = 1;
@@ -1891,6 +1893,8 @@ const HandleMenuClick = 9;
1891
1893
  const HandleMenuMouseOver = 10;
1892
1894
  const HandleContextMenu = 11;
1893
1895
  const HandleTitleBarContextMenu = 12;
1896
+ const HandleCommandCenterClick = 13;
1897
+ const HandleCommandCenterKeyDown = 14;
1894
1898
 
1895
1899
  const emptyObject = {};
1896
1900
  const i18nString = (key, placeholders = emptyObject) => {
@@ -2023,6 +2027,9 @@ const menuBar = () => {
2023
2027
  const commandCenter = () => {
2024
2028
  return i18nString(CommandCenter);
2025
2029
  };
2030
+ const search = () => {
2031
+ return i18nString(Search);
2032
+ };
2026
2033
  const layoutControls = () => {
2027
2034
  return i18nString(LayoutControls);
2028
2035
  };
@@ -2142,7 +2149,7 @@ const create3 = (id, uri, x, y, width, height, platform, controlsOverlayEnabled,
2142
2149
  };
2143
2150
 
2144
2151
  const isEqual$3 = (oldState, newState) => {
2145
- return oldState.titleBarEntries === newState.titleBarEntries && oldState.titleBarMenuBarEnabled === newState.titleBarMenuBarEnabled && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen && oldState.title === newState.title && oldState.workspaceUri === newState.workspaceUri;
2152
+ return oldState.commandCenterEnabled === newState.commandCenterEnabled && oldState.titleBarEntries === newState.titleBarEntries && oldState.titleBarMenuBarEnabled === newState.titleBarMenuBarEnabled && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen && oldState.title === newState.title && oldState.workspaceUri === newState.workspaceUri;
2146
2153
  };
2147
2154
 
2148
2155
  const isEqual$2 = (oldState, newState) => {
@@ -3391,6 +3398,44 @@ const handleClick$1 = async (state, buttonName) => {
3391
3398
  return state;
3392
3399
  };
3393
3400
 
3401
+ const commandCenterItems = [{
3402
+ label: 'Go to File',
3403
+ value: 'file'
3404
+ }, {
3405
+ label: 'Show and Run Commands',
3406
+ value: 'commands'
3407
+ }, {
3408
+ label: 'Search for Text',
3409
+ value: 'search'
3410
+ }, {
3411
+ label: 'Go to Symbol in Editor',
3412
+ value: 'symbol'
3413
+ }, {
3414
+ label: 'Start Debugging',
3415
+ value: 'debug'
3416
+ }, {
3417
+ label: 'Run Task',
3418
+ value: 'task'
3419
+ }, {
3420
+ label: 'More',
3421
+ value: 'more'
3422
+ }];
3423
+ const handleCommandCenterClick = async state => {
3424
+ await invoke('QuickPick.showCustom', commandCenterItems, {
3425
+ mode: 'quickPick',
3426
+ placeholder: 'Search files by name (append : to go to line or @ to go to symbol)',
3427
+ waitUntil: 'visible'
3428
+ });
3429
+ return state;
3430
+ };
3431
+
3432
+ const handleCommandCenterKeyDown = async (state, key) => {
3433
+ if (key !== 'Enter' && key !== ' ' && key !== 'Space') {
3434
+ return state;
3435
+ }
3436
+ return handleCommandCenterClick(state);
3437
+ };
3438
+
3394
3439
  const show2 = async (uid, menuId, x, y, args) => {
3395
3440
  await showContextMenu2(uid, menuId, x, y, args);
3396
3441
  };
@@ -3777,15 +3822,23 @@ const parseTitleTemplate = (template, folderName, appName) => {
3777
3822
  return template.replaceAll('${folderName}', () => folderName).replaceAll('${appName}', () => appName);
3778
3823
  };
3779
3824
 
3825
+ const getEndIndex = workspaceUri => {
3826
+ let endIndex = workspaceUri.length;
3827
+ while (endIndex > 0 && workspaceUri[endIndex - 1] === '/') {
3828
+ endIndex--;
3829
+ }
3830
+ return endIndex;
3831
+ };
3780
3832
  const getTitle = (workspaceUri, titleTemplate, appName) => {
3781
3833
  if (!workspaceUri) {
3782
3834
  return '';
3783
3835
  }
3784
- const slashIndex = workspaceUri.lastIndexOf('/');
3836
+ const endIndex = getEndIndex(workspaceUri);
3837
+ const slashIndex = workspaceUri.lastIndexOf('/', endIndex - 1);
3785
3838
  if (slashIndex === -1) {
3786
3839
  return '';
3787
3840
  }
3788
- const folderName = workspaceUri.slice(slashIndex + 1);
3841
+ const folderName = workspaceUri.slice(slashIndex + 1, endIndex);
3789
3842
 
3790
3843
  // If titleTemplate is empty, return folderName directly
3791
3844
  if (!titleTemplate) {
@@ -3982,6 +4035,7 @@ const MenuItemSubMenuArrowRight = 'MenuItemSubMenuArrowRight';
3982
4035
  const TitleBar = 'TitleBar';
3983
4036
  const TitleBarButton = 'TitleBarButton';
3984
4037
  const TitleBarButtons = 'TitleBarButtons';
4038
+ const TitleBarCommandCenter = 'TitleBarCommandCenter';
3985
4039
  const TitleBarEntryActive = 'TitleBarEntryActive';
3986
4040
  const TitleBarIcon = 'TitleBarIcon';
3987
4041
  const TitleBarIconIcon = 'TitleBarIconIcon';
@@ -4269,6 +4323,24 @@ const renderMenus = (oldState, newState) => {
4269
4323
  return ['Viewlet.send', uid, /* method */SetMenus, /* changes */changes, uid];
4270
4324
  };
4271
4325
 
4326
+ const Focusable = 0;
4327
+
4328
+ const getCommandCenterVirtualDom = commandCenterEnabled => {
4329
+ if (!commandCenterEnabled) {
4330
+ return [];
4331
+ }
4332
+ return [{
4333
+ ariaLabel: commandCenter(),
4334
+ childCount: 1,
4335
+ className: TitleBarCommandCenter,
4336
+ onClick: HandleCommandCenterClick,
4337
+ onKeyDown: HandleCommandCenterKeyDown,
4338
+ role: Button$2,
4339
+ tabIndex: Focusable,
4340
+ type: Div
4341
+ }, text(search())];
4342
+ };
4343
+
4272
4344
  const getIcon = assetDir => {
4273
4345
  return `${assetDir}/icons/icon.svg`;
4274
4346
  };
@@ -4410,6 +4482,7 @@ const emptyTitleBarNode = {
4410
4482
  const getTitleBarVirtualDom = state => {
4411
4483
  const {
4412
4484
  assetDir,
4485
+ commandCenterEnabled,
4413
4486
  focusedIndex,
4414
4487
  isMenuOpen,
4415
4488
  platform,
@@ -4428,7 +4501,8 @@ const getTitleBarVirtualDom = state => {
4428
4501
  }
4429
4502
  const iconSrc = getIcon(assetDir);
4430
4503
  const visibleEntries = getVisibleTitleBarEntries(titleBarEntries, width, focusedIndex, isMenuOpen);
4431
- const childCount = Number(titleBarIconEnabled) + Number(titleBarMenuBarEnabled) + Number(titleBarTitleEnabled) + Number(titleBarButtonsEnabled);
4504
+ const titleEnabled = titleBarTitleEnabled && !commandCenterEnabled;
4505
+ const childCount = Number(titleBarIconEnabled) + Number(titleBarMenuBarEnabled) + Number(commandCenterEnabled) + Number(titleEnabled) + Number(titleBarButtonsEnabled);
4432
4506
  return [{
4433
4507
  ariaLabel: titleBar(),
4434
4508
  childCount,
@@ -4437,7 +4511,7 @@ const getTitleBarVirtualDom = state => {
4437
4511
  onContextMenu: HandleTitleBarContextMenu,
4438
4512
  role: ContentInfo,
4439
4513
  type: Div
4440
- }, ...getTitleBarIconVirtualDom(titleBarIconEnabled, iconSrc), ...getTitleBarMenuBarVirtualDom(titleBarMenuBarEnabled, visibleEntries, focusedIndex), ...getTitleVirtualDom(titleBarTitleEnabled, title), ...getTitleBarButtonsVirtualDom(titleBarButtonsEnabled, titleBarButtons)];
4514
+ }, ...getTitleBarIconVirtualDom(titleBarIconEnabled, iconSrc), ...getTitleBarMenuBarVirtualDom(titleBarMenuBarEnabled, visibleEntries, focusedIndex), ...getCommandCenterVirtualDom(commandCenterEnabled), ...getTitleVirtualDom(titleEnabled, title), ...getTitleBarButtonsVirtualDom(titleBarButtonsEnabled, titleBarButtons)];
4441
4515
  };
4442
4516
 
4443
4517
  const renderTitleBar = (oldState, newState) => {
@@ -4495,6 +4569,12 @@ const renderEventListeners = () => {
4495
4569
  }, {
4496
4570
  name: HandleClickToggleMaximize,
4497
4571
  params: ['handleClickToggleMaximize']
4572
+ }, {
4573
+ name: HandleCommandCenterClick,
4574
+ params: ['handleCommandCenterClick']
4575
+ }, {
4576
+ name: HandleCommandCenterKeyDown,
4577
+ params: ['handleCommandCenterKeyDown', Key]
4498
4578
  }, {
4499
4579
  name: HandleFocusIn,
4500
4580
  params: ['handleFocus']
@@ -5222,6 +5302,8 @@ const commandMap = {
5222
5302
  'TitleBar.handleClickClose': wrapCommand(handleClickClose),
5223
5303
  'TitleBar.handleClickMinimize': wrapCommand(handleClickMinimize),
5224
5304
  'TitleBar.handleClickToggleMaximize': wrapCommand(handleClickToggleMaximize),
5305
+ 'TitleBar.handleCommandCenterClick': wrapCommand(handleCommandCenterClick),
5306
+ 'TitleBar.handleCommandCenterKeyDown': wrapCommand(handleCommandCenterKeyDown),
5225
5307
  'TitleBar.handleContextMenu': wrapCommand(handleContextMenu),
5226
5308
  'TitleBar.handleElectronMenuClick': wrapCommand(handleElectronMenuClick),
5227
5309
  'TitleBar.handleFocus': wrapCommand(handleFocus),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/title-bar-worker",
3
- "version": "4.13.0",
3
+ "version": "4.14.0",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",