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
chore(clipboard): support copy and paste
Dushusirba6a30b86cb1
diff --git a/examples/univer-preact-ts/package.json b/examples/univer-preact-ts/package.jsonindex 1b1350ade0..235289498a 100644--- a/examples/univer-preact-ts/package.json+++ b/examples/univer-preact-ts/package.json@@ -47,7 +47,9 @@"@univerjs/sheets-plugin-formula": "workspace:^0.0.1","@univerjs/sheets-plugin-import-xlsx": "workspace:^0.0.1","@univerjs/sheets-plugin-numfmt": "workspace:^0.0.1",+ "@univerjs/ui-plugin-docs": "workspace:^0.0.1","@univerjs/ui-plugin-sheets": "workspace:^0.0.1",+ "@univerjs/ui-plugin-slides": "workspace:^0.0.1","preact": "^10.12.1"}}\ No newline at end of filediff --git a/examples/univer-preact-ts/src/index.ts b/examples/univer-preact-ts/src/index.tsindex b6bc09a4b4..95f18d69e9 100644--- a/examples/univer-preact-ts/src/index.ts+++ b/examples/univer-preact-ts/src/index.ts@@ -3,6 +3,8 @@ import { RenderEngine } from '@univerjs/base-render';import { ISheetPluginConfig, SheetPlugin } from '@univerjs/base-sheets';import { SheetUIPlugin,ISheetUIPluginConfig } from '@univerjs/ui-plugin-sheets';+import { DocUIPlugin, IDocUIPluginConfig } from '@univerjs/ui-plugin-docs';+import { SlideUIPlugin, ISlideUIPluginConfig } from '@univerjs/ui-plugin-slides';import { IDocPluginConfig, DocPlugin } from '@univerjs/base-docs';import { ISlidePluginConfig, SlidePlugin } from '@univerjs/base-slides';import { DEFAULT_WORKBOOK_DATA } from '@univerjs/common-plugin-data';@@ -34,7 +36,7 @@ class UniverSheetCustom {// universheet instanceconst universheet = UniverSheet.newInstance(config.coreConfig);univer.addUniverSheet(universheet);- // base-sheet+ // base-sheetsuniversheet.installPlugin(new SheetPlugin(config.baseSheetsConfig));// ui-plugin-sheetsuniver.install(@@ -59,72 +61,97 @@ const univerSheetCustom = function (config?: ISheetPropsCustom) {return new UniverSheetCustom().init(config);};-// interface IDocPropsCustom {-// coreConfig?: Partial<IDocumentData>;-// baseDocsConfig?: IDocPluginConfig;-// }--// /**-// * Initialize the core and all plugins-// */-// class UniverDocCustom {-// constructor() {}-// init(config: IDocPropsCustom = {}): UniverDoc {-// const univerdoc = UniverDoc.newInstance(config.coreConfig);--// univerdoc.installPlugin(new RenderEngine());-// univerdoc.installPlugin(new DocPlugin(config.baseDocsConfig));--// return univerdoc;-// }-// }-// /**-// * Wrapped into a function,easy to use-// * @param config-// * @returns-// */-// const univerDocCustom = function (config?: IDocPropsCustom) {-// return new UniverDocCustom().init(config);-// };--// interface ISlidePropsCustom {-// coreConfig?: Partial<ISlideData>;-// baseSlidesConfig?: ISlidePluginConfig;-// }--// /**-// * Initialize the core and all plugins-// */-// class UniverSlideCustom {-// constructor() {}-// init(config: ISlidePropsCustom = {}): UniverSlide {-// const universlide = UniverSlide.newInstance(config.coreConfig);--// universlide.installPlugin(new RenderEngine());-// universlide.installPlugin(new SlidePlugin(config.baseSlidesConfig));--// return universlide;-// }-// }+interface IDocPropsCustom {+ coreConfig?: Partial<IDocumentData>;+ baseDocsConfig?: IDocPluginConfig;+ uiDocsConfig?: IDocUIPluginConfig;+}++/**+ * Initialize the core and all plugins+ */+class UniverDocCustom {+ constructor() {}+ init(config: IDocPropsCustom = {}): UniverDoc {++ const univer = new Univer();++ // base-render+ univer.install(new RenderEngine());++ // univerdoc instance+ const univerdoc = UniverDoc.newInstance(config.coreConfig);+ univer.addUniverDoc(univerdoc);++ // base-docs+ univerdoc.installPlugin(new DocPlugin(config.baseDocsConfig));++ // ui-plugin-sheets+ univer.install(+ new DocUIPlugin(config.uiDocsConfig)+ );++ return univerdoc;+ }+}/*** Wrapped into a function,easy to use* @param config* @returns*/-// const univerSlideCustom = function (config?: ISlidePropsCustom) {-// return new UniverSlideCustom().init(config);-// };+const univerDocCustom = function (config?: IDocPropsCustom) {+ return new UniverDocCustom().init(config);+};++interface ISlidePropsCustom {+ coreConfig?: Partial<ISlideData>;+ baseSlidesConfig?: ISlidePluginConfig;+ uiSlidesConfig?: ISlideUIPluginConfig;+}++/**+ * Initialize the core and all plugins+ */+class UniverSlideCustom {+ constructor() {}+ init(config: ISlidePropsCustom = {}): UniverSlide {+ const univer = new Univer();++ // base-render+ univer.install(new RenderEngine());+ // universlide instance+ const universlide = UniverSlide.newInstance(config.coreConfig);+ univer.addUniverSlide(universlide);+ // base-slides+ universlide.installPlugin(new SlidePlugin(config.baseSlidesConfig));+ // ui-plugin-slides+ univer.install(+ new SlideUIPlugin(config.uiSlidesConfig)+ );++ return universlide;+ }+}+/**+ * Wrapped into a function,easy to use+ * @param config+ * @returns+ */+const univerSlideCustom = function (config?: ISlidePropsCustom) {+ return new UniverSlideCustom().init(config);+};-export { univerSheetCustom};-// export { univerSheetCustom, univerDocCustom, univerSlideCustom };+export { univerSheetCustom, univerDocCustom, univerSlideCustom };export * as UniverCore from '@univerjs/core';export * as BaseRender from '@univerjs/base-render';export * as BaseComponent from '@univerjs/base-ui';export * as BaseSheets from '@univerjs/base-sheets';-// export * as BaseDocs from '@univerjs/base-docs';-// export * as BaseSlides from '@univerjs/base-slides';+export * as BaseDocs from '@univerjs/base-docs';+export * as BaseSlides from '@univerjs/base-slides';export * as UIPluginSheets from '@univerjs/ui-plugin-sheets';+export * as UIPluginDocs from '@univerjs/ui-plugin-docs';+export * as UIPluginSlides from '@univerjs/ui-plugin-slides';export * as CommonPluginData from '@univerjs/common-plugin-data';// export * as CommonPluginCollaboration from '@univerjs/common-plugin-collaboration';// export * as SheetsPluginFormula from '@univerjs/sheets-plugin-formula';diff --git a/examples/univer-sheet-ts/src/main.tsx b/examples/univer-sheet-ts/src/main.tsxindex dc162e5e50..08ac13fa80 100644--- a/examples/univer-sheet-ts/src/main.tsx+++ b/examples/univer-sheet-ts/src/main.tsx@@ -75,6 +75,7 @@ univer.install(// FormulaPlugin.create(DEFAULT_FORMULA_DATA_DEMO).installTo(universheet);FindPlugin.create().installTo(universheet);+universheet.installPlugin(new ClipboardPlugin());// sheets-plugin-ui univer.install(new SheetsUI)// sheets-plugin-ui univer.install(new SheetsUI// const univerSheetDemo = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA_DEMO);@@ -90,5 +91,5 @@ FindPlugin.create().installTo(universheet);// FormulaPlugin.create(DEFAULT_FORMULA_DATA_DEMO).installTo(univerSheetDemo);// FormulaPlugin.create(DEFAULT_FORMULA_DATA_DEMO1).installTo(univerSheetDemo);-// univerSheetDemo.installPlugin(new ClipboardPlugin());+// univerSheetDemo.installPlugin(new ImportXlsxPlugin());diff --git a/packages/base-ui/src/Common/RegisterManager.ts b/packages/base-ui/src/Common/RegisterManager.tsindex c5fcd2d870..61aa759854 100644--- a/packages/base-ui/src/Common/RegisterManager.ts+++ b/packages/base-ui/src/Common/RegisterManager.ts@@ -18,7 +18,7 @@ export class RegisterManager {setClipboardExtensionManager() {this._clipboardExtensionManager = new ClipboardExtensionManager();- const onKeyPasteObservable = this._plugin.getContext().getObserverManager().getObserver<ClipboardEvent>('onKeyPasteObservable', 'core');+ const onKeyPasteObservable = this._plugin.getGlobalContext().getObserverManager().getObserver<ClipboardEvent>('onKeyPasteObservable', 'core');if (onKeyPasteObservable && !onKeyPasteObservable.hasObservers()) {onKeyPasteObservable.add((evt: ClipboardEvent) => {@@ -32,7 +32,7 @@ export class RegisterManager {setDragAndDropExtensionManager() {this._dragAndDropExtensionManager = new DragAndDropExtensionManager();- const onDropObservable = this._plugin.getContext().getObserverManager().getObserver<DragEvent>('onDropObservable', 'core');+ const onDropObservable = this._plugin.getGlobalContext().getObserverManager().getObserver<DragEvent>('onDropObservable', 'core');if (onDropObservable && !onDropObservable.hasObservers()) {onDropObservable.add((evt: DragEvent) => {diff --git a/packages/sheets-plugin-clipboard/src/ClipboardPlugin.tsx b/packages/sheets-plugin-clipboard/src/ClipboardPlugin.tsxindex 279703880e..7e0344dc26 100644--- a/packages/sheets-plugin-clipboard/src/ClipboardPlugin.tsx+++ b/packages/sheets-plugin-clipboard/src/ClipboardPlugin.tsx@@ -40,7 +40,7 @@ export class ClipboardPlugin extends Plugin<any, SheetContext> {}registerExtension() {- const clipboardRegister = this.getContext()+ const clipboardRegister = this.getGlobalContext().getPluginManager().getRequirePluginByName<SheetUIPlugin>(SHEET_UI_PLUGIN_NAME).getRegisterManager()@@ -73,7 +73,7 @@ export class ClipboardPlugin extends Plugin<any, SheetContext> {onMounted(context: SheetContext): void {super.onMounted(context);- context.getLocale().load({+ this.getLocale().load({en,zh,});diff --git a/packages/sheets-plugin-clipboard/src/Domain/Copy.ts b/packages/sheets-plugin-clipboard/src/Domain/Copy.tsindex 8a542141f5..b7b37eecb0 100644--- a/packages/sheets-plugin-clipboard/src/Domain/Copy.ts+++ b/packages/sheets-plugin-clipboard/src/Domain/Copy.ts@@ -1,6 +1,6 @@-import { handleJsonToDom, handleStyleToString } from '@univerjs/base-ui';-import { SheetContext, PLUGIN_NAMES, Tools } from '@univerjs/core';-import { SheetPlugin, SelectionModel, RightMenuProps, SelectionControl, RightMenuItem } from '@univerjs/base-sheets';+import { SheetContext, PLUGIN_NAMES, Tools, handleJsonToDom, handleStyleToString } from '@univerjs/core';+import { SheetPlugin, SelectionModel, SelectionControl } from '@univerjs/base-sheets';+import { RightMenuProps, SheetUIPlugin, SHEET_UI_PLUGIN_NAME, RightMenuItem } from '@univerjs/ui-plugin-sheets';import { Clipboard } from './Clipboard';import { ClipboardInput } from '../UI/ClipboardInput';import { CLIPBOARD_PLUGIN } from '../Const';@@ -13,9 +13,9 @@ export abstract class Copy {const SheetPlugin = this._context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET);this._initRegisterComponent(componentList);- SheetPlugin?.addRightMenu(copyList);+ // SheetPlugin?.addRightMenu(copyList);- const manager = this._context.getObserverManager();+ const manager = this._context.getUniver().getGlobalContext().getObserverManager();manager.requiredObserver<ClipboardEvent>('onKeyCopyObservable', 'core').add((e) => {this.copy(e);});@@ -30,9 +30,23 @@ export abstract class Copy {}private _initRegisterComponent(component: any[]) {- const SheetPlugin = this._context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;+ // const SheetPlugin = this._context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;++ const mainSlotController = this._context+ .getUniver()+ .getGlobalContext()+ .getPluginManager()+ .getRequirePluginByName<SheetUIPlugin>(SHEET_UI_PLUGIN_NAME)+ .getAppUIController()+ .getSheetContainerController()+ .getMainSlotController();+for (let i = 0; i < component.length; i++) {- SheetPlugin.registerComponent(CLIPBOARD_PLUGIN + component[i].name, component[i]);+ // SheetPlugin.registerComponent(CLIPBOARD_PLUGIN + component[i].name, component[i]);++ mainSlotController.addSlot(CLIPBOARD_PLUGIN + component[i].name, {+ component: component[i],+ });}}}@@ -122,169 +136,6 @@ export class UniverCopy extends Copy {super(context, copyList, [ClipboardInput]);}- 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) {@@ -463,4 +314,167 @@ export class UniverCopy extends Copy {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-clipboard/src/Domain/Paste.ts b/packages/sheets-plugin-clipboard/src/Domain/Paste.tsindex 1f03a635b0..87069b936b 100644--- a/packages/sheets-plugin-clipboard/src/Domain/Paste.ts+++ b/packages/sheets-plugin-clipboard/src/Domain/Paste.ts@@ -14,7 +14,7 @@ export abstract class Paste {constructor(context: SheetContext, pasteList: RightMenuProps[]) {this._context = context;const SheetPlugin = this._context.getPluginManager().getRequirePluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET);- SheetPlugin.addRightMenu(pasteList);+ // SheetPlugin.addRightMenu(pasteList);// SheetPlugin.getCellEditorController().isEditMode// const manager = this._context.getObserverManager();@@ -168,6 +168,7 @@ export class UniverPaste extends Paste {// }pasteTo(data) {+ debugger// const data = await this.pasteResolver(e);// if (data.length === 0) return;diff --git a/packages/sheets-plugin-clipboard/src/UI/ClipboardInput.tsx b/packages/sheets-plugin-clipboard/src/UI/ClipboardInput.tsxindex 783b881164..0de38f16e8 100644--- a/packages/sheets-plugin-clipboard/src/UI/ClipboardInput.tsx+++ b/packages/sheets-plugin-clipboard/src/UI/ClipboardInput.tsx@@ -1,4 +1,4 @@-import { BaseComponentRender, BaseComponentSheet, Component } from '@univerjs/base-ui';+import { BaseComponentRender, Component, Input } from '@univerjs/base-ui';interface IProps {prefix?: string;@@ -10,14 +10,10 @@ interface IProps {export class ClipboardInput extends Component<IProps> {private _render: BaseComponentRender;- initialize() {- const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- this._render = component.getComponentRender();- }+ initialize() {}render() {const { prefix, placeholder1, suffix, placeholder2 } = this.props;- const Input = this._render.renderFunction('Input');return (<div>diff --git a/packages/ui-plugin-docs/src/Basics/index.ts b/packages/ui-plugin-docs/src/Basics/index.tsindex 14c41ec033..f0080f0e06 100644--- a/packages/ui-plugin-docs/src/Basics/index.ts+++ b/packages/ui-plugin-docs/src/Basics/index.ts@@ -1,5 +1,3 @@export * from './Const';-export * from './Enum';export * from '../Locale';-export * from './Shared';export * from './Interfaces';diff --git a/packages/ui-plugin-docs/src/index.ts b/packages/ui-plugin-docs/src/index.tsindex 2438192fae..370d22db75 100644--- a/packages/ui-plugin-docs/src/index.ts+++ b/packages/ui-plugin-docs/src/index.ts@@ -1 +1,2 @@export * from './DocUIPlugin';+export * from './Basics';diff --git a/packages/ui-plugin-sheets/src/Controller/CellEditorUIController.ts b/packages/ui-plugin-sheets/src/Controller/CellEditorUIController.tsindex da8c581908..bf88745a19 100644--- a/packages/ui-plugin-sheets/src/Controller/CellEditorUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/CellEditorUIController.ts@@ -1,6 +1,6 @@import { IPointerEvent, IMouseEvent } from '@univerjs/base-render';import { CANVAS_VIEW_KEY, SheetPlugin } from '@univerjs/base-sheets';-import { getRefElement, CellEditExtensionManager, KeyboardManager, $$, setLastCaretPosition, handleStringToStyle, handleDomToJson } from '@univerjs/base-ui';+import { getRefElement, CellEditExtensionManager, $$, setLastCaretPosition, handleStringToStyle, handleDomToJson } from '@univerjs/base-ui';import { Direction, handleStyleToString, ICellData, isKeyPrintable, PLUGIN_NAMES, Tools } from '@univerjs/core';import { SheetUIPlugin } from '../SheetUIPlugin';import { RichText } from '../View/RichText';@@ -21,8 +21,6 @@ export class CellEditorUIController {private _cellEditExtensionManager: CellEditExtensionManager;- private _keyboardManager: KeyboardManager;-constructor(plugin: SheetUIPlugin) {this._plugin = plugin;this._sheetPlugin = plugin.getUniver().getCurrentUniverSheetInstance().context.getPluginManager().getRequirePluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET);@@ -214,10 +212,6 @@ export class CellEditorUIController {});this._cellEditExtensionManager = new CellEditExtensionManager();-- this._keyboardManager = new KeyboardManager(this._plugin);-- // this._richTextEditEle}private setRichText() {@@ -231,8 +225,7 @@ export class CellEditorUIController {this.hideEditContainer();// init event- // this._handleKeyboardAction();- this._keyboardManager.handleKeyboardAction(this._richTextEditEle);+ this._plugin.getKeyboardManager().handleKeyboardAction(this._richTextEditEle);this._handleKeyboardObserver();// Get the display status of the formula prompt boxdiff --git a/packages/ui-plugin-sheets/src/SheetUIPlugin.ts b/packages/ui-plugin-sheets/src/SheetUIPlugin.tsindex ccd4a64748..aadc0ba608 100644--- a/packages/ui-plugin-sheets/src/SheetUIPlugin.ts+++ b/packages/ui-plugin-sheets/src/SheetUIPlugin.ts@@ -1,5 +1,5 @@import { Plugin, UniverSheet, Tools, PLUGIN_NAMES, Context } from '@univerjs/core';-import { ComponentManager, getRefElement, RegisterManager } from '@univerjs/base-ui';+import { ComponentManager, getRefElement, RegisterManager, KeyboardManager } from '@univerjs/base-ui';import { RenderEngine } from '@univerjs/base-render';import { DefaultSheetUIConfig, installObserver, ISheetUIPluginConfig, SheetUIPluginObserve, SHEET_UI_PLUGIN_NAME } from './Basics';import { zh, en } from './Locale';@@ -11,6 +11,8 @@ import { IToolbarItemProps } from './Controller';export class SheetUIPlugin extends Plugin<SheetUIPluginObserve, Context> {private _appUIController: AppUIController;+ private _keyboardManager: KeyboardManager;+private _registerManager: RegisterManager;private _config: ISheetUIPluginConfig;@@ -41,6 +43,7 @@ export class SheetUIPlugin extends Plugin<SheetUIPluginObserve, Context> {});this._componentManager = new ComponentManager();+ this._keyboardManager = new KeyboardManager(this);this._registerManager = new RegisterManager(this);this._appUIController = new AppUIController(this);// AppUIController initializes the DOM as an asynchronous rendering process, and must wait for the UI rendering to complete before starting to render the canvas@@ -94,6 +97,14 @@ export class SheetUIPlugin extends Plugin<SheetUIPluginObserve, Context> {return this._registerManager;}+ /**+ * usage this._clipboardExtensionManager.handle(data);+ * @returns+ */+ getKeyboardManager(): KeyboardManager {+ return this._keyboardManager;+ }+/*** Formula Bar API* @param strdiff --git a/packages/ui-plugin-sheets/src/index.ts b/packages/ui-plugin-sheets/src/index.tsindex 2218efe867..a5e787140d 100644--- a/packages/ui-plugin-sheets/src/index.ts+++ b/packages/ui-plugin-sheets/src/index.ts@@ -1,3 +1,4 @@export * from './Basics';export * from './Controller';export * from './SheetUIPlugin';+export * from './View';diff --git a/packages/ui-plugin-slides/src/index.ts b/packages/ui-plugin-slides/src/index.tsindex d35fee8363..4d33427683 100644--- a/packages/ui-plugin-slides/src/index.ts+++ b/packages/ui-plugin-slides/src/index.ts@@ -1 +1,2 @@-export * from './SlideUIPlugin';+export * from './SlideUIPlugin';+export * from './Basics';