son-dh / mudim

Automatically exported from code.google.com/p/mudim
0 stars 0 forks source link

Lỗi với WYSIWYG editors trên Chrome #70

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Khi cài WYSIWYG editor cho phpBB và test trên Chrome thì nó hay bị 
nhảy về đầu dòng trong khi gõ (bất kể kiểu gõ).

Cũng forum và editor đó trên IE và Firefox thì không bị.

Original issue reported on code.google.com by m...@ndthuan.com on 7 Feb 2012 at 6:41

GoogleCodeExporter commented 9 years ago
It seems that there is a problem with Range Object in CHIM.HTMLEditor.Process
 function when running on Chrome. I've replaced the content of CHIM.HTMLEditor.Process
 with one then it fixed this issue.

// Function: CHIM.HTMLEditor.Process
//----------------------------------------------------------------------------
CHIM.HTMLEditor.Process = function(target, l) {
    var sel = window.getSelection();
        var range = CHIM.HTMLEditor.GetRange(target);
        if (typeof(range)=='undefined') {
                return;
        }
        var b = CHIM.buffer;
        if (!window.opera && document.all) {
                var x = -l;
                range.moveStart('character', x);
                range.moveEnd('character', x+b.length);
                range.pasteHTML(b.toString().replace(/,/g,''));
                return;
        }
        var container = range.startContainer;
        var offset = range.startOffset;
        var start = offset - l;
        container.nodeValue = container.nodeValue.substring(0, start) +
                b.toString().replace(/,/g,'') + container.nodeValue.substring(start + l);
        if (l<b.length) {offset++;}
        range.setEnd(container, offset);
        range.setStart(container, offset);
    sel.removeAllRanges();
    sel.addRange(range);
};

Hope that this problem fixed in the next release of mudim and chim.

Original comment by testing2...@gmail.com on 1 Mar 2012 at 9:35

GoogleCodeExporter commented 9 years ago
Thanks for the fix.

Your code had a minor bug due to window.getSelection(), that function is not 
supported by IE prior to v9. A simple fix:

var sel = window.getSelection ? window.getSelection() : 
document.selection.createRange();

Original comment by m...@ndthuan.com on 27 Mar 2012 at 7:18

GoogleCodeExporter commented 9 years ago
Hi, 

Is this patch existed in latest release?

Original comment by huynhca...@gmail.com on 10 May 2012 at 5:18

GoogleCodeExporter commented 9 years ago
Fixed ở r161, cám ơn bạn testing2410

Original comment by mud...@gmail.com on 9 May 2013 at 3:58

GoogleCodeExporter commented 9 years ago

Original comment by mud...@gmail.com on 9 May 2013 at 4:07