updateElementTag () {
        let paragraphPicker = this.namedElements.paragraph;
        
        if(!paragraphPicker) { return; }

        let selection = window.getSelection();

        if(!selection) { return; }

        let textNode = selection.anchorNode;

        if(!textNode) { return; }
        
        let parentElement = textNode.parentElement;
       
        if(!parentElement) { return; }
        
        let parentElementTagName = parentElement.tagName.toLowerCase();

        // If a media objects is involved, use it as reference
        if(textNode.children) {
            for(let i = 0; i < textNode.children.length; i++) {
                if(textNode.children[i].hasAttribute('src')) {
                    parentElementTagName = textNode.children[i].parentElement.tagName.toLowerCase();
                    break;
                }
            }
        }

        // If the parent tag is not a heading or a paragraph, default to paragraph
        if(!paragraphPicker.hasOption(parentElementTagName)) {
            parentElementTagName = 'p';
        }

        paragraphPicker.setValue(parentElementTagName);
    }
/**
     * Updates the paragraph picker and selection tag
     */
Updates the paragraph picker and selection tag
Updates the paragraph picker and selection tag
updateElementTag () {
        let paragraphPicker = this.namedElements.paragraph;
        if(!paragraphPicker) { return; }
        let selection = window.getSelection();
        if(!selection) { return; }
        let textNode = selection.anchorNode;
        if(!textNode) { return; }
        let parentElement = textNode.parentElement;
        if(!parentElement) { return; }
        let parentElementTagName = parentElement.tagName.toLowerCase();
        if(textNode.children) {
            for(let i = 0; i < textNode.children.length; i++) {
                if(textNode.children[i].hasAttribute('src')) {
                    parentElementTagName = textNode.children[i].parentElement.tagName.toLowerCase();
                    break;
                }
            }
        }
        if(!paragraphPicker.hasOption(parentElementTagName)) {
            parentElementTagName = 'p';
        }
        paragraphPicker.setValue(parentElementTagName);
    }
updateElementTag ( ) { let paragraphPicker = this . namedElements . paragraph ; if ( ! paragraphPicker ) { return ; } let selection = window . getSelection ( ) ; if ( ! selection ) { return ; } let textNode = selection . anchorNode ; if ( ! textNode ) { return ; } let parentElement = textNode . parentElement ; if ( ! parentElement ) { return ; } let parentElementTagName = parentElement . tagName . toLowerCase ( ) ; if ( textNode . children ) { for ( let i = 0 ; i < textNode . children . length ; i ++ ) { if ( textNode . children [ i ] . hasAttribute ( 'src' ) ) { parentElementTagName = textNode . children [ i ] . parentElement . tagName . toLowerCase ( ) ; break ; } } } if ( ! paragraphPicker . hasOption ( parentElementTagName ) ) { parentElementTagName = 'p' ; } paragraphPicker . setValue ( parentElementTagName ) ; }
Updates the paragraph picker and selection tag
Updates the paragraph picker and selection tag
// If a media objects is involved, use it as reference // If the parent tag is not a heading or a paragraph, default to paragraph