diff --git a/src/components/Editor.vue b/src/components/Editor.vue index e3147161a59..9e41ad85395 100644 --- a/src/components/Editor.vue +++ b/src/components/Editor.vue @@ -335,6 +335,13 @@ export default { subscribe('text:image-node:delete', this.onDeleteImageNode) this.emit('update:loaded', true) subscribe('text:translate-modal:show', this.showTranslateModal) + + window.addEventListener('beforeunload', (e) => { + if (this.$queue.length > 0) { + e.preventDefault() + e.returnValue = t('text', 'Some changes have not been synced. You might loose your edits when leaving the page.') + } + }) }, created() { this.$ydoc = new Doc() @@ -559,14 +566,14 @@ export default { this.document = document this.syncError = null - const editable = !this.readOnly + const editable = !this.readOnly && !this.hasConnectionIssue if (this.$editor.isEditable !== editable) { this.$editor.setEditable(editable) } }, onSync({ steps, document }) { - this.hasConnectionIssue = false + this.hasConnectionIssue = !this.$providers[0].wsconnected || this.$syncService.pushError > 0 this.$nextTick(() => { this.emit('sync-service:sync') }) diff --git a/src/components/Editor/Status.vue b/src/components/Editor/Status.vue index e211192edcb..194742d3d55 100644 --- a/src/components/Editor/Status.vue +++ b/src/components/Editor/Status.vue @@ -6,12 +6,16 @@