From 09bc15e980e5cf1aaa9b10ca4f0ea348f76a913b Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Thu, 20 Jul 2017 12:37:18 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20broken=20editor=20at=20mob?= =?UTF-8?q?ile=20sizes=20(#790)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes https://github.com/TryGhost/Ghost/issues/8657 - add checks for the toolbar being present before attempting to set classes on the buttons --- .../app/components/gh-markdown-editor.js | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/ghost/admin/app/components/gh-markdown-editor.js b/ghost/admin/app/components/gh-markdown-editor.js index 34c4b1722d..af5a04bf98 100644 --- a/ghost/admin/app/components/gh-markdown-editor.js +++ b/ghost/admin/app/components/gh-markdown-editor.js @@ -231,16 +231,20 @@ export default Component.extend(ShortcutsMixin, { let sideBySideButton = this._editor.toolbarElements['side-by-side']; let spellcheckButton = this._editor.toolbarElements.spellcheck; - if (this.get('_isSplitScreen')) { - sideBySideButton.classList.add('active'); - } else { - sideBySideButton.classList.remove('active'); + if (sideBySideButton) { + if (this.get('_isSplitScreen')) { + sideBySideButton.classList.add('active'); + } else { + sideBySideButton.classList.remove('active'); + } } - if (this._editor.codemirror.getOption('mode') === 'spell-checker') { - spellcheckButton.classList.add('active'); - } else { - spellcheckButton.classList.remove('active'); + if (spellcheckButton) { + if (this._editor.codemirror.getOption('mode') === 'spell-checker') { + spellcheckButton.classList.add('active'); + } else { + spellcheckButton.classList.remove('active'); + } } } }, @@ -437,10 +441,16 @@ export default Component.extend(ShortcutsMixin, { preview.action(this._editor); } - previewButton.classList.add('disabled'); + if (previewButton) { + previewButton.classList.add('disabled'); + } + run.scheduleOnce('afterRender', this, this._connectSplitPreview); } else { - previewButton.classList.remove('disabled'); + if (previewButton) { + previewButton.classList.remove('disabled'); + } + run.scheduleOnce('afterRender', this, this._disconnectSplitPreview); }