如何仅在源代码中使用 TinyMCE? TinyMCE 将任何数据转换为 HTML 并显示它。我需要在不转换的情况下使用 BBCode,仅源代码。我在 Google 中找不到任何相关信息。
最佳答案
我想你想像 phpBB post表单一样使用 TinyMCE。即点击粗体,它显示[b]text[/b]
而不是粗体的格式化文本。
据我所知,您不能通过设置使用 TinyMCE 执行此操作。您将需要编写自己的函数。
tinyMCE.init({
theme_advanced_buttons1 : "mybold",
setup : function(ed) {
ed.addButton('mybold', {
title : 'bold',
image : 'img/example.gif',
onclick : function() {
// Add you own code to execute something on click
ed.focus();
ed.selection.setContent("[b]" + ed.selection.getContent() + '[/b]');
}
});
}
});
两个或三个代码很酷。如果你要为每个 bbcode 都这样做,那就太麻烦了。
如果您不打算利用 TinyMCE 的任何优势,您最好编写自己的代码来操作 <textarea>
并避免加载 TinyMCE JS。它会更轻。
关于javascript - 仅 TinyMCE 源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12034454/