add ability to set up markup for bold and italic

pull/185/head
Adam Misiorny 9 years ago
parent 42c4a0bbef
commit abedc7371d

@ -82,6 +82,9 @@ simplemde.value("This text will appear in the editor");
- image
- link
- table
- **blockStyles**: Customize how certain buttons that style blocks of text behave.
- **bold** Can be set to `**` or `__`. Defaults to `**`
- **italic** Can be set to `*` or `_`. Defaults to `*`
- **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`.
- **parsingConfig**: Adjust settings for parsing the Markdown during editing (not previewing).
- **allowAtxHeaderWithoutSpace**: If set to `true`, will render headers without a space after the `#`. Defaults to `false`.

@ -171,7 +171,7 @@ function toggleFullScreen(editor) {
* Action for toggling bold.
*/
function toggleBold(editor) {
_toggleBlock(editor, "bold", "**");
_toggleBlock(editor, "bold", editor.options.blockStyles.bold);
}
@ -179,7 +179,7 @@ function toggleBold(editor) {
* Action for toggling italic.
*/
function toggleItalic(editor) {
_toggleBlock(editor, "italic", "*");
_toggleBlock(editor, "italic", editor.options.blockStyles.italic);
}
@ -802,6 +802,10 @@ var insertTexts = {
horizontalRule: ["", "\n\n-----\n\n"]
};
var blockStyles = {
"bold": "**",
"italic": "*"
};
/**
* Interface of SimpleMDE.
@ -878,6 +882,10 @@ function SimpleMDE(options) {
options.insertTexts = extend({}, insertTexts, options.insertTexts || {});
// Merging the blockStyles, with the given options
options.blockStyles = extend({}, blockStyles, options.blockStyles || {});
// Change unique_id to uniqueId for backwards compatibility
if(options.autosave.unique_id != undefined && options.autosave.unique_id != "")
options.autosave.uniqueId = options.autosave.unique_id;

Loading…
Cancel
Save