This commit is contained in:
WittBulter 2017-01-17 15:16:52 +08:00
parent ca6b87f016
commit 827300b1ed
6 changed files with 4248 additions and 3559 deletions

View File

@ -1,25 +1,25 @@
{ {
"rules": { "rules": {
"indent": [ // "indent": [
2, // 2,
"tab" // "tab"
], // ],
"strict": 0, "strict": 0,
"no-console": 0, "no-console": 0
"quotes": [ // "quotes": [
2, // 2,
"double" // "double"
], // ],
"semi": [ // "semi": [
2, // 2,
"always" // "never"
] // ]
}, },
"env": { "env": {
"browser": true, "browser": true,
"node":true "node":true
}, },
"extends": "eslint:recommended", // "extends": "eslint:recommended",
"parserOptions": { "parserOptions": {
"ecmaVersion": 6, "ecmaVersion": 6,
"sourceType": "module" "sourceType": "module"

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

18
dist/simplemde.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -11,7 +11,7 @@ export default class Action {
/** /**
* Action for toggling bold. * Action for toggling bold.
*/ */
static toggleBold (editor){ static toggleBold (editor){
Base.toggleBlock(editor, "bold", editor.options.blockStyles.bold); Base.toggleBlock(editor, "bold", editor.options.blockStyles.bold);
} }
@ -27,12 +27,12 @@ export default class Action {
*/ */
static drawLink (editor){ static drawLink (editor){
const cm = editor.codemirror; const cm = editor.codemirror;
const stat = getState(cm); const stat = Base.getState(cm);
const options = editor.options; const options = editor.options;
let url = "http://"; let url = "http://";
if(options.promptURLs) { if (options.promptURLs){
url = prompt(options.promptTexts.link); url = prompt(options.promptTexts.link);
if(!url) { if (!url){
return false; return false;
} }
} }
@ -63,9 +63,9 @@ export default class Action {
const stat = Base.getState(cm); const stat = Base.getState(cm);
const options = editor.options; const options = editor.options;
let url = "http://"; let url = "http://";
if(options.promptURLs) { if (options.promptURLs){
url = prompt(options.promptTexts.image); url = prompt(options.promptTexts.image);
if(!url) { if (!url){
return false; return false;
} }
} }
@ -102,9 +102,9 @@ export default class Action {
static toggleCodeBlock (editor){ static toggleCodeBlock (editor){
let fenceCharsToInsert = editor.options.blockStyles.code; let fenceCharsToInsert = editor.options.blockStyles.code;
const fencing_line = line => { const fencing_line = line =>{
/* return true, if this is a ``` or ~~~ line */ /* return true, if this is a ``` or ~~~ line */
if(typeof line !== "object") { if (typeof line !== "object"){
throw "fencing_line() takes a 'line' object (not a line number, or line text). Got: " + typeof line + ": " + line; throw "fencing_line() takes a 'line' object (not a line number, or line text). Got: " + typeof line + ": " + line;
} }
return line.styles && line.styles[2] && line.styles[2].indexOf("formatting-code-block") !== -1; return line.styles && line.styles[2] && line.styles[2].indexOf("formatting-code-block") !== -1;
@ -115,7 +115,7 @@ export default class Action {
return token.state.base.base || token.state.base; return token.state.base.base || token.state.base;
} }
const code_type = (cm, line_num, line = cm.getLineHandle(line_num), firstTok, lastTok) => { const code_type = (cm, line_num, line = cm.getLineHandle(line_num), firstTok, lastTok) =>{
/* /*
* Return "single", "indented", "fenced" or false * Return "single", "indented", "fenced" or false
* *
@ -130,31 +130,31 @@ export default class Action {
line: line_num, line: line_num,
ch: line.text.length - 1 ch: line.text.length - 1
})); }));
let types = firstTok.type ? firstTok.type.split(" ") : []; let types = firstTok.type? firstTok.type.split(" "): [];
if(lastTok && token_state(lastTok).indentedCode) { if (lastTok && token_state(lastTok).indentedCode){
// have to check last char, since first chars of first line aren"t marked as indented // have to check last char, since first chars of first line aren"t marked as indented
return "indented"; return "indented";
} else if(types.indexOf("comment") === -1) { } else if (types.indexOf("comment") === -1){
// has to be after "indented" check, since first chars of first indented line aren"t marked as such // has to be after "indented" check, since first chars of first indented line aren"t marked as such
return false; return false;
} else if(token_state(firstTok).fencedChars || token_state(lastTok).fencedChars || fencing_line(line)) { } else if (token_state(firstTok).fencedChars || token_state(lastTok).fencedChars || fencing_line(line)){
return "fenced"; return "fenced";
} else { } else{
return "single"; return "single";
} }
} }
const insertFencingAtSelection = (cm, cur_start, cur_end, fenceCharsToInsert) => { const insertFencingAtSelection = (cm, cur_start, cur_end, fenceCharsToInsert) =>{
let start_line_sel = cur_start.line + 1, let start_line_sel = cur_start.line + 1,
end_line_sel = cur_end.line + 1, end_line_sel = cur_end.line + 1,
sel_multi = cur_start.line !== cur_end.line, sel_multi = cur_start.line !== cur_end.line,
repl_start = fenceCharsToInsert + "\n", repl_start = fenceCharsToInsert + "\n",
repl_end = "\n" + fenceCharsToInsert; repl_end = "\n" + fenceCharsToInsert;
if(sel_multi) { if (sel_multi){
end_line_sel++; end_line_sel++;
} }
// handle last char including \n or not // handle last char including \n or not
if(sel_multi && cur_end.ch === 0) { if (sel_multi && cur_end.ch === 0){
repl_end = fenceCharsToInsert + "\n"; repl_end = fenceCharsToInsert + "\n";
end_line_sel--; end_line_sel--;
} }
@ -179,10 +179,12 @@ export default class Action {
is_code = code_type(cm, cur_start.line, line, tok); is_code = code_type(cm, cur_start.line, line, tok);
let block_start, block_end, lineCount; let block_start, block_end, lineCount;
if(is_code === "single") { if (is_code === "single"){
// similar to some SimpleMDE _toggleBlock logic // similar to some SimpleMDE _toggleBlock logic
let start = line.text.slice(0, cur_start.ch).replace("`", ""), let start = line.text.slice(0, cur_start.ch)
end = line.text.slice(cur_start.ch).replace("`", ""); .replace("`", ""),
end = line.text.slice(cur_start.ch)
.replace("`", "");
cm.replaceRange(start + end, { cm.replaceRange(start + end, {
line: cur_start.line, line: cur_start.line,
ch: 0 ch: 0
@ -191,19 +193,19 @@ export default class Action {
ch: 99999999999999 ch: 99999999999999
}); });
cur_start.ch--; cur_start.ch--;
if(cur_start !== cur_end) { if (cur_start !== cur_end){
cur_end.ch--; cur_end.ch--;
} }
cm.setSelection(cur_start, cur_end); cm.setSelection(cur_start, cur_end);
cm.focus(); cm.focus();
} else if(is_code === "fenced") { } else if (is_code === "fenced"){
if(cur_start.line !== cur_end.line || cur_start.ch !== cur_end.ch) { if (cur_start.line !== cur_end.line || cur_start.ch !== cur_end.ch){
// use selection // use selection
// find the fenced line so we know what type it is (tilde, backticks, number of them) // find the fenced line so we know what type it is (tilde, backticks, number of them)
for(block_start = cur_start.line; block_start >= 0; block_start--) { for (block_start = cur_start.line; block_start >= 0; block_start--){
line = cm.getLineHandle(block_start); line = cm.getLineHandle(block_start);
if(fencing_line(line)) { if (fencing_line(line)){
break; break;
} }
} }
@ -215,88 +217,88 @@ export default class Action {
let start_text, start_line; let start_text, start_line;
let end_text, end_line; let end_text, end_line;
// check for selection going up against fenced lines, in which case we don't want to add more fencing // check for selection going up against fenced lines, in which case we don't want to add more fencing
if(fencing_line(cm.getLineHandle(cur_start.line))) { if (fencing_line(cm.getLineHandle(cur_start.line))){
start_text = ""; start_text = "";
start_line = cur_start.line; start_line = cur_start.line;
} else if(fencing_line(cm.getLineHandle(cur_start.line - 1))) { } else if (fencing_line(cm.getLineHandle(cur_start.line - 1))){
start_text = ""; start_text = "";
start_line = cur_start.line - 1; start_line = cur_start.line - 1;
} else { } else{
start_text = fence_chars + "\n"; start_text = fence_chars + "\n";
start_line = cur_start.line; start_line = cur_start.line;
} }
if(fencing_line(cm.getLineHandle(cur_end.line))) { if (fencing_line(cm.getLineHandle(cur_end.line))){
end_text = ""; end_text = "";
end_line = cur_end.line; end_line = cur_end.line;
if(cur_end.ch === 0) { if (cur_end.ch === 0){
end_line += 1; end_line += 1;
} }
} else if(cur_end.ch !== 0 && fencing_line(cm.getLineHandle(cur_end.line + 1))) { } else if (cur_end.ch !== 0 && fencing_line(cm.getLineHandle(cur_end.line + 1))){
end_text = ""; end_text = "";
end_line = cur_end.line + 1; end_line = cur_end.line + 1;
} else { } else{
end_text = fence_chars + "\n"; end_text = fence_chars + "\n";
end_line = cur_end.line + 1; end_line = cur_end.line + 1;
} }
if(cur_end.ch === 0) { if (cur_end.ch === 0){
// full last line selected, putting cursor at beginning of next // full last line selected, putting cursor at beginning of next
end_line -= 1; end_line -= 1;
} }
cm.operation(function() { cm.operation(function (){
// end line first, so that line numbers don't change // end line first, so that line numbers don't change
cm.replaceRange(end_text, { cm.replaceRange(end_text, {
line: end_line, line: end_line,
ch: 0 ch: 0
}, { }, {
line: end_line + (end_text ? 0 : 1), line: end_line + (end_text? 0: 1),
ch: 0 ch: 0
}); });
cm.replaceRange(start_text, { cm.replaceRange(start_text, {
line: start_line, line: start_line,
ch: 0 ch: 0
}, { }, {
line: start_line + (start_text ? 0 : 1), line: start_line + (start_text? 0: 1),
ch: 0 ch: 0
}); });
}); });
cm.setSelection({ cm.setSelection({
line: start_line + (start_text ? 1 : 0), line: start_line + (start_text? 1: 0),
ch: 0 ch: 0
}, { }, {
line: end_line + (start_text ? 1 : -1), line: end_line + (start_text? 1: -1),
ch: 0 ch: 0
}); });
cm.focus(); cm.focus();
} else { } else{
// no selection, search for ends of this fenced block // no selection, search for ends of this fenced block
let search_from = cur_start.line; let search_from = cur_start.line;
if(fencing_line(cm.getLineHandle(cur_start.line))) { // gets a little tricky if cursor is right on a fenced line if (fencing_line(cm.getLineHandle(cur_start.line))){ // gets a little tricky if cursor is right on a fenced line
if(code_type(cm, cur_start.line + 1) === "fenced") { if (code_type(cm, cur_start.line + 1) === "fenced"){
block_start = cur_start.line; block_start = cur_start.line;
search_from = cur_start.line + 1; // for searching for "end" search_from = cur_start.line + 1; // for searching for "end"
} else { } else{
block_end = cur_start.line; block_end = cur_start.line;
search_from = cur_start.line - 1; // for searching for "start" search_from = cur_start.line - 1; // for searching for "start"
} }
} }
if(block_start === undefined) { if (block_start === undefined){
for(block_start = search_from; block_start >= 0; block_start--) { for (block_start = search_from; block_start >= 0; block_start--){
line = cm.getLineHandle(block_start); line = cm.getLineHandle(block_start);
if(fencing_line(line)) { if (fencing_line(line)){
break; break;
} }
} }
} }
if(block_end === undefined) { if (block_end === undefined){
lineCount = cm.lineCount(); lineCount = cm.lineCount();
for(block_end = search_from; block_end < lineCount; block_end++) { for (block_end = search_from; block_end < lineCount; block_end++){
line = cm.getLineHandle(block_end); line = cm.getLineHandle(block_end);
if(fencing_line(line)) { if (fencing_line(line)){
break; break;
} }
} }
} }
cm.operation(function() { cm.operation(function (){
cm.replaceRange("", { cm.replaceRange("", {
line: block_start, line: block_start,
ch: 0 ch: 0
@ -314,36 +316,36 @@ export default class Action {
}); });
cm.focus(); cm.focus();
} }
} else if(is_code === "indented") { } else if (is_code === "indented"){
if(cur_start.line !== cur_end.line || cur_start.ch !== cur_end.ch) { if (cur_start.line !== cur_end.line || cur_start.ch !== cur_end.ch){
// use selection // use selection
block_start = cur_start.line; block_start = cur_start.line;
block_end = cur_end.line; block_end = cur_end.line;
if(cur_end.ch === 0) { if (cur_end.ch === 0){
block_end--; block_end--;
} }
} else { } else{
// no selection, search for ends of this indented block // no selection, search for ends of this indented block
for(block_start = cur_start.line; block_start >= 0; block_start--) { for (block_start = cur_start.line; block_start >= 0; block_start--){
line = cm.getLineHandle(block_start); line = cm.getLineHandle(block_start);
if(line.text.match(/^\s*$/)) { if (line.text.match(/^\s*$/)){
// empty or all whitespace - keep going // empty or all whitespace - keep going
continue; continue;
} else { } else{
if(code_type(cm, block_start, line) !== "indented") { if (code_type(cm, block_start, line) !== "indented"){
block_start += 1; block_start += 1;
break; break;
} }
} }
} }
lineCount = cm.lineCount(); lineCount = cm.lineCount();
for(block_end = cur_start.line; block_end < lineCount; block_end++) { for (block_end = cur_start.line; block_end < lineCount; block_end++){
line = cm.getLineHandle(block_end); line = cm.getLineHandle(block_end);
if(line.text.match(/^\s*$/)) { if (line.text.match(/^\s*$/)){
// empty or all whitespace - keep going // empty or all whitespace - keep going
continue; continue;
} else { } else{
if(code_type(cm, block_end, line) !== "indented") { if (code_type(cm, block_end, line) !== "indented"){
block_end -= 1; block_end -= 1;
break; break;
} }
@ -358,24 +360,24 @@ export default class Action {
ch: next_line.text.length - 1 ch: next_line.text.length - 1
}), }),
next_line_indented = next_line_last_tok && token_state(next_line_last_tok).indentedCode; next_line_indented = next_line_last_tok && token_state(next_line_last_tok).indentedCode;
if(next_line_indented) { if (next_line_indented){
cm.replaceRange("\n", { cm.replaceRange("\n", {
line: block_end + 1, line: block_end + 1,
ch: 0 ch: 0
}); });
} }
for(var i = block_start; i <= block_end; i++) { for (var i = block_start; i <= block_end; i++){
cm.indentLine(i, "subtract"); // TODO: this doesn't get tracked in the history, so can't be undone :( cm.indentLine(i, "subtract"); // TODO: this doesn't get tracked in the history, so can't be undone :(
} }
cm.focus(); cm.focus();
} else { } else{
// insert code formatting // insert code formatting
let no_sel_and_starting_of_line = (cur_start.line === cur_end.line && cur_start.ch === cur_end.ch && cur_start.ch === 0); let no_sel_and_starting_of_line = (cur_start.line === cur_end.line && cur_start.ch === cur_end.ch && cur_start.ch === 0);
let sel_multi = cur_start.line !== cur_end.line; let sel_multi = cur_start.line !== cur_end.line;
if(no_sel_and_starting_of_line || sel_multi) { if (no_sel_and_starting_of_line || sel_multi){
insertFencingAtSelection(cm, cur_start, cur_end, fenceCharsToInsert); insertFencingAtSelection(cm, cur_start, cur_end, fenceCharsToInsert);
} else { } else{
Base.replaceSelection(cm, false, ["`", "`"]); Base.replaceSelection(cm, false, ["`", "`"]);
} }
} }
@ -391,10 +393,10 @@ export default class Action {
// Prevent scrolling on body during fullscreen active // Prevent scrolling on body during fullscreen active
if(cm.getOption("fullScreen")) { if (cm.getOption("fullScreen")){
this.saved_overflow = document.body.style.overflow; this.saved_overflow = document.body.style.overflow;
document.body.style.overflow = "hidden"; document.body.style.overflow = "hidden";
} else { } else{
document.body.style.overflow = this.saved_overflow; document.body.style.overflow = this.saved_overflow;
} }
@ -402,9 +404,9 @@ export default class Action {
// Update toolbar class // Update toolbar class
let wrap = cm.getWrapperElement(); let wrap = cm.getWrapperElement();
if(!/fullscreen/.test(wrap.previousSibling.className)) { if (!/fullscreen/.test(wrap.previousSibling.className)){
wrap.previousSibling.className += " fullscreen"; wrap.previousSibling.className += " fullscreen";
} else { } else{
wrap.previousSibling.className = wrap.previousSibling.className.replace(/\s*fullscreen\b/, ""); wrap.previousSibling.className = wrap.previousSibling.className.replace(/\s*fullscreen\b/, "");
} }
@ -412,16 +414,16 @@ export default class Action {
// Update toolbar button // Update toolbar button
let toolbarButton = editor.toolbarElements.fullscreen; let toolbarButton = editor.toolbarElements.fullscreen;
if(!/active/.test(toolbarButton.className)) { if (!/active/.test(toolbarButton.className)){
toolbarButton.className += " active"; toolbarButton.className += " active";
} else { } else{
toolbarButton.className = toolbarButton.className.replace(/\s*active\s*/g, ""); toolbarButton.className = toolbarButton.className.replace(/\s*active\s*/g, "");
} }
// Hide side by side if needed // Hide side by side if needed
const sidebyside = cm.getWrapperElement().nextSibling; const sidebyside = cm.getWrapperElement().nextSibling;
if(/editor-preview-active-side/.test(sidebyside.className)) if (/editor-preview-active-side/.test(sidebyside.className))
this.toggleSideBySide(editor); this.toggleSideBySide(editor);
} }
@ -435,18 +437,18 @@ export default class Action {
let preview = wrapper.nextSibling; let preview = wrapper.nextSibling;
let toolbarButton = editor.toolbarElements["side-by-side"]; let toolbarButton = editor.toolbarElements["side-by-side"];
let useSideBySideListener = false; let useSideBySideListener = false;
if(/editor-preview-active-side/.test(preview.className)) { if (/editor-preview-active-side/.test(preview.className)){
preview.className = preview.className.replace( preview.className = preview.className.replace(
/\s*editor-preview-active-side\s*/g, "" /\s*editor-preview-active-side\s*/g, ""
); );
toolbarButton.className = toolbarButton.className.replace(/\s*active\s*/g, ""); toolbarButton.className = toolbarButton.className.replace(/\s*active\s*/g, "");
wrapper.className = wrapper.className.replace(/\s*CodeMirror-sided\s*/g, " "); wrapper.className = wrapper.className.replace(/\s*CodeMirror-sided\s*/g, " ");
} else { } else{
// When the preview button is clicked for the first time, // When the preview button is clicked for the first time,
// give some time for the transition from editor.css to fire and the view to slide from right to left, // give some time for the transition from editor.css to fire and the view to slide from right to left,
// instead of just appearing. // instead of just appearing.
setTimeout(function() { setTimeout(function (){
if(!cm.getOption("fullScreen")) if (!cm.getOption("fullScreen"))
this.toggleFullScreen(editor); this.toggleFullScreen(editor);
preview.className += " editor-preview-active-side"; preview.className += " editor-preview-active-side";
}, 1); }, 1);
@ -457,7 +459,7 @@ export default class Action {
// Hide normal preview if active // Hide normal preview if active
let previewNormal = wrapper.lastChild; let previewNormal = wrapper.lastChild;
if(/editor-preview-active/.test(previewNormal.className)) { if (/editor-preview-active/.test(previewNormal.className)){
previewNormal.className = previewNormal.className.replace( previewNormal.className = previewNormal.className.replace(
/\s*editor-preview-active\s*/g, "" /\s*editor-preview-active\s*/g, ""
); );
@ -467,18 +469,18 @@ export default class Action {
toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, ""); toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, "");
} }
const sideBySideRenderingFunction = function() { const sideBySideRenderingFunction = function (){
preview.innerHTML = editor.options.previewRender(editor.value(), preview); preview.innerHTML = editor.options.previewRender(editor.value(), preview);
}; };
if(!cm.sideBySideRenderingFunction) { if (!cm.sideBySideRenderingFunction){
cm.sideBySideRenderingFunction = sideBySideRenderingFunction; cm.sideBySideRenderingFunction = sideBySideRenderingFunction;
} }
if(useSideBySideListener) { if (useSideBySideListener){
preview.innerHTML = editor.options.previewRender(editor.value(), preview); preview.innerHTML = editor.options.previewRender(editor.value(), preview);
cm.on("update", cm.sideBySideRenderingFunction); cm.on("update", cm.sideBySideRenderingFunction);
} else { } else{
cm.off("update", cm.sideBySideRenderingFunction); cm.off("update", cm.sideBySideRenderingFunction);
} }
@ -493,29 +495,29 @@ export default class Action {
let cm = editor.codemirror; let cm = editor.codemirror;
let wrapper = cm.getWrapperElement(); let wrapper = cm.getWrapperElement();
let toolbar_div = wrapper.previousSibling; let toolbar_div = wrapper.previousSibling;
let toolbar = editor.options.toolbar ? editor.toolbarElements.preview : false; let toolbar = editor.options.toolbar? editor.toolbarElements.preview: false;
let preview = wrapper.lastChild; let preview = wrapper.lastChild;
if(!preview || !/editor-preview/.test(preview.className)) { if (!preview || !/editor-preview/.test(preview.className)){
preview = document.createElement("div"); preview = document.createElement("div");
preview.className = "editor-preview"; preview.className = "editor-preview";
wrapper.appendChild(preview); wrapper.appendChild(preview);
} }
if(/editor-preview-active/.test(preview.className)) { if (/editor-preview-active/.test(preview.className)){
preview.className = preview.className.replace( preview.className = preview.className.replace(
/\s*editor-preview-active\s*/g, "" /\s*editor-preview-active\s*/g, ""
); );
if(toolbar) { if (toolbar){
toolbar.className = toolbar.className.replace(/\s*active\s*/g, ""); toolbar.className = toolbar.className.replace(/\s*active\s*/g, "");
toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, ""); toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, "");
} }
} else { } else{
// When the preview button is clicked for the first time, // When the preview button is clicked for the first time,
// give some time for the transition from editor.css to fire and the view to slide from right to left, // give some time for the transition from editor.css to fire and the view to slide from right to left,
// instead of just appearing. // instead of just appearing.
setTimeout(function() { setTimeout(function (){
preview.className += " editor-preview-active"; preview.className += " editor-preview-active";
}, 1); }, 1);
if(toolbar) { if (toolbar){
toolbar.className += " active"; toolbar.className += " active";
toolbar_div.className += " disabled-for-preview"; toolbar_div.className += " disabled-for-preview";
} }
@ -524,7 +526,7 @@ export default class Action {
// Turn off side by side if needed // Turn off side by side if needed
const sidebyside = cm.getWrapperElement().nextSibling; const sidebyside = cm.getWrapperElement().nextSibling;
if(/editor-preview-active-side/.test(sidebyside.className)) if (/editor-preview-active-side/.test(sidebyside.className))
this.toggleSideBySide(editor); this.toggleSideBySide(editor);
} }
@ -542,10 +544,12 @@ export default class Action {
const cm = editor.codemirror; const cm = editor.codemirror;
Base.toggleHeading(cm, undefined, 1); Base.toggleHeading(cm, undefined, 1);
} }
static toggleHeading2 (editor){ static toggleHeading2 (editor){
const cm = editor.codemirror; const cm = editor.codemirror;
Base.toggleHeading(cm, undefined, 2); Base.toggleHeading(cm, undefined, 2);
} }
static toggleHeading3 (editor){ static toggleHeading3 (editor){
const cm = editor.codemirror; const cm = editor.codemirror;
Base.toggleHeading(cm, undefined, 3); Base.toggleHeading(cm, undefined, 3);
@ -598,10 +602,4 @@ export default class Action {
} }
} }

View File

@ -4,7 +4,7 @@ import CodeMirrorSpellChecker from 'codemirror-spell-checker'
import marked from 'marked' import marked from 'marked'
import 'codemirror/addon/edit/continuelist' import 'codemirror/addon/edit/continuelist'
import 'codemirror/addon/display/fullscreen' import 'codemirror/addon/display/fullscreen'
import 'codemirror/addon/mode/overla' import 'codemirror/addon/mode/overlay'
import 'codemirror/addon/display/placeholder' import 'codemirror/addon/display/placeholder'
import 'codemirror/addon/selection/mark-selection' import 'codemirror/addon/selection/mark-selection'
import './codemirror/tablist' import './codemirror/tablist'
@ -53,10 +53,14 @@ const createSep = () => {
} }
const createTootlip = (title, action, shortcuts) => { const createTootlip = (title, action, shortcuts) => {
let actionName;
let tooltip = title; let tooltip = title;
if(action && shortcuts[utils.getBindingName(action)]) { if(action) {
tooltip += " (" + utils.fixShortcut(shortcuts[actionName]) + ")" actionName = utils.getBindingName(action);
if(shortcuts[actionName]) {
tooltip += " (" + utils.fixShortcut(shortcuts[actionName]) + ")";
}
} }
return tooltip; return tooltip;
@ -69,6 +73,7 @@ const createTootlip = (title, action, shortcuts) => {
export class SimpleMDE extends Action { export class SimpleMDE extends Action {
constructor(options = {}) { constructor(options = {}) {
super()
// Used later to refer to it"s parent // Used later to refer to it"s parent
options.parent = this; options.parent = this;