Skip to content

Commit

Permalink
Feature: Show word count in RichText
Browse files Browse the repository at this point in the history
Show word count as last element of the overflow menu,
which now will be always shown. The word count
is updated when the menu is openend as the
tiptap word count is not reactive.

Modified ActionList: Added a named slot for adding
elements that should always shown as the last elements.

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
  • Loading branch information
susnux authored and max-nextcloud committed Sep 19, 2022
1 parent 50dd58f commit d26ef67
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 523 deletions.
64 changes: 64 additions & 0 deletions cypress/e2e/MenuBar.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { initUserAndFiles, randHash } from '../utils/index.js'

const randUser = randHash()
const fileName = 'test.md'

describe('Test the rich text editor menu bar', function() {
before(() => initUserAndFiles(randUser, fileName))

beforeEach(function() {
cy.login(randUser, 'password', {
onBeforeLoad(win) {
cy.stub(win, 'open')
.as('winOpen')

},
})

cy.openFile(fileName)
})

describe('word count', function() {
/**
*
*/
function getWordCount() {
return cy.get('.popover .open').get('[data-text-action-entry="word-count"]')
}

beforeEach(cy.clearContent)
it('empty file', () => {
cy.getFile(fileName)
.then($el => {
cy.getActionEntry('remain')
.click()
getWordCount()
.should('include.text', '0 words')
})
})

it('single word', () => {
cy.getFile(fileName)
.then($el => {
cy.getContent()
.type(' Hello ')
cy.getActionEntry('remain')
.click()
getWordCount()
.should('include.text', '1 word')
})
})

it('multiple words', () => {
cy.getFile(fileName)
.then($el => {
cy.getContent()
.type('Hello \nworld')
cy.getActionEntry('remain')
.click()
getWordCount()
.should('include.text', '2 word')
})
})
})
})
Loading

0 comments on commit d26ef67

Please sign in to comment.