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

cant using textarea #311

Closed drayanaindra closed 10 years ago

drayanaindra commented 10 years ago

can you help me, how to enable textarea ? in API textarea i add id_content because my id textarea is it, but this value not worked.

OscarGodson commented 10 years ago

Without any code I cant help much. Could you post your EpicEditor code and maybe the HTML relevant to RpicEditor?

drayanaindra commented 10 years ago

this is my code, i following your tutorial

HTML `

`

JavaScript var opts = { container: 'epiceditor', textarea: 'id_content', basePath: 'epiceditor', clientSideStorage: true, localStorageName: 'epiceditor', useNativeFullscreen: true, parser: marked, file: { name: 'epiceditor', defaultContent: '', autoSave: 100 }, theme: { base: '/themes/base/epiceditor.css', preview: '/themes/preview/preview-dark.css', editor: '/themes/editor/epic-dark.css' }, button: { preview: true, fullscreen: true, bar: "auto" }, focusOnLoad: false, shortcut: { modifier: 18, fullscreen: 70, preview: 80 }, string: { togglePreview: 'Toggle Preview Mode', toggleEdit: 'Toggle Edit Mode', toggleFullscreen: 'Enter Fullscreen' }, autogrow: false } var editor = new EpicEditor(opts);

OscarGodson commented 10 years ago

Have you called .load() yet?

drayanaindra commented 10 years ago

i write this

var editor = new EpicEditor().load(opts); 

it right ? when i try it, browser console result error at line 1110.

OscarGodson commented 10 years ago

What's the error?

drayanaindra commented 10 years ago

error result is

`TypeError: callback.call is not a function

callback.call(this);`

OscarGodson commented 10 years ago

Couple things:

  1. You can remove the textarea: 'id_content'if the textarea is in the EpicEditor div. This is totally optional, but will automatically hide it for you too.
  2. load doesn't take opts, it takes a callback (why you're getting that error. You passed a JS hash, not a function). You pass the options to the constructor (EpicEditor(opts))

Examples from the API docs:

var editor = new EpicEditor(opts);
editor.load(function () {
  console.log("Editor loaded.")
});

So, putting those two things together, this would work:

var editor = new EpicEditor(opts);
editor.load(function () {
  console.log("Editor loaded.")
});

I also took your exact code and it works fine for me as long as I actually call .load() and pass options to the constructor. If you're still having problems feel free to post again and I can reopen.

drayanaindra commented 10 years ago

so, i can't using textarea?

because if i not using textarea, i can't get content.

OscarGodson commented 10 years ago

I'm sorry, I dont understand. Yes, you can use a textarea with EpicEditor. If you're still having issues with my code above post what's going on :)

drayanaindra commented 10 years ago

my form example

<form>
    <textarea name="content", id="id_content"></textarea>
</form>

i try like tutorial on your github documentation

<form>
    <div id="epiceditor">
        <textarea name="content" id="id_content"></textarea>
    </div>
</form>

and i following your opst Javascript like documentation in Github. but, when i try search content (as name of textarea) using firebug, the content is hide.

sorry, if i many ask. :)

OscarGodson commented 10 years ago

Like I mentioned above, EpicEditor will hide the textarea if you place it inside the EpicEditor div (and only if then) because normally people don't want to show a textarea and EpicEditor since EpicEditor is replacing the textarea and the textarea is synced (so as you type in EpicEditor you'll see text update in the textarea).

If you really want to show the textarea tho just pass in textarea: 'id_content' or whatever and that should override the default behavior and keep it there. Additionally, you can just place the textarea outside of the EpicEditor div like:

<form>
    <div id="epiceditor"></div>
    <textarea name="content" id="id_content"></textarea>
</form>