FullCalendar Copy-paste Plugin
The Plugin expands for FullCalendar, which aims to add copy and paste features using shortcuts.
Actions | Window | Mac | Description |
---|---|---|---|
Copy | Ctrl + C | Cmd + C | Select event to copy. |
Cut | Ctrl + X | Cmd + X | Select event to cut. |
Paste | Ctrl + V | Cmd + V | Or you can press Enter or Click to paste. |
Duplicate | Ctrl + D | Cmd + D | Instantly clone an event. |
Cancel | ESC | ESC | Or click on the location outside the Calendar. |
Installation
- Install this library in your project.
npm i fullcalendar-copy-paste
- Use the plugin.
import copyPastePlugin from 'fullcalendar-copy-paste'
new Calendar(calendarEl, {
plugins: [copyPastePlugin],
height: "100%",
}
Configuration
Fields | Type | Description |
---|---|---|
previewCopy | Boolean | Default: true, Set false if the u wants to catch the event without wanting the view to change. |
eventCopy | Callback | Used when you want tho track changes of new and old events. |
Exp:
new Calendar(calendarEl, {
plugins: [copyPastePlugin],
height: "100%",
previewCopy: false,
eventCopy: (trigger) => {
const oldEvent = trigger.oldEvent;
const newEvent = trigger.event;
const type = trigger.type;
if (trigger.type === 'copy') {
// do something
} else if (trigger.type === 'cut') {
// do something
}
}
});
API:
API for external code:
window.calendarUtils.copy(element as HTMLElement)
window.calendarUtils.cut(element as HTMLElement);
Demo:
Copy:
Cut:
Duplicate:
Contributor: ToanNguyen