add this line to styles section of angular.json:
"node_modules/quill/dist/quill.snow.css"
Answer from Mojtaba Nejad Poor Esmaeili on Stack Overflow
» npm install ng2-json-editor
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
First get the style/size whitelisted in the .ts:
constructor(){
var fontSizeStyle = Quill.import('attributors/style/size');
fontSizeStyle.whitelist = ['0.75em','1em','1.5em','2.5em', '24px', '48px', '100px', '200px'];
Quill.register(fontSizeStyle, true);
}
Now in the html file we used this whitelisted options:
<span class="ql-formats">
<select class="ql-size">
<option value="0.75em">small</option>
<option value="1em" selected></option>
<option value="1.5em">large</option>
<option value="2.5em">huge</option>
</select>
</span>
<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>
Check the change of the value of the first dropdown options.
You can declare the var Quill so it doesn't have problems with the undefined variable: (this is how primeng does it too)
declare var Quill: any;
Working example here:
https://stackblitz.com/edit/quill-55477705?file=src/app/app.component.ts
» npm install ngx-json-viewer
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.
<p-editor [modules]="editorModules"></p-editor>
const editorModules= {
toolbar: [
[],
['bold', 'italic', 'underline', 'strike'],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'align': [] }],
[{ 'color': [] }, { 'background': [] }],
['image', 'link']
]
};
Try this in newer version
