🐛 fix broken editor at mobile sizes (#790)

closes https://github.com/TryGhost/Ghost/issues/8657
- add checks for the toolbar being present before attempting to set classes on the buttons
This commit is contained in:
Kevin Ansfield 2017-07-20 12:37:18 +01:00 committed by Aileen Nowak
parent 84b2824f95
commit 09bc15e980

View File

@ -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);
}