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
style(plugin): eslint error
Dushusira8c606a675fb
diff --git a/.husky/commit-msg b/.husky/commit-msgindex ee059c3ca3..c160a77123 100755--- a/.husky/commit-msg+++ b/.husky/commit-msg@@ -1,4 +1,4 @@#!/usr/bin/env sh. "$(dirname -- "$0")/_/husky.sh"-#npx --no -- commitlint --edit ${1}+npx --no -- commitlint --edit ${1}diff --git a/package.json b/package.jsonindex f5c9b48f47..d759cdda9e 100644--- a/package.json+++ b/package.json@@ -18,7 +18,6 @@"lighthouse-dev": "start /B node scripts/dev && lighthouse http://127.0.0.1:3103 --output html --output-path ./report.html","build": "node scripts/build.js","build:sheet": "pnpm run --filter univer-sheet-ts build:demo",- "build:sheet-esbuild": "pnpm run --filter univer-sheet-ts build:esbuild","build:doc": "pnpm run --filter univer-doc-ts build:demo","build:slide": "pnpm run --filter univer-slide-ts build:demo","link": "node scripts/link.js",diff --git a/packages/base-sheets/src/View/index.ts b/packages/base-sheets/src/View/index.tsindex e54650900a..8291d8e361 100644--- a/packages/base-sheets/src/View/index.ts+++ b/packages/base-sheets/src/View/index.ts@@ -1,2 +1,3 @@export * from './BaseView';export * from './CanvasView';+export * from './Views';diff --git a/packages/sheets-plugin-formula/src/Basics/Observer.ts b/packages/sheets-plugin-formula/src/Basics/Observer.tsindex 6718c4e61e..dff94816c7 100644--- a/packages/sheets-plugin-formula/src/Basics/Observer.ts+++ b/packages/sheets-plugin-formula/src/Basics/Observer.ts@@ -1,7 +1,7 @@import { Observable } from '@univerjs/core';import { FormulaPlugin } from '../FormulaPlugin';import { HelpFunction, SearchFunction } from '../View/UI/FormulaPrompt';-import { SearchFormulaModal } from '../View/UI/SearchFormulaModal/SearchFormulaModal1';+import { SearchFormulaModal } from '../View/UI/SearchFormulaModal/SearchFormulaModal';import { SearchItem } from '../View/UI/SearchFormulaModal/SearchItem';export type FormulaPluginObserve = {diff --git a/packages/sheets-plugin-formula/src/Controller/ArrayFormulaLineController.ts b/packages/sheets-plugin-formula/src/Controller/ArrayFormulaLineController.tsindex d60e78e312..b1734a6694 100644--- a/packages/sheets-plugin-formula/src/Controller/ArrayFormulaLineController.ts+++ b/packages/sheets-plugin-formula/src/Controller/ArrayFormulaLineController.ts@@ -39,6 +39,38 @@ export class ArrayFormulaLineControl {this._initialize();}+ /**+ * Return SheetView+ * @returns+ */+ getSheetView(): SheetView {+ return this._sheetPlugin.getCanvasView().getSheetView();+ }++ /**+ * Return WorkBook+ * @returns Workbook+ */+ getWorkBook(): Workbook {+ return this._sheetPlugin.getWorkbook();+ }++ /**+ * Return SheetView Scene+ * @returns+ */+ getSheetViewScene(): Scene {+ return this._sheetPlugin.getCanvasView().getSheetView().getScene();+ }++ dispose() {+ this._leftControl?.dispose();+ this._rightControl?.dispose();+ this._topControl?.dispose();+ this._bottomControl?.dispose();+ this._arrayFormulaLine?.dispose();+ }+private _initialize() {const { startRow, startColumn, endRow, endColumn } = this._range;const sheetId = this._sheetId;@@ -87,36 +119,4 @@ export class ArrayFormulaLineControl {this.getSheetViewScene().addObject(this._arrayFormulaLine);// this._arrayFormulaLine.makeDirty(true);}-- /**- * Return SheetView- * @returns- */- getSheetView(): SheetView {- return this._sheetPlugin.getCanvasView().getSheetView();- }-- /**- * Return WorkBook- * @returns Workbook- */- getWorkBook(): Workbook {- return this._sheetPlugin.getWorkbook();- }-- /**- * Return SheetView Scene- * @returns- */- getSheetViewScene(): Scene {- return this._sheetPlugin.getCanvasView().getSheetView().getScene();- }-- dispose() {- this._leftControl?.dispose();- this._rightControl?.dispose();- this._topControl?.dispose();- this._bottomControl?.dispose();- this._arrayFormulaLine?.dispose();- }}diff --git a/packages/sheets-plugin-formula/src/Controller/FormulaPromptController.ts b/packages/sheets-plugin-formula/src/Controller/FormulaPromptController.tsindex 935d4d6dec..cf0d044d93 100644--- a/packages/sheets-plugin-formula/src/Controller/FormulaPromptController.ts+++ b/packages/sheets-plugin-formula/src/Controller/FormulaPromptController.ts@@ -8,6 +8,12 @@ import { HelpFunction, SearchFunction } from '../View/UI/FormulaPrompt';import { CellInputHandler } from './CellInputHandler';export class FormulaPromptController {+ cellInputHandler: CellInputHandler;++ richTextEle: HTMLElement;++ richTextEditEle: HTMLElement;+private _context: SheetContext;private _sheetPlugin: SheetPlugin;@@ -18,12 +24,6 @@ export class FormulaPromptController {private _helpFunction: HelpFunction;- cellInputHandler: CellInputHandler;-- richTextEle: HTMLElement;-- richTextEditEle: HTMLElement;-constructor(private _plugin: FormulaPlugin) {this._context = this._plugin.getContext();diff --git a/packages/sheets-plugin-formula/src/View/UI/IfGenerate/ifGenerate.tsx b/packages/sheets-plugin-formula/src/View/UI/IfGenerate/ifGenerate.tsxindex 92675a4271..bb0ab5dd3d 100644--- a/packages/sheets-plugin-formula/src/View/UI/IfGenerate/ifGenerate.tsx+++ b/packages/sheets-plugin-formula/src/View/UI/IfGenerate/ifGenerate.tsx@@ -1,6 +1,6 @@import { BaseButtonProps, BaseComponentSheet, BaseModalProps, BaseSelectProps, Component, FunctionComponent } from '@univerjs/base-ui';import { Nullable, Observer, Workbook } from '@univerjs/core';-import { IConfig } from '../../Basics/Interfaces/IFormula';+import { IConfig } from '../../../Basics/Interfaces/IFormula';import styles from './index.module.less';interface IProps {@@ -17,14 +17,14 @@ interface IState {}class IfGenerate extends Component<IProps, IState> {- private _localeObserver: Nullable<Observer<Workbook>>;-Button: FunctionComponent<BaseButtonProps>;Modal: FunctionComponent<BaseModalProps>;Select: FunctionComponent<BaseSelectProps>;+ private _localeObserver: Nullable<Observer<Workbook>>;+constructor(props: IProps) {super(props);const component = this.props.config.context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;@@ -49,7 +49,7 @@ class IfGenerate extends Component<IProps, IState> {*/componentWillMount() {this.setLocale();- this._localeObserver = this._context+ this._localeObserver = this.getContext().getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.add(() => {@@ -65,7 +65,7 @@ class IfGenerate extends Component<IProps, IState> {}setLocale() {- const locale = this._context.getLocale().get('formula');+ const locale = this.getContext().getLocale().get('formula');this.setState({ locale });}diff --git a/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaModal1.tsx b/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaModal1.tsxdeleted file mode 100644index 07d8275e34..0000000000--- a/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaModal1.tsx+++ /dev/null@@ -1,277 +0,0 @@-import { BaseButtonProps, BaseComponentSheet, BaseModalProps, BaseSelectProps, Component, createRef, FunctionComponent } from '@univerjs/base-ui';-import { Nullable, Observer, Workbook } from '@univerjs/core';-import * as func from '../../Basics/Const/FunctionList'; // 全部公式数组-import { IConfig } from '../../Basics/Interfaces/IFormula';-import styles from './index.module.less';--interface IProps {- visible: boolean;- onOk: () => void;- onCancel: (e: Event) => void;- config: IConfig;-}-interface IState {- functionList: func.FunctionList[] | null;- functionType: func.FunctionType;- activeIndex: number;- inputIndex: number;- option: any;- selectType: string;- selectFun: func.FunctionList | null;- formulaMore: any;- locale: any;-}--class SearchFormulaModal1 extends Component<IProps, IState> {- Button: FunctionComponent<BaseButtonProps>;-- Modal: FunctionComponent<BaseModalProps>;-- Select: FunctionComponent<BaseSelectProps>;-- inputRef = createRef();-- funRef = createRef();-- private _localeObserver: Nullable<Observer<Workbook>>;-- initialize(props: IProps) {- // super();- const component = this.props.config.context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- const render = component.getComponentRender();- this.Button = render.renderFunction('Button');- this.Modal = render.renderFunction('Modal');- this.Select = render.renderFunction('Select');- this.state = {- functionList: null, // 所有公式- functionType: func.functionType,- activeIndex: 0, // 已选公式的下标- inputIndex: 0, // 已选 input 的下标- option: [], // 公式类型- selectType: '',- selectFun: null, // 选中的公式- formulaMore: {},- locale: null,- };- }-- /**- * init- */- componentWillMount() {- this.setLocale();- this._localeObserver = this._context- .getObserverManager()- .getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')- ?.add(() => {- this.setLocale();- });- }-- /**- * destory- */- componentWillUnmount() {- // this._context.getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);- }-- setLocale() {- const locale = this._context.getLocale();- const functionList = locale.get('functionlist') as unknown as func.FunctionList[];- const functionType = locale.get('functiontype') as any;- const formulaMore = locale.get('formulaMore');- let option = [];- for (const key in functionType) {- let op = {- key,- value: functionType[key],- label: functionType[key],- };- option.push(op);- }-- this.setState({- option,- functionList,- formulaMore,- locale,- });- }-- /**- * search function- */- onInput() {- const searchTxt = this.inputRef.current.value.toUpperCase();- let list = this._context.getLocale().get('functionlist') as unknown as func.FunctionList[];-- // eslint-disable-next-line array-callback-return- list = list.filter((item: { n: string; a: string }) => {- if (item.n.includes(searchTxt) || item.a.includes(searchTxt)) {- return item;- }- });- this.setState({- functionList: list,- activeIndex: 0,- });- }-- selectType(val: { key: number }) {- let list = this._context.getLocale().get('functionlist') as unknown as func.FunctionList[];- // eslint-disable-next-line array-callback-return- list = list.filter((item: { t: number }) => {- if (item.t === val.key) {- return item;- }- });- this.setState({- functionList: list,- activeIndex: 0,- });- }-- /**- * select function- * @param index- */- functionClick(index: number) {- this.setState({- activeIndex: index,- });- }-- /**- * select function- * @param index- */- setDescriptionDetail(index: number) {- this.setState({- inputIndex: index,- });- }-- /**- * 确定- */- okClick() {- if (this.state.selectFun) {- console.log(111);- } else {- this.setState((prevState) => {- const fun = (prevState.functionList as func.FunctionList[])[prevState.activeIndex];- return {- selectFun: fun,- inputIndex: 0,- };- });- }- }-- /**- * 取消- */- cancelClick(e: Event) {- if (this.state.selectFun) {- this.setState({- selectFun: null,- inputIndex: 0,- activeIndex: 0,- });- } else {- this.props.onCancel(e);- this.setState({- activeIndex: 0, // 已选公式的下标- inputIndex: 0, // 已选 input 的下标- selectFun: null,- });- }- }-- onCancel(evt: Event) {- this.props.onCancel(evt);- this.setState({- activeIndex: 0, // 已选公式的下标- inputIndex: 0, // 已选 input 的下标- selectFun: null,- });- }-- handleClick(...args: any[]) {- // console.dir(args);- }-- render() {- const { Modal, Select, Button } = this;- const { functionList, activeIndex, inputIndex, option, selectFun, formulaMore } = this.state;- let funParams;- let funName;- if (selectFun) {- funName = selectFun.a as string;- funParams = selectFun.p as func.P[];- }- return (- <Modal ref={this.funRef} isDrag={true} title={this.state.selectFun?.n} visible={this.props.visible} onCancel={this.onCancel.bind(this)}>- {selectFun ? null : (- <div className={styles.functionModal}>- <div className={styles.functionSearch}>- <div className={styles.functionLabel}>{formulaMore.findFunctionTitle}</div>- <div>- <input ref={this.inputRef} onInput={this.onInput.bind(this)} type="text" placeholder={formulaMore.tipInputFunctionName} />- </div>- </div>- <div className={styles.functionSelect}>- <div className={styles.functionLabel}>{formulaMore.selectCategory}</div>- <div className={styles.functionSelector}>- {/* <Select options={option} onChange={(val) => this.selectType(val)} placeholder={formulaMore.whole}></Select> */}- <Select label={option[0].label} needChange={true} children={option} onClick={this.handleClick.bind(this)}></Select>- </div>- </div>- <div className={styles.functionList}>- <div className={styles.functionLabel}>{formulaMore.selectFunctionTitle}</div>- <ul className={styles.functionLists}>- {(functionList as func.FunctionList[]).map((item, index) => (- <li onClick={this.functionClick.bind(this, index)} className={`${styles.functionListsItem} ${activeIndex === index ? styles.active : ''}`}>- <div className={styles.functionListsItemName}>{item.n}</div>- <div className={styles.functionListsItemDetail}>{item.d}</div>- </li>- ))}- </ul>- </div>- </div>- )}- {selectFun ? (- <div className={styles.functionParamModal}>- <div className={styles.functionParamList}>- {(funParams as func.P[]).map((item: { name: string }, index: number) => (- <div onClick={this.setDescriptionDetail.bind(this, index)}>- <span>{item.name}:</span>- <input type="text" />- <span>={'{}'}</span>- </div>- ))}- </div>- <div className={styles.functionParamDesc}>- <div className={styles.functionParamDescDetail}>{funName}</div>- <div className={styles.functionParamDescDetails}>- <div>{(funParams as func.P[])[inputIndex].name}</div>- <div>{(funParams as func.P[])[inputIndex].detail}</div>- </div>- </div>- <div className={styles.functionParamResult}>- {formulaMore.calculationResult}={}- </div>- </div>- ) : null}- <div className={styles.functionBtn}>- <Button type="primary" onClick={this.okClick.bind(this)}>- {this.state.locale.ok}- </Button>- <Button onClick={this.cancelClick.bind(this)}> {this.state.locale.cancel}</Button>- </div>- </Modal>- );- }-}--export { SearchFormulaModal };diff --git a/packages/sheets-plugin-formula/src/index.ts b/packages/sheets-plugin-formula/src/index.tsindex b5a1327ed2..3b3bc94e8a 100644--- a/packages/sheets-plugin-formula/src/index.ts+++ b/packages/sheets-plugin-formula/src/index.ts@@ -2,4 +2,4 @@import './Model/RegisterAction';export * from './FormulaPlugin';-export * from './Basics'+export * from './Basics';diff --git a/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.ts b/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.tsindex 59ff1043c3..5499c43207 100644--- a/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.ts+++ b/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.ts@@ -46,8 +46,8 @@ export class ImportXlsxController {}handleFiles(files: File[] | FileList | null) {- if (files == null || files.length == 0) {- alert('No files wait for import');+ if (files == null || files.length === 0) {+ console.error('No files wait for import');return;}@@ -55,14 +55,14 @@ export class ImportXlsxController {let suffixArr = name.split('.');let suffix = suffixArr[suffixArr.length - 1];if (suffix !== 'xlsx') {- alert('Currently only supports the import of xlsx files');+ console.error('Currently only supports the import of xlsx files');return;}const transformExcelToLucky = LuckyExcel.default.transformExcelToLucky;transformExcelToLucky(files[0], (exportJson: IKeyValue) => {- if (exportJson.sheets == null || exportJson.sheets.length == 0) {- alert('Failed to read the content of the excel file, currently does not support xls files!');+ if (exportJson.sheets == null || exportJson.sheets.length === 0) {+ console.error('Failed to read the content of the excel file, currently does not support xls files!');return;}@@ -76,7 +76,7 @@ export class ImportXlsxController {const sheets = univerWorkbookConfig.sheets;if (!sheets) {- return alert('No content');+ return console.error('No content');}const workbook = this._plugin.getContext().getWorkBook();diff --git a/packages/sheets-plugin-import-xlsx/src/Types/preact.d.ts b/packages/sheets-plugin-import-xlsx/src/Types/preact.d.tsindex 0d092b3751..0b110d4c6e 100644--- a/packages/sheets-plugin-import-xlsx/src/Types/preact.d.ts+++ b/packages/sheets-plugin-import-xlsx/src/Types/preact.d.ts@@ -2,3 +2,4 @@import JSX = preact.JSX;declare module 'enzyme';+declare module 'luckyexcel';diff --git a/packages/sheets-plugin-operation/src/Basics/Register/DeleteExtension.ts b/packages/sheets-plugin-operation/src/Basics/Register/DeleteExtension.tsindex 8a2e521beb..d1b788df1b 100644--- a/packages/sheets-plugin-operation/src/Basics/Register/DeleteExtension.ts+++ b/packages/sheets-plugin-operation/src/Basics/Register/DeleteExtension.ts@@ -18,7 +18,7 @@ export class DeleteExtension extends BaseDeleteExtension<OperationPlugin> {let colInfo;let rowInfo;if (content) {- // TODO move to DeleteOfficeExtension+ // TODO move to DeleteOfficeExtensionif (content.indexOf('xmlns:x="urn:schemas-microsoft-com:office:excel"') > -1) {data = handelExcelToJson(content);colInfo = handleTableColgroup(content);@@ -38,7 +38,7 @@ export class DeleteExtension extends BaseDeleteExtension<OperationPlugin> {rowInfo,});- return actionDataList+ return actionDataList;}}diff --git a/packages/sheets-plugin-operation/src/Basics/Register/InsertExtension.ts b/packages/sheets-plugin-operation/src/Basics/Register/InsertExtension.tsindex c0b377c864..12988480af 100644--- a/packages/sheets-plugin-operation/src/Basics/Register/InsertExtension.ts+++ b/packages/sheets-plugin-operation/src/Basics/Register/InsertExtension.ts@@ -18,7 +18,7 @@ export class InsertExtension extends BaseInsertExtension<OperationPlugin> {let colInfo;let rowInfo;if (content) {- // TODO move to InsertOfficeExtension+ // TODO move to InsertOfficeExtensionif (content.indexOf('xmlns:x="urn:schemas-microsoft-com:office:excel"') > -1) {data = handelExcelToJson(content);colInfo = handleTableColgroup(content);@@ -38,7 +38,7 @@ export class InsertExtension extends BaseInsertExtension<OperationPlugin> {rowInfo,});- return actionDataList+ return actionDataList;}}diff --git a/packages/sheets-plugin-operation/src/Domain/Cut.ts b/packages/sheets-plugin-operation/src/Domain/Cut.tsindex a9ca6f7dbd..fcc722853c 100644--- a/packages/sheets-plugin-operation/src/Domain/Cut.ts+++ b/packages/sheets-plugin-operation/src/Domain/Cut.ts@@ -1,8 +1,8 @@-import { handleJsonToDom, handleStyleToString } from '@univerjs/base-ui';-import { SheetContext, PLUGIN_NAMES, Tools } from '@univerjs/core';-import { SheetPlugin, SelectionModel, RightMenuProps, SelectionControl } from '@univerjs/base-sheets';+import { SheetContext, PLUGIN_NAMES, Tools, handleJsonToDom, handleStyleToString } from '@univerjs/core';+import { SheetPlugin, SelectionModel, SelectionControl } from '@univerjs/base-sheets';import { Clipboard } from './Clipboard';import { OPERATION_PLUGIN } from '../Const';+import { RightMenuProps } from '@univerjs/ui-plugin-sheets';export abstract class Cut {private _context: SheetContext;@@ -46,169 +46,6 @@ export class UniverCopy extends Cut {super(context, cotList);}- private _getSheetInfo() {- const sheet = this.getContext().getWorkBook().getActiveSheet();- const SheetPlugin = this.getContext().getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET);- const spreadsheet = SheetPlugin?.getMainComponent();- const controls = SheetPlugin?.getSelectionManager().getCurrentControls();- const selections: any = controls?.map((control: SelectionControl) => {- const model: SelectionModel = control.model;- return {- startRow: model.startRow,- startColumn: model.startColumn,- endRow: model.endRow,- endColumn: model.endColumn,- };- });- return { sheet, spreadsheet, selections };- }-- private _getRangeInfo() {- const { sheet, selections } = this._getSheetInfo();- if (!selections.length) return;- const range = sheet.getRange(selections[0]);- const rangeData = range.getValues();- if (!rangeData.length) return;- return { range, rangeData };- }-- private _getCopyContent() {- const { sheet, spreadsheet, selections } = this._getSheetInfo();- if (selections.length > 1) return;-- const rowManager: any = sheet.getRowManager().getRowData();- const colManager: any = sheet.getColumnManager().getColumnData();- let rowIndexArr: number[] = [];- let colIndexArr: number[] = [];-- for (let s = 0; s < selections.length; s++) {- let range = selections[s];-- let r1 = range.startRow;- let r2 = range.endRow;- let c1 = range.startColumn;- let c2 = range.endColumn;-- for (let copyR = r1; copyR <= r2; copyR++) {- const rowItem = rowManager.get(copyR);- if (rowItem && rowItem.hd) {- continue;- }-- if (!rowIndexArr.includes(copyR)) {- rowIndexArr.push(copyR);- }-- for (let copyC = c1; copyC <= c2; copyC++) {- const colItem = colManager.get(copyC);- if (colItem && colItem.hd) {- continue;- }-- if (!colIndexArr.includes(copyC)) {- colIndexArr.push(copyC);- }- }- }- }-- let cpData = '';- let colGroup = '';-- for (let i = 0; i < rowIndexArr.length; i++) {- let r = rowIndexArr[i];- cpData += '<tr>';-- for (let j = 0; j < colIndexArr.length; j++) {- let c = colIndexArr[j];-- let cellValue = sheet.getRange(r, c).getValue();- let column = '';- let style = '';- let span = '';-- if (r === rowIndexArr[0]) {- const colItem = colManager.get(c);- if (colItem && colItem.w) {- `<colgroup width="${colItem.w}px"></colgroup>`;- } else {- colGroup += '<colgroup width="72px"></colgroup>';- }- }-- const rowItem = rowManager.get(r);- if (rowItem && rowItem.h) {- style += `height:${rowItem.h}px;`;- } else {- style += 'height:19px;';- }-- const colItem = colManager.get(c);- if (colItem && colItem.w) {- style += `width:${colItem.w}px;`;- } else {- style += `width:72px;`;- }-- if (cellValue && cellValue.s) {- const cellStyle = this.getContext().getWorkBook().getStyles().get(cellValue.s);- if (cellStyle) {- style += handleStyleToString(cellStyle);- }- }-- const cellInfo = spreadsheet?.getCellByIndex(r, c);- if (cellInfo?.isMerged || (!cellInfo?.isMerged && cellInfo?.isMergedMainCell)) {- if (cellInfo.isMergedMainCell) {- span = `rowSpan="${cellInfo.mergeInfo.endRow - cellInfo.mergeInfo.startRow + 1}" colSpan="${- cellInfo.mergeInfo.endColumn - cellInfo.mergeInfo.startColumn + 1- }"`;- } else {- continue;- }- }-- if (style.includes('data-rotate')) {- let rotate = style.split(';').find((item) => item.includes('data-rotate'));- const match = rotate?.match(/\d+/g);- let angle = 0;- let ver = 0;- if (match?.length) {- angle = +match[0];- ver = +match[1] ?? 0;- }- column += `<td ${span} ${ver ? `data-vertical=${ver}` : ''} style="display:inline-block;transform: rotate(${angle}deg);${style}">`;- } else {- column = `<td ${span} style="${style}">`;- }-- let c_value;-- if (cellValue) {- if (cellValue.p) {- c_value = handleJsonToDom(cellValue.p);- } else {- c_value = sheet.getRange(r, c).getDisplayValue();- if (c_value == null) {- c_value = '';- }- }- } else {- c_value = '';- }-- column += c_value;-- column += '</td>';- cpData += column;- }-- cpData += '</tr>';- }- let cpTable = `<table data-type="universheet_copy_action_table">${colGroup}${cpData}</table>`;- return cpTable;- }-async copy(e: ClipboardEvent) {const table = this._getCopyContent();if (table) {@@ -401,4 +238,167 @@ export class UniverCopy extends Cut {const isWrite = await Clipboard.writeText(JSON.stringify(ret));}++ private _getSheetInfo() {+ const sheet = this.getContext().getWorkBook().getActiveSheet();+ const SheetPlugin = this.getContext().getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET);+ const spreadsheet = SheetPlugin?.getMainComponent();+ const controls = SheetPlugin?.getSelectionManager().getCurrentControls();+ const selections: any = controls?.map((control: SelectionControl) => {+ const model: SelectionModel = control.model;+ return {+ startRow: model.startRow,+ startColumn: model.startColumn,+ endRow: model.endRow,+ endColumn: model.endColumn,+ };+ });+ return { sheet, spreadsheet, selections };+ }++ private _getRangeInfo() {+ const { sheet, selections } = this._getSheetInfo();+ if (!selections.length) return;+ const range = sheet.getRange(selections[0]);+ const rangeData = range.getValues();+ if (!rangeData.length) return;+ return { range, rangeData };+ }++ private _getCopyContent() {+ const { sheet, spreadsheet, selections } = this._getSheetInfo();+ if (selections.length > 1) return;++ const rowManager: any = sheet.getRowManager().getRowData();+ const colManager: any = sheet.getColumnManager().getColumnData();+ let rowIndexArr: number[] = [];+ let colIndexArr: number[] = [];++ for (let s = 0; s < selections.length; s++) {+ let range = selections[s];++ let r1 = range.startRow;+ let r2 = range.endRow;+ let c1 = range.startColumn;+ let c2 = range.endColumn;++ for (let copyR = r1; copyR <= r2; copyR++) {+ const rowItem = rowManager.get(copyR);+ if (rowItem && rowItem.hd) {+ continue;+ }++ if (!rowIndexArr.includes(copyR)) {+ rowIndexArr.push(copyR);+ }++ for (let copyC = c1; copyC <= c2; copyC++) {+ const colItem = colManager.get(copyC);+ if (colItem && colItem.hd) {+ continue;+ }++ if (!colIndexArr.includes(copyC)) {+ colIndexArr.push(copyC);+ }+ }+ }+ }++ let cpData = '';+ let colGroup = '';++ for (let i = 0; i < rowIndexArr.length; i++) {+ let r = rowIndexArr[i];+ cpData += '<tr>';++ for (let j = 0; j < colIndexArr.length; j++) {+ let c = colIndexArr[j];++ let cellValue = sheet.getRange(r, c).getValue();+ let column = '';+ let style = '';+ let span = '';++ if (r === rowIndexArr[0]) {+ const colItem = colManager.get(c);+ if (colItem && colItem.w) {+ `<colgroup width="${colItem.w}px"></colgroup>`;+ } else {+ colGroup += '<colgroup width="72px"></colgroup>';+ }+ }++ const rowItem = rowManager.get(r);+ if (rowItem && rowItem.h) {+ style += `height:${rowItem.h}px;`;+ } else {+ style += 'height:19px;';+ }++ const colItem = colManager.get(c);+ if (colItem && colItem.w) {+ style += `width:${colItem.w}px;`;+ } else {+ style += `width:72px;`;+ }++ if (cellValue && cellValue.s) {+ const cellStyle = this.getContext().getWorkBook().getStyles().get(cellValue.s);+ if (cellStyle) {+ style += handleStyleToString(cellStyle);+ }+ }++ const cellInfo = spreadsheet?.getCellByIndex(r, c);+ if (cellInfo?.isMerged || (!cellInfo?.isMerged && cellInfo?.isMergedMainCell)) {+ if (cellInfo.isMergedMainCell) {+ span = `rowSpan="${cellInfo.mergeInfo.endRow - cellInfo.mergeInfo.startRow + 1}" colSpan="${+ cellInfo.mergeInfo.endColumn - cellInfo.mergeInfo.startColumn + 1+ }"`;+ } else {+ continue;+ }+ }++ if (style.includes('data-rotate')) {+ let rotate = style.split(';').find((item) => item.includes('data-rotate'));+ const match = rotate?.match(/\d+/g);+ let angle = 0;+ let ver = 0;+ if (match?.length) {+ angle = +match[0];+ ver = +match[1] ?? 0;+ }+ column += `<td ${span} ${ver ? `data-vertical=${ver}` : ''} style="display:inline-block;transform: rotate(${angle}deg);${style}">`;+ } else {+ column = `<td ${span} style="${style}">`;+ }++ let c_value;++ if (cellValue) {+ if (cellValue.p) {+ c_value = handleJsonToDom(cellValue.p);+ } else {+ c_value = sheet.getRange(r, c).getDisplayValue();+ if (c_value == null) {+ c_value = '';+ }+ }+ } else {+ c_value = '';+ }++ column += c_value;++ column += '</td>';+ cpData += column;+ }++ cpData += '</tr>';+ }+ let cpTable = `<table data-type="universheet_copy_action_table">${colGroup}${cpData}</table>`;+ return cpTable;+ }}diff --git a/packages/sheets-plugin-operation/src/index.ts b/packages/sheets-plugin-operation/src/index.tsindex 85d773275a..a75965dfce 100644--- a/packages/sheets-plugin-operation/src/index.ts+++ b/packages/sheets-plugin-operation/src/index.ts@@ -1,2 +1 @@export * from './OperationPlugin';-