CKEditor createFakeParserElement: writeHtml is not a function

Posted by Phil Sturgeon on Stack Overflow See other posts from Stack Overflow or by Phil Sturgeon
Published on 2010-05-13T11:32:00Z Indexed on 2010/05/13 11:34 UTC
Read the original article Hit count: 568

Filed under:
|
|

I am trying to write a plugin for CKEditor that is basically just a iframe with PHP content. The user browses around, selects the video they want and then they click insert.

The problem is that I need to create a "fake element" for this video, as inserting a video directly seems to show up as a Flash object, and we need to make it look a little different.

I have copied together some code from the Flash plugin.js (remember this is all undocumented and uncommented) and so far come up with this:

function insertFakeElement( html )
{
    editor = window.parent.instance;

    var realElement = CKEDITOR.dom.element.createFromHtml( html );

    var fakeElement = editor.createFakeParserElement( realElement, 'cke_video', 'object', true ),
        fakeStyle = fakeElement.attributes.style || '';

    var width = realElement.attributes.width,
        height = realElement.attributes.height;

    if ( typeof width != 'undefined' )
        fakeStyle = fakeElement.attributes.style = fakeStyle + 'width:' + cssifyLength( width ) + ';';

    if ( typeof height != 'undefined' )
        fakeStyle = fakeElement.attributes.style = fakeStyle + 'height:' + cssifyLength( height ) + ';';

    editor.insertHTML(fakeElement.getHtml());
}

The line "giving me jip" is:

var fakeElement = editor.createFakeParserElement( realElement, 'cke_video', 'object', true ),

It errors here saying:

l.writeHtml is not a function
[Break on this error] if(o)o.addRules(l);}});})();a.editor.p..."',o,'_text"

The .js file is minified and I have no idea how the source files all fit together so I can't track down the cause of this error.

Does anybody know what I am doing wrong?

© Stack Overflow or respective owner

Related posts about ckeditor

Related posts about JavaScript