javascript - CKEditor append child error -


with project on, have been asked move ckeditor 3 4. works fine except custom plugin wrote.

argument 1 of node.appendchild not object.

the code on place, , bit of mess. here plugin, think causing error.

    /* copyright (c) 2003-2011, cksource - frederico knabben. rights reserved. licensing, see license.html or http://ckeditor.com/license */  /**  * @fileoverview "limereplacementfields" plugin.  *  */  (function() {     var limereplacementfieldsreplaceregex = /(\{[a-z]+[^\{\}]+[a-z0-9]+\})/g;     ckeditor.plugins.add( 'limereplacementfields',     {         requires : [ 'dialog' ],         lang : [ 'en' ],         init : function( editor )         {             var lang = editor.lang.limereplacementfields;              editor.addcommand( 'createlimereplacementfields', new ckeditor.dialogcommand( 'createlimereplacementfields' ) );             editor.addcommand( 'editlimereplacementfields', new ckeditor.dialogcommand( 'editlimereplacementfields' ) );              editor.ui.addbutton( 'createlimereplacementfields',             {                 label : lang.title,                 command :'createlimereplacementfields',                 icon : this.path + 'limereplacementfields.gif'             });              if ( editor.addmenuitems )             {                 editor.addmenugroup( 'limereplacementfields', 20 );                 editor.addmenuitems(                     {                         editlimereplacementfields :                         {                             label : lang.title,                             command : 'editlimereplacementfields',                             group : 'limereplacementfields',                             order : 1,                             icon : this.path + 'limereplacementfields.gif'                         }                     } );                  if ( editor.contextmenu )                 {                     editor.contextmenu.addlistener( function( element, selection )                         {                             if ( !element || !element.data( 'cke-limereplacementfields' ) )                                 return null;                              return { editlimereplacementfields : ckeditor.tristate_off };                         } );                 }             }              editor.on( 'doubleclick', function( evt )                 {                     if ( ckeditor.plugins.limereplacementfields.getselectedplacehoder( editor ) )                         evt.data.dialog = 'editlimereplacementfields';                 });                editor.on( 'contentdom', function()                 {                     editor.document.getbody().on( 'resizestart', function( evt )                         {                             if ( editor.getselection().getselectedelement().data( 'cke-limereplacementfields' ) )                                 evt.data.preventdefault();                         });                 });              ckeditor.dialog.add( 'createlimereplacementfields', this.path + 'dialogs/limereplacementfields.js' );             ckeditor.dialog.add( 'editlimereplacementfields', this.path + 'dialogs/limereplacementfields.js' );         },         afterinit : function( editor )         {             var dataprocessor = editor.dataprocessor,                 datafilter = dataprocessor && dataprocessor.datafilter,                 htmlfilter = dataprocessor && dataprocessor.htmlfilter;              if ( datafilter )             {                 datafilter.addrules(                 {                     text : function( text )                     {                         return text.replace( limereplacementfieldsreplaceregex, function( match )                             {                                 return ckeditor.plugins.limereplacementfields.createlimereplacementfields( editor, null, match, 1 );                             });                     }                 });             }              if ( htmlfilter )             {                 htmlfilter.addrules(                 {                     elements :                     {                         'span' : function( element )                         {                             if ( element.attributes && element.attributes[ 'data-cke-limereplacementfields' ] )                                 delete element.name;                         }                     }                 });             }         },         onload: function(editor) {         ckeditor.addcss(                 '.cke_limereplacementfields' +                 '{' +                     'background-color: #ffff00;' +                     ( ckeditor.env.gecko ? 'cursor: default;' : '' ) +                 '}'             );         }     }); })();  ckeditor.plugins.setlang('limereplacementfields','en', {     limereplacementfields: {            title:sreplacementfieldtitle,         button:sreplacementfieldbutton     }     } );                          ckeditor.plugins.limereplacementfields = {     createlimereplacementfields : function( editor, oldelement, text, isget )     {         var element = new ckeditor.dom.element( 'span', editor.document );         element.setattributes(             {                 contenteditable     : 'false',                 'data-cke-limereplacementfields'    : 1,                 'class'         : 'cke_limereplacementfields'             }         );          text && element.settext( text );          if ( isget )             return element.getouterhtml();          if ( oldelement )         {             if ( ckeditor.env.ie )             {                 element.insertafter( oldelement );                 // time required ie before element removed.                 settimeout( function()                     {                         oldelement.remove();                         element.focus();                     }, 10 );             }             else                 element.replace( oldelement );         }         else             editor.insertelement( element );          return null;     },      getselectedplacehoder : function( editor )     {         var range = editor.getselection().getranges()[0];         range.shrink( ckeditor.shrink_text );         var node = range.startcontainer;         while( node && !( node.type == ckeditor.node_element && node.data( 'cke-limereplacementfields' ) ) )             node = node.getparent();         return node;     } }; 

turns out file altogether, had rewrite.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -