From cbe5ae4861f07f00e74ca3f1ad9fb9948bb23dd5 Mon Sep 17 00:00:00 2001 From: Vinicius Reis Date: Tue, 31 May 2022 16:15:50 -0300 Subject: =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20(#2462):=20proxy=20?= =?UTF-8?q?some=20sync=20service=20events?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Vinicius Reis --- src/components/EditorWrapper.vue | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/components/EditorWrapper.vue b/src/components/EditorWrapper.vue index 1a3a9b532..c9b9aff78 100644 --- a/src/components/EditorWrapper.vue +++ b/src/components/EditorWrapper.vue @@ -372,6 +372,7 @@ export default { .on('error', this.onError) .on('stateChange', this.onStateChange) .on('idle', this.onIdle) + .on('save', this.onSave) }, unlistenSyncServiceEvents() { @@ -383,6 +384,7 @@ export default { .off('error', this.onError) .off('stateChange', this.onStateChange) .off('idle', this.onIdle) + .off('save', this.onSave) }, resolveUseThisVersion() { @@ -630,6 +632,9 @@ export default { }) this.$syncService.state = this.$editor.state this.updateLastSavedStatus() + this.$nextTick(() => { + this.$emit('sync-service:sync') + }) } catch (e) { console.error('Failed to update steps in collaboration plugin', e) // TODO: we should recreate the editing session when this happens @@ -639,6 +644,11 @@ export default { onError({ type, data }) { this.$editor.setOptions({ editable: false }) + + this.$nextTick(() => { + this.$emit('sync-service:error') + }) + if (type === ERROR_TYPE.SAVE_COLLISSION && (!this.syncError || this.syncError.type !== ERROR_TYPE.SAVE_COLLISSION)) { this.contentLoaded = true this.syncError = { @@ -667,6 +677,7 @@ export default { this.$editor.commands.focus() } this.$emit('ready') + // TODO: remove $parent access this.$parent.$emit('ready', true) } if (Object.prototype.hasOwnProperty.call(state, 'dirty')) { @@ -679,6 +690,16 @@ export default { this.idle = true this.readOnly = true this.$editor.setOptions({ editable: !this.readOnly }) + + this.$nextTick(() => { + this.$emit('sync-service:idle') + }) + }, + + onSave() { + this.$nextTick(() => { + this.$emit('sync-service:save') + }) }, async close() { -- cgit v1.2.3