PrimeNG Quill编辑器自定义工具栏

时间:2017-08-28 14:33:05

标签: angular primeng quill

我想用PrimeNG制作一个quill编辑器的自定义工具栏。 我正在使用Angular 2。

这是我在html代码中所做的:

    <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>

这是它的样子 enter image description here

但正如您所看到的那样ql-listql-bullet未显示。

我该怎么办?

1 个答案:

答案 0 :(得分:8)

注意这两个按钮的代码之间的区别:

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

和编辑器渲染时的实际代码。您所要做的就是替换值属性的title属性:

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

我所做的就是回到primeng所拥有的完整功能工具栏,并右键单击&gt;检查没有正确显示的按钮的html标签,我得到了正确的代码来显示它。

相关问题