From 5d924744dea2c9dae0de244eeeb4c98abb684934 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Thu, 9 Jul 2020 22:16:17 +0200 Subject: [PATCH] Fix indent in renderTree, remove first indents --- editor/src/menu.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/editor/src/menu.js b/editor/src/menu.js index c4cddd0..a4d01b7 100644 --- a/editor/src/menu.js +++ b/editor/src/menu.js @@ -5,10 +5,15 @@ import copy from 'copy-text-to-clipboard' function renderTree(tree) { if (!tree) return [] - return _.flatMapDeep(tree, (item) => [ - _.repeat(" ", item.indented) + item.text, - renderTree(item.children), - ]) + + let recRenderTree = (tree, indent) => { + return _.flatMapDeep(tree, (item) => [ + _.repeat(" ", item.indented-indent) + item.text, + recRenderTree(item.children, indent), + ]) + } + + return recRenderTree(tree, tree[0].indented) } function connectContextMenu(editor) {