代码之家  ›  专栏  ›  技术社区  ›  Honza Pokorny

在TinyMCE简单主题中将工具栏移到顶部

  •  12
  • Honza Pokorny  · 技术社区  · 16 年前

    如何在TinyMCE Simple主题中将工具栏移到顶部?谢谢

    3 回复  |  直到 16 年前
        1
  •  24
  •   Community Mohan Dere    6 年前

    注: 以下说明适用于TinyMCE 3.x。Tinymce4.x现在可用,您可能应该改用它。看到了吗 http://www.tinymce.com/wiki.php/Configuration 更多信息。


    theme : advanced theme_simple_toolbar_location 但是 theme_advanced_toolbar_location . 请参阅此处的文档 http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_toolbar_location .

    主题:高级 然后使用 theme_advanced_buttons_1_n 财产。这里有记录 http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_buttons_1_n .

    示例中的代码没有经过测试,但应该可以工作。它将显示一个编辑器,顶部有粗体、斜体和下划线按钮。

    tinyMCE.init({
      mode : "textareas",
      theme : "advanced",
      theme_advanced_toolbar_location : "top",
      theme_advanced_buttons1 : "bold,italic,underline",
      theme_advanced_buttons2 : "",
      theme_advanced_buttons3 : ""
    });
    

    所以答案是:使用时不能移动按钮 theme : simple

        2
  •  2
  •   Sotiris Adrian J. Moreno    15 年前

    为此,您必须编辑themes/simple文件夹中的编辑器\u template.js。

    下面是将工具栏置于顶部的更改代码。

    (function() {
        var a = tinymce.DOM;
        tinymce.ThemeManager.requireLangPack("simple");
        tinymce.create("tinymce.themes.SimpleTheme", {
            init: function(c, d) {
                var e = this,
                    b = ["Bold", "Italic", "Underline", "Strikethrough", "InsertUnorderedList", "InsertOrderedList"],
                    f = c.settings;
                e.editor = c;
                c.contentCSS.push(d + "/skins/" + f.skin + "/content.css");
                c.onInit.add(function() {
                    c.onNodeChange.add(function(h, g) {
                        tinymce.each(b, function(i) {
                            g.get(i.toLowerCase()).setActive(h.queryCommandState(i))
                        })
                    })
                });
                a.loadCSS((f.editor_css ? c.documentBaseURI.toAbsolute(f.editor_css) : "") || d + "/skins/" + f.skin + "/ui.css")
            },
            renderUI: function(h) {
                var e = this,
                    i = h.targetNode,
                    b, c, d = e.editor,
                    f = d.controlManager,
                    g, tbody;
                i = a.insertAfter(a.create("span", {
                    id: d.id + "_container",
                    "class": "mceEditor " + d.settings.skin + "SimpleSkin"
                }), i);
                i = g = a.add(i, "table", {
                    cellPadding: 0,
                    cellSpacing: 0,
                    "class": "mceLayout"
                });
                tbody = c = a.add(i, "tbody");
                i = b = a.add(a.add(i, "td"), "div", {
                    "class": "mceIframeContainer"
                });
                i = a.add(a.add(c, "tr", {
                    "class": "last"
                }), "td", {
                    "class": "mceToolbar mceLast",
                    align: "center"
                });
                c = e.toolbar = f.createToolbar("tools1");
                c.add(f.createButton("bold", {
                    title: "simple.bold_desc",
                    cmd: "Bold"
                }));
                c.add(f.createButton("italic", {
                    title: "simple.italic_desc",
                    cmd: "Italic"
                }));
                c.add(f.createButton("underline", {
                    title: "simple.underline_desc",
                    cmd: "Underline"
                }));
                c.add(f.createButton("strikethrough", {
                    title: "simple.striketrough_desc",
                    cmd: "Strikethrough"
                }));
                c.add(f.createSeparator());
                c.add(f.createButton("undo", {
                    title: "simple.undo_desc",
                    cmd: "Undo"
                }));
                c.add(f.createButton("redo", {
                    title: "simple.redo_desc",
                    cmd: "Redo"
                }));
                c.add(f.createSeparator());
                c.add(f.createButton("cleanup", {
                    title: "simple.cleanup_desc",
                    cmd: "mceCleanup"
                }));
                c.add(f.createSeparator());
                c.add(f.createButton("insertunorderedlist", {
                    title: "simple.bullist_desc",
                    cmd: "InsertUnorderedList"
                }));
                c.add(f.createButton("insertorderedlist", {
                    title: "simple.numlist_desc",
                    cmd: "InsertOrderedList"
                }));
                c.renderTo(i);
                i = c = a.add(i, "tbody");
                i = a.add(c, "tr");
                return {
                    iframeContainer: b,
                    editorContainer: d.id + "_container",
                    sizeContainer: g,
                    deltaHeight: -20
                }
            },
            getInfo: function() {
                return {
                    longname: "Simple theme",
                    author: "Moxiecode Systems AB",
                    authorurl: "http://tinymce.moxiecode.com",
                    version: tinymce.majorVersion + "." + tinymce.minorVersion
                }
            }
        });
        tinymce.ThemeManager.add("simple", tinymce.themes.SimpleTheme)
    })();
    
        3
  •  -3
  •   Dean Harding    16 年前
    tinyMCE.init({
        mode : "textareas",
        theme : "simple"
        theme_simple_toolbar_location : "top"
    });
    

    重要的一点是“工具栏位置”参数。