How can I help you?
Undo redo in Vue Block Editor component
3 Feb 20266 minutes to read
The undo/redo feature in Block Editor enables users to revert or reapply changes made to the content, offering a safety net for edits and enhancing the overall editing experience.
Keyboard shortcuts
| Action | Windows | Mac | Description |
|---|---|---|---|
| Undo | Ctrl + Z | ⌘ + Z | Reverts the last action. |
| Redo | Ctrl + Y | ⌘ + Y | Reapplies the last undone action. |
Configuring Undo/Redo stack
The Block Editor stores a history of actions, allowing users to perform undo and redo operations. By default, it saves up to 30 actions. You can customize this limit using the undoRedoStack property to control the maximum number of steps that can be undone or redone.
The example below sets the undo/redo history limit to 20 actions.
<template>
<div id='container'>
<ejs-blockeditor :blocks="blocksData" :undoRedoStack="20"></ejs-blockeditor>
</div>
</template>
<script setup>
import { BlockEditorComponent as EjsBlockeditor, ContentType } from "@syncfusion/ej2-vue-blockeditor";
const blocksData = [
{
blockType: 'Heading',
properties: { level: 1},
content: [
{
contentType: ContentType.Text,
content: 'Sample Heading'
}
]
},
{
blockType: 'Paragraph',
content: [
{
contentType: ContentType.Text,
content: 'This is a sample paragraph block.'
}
]
},
{
blockType: 'Paragraph'
}
];
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-navigations/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-blockeditor/styles/tailwind3.css';
</style><template>
<div id='container'>
<ejs-blockeditor :blocks="blocksData" :undoRedoStack="20"></ejs-blockeditor>
</div>
</template>
<script>
import { BlockEditorComponent, ContentType } from "@syncfusion/ej2-vue-blockeditor";
export default {
components: {
'ejs-blockeditor': BlockEditorComponent,
},
data() {
return {
blocksData: [
{
blockType: 'Heading',
properties: { level: 1},
content: [
{
contentType: ContentType.Text,
content: 'Sample Heading'
}
]
},
{
blockType: 'Paragraph',
content: [
{
contentType: ContentType.Text,
content: 'This is a sample paragraph block.'
}
]
},
{
blockType: 'Paragraph'
}
]
};
},
methods: {
}
};
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-navigations/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css';
@import '../node_modules/@syncfusion/ej2-blockeditor/styles/tailwind3.css';
</style>