Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions cypress/e2e/sync.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,14 @@ describe('Sync', () => {
req.alias = 'deadSync'
}
})
cy.wait('@push', { timeout: 15000 + Cypress.config().defaultCommandTimeout })
cy.wait('@push', { timeout: 15000 + Cypress.config().defaultCommandTimeout })
cy.wait('@push', { timeout: 15000 + Cypress.config().defaultCommandTimeout })
cy.wait('@push', { timeout: 15000 + Cypress.config().defaultCommandTimeout })
cy.get('#editor-container .document-status')
.should('contain', 'File could not be loaded', { timeout: 10000 })
cy.get('#editor-container .document-status', { timeout: 30000 })
.should('not.contain', 'File could not be loaded')
cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' })
.as('syncAfterRecovery')
cy.getContent().type('* more content added after the lost connection{enter}')
cy.wait('@syncAfterRecovery')
cy.closeFile()
cy.testName()
.then(name => cy.downloadFile(`/${name}.md`))
Expand Down
4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/files-modal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/files-modal.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js/text-editors.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-editors.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

88 changes: 48 additions & 40 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ export default {
this.currentSession = session
this.document = document
this.readOnly = document.readOnly
if (this.$editor) {
this.$editor.setOptions({ editable: !this.readOnly })
}
this.lock = this.$syncService.lock
localStorage.setItem('nick', this.currentSession.guestName)
this.setCurrentSession(this.currentSession)
Expand All @@ -498,47 +501,52 @@ export default {
(this.isRichEditor ? Promise.resolve() : loadSyntaxHighlight(language))
.then(() => {
const session = this.currentSession
this.$editor ||= createEditor({
language,
relativePath: this.relativePath,
session,
onCreate: ({ editor }) => {
this.$syncService.startSync()
},
onUpdate: ({ editor }) => {
// this.debugContent(editor)
const proseMirrorMarkdown = this.$syncService.serialize(editor.state.doc)
this.$parent.$emit('update:content', {
markdown: proseMirrorMarkdown,
})
},
extensions: [
Collaboration.configure({
document: this.$ydoc,
}),
CollaborationCursor.configure({
provider: this.$providers[0],
user: {
name: session?.userId
? session.displayName
: (session?.guestName || t('text', 'Guest')),
color: session?.color,
},
}),
Keymap.configure({
'Mod-s': () => {
this.$syncService.save()
return true
},
}),
],
enableRichEditing: this.isRichEditor,
})
this.hasEditor = true
if (!documentState && documentSource) {
this.setContent(documentSource, { addToHistory: false })
if (!this.$editor) {
this.$editor = createEditor({
language,
relativePath: this.relativePath,
session,
onCreate: ({ editor }) => {
this.$syncService.startSync()
},
onUpdate: ({ editor }) => {
// this.debugContent(editor)
const proseMirrorMarkdown = this.$syncService.serialize(editor.state.doc)
this.$parent.$emit('update:content', {
markdown: proseMirrorMarkdown,
})
},
extensions: [
Collaboration.configure({
document: this.$ydoc,
}),
CollaborationCursor.configure({
provider: this.$providers[0],
user: {
name: session?.userId
? session.displayName
: (session?.guestName || t('text', 'Guest')),
color: session?.color,
},
}),
Keymap.configure({
'Mod-s': () => {
this.$syncService.save()
return true
},
}),
],
enableRichEditing: this.isRichEditor,
})
this.hasEditor = true
if (!documentState && documentSource) {
this.setContent(documentSource, { addToHistory: false })
}
this.listenEditorEvents()
} else {
// $editor already existed. So this is a reconnect.
this.$syncService.startSync()
}
this.listenEditorEvents()

})

Expand Down