有關此錯誤的任何建議或解決方法?
http://dev.ckeditor.com/ticket/6436
我真的需要解決這個bug,因爲我需要在CKEditor的編輯器區域中用一個退格刪除整個div。但在插入divs嵌套由於錯誤。所以,刪除個人divs變得不可能。ckeditor bug嵌套divs bug的解決方法?
1
A
回答
1
這裏是解決辦法,我終於designed-- http://thecamelcase.com/2011/06/reining-in-the-cursor-in-ckeditor/
1
我遇到同樣的問題,不幸的是鏈接到由ghostCoder所做的修復不再可用。
除了嵌套的div問題,我們已經強制粘貼爲純文本(所以數據被粘貼爲純文本,除非使用「粘貼從單詞」),我們正在使用div作爲我們的enterMode。在粘貼的數據行中,中斷被替換爲< br/>標籤,而我們希望每行都是元素內的包裝。
這是我們最終解決問題的方法。您應該知道我們沒有更改autoParagraph config option,因此它默認爲true,我不建議在配置級別禁用它。我會嘗試對此解決方案進行編碼評論,以便您瞭解這裏實際完成的內容。
config.on.instanceReady = function(e) {
var enterMode = e.editor.config.enterMode, elem = 'div';
if(enterMode === CKEDITOR.ENTER_P) {
elem = 'p';
}
// We didn't encounter any issues when using br as enterMode so
// continue only if enterMode is div or p element
if(enterMode === CKEDITOR.ENTER_DIV || enterMode === CKEDITOR.ENTER_P) {
// Disable autoParagraph in initialization to avoid nested div issue.
// When autoParagraph is manipulated this way it will still be active
// later on so if you write some inline content in source mode it
// will be properly wrapped inside <p> or <div> element.
e.editor.config.autoParagraph = false;
// Handle paste event to get rid of <br /> line breaks issue
e.editor.on('paste', function(evt) {
var data = '';
// Stop event, handle everything here manually
evt.stop();
// Get data either from event's text or html property
if(evt.data.text) {
// Remove HTML markup from pasted data
data = evt.data.text.replace(/(<([^>]+)>)/ig, '');
// Replace all line breaks with </div><div> or </p><p> markup
// And wrap the whole content inside <div> or <p> element
data = '<' + elem + '>'
+ data.replace(/\r\n|\r|\n/g, '</' + elem + '><' + elem + '>')
+ '</' + elem + '>';
} else {
// If data was not pasted as plain text just
// get data as is from event's html property
data = evt.data.html;
}
// Insert HTML data to editor
evt.editor.insertHtml(data);
// Fire afterPaste manually as we have stopped the event
// and afterPaste wouldn't get triggered otherwise
evt.editor.fire('afterPaste');
}, e.editor.element.$);
}
};
相關問題
- 1. Object.assign bug解決方法
- 2. 關於Runc的bug的解決方法
- 3. tinymce的解決方法utf8 bug
- 4. Mono的解決方法PrivateFontCollection.AddFontFile bug
- 5. 解決Mathematica Notation bug的方法?
- 6. 解決WPF Freezable bug的方法?
- 7. Shellshock Bash bug預加載解決方法
- 8. IMAP Php bug - 解決方法是什麼?
- 9. 是否有解決maven-javadoc-plugin bug MJAVADOC-414的解決方法?
- 10. Hibernate的bug,如何解決?
- 11. 解決Zend日期DST Bug
- 12. 解決不同版本的Python bug
- 13. 解決的bug在javascript - 標籤功能
- 14. AngularJS:需要解決空陣列的bug
- 15. Aquamacs 2.4 - WordWrap/Visual Line Mode - bug解決方法?
- 16. Cython:嵌套式typedefs的解決方法
- 17. PHP 7 SSH2.SFTP stat()bug解決
- 18. 我該如何解決python-social-auth Bug?
- 19. 如何解決GWT CellTree消失(bug)?
- 20. 如何解決IE 7的bug(Windows調整與GWT應用程序的bug)
- 21. 解決方法嵌套while - >獲取
- 22. SQLiteDatabase嵌套事務和解決方法
- 23. JAVA 8u77類加載器的bug - 尋找一個解決辦法
- 24. 方框代替字母 - asp.net bug,如何解決?
- 25. FireFox嵌入框 - 影子bug
- 26. 使用JQuery刪除瀏覽器重繪Bug的解決方法DeleteClass
- 27. 的Bug
- 28. 定位嵌套divs
- 29. 簡單的嵌套XSLT解決方案
- 30. 數獨求解器bug