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 関数に非常に似ています。この関数は、選択したテキストをコンテナーにラップし、適切な色スタイル属性を割り当てます。