Bugs:
- Ace问题, 还存在乱码问题 [ok]
- 普通下输入tab, ace有问题, 全都修改了 [ok]
修复:
问题1: Ace乱码
问题的原因是: 调用了tinymce.setContent()方法!! 这使得Ace失效!!
Selection.js有很多地方都到了setContent()方法来设置bookmark
解决方法:
修改Tinymce的setContent()方法 ? [根治]
Editor.js
setContent: function(content, args) { var self = this, body = self.getBody(), forcedRootBlockName; /** * life ace */ // 先destroy之前的ace var everContent = $(self.getBody()); if(everContent) { LeaAce.destroyAceFromContent(everContent); } // end // Setup args object args = args || {}; args.format = args.format || 'html'; args.set = true; args.content = content; // Do preprocessing if (!args.no_events) { self.fire('BeforeSetContent', args); } content = args.content; // 这里修改高度 // life-height // iframe父的高度是屏幕的高度, 定死. 而其内容包含title+iframe的高度, 很高 // 所以滑动会是title+iframe一起滑. // iframe的高度肯定是内容的高度度 resizeEditor(); // $("#editorContent_ifr").attr("src", "#1"); // 不做这样, scroll不启作用 // Padd empty content in Gecko and Safari. Commands will otherwise fail on the content // It will also be impossible to place the caret in the editor unless there is a BR element present if (content.length === 0 || /^\s+$/.test(content)) { forcedRootBlockName = self.settings.forced_root_block; // Check if forcedRootBlock is configured and that the block is a valid child of the body if (forcedRootBlockName && self.schema.isValidChild(body.nodeName.toLowerCase(), forcedRootBlockName.toLowerCase())) { content = ie && ie < 11 ? '' : '<br data-mce-bogus="1">'; content = self.dom.createHTML(forcedRootBlockName, self.settings.forced_root_block_attrs, content); } else if (!ie || ie < 11) { // We need to add a BR when forced_root_block is disabled on non IE browsers to place the caret content = '<br data-mce-bogus="1">'; } body.innerHTML = content; self.fire('SetContent', args); } else { // Parse and serialize the html var a = (self.parser.parse(content, {isRootContent: true})); if (args.format !== 'raw') { content = new Serializer({}, self.schema).serialize( self.parser.parse(content, {isRootContent: true}) ); } // Set the new cleaned contents to the editor args.content = trim(content); self.dom.setHTML(body, args.content); // Do post processing if (!args.no_events) { self.fire('SetContent', args); } // Don't normalize selection if the focused element isn't the body in // content editable mode since it will steal focus otherwise /*if (!self.settings.content_editable || document.activeElement === self.getBody()) { self.selection.normalize(); }*/ } /** * life ace */ if(LeaAce.canAce() && LeaAce.isAce) { try { LeaAce.initAceFromContent(self); } catch(e) { log(e); } } else { // 为了在firefox下有正常的显示 $("#editorContent pre").removeClass("ace-tomorrow ace_editor"); } // end return args.content; }
把UndoManager.js相关的LeaAce.undo()去掉.
问题2
与问题1类似, 将page.js的代码迁移到leanote_code plugin下, 无论是pre还是其它地方都插入空格.