@univerjs/sheets-drawing-ui 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,10 +13,10 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { ICommandService, RxDisposable } from '@univerjs/core';
16
+ import { ICommandService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
17
17
  import { IDrawingManagerService } from '@univerjs/drawing';
18
18
  import { IRenderManagerService } from '@univerjs/engine-render';
19
- import { SheetSkeletonService } from '@univerjs/sheets';
19
+ import { SheetPermissionCheckController, SheetSkeletonService } from '@univerjs/sheets';
20
20
  import { ISheetClipboardService } from '@univerjs/sheets-ui';
21
21
  import { IClipboardInterfaceService } from '@univerjs/ui';
22
22
  export declare class SheetsDrawingCopyPasteController extends RxDisposable {
@@ -26,12 +26,16 @@ export declare class SheetsDrawingCopyPasteController extends RxDisposable {
26
26
  private readonly _drawingService;
27
27
  private readonly _clipboardInterfaceService;
28
28
  private readonly _commandService;
29
+ private readonly _instanceService;
30
+ private readonly _permissions;
31
+ dispose(): void;
29
32
  private _copyInfo;
30
- constructor(_sheetClipboardService: ISheetClipboardService, _renderManagerService: IRenderManagerService, _sheetSkeletonService: SheetSkeletonService, _drawingService: IDrawingManagerService, _clipboardInterfaceService: IClipboardInterfaceService, _commandService: ICommandService);
33
+ constructor(_sheetClipboardService: ISheetClipboardService, _renderManagerService: IRenderManagerService, _sheetSkeletonService: SheetSkeletonService, _drawingService: IDrawingManagerService, _clipboardInterfaceService: IClipboardInterfaceService, _commandService: ICommandService, _instanceService: IUniverInstanceService, _permissions: SheetPermissionCheckController);
31
34
  private get _focusedDrawings();
32
35
  private _initCopyPaste;
33
36
  private _createDrawingsCopyInfoByRange;
34
37
  private _generateSingleDrawingPasteMutations;
38
+ private _generateChartSheetImagePasteMutations;
35
39
  private _generateMutations;
36
40
  private _generateRangeDrawingsPasteMutations;
37
41
  }
@@ -33,5 +33,7 @@ export declare class SheetDrawingPermissionController extends Disposable {
33
33
  private _handleDrawingEditableFalse;
34
34
  private _initViewPermissionChange;
35
35
  private _initEditPermissionChange;
36
+ private _initChartSheetCommandPermissionCheck;
37
+ private _checkChartSheetEditPermission;
36
38
  private _initCommandPermissionCheck;
37
39
  }
@@ -20,7 +20,6 @@ import { Disposable, ICommandService, IContextService, IImageIoService, Injector
20
20
  import { IDrawingManagerService } from '@univerjs/drawing';
21
21
  import { SheetInterceptorService, SheetSkeletonService, SheetsSelectionsService } from '@univerjs/sheets';
22
22
  import { ISheetDrawingService } from '@univerjs/sheets-drawing';
23
- import { ISheetSelectionRenderService } from '@univerjs/sheets-ui';
24
23
  import { ILocalFileService, IMessageService } from '@univerjs/ui';
25
24
  /**
26
25
  * Get the size of the drawing within the cell
@@ -39,7 +38,6 @@ export declare class SheetDrawingUpdateController extends Disposable implements
39
38
  private readonly _context;
40
39
  private readonly _commandService;
41
40
  private readonly _sheetInterceptorService;
42
- private readonly _selectionRenderService;
43
41
  private readonly _imageIoService;
44
42
  private readonly _fileOpenerService;
45
43
  private readonly _sheetDrawingService;
@@ -51,14 +49,19 @@ export declare class SheetDrawingUpdateController extends Disposable implements
51
49
  private readonly _injector;
52
50
  private readonly _urlImageService;
53
51
  private readonly _workbookSelections;
54
- constructor(_context: IRenderContext<Workbook>, _commandService: ICommandService, _sheetInterceptorService: SheetInterceptorService, _selectionRenderService: ISheetSelectionRenderService, _imageIoService: IImageIoService, _fileOpenerService: ILocalFileService, _sheetDrawingService: ISheetDrawingService, _drawingManagerService: IDrawingManagerService, _contextService: IContextService, _messageService: IMessageService, _localeService: LocaleService, selectionManagerService: SheetsSelectionsService, _sheetSkeletonService: SheetSkeletonService, _injector: Injector, _urlImageService: IURLImageService);
52
+ constructor(_context: IRenderContext<Workbook>, _commandService: ICommandService, _sheetInterceptorService: SheetInterceptorService, _imageIoService: IImageIoService, _fileOpenerService: ILocalFileService, _sheetDrawingService: ISheetDrawingService, _drawingManagerService: IDrawingManagerService, _contextService: IContextService, _messageService: IMessageService, _localeService: LocaleService, selectionManagerService: SheetsSelectionsService, _sheetSkeletonService: SheetSkeletonService, _injector: Injector, _urlImageService: IURLImageService);
55
53
  insertFloatImage(): Promise<boolean>;
56
54
  insertCellImage(): Promise<boolean>;
57
55
  setWorksheetBackgroundImage(files?: Nullable<File[]>): Promise<boolean>;
58
56
  insertCellImageByFile(file: File, location?: ISheetLocationBase): Promise<boolean>;
59
- insertFloatImageByFile(file: File): Promise<boolean | undefined>;
57
+ insertFloatImageByFile(file: File): Promise<boolean>;
58
+ private _insertFloatImage;
60
59
  private _insertCellImage;
61
60
  insertCellImageByUrl(url: string, location?: ISheetLocationBase): Promise<boolean>;
61
+ private _captureImageTarget;
62
+ private _captureCellImageTarget;
63
+ private _isImageTargetValid;
64
+ private _getChartImageBounds;
62
65
  private _getUnitInfo;
63
66
  private _getImagePosition;
64
67
  private _updateOrderListener;
@@ -17,8 +17,8 @@ import type { ITransformState, Nullable } from '@univerjs/core';
17
17
  import type { ICanvasFloatDom, ICanvasFloatDomInfo, IDOMAnchor } from '@univerjs/sheets-drawing-ui';
18
18
  import type { IFComponentKey } from '@univerjs/sheets-ui/facade';
19
19
  import type { FRange } from '@univerjs/sheets/facade';
20
- import type { ISaveCellImagesOptions } from './f-range';
21
20
  import { FWorksheet } from '@univerjs/sheets/facade';
21
+ import type { ISaveCellImagesOptions } from './f-range';
22
22
  export interface IFICanvasFloatDom extends Omit<ICanvasFloatDom, 'componentKey' | 'unitId' | 'subUnitId'>, IFComponentKey {
23
23
  }
24
24
  export interface IFCanvasFloatDomResult extends Omit<ICanvasFloatDom, 'componentKey' | 'unitId' | 'subUnitId' | 'initPosition'>, IFComponentKey, Pick<ICanvasFloatDomInfo, 'id'> {
@@ -63,6 +63,10 @@ export interface IFWorksheetDrawingUIMixin {
63
63
  getAllFloatDoms(): IFCanvasFloatDomResult[];
64
64
  /**
65
65
  * Update float dom position and properties
66
+ *
67
+ * For multiple floating DOM elements on this worksheet, prefer {@link FWorksheet.batchUpdateFloatDoms}
68
+ * with an array of `{ id, config }` updates instead of calling this method in a loop.
69
+ *
66
70
  * @param {string} id - float dom id
67
71
  * @param {Partial<IFCanvasFloatDomResult>} config - new float dom config
68
72
  * @returns {FWorksheet} The worksheet instance for chaining
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import type { IDisposable, IPosition, IRange, ITransformState, Nullable, Serializable, Worksheet } from '@univerjs/core';
17
17
  import type { BaseObject, IBoundRectNoAngle, IRectProps, Scene, SpreadsheetSkeleton } from '@univerjs/engine-render';
18
- import type { IFloatDomData } from '@univerjs/sheets-drawing';
18
+ import type { IFloatDomData, ISheetDrawing } from '@univerjs/sheets-drawing';
19
19
  import type { IFloatDom, IFloatDomLayout } from '@univerjs/ui';
20
20
  import { Disposable, DrawingTypeEnum, ICommandService, IUniverInstanceService, LifecycleService } from '@univerjs/core';
21
21
  import { IDrawingManagerService } from '@univerjs/drawing';
@@ -279,8 +279,12 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
279
279
  subUnitId: string;
280
280
  id: string;
281
281
  }>;
282
+ private readonly _moveTransformConstraints;
283
+ registerMoveTransformConstraint(constraint: (drawing: ISheetDrawing, transform: ITransformState) => ITransformState): IDisposable;
284
+ private readonly _floatDomMoveDisposables;
282
285
  private readonly _renderObjectFactories;
283
286
  constructor(_renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _drawingManagerService: IDrawingManagerService, _canvasFloatDomService: CanvasFloatDomService, _sheetDrawingService: ISheetDrawingService, _lifecycleService: LifecycleService, _canvasFloatDomPreviewService?: CanvasFloatDomPreviewService | undefined);
287
+ dispose(): void;
284
288
  /**
285
289
  * Register a factory that creates the canvas-side render object for a sheet
286
290
  * float-dom drawing type. The latest registered factory wins; disposing the
@@ -289,8 +293,10 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
289
293
  */
290
294
  registerRenderObjectFactory(drawingType: DrawingTypeEnum, factory: SheetFloatDomRenderObjectFactory): IDisposable;
291
295
  private _createRenderObject;
296
+ private _forwardWheelToCanvas;
292
297
  private _bindScrollEvent;
293
298
  getFloatDomInfo(id: string): ICanvasFloatDomInfo | undefined;
299
+ updateFloatDomEventOptions(id: string, eventOptions: IFloatDom['eventOptions']): void;
294
300
  getFloatDomsBySubUnitId(unitId: string, subUnitId: string): ICanvasFloatDomInfo[];
295
301
  private static _disposeExternalFloatDom;
296
302
  private _createFloatDomDisposable;
@@ -311,6 +317,7 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
311
317
  private _drawingAddListener;
312
318
  private _scrollUpdateListener;
313
319
  private _bindFloatDomScroll;
320
+ private _calculateFloatDomPosition;
314
321
  updateFloatDomProps(unitId: string, subUnitId: string, id: string, props: Record<string, any>): void;
315
322
  private _getObjectIncludingGroup;
316
323
  private _getChildObjectFromGroup;
@@ -19,6 +19,7 @@ import { SHEET_EXTENSION_TYPE, SheetExtension } from '@univerjs/engine-render';
19
19
  export declare const WORKSHEET_BACKGROUND_IMAGE_EXTENSION_KEY = "WorksheetBackgroundImageExtension";
20
20
  export declare class WorksheetBackgroundImageExtension extends SheetExtension {
21
21
  private readonly _requestRender;
22
+ readonly viewportCacheReusable: boolean;
22
23
  uKey: string;
23
24
  type: SHEET_EXTENSION_TYPE;
24
25
  private readonly _imageCache;