Skip to content
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
9 changes: 7 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
"authors": [
"Ignacio de Tomás <[email protected]>"
],
"keywords": ["markdown", "bootstrap", "editor", "ace"],
"keywords": [
"markdown",
"bootstrap",
"editor",
"ace"
],
"license": "MIT",
"ignore": [
"**/.*",
Expand All @@ -14,6 +19,6 @@
],
"dependencies": {
"bootstrap": "~3.3.1",
"ace-builds": "~1.1.8"
"ace-builds": "^1.2.6"
}
}
2 changes: 1 addition & 1 deletion dist/css/bootstrap-markdown-editor.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/js/bootstrap-markdown-editor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions src/bootstrap-markdown-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@
},
readOnly: false
});

editor.commands.addCommand({
name: 'code',
bindKey: {win: 'Ctrl-Y', mac: 'Command-Y'},
exec: function (editor) {
var selectedText = editor.session.getTextRange(editor.getSelectionRange());

if (selectedText === '') {
snippetManager.insertSnippet(editor, '```\n${1:text}\n```');
} else {
snippetManager.insertSnippet(editor, '```\n' + selectedText + '\n```');
}
},
readOnly: false
});
}

function insertBeforeText (editor, string) {
Expand Down Expand Up @@ -132,6 +147,12 @@
html += '<div class="btn-group">';
html += '<button type="button" data-mdtooltip="tooltip" title="' + options.label.btnList + '" class="md-btn btn btn-sm btn-default" data-btn="ul"><span class="glyphicon glyphicon glyphicon-list"></span></button>';
html += '<button type="button" data-mdtooltip="tooltip" title="' + options.label.btnOrderedList + '" class="md-btn btn btn-sm btn-default" data-btn="ol"><span class="glyphicon glyphicon-th-list"></span></button>';
if (options.code === true) {
html += '<button type="button" data-mdtooltip="tooltip" title="' + options.label.btnCode + '" class="md-btn btn btn-sm btn-default" data-btn="code"><span class="glyphicon glyphicon-console"></span></button>';
}
if (options.quote === true) {
html += '<button type="button" data-mdtooltip="tooltip" title="' + options.label.btnQuote + '" class="md-btn btn btn-sm btn-default" data-btn="quote"><span class="glyphicon glyphicon-comment"></span></button>';
}
html += '</div>'; // .btn-group

html += '<div class="btn-group">';
Expand Down Expand Up @@ -291,6 +312,9 @@
} else if (btnType === 'ol') {
insertBeforeText(editor, '1.');

} else if (btnType === 'quote') {
insertBeforeText(editor, '>');

} else if (btnType === 'bold') {
editor.execCommand('bold');

Expand All @@ -300,6 +324,9 @@
} else if (btnType === 'link') {
editor.execCommand('link');

} else if (btnType === 'code') {
editor.execCommand('code');

} else if (btnType === 'image') {
if (selectedText === '') {
snippetManager.insertSnippet(editor, '![${1:text}](http://$2)');
Expand Down Expand Up @@ -413,6 +440,8 @@
btnItalic: 'Italic',
btnList: 'Unordered list',
btnOrderedList: 'Ordered list',
btnCode: 'Code',
btnQuote: 'Quote',
btnLink: 'Link',
btnImage: 'Insert image',
btnUpload: 'Upload image',
Expand Down