Add help icon, Add shortcut note to tooltip, Add preview shortcut

pull/23/head
Wes Cossick 9 years ago
parent 8f1c54b7dd
commit 6c3baad29b

@ -7,7 +7,8 @@ var shortcuts = {
'Cmd-Alt-I': drawImage, 'Cmd-Alt-I': drawImage,
"Cmd-'": toggleBlockquote, "Cmd-'": toggleBlockquote,
'Cmd-Alt-L': toggleOrderedList, 'Cmd-Alt-L': toggleOrderedList,
'Cmd-L': toggleUnOrderedList 'Cmd-L': toggleUnOrderedList,
'Cmd-P': togglePreview,
}; };
@ -31,19 +32,15 @@ function createIcon(name, options, enableTooltips) {
options = options || {}; options = options || {};
var el = document.createElement('a'); var el = document.createElement('a');
enableTooltips = (enableTooltips == undefined) ? true : enableTooltips; enableTooltips = (enableTooltips == undefined) ? true : enableTooltips;
var shortcut = options.shortcut || shortcuts[name]; if (options.title && enableTooltips) {
if (shortcut) { el.title = options.title;
shortcut = fixShortcut(shortcut);
el.title = shortcut;
el.title = el.title.replace('Cmd', '⌘');
if (isMac) { if (isMac) {
el.title = el.title.replace('Ctrl', '⌘');
el.title = el.title.replace('Alt', '⌥'); el.title = el.title.replace('Alt', '⌥');
} }
} }
if(options.title && enableTooltips)
el.title = options.title;
el.className = options.className || 'icon-' + name; el.className = options.className || 'icon-' + name;
return el; return el;
@ -395,55 +392,62 @@ function wordCount(data) {
var toolbar = [{ var toolbar = [{
name: 'bold', name: "bold",
action: toggleBold, action: toggleBold,
className: "fa fa-bold", className: "fa fa-bold",
title: "Bold", title: "Bold (Ctrl+B)",
}, },
{ {
name: 'italic', name: "italic",
action: toggleItalic, action: toggleItalic,
className: "fa fa-italic", className: "fa fa-italic",
title: "Italic", title: "Italic (Ctrl+I)",
}, },
'|', "|",
{ {
name: 'quote', name: "quote",
action: toggleBlockquote, action: toggleBlockquote,
className: "fa fa-quote-left", className: "fa fa-quote-left",
title: "Quote", title: "Quote (Ctrl+')",
}, },
{ {
name: 'unordered-list', name: "unordered-list",
action: toggleUnOrderedList, action: toggleUnOrderedList,
className: "fa fa-list-ul", className: "fa fa-list-ul",
title: "Generic List", title: "Generic List (Ctrl+L)",
}, },
{ {
name: 'ordered-list', name: "ordered-list",
action: toggleOrderedList, action: toggleOrderedList,
className: "fa fa-list-ol", className: "fa fa-list-ol",
title: "Numbered List", title: "Numbered List (Ctrl+Alt+L)",
}, },
'|', "|",
{ {
name: 'link', name: "link",
action: drawLink, action: drawLink,
className: "fa fa-link", className: "fa fa-link",
title: "Create Link", title: "Create Link (Ctrl+K)",
}, },
{ {
name: 'image', name: "image",
action: drawImage, action: drawImage,
className: "fa fa-picture-o", className: "fa fa-picture-o",
title: "Insert Image", title: "Insert Image (Ctrl+Alt+I)",
}, },
'|', "|",
{ {
name: 'preview', name: "preview",
action: togglePreview, action: togglePreview,
className: "fa fa-eye", className: "fa fa-eye",
title: "Toggle Preview", title: "Toggle Preview (Ctrl+P)",
},
"|",
{
name: "guide",
action: "http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide",
className: "fa fa-question-circle",
title: "Markdown Guide",
}]; }];
/** /**

Loading…
Cancel
Save