Javascript 如何使用epiceditor打开文件?
我有以下文件结构 在content.php中,我有以下JS代码Javascript 如何使用epiceditor打开文件?,javascript,epiceditor,Javascript,Epiceditor,我有以下文件结构 在content.php中,我有以下JS代码 var file = "http://2sense.net/blog/posts/my-second-post.md" var opts = { basePath: "http://2sense.net/blog/posts/", container: 'epiceditor', textarea: null, base
var file = "http://2sense.net/blog/posts/my-second-post.md"
var opts = {
basePath: "http://2sense.net/blog/posts/",
container: 'epiceditor',
textarea: null,
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
},
focusOnLoad: false,
shortcut: {
modifier: 18,
fullscreen: 70,
preview: 80
},
string: {
togglePreview: 'Toggle Preview Mode',
toggleEdit: 'Toggle Edit Mode',
toggleFullscreen: 'Enter Fullscreen'
}
}
window.editor = new EpicEditor(opts);
editor.load(function () {
console.log("Editor loaded.")
});
$("#openfile").on("click", function() {
console.log("openfile");
editor.open(file);
editor.enterFullscreen();
})
当我尝试用“editor.open(file);”打开文件时,不会发生任何事情。我已经确认,当我按下按钮时,事件已被触发。
你知道如何解决这个问题吗,或者你有一个真实的例子。。。epiceditor网站上的API文档并没有说太多
Cheers客户端JS无法打开桌面文件(或者,不容易或跨浏览器)。这将是一个很好的特性,可以与文件API一起使用,但尚未实现。EpicEditor将“文件”存储在本地存储中。当您执行
editor.open('foo')
时,您基本上是在执行:JSON.parse(localStorage['epiceditor'])['foo'].content
。这已经被问了好几次了,所以我做了一张记录,以便在文档中更清楚地说明这一点
这有用吗
另外,我们欢迎您提交对您有意义的文档请求:)谢谢您,奥斯卡!任何其他“已知”的解决方案都可以实现这一点吗?使用您的后端lang像
编辑器那样写入它。导入($filename,$content)
,或者像$一样使用ajax。get('/path/to/file.md',function(data){editor.importFile('file',data)})