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
feat(float-image): support paste image from external (#3617)
siamee66eac88483
diff --git a/e2e/perf/scroll.spec.ts b/e2e/perf/scroll.spec.tsindex 8ac962414b..2ec5ffd626 100644--- a/e2e/perf/scroll.spec.ts+++ b/e2e/perf/scroll.spec.ts@@ -14,9 +14,9 @@* limitations under the License.*/-import { chromium, expect, test } from '@playwright/test';-/* eslint-disable no-console */import type { Page } from '@playwright/test';+/* eslint-disable no-console */+import { chromium, expect, test } from '@playwright/test';import { sheetData as emptySheetData } from '../__testing__/emptysheet';import { sheetData as freezeData } from '../__testing__/freezesheet';import { sheetData as mergeCellData } from '../__testing__/mergecell';diff --git a/packages/design/src/components/form-layout/FormLayout.tsx b/packages/design/src/components/form-layout/FormLayout.tsxindex 1218c3e6f9..203fad7e50 100644--- a/packages/design/src/components/form-layout/FormLayout.tsx+++ b/packages/design/src/components/form-layout/FormLayout.tsx@@ -42,7 +42,7 @@ export const FormLayout = (props: IFormLayoutProps) => {const isInner = useContext(FormLayoutContext);return (- <FormLayoutContext.Provider value={true}>+ <FormLayoutContext.Provider value><div className={clsx(styles.formLayout, isInner ? styles.formLayoutInner : '', className)} style={style}>{label && (<div style={{ cursor: collapsable ? 'pointer' : 'default' }} className={styles.formLayoutLabel} onClick={() => setCollapsed(!collapsed)}>diff --git a/packages/docs-mention-ui/src/controllers/doc-mention-trigger.controller.ts b/packages/docs-mention-ui/src/controllers/doc-mention-trigger.controller.tsindex a47c412b3a..24977e2c8c 100644--- a/packages/docs-mention-ui/src/controllers/doc-mention-trigger.controller.ts+++ b/packages/docs-mention-ui/src/controllers/doc-mention-trigger.controller.ts@@ -19,8 +19,8 @@ import { Disposable, ICommandService, Inject, Tools } from '@univerjs/core';import { DocSelectionManagerService } from '@univerjs/docs';import { DeleteLeftCommand, InsertCommand, MoveCursorOperation } from '@univerjs/docs-ui';import { CloseMentionEditPopupOperation, ShowMentionEditPopupOperation } from '../commands/operations/mention-popup.operation';-import { DocMentionService } from '../services/doc-mention.service';import { DocMentionPopupService } from '../services/doc-mention-popup.service';+import { DocMentionService } from '../services/doc-mention.service';export class DocMentionTriggerController extends Disposable {constructor(diff --git a/packages/docs-ui/src/controllers/render-controllers/doc-clipboard.controller.ts b/packages/docs-ui/src/controllers/render-controllers/doc-clipboard.controller.tsindex c6bdd4c14e..4a73a6eb8b 100644--- a/packages/docs-ui/src/controllers/render-controllers/doc-clipboard.controller.ts+++ b/packages/docs-ui/src/controllers/render-controllers/doc-clipboard.controller.ts@@ -24,11 +24,8 @@ import {RxDisposable,} from '@univerjs/core';import {- FILE__BMP_CLIPBOARD_MIME_TYPE,- FILE__JPEG_CLIPBOARD_MIME_TYPE,- FILE__WEBP_CLIPBOARD_MIME_TYPE,- FILE_PNG_CLIPBOARD_MIME_TYPE,HTML_CLIPBOARD_MIME_TYPE,+ imageMimeTypeSet,PLAIN_TEXT_CLIPBOARD_MIME_TYPE,} from '@univerjs/ui';import { takeUntil } from 'rxjs';@@ -67,15 +64,8 @@ export class DocClipboardController extends RxDisposable implements IRenderModullet htmlContent = clipboardEvent.clipboardData?.getData(HTML_CLIPBOARD_MIME_TYPE);const textContent = clipboardEvent.clipboardData?.getData(PLAIN_TEXT_CLIPBOARD_MIME_TYPE);- const imageTypes = [- FILE__BMP_CLIPBOARD_MIME_TYPE,- FILE__JPEG_CLIPBOARD_MIME_TYPE,- FILE__WEBP_CLIPBOARD_MIME_TYPE,- FILE_PNG_CLIPBOARD_MIME_TYPE,- ];-const files = [...(clipboardEvent.clipboardData?.items || [])]- .filter((item) => imageTypes.includes(item.type))+ .filter((item) => imageMimeTypeSet.has(item.type)).map((item) => item.getAsFile()!).filter((e) => !!e);diff --git a/packages/drawing/src/services/drawing-manager-impl.service.ts b/packages/drawing/src/services/drawing-manager-impl.service.tsindex 043cf90f1f..8edfe2d0dc 100644--- a/packages/drawing/src/services/drawing-manager-impl.service.ts+++ b/packages/drawing/src/services/drawing-manager-impl.service.ts@@ -237,7 +237,7 @@ export class UnitDrawingService<T extends IDrawingParam> implements IUnitDrawing* ops: [[unit, sheetUnit, order, 0, { r: true }], [unit, sheetUnit, order, 1, { r: true }]]* We expected them to composed as [unit, sheetUnit, order, [0, { r: true }], [1, { r: true }]]* But extremely confusing to get [unit, sheetUnit, order, 0, { r: true }, 2, { r: true }]- * And We apply this composed op to data, it's not a 2-index item for us to remove.+ * And We apply this composed op to data, it's no item with index 2 can be removed.* So use unshift api instead of push here.*/ops.unshift(op);diff --git a/packages/engine-formula/src/functions/information/sheet/__tests__/index.spec.ts b/packages/engine-formula/src/functions/information/sheet/__tests__/index.spec.tsindex 629a8b44fd..66d167d41b 100644--- a/packages/engine-formula/src/functions/information/sheet/__tests__/index.spec.ts+++ b/packages/engine-formula/src/functions/information/sheet/__tests__/index.spec.ts@@ -148,7 +148,7 @@ describe('Test rank function', () => {const result = await calculate('=SHEET(A1)');expect(result).toBe(1);- const result2 = await calculate(`=SHEET('工作表2'!A1)`);+ const result2 = await calculate('=SHEET(\'工作表2\'!A1)');expect(result2).toBe(2);});diff --git a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.tsx b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.tsxindex 04eda3143c..15c0f2f53c 100644--- a/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.tsx+++ b/packages/sheets-conditional-formatting-ui/src/components/panel/rule-list/index.tsx@@ -391,7 +391,6 @@ export const RuleList = (props: IRuleListProps) => {<divclassName={`${styles.draggableHandle}-draggableHandle`}onClick={(e) => e.stopPropagation()}diff --git a/packages/sheets-drawing-ui/src/commands/commands/insert-image.command.ts b/packages/sheets-drawing-ui/src/commands/commands/insert-image.command.tsindex 85225798f7..78af54fcd1 100644--- a/packages/sheets-drawing-ui/src/commands/commands/insert-image.command.ts+++ b/packages/sheets-drawing-ui/src/commands/commands/insert-image.command.ts@@ -26,11 +26,23 @@ export interface IInsertImageCommandParams {export const InsertFloatImageCommand: ICommand<IInsertImageCommandParams> = {id: 'sheet.command.insert-float-image',type: CommandType.COMMAND,- handler: (accessor) => {+ handler: async (accessor, params) => {const renderManagerService = accessor.get(IRenderManagerService);- return renderManagerService.getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_SHEET)- ?.with(SheetDrawingUpdateController)- .insertFloatImage() ?? false;+ const sheetDrawingUpdateController = renderManagerService.getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_SHEET)+ ?.with(SheetDrawingUpdateController);++ if (!sheetDrawingUpdateController) {+ return false;+ }+ const files = params?.files;++ if (files) {+ const awaitFiles = files.map((file) => sheetDrawingUpdateController.insertFloatImageByFile(file));++ return (await Promise.all(awaitFiles)).every((result) => result);+ } else {+ return sheetDrawingUpdateController.insertFloatImage() ?? false;+ }},};diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-copy-paste.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-copy-paste.controller.tsindex cdd930e674..a1875c15d6 100644--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-copy-paste.controller.ts+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-copy-paste.controller.ts@@ -16,50 +16,196 @@import type { IMutationInfo, IRange, Nullable } from '@univerjs/core';import type { IDrawingJsonUndo1 } from '@univerjs/drawing';-import type { ISheetDrawing } from '@univerjs/sheets-drawing';+import type { ISheetDrawing, ISheetImage } from '@univerjs/sheets-drawing';import type { IDiscreteRange, IPasteHookValueType, ISheetDiscreteRangeLocation } from '@univerjs/sheets-ui';-import { Disposable, Tools } from '@univerjs/core';+import type { IDeleteDrawingCommandParams } from '../commands/commands/interfaces';+import { Disposable, DrawingTypeEnum, ICommandService, Tools } from '@univerjs/core';+import { IDrawingManagerService, ImageSourceType } from '@univerjs/drawing';import { IRenderManagerService } from '@univerjs/engine-render';-import { DrawingApplyType, ISheetDrawingService, SetDrawingApplyMutation, SheetDrawingAnchorType } from '@univerjs/sheets-drawing';-import { COPY_TYPE, ISheetClipboardService, PREDEFINED_HOOK_NAME, SheetSkeletonManagerService, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';+import { DrawingApplyType, SetDrawingApplyMutation, SheetDrawingAnchorType } from '@univerjs/sheets-drawing';++import { COPY_TYPE, discreteRangeToRange, ISheetClipboardService, ISheetSelectionRenderService, PREDEFINED_HOOK_NAME, SheetSkeletonManagerService, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';+import { IClipboardInterfaceService } from '@univerjs/ui';+import { transformToDrawingPosition } from '../basics/transform-position';+import { InsertFloatImageCommand } from '../commands/commands/insert-image.command';+import { RemoveSheetDrawingCommand } from '../commands/commands/remove-sheet-drawing.command';++const IMAGE_PNG_MIME_TYPE = 'image/png';++function base64ToBlob(base64: string) {+ const arr = base64.split(',');+ const binStr = atob(arr[1]);+ const len = binStr.length;+ const bytes = new Uint8Array(len);++ for (let i = 0; i < len; i++) {+ bytes[i] = binStr.charCodeAt(i);+ }++ return new Blob([bytes], { type: IMAGE_PNG_MIME_TYPE });+}++function copyBase64ToClipboard(base64: string) {+ const item = new ClipboardItem({ [IMAGE_PNG_MIME_TYPE]: base64ToBlob(base64) });+ navigator.clipboard.write([item]).catch((err) => {+ console.error('Could not copy image using clipboard API: ', err);+ });+}++function focusDocument() {+ function createInputElement() {+ const input = document.createElement('input');+ input.style.position = 'absolute';+ input.style.height = '1px';+ input.style.width = '1px';+ input.style.opacity = '0';++ return input;+ }++ const activeElement = document.activeElement;+ const input = createInputElement();+ document.body.appendChild(input);+ input.focus();++ return () => {+ input.blur();+ document.body.removeChild(input);+ if (activeElement instanceof HTMLElement) {+ activeElement.focus();+ }+ };+}++const specialPastes: IPasteHookValueType[] = [+ PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,+ PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,+ PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,+ PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA,+];export class SheetsDrawingCopyPasteController extends Disposable {private _copyInfo: Nullable<{drawings: ISheetDrawing[];+ copyRange?: IRange;unitId: string;subUnitId: string;}>;constructor(@ISheetClipboardService private _sheetClipboardService: ISheetClipboardService,- // @Inject(ISheetSelectionRenderService) private readonly _selectionRenderService: ISheetSelectionRenderService,-@IRenderManagerService private readonly _renderManagerService: IRenderManagerService,-- @ISheetDrawingService private readonly _sheetDrawingService: ISheetDrawingService- // @Inject(Injector) private _injector: Injector+ @IDrawingManagerService private readonly _drawingService: IDrawingManagerService,+ @IClipboardInterfaceService private readonly _clipboardInterfaceService: IClipboardInterfaceService,+ @ICommandService private readonly _commandService: ICommandService) {super();this._initCopyPaste();}+ private get _focusedDrawings() {+ return this._drawingService.getFocusDrawings() as ISheetDrawing[];+ }++ // eslint-disable-next-line max-lines-per-functionprivate _initCopyPaste() {this._sheetClipboardService.addClipboardHook({id: 'SHEET_IMAGE_UI_PLUGIN',- onBeforeCopy: (unitId, subUnitId, range) => this._collect(unitId, subUnitId, range),++ onBeforeCopy: (unitId, subUnitId, range, copyType) => {+ const focusDrawings = this._focusedDrawings;+ if (focusDrawings.length > 0) {+ // handle single drawing copy+ const [drawing] = focusDrawings;++ if (copyType === COPY_TYPE.CUT) {+ const params: IDeleteDrawingCommandParams = {+ unitId,+ drawings: [drawing],+ };+ // Delete the drawing when it is cut+ this._commandService.executeCommand(RemoveSheetDrawingCommand.id, params);+ }++ setTimeout(() => {+ // Rewrite the clipboard content to prevent the default copy behavior, prevent to call the 'onPasteCells'+ const dispose = focusDocument();+ if (drawing.drawingType === DrawingTypeEnum.DRAWING_IMAGE+ && (drawing as ISheetImage).imageSourceType === ImageSourceType.BASE64) {+ copyBase64ToClipboard((drawing as ISheetImage).source);+ } else {+ this._clipboardInterfaceService.writeText('');+ }+ dispose();+ }, 200);++ const newCopyInfo = {+ unitId: drawing.unitId,+ subUnitId: drawing.subUnitId,+ drawings: [drawing],+ };++ this._copyInfo = newCopyInfo;+ } else {+ // handle copy range that contained drawings+ const newCopyInfo = this._createDrawingsCopyInfoByRange(unitId, subUnitId, range);+ this._copyInfo = newCopyInfo;+ }+ },+onPasteCells: (pasteFrom, pasteTo, data, payload) => {+ if (!this._copyInfo) {+ return { redos: [], undos: [] };+ }+const { copyType = COPY_TYPE.COPY, pasteType } = payload;const { range: copyRange } = pasteFrom || {};- const { range: pastedRange, unitId, subUnitId } = pasteTo;- return this._generateMutations(pastedRange, { copyType, pasteType, copyRange, unitId, subUnitId });+ const { range: pasteRange, unitId, subUnitId } = pasteTo;++ const mutations = this._copyInfo.copyRange+ ? this._generateRangeDrawingsPasteMutations({ pasteType, unitId, subUnitId, pasteRange }, { copyRange, copyType })+ : this._generateSingleDrawingPasteMutations({ pasteTo, pasteType }, COPY_TYPE.COPY);++ return mutations;},+onPastePlainText: (pasteTo: ISheetDiscreteRangeLocation, clipText: string) => {return { undos: [], redos: [] };},++ onPasteUnrecognized: (pasteTo: ISheetDiscreteRangeLocation) => {+ if (this._copyInfo) {+ return this._generateSingleDrawingPasteMutations({ pasteTo, pasteType: PREDEFINED_HOOK_NAME.DEFAULT_PASTE }, COPY_TYPE.COPY);+ } else {+ return { undos: [], redos: [] };+ }+ },++ onPasteFiles: (pasteTo: ISheetDiscreteRangeLocation, files) => {+ if (this._copyInfo) {+ return this._generateSingleDrawingPasteMutations({ pasteTo, pasteType: PREDEFINED_HOOK_NAME.DEFAULT_PASTE }, COPY_TYPE.COPY);+ } else {+ // Paste image from external+ const images = files.filter((file) => file.type.includes('image'));+ if (images.length) {+ return {+ undos: [],+ redos: [+ {+ id: InsertFloatImageCommand.id,+ params: { files: images },+ },+ ],+ };+ }+ }++ return { undos: [], redos: [] };+ },});}- private _collect(unitId: string, subUnitId: string, range: IRange) {+ private _createDrawingsCopyInfoByRange(unitId: string, subUnitId: string, range: IRange) {const skeletonManagerService = this._renderManagerService.getRenderById(unitId)?.with(SheetSkeletonManagerService);if (!skeletonManagerService) return;@@ -69,12 +215,14 @@ export class SheetsDrawingCopyPasteController extends Disposable {}const { startX, endX, startY, endY } = selectionRect;- const drawings = this._sheetDrawingService.getDrawingData(unitId, subUnitId);- const containedDrawings: ISheetDrawing[] = [];+ const drawings = this._drawingService.getDrawingData(unitId, subUnitId);++ const containedDrawings: ISheetDrawing[] = this._focusedDrawings.slice();+Object.keys(drawings).forEach((drawingId) => {const drawing = drawings[drawingId];const { transform } = drawing;- if (drawing.anchorType !== SheetDrawingAnchorType.Both) {+ if ((drawing as ISheetDrawing).anchorType !== SheetDrawingAnchorType.Both) {return;}if (!transform) {@@ -89,11 +237,13 @@ export class SheetsDrawingCopyPasteController extends Disposable {};if (startX <= drawingStartX && drawingEndX <= endX && startY <= drawingStartY && drawingEndY <= endY) {- containedDrawings.push(drawing);+ containedDrawings.push(drawing as ISheetDrawing);}});+if (containedDrawings.length) {- this._copyInfo = {+ return {+ copyRange: range,drawings: containedDrawings,unitId,subUnitId,@@ -101,93 +251,95 @@ export class SheetsDrawingCopyPasteController extends Disposable {}}- // eslint-disable-next-line max-lines-per-function- private _generateMutations(- pastedRange: IDiscreteRange,- copyInfo: {- copyType: COPY_TYPE;- copyRange?: IDiscreteRange;- pasteType: IPasteHookValueType;- unitId: string;- subUnitId: string;- }- ) {- if (!this._copyInfo) {- return { redos: [], undos: [] };- }+ private _generateSingleDrawingPasteMutations(pasteContext: {+ pasteTo: ISheetDiscreteRangeLocation;+ pasteType: IPasteHookValueType;+ }, copyType: COPY_TYPE) {+ const { pasteType, pasteTo } = pasteContext;- const specialPastes: IPasteHookValueType[] = [- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA,- ];- if (specialPastes.includes(copyInfo.pasteType)) {+ if (specialPastes.includes(pasteType)) {return { redos: [], undos: [] };}- const { copyRange } = copyInfo;- if (!copyRange) {- return { redos: [], undos: [] };- }- const { drawings, unitId, subUnitId } = this._copyInfo;- const { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyRange, pastedRange]);- const { row: copyRow, col: copyCol } = mapFunc(vCopyRange.startRow, vCopyRange.startColumn);- const { row: pasteRow, col: pasteCol } = mapFunc(vPastedRange.startRow, vPastedRange.startColumn);+ const { unitId, subUnitId, range } = pasteTo;+ const render = this._renderManagerService.getRenderById(unitId);+ const skeletonManagerService = render?.with(SheetSkeletonManagerService);+ const selectionRenderService = render?.with(ISheetSelectionRenderService);- const skeletonManagerService = this._renderManagerService.getRenderById(unitId)?.with(SheetSkeletonManagerService);+ const copyInfo = this._copyInfo!;- if (!skeletonManagerService) {+ if (!skeletonManagerService || !selectionRenderService) {return { redos: [], undos: [] };}- const copyRect = skeletonManagerService.attachRangeWithCoord({- startRow: copyRow,- endRow: copyRow,- startColumn: copyCol,- endColumn: copyCol,- });- const pasteRect = skeletonManagerService.attachRangeWithCoord({- startRow: pasteRow,- endRow: pasteRow,- startColumn: pasteCol,- endColumn: pasteCol,+ const { drawings } = copyInfo;++ const pasteRange = discreteRangeToRange(range);++ return this._generateMutations(drawings, {+ unitId,+ subUnitId,+ isCut: copyType === COPY_TYPE.CUT,+ getTransform: (transform, sheetTransform) => {+ const pasteRect = skeletonManagerService.attachRangeWithCoord({+ startRow: pasteRange.startRow,+ endRow: pasteRange.endRow,+ startColumn: pasteRange.startColumn,+ endColumn: pasteRange.endColumn,+ });++ const newTransform = {+ ...transform,+ left: pasteRect?.startX,+ top: pasteRect?.startY,+ };++ return {+ transform: newTransform,+ sheetTransform: transformToDrawingPosition(newTransform, selectionRenderService) ?? sheetTransform,+ };+ },});- if (!copyRect || !pasteRect) {- return { redos: [], undos: [] };- }+ }++ private _generateMutations(drawings: ISheetDrawing[], payload: {+ unitId: string;+ subUnitId: string;+ getTransform: (transform: ISheetDrawing['transform'], sheetTransform: ISheetDrawing['sheetTransform']) => {+ transform: ISheetDrawing['transform'];+ sheetTransform: ISheetDrawing['sheetTransform'];+ };+ isCut: boolean;+ }) {+ const {+ unitId,+ subUnitId,+ getTransform,+ isCut,+ } = payload;+const redos: IMutationInfo[] = [];const undos: IMutationInfo[] = [];- const leftOffset = pasteRect.startX - copyRect.startX;- const topOffset = pasteRect.startY - copyRect.startY;- const rowOffset = pasteRow - copyRow;- const columnOffset = pasteCol - copyCol;- const isCut = copyInfo.copyType === COPY_TYPE.CUT;- const { _sheetDrawingService } = this;++ const { _drawingService } = this;+drawings.forEach((drawing) => {const { transform, sheetTransform } = drawing;if (!transform) {return;}-+ const transformContext = getTransform(transform, sheetTransform);const drawingObject: Partial<ISheetDrawing> = {...drawing,unitId,subUnitId,drawingId: isCut ? drawing.drawingId : Tools.generateRandomId(),- transform: {- ...transform,- left: transform.left! + leftOffset,- top: transform.top! + topOffset,- },- sheetTransform: {- to: { ...sheetTransform.to, row: sheetTransform.to.row + rowOffset, column: sheetTransform.to.column + columnOffset },- from: { ...sheetTransform.from, row: sheetTransform.from.row + rowOffset, column: sheetTransform.from.column + columnOffset },- },+ transform: transformContext.transform,+ sheetTransform: transformContext.sheetTransform,};if (isCut) {- const { undo, redo, objects } = _sheetDrawingService.getBatchUpdateOp([drawingObject] as ISheetDrawing[]) as IDrawingJsonUndo1;+ const { undo, redo, objects } = _drawingService.getBatchUpdateOp([drawingObject] as ISheetDrawing[]) as IDrawingJsonUndo1;redos.push({id: SetDrawingApplyMutation.id,params: {@@ -209,15 +361,109 @@ export class SheetsDrawingCopyPasteController extends Disposable {},});} else {- const { undo, redo, objects } = _sheetDrawingService.getBatchAddOp([drawingObject] as ISheetDrawing[]) as IDrawingJsonUndo1;+ const { undo, redo, objects } = _drawingService.getBatchAddOp([drawingObject] as ISheetDrawing[]) as IDrawingJsonUndo1;redos.push({ id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.INSERT } });undos.push({ id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.REMOVE } });}});- return {- redos,- undos,- };+ return { redos, undos };+ }++ // eslint-disable-next-line max-lines-per-function+ private _generateRangeDrawingsPasteMutations(+ pasteContext: {+ unitId: string;+ subUnitId: string;+ pasteRange: IDiscreteRange;+ pasteType: IPasteHookValueType;+ },+ copyContext: {+ copyType: COPY_TYPE;+ copyRange?: IDiscreteRange;+ }+ ) {+ const {+ unitId,+ subUnitId,+ pasteType,+ pasteRange,+ } = pasteContext;++ const {+ copyRange,+ copyType,+ } = copyContext;++ if (specialPastes.includes(pasteType)) {+ return { redos: [], undos: [] };+ }++ const skeletonManagerService = this._renderManagerService.getRenderById(unitId)?.with(SheetSkeletonManagerService);++ if (!skeletonManagerService || !this._copyInfo) {+ return { redos: [], undos: [] };+ }++ const { drawings } = this._copyInfo;++ if (!copyRange) {+ return this._generateSingleDrawingPasteMutations({+ pasteTo: { unitId, subUnitId, range: discreteRangeToRange(pasteRange) as unknown as IDiscreteRange },+ pasteType,+ }, copyType);+ }++ const { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyRange, pasteRange]);+ const { row: copyRow, col: copyCol } = mapFunc(vCopyRange.startRow, vCopyRange.startColumn);+ const { row: pasteRow, col: pasteCol } = mapFunc(vPastedRange.startRow, vPastedRange.startColumn);++ const copyRect = skeletonManagerService.attachRangeWithCoord({+ startRow: copyRow,+ endRow: copyRow,+ startColumn: copyCol,+ endColumn: copyCol,+ });+ const pasteRect = skeletonManagerService.attachRangeWithCoord({+ startRow: pasteRow,+ endRow: pasteRow,+ startColumn: pasteCol,+ endColumn: pasteCol,+ });++ if (!copyRect || !pasteRect || !this._copyInfo) {+ return { redos: [], undos: [] };+ }++ const leftOffset = pasteRect.startX - copyRect.startX;+ const topOffset = pasteRect.startY - copyRect.startY;+ const rowOffset = pasteRow - copyRow;+ const columnOffset = pasteCol - copyCol;++ return this._generateMutations(drawings, {+ unitId,+ subUnitId,+ getTransform: (transform, sheetTransform) => ({+ transform: {+ ...transform,+ left: (transform?.left ?? 0) + leftOffset,+ top: (transform?.top ?? 0) + topOffset,+ },+ sheetTransform: {+ ...sheetTransform,+ to: {+ ...sheetTransform.to,+ row: sheetTransform.to.row + rowOffset,+ column: sheetTransform.to.column + columnOffset,+ },+ from: {+ ...sheetTransform.from,+ row: sheetTransform.from.row + rowOffset,+ column: sheetTransform.from.column + columnOffset,+ },+ },+ }),+ isCut: copyType === COPY_TYPE.CUT,+ });}}diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.tsindex 8afd9e669b..dcfd3c2362 100644--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing-update.controller.ts@@ -16,6 +16,7 @@import type { IAccessor, IRange, Nullable, Workbook } from '@univerjs/core';import type { IImageData, IImageIoServiceParam } from '@univerjs/drawing';+import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';import type { ISheetLocationBase, WorkbookSelectionModel } from '@univerjs/sheets';import type { ISheetDrawing, ISheetDrawingPosition } from '@univerjs/sheets-drawing';import type { IInsertDrawingCommandParams, ISetDrawingCommandParams } from '../commands/commands/interfaces';@@ -24,7 +25,7 @@ import { BooleanNumber, BuildTextUtils, createDocumentModelWithStyle, Disposableimport { MessageType } from '@univerjs/design';import { docDrawingPositionToTransform } from '@univerjs/docs-ui';import { DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_ALLOW_SIZE, DRAWING_IMAGE_COUNT_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, DRAWING_IMAGE_WIDTH_LIMIT, getImageSize, IDrawingManagerService, IImageIoService, ImageUploadStatusType, SetDrawingSelectedOperation } from '@univerjs/drawing';-import { type IRenderContext, IRenderManagerService, type IRenderModule } from '@univerjs/engine-render';+import { IRenderManagerService } from '@univerjs/engine-render';import { SetRangeValuesCommand, SheetsSelectionsService } from '@univerjs/sheets';import { ISheetDrawingService } from '@univerjs/sheets-drawing';import { attachRangeWithCoord, ISheetSelectionRenderService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';@@ -136,7 +137,7 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderMreturn false;}- files.forEach(async (file) => await this._insertFloatImage(file));+ files.forEach(async (file) => await this.insertFloatImageByFile(file));return true;}@@ -153,7 +154,7 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderMreturn false;}- private async _insertFloatImage(file: File) {+ async insertFloatImageByFile(file: File) {let imageParam: Nullable<IImageIoServiceParam>;try {@@ -214,7 +215,7 @@ export class SheetDrawingUpdateController extends Disposable implements IRenderMsheetTransform,};- this._commandService.executeCommand(InsertSheetDrawingCommand.id, {+ return this._commandService.executeCommand(InsertSheetDrawingCommand.id, {unitId,drawings: [sheetDrawingParam],} as IInsertDrawingCommandParams);diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing.controller.tsindex 049370e33c..54628fd28e 100644--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing.controller.ts+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing.controller.ts@@ -15,14 +15,17 @@*/import { Disposable, ICommandService, Inject } from '@univerjs/core';-import { AddImageSingle } from '@univerjs/icons';+import { IDrawingManagerService } from '@univerjs/drawing';+import { AddImageSingle } from '@univerjs/icons';+import { SheetsSelectionsService } from '@univerjs/sheets';import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';import { DeleteDrawingsCommand } from '../commands/commands/delete-drawings.command';import { GroupSheetDrawingCommand } from '../commands/commands/group-sheet-drawing.command';import { InsertCellImageCommand, InsertFloatImageCommand } from '../commands/commands/insert-image.command';import { InsertSheetDrawingCommand } from '../commands/commands/insert-sheet-drawing.command';import { MoveDrawingsCommand } from '../commands/commands/move-drawings.command';+import { RemoveSheetDrawingCommand } from '../commands/commands/remove-sheet-drawing.command';import { SetDrawingArrangeCommand } from '../commands/commands/set-drawing-arrange.command';import { SetSheetDrawingCommand } from '../commands/commands/set-sheet-drawing.command';@@ -41,7 +44,9 @@ export class SheetDrawingUIController extends Disposable {@Inject(ComponentManager) private readonly _componentManager: ComponentManager,@IMenuManagerService private readonly _menuManagerService: IMenuManagerService,@ICommandService private readonly _commandService: ICommandService,- @IShortcutService private readonly _shortcutService: IShortcutService+ @IShortcutService private readonly _shortcutService: IShortcutService,+ @IDrawingManagerService private readonly _drawingManagerService: IDrawingManagerService,+ @Inject(SheetsSelectionsService) private readonly _sheetsSelectionsService: SheetsSelectionsService) {super();diff --git a/packages/sheets-drawing/src/index.ts b/packages/sheets-drawing/src/index.tsindex 7b53198cd0..0da2d585e9 100644--- a/packages/sheets-drawing/src/index.ts+++ b/packages/sheets-drawing/src/index.ts@@ -20,7 +20,5 @@ export { SHEET_DRAWING_PLUGIN } from './controllers/sheet-drawing.controller';export type { IFloatDomData, ISheetDrawing, ISheetDrawingPosition, ISheetFloatDom, ISheetImage } from './services/sheet-drawing.service';// #region - all commands-export { DrawingApplyType, type ISetDrawingApplyMutationParams, SetDrawingApplyMutation } from './commands/mutations/set-drawing-apply.mutation';-// #endregiondiff --git a/packages/sheets-filter-ui/src/controllers/sheets-filter-ui-desktop.controller.ts b/packages/sheets-filter-ui/src/controllers/sheets-filter-ui-desktop.controller.tsindex e69eed557e..dea188e0b9 100644--- a/packages/sheets-filter-ui/src/controllers/sheets-filter-ui-desktop.controller.ts+++ b/packages/sheets-filter-ui/src/controllers/sheets-filter-ui-desktop.controller.ts@@ -29,8 +29,8 @@ import { ChangeFilterByOperation, CloseFilterPanelOperation, FILTER_PANEL_OPENEDimport { SheetsFilterPanelService } from '../services/sheets-filter-panel.service';import { FilterPanel } from '../views/components/SheetsFilterPanel';import { menuSchema } from './menu.schema';-import { SmartToggleFilterShortcut } from './sheets-filter.shortcut';import { SheetsFilterUIMobileController } from './sheets-filter-ui-mobile.controller';+import { SmartToggleFilterShortcut } from './sheets-filter.shortcut';export const FILTER_PANEL_POPUP_KEY = 'FILTER_PANEL_POPUP';diff --git a/packages/sheets-ui/src/commands/commands/clipboard.command.ts b/packages/sheets-ui/src/commands/commands/clipboard.command.tsindex 0c772a0cc1..922f9312ee 100644--- a/packages/sheets-ui/src/commands/commands/clipboard.command.ts+++ b/packages/sheets-ui/src/commands/commands/clipboard.command.ts@@ -56,6 +56,7 @@ export interface ISheetPasteParams {export interface ISheetPasteByShortKeyParams {htmlContent?: string;textContent?: string;+ files?: File[];}export const SheetPasteCommand: IMultiCommand = {@@ -88,8 +89,8 @@ export const SheetPasteShortKeyCommand: ICommand = {type: CommandType.COMMAND,handler: async (accessor: IAccessor, params: ISheetPasteByShortKeyParams) => {const clipboardService = accessor.get(ISheetClipboardService);- const { htmlContent, textContent } = params;- clipboardService.legacyPaste(htmlContent, textContent);+ const { htmlContent, textContent, files } = params;+ clipboardService.legacyPaste(htmlContent, textContent, files);return true;},diff --git a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.tsindex a45005d85a..89db54a0dc 100644--- a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts+++ b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts@@ -61,16 +61,19 @@ import {isFormulaString,IUniverInstanceService,LocaleService,+ObjectMatrix,+RxDisposable,Tools,UniverInstanceType,} from '@univerjs/core';import { MessageType } from '@univerjs/design';-import { DocSelectionRenderService } from '@univerjs/docs-ui';+import { DocSelectionRenderService } from '@univerjs/docs-ui';import { IRenderManagerService } from '@univerjs/engine-render';+import {InsertColMutation,InsertRowMutation,@@ -162,7 +165,9 @@ export class SheetClipboardController extends RxDisposable {const clipboardEvent = config!.event as ClipboardEvent;const htmlContent = clipboardEvent.clipboardData?.getData('text/html');const textContent = clipboardEvent.clipboardData?.getData('text/plain');- this._commandService.executeCommand(SheetPasteShortKeyCommand.id, { htmlContent, textContent });+ const files = this._resolveClipboardFiles(clipboardEvent.clipboardData);++ this._commandService.executeCommand(SheetPasteShortKeyCommand.id, { htmlContent, textContent, files });});};@@ -185,6 +190,18 @@ export class SheetClipboardController extends RxDisposable {});}+ private _resolveClipboardFiles(clipboardData: DataTransfer | null) {+ if (!clipboardData) {+ return;+ }++ const files = Array.from(clipboardData.items)+ .map((item) => item.kind === 'file' ? item.getAsFile() : undefined)+ .filter(Boolean) as File[];++ return files.length > 0 ? files : undefined;+ }+private _init(): void {// register sheet clipboard commands[SheetCopyCommand, SheetCutCommand, SheetPasteCommand].forEach((command) =>diff --git a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts b/packages/sheets-ui/src/services/clipboard/clipboard.service.tsindex b66aad935a..d38a508cd3 100644--- a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts+++ b/packages/sheets-ui/src/services/clipboard/clipboard.service.ts@@ -15,7 +15,8 @@*/import type {- ICellData, ICellDataWithSpanAndDisplay, IDisposable,+ ICellData,+ ICellDataWithSpanAndDisplay, IDisposable,IMutationInfo,IRange,Nullable, Workbook, Worksheet,@@ -51,22 +52,23 @@ import {Tools,UniverInstanceType,} from '@univerjs/core';-import { IRenderManagerService } from '@univerjs/engine-render';+import {getPrimaryForRange,SetSelectionsOperation,SetWorksheetActiveOperation,- SheetsSelectionsService,-} from '@univerjs/sheets';-import { HTML_CLIPBOARD_MIME_TYPE, IClipboardInterfaceService, INotificationService, IPlatformService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE } from '@univerjs/ui';++ SheetsSelectionsService } from '@univerjs/sheets';+import { FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FILE_PNG_CLIPBOARD_MIME_TYPE, HTML_CLIPBOARD_MIME_TYPE, IClipboardInterfaceService, imageMimeTypeSet, INotificationService, IPlatformService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE } from '@univerjs/ui';+import { BehaviorSubject, Subject } from 'rxjs';import { rangeToDiscreteRange, virtualizeDiscreteRanges } from '../../controllers/utils/range-tools';import { IMarkSelectionService } from '../mark-selection/mark-selection.service';import { SheetSkeletonManagerService } from '../sheet-skeleton-manager.service';import { createCopyPasteSelectionStyle } from '../utils/selection-util';-import { CopyContentCache, extractId, genId } from './copy-content-cache';+import { CopyContentCache, extractId, genId } from './copy-content-cache';import { HtmlToUSMService } from './html-to-usm/converter';import { LarkPastePlugin } from './html-to-usm/paste-plugins/plugin-lark';import { UniverPastePlugin } from './html-to-usm/paste-plugins/plugin-univer';@@ -85,6 +87,13 @@ export const PREDEFINED_HOOK_NAME = {SPECIAL_PASTE_FORMULA: 'special-paste-formula',} as const;+const IMAGE_MIME_TO_EXTENSION = {+ [FILE_PNG_CLIPBOARD_MIME_TYPE]: 'png',+ [FILE__JPEG_CLIPBOARD_MIME_TYPE]: 'jpg',+ [FILE__WEBP_CLIPBOARD_MIME_TYPE]: 'webp',+ [FILE__BMP_CLIPBOARD_MIME_TYPE]: 'bmp',+} as const;+interface ICopyContent {copyId: string;plain: string;@@ -111,7 +120,8 @@ export interface ISheetClipboardService {copy(): Promise<boolean>;cut(): Promise<boolean>;paste(item: ClipboardItem, pasteType?: string): Promise<boolean>; // get content from a ClipboardItem and paste it.- legacyPaste(html?: string, text?: string): Promise<boolean>; // paste a HTML string or plain text directly.+ legacyPaste(html?: string, text?: string, files?: File[]): Promise<boolean>; // paste a HTML string or plain text directly.+rePasteWithPasteType(type: IPasteHookKeyType): boolean;disposePasteOptionsCache(): void;@@ -182,10 +192,8 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard}generateCopyContent(workbookId: string, worksheetId: string, range: IRange): Nullable<ICopyContent> {- const hooks = this._clipboardHooks;- hooks.forEach((h) => h.onBeforeCopy?.(workbookId, worksheetId, range));- const copyContent = this._generateCopyContent(workbookId, worksheetId, range, hooks);- hooks.forEach((h) => h.onAfterCopy?.());+ const copyContent = this._generateCopyContent(workbookId, worksheetId, range, this._clipboardHooks);+return copyContent;}@@ -200,8 +208,14 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardif (!worksheet) {return false;}+ const hooks = this._clipboardHooks;+ const workbookId = workbook.getUnitId();+ const worksheetId = worksheet.getSheetId();++ hooks.forEach((h) => h.onBeforeCopy?.(workbookId, worksheetId, selection.range, copyType));+ const copyContent = this.generateCopyContent(workbookId, worksheetId, selection.range);+ hooks.forEach((h) => h.onAfterCopy?.());- const copyContent = this.generateCopyContent(workbook.getUnitId(), worksheet.getSheetId(), selection.range);if (!copyContent) {return false;}@@ -245,6 +259,22 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard? await item.getType(HTML_CLIPBOARD_MIME_TYPE).then((blob) => blob && blob.text()): '';+ const imageIndex = types.findIndex((type) => imageMimeTypeSet.has(type));++ if (imageIndex !== -1) {+ const imageMimeType = types[imageIndex]!;+ const imageBlob = await item.getType(imageMimeType);++ if (imageBlob) {+ const file = new File(+ [imageBlob],+ `clipboard-image.${IMAGE_MIME_TO_EXTENSION[imageMimeType as keyof typeof IMAGE_MIME_TO_EXTENSION]}`,+ { type: imageMimeType });++ return this._pasteFiles([file], pasteType);+ }+ }+if (html) {// Firstly see if the html content is from Excelif (this._platformService.isWindows && (await clipboardItemIsFromExcel(html))) {@@ -269,8 +299,10 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardreturn false;}- legacyPaste(html?: string, text?: string): Promise<boolean> {- if (html) {+ legacyPaste(html?: string, text?: string, files?: File[]): Promise<boolean> {+ if (files) {+ return this._pasteFiles(files, PREDEFINED_HOOK_NAME.DEFAULT_PASTE);+ } else if (html) {return this._pasteHTML(html, PREDEFINED_HOOK_NAME.DEFAULT_PASTE);} else if (text) {// Converts text with tabs and newlines into an HTML table@@ -279,9 +311,11 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard} else {return this._pastePlainText(text, PREDEFINED_HOOK_NAME.DEFAULT_PASTE);}+ } else {+ return this._pasteUnrecognized();}- return Promise.resolve(false);+ // return Promise.resolve(false);}rePasteWithPasteType(type: IPasteHookKeyType): boolean {@@ -419,7 +453,14 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardthis._clipboardHooks$.next(this._clipboardHooks);}- private async _pastePlainText(text: string, pasteType: IPasteHookValueType): Promise<boolean> {+ private async _executePaste(generateMutations: (hook: ISheetClipboardHook, payload: {+ unitId: string;+ subUnitId: string;+ range: IDiscreteRange;+ }) => undefined | ({+ undos: IMutationInfo[];+ redos: IMutationInfo[];+ })): Promise<boolean> {const target = this._getPastingTarget();if (!target.subUnitId || !target.selection) {return false;@@ -447,17 +488,12 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardconst redoMutationsInfo: IMutationInfo[] = [];const undoMutationsInfo: IMutationInfo[] = [];enabledHooks.forEach((h) => {- const contentReturn = h.onPastePlainText?.(- {- unitId,- subUnitId,- range,- },- text,- {- pasteType,- }- );+ const contentReturn = generateMutations(h, {+ unitId,+ subUnitId,+ range,+ });+if (contentReturn) {redoMutationsInfo.push(...contentReturn.redos);undoMutationsInfo.push(...contentReturn.undos);@@ -476,6 +512,24 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardreturn result;}+ private async _pasteFiles(files: File[], pasteType: IPasteHookValueType): Promise<boolean> {+ return this._executePaste((h, payload) => {+ return h.onPasteFiles?.(payload, files, { pasteType });+ });+ }++ private async _pastePlainText(text: string, pasteType: IPasteHookValueType): Promise<boolean> {+ return this._executePaste((h, payload) => {+ return h.onPastePlainText?.(payload, text, { pasteType });+ });+ }++ private _pasteUnrecognized() {+ return this._executePaste((h, payload) => {+ return h.onPasteUnrecognized?.(payload);+ });+ }+private async _pasteHTML(html: string, pasteType: IPasteHookValueType): Promise<boolean> {const copyId = extractId(html);if (copyId && this._copyContentCache.get(copyId)) {diff --git a/packages/sheets-ui/src/services/clipboard/type.ts b/packages/sheets-ui/src/services/clipboard/type.tsindex 3227bc5d61..89da6e21b4 100644--- a/packages/sheets-ui/src/services/clipboard/type.ts+++ b/packages/sheets-ui/src/services/clipboard/type.ts@@ -102,7 +102,6 @@ export interface ISheetClipboardHook {* The priority of the hook. The higher the priority, the earlier the hook would be called.*/priority?: number;-/*** The callback would be called after the clipboard service has decided what region need to be copied.* Features could use this hook to build copying cache or any other pre-copy jobs.@@ -110,8 +109,7 @@ export interface ISheetClipboardHook {* @param subUnitId* @param range*/- onBeforeCopy?(unitId: string, subUnitId: string, range: IRange): void;-+ onBeforeCopy?(unitId: string, subUnitId: string, range: IRange, copyType: COPY_TYPE): void;/*** Properties that would be appended to the td element.*@@ -236,6 +234,14 @@ export interface ISheetClipboardHook {undos: IMutationInfo[];redos: IMutationInfo[];};+ onPasteFiles?(pasteTo: ISheetDiscreteRangeLocation, files: File[], payload: ICopyPastePayload): {+ undos: IMutationInfo[];+ redos: IMutationInfo[];+ };+ onPasteUnrecognized?(pasteTo: ISheetDiscreteRangeLocation): {+ undos: IMutationInfo[];+ redos: IMutationInfo[];+ };/*** Would be called after paste content has been written into Univer.diff --git a/packages/sheets/src/services/permission/range-permission/range-protection.ref-range.ts b/packages/sheets/src/services/permission/range-permission/range-protection.ref-range.tsindex f84f43bfce..32199e95bf 100644--- a/packages/sheets/src/services/permission/range-permission/range-protection.ref-range.ts+++ b/packages/sheets/src/services/permission/range-permission/range-protection.ref-range.ts@@ -48,9 +48,9 @@ import { InsertColMutation, InsertRowMutation } from '../../../commands/mutationimport { type IMoveRowsMutationParams, MoveColsMutation, MoveRowsMutation } from '../../../commands/mutations/move-rows-cols.mutation';import { RemoveColMutation, RemoveRowMutation } from '../../../commands/mutations/remove-row-col.mutation';import { SetRangeProtectionMutation } from '../../../commands/mutations/set-range-protection.mutation';-import { RangeProtectionCache } from '../../../model/range-protection.cache';import { RangeProtectionRenderModel } from '../../../model/range-protection-render.model';import { RangeProtectionRuleModel } from '../../../model/range-protection-rule.model';+import { RangeProtectionCache } from '../../../model/range-protection.cache';import { RefRangeService } from '../../../services/ref-range/ref-range.service';import { SheetInterceptorService } from '../../sheet-interceptor/sheet-interceptor.service';diff --git a/packages/sheets/src/services/permission/range-permission/range-protection.service.ts b/packages/sheets/src/services/permission/range-permission/range-protection.service.tsindex 4ca6f58364..0a3c4b7c6c 100644--- a/packages/sheets/src/services/permission/range-permission/range-protection.service.ts+++ b/packages/sheets/src/services/permission/range-permission/range-protection.service.ts@@ -19,9 +19,9 @@ import type { UnitAction } from '@univerjs/protocol';import type { IObjectModel } from '../../../model/range-protection-rule.model';import { Disposable, Inject, IPermissionService, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';import { UnitObject, UniverType } from '@univerjs/protocol';-import { RangeProtectionCache } from '../../../model/range-protection.cache';-import { RangeProtectionRuleModel } from '../../../model/range-protection-rule.model';++import { RangeProtectionCache } from '../../../model/range-protection.cache';import { baseProtectionActions, getAllRangePermissionPoint } from './util';const PLUGIN_NAME = 'SHEET_RANGE_PROTECTION_PLUGIN';diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.tsindex 57c96c386e..a1feb4fedf 100644--- a/packages/ui/src/index.ts+++ b/packages/ui/src/index.ts@@ -53,6 +53,7 @@ export {FILE_SVG_XML_CLIPBOARD_MIME_TYPE,HTML_CLIPBOARD_MIME_TYPE,IClipboardInterfaceService,+ imageMimeTypeSet,PLAIN_TEXT_CLIPBOARD_MIME_TYPE,} from './services/clipboard/clipboard-interface.service';export { IConfirmService } from './services/confirm/confirm.service';diff --git a/packages/ui/src/mobile-ui-plugin.ts b/packages/ui/src/mobile-ui-plugin.tsindex 24c64db754..24b302a329 100644--- a/packages/ui/src/mobile-ui-plugin.ts+++ b/packages/ui/src/mobile-ui-plugin.ts@@ -22,8 +22,8 @@ import { ComponentManager } from './common/component-manager';import { ZIndexManager } from './common/z-index-manager';import { ErrorController } from './controllers/error/error.controller';import { SharedController } from './controllers/shared-shortcut.controller';-import { IUIController } from './controllers/ui/ui.controller';import { MobileUIController } from './controllers/ui/ui-mobile.controller';+import { IUIController } from './controllers/ui/ui.controller';import { DesktopBeforeCloseService, IBeforeCloseService } from './services/before-close/before-close.service';import { BrowserClipboardService, IClipboardInterfaceService } from './services/clipboard/clipboard-interface.service';import { IConfirmService } from './services/confirm/confirm.service';@@ -44,8 +44,8 @@ import { INotificationService } from './services/notification/notification.serviimport { IUIPartsService, UIPartsService } from './services/parts/parts.service';import { IPlatformService, PlatformService } from './services/platform/platform.service';import { CanvasPopupService, ICanvasPopupService } from './services/popup/canvas-popup.service';-import { IShortcutService, ShortcutService } from './services/shortcut/shortcut.service';import { ShortcutPanelService } from './services/shortcut/shortcut-panel.service';+import { IShortcutService, ShortcutService } from './services/shortcut/shortcut.service';import { DesktopSidebarService } from './services/sidebar/desktop-sidebar.service';import { ISidebarService } from './services/sidebar/sidebar.service';import { DesktopZenZoneService } from './services/zen-zone/desktop-zen-zone.service';diff --git a/packages/ui/src/services/clipboard/clipboard-interface.service.ts b/packages/ui/src/services/clipboard/clipboard-interface.service.tsindex 3716c09ed8..a5b9d26bf1 100644--- a/packages/ui/src/services/clipboard/clipboard-interface.service.ts+++ b/packages/ui/src/services/clipboard/clipboard-interface.service.ts@@ -27,6 +27,13 @@ export const FILE__BMP_CLIPBOARD_MIME_TYPE = 'image/bmp';export const FILE__WEBP_CLIPBOARD_MIME_TYPE = 'image/webp';export const FILE_SVG_XML_CLIPBOARD_MIME_TYPE = 'image/svg+xml';+export const imageMimeTypeSet = new Set([+ FILE__BMP_CLIPBOARD_MIME_TYPE,+ FILE__JPEG_CLIPBOARD_MIME_TYPE,+ FILE__WEBP_CLIPBOARD_MIME_TYPE,+ FILE_PNG_CLIPBOARD_MIME_TYPE,+]);+/*** This interface provides an interface to access system's clipboard.*/