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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
toolbar回显
tonytonychopper123b841f065ce26
diff --git a/packages/core/src/Sheets/Domain/Range.ts b/packages/core/src/Sheets/Domain/Range.tsindex 38efa79f8e..a96bd2947d 100644--- a/packages/core/src/Sheets/Domain/Range.ts+++ b/packages/core/src/Sheets/Domain/Range.ts@@ -35,6 +35,7 @@ import {} from '../../Enum';import {+ IBorderData,IBorderStyleData,ICellData,ICellDataMatrix,@@ -474,6 +475,18 @@ export class Range {return this._getStyles('fs');}+ /**+ * Returns the border info of the cells in the range.+ */++ getBorder(): IBorderData {+ return this.getBorders()[0][0];+ }++ getBorders(): IBorderData[][] {+ return this._getStyles('bd');+ }+/*** Returns the font style ('italic' or 'normal') of the cell in the top-left corner of the range.*/@@ -747,14 +760,16 @@ export class Range {/*** Returns the text rotation settings for the top left cell of the range.*/- getTextRotation(): number {+ // getTextRotation(): number {+ getTextRotation() {return this.getTextRotations()[0][0];}/*** Returns the text rotation settings for the cells in the range.*/- getTextRotations(): number[][] {+ // getTextRotations(): number[][] {+ getTextRotations() {return this._getStyles('tr');}@@ -2020,9 +2035,9 @@ export class Range {const zx = Math.abs(currentStartColumn +- currentEndColumn -- incomingStartColumn -- incomingEndColumn+ currentEndColumn -+ incomingStartColumn -+ incomingEndColumn);const x =Math.abs(currentStartColumn - currentEndColumn) +diff --git a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.tsindex 81346be1c5..576524fe75 100644--- a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts@@ -1,6 +1,6 @@import { BorderInfo, SelectionControl, SheetPlugin } from '@univerjs/base-sheets';import { BaseSelectChildrenProps, BaseSelectProps, ColorPicker, ComponentChildren } from '@univerjs/base-ui';-import { BorderType, DEFAULT_STYLES, FontItalic, FontStyleType, FontWeight, HorizontalAlign, IKeyValue, PLUGIN_NAMES, Range, Tools, UIObserver, VerticalAlign, WrapStrategy } from '@univerjs/core';+import { BorderType, DEFAULT_STYLES, FontItalic, FontStyleType, FontWeight, HorizontalAlign, IBorderData, IKeyValue, PLUGIN_NAMES, Range, Tools, UIObserver, VerticalAlign, WrapStrategy } from '@univerjs/core';import { SheetUIPlugin } from '..';import { DefaultToolbarConfig, SheetToolbarConfig, SHEET_UI_PLUGIN_NAME } from '../Basics';import { ColorSelect, LineBold, LineColor, Toolbar } from '../View';@@ -246,6 +246,7 @@ export class ToolbarUIController {customLabel: {name: SHEET_UI_PLUGIN_NAME + LineColor.name,props: {+ color: '#000',label: 'borderLine.borderColor',getComponent: (ref: LineColor) => this._lineColor = ref},@@ -274,6 +275,7 @@ export class ToolbarUIController {customLabel: {name: SHEET_UI_PLUGIN_NAME + LineBold.name,props: {+ img: 0,label: 'borderLine.borderSize',getComponent: (ref: LineBold) => this._lineBold = ref},@@ -381,12 +383,13 @@ export class ToolbarUIController {const fontWeight = range.getFontWeight();const fontName = range.getFontFamily();const fontItalic = range.getFontStyle();- const fontColor = range.getFontColor();- const background = range.getBackground();+ // const fontColor = range.getFontColor();+ // const background = range.getBackground();const underline = range.getUnderline();- const horizontalAlign = range.getHorizontalAlignment();- const verticalAlign = range.getVerticalAlignment();+ const horizontalAlign = range.getHorizontalAlignment() ?? HorizontalAlign.LEFT;+ const verticalAlign = range.getVerticalAlignment() ?? VerticalAlign.BOTTOM;const rotation = range.getTextRotation();+ const warp = range.getWrapStrategy() ?? WrapStrategy.CLIP;const bold = this._toolList.find((item) => item.name === 'bold')const italic = this._toolList.find((item) => item.name === 'italic')@@ -395,12 +398,14 @@ export class ToolbarUIController {const fontNameItem = this._toolList.find((item) => item.name === 'font');const fontBoldItem = this._toolList.find((item) => item.name === 'bold');const fontItalicItem = this._toolList.find((item) => item.name === 'italic');- const textColor = this._toolList.find((item) => item.name === 'textColor')- const fillColor = this._toolList.find((item) => item.name === 'fillColor')+ // const textColor = this._toolList.find((item) => item.name === 'textColor')+ // const fillColor = this._toolList.find((item) => item.name === 'fillColor')const strikethroughItem = this._toolList.find((item) => item.name === 'strikethrough');const underlineItem = this._toolList.find((item) => item.name === 'underline');const horizontalAlignModeItem = this._toolList.find((item) => item.name === 'horizontalAlignMode');const verticalAlignModeItem = this._toolList.find((item) => item.name === 'verticalAlignMode');+ const textWrapMode = this._toolList.find((item) => item.name === 'textWrapMode');+ // const border = this._toolList.find((item) => item.name === 'border')if (bold) {bold.active = isBold === FontWeight.BOLD@@ -427,18 +432,18 @@ export class ToolbarUIController {if (fontItalicItem) {fontItalicItem.active = !!fontItalic;}- if (textColor) {- const label = textColor.customLabel- if (label && label.props) {- label.props.color = fontColor- }- }- if (fillColor) {- const label = fillColor.customLabel- if (label && label.props) {- label.props.color = background- }- }+ // if (textColor) {+ // const label = textColor.customLabel+ // if (label && label.props) {+ // label.props.color = fontColor+ // }+ // }+ // if (fillColor) {+ // const label = fillColor.customLabel+ // if (label && label.props) {+ // label.props.color = background+ // }+ // }if (underlineItem) {underlineItem.active = !!(underline && underline.s);}@@ -449,7 +454,11 @@ export class ToolbarUIController {}if (textRotateModeItem) {textRotateModeItem.children?.forEach((item) => {- item.selected = rotation === item.value;+ if (rotation.v) {+ item.selected = item.value === 'v'+ } else {+ item.selected = rotation.a === item.value;+ }});}if (verticalAlignModeItem) {@@ -457,6 +466,12 @@ export class ToolbarUIController {item.selected = verticalAlign === item.value;});}+ if (textWrapMode) {+ textWrapMode.children?.forEach((item) => {+ item.selected = warp === item.value;+ });+ }+this.setToolbar();}}diff --git a/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsx b/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsxindex 9ea6de56cc..dc089d245a 100644--- a/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsx+++ b/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsx@@ -8,6 +8,7 @@ interface IState {interface IProps extends BaseComponentProps {label: string;+ img: string;}export class LineBold extends Component<IProps, IState> {@@ -21,6 +22,12 @@ export class LineBold extends Component<IProps, IState> {this.props.getComponent?.(this);}+ componentWillReceiveProps(props: IProps) {+ this.setState({+ img: props.img,+ });+ }+setImg(img: string = '') {this.setState({img,@@ -43,7 +50,7 @@ export class LineBold extends Component<IProps, IState> {<div style={{ paddingBottom: '3px', width: '100%', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}><span className={'base-sheets-line-bold'} style={{ position: 'relative' }}>{this.getLocale(label)}- <div style={{ width: '100%', height: 0, position: 'absolute', left: 0, bottom: '10px' }}>{img.length ? this.getImg(img) : ''}</div>+ <div style={{ width: '100%', height: 0, position: 'absolute', left: 0, bottom: '14px' }}>{img.length ? this.getImg(img) : ''}</div></span><Icon.RightIcon /></div>diff --git a/packages/ui-plugin-sheets/src/View/Common/Line/LineColor.tsx b/packages/ui-plugin-sheets/src/View/Common/Line/LineColor.tsxindex 6250e875ec..4ec8233898 100644--- a/packages/ui-plugin-sheets/src/View/Common/Line/LineColor.tsx+++ b/packages/ui-plugin-sheets/src/View/Common/Line/LineColor.tsx@@ -12,7 +12,7 @@ interface IProps extends BaseComponentProps {export class LineColor extends Component<IProps, IState> {initialize() {this.state = {- color: 'rgb(217,217,217)',+ color: this.props.color,};}@@ -20,6 +20,12 @@ export class LineColor extends Component<IProps, IState> {this.props.getComponent?.(this);}+ componentWillReceiveProps(props: IProps): void {+ this.setState({+ color: props.color,+ });+ }+setColor(color: string) {this.setState({color,