OK, tôi đã phát hiện ra sự nhầm lẫn nằm ở đâu.
Phiên bản TinyMCE 3.x chứa chủ đề advanced
nhưng không được giao với 4.0 mà tôi đang sử dụng. Tôi đã tải xuống 3.x và thử chủ đề nâng cao với 4.0 nhưng nó không tương thích. Wordpress có vẻ như tàu với 3.x đó là lý do tại sao tôi nghĩ rằng nó là một lựa chọn duy nhất wordpress.
Để biết thêm thông (hy vọng nó sẽ giúp người khác):
Có vẻ như bây giờ mà bạn phải sử dụng các tùy chọn format_styles
và custom_formats
so với biên tập TinyMCE để cung cấp cho người dùng khả năng để lựa chọn phong cách. Tôi đã viết một số mã phân tích tệp CSS của tôi, tìm tất cả các lớp H2, 2 etc
, P
và A
và điền các tùy chọn đó. Đó là chặng đường dài nhưng nó hoạt động rất tốt. Nó chỉ là một sự xấu hổ không có ra khỏi thói quen hộp.
tôi đã kết thúc bằng CssParser với đoạn mã sau (C# - Sao chép dán này sẽ không làm việc nhưng nó sẽ cho một hướng dẫn tốt về những gì để làm):
//Declared so we can deserialise into JSON
public class CustomFormat
{
public string title;
public string selector;
public string classes;
}
private void BuildTinyMCECSS()
{
List<string> AllowedTags = new List<string> { "p", "a", "h1", "h2", "h3", "h4", "h5", "h6" };
CssParser StyleSheet = new CssParser();
StyleSheet.AddStyleSheet("MyPath/Styles.css");
//1: Only in our allowed tags. 2: Isn't a pseudo class. 3: Is a class of one of the allowed tags.
foreach (KeyValuePair<string, StyleClass> Style in StyleSheet.Styles.Where(n => AllowedTags.Any(a => n.Key.StartsWith(a) && !n.Key.Contains(':') && n.Key.Contains('.'))))
{
CustomFormat CF = new CustomFormat();
CF.title = Style.Key;
CF.selector = Style.Key.Substring(0, Str.IndexOf('.'));
CF.classes = Style.Key.Substring(Style.Key.IndexOf('.') + 1);
//Note: CCUtils is a static class I use for utilities. Any code to deserialise will work
string JS = String.Format("{1},", Style.Key, CCUtils.SerializeToStringJSON(CF, typeof(CustomFormat)));
Session["JS"] += JS;
}
//Remove the spare comma at the end (ie won't like it)
Session["JS"] = Session["JS"].ToString().Substring(0, Session["JS"].ToString().LastIndexOf(','));
}
mã init của tôi cho style_formats
trông giống như này (lưu ý, tôi phải làm lại thêm các tùy chọn mặc định như thêm bất cứ điều gì vào style_format
xóa nó hiện danh sách
style_formats:
[{
title: "Headers",
items: [{title: "Header 1",format: "h1"}, {title: "Header 2",format: "h2"}, {title: "Header 3",format: "h3"}, {title: "Header 4",format: "h4"}, {title: "Header 5",format: "h5"}, {title: "Header 6",format: "h6"}]},
{title: "Inline",items: [{title: "Bold",icon: "bold",format: "bold"}, {title: "Italic",icon: "italic",format: "italic"},
{title: "Underline",icon: "underline",format: "underline"}, {title: "Strikethrough",icon: "strikethrough",format: "strikethrough"}, {title: "Superscript",icon: "superscript",format: "superscript"}, {title: "Subscript",icon: "subscript",format: "subscript"}, {title: "Code",icon: "code",format: "code"}]},
{title: "Blocks",items: [{title: "Paragraph",format: "p"}, {title: "Blockquote",format: "blockquote"}, {title: "Div",format: "div"}, {title: "Pre",format: "pre"}]},
{title: "Alignment",items: [{title: "Left",icon: "alignleft",format: "alignleft"}, {title: "Center",icon: "aligncenter",format: "aligncenter"}, {title: "Right",icon: "alignright",format: "alignright"}, {title: "Justify",icon: "alignjustify",format: "alignjustify"}]},
{
title: "Classes", items: [<%= Session["JS"] %>]
}]
thông tin thêm về các tùy chọn style_formats
có thể được tìm thấy ở đây:. TinyMCE Style Formats
+1 câu hỏi hay – Thariama
@Thariama - Cảm ơn, tôi đã phát hiện ra sự nhầm lẫn với điều này và đã trả lời dưới đây. – webnoob