From 41327dd1e89bf523fb180ab63e4f6c80b47f5664 Mon Sep 17 00:00:00 2001 From: Regev Brody Date: Sat, 4 Jul 2020 00:46:07 +0300 Subject: [PATCH] feat: support MultiMarkdown tables (#2126) --- client/components/editor/editor-markdown.vue | 2 ++ package.json | 1 + .../markdown-multi-table/definition.yml | 23 +++++++++++++++++ .../markdown-multi-table/renderer.js | 11 ++++++++ yarn.lock | 25 +++++++++++++++++++ 5 files changed, 62 insertions(+) create mode 100644 server/modules/rendering/markdown-multi-table/definition.yml create mode 100644 server/modules/rendering/markdown-multi-table/renderer.js diff --git a/client/components/editor/editor-markdown.vue b/client/components/editor/editor-markdown.vue index 03f68f80ee..7665b8ad4d 100644 --- a/client/components/editor/editor-markdown.vue +++ b/client/components/editor/editor-markdown.vue @@ -228,6 +228,7 @@ import mdAbbr from 'markdown-it-abbr' import mdSup from 'markdown-it-sup' import mdSub from 'markdown-it-sub' import mdMark from 'markdown-it-mark' +import mdMultiTable from 'markdown-it-multimd-table' import mdFootnote from 'markdown-it-footnote' import mdImsize from 'markdown-it-imsize' import katex from 'katex' @@ -287,6 +288,7 @@ const md = new MarkdownIt({ .use(mdAbbr) .use(mdSup) .use(mdSub) + .use(mdMultiTable, {multiline: true, rowspan: true, headerless: true}) .use(mdMark) .use(mdFootnote) .use(mdImsize) diff --git a/package.json b/package.json index e617d12118..89cc75c296 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,7 @@ "markdown-it-imsize": "2.0.1", "markdown-it-mark": "3.0.0", "markdown-it-mathjax": "2.0.0", + "markdown-it-multimd-table": "4.0.2", "markdown-it-sub": "1.0.0", "markdown-it-sup": "1.0.0", "markdown-it-task-lists": "2.1.1", diff --git a/server/modules/rendering/markdown-multi-table/definition.yml b/server/modules/rendering/markdown-multi-table/definition.yml new file mode 100644 index 0000000000..d3cbe67acf --- /dev/null +++ b/server/modules/rendering/markdown-multi-table/definition.yml @@ -0,0 +1,23 @@ +key: markdownMultiTable +title: MultiMarkdown Table +description: Add MultiMarkdown table support +author: requarks.io +icon: mdi-table +enabledDefault: false +dependsOn: markdownCore +props: + multilineEnabled: + type: Boolean + title: Multiline + hint: Enable multiple lines rows + default: true + headerlessEnabled: + type: Boolean + title: Headerless + hint: Enable ommited table headers + default: true + rowspanEnabled: + type: Boolean + title: Rowspan + hint: Enable table row spans + default: true diff --git a/server/modules/rendering/markdown-multi-table/renderer.js b/server/modules/rendering/markdown-multi-table/renderer.js new file mode 100644 index 0000000000..79be64c1f1 --- /dev/null +++ b/server/modules/rendering/markdown-multi-table/renderer.js @@ -0,0 +1,11 @@ +const multiTable = require('markdown-it-multimd-table') + +module.exports = { + init (md, conf) { + md.use(multiTable, { + multiline: conf.multilineEnabled, + rowspan: conf.rowspanEnabled, + headerless: conf.headerlessEnabled + }) + } +} diff --git a/yarn.lock b/yarn.lock index 50b2c9f73c..792f85fedd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11163,6 +11163,13 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00" integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= +linkify-it@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.2.0.tgz#e3b54697e78bf915c70a38acd78fd09e0058b1cf" + integrity sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw== + dependencies: + uc.micro "^1.0.1" + linkify-it@^3.0.1: version "3.0.2" resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-3.0.2.tgz#f55eeb8bc1d3ae754049e124ab3bb56d97797fb8" @@ -11596,6 +11603,13 @@ markdown-it-mathjax@2.0.0: resolved "https://registry.yarnpkg.com/markdown-it-mathjax/-/markdown-it-mathjax-2.0.0.tgz#ae2b4f4c5c719a03f9e475c664f7b2685231d9e9" integrity sha1-ritPTFxxmgP55HXGZPeyaFIx2ek= +markdown-it-multimd-table@4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/markdown-it-multimd-table/-/markdown-it-multimd-table-4.0.2.tgz#3dfbdb35356fa5e3de85e6868985dddcd1051e17" + integrity sha512-SlcssTj7FoYstVQ7MsM8A46/lhbN1K6/q0e9v56o/5kaWmTheXZXQX3nuZgw7WQocn+3nyQGcoO7ovcqeFxaAw== + dependencies: + markdown-it "^8.4.2" + markdown-it-sub@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/markdown-it-sub/-/markdown-it-sub-1.0.0.tgz#375fd6026eae7ddcb012497f6411195ea1e3afe8" @@ -11622,6 +11636,17 @@ markdown-it@11.0.0: mdurl "^1.0.1" uc.micro "^1.0.5" +markdown-it@^8.4.2: + version "8.4.2" + resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54" + integrity sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ== + dependencies: + argparse "^1.0.7" + entities "~1.1.1" + linkify-it "^2.0.0" + mdurl "^1.0.1" + uc.micro "^1.0.5" + math-expression-evaluator@^1.2.14: version "1.2.17" resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz#de819fdbcd84dccd8fae59c6aeb79615b9d266ac"