admin管理员组文章数量:1401673
I want to be able to add custom font families to my Quill JS editor using the toolbar options via JavaScript, rather than defining them through HTML.
The code I have is below, which is the same code taken from the documentation:
var toolbarOptions = [
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }],
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
[{ 'script': 'sub'}, { 'script': 'super' }],
[{ 'indent': '-1'}, { 'indent': '+1' }],
[{ 'direction': 'rtl' }],
[{ 'size': ['small', false, 'large', 'huge'] }],
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }],
[{ 'font': [] }], // Here, how do I specify custom font families??
[{ 'align': [] }],
];
var quill = new Quill('#editor', {
modules: {
toolbar: toolbarOptions
},
theme: 'snow'
});
Code running here:
Is there any way to do this? Also, I assume I need to include a link to Google fonts for each font I want to use, right?
Thanks
I want to be able to add custom font families to my Quill JS editor using the toolbar options via JavaScript, rather than defining them through HTML.
The code I have is below, which is the same code taken from the documentation:
var toolbarOptions = [
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }],
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
[{ 'script': 'sub'}, { 'script': 'super' }],
[{ 'indent': '-1'}, { 'indent': '+1' }],
[{ 'direction': 'rtl' }],
[{ 'size': ['small', false, 'large', 'huge'] }],
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }],
[{ 'font': [] }], // Here, how do I specify custom font families??
[{ 'align': [] }],
];
var quill = new Quill('#editor', {
modules: {
toolbar: toolbarOptions
},
theme: 'snow'
});
Code running here: https://codepen.io/anon/pen/VgVZMg
Is there any way to do this? Also, I assume I need to include a link to Google fonts for each font I want to use, right?
Thanks
Share Improve this question asked Feb 16, 2019 at 11:14 alexconsalexcons 5314 gold badges8 silver badges18 bronze badges 1- 4 It is answered here: stackoverflow./questions/43728080/… – Dipen Shah Commented Feb 20, 2019 at 4:25
1 Answer
Reset to default 4 +50you can find your answer in this lisnk:
How to add font types on Quill js with toolbar options?
The process is like this you need 4 ponents:
A select tag with a ql-font class. This will contain the new font options. Add the new fonts to the whitelist. This has to be defined before you call the the Quill constructor in Javascript. Define the font-family for each label in the dropdown. Example: font-family: "Inconsolata" Define the content font-families that will be used in the text area. Following the example in the 3rd ponent: .ql-font-inconsolata { font-family: "Inconsolata";}
for more information visit link please.
本文标签: javascriptHow to add custom fonts to the QuillJS editorStack Overflow
版权声明:本文标题:javascript - How to add custom fonts to the QuillJS editor? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744292918a2599201.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论