@univerjs/ui 1.2.0 → 1.3.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/lib/cjs/index.js +765 -525
- package/lib/cjs/locale/ar-SA.js +16 -1
- package/lib/cjs/locale/ca-ES.js +16 -1
- package/lib/cjs/locale/de-DE.js +16 -1
- package/lib/cjs/locale/en-US.js +16 -1
- package/lib/cjs/locale/es-ES.js +16 -1
- package/lib/cjs/locale/fa-IR.js +16 -1
- package/lib/cjs/locale/fr-FR.js +16 -1
- package/lib/cjs/locale/id-ID.js +16 -1
- package/lib/cjs/locale/it-IT.js +16 -1
- package/lib/cjs/locale/ja-JP.js +16 -1
- package/lib/cjs/locale/ko-KR.js +16 -1
- package/lib/cjs/locale/pl-PL.js +16 -1
- package/lib/cjs/locale/pt-BR.js +16 -1
- package/lib/cjs/locale/ru-RU.js +16 -1
- package/lib/cjs/locale/sk-SK.js +16 -1
- package/lib/cjs/locale/vi-VN.js +16 -1
- package/lib/cjs/locale/zh-CN.js +16 -1
- package/lib/cjs/locale/zh-HK.js +16 -1
- package/lib/cjs/locale/zh-TW.js +16 -1
- package/lib/es/index.js +765 -526
- package/lib/es/locale/ar-SA.js +16 -1
- package/lib/es/locale/ca-ES.js +16 -1
- package/lib/es/locale/de-DE.js +16 -1
- package/lib/es/locale/en-US.js +16 -1
- package/lib/es/locale/es-ES.js +16 -1
- package/lib/es/locale/fa-IR.js +16 -1
- package/lib/es/locale/fr-FR.js +16 -1
- package/lib/es/locale/id-ID.js +16 -1
- package/lib/es/locale/it-IT.js +16 -1
- package/lib/es/locale/ja-JP.js +16 -1
- package/lib/es/locale/ko-KR.js +16 -1
- package/lib/es/locale/pl-PL.js +16 -1
- package/lib/es/locale/pt-BR.js +16 -1
- package/lib/es/locale/ru-RU.js +16 -1
- package/lib/es/locale/sk-SK.js +16 -1
- package/lib/es/locale/vi-VN.js +16 -1
- package/lib/es/locale/zh-CN.js +16 -1
- package/lib/es/locale/zh-HK.js +16 -1
- package/lib/es/locale/zh-TW.js +16 -1
- package/lib/index.css +98 -21
- package/lib/index.js +765 -526
- package/lib/locale/ar-SA.js +16 -1
- package/lib/locale/ca-ES.js +16 -1
- package/lib/locale/de-DE.js +16 -1
- package/lib/locale/en-US.js +16 -1
- package/lib/locale/es-ES.js +16 -1
- package/lib/locale/fa-IR.js +16 -1
- package/lib/locale/fr-FR.js +16 -1
- package/lib/locale/id-ID.js +16 -1
- package/lib/locale/it-IT.js +16 -1
- package/lib/locale/ja-JP.js +16 -1
- package/lib/locale/ko-KR.js +16 -1
- package/lib/locale/pl-PL.js +16 -1
- package/lib/locale/pt-BR.js +16 -1
- package/lib/locale/ru-RU.js +16 -1
- package/lib/locale/sk-SK.js +16 -1
- package/lib/locale/vi-VN.js +16 -1
- package/lib/locale/zh-CN.js +16 -1
- package/lib/locale/zh-HK.js +16 -1
- package/lib/locale/zh-TW.js +16 -1
- package/lib/types/facade/f-univer.d.ts +5 -3
- package/lib/types/index.d.ts +1 -1
- package/lib/types/locale/en-US.d.ts +15 -0
- package/lib/types/services/font.service.d.ts +9 -2
- package/lib/types/services/menu/menu-manager.service.d.ts +1 -1
- package/lib/types/views/components/ribbon/RibbonOverflow.d.ts +22 -0
- package/lib/types/views/components/ribbon/ToolbarItem.d.ts +1 -0
- package/lib/types/views/components/ribbon/hook.d.ts +2 -2
- package/lib/types/views/emoji-picker/emoji-picker-utils.d.ts +1 -1
- package/lib/umd/index.js +19 -19
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -1374,45 +1374,102 @@ let MenuManagerService = _MenuManagerService = class MenuManagerService extends
|
|
|
1374
1374
|
["ribbon.start"]: {
|
|
1375
1375
|
order: 0,
|
|
1376
1376
|
title: "ui.ribbon.start",
|
|
1377
|
-
["ribbon.start.history"]: {
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
["ribbon.start.
|
|
1377
|
+
["ribbon.start.history"]: {
|
|
1378
|
+
order: 0,
|
|
1379
|
+
title: "ui.ribbon.groups.clipboard"
|
|
1380
|
+
},
|
|
1381
|
+
["ribbon.start.format"]: {
|
|
1382
|
+
order: 1,
|
|
1383
|
+
title: "ui.ribbon.groups.font"
|
|
1384
|
+
},
|
|
1385
|
+
["ribbon.start.layout"]: {
|
|
1386
|
+
order: 2,
|
|
1387
|
+
title: "ui.ribbon.groups.layout"
|
|
1388
|
+
},
|
|
1389
|
+
["ribbon.start.number"]: {
|
|
1390
|
+
order: 3,
|
|
1391
|
+
title: "ui.ribbon.groups.number"
|
|
1392
|
+
},
|
|
1393
|
+
["ribbon.start.others"]: {
|
|
1394
|
+
order: 4,
|
|
1395
|
+
title: "ui.ribbon.groups.tools"
|
|
1396
|
+
}
|
|
1382
1397
|
},
|
|
1383
1398
|
["ribbon.insert"]: {
|
|
1384
1399
|
order: 1,
|
|
1385
1400
|
title: "ui.ribbon.insert",
|
|
1386
|
-
["ribbon.insert.edit"]: {
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1401
|
+
["ribbon.insert.edit"]: {
|
|
1402
|
+
order: 0,
|
|
1403
|
+
title: "ui.ribbon.groups.editing"
|
|
1404
|
+
},
|
|
1405
|
+
["ribbon.insert.media"]: {
|
|
1406
|
+
order: 1,
|
|
1407
|
+
title: "ui.ribbon.groups.media"
|
|
1408
|
+
},
|
|
1409
|
+
["ribbon.insert.cell"]: {
|
|
1410
|
+
order: 2,
|
|
1411
|
+
title: "ui.ribbon.groups.cells"
|
|
1412
|
+
},
|
|
1413
|
+
["ribbon.insert.others"]: {
|
|
1414
|
+
order: 3,
|
|
1415
|
+
title: "ui.ribbon.groups.tools"
|
|
1416
|
+
}
|
|
1390
1417
|
},
|
|
1391
1418
|
["ribbon.formulas"]: {
|
|
1392
1419
|
order: 2,
|
|
1393
1420
|
title: "ui.ribbon.formulas",
|
|
1394
|
-
["ribbon.formulas.basic"]: {
|
|
1395
|
-
|
|
1421
|
+
["ribbon.formulas.basic"]: {
|
|
1422
|
+
order: 0,
|
|
1423
|
+
title: "ui.ribbon.groups.formulas"
|
|
1424
|
+
},
|
|
1425
|
+
["ribbon.formulas.others"]: {
|
|
1426
|
+
order: 1,
|
|
1427
|
+
title: "ui.ribbon.groups.tools"
|
|
1428
|
+
}
|
|
1396
1429
|
},
|
|
1397
1430
|
["ribbon.data"]: {
|
|
1398
1431
|
order: 3,
|
|
1399
1432
|
title: "ui.ribbon.data",
|
|
1400
|
-
["ribbon.data.formulas"]: {
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1433
|
+
["ribbon.data.formulas"]: {
|
|
1434
|
+
order: 0,
|
|
1435
|
+
title: "ui.ribbon.groups.formulas"
|
|
1436
|
+
},
|
|
1437
|
+
["ribbon.data.rules"]: {
|
|
1438
|
+
order: 1,
|
|
1439
|
+
title: "ui.ribbon.groups.rules"
|
|
1440
|
+
},
|
|
1441
|
+
["ribbon.data.organization"]: {
|
|
1442
|
+
order: 2,
|
|
1443
|
+
title: "ui.ribbon.groups.organization"
|
|
1444
|
+
},
|
|
1445
|
+
["ribbon.data.others"]: {
|
|
1446
|
+
order: 3,
|
|
1447
|
+
title: "ui.ribbon.groups.tools"
|
|
1448
|
+
}
|
|
1404
1449
|
},
|
|
1405
1450
|
["ribbon.view"]: {
|
|
1406
1451
|
order: 4,
|
|
1407
1452
|
title: "ui.ribbon.view",
|
|
1408
|
-
["ribbon.view.display"]: {
|
|
1409
|
-
|
|
1410
|
-
|
|
1453
|
+
["ribbon.view.display"]: {
|
|
1454
|
+
order: 0,
|
|
1455
|
+
title: "ui.ribbon.groups.display"
|
|
1456
|
+
},
|
|
1457
|
+
["ribbon.view.Visibility"]: {
|
|
1458
|
+
order: 0,
|
|
1459
|
+
title: "ui.ribbon.groups.visibility"
|
|
1460
|
+
},
|
|
1461
|
+
["ribbon.view.others"]: {
|
|
1462
|
+
order: 0,
|
|
1463
|
+
title: "ui.ribbon.groups.tools"
|
|
1464
|
+
}
|
|
1411
1465
|
},
|
|
1412
1466
|
["ribbon.others"]: {
|
|
1413
1467
|
order: 5,
|
|
1414
1468
|
title: "ui.ribbon.others",
|
|
1415
|
-
["ribbon.others.others"]: {
|
|
1469
|
+
["ribbon.others.others"]: {
|
|
1470
|
+
order: 0,
|
|
1471
|
+
title: "ui.ribbon.groups.tools"
|
|
1472
|
+
}
|
|
1416
1473
|
}
|
|
1417
1474
|
},
|
|
1418
1475
|
["contextMenu"]: {
|
|
@@ -3375,6 +3432,7 @@ function placeRibbonGridItems(items) {
|
|
|
3375
3432
|
const columnSpan = layout.columnSpan ?? 1;
|
|
3376
3433
|
const cells = getCells(layout.row, layout.column, rowSpan, columnSpan);
|
|
3377
3434
|
if (!isValidGridGeometry(layout, rowSpan, cells)) {
|
|
3435
|
+
globalThis.console.warn(`[RibbonGrid] Invalid gridLayout for "${item.key}"; using fallback placement.`);
|
|
3378
3436
|
fallbackItems.push({ item });
|
|
3379
3437
|
continue;
|
|
3380
3438
|
}
|
|
@@ -3441,6 +3499,83 @@ function getCells(row, column, rowSpan, columnSpan) {
|
|
|
3441
3499
|
return cells;
|
|
3442
3500
|
}
|
|
3443
3501
|
|
|
3502
|
+
//#endregion
|
|
3503
|
+
//#region src/views/components/ribbon/ToolbarButton.tsx
|
|
3504
|
+
/**
|
|
3505
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3506
|
+
*
|
|
3507
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3508
|
+
* you may not use this file except in compliance with the License.
|
|
3509
|
+
* You may obtain a copy of the License at
|
|
3510
|
+
*
|
|
3511
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3512
|
+
*
|
|
3513
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3514
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3515
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3516
|
+
* See the License for the specific language governing permissions and
|
|
3517
|
+
* limitations under the License.
|
|
3518
|
+
*/
|
|
3519
|
+
const toolbarButtonClassName = `
|
|
3520
|
+
univer-box-border univer-flex univer-h-6 univer-min-w-6 univer-cursor-pointer univer-items-center
|
|
3521
|
+
univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-px-0 univer-py-0
|
|
3522
|
+
univer-text-gray-900 univer-outline-none univer-transition-colors univer-animate-in univer-fade-in
|
|
3523
|
+
dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700 dark:disabled:!univer-text-gray-600
|
|
3524
|
+
disabled:univer-cursor-not-allowed disabled:univer-text-gray-300 disabled:hover:univer-bg-transparent
|
|
3525
|
+
hover:univer-bg-gray-100 whitespace-nowrap univer-w-max
|
|
3526
|
+
[&_svg]:univer-shrink-0
|
|
3527
|
+
`;
|
|
3528
|
+
const toolbarButtonVariants = cva(toolbarButtonClassName, {
|
|
3529
|
+
variants: {
|
|
3530
|
+
noIcon: {
|
|
3531
|
+
true: "univer-px-2",
|
|
3532
|
+
false: ""
|
|
3533
|
+
},
|
|
3534
|
+
active: {
|
|
3535
|
+
true: "!univer-bg-gray-200 dark:!univer-bg-gray-500",
|
|
3536
|
+
false: ""
|
|
3537
|
+
}
|
|
3538
|
+
},
|
|
3539
|
+
defaultVariants: {
|
|
3540
|
+
noIcon: false,
|
|
3541
|
+
active: false
|
|
3542
|
+
}
|
|
3543
|
+
});
|
|
3544
|
+
/**
|
|
3545
|
+
* Button Component
|
|
3546
|
+
*/
|
|
3547
|
+
function ToolbarButton(props) {
|
|
3548
|
+
const { children, className, style, disabled = false, active = false, noIcon, onClick, onDoubleClick, ...restProps } = props;
|
|
3549
|
+
const handleClick = (e) => {
|
|
3550
|
+
if (disabled) {
|
|
3551
|
+
e.preventDefault();
|
|
3552
|
+
return;
|
|
3553
|
+
}
|
|
3554
|
+
onClick && onClick(e);
|
|
3555
|
+
};
|
|
3556
|
+
const handleDoubleClick = (e) => {
|
|
3557
|
+
if (disabled) {
|
|
3558
|
+
e.preventDefault();
|
|
3559
|
+
return;
|
|
3560
|
+
}
|
|
3561
|
+
onDoubleClick && onDoubleClick(e);
|
|
3562
|
+
};
|
|
3563
|
+
return /* @__PURE__ */ jsx("button", {
|
|
3564
|
+
type: "button",
|
|
3565
|
+
className: clsx(toolbarButtonVariants({
|
|
3566
|
+
noIcon,
|
|
3567
|
+
active,
|
|
3568
|
+
className
|
|
3569
|
+
})),
|
|
3570
|
+
style,
|
|
3571
|
+
disabled,
|
|
3572
|
+
onClick: handleClick,
|
|
3573
|
+
onDoubleClick: handleDoubleClick,
|
|
3574
|
+
...restProps,
|
|
3575
|
+
children
|
|
3576
|
+
});
|
|
3577
|
+
}
|
|
3578
|
+
|
|
3444
3579
|
//#endregion
|
|
3445
3580
|
//#region src/views/custom-label/CustomLabel.tsx
|
|
3446
3581
|
/**
|
|
@@ -3543,82 +3678,334 @@ function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
|
|
|
3543
3678
|
}
|
|
3544
3679
|
|
|
3545
3680
|
//#endregion
|
|
3546
|
-
//#region src/
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
[
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
},
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3681
|
+
//#region src/services/font.service.ts
|
|
3682
|
+
const IFontService = createIdentifier("univer.font-service");
|
|
3683
|
+
let FontCategory = /* @__PURE__ */ function(FontCategory) {
|
|
3684
|
+
FontCategory["SANS_SERIF"] = "sans-serif";
|
|
3685
|
+
FontCategory["SERIF"] = "serif";
|
|
3686
|
+
FontCategory["MONOSPACE"] = "monospace";
|
|
3687
|
+
FontCategory["DISPLAY"] = "display";
|
|
3688
|
+
FontCategory["HANDWRITING"] = "handwriting";
|
|
3689
|
+
return FontCategory;
|
|
3690
|
+
}({});
|
|
3691
|
+
const DEFAULT_FONT_LIST = [
|
|
3692
|
+
["宋体", { category: "serif" }],
|
|
3693
|
+
["Arial", { category: "sans-serif" }],
|
|
3694
|
+
["Baskerville", { category: "serif" }],
|
|
3695
|
+
["Comic Sans MS", { category: "handwriting" }],
|
|
3696
|
+
["Courier New", { category: "monospace" }],
|
|
3697
|
+
["Helvetica", { category: "sans-serif" }],
|
|
3698
|
+
["Times New Roman", { category: "serif" }],
|
|
3699
|
+
["Verdana", { category: "sans-serif" }],
|
|
3700
|
+
["Apple LiGothic", { category: "sans-serif" }],
|
|
3701
|
+
["Apple LiSung", { category: "serif" }],
|
|
3702
|
+
["Hei", { category: "sans-serif" }],
|
|
3703
|
+
["Kai", { category: "handwriting" }],
|
|
3704
|
+
["LiHei Pro", { category: "sans-serif" }],
|
|
3705
|
+
["LiSong Pro", { category: "serif" }],
|
|
3706
|
+
["STFangsong", { category: "serif" }],
|
|
3707
|
+
["STHeiti", { category: "sans-serif" }],
|
|
3708
|
+
["STKaiti", { category: "handwriting" }],
|
|
3709
|
+
["STSong", { category: "serif" }],
|
|
3710
|
+
["报隶-繁", { category: "handwriting" }],
|
|
3711
|
+
["报隶-简", { category: "handwriting" }],
|
|
3712
|
+
["冬青黑体简体中文", { category: "sans-serif" }],
|
|
3713
|
+
["黑体-繁", { category: "sans-serif" }],
|
|
3714
|
+
["黑体-简", { category: "sans-serif" }],
|
|
3715
|
+
["华文仿宋", { category: "serif" }],
|
|
3716
|
+
["华文楷体", { category: "handwriting" }],
|
|
3717
|
+
["华文宋体", { category: "serif" }],
|
|
3718
|
+
["楷体-繁", { category: "handwriting" }],
|
|
3719
|
+
["楷体-简", { category: "handwriting" }],
|
|
3720
|
+
["兰亭黑-繁", { category: "sans-serif" }],
|
|
3721
|
+
["兰亭黑-简", { category: "sans-serif" }],
|
|
3722
|
+
["隶变-繁", { category: "handwriting" }],
|
|
3723
|
+
["隶变-简", { category: "handwriting" }],
|
|
3724
|
+
["凌慧体-繁", { category: "handwriting" }],
|
|
3725
|
+
["凌慧体-简", { category: "handwriting" }],
|
|
3726
|
+
["翩翩体-繁", { category: "handwriting" }],
|
|
3727
|
+
["翩翩体-简", { category: "handwriting" }],
|
|
3728
|
+
["苹方-繁", { category: "sans-serif" }],
|
|
3729
|
+
["苹方-港", { category: "sans-serif" }],
|
|
3730
|
+
["苹方-简", { category: "sans-serif" }],
|
|
3731
|
+
["手札体-繁", { category: "handwriting" }],
|
|
3732
|
+
["手札体-简", { category: "handwriting" }],
|
|
3733
|
+
["宋体-繁", { category: "serif" }],
|
|
3734
|
+
["宋体-简", { category: "serif" }],
|
|
3735
|
+
["娃娃体-繁", { category: "handwriting" }],
|
|
3736
|
+
["娃娃体-简", { category: "handwriting" }],
|
|
3737
|
+
["魏碑-繁", { category: "handwriting" }],
|
|
3738
|
+
["魏碑-简", { category: "handwriting" }],
|
|
3739
|
+
["行楷-繁", { category: "handwriting" }],
|
|
3740
|
+
["行楷-简", { category: "handwriting" }],
|
|
3741
|
+
["雅痞-繁", { category: "display" }],
|
|
3742
|
+
["雅痞-简", { category: "display" }],
|
|
3743
|
+
["圆体-繁", { category: "sans-serif" }],
|
|
3744
|
+
["圆体-简", { category: "sans-serif" }],
|
|
3745
|
+
["Arial Black", { category: "sans-serif" }],
|
|
3746
|
+
["Big Caslon", { category: "serif" }],
|
|
3747
|
+
["Courier", { category: "monospace" }],
|
|
3748
|
+
["Didot", { category: "serif" }],
|
|
3749
|
+
["Futura", { category: "sans-serif" }],
|
|
3750
|
+
["Georgia", { category: "serif" }],
|
|
3751
|
+
["Helvetica Neue", { category: "sans-serif" }],
|
|
3752
|
+
["Optima", { category: "sans-serif" }],
|
|
3753
|
+
["Times", { category: "serif" }],
|
|
3754
|
+
["Tahoma", { category: "sans-serif" }],
|
|
3755
|
+
["BIZ UDGothic", { category: "monospace" }],
|
|
3756
|
+
["BIZ UDMincho", { category: "monospace" }],
|
|
3757
|
+
["Hiragino Maru Gothic Pro", { category: "sans-serif" }],
|
|
3758
|
+
["Hiragino Maru Gothic ProN", { category: "sans-serif" }],
|
|
3759
|
+
["Hiragino Mincho Pro", { category: "serif" }],
|
|
3760
|
+
["Hiragino Mincho ProN", { category: "serif" }],
|
|
3761
|
+
["Hiragino Sans", { category: "sans-serif" }],
|
|
3762
|
+
["Klee", { category: "handwriting" }],
|
|
3763
|
+
["Osaka", { category: "sans-serif" }],
|
|
3764
|
+
["Toppan Bunkyu Gothic", { category: "sans-serif" }],
|
|
3765
|
+
["Toppan Bunkyu Midashi Gothic", { category: "sans-serif" }],
|
|
3766
|
+
["Toppan Bunkyu Midashi Mincho", { category: "serif" }],
|
|
3767
|
+
["Toppan Bunkyu Mincho", { category: "serif" }],
|
|
3768
|
+
["Tsukushi A Round Gothic", { category: "sans-serif" }],
|
|
3769
|
+
["Tsukushi B Round Gothic", { category: "sans-serif" }],
|
|
3770
|
+
["YuKyokasho", { category: "handwriting" }],
|
|
3771
|
+
["YuKyokasho Yoko", { category: "handwriting" }],
|
|
3772
|
+
["YuMincho +36p Kana", { category: "serif" }],
|
|
3773
|
+
["American Typewriter", { category: "serif" }],
|
|
3774
|
+
["Andale Mono", { category: "monospace" }],
|
|
3775
|
+
["Apple Chancery", { category: "handwriting" }],
|
|
3776
|
+
["Apple SD Gothic Neo", { category: "sans-serif" }],
|
|
3777
|
+
["Apple Symbols", { category: "display" }],
|
|
3778
|
+
["AppleGothic", { category: "sans-serif" }],
|
|
3779
|
+
["AppleMyungjo", { category: "serif" }],
|
|
3780
|
+
["Arial Unicode MS", { category: "sans-serif" }],
|
|
3781
|
+
["Athelas", { category: "serif" }],
|
|
3782
|
+
["Avenir", { category: "sans-serif" }],
|
|
3783
|
+
["Avenir Next", { category: "sans-serif" }],
|
|
3784
|
+
["Avenir Next Condensed", { category: "sans-serif" }],
|
|
3785
|
+
["Ayuthaya", { category: "sans-serif" }],
|
|
3786
|
+
["Bangla MN", { category: "serif" }],
|
|
3787
|
+
["Bangla Sangam MN", { category: "sans-serif" }],
|
|
3788
|
+
["Bauhaus 93", { category: "display" }],
|
|
3789
|
+
["Bodoni 72", { category: "serif" }],
|
|
3790
|
+
["Bodoni 72 Oldstyle", { category: "serif" }],
|
|
3791
|
+
["Bodoni 72 Smallcaps", { category: "serif" }],
|
|
3792
|
+
["Bodoni Ornaments", { category: "display" }],
|
|
3793
|
+
["Bookshelf Symbol 7", { category: "display" }],
|
|
3794
|
+
["Bradley Hand", { category: "handwriting" }],
|
|
3795
|
+
["Chalkboard", { category: "handwriting" }],
|
|
3796
|
+
["Chalkboard SE", { category: "handwriting" }],
|
|
3797
|
+
["Chalkduster", { category: "handwriting" }],
|
|
3798
|
+
["Charter", { category: "serif" }],
|
|
3799
|
+
["Cochin", { category: "serif" }],
|
|
3800
|
+
["Copperplate", { category: "serif" }],
|
|
3801
|
+
["Devanagari Sangam MN", { category: "sans-serif" }],
|
|
3802
|
+
["Din Alternate", { category: "sans-serif" }],
|
|
3803
|
+
["Euphemia UCAS", { category: "sans-serif" }],
|
|
3804
|
+
["Galvji", { category: "sans-serif" }],
|
|
3805
|
+
["Geneva", { category: "sans-serif" }],
|
|
3806
|
+
["Gill Sans", { category: "sans-serif" }],
|
|
3807
|
+
["Gujarati Sangam MN", { category: "sans-serif" }],
|
|
3808
|
+
["GungSeo", { category: "handwriting" }],
|
|
3809
|
+
["Gurmukhi MN", { category: "serif" }],
|
|
3810
|
+
["Gurmukhi Sangam MN", { category: "sans-serif" }],
|
|
3811
|
+
["HeadLineA", { category: "display" }],
|
|
3812
|
+
["Herculanum", { category: "display" }],
|
|
3813
|
+
["Hiragino Kaku Gothic Pro", { category: "sans-serif" }],
|
|
3814
|
+
["Hiragino Kaku Gothic ProN", { category: "sans-serif" }],
|
|
3815
|
+
["Hiragino Kaku Gothic Std", { category: "sans-serif" }],
|
|
3816
|
+
["Hiragino Kaku Gothic StdN", { category: "sans-serif" }],
|
|
3817
|
+
["Hoefler Text", { category: "serif" }],
|
|
3818
|
+
["Impact", { category: "sans-serif" }],
|
|
3819
|
+
["InaiMathi", { category: "sans-serif" }],
|
|
3820
|
+
["Iowan Old Style", { category: "serif" }],
|
|
3821
|
+
["Kannada MN", { category: "serif" }],
|
|
3822
|
+
["Kannada Sangam MN", { category: "sans-serif" }],
|
|
3823
|
+
["Kefa", { category: "serif" }],
|
|
3824
|
+
["Khmer MN", { category: "serif" }],
|
|
3825
|
+
["Khmer Sangam MN", { category: "sans-serif" }],
|
|
3826
|
+
["Kohinoor Bangla", { category: "sans-serif" }],
|
|
3827
|
+
["Kohinoor Devanagari", { category: "sans-serif" }],
|
|
3828
|
+
["Kohinoor Telugu", { category: "sans-serif" }],
|
|
3829
|
+
["Krungthep", { category: "sans-serif" }],
|
|
3830
|
+
["Lao MN", { category: "serif" }],
|
|
3831
|
+
["Lao Sangam MN", { category: "sans-serif" }],
|
|
3832
|
+
["Lucida Grande", { category: "sans-serif" }],
|
|
3833
|
+
["Luminari", { category: "display" }],
|
|
3834
|
+
["Malayalam MN", { category: "serif" }],
|
|
3835
|
+
["Malayalam Sangam MN", { category: "sans-serif" }],
|
|
3836
|
+
["Marion", { category: "serif" }],
|
|
3837
|
+
["Marker Felt", { category: "handwriting" }],
|
|
3838
|
+
["Menlo", { category: "monospace" }],
|
|
3839
|
+
["Microsoft Sans Serif", { category: "sans-serif" }],
|
|
3840
|
+
["Modern No. 20", { category: "serif" }],
|
|
3841
|
+
["Monaco", { category: "monospace" }],
|
|
3842
|
+
["Mukta Mahee", { category: "sans-serif" }],
|
|
3843
|
+
["Nanum Brush Script", { category: "handwriting" }],
|
|
3844
|
+
["Nanum Gothic", { category: "sans-serif" }],
|
|
3845
|
+
["Nanum Myeongjo", { category: "serif" }],
|
|
3846
|
+
["Nanum Pen Script", { category: "handwriting" }],
|
|
3847
|
+
["Noteworthy", { category: "handwriting" }],
|
|
3848
|
+
["Oriya MN", { category: "serif" }],
|
|
3849
|
+
["Oriya Sangam MN", { category: "sans-serif" }],
|
|
3850
|
+
["Palatino", { category: "serif" }],
|
|
3851
|
+
["Papyrus", { category: "display" }],
|
|
3852
|
+
["PCMyungjo", { category: "monospace" }],
|
|
3853
|
+
["Phosphate", { category: "display" }],
|
|
3854
|
+
["PilGi", { category: "handwriting" }],
|
|
3855
|
+
["Plantagenet Cherokee", { category: "serif" }],
|
|
3856
|
+
["PT Mono", { category: "monospace" }],
|
|
3857
|
+
["PT Sans", { category: "sans-serif" }],
|
|
3858
|
+
["PT Sans Caption", { category: "sans-serif" }],
|
|
3859
|
+
["PT Serif", { category: "serif" }],
|
|
3860
|
+
["PT Serif Caption", { category: "serif" }],
|
|
3861
|
+
["Rockwell", { category: "serif" }],
|
|
3862
|
+
["Sathu", { category: "sans-serif" }],
|
|
3863
|
+
["Savoye LET", { category: "handwriting" }],
|
|
3864
|
+
["Seravek", { category: "sans-serif" }],
|
|
3865
|
+
["Shree Devanagari 714", { category: "sans-serif" }],
|
|
3866
|
+
["SignPainter", { category: "handwriting" }],
|
|
3867
|
+
["Silom", { category: "display" }],
|
|
3868
|
+
["Sinhala MN", { category: "serif" }],
|
|
3869
|
+
["Sinhala Sangam MN", { category: "sans-serif" }],
|
|
3870
|
+
["Skia", { category: "sans-serif" }],
|
|
3871
|
+
["Snell Roundhand", { category: "handwriting" }],
|
|
3872
|
+
["STIXGeneral", { category: "serif" }],
|
|
3873
|
+
["Sukhumvit Set", { category: "sans-serif" }],
|
|
3874
|
+
["Superclarendon", { category: "serif" }],
|
|
3875
|
+
["Tamil MN", { category: "serif" }],
|
|
3876
|
+
["Tamil Sangam MN", { category: "sans-serif" }],
|
|
3877
|
+
["Telugu MN", { category: "serif" }],
|
|
3878
|
+
["Telugu Sangam MN", { category: "sans-serif" }],
|
|
3879
|
+
["Trattatello", { category: "handwriting" }],
|
|
3880
|
+
["Trebuchet MS", { category: "sans-serif" }],
|
|
3881
|
+
["Webdings", { category: "display" }],
|
|
3882
|
+
["Wingdings", { category: "display" }],
|
|
3883
|
+
["Wingdings 2", { category: "display" }],
|
|
3884
|
+
["Wingdings 3", { category: "display" }],
|
|
3885
|
+
["YuGothic", { category: "sans-serif" }],
|
|
3886
|
+
["YuGothic Light", { category: "sans-serif" }],
|
|
3887
|
+
["YuGothic Medium", { category: "sans-serif" }],
|
|
3888
|
+
["Zapfino", { category: "handwriting" }]
|
|
3889
|
+
].map(([value, config]) => ({
|
|
3890
|
+
value,
|
|
3891
|
+
label: value,
|
|
3892
|
+
...config
|
|
3893
|
+
}));
|
|
3894
|
+
let FontService = class FontService {
|
|
3895
|
+
constructor(_configService) {
|
|
3896
|
+
this._configService = _configService;
|
|
3897
|
+
_defineProperty(this, "fonts$", new BehaviorSubject([]));
|
|
3898
|
+
const { customFontFamily } = this._configService.getConfig("ui.config") ?? {};
|
|
3899
|
+
let fonts = [];
|
|
3900
|
+
if (customFontFamily) {
|
|
3901
|
+
if (Array.isArray(customFontFamily)) fonts = [...DEFAULT_FONT_LIST, ...customFontFamily];
|
|
3902
|
+
else if (customFontFamily.override) fonts = [...customFontFamily.list];
|
|
3903
|
+
else fonts = [...DEFAULT_FONT_LIST, ...customFontFamily.list];
|
|
3904
|
+
} else fonts = [...DEFAULT_FONT_LIST];
|
|
3905
|
+
this.fonts$.next(fonts);
|
|
3585
3906
|
}
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3907
|
+
dispose() {
|
|
3908
|
+
this.resetToDefaults();
|
|
3909
|
+
this.fonts$.complete();
|
|
3910
|
+
}
|
|
3911
|
+
getFonts() {
|
|
3912
|
+
return this.fonts$.getValue();
|
|
3913
|
+
}
|
|
3914
|
+
getFontByValue(value) {
|
|
3915
|
+
return this.getFonts().find((font) => font.value === value);
|
|
3916
|
+
}
|
|
3917
|
+
/**
|
|
3918
|
+
* Check if the current browser environment supports the font
|
|
3919
|
+
* @param fontValue
|
|
3920
|
+
* @returns boolean Whether the font is supported
|
|
3921
|
+
*/
|
|
3922
|
+
isFontSupported(fontValue) {
|
|
3923
|
+
const context = document.createElement("canvas").getContext("2d");
|
|
3924
|
+
if (!context) return false;
|
|
3925
|
+
const text = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
3926
|
+
const size = "72px";
|
|
3927
|
+
const baseFonts = [
|
|
3928
|
+
"monospace",
|
|
3929
|
+
"serif",
|
|
3930
|
+
"sans-serif"
|
|
3931
|
+
];
|
|
3932
|
+
const defaultWidths = {};
|
|
3933
|
+
baseFonts.forEach((base) => {
|
|
3934
|
+
context.font = `${size} ${base}`;
|
|
3935
|
+
defaultWidths[base] = context.measureText(text).width;
|
|
3936
|
+
});
|
|
3937
|
+
return baseFonts.some((base) => {
|
|
3938
|
+
context.font = `${size} "${fontValue}", ${base}`;
|
|
3939
|
+
return context.measureText(text).width !== defaultWidths[base];
|
|
3940
|
+
});
|
|
3941
|
+
}
|
|
3942
|
+
addFont(font) {
|
|
3943
|
+
if (this.getFontByValue(font.value)) throw new Error(`[FontService]: Font with value "${font.value}" already exists.`);
|
|
3944
|
+
const updatedFonts = [...this.getFonts(), font].sort();
|
|
3945
|
+
this.fonts$.next(updatedFonts);
|
|
3946
|
+
}
|
|
3947
|
+
updateFont(value, updates) {
|
|
3948
|
+
const fonts = this.getFonts();
|
|
3949
|
+
const fontIndex = fonts.findIndex((font) => font.value === value);
|
|
3950
|
+
if (fontIndex === -1) throw new Error(`Font with value "${value}" not found.`);
|
|
3951
|
+
const updatedFont = {
|
|
3952
|
+
...fonts[fontIndex],
|
|
3953
|
+
...updates
|
|
3954
|
+
};
|
|
3955
|
+
const updatedFonts = [...fonts];
|
|
3956
|
+
updatedFonts[fontIndex] = updatedFont;
|
|
3957
|
+
this.fonts$.next(updatedFonts);
|
|
3958
|
+
}
|
|
3959
|
+
removeFont(value) {
|
|
3960
|
+
const fonts = this.getFonts();
|
|
3961
|
+
if (fonts.findIndex((font) => font.value === value) === -1) return false;
|
|
3962
|
+
const updatedFonts = fonts.filter((font) => font.value !== value);
|
|
3963
|
+
this.fonts$.next(updatedFonts);
|
|
3964
|
+
return true;
|
|
3965
|
+
}
|
|
3966
|
+
resetToDefaults() {
|
|
3967
|
+
this.fonts$.next([...DEFAULT_FONT_LIST]);
|
|
3968
|
+
}
|
|
3969
|
+
};
|
|
3970
|
+
FontService = __decorate([__decorateParam(0, IConfigService)], FontService);
|
|
3971
|
+
|
|
3972
|
+
//#endregion
|
|
3973
|
+
//#region src/views/font-family/use-font-list.ts
|
|
3974
|
+
function useFontList() {
|
|
3975
|
+
const fontService = useDependency(IFontService);
|
|
3976
|
+
return {
|
|
3977
|
+
fonts: useObservable(fontService.fonts$, fontService.getFonts()),
|
|
3978
|
+
fontService
|
|
3605
3979
|
};
|
|
3606
|
-
return /* @__PURE__ */ jsx("button", {
|
|
3607
|
-
type: "button",
|
|
3608
|
-
className: clsx(toolbarButtonVariants({
|
|
3609
|
-
noIcon,
|
|
3610
|
-
active,
|
|
3611
|
-
className
|
|
3612
|
-
})),
|
|
3613
|
-
style,
|
|
3614
|
-
disabled,
|
|
3615
|
-
onClick: handleClick,
|
|
3616
|
-
onDoubleClick: handleDoubleClick,
|
|
3617
|
-
...restProps,
|
|
3618
|
-
children
|
|
3619
|
-
});
|
|
3620
3980
|
}
|
|
3621
3981
|
|
|
3982
|
+
//#endregion
|
|
3983
|
+
//#region src/views/font-family/FontFamilyItem.tsx
|
|
3984
|
+
const FONT_FAMILY_ITEM_COMPONENT = "UI_FONT_FAMILY_ITEM_COMPONENT";
|
|
3985
|
+
const FontFamilyItem = ({ value, onChange }) => {
|
|
3986
|
+
const localeService = useDependency(LocaleService);
|
|
3987
|
+
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
3988
|
+
const { fonts, fontService } = useFontList();
|
|
3989
|
+
function handleSelectFont(nextValue) {
|
|
3990
|
+
onChange(nextValue);
|
|
3991
|
+
}
|
|
3992
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
3993
|
+
dir: direction,
|
|
3994
|
+
className: "univer-m-0 univer-list-none univer-p-0 univer-text-sm",
|
|
3995
|
+
style: { fontFamily: value },
|
|
3996
|
+
children: fonts.map((font) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", {
|
|
3997
|
+
className: "univer-flex univer-h-7 univer-w-full univer-appearance-none univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-border-none univer-bg-transparent univer-px-2 univer-text-gray-900 hover:univer-bg-gray-100 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700",
|
|
3998
|
+
style: { fontFamily: font.value },
|
|
3999
|
+
type: "button",
|
|
4000
|
+
onClick: () => handleSelectFont(font.value),
|
|
4001
|
+
children: [localeService.t(font.label), !fontService.isFontSupported(font.value) && /* @__PURE__ */ jsx(Tooltip, {
|
|
4002
|
+
title: localeService.t("ui.fontFamily.not-supported"),
|
|
4003
|
+
children: /* @__PURE__ */ jsx(InfoIcon, { className: "univer-text-gray-300 dark:!univer-text-gray-400" })
|
|
4004
|
+
})]
|
|
4005
|
+
}) }, font.value))
|
|
4006
|
+
});
|
|
4007
|
+
};
|
|
4008
|
+
|
|
3622
4009
|
//#endregion
|
|
3623
4010
|
//#region src/views/components/ribbon/TooltipButtonWrapper.tsx
|
|
3624
4011
|
const TooltipWrapperContext = createContext({
|
|
@@ -3764,10 +4151,6 @@ function DropdownMenuLabel({ icon, value, option, preserveStrokeWidth, onOptionS
|
|
|
3764
4151
|
})]
|
|
3765
4152
|
});
|
|
3766
4153
|
}
|
|
3767
|
-
function getOptionKey(option) {
|
|
3768
|
-
var _option$label2;
|
|
3769
|
-
return String(option.id ?? option.commandId ?? option.value ?? (typeof option.label === "string" ? option.label : (_option$label2 = option.label) === null || _option$label2 === void 0 ? void 0 : _option$label2.name));
|
|
3770
|
-
}
|
|
3771
4154
|
function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, preserveStrokeWidth, onOptionSelect, dropdownComponent, dropdownMenuComponent: DropdownMenuComponent = DropdownMenu }) {
|
|
3772
4155
|
const { dropdownVisible, setDropdownVisible } = useContext(TooltipWrapperContext);
|
|
3773
4156
|
const shortcutService = useDependency(IShortcutService);
|
|
@@ -3900,6 +4283,10 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3900
4283
|
function handleEmbedBoundaryFocusOutside(event) {
|
|
3901
4284
|
keepInteractionInsideSameEmbedBoundary(event);
|
|
3902
4285
|
}
|
|
4286
|
+
function getOptionKey(option) {
|
|
4287
|
+
var _option$label2;
|
|
4288
|
+
return String(option.id ?? option.commandId ?? option.value ?? (typeof option.label === "string" ? option.label : (_option$label2 = option.label) === null || _option$label2 === void 0 ? void 0 : _option$label2.name));
|
|
4289
|
+
}
|
|
3903
4290
|
function handleOptionSelect(option) {
|
|
3904
4291
|
var _instanceService$getC, _instanceService$getC2;
|
|
3905
4292
|
const target = sheetTarget;
|
|
@@ -3931,8 +4318,8 @@ function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled,
|
|
|
3931
4318
|
return {
|
|
3932
4319
|
type: "item",
|
|
3933
4320
|
className: clsx({
|
|
3934
|
-
"focus:univer-bg-
|
|
3935
|
-
"!univer-p-0": isSingleEmbeddedCustomPanel
|
|
4321
|
+
"focus:univer-bg-transparent dark:focus:!univer-bg-transparent": typeof option.label !== "string" && ((_option$label3 = option.label) === null || _option$label3 === void 0 ? void 0 : _option$label3.hoverable) === false,
|
|
4322
|
+
"!univer-p-0": isSingleEmbeddedCustomPanel || typeof option.label === "object" && option.label.name === "UI_FONT_FAMILY_ITEM_COMPONENT"
|
|
3936
4323
|
}),
|
|
3937
4324
|
children: /* @__PURE__ */ jsx(DropdownMenuLabel, {
|
|
3938
4325
|
icon: option.icon,
|
|
@@ -4121,16 +4508,17 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
4121
4508
|
const { value, hidden, disabled, activated } = useToolbarItemStatus(props);
|
|
4122
4509
|
const executeCommand = (commandId, params) => {
|
|
4123
4510
|
layoutService.focus();
|
|
4124
|
-
commandService.executeCommand(commandId, params);
|
|
4511
|
+
return commandService.executeCommand(commandId, params);
|
|
4125
4512
|
};
|
|
4126
|
-
const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params, grid, large, showLabel, iconSize, iconColor, fullWidth, preserveStrokeWidth, dropdownComponent, dropdownMenuComponent } = props;
|
|
4513
|
+
const { tooltip, shortcut, icon, title, label, id, commandId, type, slot, params, grid, overflow, large, showLabel, iconSize, iconColor, fullWidth, preserveStrokeWidth, dropdownComponent, dropdownMenuComponent } = props;
|
|
4127
4514
|
const gridLabel = title ?? tooltip;
|
|
4128
4515
|
const shortcutDisplay = useToolbarShortcutDisplay({
|
|
4129
4516
|
id,
|
|
4130
4517
|
commandId,
|
|
4131
4518
|
shortcut
|
|
4132
4519
|
});
|
|
4133
|
-
|
|
4520
|
+
const tooltipLabel = tooltip ?? (overflow ? title : void 0);
|
|
4521
|
+
let tooltipTitle = typeof tooltipLabel === "string" ? localeService.t(tooltipLabel) : "";
|
|
4134
4522
|
if (shortcutDisplay) tooltipTitle += ` (${shortcutDisplay})`;
|
|
4135
4523
|
const { selections } = props;
|
|
4136
4524
|
const selections$ = useMemo(() => {
|
|
@@ -4157,26 +4545,27 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
4157
4545
|
const selectionsCommandId = props.selectionsCommandId;
|
|
4158
4546
|
const bId = commandId ?? id;
|
|
4159
4547
|
const sId = selectionsCommandId ?? commandId ?? id;
|
|
4160
|
-
const titleToDisplay = grid ? showLabel ? gridLabel : large ? void 0 : title : title;
|
|
4161
4548
|
const customLabelName = typeof label === "string" ? label : (label === null || label === void 0 ? void 0 : label.name) ?? "";
|
|
4162
4549
|
const hasCustomLabel = Boolean(componentManager.get(customLabelName));
|
|
4163
|
-
|
|
4550
|
+
let titleToDisplay = grid ? showLabel ? gridLabel : large ? void 0 : title : title;
|
|
4551
|
+
if (overflow) titleToDisplay = hasCustomLabel || iconToDisplay && !showLabel ? void 0 : gridLabel;
|
|
4552
|
+
const selectorAriaLabel = tooltip ? localeService.t(tooltip) : typeof title === "string" ? localeService.t(title) : void 0;
|
|
4164
4553
|
function handleSelect(option) {
|
|
4165
4554
|
if (disabled) return;
|
|
4166
4555
|
let commandId = sId;
|
|
4167
4556
|
if (option.id) commandId = option.id;
|
|
4168
4557
|
const commandParams = typeof option.params === "function" ? option.params(option.value) : option.params;
|
|
4169
|
-
executeCommand(commandId, commandParams ?? { value: option.value });
|
|
4558
|
+
return executeCommand(commandId, commandParams ?? { value: option.value });
|
|
4170
4559
|
}
|
|
4171
4560
|
function handleSelectionsValueChange(value) {
|
|
4172
4561
|
if (disabled) return;
|
|
4173
|
-
executeCommand(sId, { value });
|
|
4562
|
+
return executeCommand(sId, { value });
|
|
4174
4563
|
}
|
|
4175
4564
|
function handleClick() {
|
|
4176
4565
|
if (disabled) return;
|
|
4177
4566
|
if (menuType === 2) {
|
|
4178
4567
|
const commandParams = typeof params === "function" ? params() : params;
|
|
4179
|
-
executeCommand(bId, commandParams ?? { value });
|
|
4568
|
+
return executeCommand(bId, commandParams ?? { value });
|
|
4180
4569
|
}
|
|
4181
4570
|
}
|
|
4182
4571
|
if (menuType === 2) return /* @__PURE__ */ jsxs("div", {
|
|
@@ -4185,15 +4574,21 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
4185
4574
|
"aria-disabled": disabled,
|
|
4186
4575
|
className: clsx(toolbarButtonSelectorRootVariants({ disabled }), {
|
|
4187
4576
|
"univer-box-border univer-h-full univer-min-w-14 univer-flex-col !univer-pr-0": grid && large,
|
|
4188
|
-
"univer-box-border univer-h-full": grid && !large
|
|
4577
|
+
"univer-box-border univer-h-full": grid && !large,
|
|
4578
|
+
"!univer-h-auto univer-min-h-7 univer-w-full univer-text-xs": overflow
|
|
4189
4579
|
}),
|
|
4190
|
-
children: [/* @__PURE__ */ jsx("
|
|
4191
|
-
|
|
4580
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
4581
|
+
type: "button",
|
|
4582
|
+
disabled,
|
|
4583
|
+
"aria-label": selectorAriaLabel,
|
|
4584
|
+
"aria-pressed": props.activated$ ? activated : void 0,
|
|
4585
|
+
className: clsx("univer-border-0 univer-bg-transparent univer-text-inherit focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600", toolbarButtonSelectorMainVariants({
|
|
4192
4586
|
active: activated,
|
|
4193
4587
|
disabled
|
|
4194
4588
|
}), {
|
|
4195
4589
|
"univer-h-full univer-w-full univer-flex-col univer-justify-center univer-rounded univer-px-1 univer-pb-4 [&>svg]:univer-size-6": grid && large,
|
|
4196
|
-
"[&>svg]:univer-size-4": grid && !large
|
|
4590
|
+
"[&>svg]:univer-size-4": grid && !large,
|
|
4591
|
+
"univer-min-h-7 univer-min-w-0 univer-flex-1 univer-gap-1.5 univer-whitespace-normal univer-px-1.5 univer-text-start": overflow
|
|
4197
4592
|
}),
|
|
4198
4593
|
onClick: handleClick,
|
|
4199
4594
|
children: /* @__PURE__ */ jsx(CustomLabel, {
|
|
@@ -4215,8 +4610,11 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
4215
4610
|
onOptionSelect: handleSelect,
|
|
4216
4611
|
dropdownComponent,
|
|
4217
4612
|
dropdownMenuComponent,
|
|
4218
|
-
children: /* @__PURE__ */ jsx("
|
|
4219
|
-
|
|
4613
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
4614
|
+
type: "button",
|
|
4615
|
+
disabled,
|
|
4616
|
+
"aria-label": `${selectorAriaLabel ?? ""} ${localeService.t("ui.ribbon.more")}`,
|
|
4617
|
+
className: clsx("univer-border-0 univer-bg-transparent univer-text-inherit focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600", toolbarButtonSelectorTriggerVariants({
|
|
4220
4618
|
disabled,
|
|
4221
4619
|
active: activated
|
|
4222
4620
|
}), {
|
|
@@ -4251,7 +4649,8 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
4251
4649
|
"univer-box-border univer-h-full univer-min-w-14 univer-flex-col univer-justify-center univer-gap-1 univer-px-1.5 univer-py-1 univer-text-xs [&>svg]:univer-size-6": grid && large,
|
|
4252
4650
|
"univer-box-border univer-h-full": grid && !large,
|
|
4253
4651
|
"univer-bg-gray-0 dark:!univer-bg-gray-800": grid && !large && !icon,
|
|
4254
|
-
"[&>svg]:univer-size-4": grid && !large
|
|
4652
|
+
"[&>svg]:univer-size-4": grid && !large,
|
|
4653
|
+
"!univer-h-auto univer-min-h-7 univer-w-full univer-min-w-0 univer-gap-1.5 univer-whitespace-normal univer-px-1.5 univer-text-start univer-text-xs focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 [&>span]:univer-min-w-0 [&>span]:univer-whitespace-normal": overflow
|
|
4255
4654
|
}, grid && !large && !icon && borderClassName),
|
|
4256
4655
|
children: grid && large ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CustomLabel, {
|
|
4257
4656
|
icon: iconToDisplay,
|
|
@@ -4283,7 +4682,7 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
4283
4682
|
function renderButtonType() {
|
|
4284
4683
|
const isCustomComponent = componentManager.get(typeof label === "string" ? label : (label === null || label === void 0 ? void 0 : label.name) ?? "");
|
|
4285
4684
|
const buttonAriaLabel = tooltip ? localeService.t(tooltip) : typeof title === "string" ? localeService.t(title) : void 0;
|
|
4286
|
-
const buttonClassName = clsx(grid && !large && "[&>svg]:univer-size-4", grid && large ? "univer-h-full univer-min-w-14 univer-flex-col univer-gap-1 univer-px-1.5 univer-py-1 univer-text-xs [&>svg]:univer-size-6" : showLabel ? "univer-gap-1 univer-px-1.5 univer-text-sm" : "univer-text-sm", grid && fullWidth && isCustomComponent && "!univer-px-0");
|
|
4685
|
+
const buttonClassName = clsx(grid && !large && "[&>svg]:univer-size-4", grid && large ? "univer-h-full univer-min-w-14 univer-flex-col univer-gap-1 univer-px-1.5 univer-py-1 univer-text-xs [&>svg]:univer-size-6" : showLabel ? "univer-gap-1 univer-px-1.5 univer-text-sm" : "univer-text-sm", grid && fullWidth && isCustomComponent && "!univer-px-0", overflow && "!univer-h-auto univer-min-h-7 univer-w-full univer-justify-start univer-gap-1.5 univer-whitespace-normal univer-px-1.5 univer-py-1 univer-text-start univer-text-xs focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600");
|
|
4287
4686
|
const buttonStyle = grid && large ? {
|
|
4288
4687
|
textAlign: "center",
|
|
4289
4688
|
whiteSpace: "normal"
|
|
@@ -4301,7 +4700,7 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
4301
4700
|
"aria-disabled": disabled,
|
|
4302
4701
|
children: /* @__PURE__ */ jsx(CustomLabel, {
|
|
4303
4702
|
className: grid && fullWidth ? "!univer-w-full" : void 0,
|
|
4304
|
-
title: grid && showLabel ? gridLabel : title,
|
|
4703
|
+
title: overflow ? void 0 : grid && showLabel ? gridLabel : title,
|
|
4305
4704
|
value,
|
|
4306
4705
|
label
|
|
4307
4706
|
})
|
|
@@ -4319,7 +4718,7 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
4319
4718
|
onClick: (event) => {
|
|
4320
4719
|
if (props.subId && event.detail > 1) return;
|
|
4321
4720
|
const commandParams = typeof params === "function" ? params() : params;
|
|
4322
|
-
executeCommand(props.commandId ?? props.id, commandParams ?? (typeof value === "undefined" ? void 0 : { value }));
|
|
4721
|
+
return executeCommand(props.commandId ?? props.id, commandParams ?? (typeof value === "undefined" ? void 0 : { value }));
|
|
4323
4722
|
},
|
|
4324
4723
|
onDoubleClick: () => props.subId && executeCommand(props.subId),
|
|
4325
4724
|
children: icon ? /* @__PURE__ */ jsx(CustomLabel, {
|
|
@@ -4327,7 +4726,7 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
4327
4726
|
iconSize,
|
|
4328
4727
|
preserveStrokeWidth,
|
|
4329
4728
|
title: grid && (large || showLabel) ? gridLabel : void 0
|
|
4330
|
-
}) : /* @__PURE__ */ jsx(CustomLabel, { title })
|
|
4729
|
+
}) : /* @__PURE__ */ jsx(CustomLabel, { title: overflow ? gridLabel : title })
|
|
4331
4730
|
});
|
|
4332
4731
|
}
|
|
4333
4732
|
function renderItem() {
|
|
@@ -4348,49 +4747,219 @@ const ToolbarItem = forwardRef((props, ref) => {
|
|
|
4348
4747
|
});
|
|
4349
4748
|
});
|
|
4350
4749
|
|
|
4750
|
+
//#endregion
|
|
4751
|
+
//#region src/views/components/ribbon/RibbonOverflow.tsx
|
|
4752
|
+
/**
|
|
4753
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
4754
|
+
*
|
|
4755
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4756
|
+
* you may not use this file except in compliance with the License.
|
|
4757
|
+
* You may obtain a copy of the License at
|
|
4758
|
+
*
|
|
4759
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4760
|
+
*
|
|
4761
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4762
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4763
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4764
|
+
* See the License for the specific language governing permissions and
|
|
4765
|
+
* limitations under the License.
|
|
4766
|
+
*/
|
|
4767
|
+
function RibbonOverflow({ groups, grid = false }) {
|
|
4768
|
+
const localeService = useDependency(LocaleService);
|
|
4769
|
+
const dialogService = useDependency(IDialogService);
|
|
4770
|
+
const sidebarService = useDependency(ISidebarService);
|
|
4771
|
+
const { direction } = useContext(ConfigContext);
|
|
4772
|
+
const [openedGroups, setOpenedGroups] = useState(null);
|
|
4773
|
+
const open = openedGroups === groups;
|
|
4774
|
+
const keyboardRef = useRef(false);
|
|
4775
|
+
const restoreFocusRef = useRef(true);
|
|
4776
|
+
const label = localeService.t("ui.ribbon.more");
|
|
4777
|
+
useEffect(() => {
|
|
4778
|
+
if (!open) return;
|
|
4779
|
+
const closeForPanel = () => {
|
|
4780
|
+
restoreFocusRef.current = false;
|
|
4781
|
+
setOpenedGroups(null);
|
|
4782
|
+
};
|
|
4783
|
+
const sidebar = sidebarService.sidebarOptions$.subscribe((options) => {
|
|
4784
|
+
if (options.visible) closeForPanel();
|
|
4785
|
+
});
|
|
4786
|
+
const dialogs = dialogService.getDialogs$().subscribe((options) => {
|
|
4787
|
+
if (options.some((dialog) => dialog.open)) closeForPanel();
|
|
4788
|
+
});
|
|
4789
|
+
return () => {
|
|
4790
|
+
sidebar.unsubscribe();
|
|
4791
|
+
dialogs.unsubscribe();
|
|
4792
|
+
};
|
|
4793
|
+
}, [
|
|
4794
|
+
open,
|
|
4795
|
+
dialogService,
|
|
4796
|
+
sidebarService
|
|
4797
|
+
]);
|
|
4798
|
+
return /* @__PURE__ */ jsx(Dropdown, {
|
|
4799
|
+
open,
|
|
4800
|
+
onOpenChange: (visible) => {
|
|
4801
|
+
if (visible) restoreFocusRef.current = true;
|
|
4802
|
+
setOpenedGroups(visible ? groups : null);
|
|
4803
|
+
},
|
|
4804
|
+
align: direction === "rtl" ? "start" : "end",
|
|
4805
|
+
collisionPadding: 12,
|
|
4806
|
+
"aria-label": label,
|
|
4807
|
+
"data-u-comp": "ribbon-overflow",
|
|
4808
|
+
className: "univer-w-80 univer-max-w-[--radix-popper-available-width] univer-overflow-x-hidden",
|
|
4809
|
+
onOpenAutoFocus: (event) => {
|
|
4810
|
+
if (!keyboardRef.current) event.preventDefault();
|
|
4811
|
+
},
|
|
4812
|
+
onFocusOutside: (event) => {
|
|
4813
|
+
event.preventDefault();
|
|
4814
|
+
},
|
|
4815
|
+
onCloseAutoFocus: (event) => {
|
|
4816
|
+
if (!restoreFocusRef.current) event.preventDefault();
|
|
4817
|
+
},
|
|
4818
|
+
overlay: /* @__PURE__ */ jsx(ToolbarDropdownProvider, { children: /* @__PURE__ */ jsx("div", {
|
|
4819
|
+
className: "univer-px-2 univer-py-1",
|
|
4820
|
+
children: groups.map((group, index) => /* @__PURE__ */ jsxs("section", {
|
|
4821
|
+
"aria-label": group.title ? localeService.t(group.title) : void 0,
|
|
4822
|
+
className: clsx("univer-py-1.5", index > 0 && borderTopClassName),
|
|
4823
|
+
children: [group.title && /* @__PURE__ */ jsx("h3", {
|
|
4824
|
+
className: "univer-m-0 univer-mb-1 univer-px-1 univer-text-xs univer-font-medium univer-text-gray-500 dark:!univer-text-gray-400",
|
|
4825
|
+
children: localeService.t(group.title)
|
|
4826
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
4827
|
+
className: "univer-flex univer-flex-wrap univer-items-center univer-gap-1",
|
|
4828
|
+
children: (group.children ?? [group]).map((child) => {
|
|
4829
|
+
var _child$gridLayout, _child$gridLayout2;
|
|
4830
|
+
return child.item && /* @__PURE__ */ jsx("div", {
|
|
4831
|
+
className: "univer-min-w-0 univer-max-w-full [&>span]:univer-block [&>span]:univer-h-full",
|
|
4832
|
+
style: { width: child.item.label && !child.item.icon ? (_child$gridLayout = child.gridLayout) === null || _child$gridLayout === void 0 ? void 0 : _child$gridLayout.width : void 0 },
|
|
4833
|
+
children: /* @__PURE__ */ jsx(ToolbarItem, {
|
|
4834
|
+
...child.item,
|
|
4835
|
+
grid: true,
|
|
4836
|
+
showLabel: (_child$gridLayout2 = child.gridLayout) === null || _child$gridLayout2 === void 0 ? void 0 : _child$gridLayout2.showLabel,
|
|
4837
|
+
fullWidth: true,
|
|
4838
|
+
overflow: true,
|
|
4839
|
+
preserveStrokeWidth: true
|
|
4840
|
+
})
|
|
4841
|
+
}, child.key);
|
|
4842
|
+
})
|
|
4843
|
+
})]
|
|
4844
|
+
}, group.key))
|
|
4845
|
+
}) }),
|
|
4846
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
4847
|
+
type: "button",
|
|
4848
|
+
"aria-label": label,
|
|
4849
|
+
onPointerDown: () => {
|
|
4850
|
+
keyboardRef.current = false;
|
|
4851
|
+
},
|
|
4852
|
+
onKeyDown: () => {
|
|
4853
|
+
keyboardRef.current = true;
|
|
4854
|
+
},
|
|
4855
|
+
className: clsx(toolbarButtonClassName, "data-[state=open]:univer-bg-primary-50 data-[state=open]:univer-text-primary-600 focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 dark:data-[state=open]:!univer-bg-gray-700 dark:data-[state=open]:!univer-text-primary-300", grid && "!univer-h-14 !univer-w-14 univer-flex-col univer-gap-1.5 univer-text-xs"),
|
|
4856
|
+
children: grid ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(MoreHorizontalIcon, {
|
|
4857
|
+
className: "univer-size-5",
|
|
4858
|
+
preserveStrokeWidth: true
|
|
4859
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
4860
|
+
className: "univer-flex univer-items-center univer-gap-0.5",
|
|
4861
|
+
children: [label, /* @__PURE__ */ jsx(MoreDownIcon, {
|
|
4862
|
+
className: "univer-size-3",
|
|
4863
|
+
preserveStrokeWidth: true
|
|
4864
|
+
})]
|
|
4865
|
+
})] }) : /* @__PURE__ */ jsx(MoreVerticalIcon, { preserveStrokeWidth: true })
|
|
4866
|
+
})
|
|
4867
|
+
});
|
|
4868
|
+
}
|
|
4869
|
+
|
|
4351
4870
|
//#endregion
|
|
4352
4871
|
//#region src/views/components/ribbon/RibbonGrid.tsx
|
|
4353
4872
|
function RibbonGrid({ groups, title, className, ...props }) {
|
|
4354
4873
|
const localeService = useDependency(LocaleService);
|
|
4874
|
+
const containerRef = useRef(null);
|
|
4875
|
+
const moreRef = useRef(null);
|
|
4876
|
+
const groupsRef = useRef(/* @__PURE__ */ new Map());
|
|
4877
|
+
const [visibleGroupCount, setVisibleGroupCount] = useState(groups.length);
|
|
4878
|
+
useLayoutEffect(() => {
|
|
4879
|
+
const container = containerRef.current;
|
|
4880
|
+
if (!container) return;
|
|
4881
|
+
const measure = () => {
|
|
4882
|
+
var _moreRef$current;
|
|
4883
|
+
const style = getComputedStyle(container);
|
|
4884
|
+
const availableWidth = container.clientWidth - Number.parseFloat(style.paddingLeft || "0") - Number.parseFloat(style.paddingRight || "0");
|
|
4885
|
+
const widths = groups.map((group) => {
|
|
4886
|
+
var _groupsRef$current$ge;
|
|
4887
|
+
return ((_groupsRef$current$ge = groupsRef.current.get(group.key)) === null || _groupsRef$current$ge === void 0 ? void 0 : _groupsRef$current$ge.getBoundingClientRect().width) ?? 0;
|
|
4888
|
+
});
|
|
4889
|
+
const limit = widths.reduce((sum, width) => sum + width, 0) <= availableWidth ? availableWidth : availableWidth - (((_moreRef$current = moreRef.current) === null || _moreRef$current === void 0 ? void 0 : _moreRef$current.getBoundingClientRect().width) ?? 0);
|
|
4890
|
+
let used = 0;
|
|
4891
|
+
let count = 0;
|
|
4892
|
+
for (const width of widths) {
|
|
4893
|
+
if (used + width > limit) break;
|
|
4894
|
+
used += width;
|
|
4895
|
+
count += 1;
|
|
4896
|
+
}
|
|
4897
|
+
setVisibleGroupCount(count);
|
|
4898
|
+
};
|
|
4899
|
+
const observer = new ResizeObserver(measure);
|
|
4900
|
+
observer.observe(container);
|
|
4901
|
+
groupsRef.current.forEach((element) => observer.observe(element));
|
|
4902
|
+
if (moreRef.current) observer.observe(moreRef.current);
|
|
4903
|
+
return () => observer.disconnect();
|
|
4904
|
+
}, [groups, visibleGroupCount]);
|
|
4905
|
+
const hiddenGroups = groups.slice(visibleGroupCount);
|
|
4355
4906
|
return /* @__PURE__ */ jsx("div", {
|
|
4356
4907
|
...props,
|
|
4908
|
+
ref: containerRef,
|
|
4357
4909
|
"data-testid": "ribbon-grid-toolbar",
|
|
4358
4910
|
"data-u-comp": "ribbon-grid-toolbar",
|
|
4359
|
-
className: clsx("univer-box-border univer-flex univer-
|
|
4911
|
+
className: clsx("univer-relative univer-box-border univer-flex univer-h-[73px] univer-min-w-0 univer-overflow-hidden univer-bg-gray-50 univer-px-2 univer-text-sm dark:!univer-bg-gray-900", borderBottomClassName, className),
|
|
4360
4912
|
role: "toolbar",
|
|
4361
4913
|
"aria-label": localeService.t(title),
|
|
4362
|
-
children: /* @__PURE__ */
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4914
|
+
children: /* @__PURE__ */ jsxs(ToolbarDropdownProvider, { children: [/* @__PURE__ */ jsx("div", {
|
|
4915
|
+
className: "univer-flex univer-min-w-0 univer-overflow-hidden",
|
|
4916
|
+
children: groups.map((group, index) => {
|
|
4917
|
+
const placements = placeRibbonGridItems(group.children ?? []);
|
|
4918
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4919
|
+
ref: (element) => {
|
|
4920
|
+
if (element) groupsRef.current.set(group.key, element);
|
|
4921
|
+
else groupsRef.current.delete(group.key);
|
|
4922
|
+
},
|
|
4923
|
+
"data-u-comp": "ribbon-grid-group",
|
|
4924
|
+
"data-group-key": group.key,
|
|
4925
|
+
"aria-hidden": index >= visibleGroupCount || void 0,
|
|
4926
|
+
className: clsx("univer-relative univer-box-border univer-flex univer-w-max univer-shrink-0 univer-flex-col univer-px-2", index >= visibleGroupCount && "univer-pointer-events-none univer-invisible univer-absolute"),
|
|
4927
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
4928
|
+
"data-testid": "ribbon-grid-group-grid",
|
|
4929
|
+
className: "univer-grid univer-min-h-0 univer-flex-1 univer-grid-flow-col univer-grid-rows-[repeat(2,1.5rem)] univer-content-center univer-gap-2 univer-py-2 [&>div>span>span]:univer-h-full",
|
|
4930
|
+
children: placements.map((placement) => placement.item.item && /* @__PURE__ */ jsx("div", {
|
|
4931
|
+
className: clsx("univer-flex univer-items-stretch [&>span>button]:univer-h-full [&>span]:univer-h-full", placement.width && "[&>span>span]:univer-w-full [&>span]:univer-w-full [&_[data-u-command]]:univer-w-full"),
|
|
4932
|
+
style: {
|
|
4933
|
+
gridRow: `${placement.row} / span ${placement.rowSpan}`,
|
|
4934
|
+
gridColumn: `${placement.column} / span ${placement.columnSpan}`,
|
|
4935
|
+
width: placement.width
|
|
4936
|
+
},
|
|
4937
|
+
children: /* @__PURE__ */ jsx(ToolbarItem, {
|
|
4938
|
+
...placement.item.item,
|
|
4939
|
+
grid: true,
|
|
4940
|
+
large: placement.rowSpan > 1,
|
|
4941
|
+
showLabel: placement.showLabel,
|
|
4942
|
+
iconSize: placement.iconSize,
|
|
4943
|
+
fullWidth: placement.width !== void 0,
|
|
4944
|
+
preserveStrokeWidth: true
|
|
4945
|
+
})
|
|
4946
|
+
}, placement.item.key))
|
|
4947
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
4948
|
+
"data-testid": "ribbon-grid-group-divider",
|
|
4949
|
+
className: clsx("univer-pointer-events-none univer-absolute univer-bottom-1.5 univer-right-0 univer-top-3.5 !univer-border-gray-300 univer-opacity-50 rtl:univer-left-0 rtl:univer-right-auto", borderRightClassName),
|
|
4950
|
+
"aria-hidden": "true"
|
|
4951
|
+
})]
|
|
4952
|
+
}, group.key);
|
|
4953
|
+
})
|
|
4954
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
4955
|
+
ref: moreRef,
|
|
4956
|
+
"aria-hidden": hiddenGroups.length === 0 || void 0,
|
|
4957
|
+
className: clsx("univer-box-border univer-w-16 univer-shrink-0 univer-py-2 univer-pl-2 rtl:univer-pl-0 rtl:univer-pr-2", hiddenGroups.length === 0 && "univer-invisible univer-absolute"),
|
|
4958
|
+
children: hiddenGroups.length > 0 && /* @__PURE__ */ jsx(RibbonOverflow, {
|
|
4959
|
+
groups: hiddenGroups,
|
|
4960
|
+
grid: true
|
|
4961
|
+
})
|
|
4962
|
+
})] }, visibleGroupCount)
|
|
4394
4963
|
});
|
|
4395
4964
|
}
|
|
4396
4965
|
|
|
@@ -4580,7 +5149,7 @@ function Ribbon(props) {
|
|
|
4580
5149
|
...embedRibbonOverrideAttributes,
|
|
4581
5150
|
groups: activeGroup.allGroups,
|
|
4582
5151
|
title: activatedTabTitle
|
|
4583
|
-
}),
|
|
5152
|
+
}, effectiveActivatedTab),
|
|
4584
5153
|
!hideToolbar && ribbonType !== "grid" && /* @__PURE__ */ jsxs("div", {
|
|
4585
5154
|
...embedRibbonOverrideAttributes,
|
|
4586
5155
|
className: clsx("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm", {
|
|
@@ -4608,37 +5177,7 @@ function Ribbon(props) {
|
|
|
4608
5177
|
}) }, groupItem.key);
|
|
4609
5178
|
}), collapsedIds.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
4610
5179
|
className: "univer-pl-2 rtl:univer-pr-2",
|
|
4611
|
-
children: /* @__PURE__ */ jsx(
|
|
4612
|
-
collisionPadding: {
|
|
4613
|
-
right: 12,
|
|
4614
|
-
left: 12
|
|
4615
|
-
},
|
|
4616
|
-
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
4617
|
-
overlay: /* @__PURE__ */ jsx("div", {
|
|
4618
|
-
className: "univer-box-border univer-grid univer-max-w-[--radix-popper-available-width] univer-gap-2 univer-p-2",
|
|
4619
|
-
children: activeGroup.hiddenGroups.map((groupItem) => {
|
|
4620
|
-
var _groupItem$children5;
|
|
4621
|
-
return /* @__PURE__ */ jsx("div", {
|
|
4622
|
-
className: "univer-flex univer-items-center univer-gap-2",
|
|
4623
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
4624
|
-
className: "univer-flex univer-flex-wrap univer-gap-2",
|
|
4625
|
-
children: groupItem.children ? (_groupItem$children5 = groupItem.children) === null || _groupItem$children5 === void 0 ? void 0 : _groupItem$children5.map((child) => child.item && /* @__PURE__ */ jsx(ToolbarItem, {
|
|
4626
|
-
...child.item,
|
|
4627
|
-
preserveStrokeWidth: true
|
|
4628
|
-
}, child.key)) : groupItem.item && /* @__PURE__ */ jsx(ToolbarItem, {
|
|
4629
|
-
...groupItem.item,
|
|
4630
|
-
preserveStrokeWidth: true
|
|
4631
|
-
}, groupItem.key)
|
|
4632
|
-
})
|
|
4633
|
-
}, groupItem.key);
|
|
4634
|
-
})
|
|
4635
|
-
}),
|
|
4636
|
-
children: /* @__PURE__ */ jsx("button", {
|
|
4637
|
-
type: "button",
|
|
4638
|
-
className: toolbarButtonClassName,
|
|
4639
|
-
children: /* @__PURE__ */ jsx(MoreVerticalIcon, { preserveStrokeWidth: true })
|
|
4640
|
-
})
|
|
4641
|
-
})
|
|
5180
|
+
children: /* @__PURE__ */ jsx(RibbonOverflow, { groups: activeGroup.hiddenGroups })
|
|
4642
5181
|
})] }, effectiveActivatedTab)
|
|
4643
5182
|
})]
|
|
4644
5183
|
}),
|
|
@@ -5774,8 +6313,9 @@ function ContextMenuMenuItem(props) {
|
|
|
5774
6313
|
const scheduleSubmenuClose = useCallback(() => {
|
|
5775
6314
|
clearSubmenuCloseTimer();
|
|
5776
6315
|
submenuCloseTimerRef.current = setTimeout(() => {
|
|
6316
|
+
var _submenuElementRef$cu;
|
|
5777
6317
|
submenuCloseTimerRef.current = null;
|
|
5778
|
-
closeSubmenu();
|
|
6318
|
+
if (!((_submenuElementRef$cu = submenuElementRef.current) === null || _submenuElementRef$cu === void 0 ? void 0 : _submenuElementRef$cu.contains(document.activeElement))) closeSubmenu();
|
|
5779
6319
|
}, 500);
|
|
5780
6320
|
}, [clearSubmenuCloseTimer, closeSubmenu]);
|
|
5781
6321
|
useEffect(() => {
|
|
@@ -5791,9 +6331,9 @@ function ContextMenuMenuItem(props) {
|
|
|
5791
6331
|
return preventBrowserZoomInContainers([submenuElement]);
|
|
5792
6332
|
}, [submenuVisible]);
|
|
5793
6333
|
useLayoutEffect(() => {
|
|
5794
|
-
var _submenuElementRef$
|
|
6334
|
+
var _submenuElementRef$cu2;
|
|
5795
6335
|
if (!submenuVisible || !submenuPositionReady || !keyboardSubmenuFocusRequested) return;
|
|
5796
|
-
const firstEnabledButton = (_submenuElementRef$
|
|
6336
|
+
const firstEnabledButton = (_submenuElementRef$cu2 = submenuElementRef.current) === null || _submenuElementRef$cu2 === void 0 ? void 0 : _submenuElementRef$cu2.querySelector("button:not(:disabled)");
|
|
5797
6337
|
firstEnabledButton === null || firstEnabledButton === void 0 || firstEnabledButton.focus();
|
|
5798
6338
|
}, [
|
|
5799
6339
|
keyboardSubmenuFocusRequested,
|
|
@@ -5827,10 +6367,13 @@ function ContextMenuMenuItem(props) {
|
|
|
5827
6367
|
setSubmenuPositionReady(true);
|
|
5828
6368
|
};
|
|
5829
6369
|
const frameId = window.requestAnimationFrame(updateSubmenuPosition);
|
|
6370
|
+
const resizeObserver = new ResizeObserver(updateSubmenuPosition);
|
|
6371
|
+
if (submenuElementRef.current) resizeObserver.observe(submenuElementRef.current);
|
|
5830
6372
|
window.addEventListener("resize", updateSubmenuPosition);
|
|
5831
6373
|
window.addEventListener("scroll", updateSubmenuPosition, true);
|
|
5832
6374
|
return () => {
|
|
5833
6375
|
window.cancelAnimationFrame(frameId);
|
|
6376
|
+
resizeObserver.disconnect();
|
|
5834
6377
|
window.removeEventListener("resize", updateSubmenuPosition);
|
|
5835
6378
|
window.removeEventListener("scroll", updateSubmenuPosition, true);
|
|
5836
6379
|
};
|
|
@@ -5887,9 +6430,10 @@ function ContextMenuMenuItem(props) {
|
|
|
5887
6430
|
},
|
|
5888
6431
|
onMouseLeave: (event) => {
|
|
5889
6432
|
if (hasSubmenu) {
|
|
5890
|
-
var _submenuElementRef$
|
|
6433
|
+
var _submenuElementRef$cu3, _submenuElementRef$cu4;
|
|
6434
|
+
if ((_submenuElementRef$cu3 = submenuElementRef.current) === null || _submenuElementRef$cu3 === void 0 ? void 0 : _submenuElementRef$cu3.contains(document.activeElement)) return;
|
|
5891
6435
|
const nextTarget = event.relatedTarget;
|
|
5892
|
-
if (nextTarget && ((_submenuElementRef$
|
|
6436
|
+
if (nextTarget && ((_submenuElementRef$cu4 = submenuElementRef.current) === null || _submenuElementRef$cu4 === void 0 ? void 0 : _submenuElementRef$cu4.contains(nextTarget))) return;
|
|
5893
6437
|
if (isContextMenuPointerLeaveTarget(nextTarget, menuItemElementRef.current, rootMenuElement)) {
|
|
5894
6438
|
closeSubmenu();
|
|
5895
6439
|
return;
|
|
@@ -5985,7 +6529,8 @@ function ContextMenuMenuItem(props) {
|
|
|
5985
6529
|
onMenuPointerEnter === null || onMenuPointerEnter === void 0 || onMenuPointerEnter();
|
|
5986
6530
|
},
|
|
5987
6531
|
onMouseLeave: (event) => {
|
|
5988
|
-
var _menuItemElementRef$c;
|
|
6532
|
+
var _submenuElementRef$cu5, _menuItemElementRef$c;
|
|
6533
|
+
if ((_submenuElementRef$cu5 = submenuElementRef.current) === null || _submenuElementRef$cu5 === void 0 ? void 0 : _submenuElementRef$cu5.contains(document.activeElement)) return;
|
|
5989
6534
|
const nextTarget = event.relatedTarget;
|
|
5990
6535
|
if (nextTarget && ((_menuItemElementRef$c = menuItemElementRef.current) === null || _menuItemElementRef$c === void 0 ? void 0 : _menuItemElementRef$c.contains(nextTarget))) return;
|
|
5991
6536
|
if (isContextMenuPointerLeaveTarget(nextTarget, menuItemElementRef.current, rootMenuElement)) {
|
|
@@ -7092,7 +7637,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
|
|
|
7092
7637
|
//#endregion
|
|
7093
7638
|
//#region package.json
|
|
7094
7639
|
var name = "@univerjs/ui";
|
|
7095
|
-
var version = "1.
|
|
7640
|
+
var version = "1.3.0";
|
|
7096
7641
|
|
|
7097
7642
|
//#endregion
|
|
7098
7643
|
//#region src/views/color-picker/interface.ts
|
|
@@ -23134,299 +23679,6 @@ function MobileEmojiPicker(props) {
|
|
|
23134
23679
|
});
|
|
23135
23680
|
}
|
|
23136
23681
|
|
|
23137
|
-
//#endregion
|
|
23138
|
-
//#region src/services/font.service.ts
|
|
23139
|
-
const IFontService = createIdentifier("univer.font-service");
|
|
23140
|
-
const DEFAULT_FONT_LIST = [
|
|
23141
|
-
"宋体",
|
|
23142
|
-
"Arial",
|
|
23143
|
-
"Baskerville",
|
|
23144
|
-
"Comic Sans MS",
|
|
23145
|
-
"Courier New",
|
|
23146
|
-
"Helvetica",
|
|
23147
|
-
"Times New Roman",
|
|
23148
|
-
"Verdana",
|
|
23149
|
-
"Apple LiGothic",
|
|
23150
|
-
"Apple LiSung",
|
|
23151
|
-
"Hei",
|
|
23152
|
-
"Kai",
|
|
23153
|
-
"LiHei Pro",
|
|
23154
|
-
"LiSong Pro",
|
|
23155
|
-
"STFangsong",
|
|
23156
|
-
"STHeiti",
|
|
23157
|
-
"STKaiti",
|
|
23158
|
-
"STSong",
|
|
23159
|
-
"报隶-繁",
|
|
23160
|
-
"报隶-简",
|
|
23161
|
-
"冬青黑体简体中文",
|
|
23162
|
-
"黑体-繁",
|
|
23163
|
-
"黑体-简",
|
|
23164
|
-
"华文仿宋",
|
|
23165
|
-
"华文楷体",
|
|
23166
|
-
"华文宋体",
|
|
23167
|
-
"楷体-繁",
|
|
23168
|
-
"楷体-简",
|
|
23169
|
-
"兰亭黑-繁",
|
|
23170
|
-
"兰亭黑-简",
|
|
23171
|
-
"隶变-繁",
|
|
23172
|
-
"隶变-简",
|
|
23173
|
-
"凌慧体-繁",
|
|
23174
|
-
"凌慧体-简",
|
|
23175
|
-
"翩翩体-繁",
|
|
23176
|
-
"翩翩体-简",
|
|
23177
|
-
"苹方-繁",
|
|
23178
|
-
"苹方-港",
|
|
23179
|
-
"苹方-简",
|
|
23180
|
-
"手札体-繁",
|
|
23181
|
-
"手札体-简",
|
|
23182
|
-
"宋体-繁",
|
|
23183
|
-
"宋体-简",
|
|
23184
|
-
"娃娃体-繁",
|
|
23185
|
-
"娃娃体-简",
|
|
23186
|
-
"魏碑-繁",
|
|
23187
|
-
"魏碑-简",
|
|
23188
|
-
"行楷-繁",
|
|
23189
|
-
"行楷-简",
|
|
23190
|
-
"雅痞-繁",
|
|
23191
|
-
"雅痞-简",
|
|
23192
|
-
"圆体-繁",
|
|
23193
|
-
"圆体-简",
|
|
23194
|
-
"Arial Black",
|
|
23195
|
-
"Big Caslon",
|
|
23196
|
-
"Courier",
|
|
23197
|
-
"Didot",
|
|
23198
|
-
"Futura",
|
|
23199
|
-
"Georgia",
|
|
23200
|
-
"Helvetica Neue",
|
|
23201
|
-
"Optima",
|
|
23202
|
-
"Times",
|
|
23203
|
-
"Tahoma",
|
|
23204
|
-
"BIZ UDGothic",
|
|
23205
|
-
"BIZ UDMincho",
|
|
23206
|
-
"Hiragino Maru Gothic Pro",
|
|
23207
|
-
"Hiragino Maru Gothic ProN",
|
|
23208
|
-
"Hiragino Mincho Pro",
|
|
23209
|
-
"Hiragino Mincho ProN",
|
|
23210
|
-
"Hiragino Sans",
|
|
23211
|
-
"Klee",
|
|
23212
|
-
"Osaka",
|
|
23213
|
-
"Toppan Bunkyu Gothic",
|
|
23214
|
-
"Toppan Bunkyu Midashi Gothic",
|
|
23215
|
-
"Toppan Bunkyu Midashi Mincho",
|
|
23216
|
-
"Toppan Bunkyu Mincho",
|
|
23217
|
-
"Tsukushi A Round Gothic",
|
|
23218
|
-
"Tsukushi B Round Gothic",
|
|
23219
|
-
"YuKyokasho",
|
|
23220
|
-
"YuKyokasho Yoko",
|
|
23221
|
-
"YuMincho +36p Kana",
|
|
23222
|
-
"American Typewriter",
|
|
23223
|
-
"Andale Mono",
|
|
23224
|
-
"Apple Chancery",
|
|
23225
|
-
"Apple SD Gothic Neo",
|
|
23226
|
-
"Apple Symbols",
|
|
23227
|
-
"AppleGothic",
|
|
23228
|
-
"AppleMyungjo",
|
|
23229
|
-
"Arial Unicode MS",
|
|
23230
|
-
"Athelas",
|
|
23231
|
-
"Avenir",
|
|
23232
|
-
"Avenir Next",
|
|
23233
|
-
"Avenir Next Condensed",
|
|
23234
|
-
"Ayuthaya",
|
|
23235
|
-
"Bangla MN",
|
|
23236
|
-
"Bangla Sangam MN",
|
|
23237
|
-
"Bauhaus 93",
|
|
23238
|
-
"Bodoni 72",
|
|
23239
|
-
"Bodoni 72 Oldstyle",
|
|
23240
|
-
"Bodoni 72 Smallcaps",
|
|
23241
|
-
"Bodoni Ornaments",
|
|
23242
|
-
"Bookshelf Symbol 7",
|
|
23243
|
-
"Bradley Hand",
|
|
23244
|
-
"Chalkboard",
|
|
23245
|
-
"Chalkboard SE",
|
|
23246
|
-
"Chalkduster",
|
|
23247
|
-
"Charter",
|
|
23248
|
-
"Cochin",
|
|
23249
|
-
"Copperplate",
|
|
23250
|
-
"Devanagari Sangam MN",
|
|
23251
|
-
"Din Alternate",
|
|
23252
|
-
"Euphemia UCAS",
|
|
23253
|
-
"Galvji",
|
|
23254
|
-
"Geneva",
|
|
23255
|
-
"Gill Sans",
|
|
23256
|
-
"Gujarati Sangam MN",
|
|
23257
|
-
"GungSeo",
|
|
23258
|
-
"Gurmukhi MN",
|
|
23259
|
-
"Gurmukhi Sangam MN",
|
|
23260
|
-
"HeadLineA",
|
|
23261
|
-
"Herculanum",
|
|
23262
|
-
"Hiragino Kaku Gothic Pro",
|
|
23263
|
-
"Hiragino Kaku Gothic ProN",
|
|
23264
|
-
"Hiragino Kaku Gothic Std",
|
|
23265
|
-
"Hiragino Kaku Gothic StdN",
|
|
23266
|
-
"Hoefler Text",
|
|
23267
|
-
"Impact",
|
|
23268
|
-
"InaiMathi",
|
|
23269
|
-
"Iowan Old Style",
|
|
23270
|
-
"Kannada MN",
|
|
23271
|
-
"Kannada Sangam MN",
|
|
23272
|
-
"Kefa",
|
|
23273
|
-
"Khmer MN",
|
|
23274
|
-
"Khmer Sangam MN",
|
|
23275
|
-
"Kohinoor Bangla",
|
|
23276
|
-
"Kohinoor Devanagari",
|
|
23277
|
-
"Kohinoor Telugu",
|
|
23278
|
-
"Krungthep",
|
|
23279
|
-
"Lao MN",
|
|
23280
|
-
"Lao Sangam MN",
|
|
23281
|
-
"Lucida Grande",
|
|
23282
|
-
"Luminari",
|
|
23283
|
-
"Malayalam MN",
|
|
23284
|
-
"Malayalam Sangam MN",
|
|
23285
|
-
"Marion",
|
|
23286
|
-
"Marker Felt",
|
|
23287
|
-
"Menlo",
|
|
23288
|
-
"Microsoft Sans Serif",
|
|
23289
|
-
"Modern No. 20",
|
|
23290
|
-
"Monaco",
|
|
23291
|
-
"Mukta Mahee",
|
|
23292
|
-
"Nanum Brush Script",
|
|
23293
|
-
"Nanum Gothic",
|
|
23294
|
-
"Nanum Myeongjo",
|
|
23295
|
-
"Nanum Pen Script",
|
|
23296
|
-
"Noteworthy",
|
|
23297
|
-
"Oriya MN",
|
|
23298
|
-
"Oriya Sangam MN",
|
|
23299
|
-
"Palatino",
|
|
23300
|
-
"Papyrus",
|
|
23301
|
-
"PCMyungjo",
|
|
23302
|
-
"Phosphate",
|
|
23303
|
-
"PilGi",
|
|
23304
|
-
"Plantagenet Cherokee",
|
|
23305
|
-
"PT Mono",
|
|
23306
|
-
"PT Sans",
|
|
23307
|
-
"PT Sans Caption",
|
|
23308
|
-
"PT Serif",
|
|
23309
|
-
"PT Serif Caption",
|
|
23310
|
-
"Rockwell",
|
|
23311
|
-
"Sathu",
|
|
23312
|
-
"Savoye LET",
|
|
23313
|
-
"Seravek",
|
|
23314
|
-
"Shree Devanagari 714",
|
|
23315
|
-
"SignPainter",
|
|
23316
|
-
"Silom",
|
|
23317
|
-
"Sinhala MN",
|
|
23318
|
-
"Sinhala Sangam MN",
|
|
23319
|
-
"Skia",
|
|
23320
|
-
"Snell Roundhand",
|
|
23321
|
-
"STIXGeneral",
|
|
23322
|
-
"Sukhumvit Set",
|
|
23323
|
-
"Superclarendon",
|
|
23324
|
-
"Tamil MN",
|
|
23325
|
-
"Tamil Sangam MN",
|
|
23326
|
-
"Telugu MN",
|
|
23327
|
-
"Telugu Sangam MN",
|
|
23328
|
-
"Trattatello",
|
|
23329
|
-
"Trebuchet MS",
|
|
23330
|
-
"Webdings",
|
|
23331
|
-
"Wingdings",
|
|
23332
|
-
"Wingdings 2",
|
|
23333
|
-
"Wingdings 3",
|
|
23334
|
-
"YuGothic",
|
|
23335
|
-
"YuGothic Light",
|
|
23336
|
-
"YuGothic Medium",
|
|
23337
|
-
"Zapfino"
|
|
23338
|
-
].map((value) => ({
|
|
23339
|
-
value,
|
|
23340
|
-
label: value
|
|
23341
|
-
}));
|
|
23342
|
-
let FontService = class FontService {
|
|
23343
|
-
constructor(_configService) {
|
|
23344
|
-
this._configService = _configService;
|
|
23345
|
-
_defineProperty(this, "fonts$", new BehaviorSubject([]));
|
|
23346
|
-
const { customFontFamily } = this._configService.getConfig("ui.config") ?? {};
|
|
23347
|
-
let fonts = [];
|
|
23348
|
-
if (customFontFamily) {
|
|
23349
|
-
if (Array.isArray(customFontFamily)) fonts = [...DEFAULT_FONT_LIST, ...customFontFamily];
|
|
23350
|
-
else if (customFontFamily.override) fonts = [...customFontFamily.list];
|
|
23351
|
-
else fonts = [...DEFAULT_FONT_LIST, ...customFontFamily.list];
|
|
23352
|
-
} else fonts = [...DEFAULT_FONT_LIST];
|
|
23353
|
-
this.fonts$.next(fonts);
|
|
23354
|
-
}
|
|
23355
|
-
dispose() {
|
|
23356
|
-
this.resetToDefaults();
|
|
23357
|
-
this.fonts$.complete();
|
|
23358
|
-
}
|
|
23359
|
-
getFonts() {
|
|
23360
|
-
return this.fonts$.getValue();
|
|
23361
|
-
}
|
|
23362
|
-
getFontByValue(value) {
|
|
23363
|
-
return this.getFonts().find((font) => font.value === value);
|
|
23364
|
-
}
|
|
23365
|
-
/**
|
|
23366
|
-
* Check if the current browser environment supports the font
|
|
23367
|
-
* @param fontValue
|
|
23368
|
-
* @returns boolean Whether the font is supported
|
|
23369
|
-
*/
|
|
23370
|
-
isFontSupported(fontValue) {
|
|
23371
|
-
const context = document.createElement("canvas").getContext("2d");
|
|
23372
|
-
if (!context) return false;
|
|
23373
|
-
const text = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
23374
|
-
const size = "72px";
|
|
23375
|
-
const baseFonts = [
|
|
23376
|
-
"monospace",
|
|
23377
|
-
"serif",
|
|
23378
|
-
"sans-serif"
|
|
23379
|
-
];
|
|
23380
|
-
const defaultWidths = {};
|
|
23381
|
-
baseFonts.forEach((base) => {
|
|
23382
|
-
context.font = `${size} ${base}`;
|
|
23383
|
-
defaultWidths[base] = context.measureText(text).width;
|
|
23384
|
-
});
|
|
23385
|
-
return baseFonts.some((base) => {
|
|
23386
|
-
context.font = `${size} "${fontValue}", ${base}`;
|
|
23387
|
-
return context.measureText(text).width !== defaultWidths[base];
|
|
23388
|
-
});
|
|
23389
|
-
}
|
|
23390
|
-
addFont(font) {
|
|
23391
|
-
if (this.getFontByValue(font.value)) throw new Error(`[FontService]: Font with value "${font.value}" already exists.`);
|
|
23392
|
-
const updatedFonts = [...this.getFonts(), font].sort();
|
|
23393
|
-
this.fonts$.next(updatedFonts);
|
|
23394
|
-
}
|
|
23395
|
-
updateFont(value, updates) {
|
|
23396
|
-
const fonts = this.getFonts();
|
|
23397
|
-
const fontIndex = fonts.findIndex((font) => font.value === value);
|
|
23398
|
-
if (fontIndex === -1) throw new Error(`Font with value "${value}" not found.`);
|
|
23399
|
-
const updatedFont = {
|
|
23400
|
-
...fonts[fontIndex],
|
|
23401
|
-
...updates
|
|
23402
|
-
};
|
|
23403
|
-
const updatedFonts = [...fonts];
|
|
23404
|
-
updatedFonts[fontIndex] = updatedFont;
|
|
23405
|
-
this.fonts$.next(updatedFonts);
|
|
23406
|
-
}
|
|
23407
|
-
removeFont(value) {
|
|
23408
|
-
const fonts = this.getFonts();
|
|
23409
|
-
if (fonts.findIndex((font) => font.value === value) === -1) return false;
|
|
23410
|
-
const updatedFonts = fonts.filter((font) => font.value !== value);
|
|
23411
|
-
this.fonts$.next(updatedFonts);
|
|
23412
|
-
return true;
|
|
23413
|
-
}
|
|
23414
|
-
resetToDefaults() {
|
|
23415
|
-
this.fonts$.next([...DEFAULT_FONT_LIST]);
|
|
23416
|
-
}
|
|
23417
|
-
};
|
|
23418
|
-
FontService = __decorate([__decorateParam(0, IConfigService)], FontService);
|
|
23419
|
-
|
|
23420
|
-
//#endregion
|
|
23421
|
-
//#region src/views/font-family/use-font-list.ts
|
|
23422
|
-
function useFontList() {
|
|
23423
|
-
const fontService = useDependency(IFontService);
|
|
23424
|
-
return {
|
|
23425
|
-
fonts: useObservable(fontService.fonts$, fontService.getFonts()),
|
|
23426
|
-
fontService
|
|
23427
|
-
};
|
|
23428
|
-
}
|
|
23429
|
-
|
|
23430
23682
|
//#endregion
|
|
23431
23683
|
//#region src/views/font-family/FontFamily.tsx
|
|
23432
23684
|
const FONT_FAMILY_COMPONENT = "UI_FONT_FAMILY_COMPONENT";
|
|
@@ -23502,33 +23754,6 @@ const FontFamily = ({ className, disabled: disabledProp, value, disabled$, onCha
|
|
|
23502
23754
|
});
|
|
23503
23755
|
};
|
|
23504
23756
|
|
|
23505
|
-
//#endregion
|
|
23506
|
-
//#region src/views/font-family/FontFamilyItem.tsx
|
|
23507
|
-
const FONT_FAMILY_ITEM_COMPONENT = "UI_FONT_FAMILY_ITEM_COMPONENT";
|
|
23508
|
-
const FontFamilyItem = ({ value, onChange }) => {
|
|
23509
|
-
const localeService = useDependency(LocaleService);
|
|
23510
|
-
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
23511
|
-
const { fonts, fontService } = useFontList();
|
|
23512
|
-
function handleSelectFont(nextValue) {
|
|
23513
|
-
onChange(nextValue);
|
|
23514
|
-
}
|
|
23515
|
-
return /* @__PURE__ */ jsx("ul", {
|
|
23516
|
-
dir: direction,
|
|
23517
|
-
className: "univer-m-0 univer-list-none univer-p-0 univer-text-sm",
|
|
23518
|
-
style: { fontFamily: value },
|
|
23519
|
-
children: fonts.map((font) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", {
|
|
23520
|
-
className: "univer-flex univer-h-7 univer-w-full univer-appearance-none univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-border-none univer-bg-transparent univer-px-2 univer-text-gray-900 hover:univer-bg-gray-100 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700",
|
|
23521
|
-
style: { fontFamily: font.value },
|
|
23522
|
-
type: "button",
|
|
23523
|
-
onClick: () => handleSelectFont(font.value),
|
|
23524
|
-
children: [localeService.t(font.label), !fontService.isFontSupported(font.value) && /* @__PURE__ */ jsx(Tooltip, {
|
|
23525
|
-
title: localeService.t("ui.fontFamily.not-supported"),
|
|
23526
|
-
children: /* @__PURE__ */ jsx(InfoIcon, { className: "univer-text-gray-300 dark:!univer-text-gray-400" })
|
|
23527
|
-
})]
|
|
23528
|
-
}) }, font.value))
|
|
23529
|
-
});
|
|
23530
|
-
};
|
|
23531
|
-
|
|
23532
23757
|
//#endregion
|
|
23533
23758
|
//#region src/views/font-size/FontSize.tsx
|
|
23534
23759
|
const FontSize = (props) => {
|
|
@@ -27842,34 +28067,48 @@ function Slider(props) {
|
|
|
27842
28067
|
/* @__PURE__ */ jsx("div", {
|
|
27843
28068
|
className: "univer-hidden univer-h-6 univer-items-center sm:!univer-flex",
|
|
27844
28069
|
children: /* @__PURE__ */ jsx("div", {
|
|
27845
|
-
className: clsx("univer-relative univer-h-1.5 univer-
|
|
28070
|
+
className: clsx("univer-relative univer-h-1.5 univer-px-1.5", { "univer-opacity-60": disabled }),
|
|
27846
28071
|
style: { width: `${SLIDER_WIDTH}px` },
|
|
27847
28072
|
children: /* @__PURE__ */ jsxs("div", {
|
|
27848
28073
|
ref: sliderInnerRailRef,
|
|
27849
28074
|
role: "track",
|
|
27850
|
-
className: "univer-relative univer-h-1.5 univer-bg-gray-200 dark:!univer-bg-gray-600",
|
|
28075
|
+
className: "univer-relative univer-h-1.5 univer-rounded-full univer-bg-gray-200 univer-transition-colors dark:!univer-bg-gray-600",
|
|
27851
28076
|
onPointerDown: handlePointerDown,
|
|
27852
28077
|
children: [
|
|
27853
28078
|
/* @__PURE__ */ jsx("div", {
|
|
27854
28079
|
className: clsx("univer-absolute univer-top-0 univer-h-full univer-rounded-full univer-bg-primary-500", isRtl ? "univer-right-0" : "univer-left-0"),
|
|
27855
28080
|
style: { width: `${sliderOffset}%` }
|
|
27856
28081
|
}),
|
|
27857
|
-
/* @__PURE__ */ jsx("
|
|
27858
|
-
className: "univer-absolute univer-left-1/2 univer-top-1/2 univer-
|
|
27859
|
-
|
|
27860
|
-
|
|
27861
|
-
|
|
27862
|
-
|
|
27863
|
-
|
|
27864
|
-
|
|
27865
|
-
|
|
27866
|
-
|
|
27867
|
-
|
|
27868
|
-
|
|
27869
|
-
|
|
27870
|
-
|
|
28082
|
+
/* @__PURE__ */ jsx("div", {
|
|
28083
|
+
className: "univer-absolute univer-left-1/2 univer-top-1/2 univer-size-6 -univer-translate-x-1/2 -univer-translate-y-1/2",
|
|
28084
|
+
children: /* @__PURE__ */ jsx(Tooltip, {
|
|
28085
|
+
title: `${localeService.t("ui.accessibility.resetZoom")} (${resetPoint}%)`,
|
|
28086
|
+
placement: "top",
|
|
28087
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
28088
|
+
className: "univer-size-6 univer-p-0 focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-primary-100",
|
|
28089
|
+
size: "small",
|
|
28090
|
+
variant: "link",
|
|
28091
|
+
type: "button",
|
|
28092
|
+
"data-u-comp": "zoom-reset",
|
|
28093
|
+
"aria-label": localeService.t("ui.accessibility.resetZoom"),
|
|
28094
|
+
disabled,
|
|
28095
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
28096
|
+
onClick: handleReset,
|
|
28097
|
+
onKeyDown: (e) => {
|
|
28098
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
28099
|
+
e.preventDefault();
|
|
28100
|
+
e.stopPropagation();
|
|
28101
|
+
handleReset();
|
|
28102
|
+
},
|
|
28103
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
28104
|
+
"aria-hidden": "true",
|
|
28105
|
+
className: "univer-box-border univer-h-3 univer-w-1 univer-rounded-full univer-border univer-border-solid univer-border-gray-0 univer-bg-gray-600 dark:!univer-border-gray-800 dark:!univer-bg-gray-100"
|
|
28106
|
+
})
|
|
28107
|
+
})
|
|
28108
|
+
})
|
|
28109
|
+
}),
|
|
27871
28110
|
/* @__PURE__ */ jsx("button", {
|
|
27872
|
-
className: clsx("univer-absolute univer-top-1/2 univer-size-3.5 -univer-translate-x-1/2 -univer-translate-y-1/2 univer-rounded-full univer-bg-gray-0 univer-shadow-sm univer-transition
|
|
28111
|
+
className: clsx("univer-absolute univer-top-1/2 univer-size-3.5 -univer-translate-x-1/2 -univer-translate-y-1/2 univer-rounded-full univer-bg-gray-0 univer-shadow-sm univer-transition focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-primary-100 dark:!univer-bg-gray-800", borderClassName, {
|
|
27873
28112
|
"univer-cursor-pointer hover:univer-border-primary-600 hover:univer-shadow-md": !disabled,
|
|
27874
28113
|
"univer-cursor-not-allowed": disabled,
|
|
27875
28114
|
"univer-scale-105 univer-border-primary-600 univer-shadow-md": isDragging
|
|
@@ -29934,4 +30173,4 @@ function ProgressBar(props) {
|
|
|
29934
30173
|
}
|
|
29935
30174
|
|
|
29936
30175
|
//#endregion
|
|
29937
|
-
export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomPreviewService, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, EMBED_CHILD_UNIT_ID_ATTRIBUTE, EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, EMOJI_CATEGORIES, EMOJI_PICKER_COMPONENT, EMOJI_RECENT_LIMIT, EmojiPicker, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FloatingObjectToolbarPosition, FontFamily, FontFamilyDropdown, FontFamilyItem, FontService, FontSize, FormatPainterSessionService, HEADING_ITEM_COMPONENT, HEADING_LIST, HOVER_TRACK_HOST_CLASS_NAME, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, HoverTrack, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonOverrideService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IUIRuntimeScopeService, IUnitPresenceUIAdapterRegistry, IWorkbenchService, IconManager, KeyCode, MOBILE_UI_MODE, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileCanvasGesture, MobileContextMenu, MobileDialogService, MobileDrawer, MobileFontFamilyDropdown, MobileKeyboardInsetContext, MobileMenu, MobileZoomIndicator, MockMessageService, NativeTextEditorShortcutBehavior, ObjectPermissionButton, ObjectPermissionPanelButton, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonOverrideService, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SYMBOL_CATEGORIES, SYMBOL_PICKER_COMPONENT, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, SymbolPicker, ThemeSwitcherService, ToggleFullscreenOperation, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UIRuntimeScopeService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoRedoGroupService, UndoShortcutItem, UnitPresenceUIAdapterRegistry, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, WorkbenchService, ZIndexManager, ZoomInput, bindFormatPainterCanvas, connectDependencies, connectInjector, getAllEmojis, getDefaultRecentEmojis, getEmbedBoundaryOwner, getEmbedChildUnitId, getEmojiLocaleData, getHeaderFooterMenuHiddenObservable, getLocalizedEmojiTitle, getMenuHiddenObservable, getMobileCanvasPanDelta, getRandomEmoji, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, isEmbedBoundaryTarget, keepInteractionInsideSameEmbedBoundary, mergeMenuConfigs, objectPermissionMenuItemFactory, openObjectPermissionDialog, openObjectPermissionPanel, parseHtmlDocument, parseHtmlFragment, parseStoredRecentEmojis, preventBrowserZoomInContainers, promoteRecentEmoji, sanitizeParsedHtml, searchEmojis, splitSpanText, supportClipboardAPI, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useMobileCanvasPanel, useMobileCanvasViewport, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };
|
|
30176
|
+
export { AnchoredContextMenu, BrowserClipboardService, BuiltInUIPart, COLOR_PICKER_COMPONENT, COMMON_LABEL_COMPONENT, CanvasFloatDomPreviewService, CanvasFloatDomService, CanvasPopup, CanvasPopupService, CommonLabel, ComponentContainer, ComponentManager, DesktopContextMenu as ContextMenu, ContextMenuGroup, ContextMenuHostService, ContextMenuPanel, ContextMenuPosition, ContextMenuService, CopyCommand, CopyShortcutItem, CustomLabel, CutCommand, CutShortcutItem, DISABLE_AUTO_FOCUS_KEY, DesktopBeforeCloseService, DesktopConfirmService, DesktopDialogService, DesktopGalleryService, DesktopLayoutService, DesktopLocalFileService, DesktopLocalStorageService, DesktopMessageService, DesktopNotificationService, DesktopRibbonService, DesktopSidebarService, DesktopUIController, EMBED_CHILD_UNIT_ID_ATTRIBUTE, EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE, EMOJI_CATEGORIES, EMOJI_PICKER_COMPONENT, EMOJI_RECENT_LIMIT, EmojiPicker, ErrorController, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE_SVG_XML_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, FloatDom, FloatDomSingle, FloatingObjectToolbarPosition, FontCategory, FontFamily, FontFamilyDropdown, FontFamilyItem, FontService, FontSize, FormatPainterSessionService, HEADING_ITEM_COMPONENT, HEADING_LIST, HOVER_TRACK_HOST_CLASS_NAME, HTML_CLIPBOARD_MIME_TYPE, HeadingItem, HoverTrack, IBeforeCloseService, ICanvasPopupService, IClipboardInterfaceService, IContextMenuHostService, IContextMenuService, IDialogService, IFontService, IGalleryService, ILayoutService, ILeftSidebarService, ILocalFileService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IRibbonOverrideService, IRibbonService, IShortcutService, ISidebarService, IUIController, IUIPartsService, IUIRuntimeScopeService, IUnitPresenceUIAdapterRegistry, IWorkbenchService, IconManager, KeyCode, MOBILE_UI_MODE, MenuItemType, MenuManagerPosition, MenuManagerService, MetaKeys, MobileCanvasGesture, MobileContextMenu, MobileDialogService, MobileDrawer, MobileFontFamilyDropdown, MobileKeyboardInsetContext, MobileMenu, MobileZoomIndicator, MockMessageService, NativeTextEditorShortcutBehavior, ObjectPermissionButton, ObjectPermissionPanelButton, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, PlatformService, PrintFloatDomSingle, ProgressBar, RectPopup, RediConsumer, RediContext, RediProvider, RedoShortcutItem, Ribbon, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonOverrideService, RibbonPosition, RibbonStartGroup, RibbonViewGroup, SYMBOL_CATEGORIES, SYMBOL_PICKER_COMPONENT, SharedController, SheetPasteShortKeyCommandName, ShortcutPanelController, ShortcutPanelService, ShortcutService, Sidebar, SingleCanvasPopup, SingleUnitUIController, Slider, SymbolPicker, ThemeSwitcherService, ToggleFullscreenOperation, ToggleShortcutPanelOperation, ToolbarButton, ToolbarItem, menuSchema as UIMenuSchema, UIPartsService, UIRuntimeScopeService, UI_PLUGIN_CONFIG_KEY, UNI_DISABLE_CHANGING_FOCUS_KEY, UndoRedoGroupService, UndoShortcutItem, UnitPresenceUIAdapterRegistry, UniverMobileUIPlugin, UniverUIPlugin, WithDependency, WorkbenchService, ZIndexManager, ZoomInput, bindFormatPainterCanvas, connectDependencies, connectInjector, getAllEmojis, getDefaultRecentEmojis, getEmbedBoundaryOwner, getEmbedChildUnitId, getEmojiLocaleData, getHeaderFooterMenuHiddenObservable, getLocalizedEmojiTitle, getMenuHiddenObservable, getMobileCanvasPanDelta, getRandomEmoji, handelExcelToJson, handelTableToJson, handleDomToJson, handlePlainToJson, handleStringToStyle, handleTableColgroup, handleTableMergeData, handleTableRowGroup, imageMimeTypeSet, isEmbedBoundaryTarget, keepInteractionInsideSameEmbedBoundary, mergeMenuConfigs, objectPermissionMenuItemFactory, openObjectPermissionDialog, openObjectPermissionPanel, parseHtmlDocument, parseHtmlFragment, parseStoredRecentEmojis, preventBrowserZoomInContainers, promoteRecentEmoji, sanitizeParsedHtml, searchEmojis, splitSpanText, supportClipboardAPI, textTrim, useClickOutSide, useComponentsOfPart, useConfigValue, useDebounceFn, useDependency, useEvent, useInjector, useMobileCanvasPanel, useMobileCanvasViewport, useObservable, useObservableRef, useScrollYOverContainer, useSidebarClick, useToolbarItemStatus, useUpdateBinder, useUpdateEffect, useVirtualList };
|