OscarGodson / EpicEditor

EpicEditor is an embeddable JavaScript Markdown editor with split fullscreen editing, live previewing, automatic draft saving, offline support, and more. For developers, it offers a robust API, can be easily themed, and allows you to swap out the bundled Markdown parser with anything you throw at it.
http://epiceditor.com
MIT License
4.25k stars 334 forks source link

EpicEditor markdown content. #271

Closed ganlub closed 11 years ago

ganlub commented 11 years ago

Hi, I'm trying to get the epiceditor content form JS, but I'm doing: var content = editor.exportFile(); $("#content").val(content);

or var content = (editor.getElement('editor').body.innerText);

but the content it's plagued of \r\n, something like this: ***\r\n#Title\r\n## Hola\r\n### text

How can I get the clean content to save it on a file through php. Thank you very much, and congrats for the nice project!

OscarGodson commented 11 years ago

Can you share what browser and epiceditor version you're on? Its very strange its exporting hidden characters like that. Never seen that before.

ganlub commented 11 years ago

Hey! I'm using Chromium 28.0.1500.52 on Ubuntu 13.04 and Firefox 22.0, and the epiceditor version was the 0.2.1.1. I attach you the php that contains the EE file on pastebin: http://pastebin.com/etATdVhx.

Thank you very much!

OscarGodson commented 11 years ago

I wonder if it has to do with the hidden input? Couple questions:

  1. Does console.log(editor.exportFile()) show those characters?
  2. If you change the #content (the hidden input) to a textarea, do those characters still appear?
  3. Most likely not, but gotta ask ;) you didn't type \r\n right?
ganlub commented 11 years ago
  1. the console.log don't show the characters (http://db.tt/krEZ1QUq)
  2. OMG, it doesn't show the characters too (http://db.tt/5vUHdqEJ)
  3. Haha, definitely no!

So... it's the Php part, if i remove the $mysqli->real_escape_string($_POST['content']) and I leave it as $_POST['content'] it works!! Thank you for teach me how to debug more logically and found the mistakes by my self!!!!

OscarGodson commented 11 years ago

No worries! Good luck :)

ganlub commented 11 years ago

Hi! I have another trouble, now I'm trying to load a .md file on the editor, but I dunno what I'm doing wrong because I'm getting just '#Editing article' and nothing else, and on the console I can't see nothing.

$("#datepicker").change(function() {
    if($("#datepicker").val()!='<?php echo Date("Y-m-d"); ?>'){
            //editor.open('press/Readme.md');
            editor.importFile('press/Readme.md',"#Editing article")
            alert("Changed!");
        }

});

Thank you!

OscarGodson commented 11 years ago

Are you trying to load a file on your computer or server? If so, this is a client side JS framework. Client side JS doesn't have access to your file system. If you want that file to be accessible in EpicEditor's file storage you need to write to it like

Then, in your JS you'd have access to the content.

ganlub commented 11 years ago

I'm trying to load the file form the server, it changed the way as what you said, but it doesn't work. The demoFunc() returns a markdown file content:

editor.importFile('Readme.md', '<? echo $managePress->demoFunc(); ?>');

Something it's going wrong and I don't know where.

OscarGodson commented 11 years ago

What does console.log(editor.exportFile('Readme.md')) log out?

OscarGodson commented 11 years ago

After importfile, of course

ganlub commented 11 years ago

the console log is printing me exactly $managePress->demoFunc(), because I did editor.importFile('Readme.md', '<? echo '$managePress->demoFunc()'; ?>');

OscarGodson commented 11 years ago

Do you not have PHP running? PHP should replace that right? I don't really do PHP, so I'm not sure why your PHP is working but EpicEditor is returning the content you gave it.

n00dles commented 11 years ago

Remove the quotes around the echo