概述
// 自定义字体大小
const Size = Quill.import('attributors/style/size')
Size.whitelist = [false, '12px', '14px', '16px', '18px', '20px', '32px']
Quill.register(Size, true)
// 自定义字体类型
const fonts = [false, 'SimSun', 'SimHei', 'Microsoft-YaHei', 'KaiTi', 'FangSong', 'Arial', 'Times-New-Roman', 'sans-serif',
'宋体', '黑体'
]
// const Font = Quill.import('formats/font') 不可用
const Font = Quill.import('attributors/style/font')
Font.whitelist = fonts
Quill.register(Font, true)
// 自定义字体大小
const Size = Quill.import('attributors/style/size')
Size.whitelist = [false, '12px', '14px', '16px', '18px', '20px', '32px']
Quill.register(Size, true)
// 自定义字体类型
const fonts = [false, 'SimSun', 'SimHei', 'Microsoft-YaHei', 'KaiTi', 'FangSong', 'Arial', 'Times-New-Roman', 'sans-serif',
'宋体', '黑体'
]
// const Font = Quill.import('formats/font') 不可用
const Font = Quill.import('attributors/style/font')
Font.whitelist = fonts
Quill.register(Font, true)
配置项
const toolbarOptions = [
['bold', 'italic', 'underline', 'strike'], // 加粗 斜体 下划线 删除线
['blockquote', 'code-block'], // 引用
代码块
[{ list: 'ordered' }, { list: 'bullet' }], // 有序、无序列表
[{ script: 'sub' }, { script: 'super' }], // 上标/下标
[{ indent: '-1' }, { indent: '+1' }], // 缩进
// [{ size: ['small', 'normal', 'large', 'huge'] }], // 字体大小
[{ size: Size.whitelist }], // 字体大小
[{ header: [1, 2, 3, 4, 5, 6, false] }], // 标题
[{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色
[{ font: Font.whitelist }], // 字体种类
[{ align: [] }], // 对齐方式
['clean'], // 清除文本格式
// ['link', 'image', 'video'] // 链接、图片、视频
['link', 'image'] // 链接、图片、视频
]
style
<style scoped lang='less'>
p {
margin: 10px;
}
.edit_container,
.quill-editor {
width: 1010px;
height: 460px;
}
/deep/ .ql-snow .ql-picker {
line-height: 24px;
}
/deep/ .ql-container {
height: 400px;
overflow: auto;
}
/deep/ .ql-snow .ql-picker.ql-size .ql-picker-label::before,
/deep/.ql-snow .ql-picker.ql-size .ql-picker-item::before {
content: "字号";
}
/deep/.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="12px"]::before,
/deep/.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="12px"]::before {
content: '12px';
}
/deep/.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="14px"]::before,
/deep/.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="14px"]::before {
content: "14px";
}
/deep/ .ql-snow .ql-picker.ql-size .ql-picker-label[data-value="16px"]::before,
/deep/ .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="16px"]::before {
content: "16px";
}
/deep/ .ql-snow .ql-picker.ql-size .ql-picker-label[data-value="18px"]::before,
/deep/ .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="18px"]::before {
content: "18px";
}
/deep/ .ql-snow .ql-picker.ql-size .ql-picker-label[data-value="20px"]::before,
/deep/ .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="20px"]::before {
content: "20px";
}
/deep/ .ql-snow .ql-picker.ql-size .ql-picker-label[data-value="32px"]::before,
/deep/ .ql-snow .ql-picker.ql-size .ql-picker-item[data-value="32px"]::before {content: "32px";
}
/deep/ .ql-snow .ql-picker.ql-header .ql-picker-label::before,
/deep/.ql-snow .ql-picker.ql-header .ql-picker-item::before {
content: "正文" !important;
}
/deep/ .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
/deep/.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before {
content: "标题1" !important;
}
/deep/ .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
/deep/.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before {
content: "标题2" !important;
}
/deep/ .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
/deep/.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before {
content: "标题3" !important;
}
/deep/ .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="4"]::before,
/deep/ .ql-snow .ql-picker.ql-header .ql-picker-item[data-value="4"]::before {
content: "标题4" !important;
}
/deep/ .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="5"]::before,
/deep/.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="5"]::before {
content: "标题5" !important;}
/deep/ .ql-snow .ql-picker.ql-header .ql-picker-label[data-value="6"]::before,
/deep/ .ql-snow .ql-picker.ql-header .ql-picker-item[data-value="6"]::before {
content: "标题6" !important;
}
/deep/ .ql-snow .ql-picker.ql-font .ql-picker-label::before,
/deep/ .ql-snow .ql-picker.ql-font .ql-picker-item::before {
content: "字体" !important;
}
/deep/.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="Arial"]::before,
/deep/.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="Arial"]::before {
content: "Arial" !important;
}
/deep/.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="SimSun"]::before,
/deep/.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="SimSun"]::before {
content: "SimSun" !important;
}
/deep/.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="SimHei"]::before,
/deep/.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="SimHei"]::before {
content: "SimHei" !important;
}
/deep/.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="Microsoft-YaHei"]::before,
/deep/.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="Microsoft-YaHei"]::before {
content: "微软雅黑" !important;
}
/deep/.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="Arial"]::before,
/deep/.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="Arial"]::before {
content: "Arial" !important;
}
/deep/.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="Times-New-Roman"]::before,
/deep/.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="Times-New-Roman"]::before {
content: "罗马" !important;
}
/deep/.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="KaiTi"]::before,
/deep/.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="KaiTi"]::before {
content: "楷体" !important;
}
/deep/.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="sans-serif"]::before,
/deep/.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="sans-serif"]::before {
content: "sans-serif" !important;
}
/deep/.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="宋体"]::before,
/deep/.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="宋体"]::before {
content: "宋体" !important;
}
/deep/.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="黑体"]::before,
/deep/.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="黑体"]::before {
content: "黑体" !important;
}
/deep/.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="FangSong"]::before,
/deep/.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="FangSong"]::before {
content: "仿宋" !important;
}
</style>
最后
以上就是默默电话为你收集整理的vue-quill-editor富文本编辑器自定义字体及字号的全部内容,希望文章能够帮你解决vue-quill-editor富文本编辑器自定义字体及字号所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复