我在 quill 中创建了一个自定义下拉菜单。我用羊皮纸
var Parchment = Quill.import('parchment');
var lineHeightConfig = {
scope: Parchment.Scope.INLINE,
whitelist: [
'1.0',
'5.0',
'10.0'
]
};
var lineHeightClass = new Parchment.Attributor.Class('lineheight', 'ql-line-height', lineHeightConfig);
var lineHeightStyle = new Parchment.Attributor.Style('lineheight', 'line-height', lineHeightConfig);
Parchment.register(lineHeightClass);
Parchment.register(lineHeightStyle);
我在视图中定义了我的编辑器:
<quill-editor #editor >
<div quill-editor-toolbar>
<!-- Basic buttons -->
<span class="ql-formats">
<button class="ql-bold" [title]="'Bold'"></button>
<button class="ql-italic" [title]="'Italic'"></button>
<button class="ql-underline" [title]="'Underline'"></button>
</span>
<span class="ql-formats">
<select class="ql-lineheight" [title]="'Line Height'">
<option selected></option>
<option value="1.0"></option>
<option value="5.0"></option>
<option value="10.0"></option>
</select>
</span>
</div>
</quill-editor>
我添加了一些 css 定义:
.ql-snow .ql-picker.ql-lineheight{
width: 58px;
}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value="1.0"]::before {content: "1.0";}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='1.0']::before {content: '1.0' !important;}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='5.0']::before {content: '5.0';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='5.0']::before {content: '5.0' !important;}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='10.0']::before {content: '10.0';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='10.0']::before {content: '10.0' !important;}
新的下拉菜单显示并正常工作,但标签仍为空。
这里是堆栈闪电战