Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(base-doc): findlocale error

tonytonychopper123c35f7ecf015f
diff --git a/packages/base-ui/src/Common/SlotManager.ts b/packages/base-ui/src/Common/SlotManager.ts
index 652ef7ca5e..b457d4eed0 100644
--- a/packages/base-ui/src/Common/SlotManager.ts
+++ b/packages/base-ui/src/Common/SlotManager.ts
@@ -11,8 +11,10 @@ export type SlotGroupProps = Map<string, Map<string, SlotComponent>>;
export type SlotList = Map<string, Slot>;
export class SlotManager {
+ // slot配置
private _slotGroup: SlotGroupProps = new Map();
+ // slot实例
private _slotList: SlotList = new Map();
getComponent = (ref: Slot) => {
diff --git a/packages/base-ui/src/Utils/util.ts b/packages/base-ui/src/Utils/util.ts
index c7019a0baa..e1f95ea0ea 100644
--- a/packages/base-ui/src/Utils/util.ts
+++ b/packages/base-ui/src/Utils/util.ts
@@ -234,74 +234,6 @@ export function setLastCaretPosition(dom: HTMLElement) {
range && range.collapseToEnd();
}
-/**
- * 翻译数据中的国际化
- */
-// function resetLabel(label: string[] | string, locale: Locale) {
-// let str = '';
-
-// if (label instanceof Array) {
-// label.forEach((item) => {
-// if (item.includes('.')) {
-// str += locale.get(item);
-// } else {
-// str += item;
-// }
-// });
-// } else {
-// if (label.includes('.')) {
-// str = locale.get(label);
-// } else {
-// str += label;
-// }
-// }
-
-// return str;
-// }
-
-// export function findLocale<T>(obj: T, fn: Function) {
-// for (let k in obj) {
-// if (k.endsWith('Locale') && typeof obj[k] === 'string') {
-// const index = k.indexOf('Locale');
-// obj[k.slice(0, index)] = fn(obj[k]);
-// }
-// }
-// return obj;
-// }
-
-// function findLocale(obj: any, locale: Locale) {
-// for (let k in obj) {
-// if (k === 'locale') {
-// obj.label = resetLabel(obj[k], locale);
-// } else if (k.endsWith('Locale')) {
-// const index = k.indexOf('Locale');
-// obj[k.slice(0, index)] = resetLabel(obj[k], locale);
-// } else if (obj[k] && !obj[k].$$typeof) {
-// if (Object.prototype.toString.call(obj[k]) === '[object Object]') {
-// findLocale(obj[k], locale);
-// } else if (Object.prototype.toString.call(obj[k]) === '[object Array]') {
-// resetDataLabel(obj[k], locale);
-// }
-// }
-// }
-
-// return obj;
-// }
-
-// export function resetDataLabel(data: any[], locale: Locale) {
-// for (let i = 0; i < data.length; i++) {
-// let item = data[i];
-
-// item = findLocale(item, locale);
-
-// if (item.children) {
-// item.children = resetDataLabel(item.children, locale);
-// }
-// }
-
-// return data;
-// }
-
export function isCtrlPressed(event: KeyboardEvent) {
let isCtrl = false;
diff --git a/packages/sheets-plugin-find/src/View/UI/index.module.less b/packages/sheets-plugin-find/src/View/UI/index.module.less
index a21cfecadc..872098dfd9 100644
--- a/packages/sheets-plugin-find/src/View/UI/index.module.less
+++ b/packages/sheets-plugin-find/src/View/UI/index.module.less
@@ -45,7 +45,7 @@
}
>span {
- width: 50px;
+ width: 60px;
flex-shrink: 0
}
diff --git a/packages/ui-plugin-docs/src/Controller/AppUIController.ts b/packages/ui-plugin-docs/src/Controller/AppUIController.ts
index 23bcf8edee..15ec0e2284 100644
--- a/packages/ui-plugin-docs/src/Controller/AppUIController.ts
+++ b/packages/ui-plugin-docs/src/Controller/AppUIController.ts
@@ -18,6 +18,7 @@ export class AppUIController {
UI.create({
context: this._plugin.getGlobalContext(),
locale: this._plugin.getGlobalContext().getLocale().getCurrentLocale(),
+ componentManager: this._plugin.getComponentManager(),
changeLocale: this.changeLocale,
UIConfig,
container: this._plugin.getConfig().container,
diff --git a/packages/ui-plugin-docs/src/Controller/InfoBarUIController.ts b/packages/ui-plugin-docs/src/Controller/InfoBarUIController.ts
index 18a599f037..d9243eda11 100644
--- a/packages/ui-plugin-docs/src/Controller/InfoBarUIController.ts
+++ b/packages/ui-plugin-docs/src/Controller/InfoBarUIController.ts
@@ -3,7 +3,6 @@ import { InfoBarModel } from '../Model';
import { InfoBar } from '../View/InfoBar';
type IProps = {
- locale?: string;
label?: string;
onBlur?: (e: FocusEvent) => void;
};
@@ -36,12 +35,6 @@ export class InfoBarUIController {
};
resetInfoList(list: BaseInfoBarProps) {
- const locale = this._plugin.getContext().getLocale();
- for (let k in list) {
- if (list[k].locale) {
- list[k].label = locale.get(list[k].locale);
- }
- }
this._infoBar.setInfoList(list);
}
@@ -57,16 +50,16 @@ export class InfoBarUIController {
this._infoBarModel = new InfoBarModel(name);
this._infoList = {
back: {
- locale: 'info.return',
+ label: 'info.return',
},
rename: {
- locale: 'info.tips',
+ label: 'info.tips',
},
update: {
- locale: 'info.detailUpdate',
+ label: 'info.detailUpdate',
},
save: {
- locale: 'info.detailSave',
+ label: 'info.detailSave',
},
sheet: {
label: name,
diff --git a/packages/ui-plugin-docs/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-docs/src/Controller/ToolbarUIController.ts
index dd3199c86c..1c50ad6a5b 100644
--- a/packages/ui-plugin-docs/src/Controller/ToolbarUIController.ts
+++ b/packages/ui-plugin-docs/src/Controller/ToolbarUIController.ts
@@ -1,4 +1,4 @@
-import { BaseSelectChildrenProps, BaseSelectProps, ColorPicker, ComponentChildren } from '@univerjs/base-ui';
+import { BaseSelectChildrenProps, BaseSelectProps, ColorPicker, ComponentChildren, CustomComponent } from '@univerjs/base-ui';
import { DEFAULT_STYLES, HorizontalAlign, Tools, UIObserver, VerticalAlign, WrapStrategy, Range, FontWeight, FontItalic, ITextRotation } from '@univerjs/core';
import { DefaultToolbarConfig, DocToolbarConfig, DOC_UI_PLUGIN_NAME } from '../Basics';
import { DocUIPlugin } from '../DocUIPlugin';
@@ -8,15 +8,8 @@ import { FONT_FAMILY_CHILDREN, FONT_SIZE_CHILDREN, HORIZONTAL_ALIGN_CHILDREN, VE
import styles from '../View/Toolbar/index.module.less';
-// 继承基础下拉属性,添加国际化
-export interface BaseToolbarSelectChildrenProps extends BaseSelectChildrenProps {
- suffixLocale?: string;
- children?: BaseToolbarSelectChildrenProps[];
-}
-
export interface BaseToolbarSelectProps extends BaseSelectProps {
- suffixLocale?: string;
- children?: BaseToolbarSelectChildrenProps[];
+ children?: BaseSelectChildrenProps[];
}
enum ToolbarType {
@@ -61,7 +54,7 @@ export class ToolbarUIController {
toolbarType: 1,
tooltip: 'toolbar.undo',
name: 'undo',
- customLabel: {
+ label: {
name: 'ForwardIcon',
},
show: this._config.undo,
@@ -73,7 +66,7 @@ export class ToolbarUIController {
{
toolbarType: 1,
tooltip: 'toolbar.redo',
- customLabel: {
+ label: {
name: 'BackIcon',
},
name: 'redo',
@@ -119,7 +112,7 @@ export class ToolbarUIController {
{
toolbarType: 1,
tooltip: 'toolbar.bold',
- customLabel: {
+ label: {
name: 'BoldIcon',
},
unActive: false,
@@ -133,7 +126,7 @@ export class ToolbarUIController {
{
toolbarType: 1,
tooltip: 'toolbar.italic',
- customLabel: {
+ label: {
name: 'ItalicIcon',
},
unActive: false,
@@ -147,7 +140,7 @@ export class ToolbarUIController {
{
toolbarType: 1,
tooltip: 'toolbar.strikethrough',
- customLabel: {
+ label: {
name: 'DeleteLineIcon',
},
unActive: false,
@@ -164,7 +157,7 @@ export class ToolbarUIController {
{
toolbarType: 1,
tooltip: 'toolbar.underline',
- customLabel: {
+ label: {
name: 'UnderLineIcon',
},
unActive: false,
@@ -181,14 +174,14 @@ export class ToolbarUIController {
{
type: 5,
tooltip: 'toolbar.textColor.main',
- customLabel: {
+ label: {
name: DOC_UI_PLUGIN_NAME + ColorSelect.name,
props: {
getComponent: (ref: ColorSelect) => {
this._colorSelect1 = ref;
},
color: '#000',
- customLabel: {
+ label: {
name: 'TextColorIcon',
},
},
@@ -197,19 +190,19 @@ export class ToolbarUIController {
this.hideTooltip();
const textColor = this._toolList.find((item) => item.name === 'textColor');
if (!textColor) return;
- if (!textColor.customLabel) return;
- if (!textColor.customLabel.props) return;
- textColor.customLabel.props.color = this._textColor;
+ if (!textColor.label) return;
+ if (!(textColor.label as CustomComponent).props?.color) return;
+ (textColor.label as CustomComponent).props!.color = this._textColor;
this.changeColor(this._textColor);
},
hideSelectedIcon: true,
className: styles.selectColorPickerParent,
children: [
{
- labelLocale: 'toolbar.resetColor',
+ label: 'toolbar.resetColor',
},
{
- customLabel: {
+ label: {
name: DOC_UI_PLUGIN_NAME + ColorPicker.name,
props: {
onClick: (color: string, e: MouseEvent) => {
@@ -227,14 +220,14 @@ export class ToolbarUIController {
{
type: 5,
tooltip: 'toolbar.fillColor.main',
- customLabel: {
+ label: {
name: DOC_UI_PLUGIN_NAME + ColorSelect.name,
props: {
getComponent: (ref: ColorSelect) => {
this._colorSelect2 = ref;
},
color: '#fff',
- customLabel: {
+ label: {
name: 'FillColorIcon',
},
},
@@ -243,19 +236,19 @@ export class ToolbarUIController {
this.hideTooltip();
const fillColor = this._toolList.find((item) => item.name === 'fillColor');
if (!fillColor) return;
- if (!fillColor.customLabel) return;
- if (!fillColor.customLabel.props) return;
- fillColor.customLabel.props.color = this._background;
+ if (!fillColor.label) return;
+ if (!(fillColor.label as CustomComponent).props?.color) return;
+ (fillColor.label as CustomComponent).props!.color = this._background;
this.setBackground(this._background);
},
hideSelectedIcon: true,
className: styles.selectColorPickerParent,
children: [
{
- labelLocale: 'toolbar.resetColor',
+ label: 'toolbar.resetColor',
},
{
- customLabel: {
+ label: {
name: DOC_UI_PLUGIN_NAME + ColorPicker.name,
props: {
onClick: (color: string, e: MouseEvent) => {
diff --git a/packages/ui-plugin-docs/src/View/App.tsx b/packages/ui-plugin-docs/src/View/App.tsx
index 49d7d08465..0c6c4ff926 100644
--- a/packages/ui-plugin-docs/src/View/App.tsx
+++ b/packages/ui-plugin-docs/src/View/App.tsx
@@ -1,10 +1,11 @@
-import { AppContext, BaseComponentProps, Component } from '@univerjs/base-ui';
+import { AppContext, BaseComponentProps, Component, ComponentManager } from '@univerjs/base-ui';
import { LocaleType } from '@univerjs/core';
import { BaseDocContainerProps, DocContainer } from './DocContainer';
export interface BaseUIProps extends BaseComponentProps {
locale: LocaleType;
UIConfig: BaseDocContainerProps;
+ componentManager: ComponentManager;
changeLocale: (locale: string) => void;
}
@@ -29,7 +30,7 @@ export class App extends Component<BaseUIProps, IState> {
}
render() {
- const { context, UIConfig } = this.props;
+ const { context, UIConfig, componentManager } = this.props;
const { locale } = this.state;
return (
@@ -37,6 +38,7 @@ export class App extends Component<BaseUIProps, IState> {
value={{
context,
locale,
+ componentManager,
}}
>
<div
diff --git a/packages/ui-plugin-docs/src/View/Common/ColorSelect/ColorSelect.tsx b/packages/ui-plugin-docs/src/View/Common/ColorSelect/ColorSelect.tsx
index b4289f5d65..f84ed44a36 100644
--- a/packages/ui-plugin-docs/src/View/Common/ColorSelect/ColorSelect.tsx
+++ b/packages/ui-plugin-docs/src/View/Common/ColorSelect/ColorSelect.tsx
@@ -1,35 +1,18 @@
-import { BaseComponentProps, Component, ComponentChildren } from '@univerjs/base-ui';
-import { DocUIPlugin } from '../../..';
-import { DOC_UI_PLUGIN_NAME } from '../../../Basics';
+import { BaseComponentProps, Component, ComponentChildren, CustomComponent } from '@univerjs/base-ui';
import styles from './index.module.less';
interface IProps extends BaseComponentProps {
- customLabel?: {
- name: string;
- props: any;
- };
- label?: ComponentChildren;
+ label?: ComponentChildren | CustomComponent;
id: string;
color: string;
}
interface IState {
- label: ComponentChildren;
color: string;
}
export class ColorSelect extends Component<IProps, IState> {
componentDidMount(): void {
- const componentManager = this.getContext().getPluginManager().getPluginByName<DocUIPlugin>(DOC_UI_PLUGIN_NAME)?.getComponentManager();
- let label = this.props.label;
- if (this.props.customLabel) {
- const Label = componentManager?.get(this.props.customLabel.name);
- label = <Label {...this.props.customLabel.props}></Label>;
- }
- this.setState({
- label,
- color: this.props.color,
- });
this.props.getComponent?.(this);
}
@@ -46,9 +29,10 @@ export class ColorSelect extends Component<IProps, IState> {
}
render() {
+ const { label } = this.props;
return (
<div className={styles.colorSelect}>
- <div>{this.state.label}</div>
+ <div>{this.getLabel(label)}</div>
<div className={styles.colorSelectLine} style={{ background: this.state.color }}></div>
</div>
);
diff --git a/packages/ui-plugin-docs/src/View/InfoBar/InfoBar.tsx b/packages/ui-plugin-docs/src/View/InfoBar/InfoBar.tsx
index d2ce4d4dd4..bd84f63a9b 100644
--- a/packages/ui-plugin-docs/src/View/InfoBar/InfoBar.tsx
+++ b/packages/ui-plugin-docs/src/View/InfoBar/InfoBar.tsx
@@ -49,8 +49,8 @@ export class InfoBar extends Component<IProps, IState> {
<Input bordered={false} value={sheet.label} onBlur={renameSheet} />
</Tooltip>
</div>
- <div className={styles.infoDetailUpdate}>{update.label}</div>
- <div className={styles.infoDetailSave}>{save.label}</div>
+ <div className={styles.infoDetailUpdate}>{this.getLabel(update.label)}</div>
+ <div className={styles.infoDetailSave}>{this.getLabel(save.label)}</div>
</Container>
);
}
diff --git a/packages/ui-plugin-docs/src/View/Toolbar/Const.ts b/packages/ui-plugin-docs/src/View/Toolbar/Const.ts
index c2db56e735..db573b0f9d 100644
--- a/packages/ui-plugin-docs/src/View/Toolbar/Const.ts
+++ b/packages/ui-plugin-docs/src/View/Toolbar/Const.ts
@@ -66,83 +66,83 @@ export const FONT_SIZE_CHILDREN = [
export const FONT_FAMILY_CHILDREN = [
{
- labelLocale: 'fontFamily.TimesNewRoman',
+ label: 'fontFamily.TimesNewRoman',
style: { 'font-family': 'Times New Roman' },
value: 'Times New Roman',
selected: true,
},
{
- labelLocale: 'fontFamily.Arial',
+ label: 'fontFamily.Arial',
style: { 'font-family': 'Arial' },
value: 'Arial',
},
{
- labelLocale: 'fontFamily.Tahoma',
+ label: 'fontFamily.Tahoma',
style: { 'font-family': 'Tahoma' },
value: 'Tahoma',
},
{
- labelLocale: 'fontFamily.Verdana',
+ label: 'fontFamily.Verdana',
style: { 'font-family': 'Verdana' },
value: 'Verdana',
},
{
- labelLocale: 'fontFamily.MicrosoftAccorblack',
+ label: 'fontFamily.MicrosoftAccorblack',
style: { 'font-family': '微软雅黑' },
value: '微软雅黑',
},
{
- labelLocale: 'fontFamily.SimSun',
+ label: 'fontFamily.SimSun',
style: { 'font-family': '宋体' },
value: '宋体',
},
{
- labelLocale: 'fontFamily.SimHei',
+ label: 'fontFamily.SimHei',
style: { 'font-family': '黑体' },
value: '黑体',
},
{
- labelLocale: 'fontFamily.Kaiti',
+ label: 'fontFamily.Kaiti',
style: { 'font-family': '楷体' },
value: '楷体',
},
{
- labelLocale: 'fontFamily.FangSong',
+ label: 'fontFamily.FangSong',
style: { 'font-family': '仿宋' },
value: '仿宋',
},
{
- labelLocale: 'fontFamily.NSimSun',
+ label: 'fontFamily.NSimSun',
style: { 'font-family': '新宋体' },
value: '新宋体',
},
{
- labelLocale: 'fontFamily.STXinwei',
+ label: 'fontFamily.STXinwei',
style: { 'font-family': '华文新魏' },
value: '华文新魏',
},
{
- labelLocale: 'fontFamily.STXingkai',
+ label: 'fontFamily.STXingkai',
style: { 'font-family': '华文行楷' },
value: '华文行楷',
},
{
- labelLocale: 'fontFamily.STLiti',
+ label: 'fontFamily.STLiti',
style: { 'font-family': '华文隶书' },
value: '华文隶书',
},
{
- labelLocale: 'fontFamily.HanaleiFill',
+ label: 'fontFamily.HanaleiFill',
style: { 'font-family': 'HanaleiFill' },
value: 'HanaleiFill',
},
{
- labelLocale: 'fontFamily.Anton',
+ label: 'fontFamily.Anton',
style: { 'font-family': 'Anton' },
value: 'Anton',
},
{
- labelLocale: 'fontFamily.Pacifico',
+ label: 'fontFamily.Pacifico',
style: { 'font-family': 'Pacifico' },
value: 'Pacifico',
},
@@ -150,73 +150,73 @@ export const FONT_FAMILY_CHILDREN = [
export const BORDER_LINE_CHILDREN = [
{
- labelLocale: 'borderLine.borderTop',
- customSuffix: {
+ label: 'borderLine.borderTop',
+ suffix: {
name: 'TopBorderIcon',
},
value: 'top',
},
{
- labelLocale: 'borderLine.borderBottom',
- customSuffix: {
+ label: 'borderLine.borderBottom',
+ suffix: {
name: 'BottomBorderIcon',
},
value: 'bottom',
},
{
- labelLocale: 'borderLine.borderLeft',
- customSuffix: {
+ label: 'borderLine.borderLeft',
+ suffix: {
name: 'LeftBorderIcon',
},
value: 'left',
},
{
- labelLocale: 'borderLine.borderRight',
- customSuffix: {
+ label: 'borderLine.borderRight',
+ suffix: {
name: 'RightBorderIcon',
},
value: 'right',
border: true,
},
{
- labelLocale: 'borderLine.borderNone',
- customSuffix: {
+ label: 'borderLine.borderNone',
+ suffix: {
name: 'NoneBorderIcon',
},
value: 'none',
},
{
- labelLocale: 'borderLine.borderAll',
- customSuffix: {
+ label: 'borderLine.borderAll',
+ suffix: {
name: 'FullBorderIcon',
},
value: 'all',
selected: true,
},
{
- labelLocale: 'borderLine.borderOutside',
- customSuffix: {
+ label: 'borderLine.borderOutside',
+ suffix: {
name: 'OuterBorderIcon',
},
value: 'outside',
},
{
- labelLocale: 'borderLine.borderInside',
- customSuffix: {
+ label: 'borderLine.borderInside',
+ suffix: {
name: 'InnerBorderIcon',
},
value: 'inside',
},
{
- labelLocale: 'borderLine.borderHorizontal',
- customSuffix: {
+ label: 'borderLine.borderHorizontal',
+ suffix: {
name: 'StripingBorderIcon',
},
value: 'horizontal',
},
{
- labelLocale: 'borderLine.borderVertical',
- customSuffix: {
+ label: 'borderLine.borderVertical',
+ suffix: {
name: 'VerticalBorderIcon',
},
value: 'vertical',
@@ -225,71 +225,71 @@ export const BORDER_LINE_CHILDREN = [
export const BORDER_SIZE_CHILDREN = [
{
- labelLocale: 'borderLine.borderNone',
+ label: 'borderLine.borderNone',
value: BorderStyleTypes.NONE,
},
{
- customLabel: {
+ label: {
name: 'BorderThin',
},
value: BorderStyleTypes.THIN,
},
{
- customLabel: {
+ label: {
name: 'BorderHair',
},
value: BorderStyleTypes.HAIR,
},
{
- customLabel: {
+ label: {
name: 'BorderDotted',
},
value: BorderStyleTypes.DOTTED,
},
{
- customLabel: {
+ label: {
name: 'BorderDashed',
},
value: BorderStyleTypes.DASHED,
},
{
- customLabel: {
+ label: {
name: 'BorderDashDot',
},
value: BorderStyleTypes.DOTTED,
},
{
- customLabel: {
+ label: {
name: 'BorderDashDotDot',
},
value: BorderStyleTypes.DASH_DOT_DOT,
},
{
- customLabel: {
+ label: {
name: 'BorderMedium',
},
value: BorderStyleTypes.MEDIUM,
},
{
- customLabel: {
+ label: {
name: 'BorderMediumDashed',
},
value: BorderStyleTypes.MEDIUM_DASHED,
},
{
- customLabel: {
+ label: {
name: 'BorderMediumDashDot',
},
value: BorderStyleTypes.MEDIUM_DASH_DOT,
},
{
- customLabel: {
+ label: {
name: 'BorderMediumDashDotDot',
},
value: BorderStyleTypes.MEDIUM_DASH_DOT_DOT,
},
{
- customLabel: {
+ label: {
name: 'BorderThick',
},
value: BorderStyleTypes.THICK,
@@ -298,42 +298,42 @@ export const BORDER_SIZE_CHILDREN = [
export const MERGE_CHILDREN = [
{
- labelLocale: 'merge.all',
+ label: 'merge.all',
value: 'all',
},
{
- labelLocale: 'merge.vertical',
+ label: 'merge.vertical',
value: 'vertical',
},
{
- labelLocale: 'merge.horizontal',
+ label: 'merge.horizontal',
value: 'horizontal',
},
{
- labelLocale: 'merge.cancel',
+ label: 'merge.cancel',
value: 'cancel',
},
];
export const HORIZONTAL_ALIGN_CHILDREN = [
{
- labelLocale: 'align.left',
- customSuffix: {
+ label: 'align.left',
+ suffix: {
name: 'LeftAlignIcon',
},
value: 1,
},
{
- labelLocale: 'align.center',
+ label: 'align.center',
selected: true,
- customSuffix: {
+ suffix: {
name: 'CenterAlignIcon',
},
value: 2,
},
{
- labelLocale: 'align.right',
- customSuffix: {
+ label: 'align.right',
+ suffix: {
name: 'RightAlignIcon',
},
value: 3,
@@ -342,22 +342,22 @@ export const HORIZONTAL_ALIGN_CHILDREN = [
export const VERTICAL_ALIGN_CHILDREN = [
{
- labelLocale: 'align.top',
- customSuffix: {
+ label: 'align.top',
+ suffix: {
name: 'TopVerticalIcon',
},
value: 1,
},
{
- labelLocale: 'align.middle',
- customSuffix: {
+ label: 'align.middle',
+ suffix: {
name: 'CenterVerticalIcon',
},
value: 2,
},
{
- labelLocale: 'align.bottom',
- customSuffix: {
+ label: 'align.bottom',
+ suffix: {
name: 'BottomVerticalIcon',
},
value: 3,
@@ -366,22 +366,22 @@ export const VERTICAL_ALIGN_CHILDREN = [
export const TEXT_WRAP_CHILDREN = [
{
- labelLocale: 'textWrap.overflow',
- customSuffix: {
+ label: 'textWrap.overflow',
+ suffix: {
name: 'OverflowIcon',
},
value: 1,
},
{
- labelLocale: 'textWrap.wrap',
- customSuffix: {
+ label: 'textWrap.wrap',
+ suffix: {
name: 'BrIcon',
},
value: 3,
},
{
- labelLocale: 'textWrap.clip',
- customSuffix: {
+ label: 'textWrap.clip',
+ suffix: {
name: 'CutIcon',
},
value: 2,
@@ -390,43 +390,43 @@ export const TEXT_WRAP_CHILDREN = [
export const TEXT_ROTATE_CHILDREN = [
{
- labelLocale: 'textRotate.none',
- customSuffix: {
+ label: 'textRotate.none',
+ suffix: {
name: 'TextRotateIcon',
},
value: 0,
},
{
- labelLocale: 'textRotate.angleUp',
- customSuffix: {
+ label: 'textRotate.angleUp',
+ suffix: {
name: 'TextRotateAngleUpIcon',
},
value: -45,
},
{
- labelLocale: 'textRotate.angleDown',
- customSuffix: {
+ label: 'textRotate.angleDown',
+ suffix: {
name: 'TextRotateAngleDownIcon',
},
value: 45,
},
{
- labelLocale: 'textRotate.vertical',
- customSuffix: {
+ label: 'textRotate.vertical',
+ suffix: {
name: 'TextRotateVerticalIcon',
},
value: 'v',
},
{
- labelLocale: 'textRotate.rotationUp',
- customSuffix: {
+ label: 'textRotate.rotationUp',
+ suffix: {
name: 'TextRotateRotationUpIcon',
},
value: -90,
},
{
- labelLocale: 'textRotate.rotationDown',
- customSuffix: {
+ label: 'textRotate.rotationDown',
+ suffix: {
name: 'TextRotateRotationDownIcon',
},
value: 90,
diff --git a/packages/ui-plugin-docs/src/View/Toolbar/Toolbar.tsx b/packages/ui-plugin-docs/src/View/Toolbar/Toolbar.tsx
index 4394ca3a29..c0e40caea6 100644
--- a/packages/ui-plugin-docs/src/View/Toolbar/Toolbar.tsx
+++ b/packages/ui-plugin-docs/src/View/Toolbar/Toolbar.tsx
@@ -1,4 +1,4 @@
-import { AppContext, AppContextValues, BaseComponentProps, Button, Component, Container, createRef, debounce, findLocale, PreactContext, Select, Tooltip } from '@univerjs/base-ui';
+import { AppContext, AppContextValues, BaseComponentProps, Button, Component, Container, createRef, debounce, PreactContext, Select, Tooltip } from '@univerjs/base-ui';
import { DocUIPlugin } from '../..';
import { DOC_UI_PLUGIN_NAME } from '../../Basics';
import { IToolbarItemProps } from '../../Controller';
@@ -143,38 +143,7 @@ export class Toolbar extends Component<IProps, IState> {
}
};
- resetLabel = (toolList: IToolbarItemProps[]) => {
- const componentManager = this.getContext().getPluginManager().getPluginByName<DocUIPlugin>(DOC_UI_PLUGIN_NAME)?.getComponentManager();
-
- for (let i = 0; i < toolList.length; i++) {
- const item = findLocale<IToolbarItemProps>(toolList[i], this.getLocale.bind(this));
- // 优先寻找自定义组件
- if (item.customLabel) {
- const Label = componentManager?.get(item.customLabel.name);
- if (Label) {
- const props = item.customLabel.props ?? {};
- item.label = <Label {...props} />;
- }
- }
-
- if (item.customSuffix) {
- const Suffix = componentManager?.get(item.customSuffix.name);
- if (Suffix) {
- const props = item.customSuffix.props ?? {};
- item.suffix = <Suffix {...props} />;
- }
- }
-
- if (item.children) {
- item.children = this.resetLabel(item.children);
- }
- }
- return toolList;
- };
-
setToolbar = (toolList: any[]) => {
- // toolList = this.resetLabel(toolList);
-
this.setState(
{
toolList,
@@ -207,14 +176,13 @@ export class Toolbar extends Component<IProps, IState> {
// 渲染dom
getToolbarList(list: IToolbarItemProps[]) {
- list = this.resetLabel(list);
return list.map((item) => {
if (item.toolbarType) {
if (item.show) {
return (
- <Tooltip title={this.getLocale(item.tooltip)} placement={'bottom'}>
+ <Tooltip title={item.tooltip} placement={'bottom'}>
<Button unActive={item.unActive} className={styles.textButton} type="text" active={item.active} onClick={item.onClick}>
- {item.label}
+ {this.getLabel(item.label)}
</Button>
</Tooltip>
);
@@ -223,13 +191,12 @@ export class Toolbar extends Component<IProps, IState> {
if (item.show) {
return (
<Select
- tooltip={this.getLocale(item.tooltip)}
+ tooltip={item.tooltip}
type={item.type}
display={item.display}
children={item.children}
- customLabel={item.customLabel}
- customSuffix={item.customSuffix}
label={item.label}
+ suffix={item.suffix}
onClick={item.onClick}
onPressEnter={item.onPressEnter}
onMainClick={item.onMainClick}
diff --git a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts b/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts
index 1b36dc5c80..19cdc070c0 100644
--- a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts
+++ b/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts
@@ -58,9 +58,6 @@ export class SheetContainerUIController {
this._countBarController = new CountBarUIController(this._plugin);
this._sheetBarController = new SheetBarUIController(this._plugin);
// 插入prompt组件
- // this._slotController.addSlot(SHEET_UI_PLUGIN_NAME + Prompt.name, {
- // component: Prompt,
- // });
this._plugin.getComponentManager().register(Prompt.name, Prompt);
this._slotManager.setSlotComponent('main', {
name: Prompt.name,
diff --git a/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx b/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx
index 99f3786852..f84ed44a36 100644
--- a/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx
+++ b/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx
@@ -8,7 +8,6 @@ interface IProps extends BaseComponentProps {
}
interface IState {
- label: ComponentChildren;
color: string;
}
diff --git a/packages/ui-plugin-sheets/src/View/Toolbar/Toolbar.tsx b/packages/ui-plugin-sheets/src/View/Toolbar/Toolbar.tsx
index 97337016eb..707a7840ea 100644
--- a/packages/ui-plugin-sheets/src/View/Toolbar/Toolbar.tsx
+++ b/packages/ui-plugin-sheets/src/View/Toolbar/Toolbar.tsx
@@ -144,8 +144,6 @@ export class Toolbar extends Component<IProps, IState> {
};
setToolbar = (toolList: any[]) => {
- // toolList = this.resetLabel(toolList);
-
this.setState(
{
toolList,
diff --git a/packages/ui-plugin-slides/src/Controller/AppUIController.ts b/packages/ui-plugin-slides/src/Controller/AppUIController.ts
index f92032d77b..33204ecebc 100644
--- a/packages/ui-plugin-slides/src/Controller/AppUIController.ts
+++ b/packages/ui-plugin-slides/src/Controller/AppUIController.ts
@@ -18,6 +18,7 @@ export class AppUIController {
UI.create({
context: this._plugin.getGlobalContext(),
locale: this._plugin.getGlobalContext().getLocale().getCurrentLocale(),
+ componentManager: this._plugin.getComponentManager(),
changeLocale: this.changeLocale,
UIConfig,
container: this._plugin.getConfig().container,
diff --git a/packages/ui-plugin-slides/src/Controller/InfoBarUIController.ts b/packages/ui-plugin-slides/src/Controller/InfoBarUIController.ts
index b0fc699f3a..83ce24f3ad 100644
--- a/packages/ui-plugin-slides/src/Controller/InfoBarUIController.ts
+++ b/packages/ui-plugin-slides/src/Controller/InfoBarUIController.ts
@@ -3,7 +3,6 @@ import { SlideUIPlugin } from '../SlideUIPlugin';
import { InfoBar } from '../View/InfoBar';
type IProps = {
- locale?: string;
label?: string;
onBlur?: (e: FocusEvent) => void;
};
@@ -36,12 +35,6 @@ export class InfoBarUIController {
};
resetInfoList(list: BaseInfoBarProps) {
- const locale = this._plugin.getGlobalContext().getLocale();
- for (let k in list) {
- if (list[k].locale) {
- list[k].label = locale.get(list[k].locale);
- }
- }
this._infoBar.setInfoList(list);
}
@@ -57,16 +50,16 @@ export class InfoBarUIController {
this._infoBarModel = new InfoBarModel(name);
this._infoList = {
back: {
- locale: 'info.return',
+ label: 'info.return',
},
rename: {
- locale: 'info.tips',
+ label: 'info.tips',
},
update: {
- locale: 'info.detailUpdate',
+ label: 'info.detailUpdate',
},
save: {
- locale: 'info.detailSave',
+ label: 'info.detailSave',
},
slide: {
label: name,
diff --git a/packages/ui-plugin-slides/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-slides/src/Controller/ToolbarUIController.ts
index 32916b8758..7c9920929a 100644
--- a/packages/ui-plugin-slides/src/Controller/ToolbarUIController.ts
+++ b/packages/ui-plugin-slides/src/Controller/ToolbarUIController.ts
@@ -1,5 +1,5 @@
import { BorderInfo, SlidePlugin } from '@univerjs/base-slides';
-import { BaseSelectChildrenProps, BaseSelectProps, ColorPicker, ComponentChildren } from '@univerjs/base-ui';
+import { BaseSelectChildrenProps, BaseSelectProps, ColorPicker, ComponentChildren, CustomComponent } from '@univerjs/base-ui';
import { BorderType, CommandManager, DEFAULT_STYLES, HorizontalAlign, IKeyValue, PLUGIN_NAMES, Tools, UIObserver, VerticalAlign, WrapStrategy } from '@univerjs/core';
import { SlideUIPlugin } from '..';
import { DefaultToolbarConfig, SlideToolbarConfig, SLIDE_UI_PLUGIN_NAME } from '../Basics';
@@ -7,8 +7,6 @@ import { ColorSelect, LineBold, LineColor, Toolbar } from '../View';
import {
FONT_FAMILY_CHILDREN,
FONT_SIZE_CHILDREN,
- BORDER_LINE_CHILDREN,
- BORDER_SIZE_CHILDREN,
MERGE_CHILDREN,
HORIZONTAL_ALIGN_CHILDREN,
VERTICAL_ALIGN_CHILDREN,
@@ -18,17 +16,8 @@ import {
import styles from '../View/Toolbar/index.module.less';
-// 继承基础下拉属性,添加国际化
-export interface BaseToolbarSelectChildrenProps extends BaseSelectChildrenProps {
- suffixLocale?: string;
- children?: BaseToolbarSelectChildrenProps[];
- labelLocale?: string;
-}
-
export interface BaseToolbarSelectProps extends BaseSelectProps {
- suffixLocale?: string;
- children?: BaseToolbarSelectChildrenProps[];
- labelLocale?: string;
+ children?: BaseSelectChildrenProps[];
}
enum ToolbarType {
@@ -88,7 +77,7 @@ export class ToolbarUIController {
tooltip: 'toolbar.undo',
name: 'undo',
unActive: true,
- customLabel: {
+ label: {
name: 'ForwardIcon',
},
show: this._config.undo,
@@ -101,7 +90,7 @@ export class ToolbarUIController {
toolbarType: 1,
tooltip: 'toolbar.redo',
unActive: true,
- customLabel: {
+ label: {
name: 'BackIcon',
},
name: 'redo',
@@ -147,7 +136,7 @@ export class ToolbarUIController {
{
toolbarType: 1,
tooltip: 'toolbar.bold',
- customLabel: {
+ label: {
name: 'BoldIcon',
},
active: false,
@@ -161,7 +150,7 @@ export class ToolbarUIController {
{
toolbarType: 1,
tooltip: 'toolbar.italic',
- customLabel: {
+ label: {
name: 'ItalicIcon',
},
name: 'italic',
@@ -174,7 +163,7 @@ export class ToolbarUIController {
{
toolbarType: 1,
tooltip: 'toolbar.strikethrough',
- customLabel: {
+ label: {
name: 'DeleteLineIcon',
},
name: 'strikethrough',
@@ -190,7 +179,7 @@ export class ToolbarUIController {
{
toolbarType: 1,
tooltip: 'toolbar.underline',
- customLabel: {
+ label: {
name: 'UnderLineIcon',
},
name: 'underline',
@@ -206,14 +195,14 @@ export class ToolbarUIController {
{
type: 5,
tooltip: 'toolbar.textColor.main',
- customLabel: {
+ label: {
name: SLIDE_UI_PLUGIN_NAME + ColorSelect.name,
props: {
getComponent: (ref: ColorSelect) => {
this._colorSelect1 = ref;
},
color: '#000',
- customLabel: {
+ label: {
name: 'TextColorIcon',
},
},
@@ -221,20 +210,19 @@ export class ToolbarUIController {
onClick: () => {
this.hideTooltip();
const textColor = this._toolList.find((item) => item.name === 'textColor');
- if (!textColor) return;
- if (!textColor.customLabel) return;
- if (!textColor.customLabel.props) return;
- textColor.customLabel.props.color = this._textColor;
+ if (!textColor || !textColor.label) return;
+ if (!(textColor.label as CustomComponent).props?.color) return;
+ (textColor.label as CustomComponent).props!.color = this._textColor;
this.changeColor(this._textColor);
},
hideSelectedIcon: true,
className: styles.selectColorPickerParent,
children: [
{
- labelLocale: 'toolbar.resetColor',
+ label: 'toolbar.resetColor',
},
{
- customLabel: {
+ label: {
name: SLIDE_UI_PLUGIN_NAME + ColorPicker.name,
props: {
onClick: (color: string, e: MouseEvent) => {
@@ -252,14 +240,14 @@ export class ToolbarUIController {
{
type: 5,
tooltip: 'toolbar.fillColor.main',
- customLabel: {
+ label: {
name: SLIDE_UI_PLUGIN_NAME + ColorSelect.name,
props: {
getComponent: (ref: ColorSelect) => {
this._colorSelect2 = ref;
},
color: '#fff',
- customLabel: {
+ label: {
name: 'FillColorIcon',
},
},
@@ -267,20 +255,19 @@ export class ToolbarUIController {
onClick: () => {
this.hideTooltip();
const fillColor = this._toolList.find((item) => item.name === 'fillColor');
- if (!fillColor) return;
- if (!fillColor.customLabel) return;
- if (!fillColor.customLabel.props) return;
- fillColor.customLabel.props.color = this._background;
+ if (!fillColor || !fillColor.label) return;
+ if (!(fillColor.label as CustomComponent).props?.color) return;
+ (fillColor.label as CustomComponent).props!.color = this._background;
this.setBackground(this._background);
},
hideSelectedIcon: true,
className: styles.selectColorPickerParent,
children: [
{
- labelLocale: 'toolbar.resetColor',
+ label: 'toolbar.resetColor',
},
{
- customLabel: {
+ label: {
name: SLIDE_UI_PLUGIN_NAME + ColorPicker.name,
props: {
onClick: (color: string, e: MouseEvent) => {
@@ -295,82 +282,81 @@ export class ToolbarUIController {
name: 'fillColor',
show: this._config.fillColor,
},
- {
- type: 3,
- display: 1,
- show: this._config.border,
- tooltip: 'toolbar.border.main',
- className: styles.selectDoubleString,
- onClick: (value: string) => {
- if (value) {
- this._borderInfo.type = value as BorderType;
- }
- this.hideTooltip();
- this.setBorder();
- },
- name: 'border',
- children: [
- ...BORDER_LINE_CHILDREN,
- {
- name: 'borderColor',
- customLabel: {
- name: SLIDE_UI_PLUGIN_NAME + LineColor.name,
- props: {
- color: '#000',
- label: 'borderLine.borderColor',
- getComponent: (ref: LineColor) => (this._lineColor = ref),
- },
- },
- unSelectable: true,
- className: styles.selectColorPickerParent,
- children: [
- {
- customLabel: {
- name: SLIDE_UI_PLUGIN_NAME + ColorPicker.name,
- props: {
- onClick: (color: string, e: MouseEvent) => {
- this._lineColor.setColor(color);
- this._borderInfo.color = color;
- const borderItem = this._toolList.find((item) => item.name === 'border');
- const lineColor = borderItem?.children?.find((item) => item.name === 'borderColor');
- if (!lineColor) return;
- if (!lineColor.customLabel) return;
- if (!lineColor.customLabel.props) return;
- lineColor.customLabel.props.color = color;
- },
- },
- },
- className: styles.selectColorPicker,
- onClick: (...arg) => {
- arg[0].stopPropagation();
- },
- },
- ],
- },
- {
- customLabel: {
- name: SLIDE_UI_PLUGIN_NAME + LineBold.name,
- props: {
- img: 0,
- label: 'borderLine.borderSize',
- getComponent: (ref: LineBold) => (this._lineBold = ref),
- },
- },
- onClick: (...arg) => {
- arg[0].stopPropagation();
- this._lineBold.setImg(BORDER_SIZE_CHILDREN[arg[2]].customLabel?.name);
- this._borderInfo.style = arg[1];
- },
- className: styles.selectLineBoldParent,
- unSelectable: true,
- children: BORDER_SIZE_CHILDREN,
- },
- ],
- },
+ // {
+ // type: 3,
+ // display: 1,
+ // show: this._config.border,
+ // tooltip: 'toolbar.border.main',
+ // className: styles.selectDoubleString,
+ // onClick: (value: string) => {
+ // if (value) {
+ // this._borderInfo.type = value as BorderType;
+ // }
+ // this.hideTooltip();
+ // this.setBorder();
+ // },
+ // name: 'border',
+ // children: [
+ // ...BORDER_LINE_CHILDREN,
+ // {
+ // name: 'borderColor',
+ // label: {
+ // name: SLIDE_UI_PLUGIN_NAME + LineColor.name,
+ // props: {
+ // color: '#000',
+ // label: 'borderLine.borderColor',
+ // getComponent: (ref: LineColor) => (this._lineColor = ref),
+ // },
+ // },
+ // unSelectable: true,
+ // className: styles.selectColorPickerParent,
+ // children: [
+ // {
+ // label: {
+ // name: SLIDE_UI_PLUGIN_NAME + ColorPicker.name,
+ // props: {
+ // onClick: (color: string, e: MouseEvent) => {
+ // this._lineColor.setColor(color);
+ // this._borderInfo.color = color;
+ // const borderItem = this._toolList.find((item) => item.name === 'border');
+ // const lineColor = borderItem?.children?.find((item) => item.name === 'borderColor');
+ // if (!lineColor || !lineColor.label) return;
+ // if (!(lineColor.label as CustomComponent).props?.color) return;
+ // (lineColor.label as CustomComponent).props!.color = color;
+ // },
+ // },
+ // },
+ // className: styles.selectColorPicker,
+ // onClick: (...arg) => {
+ // arg[0].stopPropagation();
+ // },
+ // },
+ // ],
+ // },
+ // {
+ // label: {
+ // name: SLIDE_UI_PLUGIN_NAME + LineBold.name,
+ // props: {
+ // img: 0,
+ // label: 'borderLine.borderSize',
+ // getComponent: (ref: LineBold) => (this._lineBold = ref),
+ // },
+ // },
+ // onClick: (...arg) => {
+ // arg[0].stopPropagation();
+ // this._lineBold.setImg(BORDER_SIZE_CHILDREN[arg[2]].label?.name);
+ // this._borderInfo.style = arg[1];
+ // },
+ // className: styles.selectLineBoldParent,
+ // unSelectable: true,
+ // children: BORDER_SIZE_CHILDREN,
+ // },
+ // ],
+ // },
{
type: 5,
tooltip: 'toolbar.mergeCell.main',
- customLabel: {
+ label: {
name: 'MergeIcon',
},
show: this._config.mergeCell,
diff --git a/packages/ui-plugin-slides/src/View/App.tsx b/packages/ui-plugin-slides/src/View/App.tsx
index 6f666e7270..a02f040ab8 100644
--- a/packages/ui-plugin-slides/src/View/App.tsx
+++ b/packages/ui-plugin-slides/src/View/App.tsx
@@ -1,10 +1,11 @@
-import { AppContext, BaseComponentProps, Component } from '@univerjs/base-ui';
+import { AppContext, BaseComponentProps, Component, ComponentManager } from '@univerjs/base-ui';
import { LocaleType } from '@univerjs/core';
import { BaseSlideContainerProps, SlideContainer } from './SlideContainer';
export interface BaseUIProps extends BaseComponentProps {
locale: LocaleType;
UIConfig: BaseSlideContainerProps;
+ componentManager: ComponentManager;
changeLocale: (locale: string) => void;
}
@@ -29,7 +30,7 @@ export class App extends Component<BaseUIProps, IState> {
}
render() {
- const { context, UIConfig } = this.props;
+ const { context, UIConfig, componentManager } = this.props;
const { locale } = this.state;
return (
@@ -37,6 +38,7 @@ export class App extends Component<BaseUIProps, IState> {
value={{
context,
locale,
+ componentManager,
}}
>
<div
diff --git a/packages/ui-plugin-slides/src/View/Common/ColorSelect/ColorSelect.tsx b/packages/ui-plugin-slides/src/View/Common/ColorSelect/ColorSelect.tsx
index 48a5f973ee..f84ed44a36 100644
--- a/packages/ui-plugin-slides/src/View/Common/ColorSelect/ColorSelect.tsx
+++ b/packages/ui-plugin-slides/src/View/Common/ColorSelect/ColorSelect.tsx
@@ -1,35 +1,18 @@
-import { BaseComponentProps, Component, ComponentChildren } from '@univerjs/base-ui';
-import { SlideUIPlugin } from '../../..';
-import { SLIDE_UI_PLUGIN_NAME } from '../../../Basics';
+import { BaseComponentProps, Component, ComponentChildren, CustomComponent } from '@univerjs/base-ui';
import styles from './index.module.less';
interface IProps extends BaseComponentProps {
- customLabel?: {
- name: string;
- props: any;
- };
- label?: ComponentChildren;
+ label?: ComponentChildren | CustomComponent;
id: string;
color: string;
}
interface IState {
- label: ComponentChildren;
color: string;
}
export class ColorSelect extends Component<IProps, IState> {
componentDidMount(): void {
- const componentManager = this.getContext().getPluginManager().getPluginByName<SlideUIPlugin>(SLIDE_UI_PLUGIN_NAME)?.getComponentManager();
- let label = this.props.label;
- if (this.props.customLabel) {
- const Label = componentManager?.get(this.props.customLabel.name);
- label = <Label {...this.props.customLabel.props}></Label>;
- }
- this.setState({
- label,
- color: this.props.color,
- });
this.props.getComponent?.(this);
}
@@ -46,9 +29,10 @@ export class ColorSelect extends Component<IProps, IState> {
}
render() {
+ const { label } = this.props;
return (
<div className={styles.colorSelect}>
- <div>{this.state.label}</div>
+ <div>{this.getLabel(label)}</div>
<div className={styles.colorSelectLine} style={{ background: this.state.color }}></div>
</div>
);
diff --git a/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsx b/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsx
index 7509e1239c..43d8889957 100644
--- a/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsx
+++ b/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsx
@@ -49,8 +49,8 @@ export class InfoBar extends Component<IProps, IState> {
<Input bordered={false} value={slide.label} onBlur={renameSheet} />
</Tooltip>
</div>
- <div className={styles.infoDetailUpdate}>{update.label}</div>
- <div className={styles.infoDetailSave}>{save.label}</div>
+ <div className={styles.infoDetailUpdate}>{this.getLabel(update.label)}</div>
+ <div className={styles.infoDetailSave}>{this.getLabel(save.label)}</div>
</Container>
);
}
diff --git a/packages/ui-plugin-slides/src/View/Toolbar/Const.ts b/packages/ui-plugin-slides/src/View/Toolbar/Const.ts
index c2db56e735..db573b0f9d 100644
--- a/packages/ui-plugin-slides/src/View/Toolbar/Const.ts
+++ b/packages/ui-plugin-slides/src/View/Toolbar/Const.ts
@@ -66,83 +66,83 @@ export const FONT_SIZE_CHILDREN = [
export const FONT_FAMILY_CHILDREN = [
{
- labelLocale: 'fontFamily.TimesNewRoman',
+ label: 'fontFamily.TimesNewRoman',
style: { 'font-family': 'Times New Roman' },
value: 'Times New Roman',
selected: true,
},
{
- labelLocale: 'fontFamily.Arial',
+ label: 'fontFamily.Arial',
style: { 'font-family': 'Arial' },
value: 'Arial',
},
{
- labelLocale: 'fontFamily.Tahoma',
+ label: 'fontFamily.Tahoma',
style: { 'font-family': 'Tahoma' },
value: 'Tahoma',
},
{
- labelLocale: 'fontFamily.Verdana',
+ label: 'fontFamily.Verdana',
style: { 'font-family': 'Verdana' },
value: 'Verdana',
},
{
- labelLocale: 'fontFamily.MicrosoftAccorblack',
+ label: 'fontFamily.MicrosoftAccorblack',
style: { 'font-family': '微软雅黑' },
value: '微软雅黑',
},
{
- labelLocale: 'fontFamily.SimSun',
+ label: 'fontFamily.SimSun',
style: { 'font-family': '宋体' },
value: '宋体',
},
{
- labelLocale: 'fontFamily.SimHei',
+ label: 'fontFamily.SimHei',
style: { 'font-family': '黑体' },
value: '黑体',
},
{
- labelLocale: 'fontFamily.Kaiti',
+ label: 'fontFamily.Kaiti',
style: { 'font-family': '楷体' },
value: '楷体',
},
{
- labelLocale: 'fontFamily.FangSong',
+ label: 'fontFamily.FangSong',
style: { 'font-family': '仿宋' },
value: '仿宋',
},
{
- labelLocale: 'fontFamily.NSimSun',
+ label: 'fontFamily.NSimSun',
style: { 'font-family': '新宋体' },
value: '新宋体',
},
{
- labelLocale: 'fontFamily.STXinwei',
+ label: 'fontFamily.STXinwei',
style: { 'font-family': '华文新魏' },
value: '华文新魏',
},
{
- labelLocale: 'fontFamily.STXingkai',
+ label: 'fontFamily.STXingkai',
style: { 'font-family': '华文行楷' },
value: '华文行楷',
},
{
- labelLocale: 'fontFamily.STLiti',
+ label: 'fontFamily.STLiti',
style: { 'font-family': '华文隶书' },
value: '华文隶书',
},
{
- labelLocale: 'fontFamily.HanaleiFill',
+ label: 'fontFamily.HanaleiFill',
style: { 'font-family': 'HanaleiFill' },
value: 'HanaleiFill',
},
{
- labelLocale: 'fontFamily.Anton',
+ label: 'fontFamily.Anton',
style: { 'font-family': 'Anton' },
value: 'Anton',
},
{
- labelLocale: 'fontFamily.Pacifico',
+ label: 'fontFamily.Pacifico',
style: { 'font-family': 'Pacifico' },
value: 'Pacifico',
},
@@ -150,73 +150,73 @@ export const FONT_FAMILY_CHILDREN = [
export const BORDER_LINE_CHILDREN = [
{
- labelLocale: 'borderLine.borderTop',
- customSuffix: {
+ label: 'borderLine.borderTop',
+ suffix: {
name: 'TopBorderIcon',
},
value: 'top',
},
{
- labelLocale: 'borderLine.borderBottom',
- customSuffix: {
+ label: 'borderLine.borderBottom',
+ suffix: {
name: 'BottomBorderIcon',
},
value: 'bottom',
},
{
- labelLocale: 'borderLine.borderLeft',
- customSuffix: {
+ label: 'borderLine.borderLeft',
+ suffix: {
name: 'LeftBorderIcon',
},
value: 'left',
},
{
- labelLocale: 'borderLine.borderRight',
- customSuffix: {
+ label: 'borderLine.borderRight',
+ suffix: {
name: 'RightBorderIcon',
},
value: 'right',
border: true,
},
{
- labelLocale: 'borderLine.borderNone',
- customSuffix: {
+ label: 'borderLine.borderNone',
+ suffix: {
name: 'NoneBorderIcon',
},
value: 'none',
},
{
- labelLocale: 'borderLine.borderAll',
- customSuffix: {
+ label: 'borderLine.borderAll',
+ suffix: {
name: 'FullBorderIcon',
},
value: 'all',
selected: true,
},
{
- labelLocale: 'borderLine.borderOutside',
- customSuffix: {
+ label: 'borderLine.borderOutside',
+ suffix: {
name: 'OuterBorderIcon',
},
value: 'outside',
},
{
- labelLocale: 'borderLine.borderInside',
- customSuffix: {
+ label: 'borderLine.borderInside',
+ suffix: {
name: 'InnerBorderIcon',
},
value: 'inside',
},
{
- labelLocale: 'borderLine.borderHorizontal',
- customSuffix: {
+ label: 'borderLine.borderHorizontal',
+ suffix: {
name: 'StripingBorderIcon',
},
value: 'horizontal',
},
{
- labelLocale: 'borderLine.borderVertical',
- customSuffix: {
+ label: 'borderLine.borderVertical',
+ suffix: {
name: 'VerticalBorderIcon',
},
value: 'vertical',
@@ -225,71 +225,71 @@ export const BORDER_LINE_CHILDREN = [
export const BORDER_SIZE_CHILDREN = [
{
- labelLocale: 'borderLine.borderNone',
+ label: 'borderLine.borderNone',
value: BorderStyleTypes.NONE,
},
{
- customLabel: {
+ label: {
name: 'BorderThin',
},
value: BorderStyleTypes.THIN,
},
{
- customLabel: {
+ label: {
name: 'BorderHair',
},
value: BorderStyleTypes.HAIR,
},
{
- customLabel: {
+ label: {
name: 'BorderDotted',
},
value: BorderStyleTypes.DOTTED,
},
{
- customLabel: {
+ label: {
name: 'BorderDashed',
},
value: BorderStyleTypes.DASHED,
},
{
- customLabel: {
+ label: {
name: 'BorderDashDot',
},
value: BorderStyleTypes.DOTTED,
},
{
- customLabel: {
+ label: {
name: 'BorderDashDotDot',
},
value: BorderStyleTypes.DASH_DOT_DOT,
},
{
- customLabel: {
+ label: {
name: 'BorderMedium',
},
value: BorderStyleTypes.MEDIUM,
},
{
- customLabel: {
+ label: {
name: 'BorderMediumDashed',
},
value: BorderStyleTypes.MEDIUM_DASHED,
},
{
- customLabel: {
+ label: {
name: 'BorderMediumDashDot',
},
value: BorderStyleTypes.MEDIUM_DASH_DOT,
},
{
- customLabel: {
+ label: {
name: 'BorderMediumDashDotDot',
},
value: BorderStyleTypes.MEDIUM_DASH_DOT_DOT,
},
{
- customLabel: {
+ label: {
name: 'BorderThick',
},
value: BorderStyleTypes.THICK,
@@ -298,42 +298,42 @@ export const BORDER_SIZE_CHILDREN = [
export const MERGE_CHILDREN = [
{
- labelLocale: 'merge.all',
+ label: 'merge.all',
value: 'all',
},
{
- labelLocale: 'merge.vertical',
+ label: 'merge.vertical',
value: 'vertical',
},
{
- labelLocale: 'merge.horizontal',
+ label: 'merge.horizontal',
value: 'horizontal',
},
{
- labelLocale: 'merge.cancel',
+ label: 'merge.cancel',
value: 'cancel',
},
];
export const HORIZONTAL_ALIGN_CHILDREN = [
{
- labelLocale: 'align.left',
- customSuffix: {
+ label: 'align.left',
+ suffix: {
name: 'LeftAlignIcon',
},
value: 1,
},
{
- labelLocale: 'align.center',
+ label: 'align.center',
selected: true,
- customSuffix: {
+ suffix: {
name: 'CenterAlignIcon',
},
value: 2,
},
{
- labelLocale: 'align.right',
- customSuffix: {
+ label: 'align.right',
+ suffix: {
name: 'RightAlignIcon',
},
value: 3,
@@ -342,22 +342,22 @@ export const HORIZONTAL_ALIGN_CHILDREN = [
export const VERTICAL_ALIGN_CHILDREN = [
{
- labelLocale: 'align.top',
- customSuffix: {
+ label: 'align.top',
+ suffix: {
name: 'TopVerticalIcon',
},
value: 1,
},
{
- labelLocale: 'align.middle',
- customSuffix: {
+ label: 'align.middle',
+ suffix: {
name: 'CenterVerticalIcon',
},
value: 2,
},
{
- labelLocale: 'align.bottom',
- customSuffix: {
+ label: 'align.bottom',
+ suffix: {
name: 'BottomVerticalIcon',
},
value: 3,
@@ -366,22 +366,22 @@ export const VERTICAL_ALIGN_CHILDREN = [
export const TEXT_WRAP_CHILDREN = [
{
- labelLocale: 'textWrap.overflow',
- customSuffix: {
+ label: 'textWrap.overflow',
+ suffix: {
name: 'OverflowIcon',
},
value: 1,
},
{
- labelLocale: 'textWrap.wrap',
- customSuffix: {
+ label: 'textWrap.wrap',
+ suffix: {
name: 'BrIcon',
},
value: 3,
},
{
- labelLocale: 'textWrap.clip',
- customSuffix: {
+ label: 'textWrap.clip',
+ suffix: {
name: 'CutIcon',
},
value: 2,
@@ -390,43 +390,43 @@ export const TEXT_WRAP_CHILDREN = [
export const TEXT_ROTATE_CHILDREN = [
{
- labelLocale: 'textRotate.none',
- customSuffix: {
+ label: 'textRotate.none',
+ suffix: {
name: 'TextRotateIcon',
},
value: 0,
},
{
- labelLocale: 'textRotate.angleUp',
- customSuffix: {
+ label: 'textRotate.angleUp',
+ suffix: {
name: 'TextRotateAngleUpIcon',
},
value: -45,
},
{
- labelLocale: 'textRotate.angleDown',
- customSuffix: {
+ label: 'textRotate.angleDown',
+ suffix: {
name: 'TextRotateAngleDownIcon',
},
value: 45,
},
{
- labelLocale: 'textRotate.vertical',
- customSuffix: {
+ label: 'textRotate.vertical',
+ suffix: {
name: 'TextRotateVerticalIcon',
},
value: 'v',
},
{
- labelLocale: 'textRotate.rotationUp',
- customSuffix: {
+ label: 'textRotate.rotationUp',
+ suffix: {
name: 'TextRotateRotationUpIcon',
},
value: -90,
},
{
- labelLocale: 'textRotate.rotationDown',
- customSuffix: {
+ label: 'textRotate.rotationDown',
+ suffix: {
name: 'TextRotateRotationDownIcon',
},
value: 90,
diff --git a/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.tsx b/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.tsx
index cb8cdcaa83..530e4147c1 100644
--- a/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.tsx
+++ b/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.tsx
@@ -1,4 +1,4 @@
-import { AppContext, AppContextValues, BaseComponentProps, Button, Component, Container, createRef, debounce, findLocale, PreactContext, Select, Tooltip } from '@univerjs/base-ui';
+import { AppContext, AppContextValues, BaseComponentProps, Button, Component, Container, createRef, debounce, PreactContext, Select, Tooltip } from '@univerjs/base-ui';
import { SlideUIPlugin } from '../..';
import { SLIDE_UI_PLUGIN_NAME } from '../../Basics';
import { IToolbarItemProps } from '../../Controller';
@@ -143,35 +143,6 @@ export class Toolbar extends Component<IProps, IState> {
}
};
- resetLabel = (toolList: IToolbarItemProps[]) => {
- const componentManager = this.getContext().getPluginManager().getPluginByName<SlideUIPlugin>(SLIDE_UI_PLUGIN_NAME)?.getComponentManager();
-
- for (let i = 0; i < toolList.length; i++) {
- const item = findLocale<IToolbarItemProps>(toolList[i], this.getLocale.bind(this));
- // 优先寻找自定义组件
- if (item.customLabel) {
- const Label = componentManager?.get(item.customLabel.name);
- if (Label) {
- const props = item.customLabel.props ?? {};
- item.label = <Label {...props} />;
- }
- }
-
- if (item.customSuffix) {
- const Suffix = componentManager?.get(item.customSuffix.name);
- if (Suffix) {
- const props = item.customSuffix.props ?? {};
- item.suffix = <Suffix {...props} />;
- }
- }
-
- if (item.children) {
- item.children = this.resetLabel(item.children);
- }
- }
- return toolList;
- };
-
setToolbar = (toolList: any[]) => {
// toolList = this.resetLabel(toolList);
@@ -211,14 +182,13 @@ export class Toolbar extends Component<IProps, IState> {
// 渲染dom
getToolbarList(list: IToolbarItemProps[]) {
- list = this.resetLabel(list);
return list.map((item) => {
if (item.toolbarType) {
if (item.show) {
return (
- <Tooltip title={this.getLocale(item.tooltip)} placement={'bottom'}>
+ <Tooltip title={item.tooltip} placement={'bottom'}>
<Button unActive={item.unActive} className={styles.textButton} type="text" active={item.active} onClick={item.onClick}>
- {item.label}
+ {this.getLabel(item.label)}
</Button>
</Tooltip>
);
@@ -227,12 +197,11 @@ export class Toolbar extends Component<IProps, IState> {
if (item.show) {
return (
<Select
- tooltip={this.getLocale(item.tooltip)}
+ tooltip={item.tooltip}
type={item.type}
display={item.display}
children={item.children}
- customLabel={item.customLabel}
- customSuffix={item.customSuffix}
+ suffix={item.suffix}
label={item.label}
onClick={item.onClick}
onPressEnter={item.onPressEnter}