From 16148b225507866c13098e42d21e9130ba21beef Mon Sep 17 00:00:00 2001 From: Caleb John Date: Sun, 9 Jan 2022 03:22:22 -0800 Subject: [PATCH] Desktop: Fixes #5808: Scrolling was out of sync when a Multi Markdown Table was being used (#5815) --- ...down-it-multimd-table-npm-4.1.1-47e334d4bd | 43 +++++++++++++++++++ package.json | 5 ++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .yarn/patches/markdown-it-multimd-table-npm-4.1.1-47e334d4bd diff --git a/.yarn/patches/markdown-it-multimd-table-npm-4.1.1-47e334d4bd b/.yarn/patches/markdown-it-multimd-table-npm-4.1.1-47e334d4bd new file mode 100644 index 0000000000..6f1a9fa4e5 --- /dev/null +++ b/.yarn/patches/markdown-it-multimd-table-npm-4.1.1-47e334d4bd @@ -0,0 +1,43 @@ +diff --git a/index.js b/index.js +index 85d89900d5fe575dd0c19430209fb1703b03554e..5fa68cc9a4bd2b21a7188bd263262fd9b1604ac6 100644 +--- a/index.js ++++ b/index.js +@@ -145,7 +145,8 @@ module.exports = function multimd_table_plugin(md, options) { + colspan, leftToken, + rowspan, upTokens = [], + tableLines, tgroupLines, +- tag, text, range, r, c, b; ++ tag, text, range, r, c, b, t, ++ blockState; + + if (startLine + 2 > endLine) { return false; } + +@@ -315,18 +316,26 @@ module.exports = function multimd_table_plugin(md, options) { + + /* Multiline. Join the text and feed into markdown-it blockParser. */ + if (options.multiline && trToken.meta.multiline && trToken.meta.mbounds) { +- text = [ text.trimRight() ]; ++ // Pad the text with empty lines to ensure the line number mapping is correct ++ text = new Array(trToken.map[0]).fill('').concat([ text.trimRight() ]); + for (b = 1; b < trToken.meta.mbounds.length; b++) { + /* Line with N bounds has cells indexed from 0 to N-2 */ + if (c > trToken.meta.mbounds[b].length - 2) { continue; } + range = [ trToken.meta.mbounds[b][c] + 1, trToken.meta.mbounds[b][c + 1] ]; + text.push(state.src.slice.apply(state.src, range).trimRight()); + } +- state.md.block.parse(text.join('\n'), state.md, state.env, state.tokens); ++ blockState = new state.md.block.State(text.join('\n'), state.md, state.env, []); ++ blockState.level = trToken.level + 1; ++ // Start tokenizing from the actual content (trToken.map[0]) ++ state.md.block.tokenize(blockState, trToken.map[0], blockState.lineMax); ++ for (t = 0; t < blockState.tokens.length; t++) { ++ state.tokens.push(blockState.tokens[t]); ++ } + } else { + token = state.push('inline', '', 0); + token.content = text.trim(); + token.map = trToken.map; ++ token.level = trToken.level + 1; + token.children = []; + } + diff --git a/package.json b/package.json index c7da4cca2a..b0d1cbcd85 100644 --- a/package.json +++ b/package.json @@ -78,5 +78,8 @@ "node-gyp": "^8.4.1", "nodemon": "^2.0.9" }, - "packageManager": "yarn@3.1.1" + "packageManager": "yarn@3.1.1", + "resolutions": { + "markdown-it-multimd-table@4.1.1": "patch:markdown-it-multimd-table@npm:4.1.1#.yarn/patches/markdown-it-multimd-table-npm-4.1.1-47e334d4bd" + } }