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
flush
jerry71263419b1f9
diff --git a/packages/ui-plugin-sheets/src/Controller/CountBarUIController.ts b/packages/ui-plugin-sheets/src/Controller/CountBarUIController.tsindex 1550a21e9d..ec4862223f 100644--- a/packages/ui-plugin-sheets/src/Controller/CountBarUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/CountBarUIController.ts@@ -10,8 +10,7 @@ export class CountBarUIController {let rectList = rangeList.getRangeList();let recList: string[] = [];let plugin = this._plugin;- let context = plugin.getContext();- let workbook = context.getWorkBook();+ let workbook = plugin.getContext().getUniver().getCurrentUniverSheetInstance().getWorkBook();let worksheet = workbook.getActiveSheet();let cellMatrix = worksheet.getCellMatrix();let avg = 0;@@ -46,12 +45,7 @@ export class CountBarUIController {}protected _refreshCountBarUI(): void {- const workbook = this._plugin.getContext().getUniver().getCurrentUniverSheetInstance().getWorkBook();- this._countBar.setState({- onChange: (v: any) => {- workbook.getActiveSheet().setZoomRatio(Tools.numberFixed(v / 100, 2));- },- });+}protected _refreshComponent(): void {@@ -92,7 +86,9 @@ export class CountBarUIController {}// changeRatio- changeRatio(ratio: string) { }+ onChange = (ratio: string) => {+ console.log(ratio);+ }// 刷新组件setCountBar(content: string) {diff --git a/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts b/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.tsindex 9a075d448a..a7e79b0c4a 100644--- a/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts+++ b/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts@@ -138,7 +138,8 @@ export class SheetBarUIController {props: {onClick: (color: string) => {this.setUIObserve('onUIChangeObservable', {- name: 'changeSheetColor', value: {+ name: 'changeSheetColor',+ value: {color, sheetId: this._dataId}});diff --git a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts b/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.tsindex d8329576e5..400da6901e 100644--- a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts@@ -132,6 +132,7 @@ export class SheetContainerUIController {},countBar: {getComponent: this._countBarController.getComponent,+ onChange: this._countBarController.onChange,},sheetBar: {getComponent: this._sheetBarController.getComponent,diff --git a/packages/ui-plugin-sheets/src/View/CountBar/CountBar.tsx b/packages/ui-plugin-sheets/src/View/CountBar/CountBar.tsxindex 854c673a71..ff934bc237 100644--- a/packages/ui-plugin-sheets/src/View/CountBar/CountBar.tsx+++ b/packages/ui-plugin-sheets/src/View/CountBar/CountBar.tsx@@ -2,20 +2,23 @@ import { BaseCountBarProps, Button, Component, CountBarComponent, createRef, Icoimport { PLUGIN_NAMES } from '@univerjs/core';import styles from './index.module.less';-type CountState = {+interface CountState {zoom: number;content: string;- onChange?: (value: string) => void;};-export class CountBar extends Component<BaseCountBarProps, CountState> {+interface CountBarProps extends BaseCountBarProps {+ onChange?: (value: string) => void;+}++export class CountBar extends Component<CountBarProps, CountState> {max = 400;min = 0;ref = createRef();- initialize(props: BaseCountBarProps) {+ initialize(props: CountBarProps) {this.state = {zoom: 100,content: '',@@ -42,11 +45,10 @@ export class CountBar extends Component<BaseCountBarProps, CountState> {onChange = (e: Event) => {let target = e.target as HTMLInputElement;- if (this.state.onChange) {- this.state.onChange(target.value);+ if (this.props.onChange) {+ this.props.onChange(target.value);}this.setValue({ zoom: target.value });- console.log(target.value);this.ref.current.changeInputValue(0, target.value);};@@ -59,8 +61,8 @@ export class CountBar extends Component<BaseCountBarProps, CountState> {let value = (number + 1) * 10;if (value >= this.max) value = this.max;this.setValue({ zoom: value });- if (this.state.onChange) {- this.state.onChange(String(value));+ if (this.props.onChange) {+ this.props.onChange(String(value));}};@@ -69,8 +71,8 @@ export class CountBar extends Component<BaseCountBarProps, CountState> {let value = (number - 1) * 10;if (value <= this.min) value = this.min;this.setValue({ zoom: value });- if (this.state.onChange) {- this.state.onChange(String(value));+ if (this.props.onChange) {+ this.props.onChange(String(value));}this.ref.current.changeInputValue(0, value);};