闲来无事,把 B3log Solo 所用编辑器 TinyMCE 从 3.3.9.2 升级到了 3.4.3.2。结果出现了2个问题。
可能由于我没看 changelog 所致吧。因为实在太多了,人又懒,结果。。。
1. 使用“编辑 HTML 源代码”功能,标签中无内容(如:<a class=’text’></a>)将会被移除。
修改文件:tiny_mce/themes/advanced/js/source_editor.js
saveContent() 中
tinyMCEPopup.editor.setContent(document.getElementById('htmlSource').value, {sorce_view: true});
改为
tinyMCEPopup.editor.setContent(document.getElementById('htmlSource').value, {format : 'raw'});
onLoadInit() 中
document.getElementById('htmlSource').value = tinyMCEPopup.editor.getContent({sorce_view: true});
改为
document.getElementById('htmlSource').value = tinyMCEPopup.editor.getContent({format : 'raw'});
2. 使用 SyntaxHighLighter 插入 html 代码,不会进行高亮。
修改文件:tiny_mce/plugins/syntaxhl/syntaxhl.js
unescapeHtml(text) 中
return text;
改为
return text.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");
escapeHtml(text) 中
return text;
改为
return text.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
3. 高亮插件 SyntaxHighlighter 在 Chrome 中出现纵向滚动条,且右边框看不见。
修改文件:SyntaxHighlighter/styles/*.css
.syntaxhighlighter {
width: 100% !important;
margin: 1em 0 1em 0 !important;
position: relative !important;
overflow-x: auto !important;
font-size: 1em !important;
}
改为
.syntaxhighlighter {
width: auto;
margin: 1em 0 1em 0 !important;
position: relative !important;
overflow-x: auto;
overflow-y: hidden;
font-size: 1em !important;
}