Skip to content
This repository has been archived by the owner on May 9, 2018. It is now read-only.

Replace EpicEditor with SimpleMDE #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ JSONEditor.plugins = {
ace: {
theme: ''
},
epiceditor: {
SimpleMDE: {

},
sceditor: {
Expand Down
35 changes: 13 additions & 22 deletions src/editors/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({
if(this.sceditor_instance) {
this.sceditor_instance.val(sanitized);
}
else if(this.epiceditor) {
this.epiceditor.importFile(null,sanitized);
else if(this.SimpleMDE) {
this.SimpleMDE.value(sanitized);
}
else if(this.ace_editor) {
this.ace_editor.setValue(sanitized);
Expand Down Expand Up @@ -318,25 +318,16 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({
self.onChange(true);
});
}
// EpicEditor for markdown (if it's loaded)
else if (this.input_type === 'markdown' && window.EpicEditor) {
this.epiceditor_container = document.createElement('div');
this.input.parentNode.insertBefore(this.epiceditor_container,this.input);
this.input.style.display = 'none';

options = $extend({},JSONEditor.plugins.epiceditor,{
container: this.epiceditor_container,
clientSideStorage: false
// SimpleMDE for markdown (if it's loaded)
else if (this.input_type === 'markdown' && window.SimpleMDE) {
options = $extend({},JSONEditor.plugins.SimpleMDE,{
element: this.input
});

this.epiceditor = new window.EpicEditor(options).load();

this.epiceditor.importFile(null,this.getValue());

this.epiceditor.on('update',function() {
var val = self.epiceditor.exportFile();
self.input.value = val;
self.value = val;

this.SimpleMDE = new window.SimpleMDE((options));

this.SimpleMDE.codemirror.on("change",function() {
self.value = self.SimpleMDE.value();
self.is_dirty = true;
self.onChange(true);
});
Expand Down Expand Up @@ -388,8 +379,8 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({
if(this.sceditor_instance) {
this.sceditor_instance.destroy();
}
else if(this.epiceditor) {
this.epiceditor.unload();
else if(this.SimpleMDE) {
this.SimpleMDE.destroy();
}
else if(this.ace_editor) {
this.ace_editor.destroy();
Expand Down