0

我有以下文件结构

在此处输入图像描述

在 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,
          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 文档并没有说太多。

干杯

4

1 回答 1

1

客户端 JS 无法打开桌面文件(或者,不容易或跨浏览器)。这将是与 File API 一起使用的一个不错的功能,但尚未实现。EpicEditor 将“文件”存储在 localStorage 中。当你这样做时editor.open('foo'),你基本上是在做:JSON.parse(localStorage['epiceditor'])['foo'].content. 这已经被问过几次了,所以我做了一张票,以便在文档中更清楚地说明这一点。

https://github.com/OscarGodson/EpicEditor/issues/276

这有帮助吗?

PS 一个对你有意义的文档的拉取请求总是受欢迎的:)

于 2013-08-07T20:45:17.117 回答