@@ -40,6 +40,7 @@ function createScene() {
4040
4141function createController ( options : {
4242 drawing ?: Record < string , unknown > ;
43+ hasDocumentUnit ?: boolean ;
4344 rects ?: Rect [ ] ;
4445 page ?: any ;
4546 refreshDrawingOnAdd ?: { left : number ; top : number ; width : number ; height : number ; angle : number } ;
@@ -115,7 +116,7 @@ function createController(options: {
115116 } ;
116117 const doc = { getUnitId : ( ) => 'doc-1' } ;
117118 const univerInstanceService = {
118- getUnit : vi . fn ( ( ) => doc ) ,
119+ getUnit : vi . fn ( ( ) => options . hasDocumentUnit === false ? null : doc ) ,
119120 getCurrentUnitOfType : vi . fn ( ( ) => doc ) ,
120121 getCurrentTypeOfUnit$ : vi . fn ( ( ) => new BehaviorSubject ( null ) ) ,
121122 } ;
@@ -308,6 +309,23 @@ describe('DocFloatDomController', () => {
308309 controller . dispose ( ) ;
309310 } ) ;
310311
312+ it ( 'ignores embed drawing events owned by non-document hosts' , ( ) => {
313+ const { controller, add$, renderUnit, drawingRenderService, refreshDrawings } = createController ( {
314+ drawing : {
315+ data : { version : 1 , embedId : 'embed-1' , hostAnchorId : 'anchor-1' } ,
316+ } ,
317+ hasDocumentUnit : false ,
318+ } ) ;
319+
320+ add$ . next ( [ { unitId : 'sheet-1' , subUnitId : 'sheet-1' , drawingId : 'dom-1' } ] ) ;
321+
322+ expect ( renderUnit . with ) . not . toHaveBeenCalled ( ) ;
323+ expect ( drawingRenderService . renderFloatDom ) . not . toHaveBeenCalled ( ) ;
324+ expect ( refreshDrawings ) . not . toHaveBeenCalled ( ) ;
325+
326+ controller . dispose ( ) ;
327+ } ) ;
328+
311329 it ( 'waits for layout runtime geometry before mounting an embed custom block' , ( ) => {
312330 const rect = new Rect ( 'dom-rect' , {
313331 left : 10 ,
0 commit comments