From 9892249e49dd5ef035fa0086d2c90efb0edae8e9 Mon Sep 17 00:00:00 2001 From: jos Date: Sat, 3 Aug 2019 11:08:00 +0200 Subject: [PATCH] Fixed #755: JSONEditor throwing an exception in mode `code`, `text`, and `preview` when `statusBar: false` --- HISTORY.md | 6 ++++++ src/js/previewmode.js | 3 ++- src/js/textmode.js | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 4502f7b..0db492e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,12 @@ https://github.com/josdejong/jsoneditor +## not yet publised, version 6.2.2 + +- Fixed #755: JSONEditor throwing an exception in mode `code`, `text`, and + `preview` when `statusBar: false`. + + ## 2019-08-01, version 6.2.1 - Updated Chinese translation. Thanks @SargerasWang. diff --git a/src/js/previewmode.js b/src/js/previewmode.js index b096dd8..7880709 100644 --- a/src/js/previewmode.js +++ b/src/js/previewmode.js @@ -236,7 +236,8 @@ previewmode.create = function (container, options) { onFocusLine: null, onChangeHeight: function (height) { // TODO: change CSS to using flex box, remove setting height using JavaScript - var totalHeight = height + me.dom.statusBar.clientHeight + 1; + var statusBarHeight = me.dom.statusBar ? me.dom.statusBar.clientHeight : 0; + var totalHeight = height + statusBarHeight + 1; me.content.style.marginBottom = (-totalHeight) + 'px'; me.content.style.paddingBottom = totalHeight + 'px'; } diff --git a/src/js/textmode.js b/src/js/textmode.js index 883181d..641dfeb 100644 --- a/src/js/textmode.js +++ b/src/js/textmode.js @@ -296,7 +296,8 @@ textmode.create = function (container, options) { }, onChangeHeight: function (height) { // TODO: change CSS to using flex box, remove setting height using JavaScript - var totalHeight = height + me.dom.statusBar.clientHeight + 1; + var statusBarHeight = me.dom.statusBar ? me.dom.statusBar.clientHeight : 0; + var totalHeight = height + statusBarHeight + 1; me.content.style.marginBottom = (-totalHeight) + 'px'; me.content.style.paddingBottom = totalHeight + 'px'; }