EventCopyPaste
Allow using [Ctrl/CMD + C/X/V] to copy/cut-and-paste events.
This feature also adds entries to the EventMenu for copying & cutting (see example below for how to configure) and to the ScheduleMenu for pasting.
You can configure how a newly pasted record is named using generateNewName.
//<code-header>
fiddle.title = 'Event copy paste';
//</code-header>
targetElement.innerHTML = '<p>Copy/cut and paste events using keyboard shortcuts or context menu:</p>';
new Calendar({
appendTo : targetElement,
height : 600,
// We have a little less width in our context, so reduce the responsive breakpoints
responsive : {
small : {
when : 480
},
medium : {
when : 640
}
},
date : '2024-05-13T10:00',
events : [
{ id : 1, name : 'Interview', startDate : '2024-05-13T10:00', duration : 1, durationUnit : 'h' },
{ id : 2, name : 'Press meeting', startDate : '2024-05-14T15:00', duration : 2, durationUnit : 'h' },
{ id : 3, name : 'Audition', startDate : '2024-05-15T08:00', duration : 3, durationUnit : 'h' }
]
});This feature is enabled by default.
Customize menu items
See EventMenu and ScheduleMenu for more info on customizing the menu items supplied by the feature. This snippet illustrates the concept:
// Custom copy text + remove cut option from event menu:
const calendar = new Calendar({
features : {
eventMenu : {
items : {
copyEvent : {
text : 'Copy booking'
},
cutEvent : false
}
}
}
});
Keyboard shortcuts
The feature has the following default keyboard shortcuts:
| Keys | Action | Action description |
|---|---|---|
Ctrl+C |
copy | Copies selected event into the clipboard. |
Ctrl+X |
cut | Cuts out selected event into the clipboard. |
Ctrl+V |
paste | Insert copied or cut event from the clipboard. |
Ctrl is the equivalent to Command and Alt
is the equivalent to Option for Mac usersFor more information on how to customize keyboard shortcuts, please see our guide.
Native/shared clipboard
If you have multiple Calendars (or other Bryntum products) on the same page, they will share clipboard. This makes
it possible to copy and paste between different Calendar instances. It is also possible to use the native Clipboard
API if it is available and if you set useNativeClipboard to true.
Regardless of native clipboard availability, copy-pasting "outside" of the current Calendar instance will convert the copied events to a string. When pasting, the string will then be parsed back into events. In case of usage of the native Clipboard API, this means it is possible to copy and paste events between completely different applications.
To configure the fields that is converted and parsed from the copied string value, please see the eventToStringFields config.