EpicEditor文字显示为  而不是空间

sw0*_*w00 2 html javascript mako web.py epiceditor

不知道这是本身的实际问题,但我使用史诗编辑器输入和保存降价在我的GAE应用(webpy灰鲭鲨作为模板引擎).

我在表单中有一个隐藏的输入元素,当我提交表单时,EpicEditor的内容会填充,但所有的空格都被替换 .这是预期的功能吗?如果我在EpicEditor网站上检查相同的代码,它显然会返回空格而不是 那么我的不同之处是什么?

<form>
<!-- form elements -->
<input id="content" name="content" type="hidden" value></input>
<div id="epiceditor"></div>
<button type="submit" name="submit" id="submit">submit</button>
</form>

<script type="text/javascript">
    $('button#submit').click(function(){
        var content = editor.getElement('editor').body.innerHTML; //all the spaces are returned as &nbsp; and breaks are <br>
        $('input#content').html(content);
    });
</script>
Run Code Online (Sandbox Code Playgroud)

注意:我想在我的数据存储的TextProperty字段中将我的内容保存为markdown,并在使用marked.js检索它时生成html标记

Osc*_*son 5

我是EpicEditor的创造者.你不应该得到innerHTML.在你写的时候,EpicEditor对innerHTML没有任何作用.您看到的文本和代码在所有浏览器之间会有所不同,而且contenteditable字段的工作方式也不同.例如,某些浏览器会为某些空格插入UTF-8字符&nbsp.

EpicEditor为您提供了标准化文本的方法.您不应该尝试手动解析文本.

$('button#submit').click(function(){
    var content = editor.exportFile();
    $('input#content').html(content);
});
Run Code Online (Sandbox Code Playgroud)

更多详细信息exportFile:http://epiceditor.com/#exportfilefilenametype

PS您不需要输入#content.这和#content一样:)