Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 6 PrimeNG custom editor

I am trying to customize my PrimeNG Editor I'm having adding a select dropdown list with custom font sizes [12px, 14px, 16px...]

Here is the component HTML

<p-editor [(ngModel)]="value" (onTextChange)="onTextChanged($event)">
            <p-header>
                    <span class="ql-formats">
                     ...
                      <select class="ql-size">
                            <option value="12px">12</option>
                            <option value="14px">14</option>
                            <option value="16px">16</option>
                        </select>
                    </span>
                   ...
                  </p-header>               
    </p-editor>

I can get the select list to show with all the font sizes enter image description here

I'm not sure how to add the functionality to change the font size when selecting an option in the list. I don't see any examples in their docs for typescript. How can I make a select list of custom font sizes?

Here are the docs I followed

example

like image 635
Train Avatar asked Apr 02 '19 14:04

Train


1 Answers

Firstly,put your component.ts

import { Editor } from 'primeng/editor';
declare var Quill: any;

and add this line in constructor

var fontSizeStyle = Quill.import('attributors/style/size');
fontSizeStyle.whitelist = ['24px', '48px', '100px', '200px'];
Quill.register(fontSizeStyle, true);

At the last,change your html

<span class="ql-formats">
   <select class="ql-size">
       <option value="24px">24</option>
       <option value="48px">48</option>
       <option value="100px">100</option>
       <option value="200px">200</option>
   </select>
</span>

Example

like image 90
ahmeticat Avatar answered Oct 20 '22 04:10

ahmeticat