Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PrimeNG Quill editor custom toolbar

I want to make a custom toolbar of quill editor with PrimeNG. I am using Angular 2.

Here is what I did in my html code :

    <p-editor [(ngModel)]="message" [style]="{'height':'320px'}">
        <p-header>
          <span class="ql-formats">
            <select class="ql-size">
              <option value="small">Petit</option>
              <option selected></option>
              <option value="large">Sous-titre</option>
              <option value="huge">Titre</option>
            </select>
          </span>
          <span class="ql-formats">
            <button class="ql-bold" aria-label="Bold"></button>
            <button class="ql-italic" aria-label="Italic"></button>
            <button class="ql-underline" aria-label="Underline"></button>
            <button class="ql-strike" aria-label="Strike"></button>
          </span>
          <span class="ql-formats">
            <select title="Text Color" class="ql-color" defaultValue="rgb(0, 0, 0)">
              <option value="rgb(0, 0, 0)" label="rgb(0, 0, 0)"></option>
              ...
              <option value="rgb(61, 20, 102)" label="rgb(61, 20, 102)"></option>
            </select>
            <span class="ql-format-separator"></span>
            <select title="Background Color" class="ql-background" defaultValue="rgb(255, 255, 255)">
              <option value="rgb(0, 0, 0)" label="rgb(0, 0, 0)"></option>
              ...
              <option value="rgb(61, 20, 102)" label="rgb(61, 20, 102)"></option>
            </select>
        </span>
          <span class="ql-formats">
            <button class="ql-list" title="List"></button>
            <button class="ql-bullet" title="Bullet"></button>
            <select title="Text Alignment" class="ql-align" >
              <option selected>Gauche</option>
              <option value="center" label="Center"></option>
              <option value="right" label="Right"></option>
              <option value="justify" label="Justify"></option>
            </select>            
          </span> 
          <span class="ql-formats">
            <button aria-label="Link" class="ql-link"></button>
            <button aria-label="Image" class="ql-image"></button>
          </span>
        </p-header>
      </p-editor>

Here is what it looks like enter image description here

But as you can see ql-list and ql-bullet are not shown.

What can I do ?

like image 399
anais1477 Avatar asked Aug 28 '17 14:08

anais1477


1 Answers

Notice the difference between your code for those two buttons:

 <button class="ql-list" title="List"></button>
 <button class="ql-bullet" title="Bullet"></button>

and the actual code when the editor renders. All you have to do is to replace the title attribute for the value attribute that would do the trick:

<button class="ql-list" value="ordered"></button>
<button class="ql-list" value="bullet"></button>

All I did was to go back on the full feature toolbar that primeng has and did right click > inspect on the html tags of the buttons that weren't displaying correctly and I got the right code to display it.

like image 106
William Matias Avatar answered Sep 17 '22 20:09

William Matias