mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-07-06 09:34:27 -06:00
Add new icon option: Strikethrough
This commit is contained in:
parent
db6d381d1c
commit
41c551c115
@ -103,6 +103,7 @@ Name | Action | Class | Tooltip
|
|||||||
:--- | :----- | :---- | :------
|
:--- | :----- | :---- | :------
|
||||||
bold | toggleBold | fa fa-bold | Bold (Ctrl+B)
|
bold | toggleBold | fa fa-bold | Bold (Ctrl+B)
|
||||||
italic | toggleItalic | fa fa-italic | Italic (Ctrl+I)
|
italic | toggleItalic | fa fa-italic | Italic (Ctrl+I)
|
||||||
|
strikethrough | toggleStrikethrough | fa fa-strikethrough | Strikethrough
|
||||||
heading | toggleHeadingSmaller | fa fa-header | Heading (Ctrl+H)
|
heading | toggleHeadingSmaller | fa fa-header | Heading (Ctrl+H)
|
||||||
heading-smaller | toggleHeadingSmaller | fa fa-header | Smaller Heading (Ctrl+H)
|
heading-smaller | toggleHeadingSmaller | fa fa-header | Smaller Heading (Ctrl+H)
|
||||||
heading-bigger | toggleHeadingBigger | fa fa-lg fa-header | Bigger Heading (Shift+Ctrl+H)
|
heading-bigger | toggleHeadingBigger | fa fa-lg fa-header | Bigger Heading (Shift+Ctrl+H)
|
||||||
|
@ -86,6 +86,8 @@ function getState(cm, pos) {
|
|||||||
ret.italic = true;
|
ret.italic = true;
|
||||||
} else if(data === 'quote') {
|
} else if(data === 'quote') {
|
||||||
ret.quote = true;
|
ret.quote = true;
|
||||||
|
} else if(data === 'strikethrough') {
|
||||||
|
ret.strikethrough = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -137,6 +139,14 @@ function toggleItalic(editor) {
|
|||||||
_toggleBlock(editor, 'italic', '*');
|
_toggleBlock(editor, 'italic', '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action for toggling strikethrough.
|
||||||
|
*/
|
||||||
|
function toggleStrikethrough(editor) {
|
||||||
|
_toggleBlock(editor, 'strikethrough', '~~');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action for toggling code block.
|
* Action for toggling code block.
|
||||||
*/
|
*/
|
||||||
@ -464,6 +474,9 @@ function _toggleBlock(editor, type, start_chars, end_chars) {
|
|||||||
} else if(type == "italic") {
|
} else if(type == "italic") {
|
||||||
start = start.replace(/(\*|_)(?![\s\S]*(\*|_))/, "");
|
start = start.replace(/(\*|_)(?![\s\S]*(\*|_))/, "");
|
||||||
end = end.replace(/(\*|_)/, "");
|
end = end.replace(/(\*|_)/, "");
|
||||||
|
} else if(type == "strikethrough") {
|
||||||
|
start = start.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/, "");
|
||||||
|
end = end.replace(/(\*\*|~~)/, "");
|
||||||
}
|
}
|
||||||
cm.replaceRange(start + end, {
|
cm.replaceRange(start + end, {
|
||||||
line: startPoint.line,
|
line: startPoint.line,
|
||||||
@ -473,7 +486,7 @@ function _toggleBlock(editor, type, start_chars, end_chars) {
|
|||||||
ch: 99999999999999
|
ch: 99999999999999
|
||||||
});
|
});
|
||||||
|
|
||||||
if(type == "bold") {
|
if(type == "bold" || type == "strikethrough") {
|
||||||
startPoint.ch -= 2;
|
startPoint.ch -= 2;
|
||||||
endPoint.ch -= 2;
|
endPoint.ch -= 2;
|
||||||
} else if(type == "italic") {
|
} else if(type == "italic") {
|
||||||
@ -488,6 +501,8 @@ function _toggleBlock(editor, type, start_chars, end_chars) {
|
|||||||
} else if(type == "italic") {
|
} else if(type == "italic") {
|
||||||
text = text.split("*").join("");
|
text = text.split("*").join("");
|
||||||
text = text.split("_").join("");
|
text = text.split("_").join("");
|
||||||
|
} else if(type == "strikethrough") {
|
||||||
|
text = text.split("~~").join("");
|
||||||
}
|
}
|
||||||
cm.replaceSelection(start + text + end);
|
cm.replaceSelection(start + text + end);
|
||||||
|
|
||||||
@ -530,10 +545,16 @@ var toolbarBuiltInButtons = {
|
|||||||
className: "fa fa-italic",
|
className: "fa fa-italic",
|
||||||
title: "Italic (Ctrl+I)",
|
title: "Italic (Ctrl+I)",
|
||||||
},
|
},
|
||||||
|
"strikethrough": {
|
||||||
|
name: "strikethrough",
|
||||||
|
action: toggleStrikethrough,
|
||||||
|
className: "fa fa-strikethrough",
|
||||||
|
title: "Strikethrough",
|
||||||
|
},
|
||||||
"heading": {
|
"heading": {
|
||||||
name: "heading",
|
name: "heading",
|
||||||
action: toggleHeadingSmaller,
|
action: toggleHeadingSmaller,
|
||||||
className: "fa fa-header",
|
className: "fa fa-heade`r",
|
||||||
title: "Heading (Ctrl+H)",
|
title: "Heading (Ctrl+H)",
|
||||||
},
|
},
|
||||||
"heading-smaller": {
|
"heading-smaller": {
|
||||||
@ -937,6 +958,7 @@ SimpleMDE.prototype.value = function(val) {
|
|||||||
*/
|
*/
|
||||||
SimpleMDE.toggleBold = toggleBold;
|
SimpleMDE.toggleBold = toggleBold;
|
||||||
SimpleMDE.toggleItalic = toggleItalic;
|
SimpleMDE.toggleItalic = toggleItalic;
|
||||||
|
SimpleMDE.toggleStrikethrough = toggleStrikethrough;
|
||||||
SimpleMDE.toggleBlockquote = toggleBlockquote;
|
SimpleMDE.toggleBlockquote = toggleBlockquote;
|
||||||
SimpleMDE.toggleHeadingSmaller = toggleHeadingSmaller;
|
SimpleMDE.toggleHeadingSmaller = toggleHeadingSmaller;
|
||||||
SimpleMDE.toggleHeadingBigger = toggleHeadingBigger;
|
SimpleMDE.toggleHeadingBigger = toggleHeadingBigger;
|
||||||
@ -963,6 +985,9 @@ SimpleMDE.prototype.toggleBold = function() {
|
|||||||
SimpleMDE.prototype.toggleItalic = function() {
|
SimpleMDE.prototype.toggleItalic = function() {
|
||||||
toggleItalic(this);
|
toggleItalic(this);
|
||||||
};
|
};
|
||||||
|
SimpleMDE.prototype.toggleStrikethrough = function() {
|
||||||
|
toggleStrikethrough(this);
|
||||||
|
};
|
||||||
SimpleMDE.prototype.toggleBlockquote = function() {
|
SimpleMDE.prototype.toggleBlockquote = function() {
|
||||||
toggleBlockquote(this);
|
toggleBlockquote(this);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user