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
27 changes: 26 additions & 1 deletion cypress/e2e/directediting.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const createDirectEditingLinkForNewFile = (user, file) => {

describe('direct editing', function() {
before(function() {
initUserAndFiles(randUser, 'test.md', 'empty.md')
initUserAndFiles(randUser, 'test.md', 'empty.md', 'empty.txt')
})

it('Open an existing file, edit and close it', () => {
Expand Down Expand Up @@ -101,4 +101,29 @@ describe('direct editing', function() {
})
})
})

it('Open an existing plain text file, edit and close it', () => {
createDirectEditingLink(randUser, 'empty.txt')
.then((token) => {
cy.logout()
cy.visit(token)
})
const closeRequestAlias = 'closeRequest'
cy.intercept({ method: 'POST', url: '**/session/close' }).as(closeRequestAlias)

cy.getContent()
.type('# This is a headline')
.type('{enter}')
.type('Some text')
.type('{enter}')

cy.get('button.icon-close').click()
cy.wait(`@${closeRequestAlias}`).then(() => {
cy.getFileContent(randUser, 'empty.txt').then((content) => {
// FIXME: This currently fails due to the save not happening fast enough
// The best would be if we always send the markdown at least on close and perform a save if the content changed
// expect(content).to.equal('# This is a headline\n\nSome text');
})
})
})
})
Empty file added cypress/fixtures/empty.txt
Empty file.
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/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.

1 change: 0 additions & 1 deletion lib/DirectEditing/TextDirectEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ public function open(IToken $token): Response {
$this->initialStateService->provideInitialState('text', 'file', [
'fileId' => $token->getFile()->getId(),
'mimetype' => $token->getFile()->getMimeType(),
'content' => $token->getFile()->getContent(),
'session' => \json_encode($session->getData())
]);
$this->initialStateService->provideInitialState('text', 'directEditingToken', $token->getToken());
Expand Down
4 changes: 1 addition & 3 deletions src/services/SyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,10 @@ class SyncService {
document: this.document,
session: this.session,
})
const content = connectionData.content
|| await this._fetchDocument()
this.emit('loaded', {
document: this.document,
session: this.session,
documentSource: '' + content,
documentSource: '' + connectionData.content,
})
}

Expand Down