@univerjs/sheets-drawing-ui 0.5.2 → 0.5.3-experimental.20250106-4af1f4e

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.
package/lib/cjs/facade.js CHANGED
@@ -1 +1 @@
1
- "use strict";var j=Object.defineProperty;var T=(e,t,i)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var R=(e,t,i)=>T(e,typeof t!="symbol"?t+"":t,i);const a=require("@univerjs/core"),B=require("@univerjs/drawing"),C=require("@univerjs/engine-render"),c=require("@univerjs/sheets-drawing-ui"),w=require("@univerjs/sheets-ui"),u=require("@univerjs/sheets-drawing"),U=require("@univerjs/sheets-ui/facade"),y=require("@univerjs/sheets/facade"),E=require("@univerjs/ui");var P=Object.defineProperty,W=Object.getOwnPropertyDescriptor,O=(e,t,i,n)=>{for(var r=n>1?void 0:n?W(t,i):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(r=(n?s(t,i,r):s(r))||r);return n&&r&&P(t,i,r),r},p=(e,t)=>(i,n)=>t(i,n,e);function x(e,t){const{from:i,to:n,flipY:r=!1,flipX:o=!1,angle:s=0,skewX:d=0,skewY:g=0}=e.sheetTransform,{column:m,columnOffset:I,row:_,rowOffset:l}=i,S=w.convertPositionSheetOverGridToAbsolute(e.unitId,e.subUnitId,{from:i,to:n},t),{left:b,top:D,width:v,height:k}=S;return{...e,column:m,columnOffset:I,row:_,rowOffset:l,width:v,height:k,flipY:r,flipX:o,angle:s,skewX:d,skewY:g}}function M(e,t,i){const{column:n,columnOffset:r,row:o,rowOffset:s,flipY:d=!1,flipX:g=!1,angle:m=0,skewX:I=0,skewY:_=0,width:l,height:S}=e,b=w.convertPositionCellToSheetOverGrid(e.unitId,e.subUnitId,{column:n,columnOffset:r,row:o,rowOffset:s},l,S,t,i),{sheetTransform:D,transform:v}=b;return{...e,sheetTransform:{...D,flipY:d,flipX:g,angle:m,skewX:I,skewY:_},transform:{...v,flipY:d,flipX:g,angle:m,skewX:I,skewY:_}}}let f=class{constructor(e,t,i){R(this,"_image");this._injector=i,this._image={drawingId:a.generateRandomId(6),drawingType:a.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:a.ImageSourceType.BASE64,source:"",unitId:e,subUnitId:t,column:0,columnOffset:0,row:0,rowOffset:0,width:0,height:0}}setImage(e){const i=this._injector.get(C.IRenderManagerService).getRenderById(e.unitId);if(!i)throw new Error(`Render Unit with unitId ${e.unitId} not found`);const n=i.with(w.SheetSkeletonManagerService);return this._image=x(e,n),this}setSource(e,t){const i=t!=null?t:a.ImageSourceType.URL;return this._image.source=e,this._image.imageSourceType=i,this}getsource(){return this._image.source}getSourceType(){return this._image.imageSourceType}setColumn(e){return this._image.column=e,this}setRow(e){return this._image.row=e,this}setColumnOffset(e){return this._image.columnOffset=e,this}setRowOffset(e){return this._image.rowOffset=e,this}setWidth(e){return this._image.width=e,this}setHeight(e){return this._image.height=e,this}setAnchorType(e){return this._image.anchorType=e,this}setCropTop(e){return this._initializeSrcRect(),this._image.srcRect.top=e,this}setCropLeft(e){return this._initializeSrcRect(),this._image.srcRect.left=e,this}setCropBottom(e){return this._initializeSrcRect(),this._image.srcRect.bottom=e,this}setCropRight(e){return this._initializeSrcRect(),this._image.srcRect.right=e,this}_initializeSrcRect(){this._image.srcRect==null&&(this._image.srcRect={top:0,left:0,bottom:0,right:0})}setRotate(e){return this._image.angle=e,this}setUnitId(e){return this._image.unitId=e,this}setSubUnitId(e){return this._image.subUnitId=e,this}async build(){const t=this._injector.get(C.IRenderManagerService).getRenderById(this._image.unitId);if(!t)throw new Error(`Render Unit with unitId ${this._image.unitId} not found`);const i=t.with(w.ISheetSelectionRenderService),n=t.with(w.SheetSkeletonManagerService);if(this._image.width===0||this._image.height===0){const r=await B.getImageSize(this._image.source),o=r.width,s=r.height;this._image.width===0&&(this._image.width=o),this._image.height===0&&(this._image.height=s)}return M(this._image,i,n)}};f=O([p(2,a.Inject(a.Injector))],f);let h=class extends a.FBase{constructor(e,t,i){super(),this._image=e,this._commandService=t,this._injector=i}getId(){return this._image.drawingId}getType(){return this._image.drawingType}remove(){return this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}toBuilder(){const e=this._injector.createInstance(f);return e.setImage(this._image),e}setSource(e,t){const i=t!=null?t:a.ImageSourceType.URL;return this._image.source=e,this._image.imageSourceType=i,this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}setPosition(e,t,i,n){const r=this.toBuilder();return r.setColumn(t),r.setRow(e),i!=null&&r.setRowOffset(i),n!=null&&r.setColumnOffset(n),this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[r.build()]})}setSize(e,t){const i=this.toBuilder();return i.setWidth(e),i.setHeight(t),this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[i.build()]})}setCrop(e,t,i,n){return this._image.srcRect==null&&(this._image.srcRect={top:0,left:0,bottom:0,right:0}),e!=null&&(this._image.srcRect.top=e),t!=null&&(this._image.srcRect.left=t),i!=null&&(this._image.srcRect.bottom=i),n!=null&&(this._image.srcRect.right=n),this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}setRotate(e){return this._image.sheetTransform.angle=e,this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}};h=O([p(1,a.ICommandService),p(2,a.Inject(a.Injector))],h);class F extends y.FWorksheet{addFloatDomToPosition(t,i){const n=this._workbook.getUnitId(),r=this._worksheet.getSheetId(),{key:o,disposableCollection:s}=U.transformComponentKey(t,this._injector.get(E.ComponentManager)),g=this._injector.get(c.SheetCanvasFloatDomManagerService).addFloatDomToPosition({...t,componentKey:o,unitId:n,subUnitId:r},i);return g?(s.add(g.dispose),{id:g.id,dispose:()=>{s.dispose(),g.dispose()}}):(s.dispose(),null)}async insertImage(t,i,n,r,o){const s=this.newOverGridImage();if(typeof t=="string")s.setSource(t);else{const m=await t.getBlob().getDataAsString();s.setSource(m,a.ImageSourceType.BASE64)}i!==void 0?s.setColumn(i):s.setColumn(0),n!==void 0?s.setRow(n):s.setRow(0),r!==void 0?s.setColumnOffset(r):s.setColumnOffset(0),o!==void 0?s.setRowOffset(o):s.setRowOffset(0);const d=await s.build();return this._commandService.syncExecuteCommand(c.InsertSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:[d]})}insertImages(t){const i=t.map(n=>(n.unitId=this._fWorkbook.getId(),n.subUnitId=this.getSheetId(),n));this._commandService.syncExecuteCommand(c.InsertSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:i})}deleteImages(t){const i=t.map(n=>({unitId:this._fWorkbook.getId(),drawingId:n.getId(),subUnitId:this.getSheetId(),drawingType:n.getType()}));this._commandService.syncExecuteCommand(c.RemoveSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:i})}getImages(){const i=this._injector.get(u.ISheetDrawingService).getDrawingData(this._fWorkbook.getId(),this.getSheetId()),n=[];for(const r in i){const o=i[r];n.push(this._injector.createInstance(h,o))}return n}getImageById(t){const n=this._injector.get(u.ISheetDrawingService).getDrawingByParam({unitId:this._fWorkbook.getId(),subUnitId:this.getSheetId(),drawingId:t});return n?this._injector.createInstance(h,n):null}getActiveImages(){const i=this._injector.get(u.ISheetDrawingService).getFocusDrawings(),n=[];for(const r in i){const o=i[r];n.push(this._injector.createInstance(h,o))}return n}updateImages(t){this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:t})}onImageInserted(t){const i=this._injector.get(u.ISheetDrawingService);i.add$.subscribe(n=>{const r=n.map(o=>this._injector.createInstance(h,i.getDrawingByParam(o)));t(r)})}onImageDeleted(t){const i=this._injector.get(u.ISheetDrawingService);i.remove$.subscribe(n=>{const r=n.map(o=>this._injector.createInstance(h,i.getDrawingByParam(o)));t(r)})}onImageChanged(t){const i=this._injector.get(u.ISheetDrawingService);i.update$.subscribe(n=>{const r=n.map(o=>this._injector.createInstance(h,i.getDrawingByParam(o)));t(r)})}newOverGridImage(){const t=this._fWorkbook.getId(),i=this.getSheetId();return this._injector.createInstance(f,t,i)}}y.FWorksheet.extend(F);
1
+ "use strict";var j=Object.defineProperty;var T=(e,t,i)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var R=(e,t,i)=>T(e,typeof t!="symbol"?t+"":t,i);const a=require("@univerjs/core"),B=require("@univerjs/drawing"),C=require("@univerjs/engine-render"),c=require("@univerjs/sheets-drawing-ui"),w=require("@univerjs/sheets-ui"),u=require("@univerjs/sheets-drawing"),U=require("@univerjs/sheets-ui/facade"),y=require("@univerjs/sheets/facade"),E=require("@univerjs/ui");var P=Object.defineProperty,W=Object.getOwnPropertyDescriptor,O=(e,t,i,n)=>{for(var r=n>1?void 0:n?W(t,i):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(r=(n?s(t,i,r):s(r))||r);return n&&r&&P(t,i,r),r},p=(e,t)=>(i,n)=>t(i,n,e);function x(e,t){const{from:i,to:n,flipY:r=!1,flipX:o=!1,angle:s=0,skewX:d=0,skewY:h=0}=e.sheetTransform,{column:m,columnOffset:l,row:I,rowOffset:f}=i,S=w.convertPositionSheetOverGridToAbsolute(e.unitId,e.subUnitId,{from:i,to:n},t),{left:b,top:D,width:v,height:k}=S;return{...e,column:m,columnOffset:l,row:I,rowOffset:f,width:v,height:k,flipY:r,flipX:o,angle:s,skewX:d,skewY:h}}function M(e,t,i){const{column:n,columnOffset:r,row:o,rowOffset:s,flipY:d=!1,flipX:h=!1,angle:m=0,skewX:l=0,skewY:I=0,width:f,height:S}=e,b=w.convertPositionCellToSheetOverGrid(e.unitId,e.subUnitId,{column:n,columnOffset:r,row:o,rowOffset:s},f,S,t,i),{sheetTransform:D,transform:v}=b;return{...e,sheetTransform:{...D,flipY:d,flipX:h,angle:m,skewX:l,skewY:I},transform:{...v,flipY:d,flipX:h,angle:m,skewX:l,skewY:I}}}let _=class{constructor(e,t,i){R(this,"_image");this._injector=i,this._image={drawingId:a.generateRandomId(6),drawingType:a.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:a.ImageSourceType.BASE64,source:"",unitId:e,subUnitId:t,column:0,columnOffset:0,row:0,rowOffset:0,width:0,height:0}}setImage(e){const i=this._injector.get(C.IRenderManagerService).getRenderById(e.unitId);if(!i)throw new Error(`Render Unit with unitId ${e.unitId} not found`);const n=i.with(w.SheetSkeletonManagerService);return this._image=x(e,n),this}setSource(e,t){const i=t!=null?t:a.ImageSourceType.URL;return this._image.source=e,this._image.imageSourceType=i,this}getsource(){return this._image.source}getSourceType(){return this._image.imageSourceType}setColumn(e){return this._image.column=e,this}setRow(e){return this._image.row=e,this}setColumnOffset(e){return this._image.columnOffset=e,this}setRowOffset(e){return this._image.rowOffset=e,this}setWidth(e){return this._image.width=e,this}setHeight(e){return this._image.height=e,this}setAnchorType(e){return this._image.anchorType=e,this}setCropTop(e){return this._initializeSrcRect(),this._image.srcRect.top=e,this}setCropLeft(e){return this._initializeSrcRect(),this._image.srcRect.left=e,this}setCropBottom(e){return this._initializeSrcRect(),this._image.srcRect.bottom=e,this}setCropRight(e){return this._initializeSrcRect(),this._image.srcRect.right=e,this}_initializeSrcRect(){this._image.srcRect==null&&(this._image.srcRect={top:0,left:0,bottom:0,right:0})}setRotate(e){return this._image.angle=e,this}setUnitId(e){return this._image.unitId=e,this}setSubUnitId(e){return this._image.subUnitId=e,this}async build(){const t=this._injector.get(C.IRenderManagerService).getRenderById(this._image.unitId);if(!t)throw new Error(`Render Unit with unitId ${this._image.unitId} not found`);const i=t.with(w.ISheetSelectionRenderService),n=t.with(w.SheetSkeletonManagerService);if(this._image.width===0||this._image.height===0){const r=await B.getImageSize(this._image.source),o=r.width,s=r.height;this._image.width===0&&(this._image.width=o),this._image.height===0&&(this._image.height=s)}return M(this._image,i,n)}};_=O([p(2,a.Inject(a.Injector))],_);let g=class extends a.FBase{constructor(e,t,i){super(),this._image=e,this._commandService=t,this._injector=i}getId(){return this._image.drawingId}getType(){return this._image.drawingType}remove(){return this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}toBuilder(){const e=this._injector.createInstance(_);return e.setImage(this._image),e}setSource(e,t){const i=t!=null?t:a.ImageSourceType.URL;return this._image.source=e,this._image.imageSourceType=i,this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}setPosition(e,t,i,n){const r=this.toBuilder();return r.setColumn(t),r.setRow(e),i!=null&&r.setRowOffset(i),n!=null&&r.setColumnOffset(n),this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[r.build()]})}setSize(e,t){const i=this.toBuilder();return i.setWidth(e),i.setHeight(t),this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[i.build()]})}setCrop(e,t,i,n){return this._image.srcRect==null&&(this._image.srcRect={top:0,left:0,bottom:0,right:0}),e!=null&&(this._image.srcRect.top=e),t!=null&&(this._image.srcRect.left=t),i!=null&&(this._image.srcRect.bottom=i),n!=null&&(this._image.srcRect.right=n),this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}setRotate(e){return this._image.sheetTransform.angle=e,this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}};g=O([p(1,a.ICommandService),p(2,a.Inject(a.Injector))],g);class F extends y.FWorksheet{addFloatDomToPosition(t,i){const n=this._workbook.getUnitId(),r=this._worksheet.getSheetId(),{key:o,disposableCollection:s}=U.transformComponentKey(t,this._injector.get(E.ComponentManager)),h=this._injector.get(c.SheetCanvasFloatDomManagerService).addFloatDomToPosition({...t,componentKey:o,unitId:n,subUnitId:r},i);return h?(s.add(h.dispose),{id:h.id,dispose:()=>{s.dispose(),h.dispose()}}):(s.dispose(),null)}async insertImage(t,i,n,r,o){const s=this.newOverGridImage();if(typeof t=="string")s.setSource(t);else{const m=await t.getBlob().getDataAsString();s.setSource(m,a.ImageSourceType.BASE64)}i!==void 0?s.setColumn(i):s.setColumn(0),n!==void 0?s.setRow(n):s.setRow(0),r!==void 0?s.setColumnOffset(r):s.setColumnOffset(0),o!==void 0?s.setRowOffset(o):s.setRowOffset(0);const d=await s.build();return this._commandService.syncExecuteCommand(c.InsertSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:[d]})}insertImages(t){const i=t.map(n=>(n.unitId=this._fWorkbook.getId(),n.subUnitId=this.getSheetId(),n));return this._commandService.syncExecuteCommand(c.InsertSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:i}),this}deleteImages(t){const i=t.map(n=>({unitId:this._fWorkbook.getId(),drawingId:n.getId(),subUnitId:this.getSheetId(),drawingType:n.getType()}));return this._commandService.syncExecuteCommand(c.RemoveSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:i}),this}getImages(){const i=this._injector.get(u.ISheetDrawingService).getDrawingData(this._fWorkbook.getId(),this.getSheetId()),n=[];for(const r in i){const o=i[r];n.push(this._injector.createInstance(g,o))}return n}getImageById(t){const n=this._injector.get(u.ISheetDrawingService).getDrawingByParam({unitId:this._fWorkbook.getId(),subUnitId:this.getSheetId(),drawingId:t});return n?this._injector.createInstance(g,n):null}getActiveImages(){const i=this._injector.get(u.ISheetDrawingService).getFocusDrawings(),n=[];for(const r in i){const o=i[r];n.push(this._injector.createInstance(g,o))}return n}updateImages(t){return this._commandService.syncExecuteCommand(c.SetSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:t}),this}onImageInserted(t){const i=this._injector.get(u.ISheetDrawingService);return a.toDisposable(i.add$.subscribe(n=>{const r=n.map(o=>this._injector.createInstance(g,i.getDrawingByParam(o)));t(r)}))}onImageDeleted(t){const i=this._injector.get(u.ISheetDrawingService);return a.toDisposable(i.remove$.subscribe(n=>{const r=n.map(o=>this._injector.createInstance(g,i.getDrawingByParam(o)));t(r)}))}onImageChanged(t){const i=this._injector.get(u.ISheetDrawingService);return a.toDisposable(i.update$.subscribe(n=>{const r=n.map(o=>this._injector.createInstance(g,i.getDrawingByParam(o)));t(r)}))}newOverGridImage(){const t=this._fWorkbook.getId(),i=this.getSheetId();return this._injector.createInstance(_,t,i)}}y.FWorksheet.extend(F);
package/lib/es/facade.js CHANGED
@@ -1,27 +1,27 @@
1
- var E = Object.defineProperty;
2
- var P = (e, t, i) => t in e ? E(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
- var R = (e, t, i) => P(e, typeof t != "symbol" ? t + "" : t, i);
4
- import { Inject as O, Injector as k, ICommandService as U, generateRandomId as W, DrawingTypeEnum as x, ImageSourceType as _, FBase as F } from "@univerjs/core";
5
- import { getImageSize as M } from "@univerjs/drawing";
6
- import { IRenderManagerService as C } from "@univerjs/engine-render";
7
- import { SetSheetDrawingCommand as h, SheetCanvasFloatDomManagerService as z, InsertSheetDrawingCommand as D, RemoveSheetDrawingCommand as A } from "@univerjs/sheets-drawing-ui";
8
- import { SheetSkeletonManagerService as y, ISheetSelectionRenderService as G, convertPositionSheetOverGridToAbsolute as $, convertPositionCellToSheetOverGrid as L } from "@univerjs/sheets-ui";
1
+ var P = Object.defineProperty;
2
+ var U = (e, t, i) => t in e ? P(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
+ var C = (e, t, i) => U(e, typeof t != "symbol" ? t + "" : t, i);
4
+ import { Inject as k, Injector as j, ICommandService as W, generateRandomId as x, DrawingTypeEnum as F, ImageSourceType as _, FBase as M, toDisposable as v } from "@univerjs/core";
5
+ import { getImageSize as z } from "@univerjs/drawing";
6
+ import { IRenderManagerService as D } from "@univerjs/engine-render";
7
+ import { SetSheetDrawingCommand as h, SheetCanvasFloatDomManagerService as A, InsertSheetDrawingCommand as y, RemoveSheetDrawingCommand as G } from "@univerjs/sheets-drawing-ui";
8
+ import { SheetSkeletonManagerService as O, ISheetSelectionRenderService as $, convertPositionSheetOverGridToAbsolute as L, convertPositionCellToSheetOverGrid as X } from "@univerjs/sheets-ui";
9
9
  import { ISheetDrawingService as g } from "@univerjs/sheets-drawing";
10
- import { transformComponentKey as X } from "@univerjs/sheets-ui/facade";
11
- import { FWorksheet as j } from "@univerjs/sheets/facade";
12
- import { ComponentManager as Y } from "@univerjs/ui";
13
- var H = Object.defineProperty, K = Object.getOwnPropertyDescriptor, T = (e, t, i, s) => {
14
- for (var n = s > 1 ? void 0 : s ? K(t, i) : t, o = e.length - 1, r; o >= 0; o--)
15
- (r = e[o]) && (n = (s ? r(t, i, n) : r(n)) || n);
16
- return s && n && H(t, i, n), n;
17
- }, v = (e, t) => (i, s) => t(i, s, e);
18
- function V(e, t) {
19
- const { from: i, to: s, flipY: n = !1, flipX: o = !1, angle: r = 0, skewX: m = 0, skewY: a = 0 } = e.sheetTransform, { column: d, columnOffset: u, row: f, rowOffset: I } = i, w = $(
10
+ import { transformComponentKey as Y } from "@univerjs/sheets-ui/facade";
11
+ import { FWorksheet as T } from "@univerjs/sheets/facade";
12
+ import { ComponentManager as H } from "@univerjs/ui";
13
+ var K = Object.defineProperty, V = Object.getOwnPropertyDescriptor, B = (e, t, i, r) => {
14
+ for (var n = r > 1 ? void 0 : r ? V(t, i) : t, o = e.length - 1, s; o >= 0; o--)
15
+ (s = e[o]) && (n = (r ? s(t, i, n) : s(n)) || n);
16
+ return r && n && K(t, i, n), n;
17
+ }, p = (e, t) => (i, r) => t(i, r, e);
18
+ function N(e, t) {
19
+ const { from: i, to: r, flipY: n = !1, flipX: o = !1, angle: s = 0, skewX: m = 0, skewY: a = 0 } = e.sheetTransform, { column: d, columnOffset: u, row: f, rowOffset: I } = i, w = L(
20
20
  e.unitId,
21
21
  e.subUnitId,
22
- { from: i, to: s },
22
+ { from: i, to: r },
23
23
  t
24
- ), { left: p, top: b, width: S, height: B } = w;
24
+ ), { left: b, top: R, width: S, height: E } = w;
25
25
  return {
26
26
  ...e,
27
27
  column: d,
@@ -29,28 +29,28 @@ function V(e, t) {
29
29
  row: f,
30
30
  rowOffset: I,
31
31
  width: S,
32
- height: B,
32
+ height: E,
33
33
  flipY: n,
34
34
  flipX: o,
35
- angle: r,
35
+ angle: s,
36
36
  skewX: m,
37
37
  skewY: a
38
38
  };
39
39
  }
40
- function N(e, t, i) {
41
- const { column: s, columnOffset: n, row: o, rowOffset: r, flipY: m = !1, flipX: a = !1, angle: d = 0, skewX: u = 0, skewY: f = 0, width: I, height: w } = e, p = L(
40
+ function q(e, t, i) {
41
+ const { column: r, columnOffset: n, row: o, rowOffset: s, flipY: m = !1, flipX: a = !1, angle: d = 0, skewX: u = 0, skewY: f = 0, width: I, height: w } = e, b = X(
42
42
  e.unitId,
43
43
  e.subUnitId,
44
- { column: s, columnOffset: n, row: o, rowOffset: r },
44
+ { column: r, columnOffset: n, row: o, rowOffset: s },
45
45
  I,
46
46
  w,
47
47
  t,
48
48
  i
49
- ), { sheetTransform: b, transform: S } = p;
49
+ ), { sheetTransform: R, transform: S } = b;
50
50
  return {
51
51
  ...e,
52
52
  sheetTransform: {
53
- ...b,
53
+ ...R,
54
54
  flipY: m,
55
55
  flipX: a,
56
56
  angle: d,
@@ -69,10 +69,10 @@ function N(e, t, i) {
69
69
  }
70
70
  let l = class {
71
71
  constructor(e, t, i) {
72
- R(this, "_image");
72
+ C(this, "_image");
73
73
  this._injector = i, this._image = {
74
- drawingId: W(6),
75
- drawingType: x.DRAWING_IMAGE,
74
+ drawingId: x(6),
75
+ drawingType: F.DRAWING_IMAGE,
76
76
  imageSourceType: _.BASE64,
77
77
  source: "",
78
78
  unitId: e,
@@ -86,11 +86,11 @@ let l = class {
86
86
  };
87
87
  }
88
88
  setImage(e) {
89
- const i = this._injector.get(C).getRenderById(e.unitId);
89
+ const i = this._injector.get(D).getRenderById(e.unitId);
90
90
  if (!i)
91
91
  throw new Error(`Render Unit with unitId ${e.unitId} not found`);
92
- const s = i.with(y);
93
- return this._image = V(e, s), this;
92
+ const r = i.with(O);
93
+ return this._image = N(e, r), this;
94
94
  }
95
95
  setSource(e, t) {
96
96
  const i = t != null ? t : _.URL;
@@ -162,21 +162,21 @@ let l = class {
162
162
  return this._image.subUnitId = e, this;
163
163
  }
164
164
  async build() {
165
- const t = this._injector.get(C).getRenderById(this._image.unitId);
165
+ const t = this._injector.get(D).getRenderById(this._image.unitId);
166
166
  if (!t)
167
167
  throw new Error(`Render Unit with unitId ${this._image.unitId} not found`);
168
- const i = t.with(G), s = t.with(y);
168
+ const i = t.with($), r = t.with(O);
169
169
  if (this._image.width === 0 || this._image.height === 0) {
170
- const n = await M(this._image.source), o = n.width, r = n.height;
171
- this._image.width === 0 && (this._image.width = o), this._image.height === 0 && (this._image.height = r);
170
+ const n = await z(this._image.source), o = n.width, s = n.height;
171
+ this._image.width === 0 && (this._image.width = o), this._image.height === 0 && (this._image.height = s);
172
172
  }
173
- return N(this._image, i, s);
173
+ return q(this._image, i, r);
174
174
  }
175
175
  };
176
- l = T([
177
- v(2, O(k))
176
+ l = B([
177
+ p(2, k(j))
178
178
  ], l);
179
- let c = class extends F {
179
+ let c = class extends M {
180
180
  constructor(e, t, i) {
181
181
  super(), this._image = e, this._commandService = t, this._injector = i;
182
182
  }
@@ -223,9 +223,9 @@ let c = class extends F {
223
223
  const i = t != null ? t : _.URL;
224
224
  return this._image.source = e, this._image.imageSourceType = i, this._commandService.syncExecuteCommand(h.id, { unitId: this._image.unitId, drawings: [this._image] });
225
225
  }
226
- setPosition(e, t, i, s) {
226
+ setPosition(e, t, i, r) {
227
227
  const n = this.toBuilder();
228
- return n.setColumn(t), n.setRow(e), i != null && n.setRowOffset(i), s != null && n.setColumnOffset(s), this._commandService.syncExecuteCommand(h.id, { unitId: this._image.unitId, drawings: [n.build()] });
228
+ return n.setColumn(t), n.setRow(e), i != null && n.setRowOffset(i), r != null && n.setColumnOffset(r), this._commandService.syncExecuteCommand(h.id, { unitId: this._image.unitId, drawings: [n.build()] });
229
229
  }
230
230
  /**
231
231
  * Set the size of the image
@@ -253,13 +253,13 @@ let c = class extends F {
253
253
  * console.log('Set crop state is ', image.setCrop(0, 0, 0, 0));
254
254
  * ```
255
255
  */
256
- setCrop(e, t, i, s) {
256
+ setCrop(e, t, i, r) {
257
257
  return this._image.srcRect == null && (this._image.srcRect = {
258
258
  top: 0,
259
259
  left: 0,
260
260
  bottom: 0,
261
261
  right: 0
262
- }), e != null && (this._image.srcRect.top = e), t != null && (this._image.srcRect.left = t), i != null && (this._image.srcRect.bottom = i), s != null && (this._image.srcRect.right = s), this._commandService.syncExecuteCommand(h.id, { unitId: this._image.unitId, drawings: [this._image] });
262
+ }), e != null && (this._image.srcRect.top = e), t != null && (this._image.srcRect.left = t), i != null && (this._image.srcRect.bottom = i), r != null && (this._image.srcRect.right = r), this._commandService.syncExecuteCommand(h.id, { unitId: this._image.unitId, drawings: [this._image] });
263
263
  }
264
264
  // setPresetGeometry(prstGeom: PresetGeometryType): boolean {
265
265
  // this._image.prstGeom = prstGeom;
@@ -274,98 +274,98 @@ let c = class extends F {
274
274
  return this._image.sheetTransform.angle = e, this._commandService.syncExecuteCommand(h.id, { unitId: this._image.unitId, drawings: [this._image] });
275
275
  }
276
276
  };
277
- c = T([
278
- v(1, U),
279
- v(2, O(k))
277
+ c = B([
278
+ p(1, W),
279
+ p(2, k(j))
280
280
  ], c);
281
- class q extends j {
281
+ class J extends T {
282
282
  addFloatDomToPosition(t, i) {
283
- const s = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), { key: o, disposableCollection: r } = X(t, this._injector.get(Y)), a = this._injector.get(z).addFloatDomToPosition({ ...t, componentKey: o, unitId: s, subUnitId: n }, i);
284
- return a ? (r.add(a.dispose), {
283
+ const r = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), { key: o, disposableCollection: s } = Y(t, this._injector.get(H)), a = this._injector.get(A).addFloatDomToPosition({ ...t, componentKey: o, unitId: r, subUnitId: n }, i);
284
+ return a ? (s.add(a.dispose), {
285
285
  id: a.id,
286
286
  dispose: () => {
287
- r.dispose(), a.dispose();
287
+ s.dispose(), a.dispose();
288
288
  }
289
- }) : (r.dispose(), null);
289
+ }) : (s.dispose(), null);
290
290
  }
291
- async insertImage(t, i, s, n, o) {
292
- const r = this.newOverGridImage();
291
+ async insertImage(t, i, r, n, o) {
292
+ const s = this.newOverGridImage();
293
293
  if (typeof t == "string")
294
- r.setSource(t);
294
+ s.setSource(t);
295
295
  else {
296
296
  const d = await t.getBlob().getDataAsString();
297
- r.setSource(d, _.BASE64);
297
+ s.setSource(d, _.BASE64);
298
298
  }
299
- i !== void 0 ? r.setColumn(i) : r.setColumn(0), s !== void 0 ? r.setRow(s) : r.setRow(0), n !== void 0 ? r.setColumnOffset(n) : r.setColumnOffset(0), o !== void 0 ? r.setRowOffset(o) : r.setRowOffset(0);
300
- const m = await r.build();
301
- return this._commandService.syncExecuteCommand(D.id, { unitId: this._fWorkbook.getId(), drawings: [m] });
299
+ i !== void 0 ? s.setColumn(i) : s.setColumn(0), r !== void 0 ? s.setRow(r) : s.setRow(0), n !== void 0 ? s.setColumnOffset(n) : s.setColumnOffset(0), o !== void 0 ? s.setRowOffset(o) : s.setRowOffset(0);
300
+ const m = await s.build();
301
+ return this._commandService.syncExecuteCommand(y.id, { unitId: this._fWorkbook.getId(), drawings: [m] });
302
302
  }
303
303
  insertImages(t) {
304
- const i = t.map((s) => (s.unitId = this._fWorkbook.getId(), s.subUnitId = this.getSheetId(), s));
305
- this._commandService.syncExecuteCommand(D.id, { unitId: this._fWorkbook.getId(), drawings: i });
304
+ const i = t.map((r) => (r.unitId = this._fWorkbook.getId(), r.subUnitId = this.getSheetId(), r));
305
+ return this._commandService.syncExecuteCommand(y.id, { unitId: this._fWorkbook.getId(), drawings: i }), this;
306
306
  }
307
307
  deleteImages(t) {
308
- const i = t.map((s) => ({
308
+ const i = t.map((r) => ({
309
309
  unitId: this._fWorkbook.getId(),
310
- drawingId: s.getId(),
310
+ drawingId: r.getId(),
311
311
  subUnitId: this.getSheetId(),
312
- drawingType: s.getType()
312
+ drawingType: r.getType()
313
313
  }));
314
- this._commandService.syncExecuteCommand(A.id, { unitId: this._fWorkbook.getId(), drawings: i });
314
+ return this._commandService.syncExecuteCommand(G.id, { unitId: this._fWorkbook.getId(), drawings: i }), this;
315
315
  }
316
316
  getImages() {
317
- const i = this._injector.get(g).getDrawingData(this._fWorkbook.getId(), this.getSheetId()), s = [];
317
+ const i = this._injector.get(g).getDrawingData(this._fWorkbook.getId(), this.getSheetId()), r = [];
318
318
  for (const n in i) {
319
319
  const o = i[n];
320
- s.push(this._injector.createInstance(c, o));
320
+ r.push(this._injector.createInstance(c, o));
321
321
  }
322
- return s;
322
+ return r;
323
323
  }
324
324
  getImageById(t) {
325
- const s = this._injector.get(g).getDrawingByParam({ unitId: this._fWorkbook.getId(), subUnitId: this.getSheetId(), drawingId: t });
326
- return s ? this._injector.createInstance(c, s) : null;
325
+ const r = this._injector.get(g).getDrawingByParam({ unitId: this._fWorkbook.getId(), subUnitId: this.getSheetId(), drawingId: t });
326
+ return r ? this._injector.createInstance(c, r) : null;
327
327
  }
328
328
  getActiveImages() {
329
- const i = this._injector.get(g).getFocusDrawings(), s = [];
329
+ const i = this._injector.get(g).getFocusDrawings(), r = [];
330
330
  for (const n in i) {
331
331
  const o = i[n];
332
- s.push(this._injector.createInstance(c, o));
332
+ r.push(this._injector.createInstance(c, o));
333
333
  }
334
- return s;
334
+ return r;
335
335
  }
336
336
  updateImages(t) {
337
- this._commandService.syncExecuteCommand(h.id, { unitId: this._fWorkbook.getId(), drawings: t });
337
+ return this._commandService.syncExecuteCommand(h.id, { unitId: this._fWorkbook.getId(), drawings: t }), this;
338
338
  }
339
339
  onImageInserted(t) {
340
340
  const i = this._injector.get(g);
341
- i.add$.subscribe((s) => {
342
- const n = s.map(
341
+ return v(i.add$.subscribe((r) => {
342
+ const n = r.map(
343
343
  (o) => this._injector.createInstance(c, i.getDrawingByParam(o))
344
344
  );
345
345
  t(n);
346
- });
346
+ }));
347
347
  }
348
348
  onImageDeleted(t) {
349
349
  const i = this._injector.get(g);
350
- i.remove$.subscribe((s) => {
351
- const n = s.map(
350
+ return v(i.remove$.subscribe((r) => {
351
+ const n = r.map(
352
352
  (o) => this._injector.createInstance(c, i.getDrawingByParam(o))
353
353
  );
354
354
  t(n);
355
- });
355
+ }));
356
356
  }
357
357
  onImageChanged(t) {
358
358
  const i = this._injector.get(g);
359
- i.update$.subscribe((s) => {
360
- const n = s.map(
359
+ return v(i.update$.subscribe((r) => {
360
+ const n = r.map(
361
361
  (o) => this._injector.createInstance(c, i.getDrawingByParam(o))
362
362
  );
363
363
  t(n);
364
- });
364
+ }));
365
365
  }
366
366
  newOverGridImage() {
367
367
  const t = this._fWorkbook.getId(), i = this.getSheetId();
368
368
  return this._injector.createInstance(l, t, i);
369
369
  }
370
370
  }
371
- j.extend(q);
371
+ T.extend(J);
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- *,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*{scrollbar-color:initial;scrollbar-width:initial}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.univer-upload-loading{position:absolute;height:100%;width:100%;text-align:center;background-color:rgba(var(--color-black),.5);z-index:1000;-webkit-user-select:none;-moz-user-select:none;user-select:none}.univer-upload-loading-body{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background-color:rgb(var(--color-white));padding:20px 40px;display:flex;align-items:center;justify-items:center;border-radius:var(--border-radius-lg)}.univer-upload-loading-body-animation{width:30px;height:30px;border:2px solid rgb(var(--color-black));border-top-color:transparent;border-radius:100%;animation:univer-UniverCircleAnimation infinite .75s linear}.univer-upload-loading-body-text{font-size:var(--font-size-xs);color:var(--color-black);padding:10px}@keyframes univer-UniverCircleAnimation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.univer-image-common-panel{text-align:center;padding:var(--padding-sm);font-size:var(--font-size-sm)}.univer-image-common-panel-grid{position:relative;width:100%}.univer-image-common-panel-border{border-top:1px solid rgb(var(--border-color));margin-top:20px}.univer-image-common-panel-title{color:rgb(var(--text-color-secondary));text-align:left}.univer-image-common-panel-subtitle{color:rgb(var(--text-color-primary));text-align:left}.univer-image-common-panel-row{position:relative;display:flex;justify-content:flex-start;align-items:flex-start;height:100%;margin-top:10px}.univer-image-common-panel-row-vertical{justify-content:center;align-items:center;height:36px}.univer-image-common-panel-column{width:100%}.univer-image-common-panel-column-center{display:flex;justify-content:center;align-items:center}.univer-image-common-panel-inline{display:flex;align-items:center;gap:var(--margin-xxs)}.univer-image-common-panel-span2{width:50%}.univer-image-common-panel-span3{width:33.33333333%}.univer-image-common-panel-input{width:90%}.univer-sheet-image-menu{position:absolute;height:100%;width:100%;text-align:center}.univer-sheet-image-menu-input{display:none}
1
+ .univer-upload-loading{position:absolute;height:100%;width:100%;text-align:center;background-color:rgba(var(--color-black),.5);z-index:1000;-webkit-user-select:none;-moz-user-select:none;user-select:none}.univer-upload-loading-body{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background-color:rgb(var(--color-white));padding:20px 40px;display:flex;align-items:center;justify-items:center;border-radius:var(--border-radius-lg)}.univer-upload-loading-body-animation{width:30px;height:30px;border:2px solid rgb(var(--color-black));border-top-color:transparent;border-radius:100%;animation:univer-UniverCircleAnimation infinite .75s linear}.univer-upload-loading-body-text{font-size:var(--font-size-xs);color:var(--color-black);padding:10px}@keyframes univer-UniverCircleAnimation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.univer-image-common-panel{text-align:center;padding:var(--padding-sm);font-size:var(--font-size-sm)}.univer-image-common-panel-grid{position:relative;width:100%}.univer-image-common-panel-border{border-top:1px solid rgb(var(--border-color));margin-top:20px}.univer-image-common-panel-title{color:rgb(var(--text-color-secondary));text-align:left}.univer-image-common-panel-subtitle{color:rgb(var(--text-color-primary));text-align:left}.univer-image-common-panel-row{position:relative;display:flex;justify-content:flex-start;align-items:flex-start;height:100%;margin-top:10px}.univer-image-common-panel-row-vertical{justify-content:center;align-items:center;height:36px}.univer-image-common-panel-column{width:100%}.univer-image-common-panel-column-center{display:flex;justify-content:center;align-items:center}.univer-image-common-panel-inline{display:flex;align-items:center;gap:var(--margin-xxs)}.univer-image-common-panel-span2{width:50%}.univer-image-common-panel-span3{width:33.33333333%}.univer-image-common-panel-input{width:90%}.univer-sheet-image-menu{position:absolute;height:100%;width:100%;text-align:center}.univer-sheet-image-menu-input{display:none}
@@ -1,4 +1,4 @@
1
- import { IFBlobSource, Nullable } from '@univerjs/core';
1
+ import { IDisposable, IFBlobSource, Nullable } from '@univerjs/core';
2
2
  import { ISheetImage } from '@univerjs/sheets-drawing';
3
3
  import { ICanvasFloatDom } from '@univerjs/sheets-drawing-ui';
4
4
  import { IFComponentKey } from '@univerjs/sheets-ui/facade';
@@ -8,7 +8,7 @@ export interface IFICanvasFloatDom extends Omit<ICanvasFloatDom, 'componentKey'
8
8
  }
9
9
  export interface IFWorksheetLegacy {
10
10
  /**
11
- * add a float dom to position
11
+ * Add a float dom to position.
12
12
  * @param layer float dom config
13
13
  * @param id float dom id, if not given will be auto generated
14
14
  * @returns float dom id and dispose function
@@ -50,21 +50,35 @@ export interface IFWorksheetLegacy {
50
50
  * const imageBuilder = activeSheet.newOverGridImage();
51
51
  * const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setWidth(500).setHeight(300).build();
52
52
  * activeSheet.insertImages([param]);
53
- *
54
- *
55
53
  * const image = activeSheet.getImageById(param.drawingId);
56
54
  * console.log(image);
57
-
58
55
  * setTimeout(async ()=>{
59
56
  * const builder = image.toBuilder();
60
57
  * const param = await builder.setHeight(50).setWidth(100).build();
61
58
  * activeSheet.updateImages([param]);
62
59
  * }, 4000);
63
60
  */
64
- insertImages(sheetImages: ISheetImage[]): void;
61
+ insertImages(sheetImages: ISheetImage[]): FWorksheet;
62
+ /**
63
+ * Get all images in current sheet.
64
+ * @returns FOverGridImage[]
65
+ * @example
66
+ * ```ts
67
+ * univerAPI.getActiveWorkbook().getActiveSheet().getImages();
68
+ * ```
69
+ */
65
70
  getImages(): FOverGridImage[];
71
+ /**
72
+ * Get image by drawing id
73
+ * @param id - The drawing id of the image
74
+ * @returns FOverGridImage | null
75
+ * @example
76
+ * ```ts
77
+ * univerAPI.getActiveWorkbook().getActiveSheet().getImageById('xxxx');
78
+ * ```
79
+ */
66
80
  getImageById(id: string): FOverGridImage | null;
67
- deleteImages(sheetImages: FOverGridImage[]): void;
81
+ deleteImages(sheetImages: FOverGridImage[]): FWorksheet;
68
82
  /**
69
83
  * Update images to the sheet
70
84
  * @param sheetImages The images to insert
@@ -76,29 +90,46 @@ export interface IFWorksheetLegacy {
76
90
  * const imageBuilder = activeSheet.newOverGridImage();
77
91
  * const param = await imageBuilder.setSource('https://avatars.githubusercontent.com/u/61444807?s=48&v=4').setColumn(5).setRow(5).setWidth(500).setHeight(300).build();
78
92
  * activeSheet.insertImages([param]);
79
- *
80
- *
81
93
  * const image = activeSheet.getImageById(param.drawingId);
82
94
  * console.log(image);
83
-
84
95
  * setTimeout(async ()=>{
85
96
  * const builder = image.toBuilder();
86
97
  * const param = await builder.setHeight(50).setWidth(100).build();
87
98
  * activeSheet.updateImages([param]);
88
99
  * }, 4000);
89
100
  */
90
- updateImages(sheetImages: ISheetImage[]): void;
101
+ updateImages(sheetImages: ISheetImage[]): FWorksheet;
102
+ /**
103
+ * Get all images in current sheet.
104
+ * @returns FOverGridImage[]
105
+ * @example
106
+ * ```ts
107
+ * univerAPI.getActiveWorkbook().getActiveSheet().getImages();
108
+ * ```
109
+ */
91
110
  getActiveImages(): FOverGridImage[];
92
- onImageInserted(callback: (images: FOverGridImage[]) => void): void;
93
- onImageDeleted(callback: (images: FOverGridImage[]) => void): void;
94
- onImageChanged(callback: (images: FOverGridImage[]) => void): void;
111
+ /**
112
+ * Hook when a image is inserted.
113
+ * @param {function(FOverGridImage[]: void)} callback - The callback function when a image is inserted.
114
+ */
115
+ onImageInserted(callback: (images: FOverGridImage[]) => void): IDisposable;
116
+ /**
117
+ * Hook when a image is deleted.
118
+ * @param {function(FOverGridImage[]: void)} callback - The callback function when a image is deleted.
119
+ */
120
+ onImageDeleted(callback: (images: FOverGridImage[]) => void): IDisposable;
121
+ /**
122
+ * Hook when a image is changed.
123
+ * @param {function(FOverGridImage[]: void)} callback - The callback function when a image is changed.
124
+ */
125
+ onImageChanged(callback: (images: FOverGridImage[]) => void): IDisposable;
95
126
  /**
96
127
  * Create a new over grid image builder.
97
- * @returns The builder
128
+ * @returns {FOverGridImageBuilder} The builder
98
129
  * @example
99
130
  * ```ts
100
131
  * // create a new over grid image builder.
101
- * const builder = UniverApi.newOverGridImage();
132
+ * const builder = univerAPI.newOverGridImage();
102
133
  * ```
103
134
  */
104
135
  newOverGridImage(): FOverGridImageBuilder;
@@ -109,15 +140,15 @@ export declare class FWorksheetLegacy extends FWorksheet implements IFWorksheetL
109
140
  dispose: () => void;
110
141
  }>;
111
142
  insertImage(url: IFBlobSource | string, column?: number, row?: number, offsetX?: number, offsetY?: number): Promise<boolean>;
112
- insertImages(sheetImages: ISheetImage[]): void;
113
- deleteImages(sheetImages: FOverGridImage[]): void;
143
+ insertImages(sheetImages: ISheetImage[]): FWorksheet;
144
+ deleteImages(sheetImages: FOverGridImage[]): FWorksheet;
114
145
  getImages(): FOverGridImage[];
115
146
  getImageById(id: string): FOverGridImage | null;
116
147
  getActiveImages(): FOverGridImage[];
117
- updateImages(sheetImages: ISheetImage[]): void;
118
- onImageInserted(callback: (images: FOverGridImage[]) => void): void;
119
- onImageDeleted(callback: (images: FOverGridImage[]) => void): void;
120
- onImageChanged(callback: (images: FOverGridImage[]) => void): void;
148
+ updateImages(sheetImages: ISheetImage[]): FWorksheet;
149
+ onImageInserted(callback: (images: FOverGridImage[]) => void): IDisposable;
150
+ onImageDeleted(callback: (images: FOverGridImage[]) => void): IDisposable;
151
+ onImageChanged(callback: (images: FOverGridImage[]) => void): IDisposable;
121
152
  newOverGridImage(): FOverGridImageBuilder;
122
153
  }
123
154
  declare module '@univerjs/sheets/facade' {
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(s,c){typeof exports=="object"&&typeof module<"u"?c(require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/sheets-drawing-ui"),require("@univerjs/sheets-ui"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-ui/facade"),require("@univerjs/sheets/facade"),require("@univerjs/ui")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/drawing","@univerjs/engine-render","@univerjs/sheets-drawing-ui","@univerjs/sheets-ui","@univerjs/sheets-drawing","@univerjs/sheets-ui/facade","@univerjs/sheets/facade","@univerjs/ui"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.UniverCore,s.UniverDrawing,s.UniverEngineRender,s.UniverSheetsDrawingUi,s.UniverSheetsUi,s.UniverSheetsDrawing,s.UniverSheetsUiFacade,s.UniverSheetsFacade,s.UniverUi))})(this,function(s,c,u,d,S,f,k,R,T){"use strict";var U=Object.defineProperty;var M=(s,c,u)=>c in s?U(s,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):s[c]=u;var O=(s,c,u)=>M(s,typeof c!="symbol"?c+"":c,u);var B=Object.defineProperty,E=Object.getOwnPropertyDescriptor,b=(e,i,t,n)=>{for(var r=n>1?void 0:n?E(i,t):i,a=e.length-1,o;a>=0;a--)(o=e[a])&&(r=(n?o(i,t,r):o(r))||r);return n&&r&&B(i,t,r),r},v=(e,i)=>(t,n)=>i(t,n,e);function P(e,i){const{from:t,to:n,flipY:r=!1,flipX:a=!1,angle:o=0,skewX:g=0,skewY:h=0}=e.sheetTransform,{column:I,columnOffset:w,row:l,rowOffset:p}=t,C=S.convertPositionSheetOverGridToAbsolute(e.unitId,e.subUnitId,{from:t,to:n},i),{left:y,top:D,width:j,height:F}=C;return{...e,column:I,columnOffset:w,row:l,rowOffset:p,width:j,height:F,flipY:r,flipX:a,angle:o,skewX:g,skewY:h}}function W(e,i,t){const{column:n,columnOffset:r,row:a,rowOffset:o,flipY:g=!1,flipX:h=!1,angle:I=0,skewX:w=0,skewY:l=0,width:p,height:C}=e,y=S.convertPositionCellToSheetOverGrid(e.unitId,e.subUnitId,{column:n,columnOffset:r,row:a,rowOffset:o},p,C,i,t),{sheetTransform:D,transform:j}=y;return{...e,sheetTransform:{...D,flipY:g,flipX:h,angle:I,skewX:w,skewY:l},transform:{...j,flipY:g,flipX:h,angle:I,skewX:w,skewY:l}}}let _=class{constructor(e,i,t){O(this,"_image");this._injector=t,this._image={drawingId:s.generateRandomId(6),drawingType:s.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:s.ImageSourceType.BASE64,source:"",unitId:e,subUnitId:i,column:0,columnOffset:0,row:0,rowOffset:0,width:0,height:0}}setImage(e){const t=this._injector.get(u.IRenderManagerService).getRenderById(e.unitId);if(!t)throw new Error(`Render Unit with unitId ${e.unitId} not found`);const n=t.with(S.SheetSkeletonManagerService);return this._image=P(e,n),this}setSource(e,i){const t=i!=null?i:s.ImageSourceType.URL;return this._image.source=e,this._image.imageSourceType=t,this}getsource(){return this._image.source}getSourceType(){return this._image.imageSourceType}setColumn(e){return this._image.column=e,this}setRow(e){return this._image.row=e,this}setColumnOffset(e){return this._image.columnOffset=e,this}setRowOffset(e){return this._image.rowOffset=e,this}setWidth(e){return this._image.width=e,this}setHeight(e){return this._image.height=e,this}setAnchorType(e){return this._image.anchorType=e,this}setCropTop(e){return this._initializeSrcRect(),this._image.srcRect.top=e,this}setCropLeft(e){return this._initializeSrcRect(),this._image.srcRect.left=e,this}setCropBottom(e){return this._initializeSrcRect(),this._image.srcRect.bottom=e,this}setCropRight(e){return this._initializeSrcRect(),this._image.srcRect.right=e,this}_initializeSrcRect(){this._image.srcRect==null&&(this._image.srcRect={top:0,left:0,bottom:0,right:0})}setRotate(e){return this._image.angle=e,this}setUnitId(e){return this._image.unitId=e,this}setSubUnitId(e){return this._image.subUnitId=e,this}async build(){const i=this._injector.get(u.IRenderManagerService).getRenderById(this._image.unitId);if(!i)throw new Error(`Render Unit with unitId ${this._image.unitId} not found`);const t=i.with(S.ISheetSelectionRenderService),n=i.with(S.SheetSkeletonManagerService);if(this._image.width===0||this._image.height===0){const r=await c.getImageSize(this._image.source),a=r.width,o=r.height;this._image.width===0&&(this._image.width=a),this._image.height===0&&(this._image.height=o)}return W(this._image,t,n)}};_=b([v(2,s.Inject(s.Injector))],_);let m=class extends s.FBase{constructor(e,i,t){super(),this._image=e,this._commandService=i,this._injector=t}getId(){return this._image.drawingId}getType(){return this._image.drawingType}remove(){return this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}toBuilder(){const e=this._injector.createInstance(_);return e.setImage(this._image),e}setSource(e,i){const t=i!=null?i:s.ImageSourceType.URL;return this._image.source=e,this._image.imageSourceType=t,this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}setPosition(e,i,t,n){const r=this.toBuilder();return r.setColumn(i),r.setRow(e),t!=null&&r.setRowOffset(t),n!=null&&r.setColumnOffset(n),this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[r.build()]})}setSize(e,i){const t=this.toBuilder();return t.setWidth(e),t.setHeight(i),this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[t.build()]})}setCrop(e,i,t,n){return this._image.srcRect==null&&(this._image.srcRect={top:0,left:0,bottom:0,right:0}),e!=null&&(this._image.srcRect.top=e),i!=null&&(this._image.srcRect.left=i),t!=null&&(this._image.srcRect.bottom=t),n!=null&&(this._image.srcRect.right=n),this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}setRotate(e){return this._image.sheetTransform.angle=e,this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}};m=b([v(1,s.ICommandService),v(2,s.Inject(s.Injector))],m);class x extends R.FWorksheet{addFloatDomToPosition(i,t){const n=this._workbook.getUnitId(),r=this._worksheet.getSheetId(),{key:a,disposableCollection:o}=k.transformComponentKey(i,this._injector.get(T.ComponentManager)),h=this._injector.get(d.SheetCanvasFloatDomManagerService).addFloatDomToPosition({...i,componentKey:a,unitId:n,subUnitId:r},t);return h?(o.add(h.dispose),{id:h.id,dispose:()=>{o.dispose(),h.dispose()}}):(o.dispose(),null)}async insertImage(i,t,n,r,a){const o=this.newOverGridImage();if(typeof i=="string")o.setSource(i);else{const I=await i.getBlob().getDataAsString();o.setSource(I,s.ImageSourceType.BASE64)}t!==void 0?o.setColumn(t):o.setColumn(0),n!==void 0?o.setRow(n):o.setRow(0),r!==void 0?o.setColumnOffset(r):o.setColumnOffset(0),a!==void 0?o.setRowOffset(a):o.setRowOffset(0);const g=await o.build();return this._commandService.syncExecuteCommand(d.InsertSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:[g]})}insertImages(i){const t=i.map(n=>(n.unitId=this._fWorkbook.getId(),n.subUnitId=this.getSheetId(),n));this._commandService.syncExecuteCommand(d.InsertSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:t})}deleteImages(i){const t=i.map(n=>({unitId:this._fWorkbook.getId(),drawingId:n.getId(),subUnitId:this.getSheetId(),drawingType:n.getType()}));this._commandService.syncExecuteCommand(d.RemoveSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:t})}getImages(){const t=this._injector.get(f.ISheetDrawingService).getDrawingData(this._fWorkbook.getId(),this.getSheetId()),n=[];for(const r in t){const a=t[r];n.push(this._injector.createInstance(m,a))}return n}getImageById(i){const n=this._injector.get(f.ISheetDrawingService).getDrawingByParam({unitId:this._fWorkbook.getId(),subUnitId:this.getSheetId(),drawingId:i});return n?this._injector.createInstance(m,n):null}getActiveImages(){const t=this._injector.get(f.ISheetDrawingService).getFocusDrawings(),n=[];for(const r in t){const a=t[r];n.push(this._injector.createInstance(m,a))}return n}updateImages(i){this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:i})}onImageInserted(i){const t=this._injector.get(f.ISheetDrawingService);t.add$.subscribe(n=>{const r=n.map(a=>this._injector.createInstance(m,t.getDrawingByParam(a)));i(r)})}onImageDeleted(i){const t=this._injector.get(f.ISheetDrawingService);t.remove$.subscribe(n=>{const r=n.map(a=>this._injector.createInstance(m,t.getDrawingByParam(a)));i(r)})}onImageChanged(i){const t=this._injector.get(f.ISheetDrawingService);t.update$.subscribe(n=>{const r=n.map(a=>this._injector.createInstance(m,t.getDrawingByParam(a)));i(r)})}newOverGridImage(){const i=this._fWorkbook.getId(),t=this.getSheetId();return this._injector.createInstance(_,i,t)}}R.FWorksheet.extend(x)});
1
+ (function(s,c){typeof exports=="object"&&typeof module<"u"?c(require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/sheets-drawing-ui"),require("@univerjs/sheets-ui"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-ui/facade"),require("@univerjs/sheets/facade"),require("@univerjs/ui")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/drawing","@univerjs/engine-render","@univerjs/sheets-drawing-ui","@univerjs/sheets-ui","@univerjs/sheets-drawing","@univerjs/sheets-ui/facade","@univerjs/sheets/facade","@univerjs/ui"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.UniverCore,s.UniverDrawing,s.UniverEngineRender,s.UniverSheetsDrawingUi,s.UniverSheetsUi,s.UniverSheetsDrawing,s.UniverSheetsUiFacade,s.UniverSheetsFacade,s.UniverUi))})(this,function(s,c,m,d,S,f,k,R,T){"use strict";var U=Object.defineProperty;var M=(s,c,m)=>c in s?U(s,c,{enumerable:!0,configurable:!0,writable:!0,value:m}):s[c]=m;var O=(s,c,m)=>M(s,typeof c!="symbol"?c+"":c,m);var B=Object.defineProperty,E=Object.getOwnPropertyDescriptor,b=(e,i,t,n)=>{for(var r=n>1?void 0:n?E(i,t):i,a=e.length-1,o;a>=0;a--)(o=e[a])&&(r=(n?o(i,t,r):o(r))||r);return n&&r&&B(i,t,r),r},v=(e,i)=>(t,n)=>i(t,n,e);function P(e,i){const{from:t,to:n,flipY:r=!1,flipX:a=!1,angle:o=0,skewX:g=0,skewY:h=0}=e.sheetTransform,{column:I,columnOffset:w,row:l,rowOffset:p}=t,C=S.convertPositionSheetOverGridToAbsolute(e.unitId,e.subUnitId,{from:t,to:n},i),{left:y,top:D,width:j,height:F}=C;return{...e,column:I,columnOffset:w,row:l,rowOffset:p,width:j,height:F,flipY:r,flipX:a,angle:o,skewX:g,skewY:h}}function W(e,i,t){const{column:n,columnOffset:r,row:a,rowOffset:o,flipY:g=!1,flipX:h=!1,angle:I=0,skewX:w=0,skewY:l=0,width:p,height:C}=e,y=S.convertPositionCellToSheetOverGrid(e.unitId,e.subUnitId,{column:n,columnOffset:r,row:a,rowOffset:o},p,C,i,t),{sheetTransform:D,transform:j}=y;return{...e,sheetTransform:{...D,flipY:g,flipX:h,angle:I,skewX:w,skewY:l},transform:{...j,flipY:g,flipX:h,angle:I,skewX:w,skewY:l}}}let _=class{constructor(e,i,t){O(this,"_image");this._injector=t,this._image={drawingId:s.generateRandomId(6),drawingType:s.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:s.ImageSourceType.BASE64,source:"",unitId:e,subUnitId:i,column:0,columnOffset:0,row:0,rowOffset:0,width:0,height:0}}setImage(e){const t=this._injector.get(m.IRenderManagerService).getRenderById(e.unitId);if(!t)throw new Error(`Render Unit with unitId ${e.unitId} not found`);const n=t.with(S.SheetSkeletonManagerService);return this._image=P(e,n),this}setSource(e,i){const t=i!=null?i:s.ImageSourceType.URL;return this._image.source=e,this._image.imageSourceType=t,this}getsource(){return this._image.source}getSourceType(){return this._image.imageSourceType}setColumn(e){return this._image.column=e,this}setRow(e){return this._image.row=e,this}setColumnOffset(e){return this._image.columnOffset=e,this}setRowOffset(e){return this._image.rowOffset=e,this}setWidth(e){return this._image.width=e,this}setHeight(e){return this._image.height=e,this}setAnchorType(e){return this._image.anchorType=e,this}setCropTop(e){return this._initializeSrcRect(),this._image.srcRect.top=e,this}setCropLeft(e){return this._initializeSrcRect(),this._image.srcRect.left=e,this}setCropBottom(e){return this._initializeSrcRect(),this._image.srcRect.bottom=e,this}setCropRight(e){return this._initializeSrcRect(),this._image.srcRect.right=e,this}_initializeSrcRect(){this._image.srcRect==null&&(this._image.srcRect={top:0,left:0,bottom:0,right:0})}setRotate(e){return this._image.angle=e,this}setUnitId(e){return this._image.unitId=e,this}setSubUnitId(e){return this._image.subUnitId=e,this}async build(){const i=this._injector.get(m.IRenderManagerService).getRenderById(this._image.unitId);if(!i)throw new Error(`Render Unit with unitId ${this._image.unitId} not found`);const t=i.with(S.ISheetSelectionRenderService),n=i.with(S.SheetSkeletonManagerService);if(this._image.width===0||this._image.height===0){const r=await c.getImageSize(this._image.source),a=r.width,o=r.height;this._image.width===0&&(this._image.width=a),this._image.height===0&&(this._image.height=o)}return W(this._image,t,n)}};_=b([v(2,s.Inject(s.Injector))],_);let u=class extends s.FBase{constructor(e,i,t){super(),this._image=e,this._commandService=i,this._injector=t}getId(){return this._image.drawingId}getType(){return this._image.drawingType}remove(){return this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}toBuilder(){const e=this._injector.createInstance(_);return e.setImage(this._image),e}setSource(e,i){const t=i!=null?i:s.ImageSourceType.URL;return this._image.source=e,this._image.imageSourceType=t,this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}setPosition(e,i,t,n){const r=this.toBuilder();return r.setColumn(i),r.setRow(e),t!=null&&r.setRowOffset(t),n!=null&&r.setColumnOffset(n),this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[r.build()]})}setSize(e,i){const t=this.toBuilder();return t.setWidth(e),t.setHeight(i),this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[t.build()]})}setCrop(e,i,t,n){return this._image.srcRect==null&&(this._image.srcRect={top:0,left:0,bottom:0,right:0}),e!=null&&(this._image.srcRect.top=e),i!=null&&(this._image.srcRect.left=i),t!=null&&(this._image.srcRect.bottom=t),n!=null&&(this._image.srcRect.right=n),this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}setRotate(e){return this._image.sheetTransform.angle=e,this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}};u=b([v(1,s.ICommandService),v(2,s.Inject(s.Injector))],u);class x extends R.FWorksheet{addFloatDomToPosition(i,t){const n=this._workbook.getUnitId(),r=this._worksheet.getSheetId(),{key:a,disposableCollection:o}=k.transformComponentKey(i,this._injector.get(T.ComponentManager)),h=this._injector.get(d.SheetCanvasFloatDomManagerService).addFloatDomToPosition({...i,componentKey:a,unitId:n,subUnitId:r},t);return h?(o.add(h.dispose),{id:h.id,dispose:()=>{o.dispose(),h.dispose()}}):(o.dispose(),null)}async insertImage(i,t,n,r,a){const o=this.newOverGridImage();if(typeof i=="string")o.setSource(i);else{const I=await i.getBlob().getDataAsString();o.setSource(I,s.ImageSourceType.BASE64)}t!==void 0?o.setColumn(t):o.setColumn(0),n!==void 0?o.setRow(n):o.setRow(0),r!==void 0?o.setColumnOffset(r):o.setColumnOffset(0),a!==void 0?o.setRowOffset(a):o.setRowOffset(0);const g=await o.build();return this._commandService.syncExecuteCommand(d.InsertSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:[g]})}insertImages(i){const t=i.map(n=>(n.unitId=this._fWorkbook.getId(),n.subUnitId=this.getSheetId(),n));return this._commandService.syncExecuteCommand(d.InsertSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:t}),this}deleteImages(i){const t=i.map(n=>({unitId:this._fWorkbook.getId(),drawingId:n.getId(),subUnitId:this.getSheetId(),drawingType:n.getType()}));return this._commandService.syncExecuteCommand(d.RemoveSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:t}),this}getImages(){const t=this._injector.get(f.ISheetDrawingService).getDrawingData(this._fWorkbook.getId(),this.getSheetId()),n=[];for(const r in t){const a=t[r];n.push(this._injector.createInstance(u,a))}return n}getImageById(i){const n=this._injector.get(f.ISheetDrawingService).getDrawingByParam({unitId:this._fWorkbook.getId(),subUnitId:this.getSheetId(),drawingId:i});return n?this._injector.createInstance(u,n):null}getActiveImages(){const t=this._injector.get(f.ISheetDrawingService).getFocusDrawings(),n=[];for(const r in t){const a=t[r];n.push(this._injector.createInstance(u,a))}return n}updateImages(i){return this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:i}),this}onImageInserted(i){const t=this._injector.get(f.ISheetDrawingService);return s.toDisposable(t.add$.subscribe(n=>{const r=n.map(a=>this._injector.createInstance(u,t.getDrawingByParam(a)));i(r)}))}onImageDeleted(i){const t=this._injector.get(f.ISheetDrawingService);return s.toDisposable(t.remove$.subscribe(n=>{const r=n.map(a=>this._injector.createInstance(u,t.getDrawingByParam(a)));i(r)}))}onImageChanged(i){const t=this._injector.get(f.ISheetDrawingService);return s.toDisposable(t.update$.subscribe(n=>{const r=n.map(a=>this._injector.createInstance(u,t.getDrawingByParam(a)));i(r)}))}newOverGridImage(){const i=this._fWorkbook.getId(),t=this.getSheetId();return this._injector.createInstance(_,i,t)}}R.FWorksheet.extend(x)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-drawing-ui",
3
- "version": "0.5.2",
3
+ "version": "0.5.3-experimental.20250106-4af1f4e",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -57,53 +57,29 @@
57
57
  "rxjs": ">=7.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@univerjs/icons": "^0.2.8",
60
+ "@univerjs/icons": "^0.2.10",
61
61
  "clsx": "^2.1.1",
62
- "@univerjs/design": "0.5.2",
63
- "@univerjs/core": "0.5.2",
64
- "@univerjs/docs-drawing": "0.5.2",
65
- "@univerjs/docs-ui": "0.5.2",
66
- "@univerjs/drawing": "0.5.2",
67
- "@univerjs/drawing-ui": "0.5.2",
68
- "@univerjs/engine-render": "0.5.2",
69
- "@univerjs/sheets-drawing": "0.5.2",
70
- "@univerjs/sheets": "0.5.2",
71
- "@univerjs/sheets-ui": "0.5.2",
72
- "@univerjs/ui": "0.5.2"
62
+ "@univerjs/core": "0.5.3-experimental.20250106-4af1f4e",
63
+ "@univerjs/design": "0.5.3-experimental.20250106-4af1f4e",
64
+ "@univerjs/docs-ui": "0.5.3-experimental.20250106-4af1f4e",
65
+ "@univerjs/drawing": "0.5.3-experimental.20250106-4af1f4e",
66
+ "@univerjs/drawing-ui": "0.5.3-experimental.20250106-4af1f4e",
67
+ "@univerjs/docs-drawing": "0.5.3-experimental.20250106-4af1f4e",
68
+ "@univerjs/engine-render": "0.5.3-experimental.20250106-4af1f4e",
69
+ "@univerjs/sheets-drawing": "0.5.3-experimental.20250106-4af1f4e",
70
+ "@univerjs/sheets": "0.5.3-experimental.20250106-4af1f4e",
71
+ "@univerjs/ui": "0.5.3-experimental.20250106-4af1f4e",
72
+ "@univerjs/sheets-ui": "0.5.3-experimental.20250106-4af1f4e"
73
73
  },
74
74
  "devDependencies": {
75
75
  "less": "^4.2.1",
76
76
  "postcss": "^8.4.49",
77
77
  "react": "18.3.1",
78
78
  "rxjs": "^7.8.1",
79
- "tailwindcss": "^3.4.16",
80
79
  "typescript": "^5.7.2",
81
- "vite": "^6.0.3",
80
+ "vite": "^6.0.6",
82
81
  "vitest": "^2.1.8",
83
- "@univerjs-infra/shared": "0.5.2"
84
- },
85
- "space": {
86
- ".": {
87
- "import": "./lib/es/index.js",
88
- "require": "./lib/cjs/index.js",
89
- "types": "./lib/types/index.d.ts"
90
- },
91
- "./*": {
92
- "import": "./lib/es/*",
93
- "require": "./lib/cjs/*",
94
- "types": "./lib/types/index.d.ts"
95
- },
96
- "./locale/*": {
97
- "import": "./lib/es/locale/*.js",
98
- "require": "./lib/cjs/locale/*.js",
99
- "types": "./lib/types/locale/*.d.ts"
100
- },
101
- "./facade": {
102
- "import": "./lib/es/facade.js",
103
- "require": "./lib/cjs/facade.js",
104
- "types": "./lib/types/facade/index.d.ts"
105
- },
106
- "./lib/*": "./lib/*"
82
+ "@univerjs-infra/shared": "0.5.3"
107
83
  },
108
84
  "scripts": {
109
85
  "test": "vitest run",
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS