Simple WYSIWYG

Smiley error - Simple WYSIWYG

Smiley error

by gdub2 » Tue May 26, 2020 5:59 am

When quoting a post with a smiley, :lol: it throws error `Uncaught TypeError: Cannot read property 'children' of null ckeditor.js?assets_version=19:280`

unminified line 6193

Code: Select all

CKEDITOR.htmlParser.node.prototype = {
                remove: function() {
                   [color=#BF0000] var b = this.parent.children,[/color]
                        h = CKEDITOR.tools.indexOf(b, this),
                        a = this.previous,
                        k = this.next;
                    a && (a.next = k);
                    k && (k.previous = a);
                    b.splice(h, 1);
                    this.parent = null
                },
gdub2
Registered User
Posts: 3
Joined: Tue May 26, 2020 5:54 am
Contact:

Re: Smiley error

by gdub2 » Thu May 28, 2020 6:10 pm

it's sloppy, but i fixed it by replacing the smiley descriptions with img tags using replaceBulk function found on stackoverflow

Code: Select all

function replaceBulk( str, findArray, replaceArray ){
  var i, regex = [], map = {}; 
  for( i=0; i<findArray.length; i++ ){ 
    regex.push( findArray[i].replace(/([-[\]{}()*+?.\\^$|#,])/g,'\\$1') );
    map[findArray[i]] = replaceArray[i]; 
  }
  regex = regex.join('|');
  str = str.replace( new RegExp( regex, 'g' ), function(matched){
    return map[matched];
  });
  return str;
}

var replaces = [];
for(i=0;i<senky_simplewysiwyg_smiley_descriptions.length;i++){
	  replaces.push('[img]'+
	  	  	  senky_simplewysiwyg_smiley_path+
	  	  	  senky_simplewysiwyg_smiley_images[I]+
	  	  	  '[/img]');
}
$('#message').html(replaceBulk($('#message').html(),senky_simplewysiwyg_smiley_descriptions,replaces));
gdub2
Registered User
Posts: 3
Joined: Tue May 26, 2020 5:54 am
Contact: