Action
Markdown Table
Insert empty MultiMarkdown table markup. The action will prompt for the number of rows and columns, and create and insert MultiMarkdown table syntax for the table with header of the requested size, like:
| | | |
|:--|:--|:--|
| | | |
| | | |
Steps
-
script
// configurable default variables let defaultCols = 3; let defaultRows = 2; let cell = "| "; let div = "|:--"; let f = () => { // create prompt and ask for cols/rows let p = Prompt.create(); p.title = "Insert Table"; p.message = "Insert empty MultiMarkdown table." p.addTextField("cols", "Columns", defaultCols, { "autocorrect": false, "keyboard": "numberPad" }); p.addTextField("rows", "Rows", defaultRows, { "autocorrect": false, "keyboard": "numberPad" }); p.addButton("Insert"); // exit if user cancels if (!p.show()) { return false; } // create table let cols = parseInt(p.fieldValues["cols"]); let rows = parseInt(p.fieldValues["rows"]); if (!cols || !rows) { return false; } let row = cell.repeat(cols) + "|\n"; let divider = div.repeat(cols) + "|\n"; let tbl = "\n\n" + row + divider + row.repeat(rows) + "\n"; // insert table let [st, len] = editor.getSelectedLineRange(); editor.setTextInRange(st+len, 0, tbl); editor.activate(); editor.setSelectedRange(st+len+4); return true; } if (!f()) { context.cancel(); }
Options
-
After Success Default Notification Error Log Level None
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.