slab / quill

Quill is a modern WYSIWYG editor built for compatibility and extensibility
https://quilljs.com
BSD 3-Clause "New" or "Revised" License
43.26k stars 3.36k forks source link

Render HTML content inside custom inline blot remove inline css and messup format #3079

Closed kapilnadiyapara closed 5 months ago

kapilnadiyapara commented 4 years ago

Hello All,

I have created one custome inline blot with name like this .

const BlockInline = Quill.import("blots/inline");
    class VNCSignature extends BlockInline {
      static create(value) {
        const node = super.create(value);
        return node;
      }
      static value(node) {
        return {
          style: node.getAttribute("style")
        };
      }
    }
    VNCSignature.blotName = "signature";
    VNCSignature.className = "signature";
    VNCSignature.tagName = "signature";
    Quill.register({
      "formats/signature": VNCSignature
    });

Now after createing i am adding my data inside the blot like this way :

setSignatureToBody(signature: string): void {
                this.mailBody =  "<br/><br/><signature>" + signature + "</signature>";
    }

Now it is adding signature but format is messup. My signature is like this

"<div><span id="98b7a15b-0fd3-45b1-8e72-ccc3a5160dda"><span id="4059b70a-05e4-470f-9a07-11a7cd2ab192"><span id="eb0f4d1a-526d-402d-97d9-9e275c0d7a77"><span id="e7a1baf1-b6fe-463b-8edb-dcddea056423"><span style="font-size:small"><span style="font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif">Kind regards </span><br style="font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif" /><br /><span style="font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif">Kapil Nadiyapara</span><br /></span></span><span class="Apple-style-span" style="background-color:#ffffff"><span style="font-family:&#39;arial&#39;;font-size:small"><strong>VNC Technologies Pvt. Ltd.</strong></span><br /><span id="eb0f4d1a-526d-402d-97d9-9e275c0d7a77" style="font-family:&#39;arial&#39;"><span id="e7a1baf1-b6fe-463b-8edb-dcddea056423"><span style="font-size:small"><span style="font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif;font-weight:bold"></span><span style="font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif;font-style:italic">Professional Services<br /></span></span></span></span></span></span></span></span><div><br /></div><span style="font-family:&#39;arial&#39;;font-size:xx-small">B-207, 208, Synergy tower , </span></div><div><span id="98b7a15b-0fd3-45b1-8e72-ccc3a5160dda"><span id="4059b70a-05e4-470f-9a07-11a7cd2ab192"><span id="eb0f4d1a-526d-402d-97d9-9e275c0d7a77"><span class="Apple-style-span" style="background-color:#ffffff"><span style="font-family:&#39;arial&#39;;font-size:xx-small">2nd floor, Corporate Road,</span></span></span></span></span></div><div><span id="98b7a15b-0fd3-45b1-8e72-ccc3a5160dda"><span id="4059b70a-05e4-470f-9a07-11a7cd2ab192"><span id="eb0f4d1a-526d-402d-97d9-9e275c0d7a77"><span class="Apple-style-span" style="background-color:#ffffff"><span style="font-family:&#39;arial&#39;;font-size:xx-small">Nr. Vodafone house,<br />Ahmedabad - 380 015. India</span></span></span></span></span></div><div><span id="98b7a15b-0fd3-45b1-8e72-ccc3a5160dda"><span id="4059b70a-05e4-470f-9a07-11a7cd2ab192"><span id="eb0f4d1a-526d-402d-97d9-9e275c0d7a77"><span class="Apple-style-span" style="background-color:#ffffff"><span style="font-family:&#39;arial&#39;;font-size:xx-small">Mobile : &#43;91 9974874566 <br />Phone: &#43;91 79 4037 3536</span><br /><span id="eb0f4d1a-526d-402d-97d9-9e275c0d7a77"><span id="e7a1baf1-b6fe-463b-8edb-dcddea056423"><span style="font-family:&#39;arial&#39;;font-size:small"><span style="font-size:xx-small"><span style="font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif"><span class="Object" id="OBJ_PREFIX_DWT341" style="color:#00008b;text-decoration:none"><span class="Object" id="OBJ_PREFIX_DWT6187_com_zimbra_email" style="color:#00008b;text-decoration:none"><span class="Object" id="OBJ_PREFIX_DWT305_com_zimbra_email" style="color:#00008b;text-decoration:none"><span class="Object" id="OBJ_PREFIX_DWT64_com_zimbra_email" style="color:#00008b;text-decoration:none">kapil.nadiyapara&#64;vnc.biz</span></span></span></span>; <span class="Object" id="OBJ_PREFIX_DWT342" style="color:#00008b;text-decoration:none"><span class="Object" id="OBJ_PREFIX_DWT6188_com_zimbra_url" style="color:#00008b;text-decoration:none"><span class="Object" id="OBJ_PREFIX_DWT306_com_zimbra_url" style="color:#00008b;text-decoration:none"><span class="Object" id="OBJ_PREFIX_DWT65_com_zimbra_url" style="color:#00008b;text-decoration:none"><a href="http://www.vnc.biz/" style="color:#00008b;text-decoration:none" rel="nofollow%20noopener%20noreferrer%20nofollow%20noopener%20noreferrer nofollow noopener noreferrer nofollow noopener noreferrer nofollow noopener noreferrer nofollow noopener noreferrer nofollow noopener noreferrer nofollow noopener noreferrer" target="_blank">www.vnc.biz</a></span></span></span></span></span></span></span></span></span><span id="eb0f4d1a-526d-402d-97d9-9e275c0d7a77" style="font-family:&#39;arial&#39;"><span id="e7a1baf1-b6fe-463b-8edb-dcddea056423"><span style="font-size:small"><span style="font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif"></span></span><span style="font-size:small"><span style="font-size:xx-small"><span style="font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif"><span class="Object" id="OBJ_PREFIX_DWT342" style="color:#00008b;text-decoration:none"><br /></span></span></span></span></span></span></span></span><span style="font-family:&#39;arial&#39;"></span></span><span style="font-family:&#39;arial&#39;"></span></span><span style="font-family:&#39;arial&#39;"></span></div><div><span class="Apple-style-span" style="background-color:#ffffff"><span style="font-family:&#39;arial&#39;;font-size:small"><span style="font-size:xx-small"><span style="font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif"><span class="Object" style="color:#00008b;text-decoration:none"><span class="Object" style="color:#00008b;text-decoration:none"><span class="Object" style="color:#00008b;text-decoration:none"><span class="Object" style="color:#00008b;text-decoration:none"><br /></span></span></span></span></span></span></span></span></div><div><span class="Apple-style-span" style="background-color:#ffffff"><span style="font-family:&#39;arial&#39;;font-size:small"><span style="font-size:xx-small"><span style="font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif"><span class="Object" style="color:#00008b;text-decoration:none"><span class="Object" style="color:#00008b;text-decoration:none"><span class="Object" style="color:#00008b;text-decoration:none"><span class="Object" style="color:#00008b;text-decoration:none"><strong style="color:#000000;font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif;font-size:13.3333px;font-style:normal;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:#ffffff"><span style="color:#000000;font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif;font-style:normal;font-weight:normal;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:16px;background-color:#ffffff;float:none;display:!important">Get your free tour of the VNClagoon in our next</span><span style="color:#000000;font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif;font-style:normal;font-weight:normal;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:16px;background-color:#ffffff;float:none;display:!important"> <a href="https://register.gotowebinar.com/rt/2647711251238490883" style="color:#005a95;text-decoration:none" rel="nofollow%20noopener%20noreferrer%20nofollow%20noopener%20noreferrer nofollow noopener noreferrer nofollow noopener noreferrer nofollow noopener noreferrer nofollow noopener noreferrer nofollow noopener noreferrer nofollow noopener noreferrer" target="_blank">webinar</a></span><span style="color:#000000;font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif;font-style:normal;font-weight:normal;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:16px;background-color:#ffffff;float:none;display:!important"> </span><span style="color:#000000;font-family:&#39;arial&#39; , &#39;helvetica&#39; , sans-serif;font-style:normal;font-weight:normal;letter-spacing:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:16px;background-color:#ffffff;float:none;display:!important">!</span></strong></span></span></span></span></span></span></span></span></div>"

But it is remove all innerHTML span etc while we render signature into the blot in quill editor. It look like this

https://prnt.sc/t8x5te

While before we created a block/embed custom blot Where we can able to render whole html uside it like this way

document.querySelector("signature").innerHTML = signature

And it render inside quill editor perfectly . But issue in the block/embed blot is when we are just press "BACKSPACE from keyborad then it will remove whole tag in quill becuase of block/embed blot so we use inline blot for fix this issue. But it remoev whole format inline blot.

Also we have change signature facility in application where we can render new signature to<signature> blot which is replace html signature in to existing but it will add more <p><br></p> before and after <signature> blot.

So can you please suggest me what i do here to make blot format same as HTML we have in signature. it should not remove my any html .

We have following version of quill and ngx-quill.

"ngx-quill": "3.6.0" "quill": "1.3.6"

quill-bot commented 5 months ago

Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide :pray: