@lvce-editor/title-bar-worker 4.9.1 → 4.10.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/titleBarWorkerMain.js +28 -21
- package/package.json +1 -1
|
@@ -3968,6 +3968,7 @@ const renderFocusedIndex = (oldState, newState) => {
|
|
|
3968
3968
|
};
|
|
3969
3969
|
|
|
3970
3970
|
const MaskIconCheck = 'MaskIconCheck';
|
|
3971
|
+
const MaskIcon = 'MaskIcon';
|
|
3971
3972
|
const Menu = 'Menu';
|
|
3972
3973
|
const MenuItem = 'MenuItem';
|
|
3973
3974
|
const MenuItemCheckMark = 'MenuItemCheckMark';
|
|
@@ -3979,6 +3980,7 @@ const MenuItemSeparatorLine = 'MenuItemSeparatorLine';
|
|
|
3979
3980
|
const MenuItemSubMenu = 'MenuItemSubMenu';
|
|
3980
3981
|
const MenuItemSubMenuArrowRight = 'MenuItemSubMenuArrowRight';
|
|
3981
3982
|
const TitleBar = 'TitleBar';
|
|
3983
|
+
const TitleBarButton = 'TitleBarButton';
|
|
3982
3984
|
const TitleBarButtons = 'TitleBarButtons';
|
|
3983
3985
|
const TitleBarEntryActive = 'TitleBarEntryActive';
|
|
3984
3986
|
const TitleBarIcon = 'TitleBarIcon';
|
|
@@ -4030,16 +4032,17 @@ const getKeyLabel = (keyCode, fallback) => {
|
|
|
4030
4032
|
};
|
|
4031
4033
|
|
|
4032
4034
|
const altKeyMask = 1 << 9;
|
|
4035
|
+
const keyBindingNode = {
|
|
4036
|
+
childCount: 1,
|
|
4037
|
+
className: MenuItemKeyBinding,
|
|
4038
|
+
type: Span
|
|
4039
|
+
};
|
|
4033
4040
|
const getKeyDom = key => {
|
|
4034
4041
|
const parsedKey = parseKey(key);
|
|
4035
4042
|
const isAlt = Boolean(key & altKeyMask);
|
|
4036
4043
|
const keyLabel = getKeyLabel(key & 0xff, parsedKey.key);
|
|
4037
4044
|
const keyBindingsString = getKeyBindingString(keyLabel, isAlt, parsedKey.isCtrl, parsedKey.isShift);
|
|
4038
|
-
return [
|
|
4039
|
-
childCount: 1,
|
|
4040
|
-
className: MenuItemKeyBinding,
|
|
4041
|
-
type: Span
|
|
4042
|
-
}, text(keyBindingsString)];
|
|
4045
|
+
return [keyBindingNode, text(keyBindingsString)];
|
|
4043
4046
|
};
|
|
4044
4047
|
|
|
4045
4048
|
const checkMark = {
|
|
@@ -4273,7 +4276,7 @@ const getIcon = assetDir => {
|
|
|
4273
4276
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
4274
4277
|
return {
|
|
4275
4278
|
childCount: 0,
|
|
4276
|
-
className:
|
|
4279
|
+
className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
|
|
4277
4280
|
role: None$1,
|
|
4278
4281
|
type
|
|
4279
4282
|
};
|
|
@@ -4289,7 +4292,7 @@ const createTitleBarButton = button => {
|
|
|
4289
4292
|
const dom = [{
|
|
4290
4293
|
ariaLabel: label,
|
|
4291
4294
|
childCount: 1,
|
|
4292
|
-
className:
|
|
4295
|
+
className: mergeClassNames(TitleBarButton, `TitleBarButton${id}`),
|
|
4293
4296
|
name: id,
|
|
4294
4297
|
onClick,
|
|
4295
4298
|
type: Button$1
|
|
@@ -4326,6 +4329,11 @@ const getTitleBarIconVirtualDom = (titleBarIconEnabled, iconSrc) => {
|
|
|
4326
4329
|
}];
|
|
4327
4330
|
};
|
|
4328
4331
|
|
|
4332
|
+
const activeEntryLabelNode = {
|
|
4333
|
+
childCount: 1,
|
|
4334
|
+
className: TitleBarTopLevelEntryLabel,
|
|
4335
|
+
type: Div
|
|
4336
|
+
};
|
|
4329
4337
|
const getItemVirtualDom = item => {
|
|
4330
4338
|
// @ts-ignore
|
|
4331
4339
|
const {
|
|
@@ -4335,10 +4343,7 @@ const getItemVirtualDom = item => {
|
|
|
4335
4343
|
keyboardShortCut,
|
|
4336
4344
|
label
|
|
4337
4345
|
} = item;
|
|
4338
|
-
|
|
4339
|
-
if (isFocused) {
|
|
4340
|
-
className += ' ' + TitleBarEntryActive;
|
|
4341
|
-
}
|
|
4346
|
+
const className = isFocused ? mergeClassNames(TitleBarTopLevelEntry, TitleBarEntryActive) : TitleBarTopLevelEntry;
|
|
4342
4347
|
return [{
|
|
4343
4348
|
ariaExpanded: isOpen,
|
|
4344
4349
|
ariaHasPopup: true,
|
|
@@ -4352,11 +4357,7 @@ const getItemVirtualDom = item => {
|
|
|
4352
4357
|
// TODO have separate name attribute
|
|
4353
4358
|
role: MenuItem$1,
|
|
4354
4359
|
type: Button$1
|
|
4355
|
-
}, ...(isFocused ? [
|
|
4356
|
-
childCount: 1,
|
|
4357
|
-
className: TitleBarTopLevelEntryLabel,
|
|
4358
|
-
type: Div
|
|
4359
|
-
}] : []), text(label)];
|
|
4360
|
+
}, ...(isFocused ? [activeEntryLabelNode] : []), text(label)];
|
|
4360
4361
|
};
|
|
4361
4362
|
const getTitleBarMenuBarItemsVirtualDom = visibleItems => {
|
|
4362
4363
|
const dom = visibleItems.flatMap(getItemVirtualDom);
|
|
@@ -4396,6 +4397,10 @@ const getTitleVirtualDom = (titleBarTitleEnabled, title) => {
|
|
|
4396
4397
|
return [parentNode, text(title)];
|
|
4397
4398
|
};
|
|
4398
4399
|
|
|
4400
|
+
const emptyTitleBarNode = {
|
|
4401
|
+
childCount: 0,
|
|
4402
|
+
type: Div
|
|
4403
|
+
};
|
|
4399
4404
|
const getTitleBarVirtualDom = state => {
|
|
4400
4405
|
const {
|
|
4401
4406
|
assetDir,
|
|
@@ -4413,10 +4418,7 @@ const getTitleBarVirtualDom = state => {
|
|
|
4413
4418
|
width
|
|
4414
4419
|
} = state;
|
|
4415
4420
|
if (platform === Electron$1 && !titleBarStyleCustom) {
|
|
4416
|
-
return [
|
|
4417
|
-
childCount: 0,
|
|
4418
|
-
type: Div
|
|
4419
|
-
}];
|
|
4421
|
+
return [emptyTitleBarNode];
|
|
4420
4422
|
}
|
|
4421
4423
|
const iconSrc = getIcon(assetDir);
|
|
4422
4424
|
const visibleEntries = getVisibleTitleBarEntries(titleBarEntries, width, focusedIndex, isMenuOpen);
|
|
@@ -4617,12 +4619,17 @@ const create = (id, uri, x, y, width, height) => {
|
|
|
4617
4619
|
|
|
4618
4620
|
const closeMenu = (state, keepFocus) => {
|
|
4619
4621
|
const {
|
|
4620
|
-
focusedIndex
|
|
4622
|
+
focusedIndex,
|
|
4623
|
+
isMenuOpen,
|
|
4624
|
+
menus
|
|
4621
4625
|
} = state;
|
|
4622
4626
|
// TODO send to renderer process
|
|
4623
4627
|
// 1. close menu
|
|
4624
4628
|
// 2. focus top level entry
|
|
4625
4629
|
const newFocusedIndex = keepFocus ? focusedIndex : -1;
|
|
4630
|
+
if (!isMenuOpen && menus.length === 0 && focusedIndex === newFocusedIndex) {
|
|
4631
|
+
return state;
|
|
4632
|
+
}
|
|
4626
4633
|
return {
|
|
4627
4634
|
...state,
|
|
4628
4635
|
focusedIndex: newFocusedIndex,
|