From 053ad27d8a98851490a201ca8e464d909d48b9ea Mon Sep 17 00:00:00 2001 From: Kyle White Date: Wed, 26 Oct 2016 23:01:22 -0500 Subject: [PATCH] Adding a button type attribute in the option property passed to the editor component. --- example/src/example.js | 3 ++- src/MDEditor.js | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/example/src/example.js b/example/src/example.js index a1d55dd..854f481 100644 --- a/example/src/example.js +++ b/example/src/example.js @@ -16,11 +16,12 @@ var App = React.createClass({ }, render () { var preview = marked(this.state.code); + var options = { buttonType: 'button' }; return (
The editor is below, with default options. This example also uses marked to generate the preview on the right as you type.
- +
diff --git a/src/MDEditor.js b/src/MDEditor.js index e769288..d8ea5a1 100644 --- a/src/MDEditor.js +++ b/src/MDEditor.js @@ -99,9 +99,13 @@ var MarkdownEditor = React.createClass({ }, ('MDEditor_toolbarButton--' + formatKey)); var labelClass = isTextIcon ? 'MDEditor_toolbarButton_label-icon' : 'MDEditor_toolbarButton_label'; - + + //Button type will default to submit if not specified, + // which can cause issues when this editor is embedded in a form. + var buttonType = this.getOptions().buttonType || 'button'; + return ( -