如何向tinyMCE添加标题(h1,h2...)按钮,具有高级主题,简单布局?
我有一个使用高级主题的tinyMCE 编辑器。我在该高级主题上使用简单布局,因此我可以在 init() 上定义自己的工具栏,而不必太深入了解tinyMCE正在做什么。
我遇到的问题是我的编辑器没有用于添加标题元素的按钮。我迫切需要这个选择,但找不到关于这个主题的实用建议。
我所做的一切都发生在tinymce.init()函数内,我将其粘贴在下面:
$("textarea.tinymce").not(".simple").tinymce({
script_url : "/_lib/script/tiny_mce/tiny_mce.js",
plugins : "wordcount,paste,spellchecker,table",
theme : "advanced",
theme_advanced_layout_manager : "SimpleLayout",
theme_advanced_statusbar_location : "bottom",
theme_advanced_toolbar_location : "top",
theme_advanced_buttons1
: "bold,italic,underline,strikethrough,|,sub,sup,|,charmap,|,forecolorpicker",
theme_advanced_buttons2
: "undo,redo,|,cut,copy,pastetext,pasteword,|,link,unlink,anchor,|,image,code",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_align : "left",
height : 480,
apply_source_formatting : false,
convert_fonts_to_spans : true
});
我正在使用jquery插件来访问tinyMCE(我确信这与我的问题无关,但它解释了代码)。
我的一个想法是使用 theme_advanced_styles 选项,但我不认为这将允许我插入实际的标题标签,而只是使用 span 和其他东西来设置我的标记的样式,使其看起来像标题。
任何想法都非常感激。 干杯, J
I have a tinyMCE editor which uses the advanced theme. I am using the simple layout on that advanced theme so I can define my own toolbars on init() without having to get too deep into what tinyMCE is doing.
The problem I have is that my editor doesn't have buttons for adding heading elements. I am desperately in need of this option but can find no practical advice on the subject.
Everything I'm doing happens inside the tinymce.init() function, which I have pasted below:
$("textarea.tinymce").not(".simple").tinymce({
script_url : "/_lib/script/tiny_mce/tiny_mce.js",
plugins : "wordcount,paste,spellchecker,table",
theme : "advanced",
theme_advanced_layout_manager : "SimpleLayout",
theme_advanced_statusbar_location : "bottom",
theme_advanced_toolbar_location : "top",
theme_advanced_buttons1
: "bold,italic,underline,strikethrough,|,sub,sup,|,charmap,|,forecolorpicker",
theme_advanced_buttons2
: "undo,redo,|,cut,copy,pastetext,pasteword,|,link,unlink,anchor,|,image,code",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_align : "left",
height : 480,
apply_source_formatting : false,
convert_fonts_to_spans : true
});
I am using the jquery plugin to access tinyMCE ( I'm sure this has nothing to do with my question but it explains the code ).
One idea I had was to use the theme_advanced_styles option but I don't think this will allow me to insert actual heading tags, but rather just style my markup with spans and whatnot to look like a header.
Any ideas greatly appreciated.
Cheers,
J
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个可以从段落中创建标题的按钮。将“formath1”添加到您的按钮列表并将其添加到您的tinymce init
Here is a button which will make a heading1 out of a paragraph. Add 'formath1' to your buttonlist and add this to your tinymce init
添加具有隐式样式的标题和其他元素可以通过
formatselect
和theme: 'advanced'
实例的theme_advanced_buttons_[1-3]
列表添加:我多余地包含了默认值只是为了演示,但是 TinyMCE Wiki 声明,自 2010-10-28 可以减少或添加此元素列表,元素包括:
Adding headings and other elements with implicit styling can be added via
formatselect
withtheme: 'advanced'
instances'theme_advanced_buttons_[1-3]
list:I superfluously-included the default values just for demonstration but the TinyMCE Wiki states that, since 2010-10-28 this element list can be reduced or added to with elements including:
我发现 标题插件 是解决这个问题的完美解决方案。接受的答案也可以。我们发现的唯一问题是,当光标位于标题时,标题按钮不会显示为活动状态,因此再次按下该按钮以恢复格式变得不直观。标题插件正确显示活动状态。
I found the heading plugin to be just a perfect solution for this problem. The accepted answer works ok, too. The only issue we found is that the heading button does not appear active when your cursor is at a heading, thus making it non-intuitive that you can press the button again to revert the formatting. The heading plugin correctly displays an active state.