Open bingomanatee opened 12 years ago
You shouldn't have to clear the localStorage and we don't use sessionStorage. importFile
will just overwrite what you have. The problem is you're trying to open
which puts content into the editor and the editor doesn't exist yet. You should actually see an error in your code above.
Try moving your load to above the open
and importFile
call like in my working example below:
http://jsbin.com/owirij/edit
@johnmdonahue maybe we should handle all local file stuff better. Maybe we should guard against the editor not being loaded and doing all the localStorage stuff still. There's no reason you should have to have the editor loaded to importFile or open file actually. Thoughts?
I'm going to mark this as a "bug" since it does make sense that you should be able to setup all this stuff before loading the editor.
I have put this code from your sample into my page
var editor = new EpicEditor({
basePath:"https://raw.github.com/OscarGodson/EpicEditor/develop/epiceditor/",
theme:{
base:"/themes/base/epiceditor.css",
preview:"/themes/preview/github.css",
editor:"/themes/editor/epic-light.css"
}});
editor.load();
editor.open('new');
editor.importFile('new', ' foo bar ');
but it only seems to work once; after that, the content continues to get sticky.
Is there any other bit of JS I can use to forcibly change the content, in the dom or the editor?
Dave
Hmm, I can't repro here. The JSBin link also doesn't reproduce what you're saying for me. Does the JSBin link do it for you? For me each refresh it says "foo bar" no matter what I put in there before. importFile
should overwrite what's ever there. Also, importFile
automatically opens the file so you should be able to get rid of that open line.
This is where it sets the text: https://github.com/OscarGodson/EpicEditor/blob/68997cba2bbaaf4c8b4ac44bfe03966ecee33d97/src/editor.js#L1091
It doesn't have any real logic just puts whatever you give it in there. Odd.
What browser, browser version, and OS are you on? Also can you make a test case that does what you say in JSBin or can you provide a link?
While not ideal, I found that lobotomizing all references to localStorage seems to obviate the problem.
I am working on my blog - it is all in local development but I should have it in a week or so at which point I'll push up a link.
Thanks for your help... Dave
I have put in (verbatim) what I see in your code
var editor = new EpicEditor({
basePath:"https://raw.github.com/OscarGodson/EpicEditor/develop/epiceditor/",
theme:{
base:"/themes/base/epiceditor.css",
preview:"/themes/preview/github.css",
editor:"/themes/editor/epic-light.css"
}});
editor.load();
editor.open('new');
editor.importFile('new', ' foo bar ');
So do you have the same issue at that JSBin link? If so what's your browser, version, and OS? I'm worried this is an actual bug of some kind. But yes, please send a link when you get a chance without your hacks that is a reproducible case
I should be fairly close to being able to show you working / nonworking examples.
On Sun, Jul 15, 2012 at 10:26 AM, Oscar Godson reply@reply.github.com wrote:
So do you have the same issue at that JSBin link? If so what's your browser, version, and OS? I'm worried this is an actual bug of some kind. But yes, please send a link when you get a chance without your hacks that is a reproducible case
Reply to this email directly or view it on GitHub: https://github.com/OscarGodson/EpicEditor/issues/152#issuecomment-6993290
Since it's been about 4 days I'm going to close this. If you can let me know if the JSBin link is a reproducible case or more info about the problem let me know and we can look into it more.
Actually, I take that back, I've updated the title. This is still a stub to make it so you can do file manipulation without needing to load the actual editor.
Lets see what happens when I take my project out of localhost.
I am having trouble clearing "History" from the epicEditor. Every time I return to the editor it has my old ocntent in it.
My code here:
doesn't do the trick - I'd expect to see "foo bar" but I see whatever I typed last visit.
How to ensure you are starting with a cherry entry field?
Thanks
Dave