Skip to content

Getting an extra span in my blot #156

@singpolyma

Description

@singpolyma

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;                                                                                                                                                  
  }                                                                                                                                                                          
}  ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions