Search code examples
javascripthtmleditorepiceditor

Set dynamic value on EpicEditor


I am using a EpicEditor. Below is the code through which I am initializing by epiceditor:

 var opts = {
    container: 'epiceditor',
    textarea: null,
    theme: {
        base: '/themes/base/epiceditor.css',
        preview: '/themes/preview/github.css',
        editor: '/themes/editor/epic-light.css'
    },
    basePath: '/epiceditor',
    clientSideStorage: false
}
var editor = new EpicEditor(opts);
editor.load();

I have some value which I am fetching from database and want to show on the epicedior. I am new to the epicEditor and no idea how to do that. Can somebody help me on this! Any expert on EpicEditor!!!


Solution

  • Try to set "textarea" property to the textarea field id from where you want to sync contents to EpicEditor.

    I have my configuration something like this:

    var opts = {
        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'
        }
    }
    var editor = new EpicEditor(opts);
    

    You can check more APIs here.