hectorguo / CKEditor-Markdown-Plugin

Markdown Plugin for CKEditor
http://hectorguo.github.io/CKEditor-Markdown-Plugin/
112 stars 24 forks source link

Loading markdown data issue #4

Open deeg opened 8 years ago

deeg commented 8 years ago

Is there a way to load markdown data into the editor and then have it set to display in WYSIWYG mode?

I'm trying something like this:

        CKEDITOR.on( 'instanceReady', function( ev ) {
            ev.editor.setData("[link](http://google.com)")
            ev.editor.setMode("markdown");
            ev.editor.setMode("wysiwyg");
        });

This seems to throw errors:

Uncaught TypeError: Cannot read property 'toTextArea' of undefinedCKEDITOR.tools.createClass.proto.detach @ plugin.js:162CKEDITOR.editor.editable @ editable.js:1207CKEDITOR.editor.setMode @ themedui.js:195(anonymous function) @ sample.js:45 selection.js:500 Uncaught TypeError: Cannot read property 'getBody' of undefined

If I run these commands one at a time from the console after loading the page changing out ev for CKEDITOR.instances['instanceName'] it seems to work fine.

Sorry if I am missing something trivial.

dashtaki commented 7 years ago

hi @deeg I had this problem already but i used ckeditor in tiddlywiki.This error raised because in plugin.js LoadCodeMirror() not called and fromTextArea() not called consequently.Trace your code to find why ?

This work fine after page loading because CodeMirror loaded and above functions loads ...

I hope this help you.