From ad158872de3972ed325e895e2d5fd71a63b933a4 Mon Sep 17 00:00:00 2001 From: Alec Fenichel Date: Fri, 2 Sep 2016 15:55:16 -0400 Subject: [PATCH 1/2] Replace EpicEditor with SimpleMDE --- src/defaults.js | 2 +- src/editors/string.js | 34 +++++++++++----------------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/defaults.js b/src/defaults.js index 81760fc06..46e7aee56 100644 --- a/src/defaults.js +++ b/src/defaults.js @@ -209,7 +209,7 @@ JSONEditor.plugins = { ace: { theme: '' }, - epiceditor: { + SimpleMDE: { }, sceditor: { diff --git a/src/editors/string.js b/src/editors/string.js index 826589874..ddecdc923 100644 --- a/src/editors/string.js +++ b/src/editors/string.js @@ -35,9 +35,6 @@ 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.ace_editor) { this.ace_editor.setValue(sanitized); } @@ -318,25 +315,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); }); @@ -388,8 +376,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(); From 8bbe3f0592a09f306e5089731760816bc5d97917 Mon Sep 17 00:00:00 2001 From: Alec Fenichel Date: Fri, 19 May 2017 09:05:28 -0400 Subject: [PATCH 2/2] Fix disappearing text when moving block, credit @xmiao --- src/editors/string.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/editors/string.js b/src/editors/string.js index ddecdc923..ab7a9de5f 100644 --- a/src/editors/string.js +++ b/src/editors/string.js @@ -35,6 +35,9 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({ if(this.sceditor_instance) { this.sceditor_instance.val(sanitized); } + else if(this.SimpleMDE) { + this.SimpleMDE.value(sanitized); + } else if(this.ace_editor) { this.ace_editor.setValue(sanitized); }