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-sheet): celledit add to

Dushusir04e874b60e2c
diff --cc packages/base-sheets/src/SpreadsheetPlugin.tsx
index eaf26274ad,1a31411026..32b3d8e4f3
--- a/packages/base-sheets/src/SpreadsheetPlugin.tsx
+++ b/packages/base-sheets/src/SpreadsheetPlugin.tsx
@@@ -1,26 -1,98 +1,26 @@@
- import { getRefElement, IMainProps, isElement, ISlotProps, IToolBarItemProps, RefObject, render } from '@univer/base-component';
+ import { getRefElement, IMainProps, isElement, ISlotProps, RefObject, render } from '@univer/base-component';
import { Engine, RenderEngine } from '@univer/base-render';
-import { AsyncFunction, Attribute, Context, IOCAttribute, IOCContainer, IRangeCellData, IRangeData, IWorkbookConfig, Plugin, PLUGIN_NAMES, Tools } from '@univer/core';
+import { AsyncFunction, Attribute, Context, IOCAttribute, IOCContainer, IWorkbookConfig, Plugin, PLUGIN_NAMES, Tools } from '@univer/core';
- import { FormulaPlugin } from '@univer/sheets-plugin-formula';
import { install, SpreadsheetPluginObserve, uninstall } from './Basics/Observer';
import { RightMenuProps } from './Model/RightMenuModel';
import { en, zh } from './Locale';
import { CANVAS_VIEW_KEY } from './View/Render/BaseView';
import { CanvasView } from './View/Render/CanvasView';
-import { BaseSheetContainerConfig, ISpreadsheetPluginConfigBase, SheetContainer } from './View/UI/SheetContainer';
+import { BaseSheetContainerConfig, SheetContainer } from './View/UI/SheetContainer';
import {
RightMenuController,
- ToolBarController,
InfoBarController,
SheetBarControl,
CellEditorController,
AntLineControl,
CountBarController,
SheetContainerController,
+ ToolBarController,
} from './Controller';
- import { ToolBarController1 } from './Controller/ToolBarController1';
+ import { IToolBarItemProps } from './Model/ToolBarModel';
+ import { ModalGroupController } from './Controller/ModalGroupController';
-
-export interface ISelectionConfig {
- selection: IRangeData;
- cell?: IRangeCellData;
-}
-
-export interface ISelectionsConfig {
- [worksheetId: string]: ISelectionConfig[];
-}
-
-export interface ISpreadsheetPluginConfig extends ISpreadsheetPluginConfigBase {
- container: HTMLElement | string;
- selections: ISelectionsConfig;
-}
-
-const DEFAULT_SPREADSHEET_PLUGIN_DATA: ISpreadsheetPluginConfig = {
- container: 'universheet',
- layout: 'auto',
- selections: {
- 'sheet-01': [
- {
- selection: {
- startRow: 13,
- endRow: 14,
- startColumn: 1,
- endColumn: 2,
- },
- },
- {
- selection: {
- startRow: 16,
- endRow: 18,
- startColumn: 1,
- endColumn: 2,
- },
- cell: {
- row: 16,
- column: 1,
- },
- },
- ],
- 'sheet-02': [
- {
- selection: {
- startRow: 17,
- endRow: 20,
- startColumn: 1,
- endColumn: 2,
- },
- },
- {
- selection: {
- startRow: 22,
- endRow: 23,
- startColumn: 1,
- endColumn: 2,
- },
- },
- {
- selection: {
- startRow: 25,
- endRow: 27,
- startColumn: 4,
- endColumn: 6,
- },
- cell: {
- row: 25,
- column: 4,
- },
- },
- ],
- },
-};
+import { ISpreadsheetPluginConfig, DEFAULT_SPREADSHEET_PLUGIN_DATA } from './Basics';
/**
* The main sheet base, construct the sheet container and layout, mount the rendering engine
diff --cc packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsx
index aed20fe3bb,ef5477f3c9..8b5c2ac167
--- a/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsx
+++ b/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsx
@@@ -13,6 -12,6 +12,7 @@@ import
RefObject,
cloneElement,
BaseComponentProps,
++ Description,
} from '@univer/base-component';
import { AsyncFunction, Context, IKeyType, LocaleType, PLUGIN_NAMES, Tools, Workbook } from '@univer/core';
import cssVars from 'css-vars-ponyfill';
@@@ -712,8 -705,10 +706,10 @@@ export class SheetContainer extends Com
return <JSXElement ref={this.refMap[item.name]} style={{ display: item.show ? '' : 'none' }} />;
}
return item;
- })} */}
+ })}
+ <ModalGroup></ModalGroup>
+
{!!layout.contentSplit && (
<Container ref={this.splitLeftRef} className={style.contentInnerLeftContainer}>
<div className={style.hoverCursor} onMouseDown={this.handleSplitBarMouseDown}></div>
diff --cc packages/base-sheets/src/main.tsx
index b4c3e8849e,d2dd409405..c74f1f3863
--- a/packages/base-sheets/src/main.tsx
+++ b/packages/base-sheets/src/main.tsx
@@@ -3,8 -3,7 +3,8 @@@ import { RenderEngine } from '@univer/b
import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';
import { UniverComponentSheet } from '@univer/style-universheet';
import { ClipboardPlugin } from '@univer/sheets-plugin-clipboard';
- import { DEFAULT_FORMULA_DATA, FormulaPlugin } from '@univer/sheets-plugin-formula';
import { NumfmtPlugin } from '@univer/sheets-plugin-numfmt';
++import { DEFAULT_FORMULA_DATA, FormulaPlugin } from '@univer/sheets-plugin-formula';
const uiDefaultConfigUp = {
container: 'universheet-demo-up',
diff --cc packages/sheets-plugin-formula/src/Basic/Register/FormulaCellExtension.ts
index f226367704,0000000000..0b75cd88b5
mode 100644,000000..100644
--- a/packages/sheets-plugin-formula/src/Basic/Register/FormulaCellExtension.ts
+++ b/packages/sheets-plugin-formula/src/Basic/Register/FormulaCellExtension.ts
@@@ -1,65 -1,0 +1,64 @@@
+import { BaseCellExtension, BaseCellExtensionFactory, ICell } from '@univer/base-sheets';
+import { IFormulaData } from '@univer/base-formula-engine';
+import { FormulaPlugin } from '../../FormulaPlugin';
+
+export class FormulaCellExtension extends BaseCellExtension {
+ setValue(value: string) {
+ this._cell.value = value;
+ }
+
+ execute() {
- console.info('Find formula!');
+ this.setValue(this._value);
+ }
+}
+
+export class FormulaCellExtensionFactory extends BaseCellExtensionFactory<FormulaPlugin> {
+ get zIndex(): number {
+ return 0;
+ }
+
+ create(cell: ICell, value: string): FormulaCellExtension {
+ return new FormulaCellExtension(cell, value);
+ }
+
+ check(cell: ICell) {
+ const { row, column } = cell;
+
+ const formulaData = this._plugin.getFormulaController().getDataModel().getFormulaData();
+
+ let formula;
+
+ Object.keys(formulaData).forEach((unitId) => {
+ const sheetData = formulaData[unitId];
+
+ const sheetIds = Object.keys(sheetData);
+
+ for (let i = 0, len = sheetIds.length; i < len; i++) {
+ const sheetId = sheetIds[i];
+ const cellData = sheetData[sheetId];
+ console.info('cellData', cellData);
+ // cellData.forEach((row, rowArray) => {
+ // rowArray.forEach((column, mainCell) => {
+ // console.log('main----', row, column, mainCell);
+ // });
+ // });
+
+ Object.keys(cellData).forEach((cellRow) => {
+ const rowArray = cellData[cellRow];
+ rowArray.forEach((cellColumn: number, value: IFormulaData) => {
+ if (Number(cellRow) === row && cellColumn === column) {
+ formula = value.formula;
+ return false;
+ }
+ });
+ });
+ }
+ });
+
+ if (!formula) {
+ return false;
+ }
+
+ return this.create(cell, formula);
+ }
+}
diff --cc packages/sheets-plugin-formula/src/FormulaPlugin.tsx
index 62b41957af,663494b619..7cd81ca3f6
--- a/packages/sheets-plugin-formula/src/FormulaPlugin.tsx
+++ b/packages/sheets-plugin-formula/src/FormulaPlugin.tsx
@@@ -1,6 -1,6 +1,5 @@@
import { Context, IOCContainer, UniverSheet, Plugin, PLUGIN_NAMES } from '@univer/core';
--import { IToolBarItemProps, ISlotElement } from '@univer/base-component';
-import { SpreadsheetPlugin } from '@univer/base-sheets';
+import { CellExtensionManager, SpreadsheetPlugin } from '@univer/base-sheets';
import { FormulaEnginePlugin } from '@univer/base-formula-engine';
import { FormulaButton } from './UI/FormulaButton';
import { zh, en } from './Locale';
@@@ -52,15 -51,13 +51,15 @@@ export class FormulaPlugin extends Plug
const config: IConfig = { context };
-- const item: IToolBarItemProps = {
++ const item = {
locale: FORMULA_PLUGIN_NAME,
-- type: ISlotElement.JSX,
++ type: 0,
show: true,
label: <FormulaButton config={config} />,
};
-- context.getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addButton(item);
++ context.getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.addToolButton(item);
+
+ this.registerExtension();
}
onMapping(IOC: IOCContainer): void {}