|
|
@@ -51,12 +51,17 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
_destroyEditor() {
|
|
|
+ // destroy() 在已 destroy 过 / 半销毁 Slate 状态下会抛 "proxy has been revoked"
|
|
|
+ // 之类的异常。Vue 2 中未捕获异常会沿调用栈冒到 console 报红,
|
|
|
+ // 但更糟的是 selectionchange 这种 document 监听器如果没及时
|
|
|
+ // removeEventListener,下次用户点页面会再次触发同一个错误循环。
|
|
|
+ // 用 try-catch 兜住,保证清理链路不会被打断。
|
|
|
if (this.editor) {
|
|
|
- this.editor.destroy()
|
|
|
+ try { this.editor.destroy() } catch (e) { /* swallow: half-destroyed slate */ }
|
|
|
this.editor = null
|
|
|
}
|
|
|
if (this.toolbar) {
|
|
|
- this.toolbar.destroy()
|
|
|
+ try { this.toolbar.destroy() } catch (e) { /* swallow */ }
|
|
|
this.toolbar = null
|
|
|
}
|
|
|
},
|