본문으로 건너뛰기Skip to content
예제 첫화면Examples home

편집할 수 없는 작업 알아보기Which tasks cannot be edited

요약 작업, 일정 없는 작업은 전부, 마일스톤은 이동만 되고 나머지는 막혀요.Summary and unscheduled tasks are fully locked, and milestones can only be moved.

활용Intermediate
직접 써 보기Live preview편집할 수 없는 작업 알아보기Which tasks cannot be edited

코드Code

탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.

빌드 도구(Vite 등)를 쓰는 프로젝트용 모듈 파일이에요. 설치 없이 바로 돌려 보려면 HTML 탭이나 직접 해보기를 쓰세요.

이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i maxgrid @maxgrid/gantt로 설치하세요.

버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.

index.html
<div id="app">
  <div class="toolbar">
    <select aria-label="편집" id="editable">
      <option value="on" selected>켜기</option>
      <option value="off">끄기</option>
    </select>
  </div>
  <div id="grid" style="height: 480px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('editable').addEventListener('change', (event) => actions.editable(api, event.target.value));
example.js
import { createGantt, createSplitView } from '@maxgrid/gantt';
// [id, 부모, 작업, 담당자, 시작, 종료, 진행률, 상태]. 날짜가 비면 일정 없음, 시작=종료면 마일스톤이에요.
const T = [
  ['1', null, '웹사이트 개편', '이준호', '2026-12-01', '2027-03-05', 0, 'TODO'],
  ['2', '1', '기획', '박민지', '2026-12-01', '2026-12-11', 0, 'TODO'],
  ['3', '2', '요구사항 수집', '박민지', '2026-12-01', '2026-12-08', 100, 'DONE'],
  ['4', '2', '경쟁 서비스 조사', '이준호', '2026-12-03', '2026-12-10', 100, 'DONE'],
  ['5', '2', '범위 확정', '박민지', '2026-12-11', '2026-12-11', 0, 'TODO'],
  ['6', '1', '디자인', '최하은', '2026-12-14', '2027-01-13', 0, 'TODO'],
  ['7', '6', '와이어프레임', '최하은', '2026-12-14', '2026-12-23', 40, 'IN_PROGRESS'],
  ['8', '6', '화면 디자인', '최하은', '2026-12-21', '2027-01-08', 10, 'IN_PROGRESS'],
  ['9', '6', '아이콘 세트', '한지우', '2026-12-28', '2027-01-08', 0, 'TODO'],
  ['10', '6', '디자인 검토', '최하은', '2027-01-11', '2027-01-13', 0, 'TODO'],
  ['11', '1', '개발', '김도윤', '2027-01-11', '2027-02-19', 0, 'TODO'],
  ['12', '11', '프런트엔드', '한지우', '2027-01-11', '2027-02-05', 0, 'TODO'],
  ['13', '11', '백엔드', '김도윤', '2027-01-11', '2027-02-12', 0, 'TODO'],
  ['14', '11', '검색 기능', '이준호', '2027-01-25', '2027-02-12', 0, 'TODO'],
  ['15', '11', '결제 기능', '김도윤', '2027-01-25', '2027-02-19', 0, 'TODO'],
  ['16', '11', '콘텐츠 입력', '박민지', '2027-01-18', '2027-02-12', 0, 'TODO'],
  ['17', '11', '통합', '김도윤', '2027-02-08', '2027-02-19', 0, 'TODO'],
  ['18', '1', '출시', '이준호', '2027-02-15', '2027-03-01', 0, 'TODO'],
  ['19', '18', '품질 점검', '한지우', '2027-02-15', '2027-02-26', 0, 'TODO'],
  ['20', '18', '출시일', '이준호', '2027-03-01', '2027-03-01', 0, 'TODO'],
  ['21', '1', '인수인계', '박민지', '2027-02-22', '2027-03-05', 0, 'TODO'],
  ['22', '21', '운영 교육', '박민지', '2027-02-22', '2027-03-05', 0, 'TODO'],
  ['23', '21', '문서화', '한지우', '2027-02-22', '2027-03-03', 0, 'TODO'],
  ['24', '11', '푸시 알림', '김도윤', '', '', 0, 'TODO'],
  ['25', '2', '법무 검토', '박민지', '', '', 0, 'TODO'],
];
// [앞 작업, 뒤 작업, 종류, 지연(작업일)]
const D = [
  ['3', '5', 'FS', 0],
  ['4', '5', 'FS', 0],
  ['5', '7', 'FS', 0],
  ['7', '8', 'SS', 3],
  ['8', '10', 'FF', 0],
  ['10', '12', 'FS', 0],
  ['10', '13', 'FS', 0],
  ['12', '17', 'FF', 0],
  ['13', '17', 'FS', 0],
  ['17', '19', 'FS', 0],
  ['19', '20', 'FS', 0],
];
// 같은 부모 안의 순서(sortNo)와 WBS 번호는 배열 순서에서 계산해요.
const parents = new Set(T.map((r) => r[1]));
const counts = new Map();
const wbsOf = new Map();
const sortOf = new Map();
for (const [id, parent] of T) {
  const n = (counts.get(parent) ?? 0) + 1;
  counts.set(parent, n);
  sortOf.set(id, n);
  wbsOf.set(id, parent === null ? String(n) : wbsOf.get(parent) + '.' + n);
}
// 표에 넣을 평평한 행(부모 id만 알면 트리가 돼요).
const rows = T.map(([id, parentId, name, assignee, start, end, progress]) => ({
  id,
  parentId,
  wbs: wbsOf.get(id),
  name,
  assignee,
  start,
  end,
  progress,
}));
// 간트 차트에 넣을 데이터. 날짜 계산은 하지 않고 받은 값을 그대로 그려요.
const data = {
  tasks: T.map(([id, parentId, name, assignee, start, end, progressPct, status]) => ({
    id,
    parentId,
    sortNo: sortOf.get(id),
    name,
    status,
    plannedStart: start || null,
    plannedEnd: end || null,
    progressPct,
    isMilestone: start !== '' && start === end,
    hasChildren: parents.has(id),
    calendarId: null,
    wbsCode: wbsOf.get(id),
    assigneeName: assignee,
    version: 1,
  })),
  dependencies: D.map(([predecessorId, successorId, depType, lagDays], n) => ({
    id: 'd' + (n + 1),
    predecessorId,
    successorId,
    depType,
    lagDays,
  })),
  calendars: [
    {
      id: 'std',
      name: '표준 달력(월-금)',
      workDays: 31,
      isDefault: true,
      exceptions: [],
    },
  ],
};
export const options = {
  columns: [
    { id: 'wbs', title: 'WBS', width: 70 },
    { id: 'name', title: '작업', width: 220 },
    { id: 'assignee', title: '담당자', width: 110 },
    { id: 'start', title: '시작', width: 100 },
    { id: 'end', title: '종료', width: 100 },
    { id: 'progress', title: '진행률(%)', kind: 'number', width: 90, align: 'end' },
  ],
  rows,
  rowKey: 'id',
  // 간트와 줄을 맞추려면 행·머리글 높이를 같게 맞춰야 해요(머리글 48, 행 32).
  rowHeight: 32,
  headerHeight: 48,
  verticalScroll: 'external',
  selection: 'single',
  tree: { parentKey: 'parentId', column: 'name', expandDepth: 'all' },
};
// 표 옆에 간트 차트를 붙여요: 표 요소를 왼쪽 칸으로 옮기고 createSplitView로 묶어요.
function mountGantt(api, ganttOptions = {}) {
  const gridEl = api.getGridElement();
  const host = gridEl.parentElement;
  const box = document.createElement('div');
  const left = document.createElement('div');
  const right = document.createElement('div');
  box.style.cssText = 'position: relative; width: 100%; height: 100%;';
  box.append(left, right);
  host.append(box);
  left.append(gridEl);
  const split = createSplitView({
    left,
    right,
    container: box,
    initial: 0.45,
    min: box.clientWidth < 600 ? 110 : 240,
  });
  // 좁은 컨테이너(600px 미만)에서는 앞의 열만 남겨 차트 자리를 확보해요. 넓어지면 열이 돌아와요.
  const fitColumns = () => {
    const narrow = box.clientWidth < 600;
    for (const id of ['assignee', 'start', 'end', 'progress'])
      api.setColumnVisible(id, !narrow);
    api.resizeColumn('wbs', narrow ? 58 : 70);
  };
  fitColumns();
  const fitObserver = new ResizeObserver(fitColumns);
  fitObserver.observe(box);
  const gantt = createGantt(right, {
    rowHeight: 32,
    locale: 'ko',
    verticalScroll: 'external',
    ...ganttOptions,
  });
  return {
    gantt,
    box,
    destroy() {
      // 연결을 풀고 표를 원래 자리로 돌려놔요.
      gantt.destroy();
      fitObserver.disconnect();
      split.destroy();
      host.append(gridEl);
      box.remove();
    },
  };
}
// 표 행을 고쳐 써요(표시용 문자열과 진행률).
function syncRow(api, id, f) {
  // rows에는 쓰지 않아요: 표가 그 객체를 그대로 쥐고 있어서, 이미 바뀐 행으로 갱신하면 달라진 게 없다고 보고 화면을 안 고쳐요.
  const row = api.getRowByKey(id);
  if (!row)
    return;
  const next = { ...row };
  if (f.plannedStart !== undefined)
    next.start = f.plannedStart;
  if (f.plannedEnd !== undefined)
    next.end = f.plannedEnd;
  if (f.progressPct !== undefined)
    next.progress = f.progressPct;
  api.updateRows([next]);
}
let view = null;
let editable = true;
let say = () => { };
// 차트 아래쪽에 현재 상태를 보여요(화면 낭독기용 role=status).
function setNote(text) {
  const box = view?.box;
  if (!box)
    return;
  let note = box.querySelector('[data-note]');
  if (!note) {
    note = document.createElement('div');
    note.dataset['note'] = '1';
    note.setAttribute('role', 'status');
    note.style.cssText =
      'position: absolute; right: 8px; bottom: 8px; z-index: 5; padding: 2px 8px; font-size: 12px; border-radius: 4px; pointer-events: none; background: var(--mxg-bg, #fff); color: var(--mxg-fg, #1f2933); border: 1px solid var(--mxg-border, #d9dee5);';
    box.append(note);
  }
  note.textContent = text;
}
export function setup(api, log) {
  editable = true;
  say = log;
  view = mountGantt(api, { editable: true });
  const gantt = view.gantt;
  gantt.setData(data);
  const unlink = gantt.attachGrid(api);
  const timers = new Set();
  // 편집할 수 없는 줄(요약·일정 없음)은 이벤트가 오지 않아요. 온 요청은 모두 승인해요.
  const answer = (intentId, taskId, f) => {
    const timer = setTimeout(() => {
      timers.delete(timer);
      gantt.applyPatch({ tasks: [{ id: taskId, ...f }], intentId });
      syncRow(api, taskId, f);
    }, 400);
    timers.add(timer);
  };
  const offs = [
    gantt.on('row-select', (e) => {
      if (editable || e.taskId === null)
        return;
      log({
        ko: `${e.taskId}번은 읽기 전용이에요. 위에서 편집을 켜면 끌 수 있어요`,
        en: `Task ${e.taskId} is read-only. Turn editing on above to drag it`,
      });
    }),
    gantt.on('task-move', (e) => {
      log({
        ko: `이동: ${e.taskId}번 → ${e.plannedStart} ~ ${e.plannedEnd}`,
        en: `Move: task ${e.taskId} to ${e.plannedStart} ~ ${e.plannedEnd}`,
      });
      answer(e.intentId, e.taskId, { plannedStart: e.plannedStart, plannedEnd: e.plannedEnd });
    }),
    gantt.on('task-resize', (e) => {
      log({
        ko: `크기: ${e.taskId}번 → ${e.plannedStart} ~ ${e.plannedEnd}`,
        en: `Resize: task ${e.taskId} to ${e.plannedStart} ~ ${e.plannedEnd}`,
      });
      answer(e.intentId, e.taskId, { plannedStart: e.plannedStart, plannedEnd: e.plannedEnd });
    }),
    gantt.on('task-progress', (e) => {
      log({
        ko: `진행률: ${e.taskId}번 → ${e.progressPct}%`,
        en: `Progress: task ${e.taskId} to ${e.progressPct}%`,
      });
      answer(e.intentId, e.taskId, { progressPct: e.progressPct });
    }),
  ];
  const summaries = data.tasks.filter((x) => x.hasChildren).length;
  const unscheduled = data.tasks.filter((x) => x.plannedStart === null).length;
  const milestones = data.tasks.filter((x) => x.isMilestone).length;
  log({
    ko: `요약 ${summaries}개, 마일스톤 ${milestones}개, 일정 없음 ${unscheduled}개는 일부 또는 전부 편집할 수 없어요`,
    en: `${summaries} summary, ${milestones} milestone and ${unscheduled} unscheduled tasks are fully or partly read-only`,
  });
  return () => {
    timers.forEach(clearTimeout);
    offs.forEach((off) => off());
    unlink();
    view?.destroy();
    view = null;
  };
}
export const actions = {
  // 편집을 켜고 꺼요. 끄면 손잡이와 끌기가 모두 사라져요.
  editable: (_api, value) => {
    editable = value !== 'off';
    view?.gantt.setOptions({ editable });
    say({
      ko: editable ? '편집 켜짐: 막대를 끌 수 있어요' : '편집 꺼짐: 막대를 눌러도 읽기 전용이에요',
      en: editable ? 'Editing on: bars can be dragged' : 'Editing off: bars are read-only',
    });
    setNote(editable ? '편집 켜짐' : '편집 꺼짐');
  },
};

