OK, ich habe herausgefunden, wo die Verwirrung liegt.
TinyMCE-Versionen 3.x enthalten das advanced
Design, aber es wird nicht mit 4.0 geliefert, die ich verwende. Ich habe 3.x heruntergeladen und versuche das erweiterte Thema mit 4.0, aber es ist nicht kompatibel. Wordpress es scheint Schiffe mit 3.x, weshalb ich dachte, es war eine Wordpress-Option.
Für weitere Informationen (in der Hoffnung es jemand anderes hilft):
Es scheint jetzt, dass Sie die format_styles
und custom_formats
Optionen gegen den TinyMCE Editor zu verwenden, haben die Benutzer die Möglichkeit zu geben, Stile zu wählen. Ich habe Code geschrieben, der meine CSS-Datei analysiert, nach allen Klassen H2, 2 etc
, P
und A
sucht und diese Optionen auffüllt. Es ist ein langer Weg, aber es funktioniert sehr gut. Es ist schade, dass es keine Routine gibt.
endete ich CssParser mit dem folgenden Code unter Verwendung von bis (C# - Kopieren Einfügen wird nicht funktionieren, aber es sollte eine gute Anleitung geben, was zu tun):
//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(','));
}
Mein init-Code für style_formats
sieht aus wie diese (beachten sie, ich habe erneut hinzuzufügen löscht die Standardoptionen wie das hinzufügen etwas in style_format
es bestehende Liste
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"] %>]
}]
Mehr Informationen über die style_formats
Option finden sie hier:. TinyMCE Style Formats
+1 gute Frage – Thariama
@Thariama - Danke, ich habe die Verwirrung mit diesem herausgefunden und habe unten beantwortet. – webnoob