mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Added guards for missing codemirror elements when destroying markdown cards
no issue - if a markdown card is created and destroyed before the simplemde+codemirror instance is fully initialised we could throw errors due to simplemde calling methods on objects that don't yet exist during teardown - we also had issues with the `_applyToolbarStyles()` method being called async by event handlers after the component was destroyed
This commit is contained in:
parent
1ca5b43fcb
commit
94c192041d
2 changed files with 8 additions and 2 deletions
|
@ -72,7 +72,9 @@ export default class GhSimplemde extends TextArea {
|
||||||
}
|
}
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._editor.toTextArea();
|
if (this._editor?.codemirror) {
|
||||||
|
this._editor.toTextArea();
|
||||||
|
}
|
||||||
delete this._editor;
|
delete this._editor;
|
||||||
super.willDestroyElement(...arguments);
|
super.willDestroyElement(...arguments);
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,11 @@ export default class KoenigCardMarkdown extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
_applyToolbarStyles() {
|
_applyToolbarStyles() {
|
||||||
let toolbar = this.element.querySelector('.editor-toolbar');
|
if (this.isDestroyed || this.isDestroying) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let toolbar = this.element?.querySelector('.editor-toolbar');
|
||||||
|
|
||||||
if (!toolbar) {
|
if (!toolbar) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue