刚刚开始使用史诗编辑器与 rails 结合,这就是我目前所拥有的:
更改 basePath 和主题、预览、编辑器路径。
defaults = { container: 'epiceditor'
, basePath: '/assets'
, textarea: 'content-input'
, clientSideStorage: true
, localStorageName: 'epiceditor'
, useNativeFullscreen: true
, file: { name: null
, defaultContent: ''
, autoSave: 100 // Set to false for no auto saving
}
, theme: { base: '/epiceditor.css'
, preview: '/github.css'
, editor: '/epic-style.css'
}
如果您使用 simple_form gem,您可以将其添加到您的表单中:
<%= f.input :content, label: false, input_html: {id: "content-input"}, as: :hidden%>
<div id="epiceditor"></div>
然后在您的 epiceditor.js 文件中将 textarea 更改为 textarea: 'content-input'(textarea id),以便它与隐藏的 textarea 同步。
function EpicEditor(options) {
// Default settings will be overwritten/extended by options arg
var self = this
, opts = options || {}
, _defaultFileSchema
, _defaultFile
, defaults = { container: 'epiceditor'
, basePath: '/assets'
, textarea: 'content-input'
, clientSideStorage: true
, localStorageName: 'epiceditor'
, useNativeFullscreen: true
, file: { name: null
默认同步/导出是文本,将其更改为 'html'
_syncTextarea = function () {
self._textareaElement.value = self.exportFile(textareaFileName, 'html', true) || self.settings.file.defaultContent;
}
当然加载脚本
<script type="text/javascript">
var editor = new EpicEditor().load();
</script>