parchment icon indicating copy to clipboard operation
parchment copied to clipboard

Getting an extra span in my blot

Open singpolyma opened this issue 3 months ago • 0 comments

In this simply blot I get an extra nested span inside with contenteditable="false" on it. This wouldn't be a problem except then this extra span also shows up in the getSemanitcHTML() output from quill which is quite annoying. Anyone know why I'm getting this extra child when I just call innerText here?

  static blotName = "mention";                                                                                                                                               
  static tagName = "span";                                                                                                                                                   
  static className = "v-card";                                                                                                                                               
                                                                                                                                                                             
  private hoverHandler?: EventListener;                                                                                                                                      
  private clickHandler?: EventListener;                                                                                                                                      
                                                                                                                                                                             
  constructor(scroll: ScrollBlot, node: Node) {                                                                                                                              
    super(scroll, node);                                                                                                                                                     
  }                                                                                                                                                                          
                                                                                                                                                                             
  static render?(data: MentionBlotData): HTMLElement;                                                                                                                        
                                                                                                                                                                             
  static create(data?: MentionBlotData) {                                                                                                                                    
    const node = super.create() as HTMLElement;                                                                                                                              
                                                                                                                                                                             
    if (typeof this.render === "function") {                                                                                                                                 
      node.appendChild(this.render(data));                                                                                                                                   
    } else {                                                                                                                                                                 
      node.innerText = data.value;                                                                                                                                           
    }                                                                                                                                                                        
                                                                                                                                                                             
    return MentionBlot.setDataValues(node, data);                                                                                                                            
  }                                                                                                                                                                          
                                                                                                                                                                             
  static setDataValues(element: HTMLElement, data: MentionBlotData) {                                                                                                        
    const domNode = element;                                                                                                                                                 
    Object.keys(data).forEach((key) => {                                                                                                                                     
      domNode.dataset[key] = data[key as keyof MentionBlotData];                                                                                                             
    });                                                                                                                                                                      
    return domNode;                                                                                                                                                          
  }                                                                                                                                                                          
                                                                                                                                                                             
  static value(domNode: HTMLElement): any {                                                                                                                                  
    return domNode.dataset;                                                                                                                                                  
  }                                                                                                                                                                          
}  ```

singpolyma avatar Oct 14 '25 06:10 singpolyma