[英]How to make the hbs module of node.js retrieve info in HTML instead of plain text?
[英]Make js to print html instead of plain text
我为timymce4做了一个小插件,它添加了1个带有标题列表的下拉菜单(例如h1,h2 ...),所以我想做的就是打印这些具有核心样式的元素标题( <h1>Header H1</h1>
),而不是html,而是以纯文本格式获取。 我究竟做错了什么?
tinyMCE.PluginManager.add('headings', function(editor, url) {
['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].forEach(function(name){
editor.addMenuItem("headers_" + name, {
tooltip: "<"+name+">Заголовок</" + name+">",
text: "<"+name+">Заголовок</" + name+">",
onClick: function() { editor.execCommand('mceToggleFormat', false, name); },
onPostRender: function() {
var self = this, setup = function() {
editor.formatter.formatChanged(name, function(state) {
self.active(state);
});
};
editor.formatter ? setup() : editor.on('init', setup);
}
})
});
});
我哪里错了?
据我所知,TinyMCE不允许HTML菜单项,也不能通过addMenuItem进行 ,或者至少我无法找到任何有案可查的案例(上述方法的params描述非常没用) 。 取而代之的是,您可能对以下内容感兴趣,它允许设置新的样式格式并自动处理它们的显示方式-尽管我确定一定是可以的,但我无法在“格式”按钮中找到如何创建子菜单的方法。可能:
<script type="text/javascript">
tinymce.init({
selector: "textarea",
style_formats: [
{title: 'Bold text', inline: 'b'},
{title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
{title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
{title: 'Example 1', inline: 'span', classes: 'example1'},
{title: 'Example 2', inline: 'span', classes: 'example2'},
{title: 'Table styles'},
{title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
]
});
</script>
<form method="post" action="dump.php">
<textarea name="content"></textarea>
</form>
http://fiddle.tinymce.com/uaeaab
如果您仍对实现自己的定制方法添加HTML代码到菜单感兴趣,我相信您可以为上述style_formats
设置找到TinyMCE的实现方式。 但是,根据我对这些JavaScript编辑器的经验,许多更“高级”的API功能会经常更改。 通常最好坚持记录的更高级别的API调用和设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.