2013-06-19 10 views
10

私は、ユーザーがリンク、段落などにそれらを適用できるように、クラスのリストを含むドロップダウンリストを作成する過程にあります。advancedテーマがこれをサポートしているので、私はこのテーマをダウンロードする場所を見つけることができません。TinyMCE先進的テーマ - どこにいますか?

先進的なテーマは、Wordpressのダウンロードのみに含まれていますが、それを使用できるフォーマットではないことがわかったので、この時点でのみWordpressです。

何か不足していますか?

+1

+1良い質問 – Thariama

+0

@Thariama - ありがとう、私はこれと混乱を見つけ出し、以下に答えました。 – webnoob

答えて

15

OK、どこに混乱があるのか​​分かりました。

TinyMCEバージョン3.xにはadvancedテーマが含まれていますが、使用している4.0では出荷されていません。私は3.xをダウンロードし、4.0で高度なテーマを試しましたが、互換性はありません。それは私がそれがWordpressの唯一のオプションだと思った理由です。詳細については

(それは他の誰かに役立ちます願って):

あなたがユーザーにスタイルを選択する機能を提供するためにTinyMCEのエディタに対するformat_stylescustom_formatsオプションを使用する必要があることになりましたようです。 CSSファイルを解析し、H2, 2 etcPAのクラスをすべて探し、これらのオプションを設定します。長い道のりですが、うまくいきます。箱入りのルーチンがないのは残念です。

私は(C#の - コピーこれは動作しません貼り付けて、それが何をすべきかの良いガイドを与える必要があります)次のコードでCssParserを使用して終了:style_formatsため

//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(',')); 
} 

マイ初期化コードは次のようになりますこの(ノート、私はstyle_formatに何かを追加するなど、デフォルトのオプションを再度追加する必要があり、それは、既存のですクリアリスト

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"] %>] 
}] 
style_formatsオプションの

詳しい情報はここで見つけることができます:。TinyMCE Style Formats

+2

あなたのソリューションを共有するための+1 – Thariama

関連する問題