我正在尝试在Redactor编辑器中创建一个下拉列表。最大的问题是使用选定的字体系列围绕选定的文本创建一个容器。
到目前为止,我已经完成了自定义下拉菜单的基本设置:
$("#text_edit").redactor({
buttons: ['html', '|', 'bold', 'italic', 'deleted', '|', 'table', 'link', '|', 'fontcolor', 'backcolor', '|', 'fontfamily'],
buttonsCustom: {
fontfamily: {
title: "Select Font",
dropdown: {
Arial: {
title: 'Arial',
callback: insertFont
},
Georgia: {
title: 'Georgia',
callback: insertFont
}
}
}
}
});
function insertFont(obj, e, key)
{
// wrap selected text in <span> container with style attribute and selected font
}
事实上,所需的方法与内置的 fontcolor 函数非常相似,它也将选定的文本包装在一个容器中,并为其分配正确的颜色样式属性。