Module files for a project with a bundler such as Vite. To run it with no setup, use the HTML tab or Try it.

This example needs an extra package. To run it locally, install with npm i maxgrid @maxgrid/gantt.

When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.

index.html
<div id="app">
  <div class="toolbar">
    <select aria-label="Editing" id="editable">
      <option value="on" selected>On</option>
      <option value="off">Off</option>
    </select>
  </div>
  <div id="grid" style="height: 480px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('editable').addEventListener('change', (event) => actions.editable(api, event.target.value));
example.js
import { createGantt, createSplitView } from '@maxgrid/gantt';
// [id, parent, task, assignee, start, end, progress, status]. No dates means unscheduled; start = end means a milestone.
const T = [
  ['1', null, 'Website renewal', 'Liam Carter', '2026-12-01', '2027-03-05', 0, 'TODO'],
  ['2', '1', 'Planning', 'Emma Stone', '2026-12-01', '2026-12-11', 0, 'TODO'],
  ['3', '2', 'Requirements', 'Emma Stone', '2026-12-01', '2026-12-08', 100, 'DONE'],
  ['4', '2', 'Competitor review', 'Liam Carter', '2026-12-03', '2026-12-10', 100, 'DONE'],
  ['5', '2', 'Scope sign-off', 'Emma Stone', '2026-12-11', '2026-12-11', 0, 'TODO'],
  ['6', '1', 'Design', 'Noah Reed', '2026-12-14', '2027-01-13', 0, 'TODO'],
  ['7', '6', 'Wireframes', 'Noah Reed', '2026-12-14', '2026-12-23', 40, 'IN_PROGRESS'],
  ['8', '6', 'Visual design', 'Noah Reed', '2026-12-21', '2027-01-08', 10, 'IN_PROGRESS'],
  ['9', '6', 'Icon set', 'Olivia Park', '2026-12-28', '2027-01-08', 0, 'TODO'],
  ['10', '6', 'Design review', 'Noah Reed', '2027-01-11', '2027-01-13', 0, 'TODO'],
  ['11', '1', 'Build', 'Ethan Cole', '2027-01-11', '2027-02-19', 0, 'TODO'],
  ['12', '11', 'Front end', 'Olivia Park', '2027-01-11', '2027-02-05', 0, 'TODO'],
  ['13', '11', 'Back end', 'Ethan Cole', '2027-01-11', '2027-02-12', 0, 'TODO'],
  ['14', '11', 'Search feature', 'Liam Carter', '2027-01-25', '2027-02-12', 0, 'TODO'],
  ['15', '11', 'Payments', 'Ethan Cole', '2027-01-25', '2027-02-19', 0, 'TODO'],
  ['16', '11', 'Content entry', 'Emma Stone', '2027-01-18', '2027-02-12', 0, 'TODO'],
  ['17', '11', 'Integration', 'Ethan Cole', '2027-02-08', '2027-02-19', 0, 'TODO'],
  ['18', '1', 'Launch', 'Liam Carter', '2027-02-15', '2027-03-01', 0, 'TODO'],
  ['19', '18', 'QA', 'Olivia Park', '2027-02-15', '2027-02-26', 0, 'TODO'],
  ['20', '18', 'Go-live', 'Liam Carter', '2027-03-01', '2027-03-01', 0, 'TODO'],
  ['21', '1', 'Handover', 'Emma Stone', '2027-02-22', '2027-03-05', 0, 'TODO'],
  ['22', '21', 'Training', 'Emma Stone', '2027-02-22', '2027-03-05', 0, 'TODO'],
  ['23', '21', 'Docs', 'Olivia Park', '2027-02-22', '2027-03-03', 0, 'TODO'],
  ['24', '11', 'Push notifications', 'Ethan Cole', '', '', 0, 'TODO'],
  ['25', '2', 'Legal review', 'Emma Stone', '', '', 0, 'TODO'],
];
// [predecessor, successor, type, lag (working days)]
const D = [
  ['3', '5', 'FS', 0],
  ['4', '5', 'FS', 0],
  ['5', '7', 'FS', 0],
  ['7', '8', 'SS', 3],
  ['8', '10', 'FF', 0],
  ['10', '12', 'FS', 0],
  ['10', '13', 'FS', 0],
  ['12', '17', 'FF', 0],
  ['13', '17', 'FS', 0],
  ['17', '19', 'FS', 0],
  ['19', '20', 'FS', 0],
];
// The order inside a parent (sortNo) and the WBS number come from the array order.
const parents = new Set(T.map((r) => r[1]));
const counts = new Map();
const wbsOf = new Map();
const sortOf = new Map();
for (const [id, parent] of T) {
  const n = (counts.get(parent) ?? 0) + 1;
  counts.set(parent, n);
  sortOf.set(id, n);
  wbsOf.set(id, parent === null ? String(n) : wbsOf.get(parent) + '.' + n);
}
// Flat grid rows (a parent id is enough to make a tree).
const rows = T.map(([id, parentId, name, assignee, start, end, progress]) => ({
  id,
  parentId,
  wbs: wbsOf.get(id),
  name,
  assignee,
  start,
  end,
  progress,
}));
// Data for the Gantt chart. It draws the values as given and does no date math.
const data = {
  tasks: T.map(([id, parentId, name, assignee, start, end, progressPct, status]) => ({
    id,
    parentId,
    sortNo: sortOf.get(id),
    name,
    status,
    plannedStart: start || null,
    plannedEnd: end || null,
    progressPct,
    isMilestone: start !== '' && start === end,
    hasChildren: parents.has(id),
    calendarId: null,
    wbsCode: wbsOf.get(id),
    assigneeName: assignee,
    version: 1,
  })),
  dependencies: D.map(([predecessorId, successorId, depType, lagDays], n) => ({
    id: 'd' + (n + 1),
    predecessorId,
    successorId,
    depType,
    lagDays,
  })),
  calendars: [
    {
      id: 'std',
      name: 'Standard calendar (Mon-Fri)',
      workDays: 31,
      isDefault: true,
      exceptions: [],
    },
  ],
};
export const options = {
  columns: [
    { id: 'wbs', title: 'WBS', width: 70 },
    { id: 'name', title: 'Task', width: 220 },
    { id: 'assignee', title: 'Assignee', width: 110 },
    { id: 'start', title: 'Start', width: 100 },
    { id: 'end', title: 'End', width: 100 },
    { id: 'progress', title: 'Progress (%)', kind: 'number', width: 90, align: 'end' },
  ],
  rows,
  rowKey: 'id',
  // Keep row and header heights equal to the chart so the lines line up (header 48, row 32).
  rowHeight: 32,
  headerHeight: 48,
  verticalScroll: 'external',
  selection: 'single',
  tree: { parentKey: 'parentId', column: 'name', expandDepth: 'all' },
};
// Put the Gantt chart next to the grid: move the grid element into the left pane and join both with createSplitView.
function mountGantt(api, ganttOptions = {}) {
  const gridEl = api.getGridElement();
  const host = gridEl.parentElement;
  const box = document.createElement('div');
  const left = document.createElement('div');
  const right = document.createElement('div');
  box.style.cssText = 'position: relative; width: 100%; height: 100%;';
  box.append(left, right);
  host.append(box);
  left.append(gridEl);
  const split = createSplitView({
    left,
    right,
    container: box,
    initial: 0.45,
    min: box.clientWidth < 600 ? 110 : 240,
  });
  // Narrow container (< 600 px): only the first columns stay so the chart keeps room; the rest come back when it widens.
  const fitColumns = () => {
    const narrow = box.clientWidth < 600;
    for (const id of ['assignee', 'start', 'end', 'progress'])
      api.setColumnVisible(id, !narrow);
    api.resizeColumn('wbs', narrow ? 58 : 70);
  };
  fitColumns();
  const fitObserver = new ResizeObserver(fitColumns);
  fitObserver.observe(box);
  const gantt = createGantt(right, {
    rowHeight: 32,
    locale: 'en',
    verticalScroll: 'external',
    ...ganttOptions,
  });
  return {
    gantt,
    box,
    destroy() {
      // Detach and put the grid back where it was.
      gantt.destroy();
      fitObserver.disconnect();
      split.destroy();
      host.append(gridEl);
      box.remove();
    },
  };
}
// Write the new values into the grid row (display strings and progress).
function syncRow(api, id, f) {
  // Don't write into `rows`: the grid holds those very objects, so an update equal to the old row changes nothing on screen.
  const row = api.getRowByKey(id);
  if (!row)
    return;
  const next = { ...row };
  if (f.plannedStart !== undefined)
    next.start = f.plannedStart;
  if (f.plannedEnd !== undefined)
    next.end = f.plannedEnd;
  if (f.progressPct !== undefined)
    next.progress = f.progressPct;
  api.updateRows([next]);
}
let view = null;
let editable = true;
let say = () => { };
// Shows the current state over the chart (role=status for screen readers).
function setNote(text) {
  const box = view?.box;
  if (!box)
    return;
  let note = box.querySelector('[data-note]');
  if (!note) {
    note = document.createElement('div');
    note.dataset['note'] = '1';
    note.setAttribute('role', 'status');
    note.style.cssText =
      'position: absolute; right: 8px; bottom: 8px; z-index: 5; padding: 2px 8px; font-size: 12px; border-radius: 4px; pointer-events: none; background: var(--mxg-bg, #fff); color: var(--mxg-fg, #1f2933); border: 1px solid var(--mxg-border, #d9dee5);';
    box.append(note);
  }
  note.textContent = text;
}
export function setup(api, log) {
  editable = true;
  say = log;
  view = mountGantt(api, { editable: true });
  const gantt = view.gantt;
  gantt.setData(data);
  const unlink = gantt.attachGrid(api);
  const timers = new Set();
  // Rows that cannot be edited (summary, unscheduled) send no event. Every request that arrives is approved.
  const answer = (intentId, taskId, f) => {
    const timer = setTimeout(() => {
      timers.delete(timer);
      gantt.applyPatch({ tasks: [{ id: taskId, ...f }], intentId });
      syncRow(api, taskId, f);
    }, 400);
    timers.add(timer);
  };
  const offs = [
    gantt.on('row-select', (e) => {
      if (editable || e.taskId === null)
        return;
      log(`Task ${e.taskId} is read-only. Turn editing on above to drag it`);
    }),
    gantt.on('task-move', (e) => {
      log(`Move: task ${e.taskId} to ${e.plannedStart} ~ ${e.plannedEnd}`);
      answer(e.intentId, e.taskId, { plannedStart: e.plannedStart, plannedEnd: e.plannedEnd });
    }),
    gantt.on('task-resize', (e) => {
      log(`Resize: task ${e.taskId} to ${e.plannedStart} ~ ${e.plannedEnd}`);
      answer(e.intentId, e.taskId, { plannedStart: e.plannedStart, plannedEnd: e.plannedEnd });
    }),
    gantt.on('task-progress', (e) => {
      log(`Progress: task ${e.taskId} to ${e.progressPct}%`);
      answer(e.intentId, e.taskId, { progressPct: e.progressPct });
    }),
  ];
  const summaries = data.tasks.filter((x) => x.hasChildren).length;
  const unscheduled = data.tasks.filter((x) => x.plannedStart === null).length;
  const milestones = data.tasks.filter((x) => x.isMilestone).length;
  log(`${summaries} summary, ${milestones} milestone and ${unscheduled} unscheduled tasks are fully or partly read-only`);
  return () => {
    timers.forEach(clearTimeout);
    offs.forEach((off) => off());
    unlink();
    view?.destroy();
    view = null;
  };
}
export const actions = {
  // Turn editing on or off. Off removes the handles and all dragging.
  editable: (_api, value) => {
    editable = value !== 'off';
    view?.gantt.setOptions({ editable });
    say(editable ? 'Editing on: bars can be dragged' : 'Editing off: bars are read-only');
    setNote(editable ? 'Editing on' : 'Editing off');
  },
};