Skip to content

editable

Lets a person move, resize and delete the calendar’s events — with the pointer, the keyboard or the context menu.

Typeboolean
Defaultfalse
Live update (update())Yes
Declared inpackages/dom/src/settings.ts

With editable: true:

  • a timed event drags to another time or day, and resizes from its end (from its start too with eventResizableFromStart); an all-day event drags between days and stretches over more;
  • the keyboard does the same: M (or Alt+Enter) on an event holds it, the arrows move it, Shift+arrows pull its end, Enter puts it down, Escape puts it back;
  • the context menu offers “Move…”, “Change duration…” and “Delete”;
  • Ctrl/Cmd+Z undoes and Ctrl/Cmd+Shift+Z redoes (keyboardUndo).

Every change is a command, checked against rules and undoable; when it is made, onEventChange(change) hears it — persist it, and change.revert() if your server refuses. An event’s own editable, startEditable or durationEditable wins over the calendar’s: a true of its own makes it editable in a calendar that is not (durationEditable: true alone: resized, not moved), and such an event carries data-editable (move, resize); an event closed to every change (editable: false) is neither moved, resized nor deleted in an editable calendar.

import { createCalendar } from '@dzcalendar/dom';
const calendar = createCalendar(element, {
timeZone: 'Europe/Paris',
editable: true,
onEventChange: (change) => {
fetch(`/api/events/${change.after?.id}`, { method: 'PUT', body: JSON.stringify(change.after) })
.then((res) => { if (!res.ok) change.revert(); });
},
});
// Later: read-only.
calendar.update({ editable: false });

In the frameworks it is an input: Angular’s editable, React’s editable, Vue’s editable; the change is Angular’s (eventChange), React’s onEventChange, Vue’s @event-change.

Drag an event, resize it from its end, or focus it (Tab or a click) and press M then the arrows.