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
fix(sheets-ui): enhance paste handling and cleanup event listeners for SheetBar (#6486)
白熱938a347f2f9f
diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.ts b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.tsindex 9bb592dfc6..12bedf738d 100644--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.ts+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.ts@@ -116,6 +116,7 @@ export class SlideTabItem {return this.getTranslateXDirection();}+ // eslint-disable-next-line max-lines-per-functionsetEditor(callback?: (event: FocusEvent) => void): void {if (!this._slideTabBar.getConfig().onNameChangeCheck()) {return;@@ -124,6 +125,15 @@ export class SlideTabItem {if (this._editMode === false) {const input = this._slideTabItem.querySelector('span');+ const pasteAction = (e: ClipboardEvent) => {+ e.preventDefault();+ const text = e.clipboardData?.getData('text/plain');+ if (text) {+ const savedText = text.replace(/\s/g, '');+ document.execCommand('insertText', false, savedText);+ }+ };+const blurAction = (focusEvent: FocusEvent) => {if (this.nameCheck()) return;@@ -136,6 +146,7 @@ export class SlideTabItem {input.removeEventListener('compositionend', compositionendAction);input.removeEventListener('input', inputAction);input.removeEventListener('keydown', keydownAction);+ input.removeEventListener('paste', pasteAction);}// Event must be removed before updateItems@@ -152,7 +163,7 @@ export class SlideTabItem {}};- let keydownAction = (e: KeyboardEvent) => {+ const keydownAction = (e: KeyboardEvent) => {if (!input) return;e.stopPropagation();@@ -161,11 +172,11 @@ export class SlideTabItem {}};- const compositionstartAction = (e: CompositionEvent) => {+ const compositionstartAction = () => {compositionFlag = false;};- const compositionendAction = (e: CompositionEvent) => {+ const compositionendAction = () => {compositionFlag = true;};@@ -191,6 +202,7 @@ export class SlideTabItem {input.addEventListener('compositionend', compositionendAction);input.addEventListener('input', inputAction);input.addEventListener('keydown', keydownAction);+ input.addEventListener('paste', pasteAction);this._editMode = true;SlideTabBar.keepSelectAll(input);}