Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paste HMTL removing inline style and HTML tags #4262

Open
Alef-Martins opened this issue Jun 20, 2024 · 0 comments
Open

Paste HMTL removing inline style and HTML tags #4262

Alef-Martins opened this issue Jun 20, 2024 · 0 comments

Comments

@Alef-Martins
Copy link

Hello!

I'm using Quill to render HTML code. There is a modal with an input where the user can paste some HTML code, and it sends the content to Quill. However, when the content is rendered by the component, the inline styles and some tags are removed. Is there a configuration to prevent those things from being removed?

`<div class="editor" [formGroup]="form">
  <quill-editor placeholder="" (onEditorCreated)="getEditorInstance($event)" #editorComponent theme="snow" format="html" formControlName="contentTinyHtml" imageResize="true" [modules]="modules" [sanitize]="true">
  </quill-editor>
</div>

<app-quill-editor-html-modal [quillContent]="form.get('contentTinyHtml')?.value" #quillModal (sendHtmlToQuillEditor)="hydrateContentInQuillEditor($event)"></app-quill-editor-html-modal>`
`ngOnInit(): void {
    
    const fontSizeArr = ['6px', '8px', '9px','10px', '11px', '12px', '13px', '14px', '16px', '18px', '24px', '30px', '36px', '48px'];
    const Size = this.Quill.import('attributors/style/size');
    Size.whitelist = fontSizeArr;
    this.Quill.register(Size, true);


    this.buildModule(Size);
  }

buildModule(size) {
    this.modules = {
      blotFormatter: {
        overlay: {
          style: {
            width: '100px',
            height: '100px',
          }
        }
      },
      'toolbar': {
        container: [
          ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
          ['blockquote', 'code-block'],
          [{ 'header': 1 }, { 'header': 2 }],               // custom button values
          [{ 'list': 'ordered' }, { 'list': 'bullet' }],
          [{ 'script': 'sub' }, { 'script': 'super' }],      // superscript/subscript
          [{ 'indent': '-1' }, { 'indent': '+1' }],          // outdent/indent
          [{ 'direction': 'rtl' }],                         // text direction
          [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
          [{ 'size': size.whitelist }],
          [{ 'font': [] }],
          [{ 'align': [] }],
          ['clean'],                                         // remove formatting button
          ['link', 'image'],                         // link and image, video
        ],
      },
      'clipboard': {
        allowed: {
            tags: ['a', 'b', 'strong', 'u', 's', 'i', 'p', 'br', 'ul', 'ol', 'li', 'span', 'center', 'table', 'td', 'tr', 'tbody'],
            attributes: ['href', 'rel', 'target', 'class', 'style']
        },
        keepSelection: true,
        substituteBlockElements: false,
        magicPasteLinks: true,
      }
    }
  }`

My ngx-quill version is 8.1.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant