tinymce.init({
selector: "#id_Edit_HTML",
menubar: false, //
content_css: "Page/css/custom.css",
language: "zh_TW",
valid_elements : '*[*]',
extended_valid_elements : '*[*]',
entity_encoding : "raw",
force_br_newlines : false,
force_p_newlines : false,
forced_root_block : '',
paste_word_valid_elements: "b,strong,i,em,h1,h2,u,p,ol,ul,li,a[href],span,color,font-size,font-color,font-family,mark",
paste_retain_style_properties: "all",
codemirror: {
indentOnInit: true, // Whether or not to indent code on init.
fullscreen: true, // Default setting is false
path: 'CodeMirror', // Path to CodeMirror distribution
config: { // CodeMirror config object
mode: 'application/x-httpd-php',
lineNumbers: true,
indentUnit: 4,
//匹配括号
matchBrackets: true,
//匹配标签
matchTags: { bothTags: true },
indentWithTabs: false,
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
extraKeys: {"Ctrl-Q": function(cm){ cm.foldCode(cm.getCursor()); }}
},
width: 800, // Default value is 800
height: 600, // Default value is 550
saveCursorPosition: true, // Insert caret marker
cssFiles: [
'addon/fold/foldgutter.css'
],
jsFiles: [ // Additional JS files to load
'addon/edit/matchbrackets.js',
'addon/edit/matchtags.js',
'addon/fold/foldcode.js',
'addon/fold/foldgutter.js',
'addon/fold/brace-fold.js',
'addon/fold/xml-fold.js',
'mode/clike/clike.js',
'mode/php/php.js'
]
},
init_instance_callback : function(editor) {
// jw: this code is heavily borrowed from tinymce.jquery.js:12231 but modified so that it will
// just remove the escaping and not add it back.
editor.serializer.addNodeFilter('script,style', function(nodes, name) {
var i = nodes.length, node, value, type;
function trim(value) {
/*jshint maxlen:255 */
/*eslint max-len:0 */
return value.replace(/(<!--\[CDATA\[|\]\]-->)/g, '\n')
.replace(/^[\r\n]*|[\r\n]*$/g, '')
.replace(/^\s*((<!--)?(\s*\/\/)?\s*<!\[CDATA\[|(<!--\s*)?\/\*\s*<!\[CDATA\[\s*\*\/|(\/\/)?\s*<!--|\/\*\s*<!--\s*\*\/)\s*[\r\n]*/gi, '\n')
.replace(/\s*(\/\*\s*\]\]>\s*\*\/(-->)?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g, '\n');
}
while (i--) {
node = nodes[i];
value = node.firstChild ? node.firstChild.value : '';
if (value.length > 0) {
node.firstChild.value = trim(value);
}
}
});
},
setup: function (editor) {
editor.on('change', function () {
tinymce.triggerSave();
});
},
plugins: [
"advlist autolink lists link image charmap preview anchor visualblocks code fullscreen insertdatetime media table contextmenu paste autoresize textcolor fullpage nonbreaking codemirror"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image forecolor backcolor | code ",
paste_data_images: true
});