diff --git a/README.md b/README.md index 9b87809..5744ba1 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ simplemde.value("This text will appear in the editor"); - **code** Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````. - **italic** Can be set to `*` or `_`. Defaults to `*`. - **element**: The DOM element for the textarea to use. Defaults to the first textarea on the page. +- **forceSync**: If set to `true`, force text changes made in SimpleMDE to be immediately stored in original textarea. Defaults to `false`. - **hideIcons**: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar. - **indentWithTabs**: If set to `false`, indent using spaces instead of tabs. Defaults to `true`. - **initialValue**: If set, will customize the initial value of the editor. @@ -120,6 +121,7 @@ var simplemde = new SimpleMDE({ italic: "_" }, element: document.getElementById("MyID"), + forceSync: true, hideIcons: ["guide", "heading"], indentWithTabs: false, initialValue: "Hello world!", diff --git a/src/js/simplemde.js b/src/js/simplemde.js index e091ed3..e277dbf 100644 --- a/src/js/simplemde.js +++ b/src/js/simplemde.js @@ -1486,6 +1486,13 @@ SimpleMDE.prototype.render = function(el) { placeholder: options.placeholder || el.getAttribute("placeholder") || "" }); + if(options.forceSync === true) { + var cm = this.codemirror; + cm.on("change", function() { + cm.save(); + }); + } + this.gui = {}; if(options.toolbar !== false) {