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
13 changes: 7 additions & 6 deletions cypress/e2e/share.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,16 @@ describe('Open test.md in viewer', function() {
cy.shareFile('/folder')
.then((token) => {
cy.logout()
cy.visit(`/s/${token}`)

return cy.visit(`/s/${token}`)
})
.then(() => {
cy.get('#rich-workspace').should('contain', 'Hello world')
cy.get('#rich-workspace').getContent().should('contain', 'Hello world')
cy.openFile('test.md')
cy.get('#editor-container').should('be.visible')
cy.get('#editor .ProseMirror').should('contain', 'Hello world')
cy.get('#editor .ProseMirror h2').should('contain', 'Hello world')
cy.get('.modal-header button.header-close').click()
cy.getModal().getContent().should('be.visible')
cy.getModal().getContent().should('contain', 'Hello world')
cy.getModal().getContent().find('h2').should('contain', 'Hello world')
cy.getModal().find('.modal-header button.header-close').click()
cy.get('.modal-mask').should('not.exist')
})
})
Expand Down
17 changes: 12 additions & 5 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,14 @@ Cypress.Commands.add('deleteFile', fileName => {
cy.get(`.files-fileList tr[data-file="${fileName}"]`).should('not.exist')
})

Cypress.Commands.add('getEditor', () => {
return cy.get('[data-text-el="editor-container"]')
Cypress.Commands.add('getModal', () => {
return cy.get('#viewer[data-handler="text"]')
})

Cypress.Commands.add('getEditor', { prevSubject: 'optional' }, (subject) => {
return subject
? cy.wrap(subject).find('[data-text-el="editor-container"]')
: cy.get('[data-text-el="editor-container"]')
})

Cypress.Commands.add('getMenu', { prevSubject: 'optional' }, (subject) => {
Expand All @@ -278,8 +284,9 @@ Cypress.Commands.add('getActionEntry', { prevSubject: 'optional' }, (subject, na
.find(`[data-text-action-entry="${name}"]`)
})

Cypress.Commands.add('getContent', () => {
return cy.getEditor().find('.ProseMirror')
Cypress.Commands.add('getContent', { prevSubject: 'optional' }, (subject) => {
return (subject ? cy.wrap(subject) : cy.getEditor())
.find('.ProseMirror')
})

Cypress.Commands.add('getOutline', () => {
Expand All @@ -296,7 +303,7 @@ Cypress.Commands.add('clearContent', () => {
.type('{selectAll}{backspace}', { force: true })
})

Cypress.Commands.add('openWorkspace', (subject, name) => {
Cypress.Commands.add('openWorkspace', () => {
cy.get('#rich-workspace .empty-workspace').click()
cy.getEditor().find('[data-text-el="editor-content-wrapper"]').click()

Expand Down
4 changes: 2 additions & 2 deletions js/editor-rich.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor-rich.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.

4 changes: 3 additions & 1 deletion src/components/ViewerComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
</template>

<script>
import { getSharingToken } from '../helpers/token.js'

export default {
name: 'ViewerComponent',
components: {
Expand All @@ -54,7 +56,7 @@ export default {
},
shareToken: {
type: String,
default: null,
default: () => getSharingToken(),
},
mime: {
type: String,
Expand Down
5 changes: 2 additions & 3 deletions src/helpers/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import { loadState } from '@nextcloud/initial-state'
import { openMimetypes } from './mime.js'
import { getSharingToken } from './token.js'
import RichWorkspace from '../views/RichWorkspace.vue'
import { imagePath } from '@nextcloud/router'
import store from '../store/index.js'
Expand Down Expand Up @@ -77,9 +78,8 @@ const registerFileCreate = () => {
}

const registerFileActionFallback = () => {
const sharingToken = document.getElementById('sharingToken') ? document.getElementById('sharingToken').value : null
const sharingToken = getSharingToken()
const filesTable = document.querySelector('#preview table.files-filestable')

if (!sharingToken || !filesTable) {
const ViewerRoot = document.createElement('div')
ViewerRoot.id = 'text-viewer-fallback'
Expand Down Expand Up @@ -135,7 +135,6 @@ const registerFileActionFallback = () => {
}

const FilesWorkspacePlugin = {

el: null,

attach(fileList) {
Expand Down
5 changes: 5 additions & 0 deletions src/helpers/token.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const getSharingToken = () => document.getElementById('sharingToken')
? document.getElementById('sharingToken').value
: null

export { getSharingToken }