@lvce-editor/title-bar-worker 2.7.0 → 2.9.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 +61 -34
- package/package.json +2 -1
|
@@ -1031,6 +1031,8 @@ const diff = (oldState, newState) => {
|
|
|
1031
1031
|
const {
|
|
1032
1032
|
get: get$1,
|
|
1033
1033
|
set: set$3,
|
|
1034
|
+
getCommandIds,
|
|
1035
|
+
registerCommands,
|
|
1034
1036
|
wrapCommand
|
|
1035
1037
|
} = create$2();
|
|
1036
1038
|
|
|
@@ -1042,12 +1044,6 @@ const diff2 = uid => {
|
|
|
1042
1044
|
return diff(oldState, newState);
|
|
1043
1045
|
};
|
|
1044
1046
|
|
|
1045
|
-
const commandsIds = ['closeMenu', 'handleClickAt', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleClick', 'handleFocus', 'handleFocusOut', 'handleKeyArrowDown', 'handleKeyArrowLeft', 'handleKeyArrowRight', 'handleKeyArrowUp', 'handleKeyEnd', 'handleKeyEnter', 'handleKeyEscape', 'handleKeyHome', 'handleKeySpace', 'handleMenuClick', 'handleMenuMouseOver', 'handleMouseOut', 'handleMouseOver', 'handlePointerOver', 'handlePointerOut', 'toggleIndex', 'toggleMenu'];
|
|
1046
|
-
|
|
1047
|
-
const getCommandIds = () => {
|
|
1048
|
-
return commandsIds;
|
|
1049
|
-
};
|
|
1050
|
-
|
|
1051
1047
|
const Menu$1 = 'menu';
|
|
1052
1048
|
const MenuBar = 'menubar';
|
|
1053
1049
|
const MenuItem$1 = 'menuitem';
|
|
@@ -1055,13 +1051,17 @@ const MenuItemCheckBox = 'menuitemcheckbox';
|
|
|
1055
1051
|
const None$1 = 'none';
|
|
1056
1052
|
const Separator$1 = 'separator';
|
|
1057
1053
|
|
|
1058
|
-
const Button = 1;
|
|
1054
|
+
const Button$1 = 1;
|
|
1059
1055
|
const Div = 4;
|
|
1060
1056
|
const Span = 8;
|
|
1061
1057
|
const Text = 12;
|
|
1062
1058
|
const I = 16;
|
|
1063
1059
|
const Img = 17;
|
|
1064
1060
|
|
|
1061
|
+
const Button = 'event.button';
|
|
1062
|
+
const ClientX = 'event.clientX';
|
|
1063
|
+
const ClientY = 'event.clientY';
|
|
1064
|
+
|
|
1065
1065
|
const Escape$2 = 8;
|
|
1066
1066
|
const Space$2 = 9;
|
|
1067
1067
|
const End$2 = 255;
|
|
@@ -2210,7 +2210,7 @@ const createTitleBarButton = button => {
|
|
|
2210
2210
|
onClick
|
|
2211
2211
|
} = button;
|
|
2212
2212
|
const dom = [{
|
|
2213
|
-
type: Button,
|
|
2213
|
+
type: Button$1,
|
|
2214
2214
|
className: `TitleBarButton TitleBarButton${id}`,
|
|
2215
2215
|
ariaLabel: label,
|
|
2216
2216
|
childCount: 1,
|
|
@@ -3028,6 +3028,16 @@ const parseKey = rawKey => {
|
|
|
3028
3028
|
};
|
|
3029
3029
|
};
|
|
3030
3030
|
|
|
3031
|
+
const getKeyDom = key => {
|
|
3032
|
+
const parsedKey = parseKey(key);
|
|
3033
|
+
const keyBindingsString = getKeyBindingString(parsedKey.key, false, parsedKey.isCtrl, parsedKey.isShift);
|
|
3034
|
+
return [{
|
|
3035
|
+
type: Span,
|
|
3036
|
+
className: MenuItemKeyBinding,
|
|
3037
|
+
childCount: 1
|
|
3038
|
+
}, text(keyBindingsString)];
|
|
3039
|
+
};
|
|
3040
|
+
|
|
3031
3041
|
const classNameFocused = mergeClassNames(MenuItem, MenuItemFocused);
|
|
3032
3042
|
const getMenuItemClassName = isFocused => {
|
|
3033
3043
|
if (isFocused) {
|
|
@@ -3042,25 +3052,15 @@ const getMenuItemDefaultDom = menuItem => {
|
|
|
3042
3052
|
key
|
|
3043
3053
|
} = menuItem;
|
|
3044
3054
|
const className = getMenuItemClassName(isFocused);
|
|
3045
|
-
const
|
|
3046
|
-
|
|
3055
|
+
const keyDom = key ? getKeyDom(key) : [];
|
|
3056
|
+
const childCount = key ? 2 : 1;
|
|
3057
|
+
return [{
|
|
3047
3058
|
type: Div,
|
|
3048
3059
|
className,
|
|
3049
3060
|
role: MenuItem$1,
|
|
3050
3061
|
tabIndex: -1,
|
|
3051
|
-
childCount
|
|
3052
|
-
}, text(label)
|
|
3053
|
-
if (key) {
|
|
3054
|
-
dom[0].childCount++;
|
|
3055
|
-
const parsedKey = parseKey(key);
|
|
3056
|
-
const keyBindingsString = getKeyBindingString(parsedKey.key, false, parsedKey.isCtrl, parsedKey.isShift);
|
|
3057
|
-
dom.push({
|
|
3058
|
-
type: Span,
|
|
3059
|
-
className: MenuItemKeyBinding,
|
|
3060
|
-
childCount: 1
|
|
3061
|
-
}, text(keyBindingsString));
|
|
3062
|
-
}
|
|
3063
|
-
return dom;
|
|
3062
|
+
childCount
|
|
3063
|
+
}, text(label), ...keyDom];
|
|
3064
3064
|
};
|
|
3065
3065
|
|
|
3066
3066
|
const disabled = {
|
|
@@ -3109,11 +3109,8 @@ const getMenuItemSubMenuDom = menuItem => {
|
|
|
3109
3109
|
isExpanded,
|
|
3110
3110
|
level
|
|
3111
3111
|
} = menuItem;
|
|
3112
|
-
|
|
3113
|
-
className
|
|
3114
|
-
if (isFocused) {
|
|
3115
|
-
className += ' ' + MenuItemFocused;
|
|
3116
|
-
}
|
|
3112
|
+
const baseClassName = mergeClassNames(MenuItem, MenuItemSubMenu);
|
|
3113
|
+
const className = isFocused ? mergeClassNames(baseClassName, MenuItemFocused) : baseClassName;
|
|
3117
3114
|
return [{
|
|
3118
3115
|
type: Div,
|
|
3119
3116
|
className,
|
|
@@ -3281,22 +3278,22 @@ const renderEventListeners = () => {
|
|
|
3281
3278
|
params: ['handleFocus']
|
|
3282
3279
|
}, {
|
|
3283
3280
|
name: HandleMenuClick,
|
|
3284
|
-
params: ['handleMenuClick',
|
|
3281
|
+
params: ['handleMenuClick', ClientX, ClientY]
|
|
3285
3282
|
}, {
|
|
3286
3283
|
name: HandleMenuMouseOver,
|
|
3287
|
-
params: ['handleMenuMouseOver',
|
|
3284
|
+
params: ['handleMenuMouseOver', ClientX, ClientY]
|
|
3288
3285
|
}, {
|
|
3289
3286
|
name: HandleClick,
|
|
3290
|
-
params: ['handleClickAt',
|
|
3287
|
+
params: ['handleClickAt', Button, ClientX, ClientY]
|
|
3291
3288
|
}, {
|
|
3292
3289
|
name: HandlePointerOut,
|
|
3293
|
-
params: ['handlePointerOut',
|
|
3290
|
+
params: ['handlePointerOut', ClientX, ClientY]
|
|
3294
3291
|
}, {
|
|
3295
3292
|
name: HandlePointerOver,
|
|
3296
|
-
params: ['handlePointerOver',
|
|
3293
|
+
params: ['handlePointerOver', ClientX, ClientY]
|
|
3297
3294
|
}, {
|
|
3298
3295
|
name: HandleFocusOut,
|
|
3299
|
-
params: ['handleFocusOut',
|
|
3296
|
+
params: ['handleFocusOut', ClientX, ClientY] // TODO maybe check relatedTarget
|
|
3300
3297
|
}];
|
|
3301
3298
|
};
|
|
3302
3299
|
|
|
@@ -3306,8 +3303,37 @@ const saveState = uid => {
|
|
|
3306
3303
|
};
|
|
3307
3304
|
};
|
|
3308
3305
|
|
|
3306
|
+
const DEFAULT_UID = 1;
|
|
3307
|
+
const createDefaultState = (uid = DEFAULT_UID) => ({
|
|
3308
|
+
assetDir: '',
|
|
3309
|
+
focusedIndex: -1,
|
|
3310
|
+
height: 30,
|
|
3311
|
+
iconWidth: 30,
|
|
3312
|
+
isMenuOpen: false,
|
|
3313
|
+
itleBarIconEnabled: true,
|
|
3314
|
+
labelFontFamily: 'system-ui, Ubuntu, Droid Sans, sans-serif',
|
|
3315
|
+
labelFontSize: 13,
|
|
3316
|
+
labelFontWeight: 400,
|
|
3317
|
+
labelLetterSpacing: 0,
|
|
3318
|
+
labelPadding: 8,
|
|
3319
|
+
menus: [],
|
|
3320
|
+
titleBarButtonsEnabled: true,
|
|
3321
|
+
titleBarButtonsWidth: 90,
|
|
3322
|
+
titleBarEntries: [],
|
|
3323
|
+
titleBarHeight: 30,
|
|
3324
|
+
titleBarIconWidth: 30,
|
|
3325
|
+
titleBarMenuBarEnabled: true,
|
|
3326
|
+
titleBarTitleEnabled: true,
|
|
3327
|
+
uid,
|
|
3328
|
+
width: 800,
|
|
3329
|
+
x: 0,
|
|
3330
|
+
y: 0,
|
|
3331
|
+
title: ''
|
|
3332
|
+
});
|
|
3333
|
+
|
|
3309
3334
|
const create = (id, uri, x, y, width, height) => {
|
|
3310
3335
|
const state = {
|
|
3336
|
+
...createDefaultState(),
|
|
3311
3337
|
uid: id,
|
|
3312
3338
|
titleBarEntries: [],
|
|
3313
3339
|
focusedIndex: -1,
|
|
@@ -3859,6 +3885,7 @@ const commandMap = {
|
|
|
3859
3885
|
};
|
|
3860
3886
|
|
|
3861
3887
|
const listen = async () => {
|
|
3888
|
+
registerCommands(commandMap);
|
|
3862
3889
|
const rpc = await WebWorkerRpcClient.create({
|
|
3863
3890
|
commandMap: commandMap
|
|
3864
3891
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/title-bar-worker",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "Title Bar Worker",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "dist/titleBarWorkerMain.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
+
"@lvce-editor/constants": "^1.26.0",
|
|
14
15
|
"@lvce-editor/viewlet-registry": "^1.4.0"
|
|
15
16
|
}
|
|
16
17
|
}
|