File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { ModuleConfig } from '../../../types-internal/module-config';
1212import  InlineTool  from  '../../tools/inline' ; 
1313import  {  CommonInternalSettings  }  from  '../../tools/base' ; 
1414import  {  IconChevronDown  }  from  '@codexteam/icons' ; 
15+ import  UI  from  '../ui' ; 
1516
1617/** 
1718 * Inline Toolbar elements 
@@ -321,6 +322,7 @@ export default class InlineToolbar extends Module<InlineToolbarNodes> {
321322  private  move ( ) : void { 
322323    const  selectionRect  =  SelectionUtils . rect  as  DOMRect ; 
323324    const  wrapperOffset  =  this . Editor . UI . nodes . wrapper . getBoundingClientRect ( ) ; 
325+     const  isNestedEditor  =  ! ! this . Editor . UI . nodes . holder . closest ( `.${ this . Editor . UI . CSS . editorWrapper }  ) 
324326    const  newCoords  =  { 
325327      x : selectionRect . x  -  wrapperOffset . x , 
326328      y : selectionRect . y  + 
@@ -330,13 +332,13 @@ export default class InlineToolbar extends Module<InlineToolbarNodes> {
330332        this . toolbarVerticalMargin , 
331333    } ; 
332334
333-     const  realRightCoord  =  newCoords . x  +  this . width ; 
335+     const  realRightCoord  =  isNestedEditor  ?  newCoords . x  +  this . width  :  newCoords . x   +   this . width   +   wrapperOffset . x ; 
334336
335337    /** 
336338     * Prevent InlineToolbar from overflowing the content zone on the right side 
337339     */ 
338340    if  ( realRightCoord  >  this . Editor . UI . contentRect . right )  { 
339-       newCoords . x  =  this . Editor . UI . contentRect . right  -  this . width ; 
341+       newCoords . x  =  isNestedEditor  ?  this . Editor . UI . contentRect . right  -  this . width  :  this . Editor . UI . contentRect . right   -   this . width   -   wrapperOffset . x ; 
340342    } 
341343
342344    this . nodes . wrapper . style . left  =  Math . floor ( newCoords . x )  +  'px' ; 
Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ export default class UI extends Module<UINodes> {
4747   */ 
4848  private  prevSelectionAnchorElement : Element  |  null  =  null ; 
4949
50+   /** 
51+    * The actual cached selection. 
52+    */ 
53+   private  prevSelection : any  =  null ; 
54+ 
5055  /** 
5156   * Editor.js UI CSS class names 
5257   * 
@@ -801,12 +806,17 @@ export default class UI extends Module<UINodes> {
801806  private  selectionChanged ( ) : void { 
802807    const  {  CrossBlockSelection,  BlockSelection }  =  this . Editor ; 
803808    const  focusedElement  =  Selection . anchorElement ; 
809+     const  currentSelection  =  window . getSelection ( ) ; 
810+ 
811+     const  sameSelection  =  currentSelection  ==  this . prevSelection  &&  currentSelection ; 
812+     const  sameFocus  =  this . prevSelectionAnchorElement  ==  focusedElement  &&  focusedElement ; 
804813
805-     if  ( this . prevSelectionAnchorElement   ==   focusedElement )  { 
814+     if  ( sameSelection   &&   sameFocus )  { 
806815      return ; 
807816    } 
808817
809818    this . prevSelectionAnchorElement  =  focusedElement ; 
819+     this . prevSelection  =  currentSelection ; 
810820
811821    if  ( CrossBlockSelection . isCrossBlockSelectionStarted )  { 
812822      // Removes all ranges when any Block is selected 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments