slab / quill

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

custom div and classes both are getting removed when binding it as HTML to the quill editor. Any workaround for this? #3838

Open kalandher opened 1 year ago

kalandher commented 1 year ago

custom div and classes both are getting removed when binding it as HTML to the quill editor (https://stackoverflow.com/questions/76744440/custom-div-and-classes-both-are-getting-removed-when-binding-it-as-html-to-the-q)

Steps for Reproduction

in Ts file i have

this.htmlText = '<span class="my-thing"><a href="http://help.com" rel="noopener noreferrer" target="_blank">help.com</a></span>

Quill editor code in HTML

<quill-editor (onEditorCreated)="onEditorCreated($event)" [(ngModel)]="htmlText" #headerElement [modules]="modules" [styles]="{height: '200px'}" (onFocus)="focus($event)" (onEditorChanged)="changedEditor($event)" (onBlur)="blur($event)" (onEditorCreated)="created($event)"></quill-editor>

after rendering custom classes and custom span are getting removed.

I have created a custom bolt to create a custom span and custom class which is working fine. I'm able to add and save. While initializing quill editor with the saved HTML. custom span and custom classes are getting removed.

this.modules = {
        toolbar: {
          container: [
            ['my-thing']
          ]
      }
    }

    var Block = Quill.import('blots/block');

    class MyThing extends Block {}
    MyThing.blotName = 'my-thing';
    MyThing.className = 'my-thing';
    MyThing.tagName = 'span';

    Quill.register(MyThing);

Expected behavior: I should see custom divs and classes which were added to the content should be shown after initializing quill editer with HTML Actual behavior: Custom elements and classes are getting removed Platforms:

Version: ngx-quill : 22.0.0 quill: 1.3.7,

benbro commented 10 months ago

Please create a CodePen showing the issue in plain JavaScript without using ngx-quill or other framework.