mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2024-06-16 20:55:20 +02:00
Merge pull request #182 from qumberhussain/development
Added support for tables
This commit is contained in:
commit
a31e978659
|
@ -283,6 +283,16 @@ function drawImage(editor) {
|
||||||
_replaceSelection(cm, stat.image, options.insertTexts.image);
|
_replaceSelection(cm, stat.image, options.insertTexts.image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action for drawing a table.
|
||||||
|
*/
|
||||||
|
function drawTable(editor) {
|
||||||
|
var cm = editor.codemirror;
|
||||||
|
var stat = getState(cm);
|
||||||
|
var options = editor.options;
|
||||||
|
_replaceSelection(cm, stat.table, options.insertTexts.table);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action for drawing a horizontal rule.
|
* Action for drawing a horizontal rule.
|
||||||
*/
|
*/
|
||||||
|
@ -747,6 +757,12 @@ var toolbarBuiltInButtons = {
|
||||||
className: "fa fa-picture-o",
|
className: "fa fa-picture-o",
|
||||||
title: "Insert Image (Ctrl+Alt+I)"
|
title: "Insert Image (Ctrl+Alt+I)"
|
||||||
},
|
},
|
||||||
|
"table": {
|
||||||
|
name: "table",
|
||||||
|
action: drawTable,
|
||||||
|
className: "fa fa-table",
|
||||||
|
title: "Insert Table"
|
||||||
|
},
|
||||||
"horizontal-rule": {
|
"horizontal-rule": {
|
||||||
name: "horizontal-rule",
|
name: "horizontal-rule",
|
||||||
action: drawHorizontalRule,
|
action: drawHorizontalRule,
|
||||||
|
@ -782,6 +798,7 @@ var toolbarBuiltInButtons = {
|
||||||
var insertTexts = {
|
var insertTexts = {
|
||||||
link: ["[", "](http://)"],
|
link: ["[", "](http://)"],
|
||||||
image: ["![](http://", ")"],
|
image: ["![](http://", ")"],
|
||||||
|
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
|
||||||
horizontalRule: ["", "\n\n-----\n\n"]
|
horizontalRule: ["", "\n\n-----\n\n"]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1257,6 +1274,7 @@ SimpleMDE.toggleUnorderedList = toggleUnorderedList;
|
||||||
SimpleMDE.toggleOrderedList = toggleOrderedList;
|
SimpleMDE.toggleOrderedList = toggleOrderedList;
|
||||||
SimpleMDE.drawLink = drawLink;
|
SimpleMDE.drawLink = drawLink;
|
||||||
SimpleMDE.drawImage = drawImage;
|
SimpleMDE.drawImage = drawImage;
|
||||||
|
SimpleMDE.drawTable = drawTable;
|
||||||
SimpleMDE.drawHorizontalRule = drawHorizontalRule;
|
SimpleMDE.drawHorizontalRule = drawHorizontalRule;
|
||||||
SimpleMDE.undo = undo;
|
SimpleMDE.undo = undo;
|
||||||
SimpleMDE.redo = redo;
|
SimpleMDE.redo = redo;
|
||||||
|
@ -1309,6 +1327,9 @@ SimpleMDE.prototype.drawLink = function() {
|
||||||
SimpleMDE.prototype.drawImage = function() {
|
SimpleMDE.prototype.drawImage = function() {
|
||||||
drawImage(this);
|
drawImage(this);
|
||||||
};
|
};
|
||||||
|
SimpleMDE.prototype.drawTable = function() {
|
||||||
|
drawTable(this);
|
||||||
|
};
|
||||||
SimpleMDE.prototype.drawHorizontalRule = function() {
|
SimpleMDE.prototype.drawHorizontalRule = function() {
|
||||||
drawHorizontalRule(this);
|
drawHorizontalRule(this);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue