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