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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ The name of the buttons are as follows
- Ordered List = cmdList0
- Code = cmdCode
- Quote = cmdQuote
- Equation = cmdEquation
32 changes: 32 additions & 0 deletions lib/codemwnci/bootstrap-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,38 @@
}
}

// Set the cursor
e.setSelection(cursor,cursor+chunk.length)
}
},
{
name: 'cmdEquation',
hotkey: 'Ctrl+E',
title: 'Equation',
icon: { glyph: 'glyphicon glyphicon-superscript', fa: 'fa fa-superscript', 'fa-3': 'icon-superscript' },
callback: function(e) {

// Give/remove ** surround the selection
var chunk, cursor, selected = e.getSelection(), content = e.getContent()

if (selected.length == 0) {
// Give extra word
chunk = e.__localize('LaTeX equation here')
} else {
chunk = selected.text
}

// transform selection and set the cursor into chunked text
if (content.substr(selected.start-1,1) == '\\\\['
&& content.substr(selected.end,1) == '\\\\]' ) {
e.setSelection(selected.start+1,selected.end+1)
e.replaceSelection(chunk)
cursor = selected.start-1
} else {
e.replaceSelection('\\\\['+chunk+'\\\\]')
cursor = selected.start+3
}

// Set the cursor
e.setSelection(cursor,cursor+chunk.length)
}
Expand Down