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
5 changes: 3 additions & 2 deletions cypress/e2e/cardFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ describe('Card', function () {
cy.get('.modal__card .ProseMirror h1').contains('Hello world').should('be.visible')
cy.get('.modal__card .ProseMirror h1')
.click()
.parent()
.type(' writing more text{enter}- List item{enter}with entries{enter}{enter}Paragraph')
cy.wait('@save', { timeout: 7000 })

Expand All @@ -284,7 +285,7 @@ describe('Card', function () {

// Scroll to the bottom to ensure all content is loaded and visible
cy.get('.modal__card .app-sidebar-tabs, .modal__card .app-sidebar__tab--active').first().scrollTo('bottom', { ensureScrollable: false })
cy.contains('.modal__card .ProseMirror p', 'Paragraph').scrollIntoView().should('be.visible')
cy.contains('.modal__card .ProseMirror p', 'Paragraph').should('be.visible')

cy.get('.modal__card .ProseMirror h1').contains('Hello world writing more text').should('be.visible')
cy.get('.modal__card .ProseMirror li').eq(0).contains('List item').should('be.visible')
Expand All @@ -298,7 +299,7 @@ describe('Card', function () {
cy.get('.card:contains("Hello world")').should('be.visible').click()
cy.get('.modal__card').should('be.visible')
cy.get('.modal__card .ProseMirror h1')
.click()
.click().parent()
.type('{enter}/create')
cy.get('.suggestion-list__item.is-selected').should('be.visible').contains('Create a new deck card')
cy.get('.suggestion-list__item.is-selected .link-picker__item').click()
Expand Down
37 changes: 31 additions & 6 deletions src/components/card/Description.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<div data-test="description">
<h5>
{{ t('deck', 'Description') }}
<span v-if="!textAppAvailable && descriptionLastEdit && !descriptionSaving">{{ t('deck', '(Unsaved)') }}</span>
<span v-if="!textAppAvailable && descriptionSaving">{{ t('deck', '(Saving…)') }}</span>
<span v-if="!collaborative && descriptionLastEdit && !descriptionSaving">{{ t('deck', '(Unsaved)') }}</span>
<span v-if="!collaborative && descriptionSaving">{{ t('deck', '(Saving…)') }}</span>
<a v-if="!textAppAvailable"
:title="t('deck', 'Formatting help')"
href="https://deck.readthedocs.io/en/latest/Markdown/"
Expand Down Expand Up @@ -40,7 +40,7 @@
id="description-preview"
dir="auto"
@click="clickedPreview"
v-html="renderedDescription" />

Check warning on line 43 in src/components/card/Description.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'v-html' directive can lead to XSS attack
<p v-else-if="!descriptionEditing" class="placeholder" @click="showEditor()">
{{ t('deck', 'Write a description …') }}
</p>
Expand Down Expand Up @@ -143,6 +143,12 @@
},
computed: {
...mapState(useSettingsStore, ['hasCardSaveError']),

// Only persisted cards can have a collaborative Text session
collaborative() {
return this.textAppAvailable && !!this.card?.id
},

mimetypeForAttachment() {
return (mimetype) => {
const url = OC.MimeType.getIconUrl(mimetype)
Expand Down Expand Up @@ -177,7 +183,7 @@
},
watch: {
card(newCard) {
if (this.textAppAvailable) {
if (this.collaborative) {
return
}
if (newCard.description !== this.descriptionOld) {
Expand All @@ -191,6 +197,10 @@
},
},
mounted() {
if (!this.collaborative) {
this.descriptionOld = this.card.description
this.description = this.card.description
}
if (this.textAppAvailable) {
this.setupEditor()
}
Expand All @@ -205,16 +215,31 @@
...mapActions(useSettingsStore, ['setHasCardSaveError']),
async setupEditor() {
await this.destroyEditor()
this.editor = await window.OCA.Text.createCollaborativeEditor({
context: { type: 'deck_card', id: this.card.id },
if (this.collaborative) {
this.editor = await window.OCA.Text.createCollaborativeEditor({
context: { type: 'deck_card', id: this.card.id },
el: this.$refs.editor,
readOnly: !this.canEdit,
})
return
}
this.editor = await window.OCA.Text.createMarkdownContentEditor({
el: this.$refs.editor,
content: this.card.description,
readOnly: !this.canEdit,
onUpdate: ({ markdown }) => {
if (this.description === markdown) {
return
}
this.description = markdown
this.updateDescription()
},
})

},
async destroyEditor() {
clearTimeout(this.descriptionSaveTimeout)
if (!this.textAppAvailable) {
if (!this.collaborative) {
await this.saveDescription()
}
try {
Expand Down
Loading