docs: disable history buttons when commands are not available (#1721)

This commit is contained in:
Domantas
2021-08-12 10:56:04 +03:00
committed by GitHub
parent 9c5a2de63e
commit 68029b0fbb
2 changed files with 36 additions and 2 deletions

View File

@@ -80,4 +80,32 @@ context('/demos/Extensions/History', () => {
cy.get('.ProseMirror')
.should('contain', 'Mistake')
})
it('should disable undo button when there are no more changes to undo', () => {
cy.get('.ProseMirror')
.should('contain', 'Mistake')
cy.get('button:first')
.should('not.have.attr', 'disabled')
cy.get('button:first')
.click()
cy.get('button:first')
.should('have.attr', 'disabled')
})
it('should disable redo button when there are no more changes to redo', () => {
cy.get('.ProseMirror')
.should('contain', 'Mistake')
cy.get('button:nth-child(2)')
.should('have.attr', 'disabled')
cy.get('button:first')
.click()
cy.get('button:nth-child(2)')
.should('not.have.attr', 'disabled')
})
})

View File

@@ -1,9 +1,15 @@
<template>
<div v-if="editor">
<button @click="editor.chain().focus().undo().run()">
<button
@click="editor.chain().focus().undo().run()"
:disabled="!editor.can().undo()"
>
undo
</button>
<button @click="editor.chain().focus().redo().run()">
<button
@click="editor.chain().focus().redo().run()"
:disabled="!editor.can().redo()"
>
redo
</button>