You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm facing an issue while working with a custom Blot that extends the Block blot. The problem is that it affects the behavior of the default <'p'> tag.
Specifically, when I try to insert a new line, it triggers the format method of my custom Blot. Also, since I added requiredContainer, the default <'p'> tag no longer behaves as expected. Instead, it wraps the line inside a blockquote, even when it's just a normal paragraph.
Can someone please help me understand how to fix this or provide guidance on preventing this unintended behavior?
Thanks in advance!
importQuillfrom"quill";constBlock=Quill.import("blots/block");constTextBlot=Quill.import("blots/text");constCursor=Quill.import("blots/cursor");constBreak=Quill.import("blots/break");constContainer=Quill.import("blots/container");constLinkBlot=Quill.import("formats/link");// -------- container <blockquote /> --------classQuoteContainerBlotextendsContainer{staticcreate(value){console.log('QuoteContainerBlot create =>',value);constdomNode=super.create(value);returndomNode;}}// -------- quote line <p /> --------classCustomQuoteBlotextendsBlock{staticblotName="custom-quote";staticregister(){Quill.register(QuoteContainerBlot);}staticcreate(value){if(!value){constdomNode=super.create();returndomNode;}console.log('create =>',value);constdomNode=super.create();domNode.setAttribute("data-blockquote","true");domNode.setAttribute("data-quote-type",value);Array.from(domNode.classList).forEach((item)=>{domNode.classList.remove(item);});if(value!=='default'){domNode.classList.add('md-alert',`md-alert-${value}`);}console.log(domNode);returndomNode;}staticformats(node){if(node.getAttribute("data-blockquote")==="true"){returnnode.getAttribute("data-quote-type")||'default';}returnfalse;}format(name,value){console.log('format =>',name,value);console.log(this.domNode.getAttribute('data-quote-type'));if(name!==this.statics.blotName||!value||value===this.domNode.getAttribute('data-quote-type')){value=falsesuper.format(name,value);}else{this.domNode.setAttribute("data-blockquote","true");this.domNode.setAttribute("data-quote-type",value);Array.from(this.domNode.classList).forEach((item)=>{this.domNode.classList.remove(item);});if(value!=='default'){this.domNode.classList.add('md-alert',`md-alert-${value}`);}}}}QuoteContainerBlot.blotName="custom-quote-container";QuoteContainerBlot.tagName="blockquote";QuoteContainerBlot.className="custom-block";QuoteContainerBlot.allowedChildren=[CustomQuoteBlot];CustomQuoteBlot.tagName="p";// -------- list all the children types you want to support inside a quote block --------CustomQuoteBlot.allowedChildren=[TextBlot,Break,Cursor,LinkBlot];CustomQuoteBlot.requiredContainer=QuoteContainerBlot;exportdefaultCustomQuoteBlot;
The text was updated successfully, but these errors were encountered:
Hi, I'm facing an issue while working with a custom Blot that extends the Block blot. The problem is that it affects the behavior of the default <'p'> tag.
Specifically, when I try to insert a new line, it triggers the format method of my custom Blot. Also, since I added requiredContainer, the default <'p'> tag no longer behaves as expected. Instead, it wraps the line inside a blockquote, even when it's just a normal paragraph.
Can someone please help me understand how to fix this or provide guidance on preventing this unintended behavior?
Thanks in advance!
The text was updated successfully, but these errors were encountered: