From cafe932cbc3e1af9a1a0d106f599fcf06f73bda5 Mon Sep 17 00:00:00 2001 From: Franck Zagala Date: Mon, 22 Jan 2024 20:11:27 +0000 Subject: [PATCH 01/41] implement until keyword in gantt charts --- docs/syntax/gantt.md | 13 +++-- .../mermaid/src/diagrams/gantt/ganttDb.js | 29 ++++++++++ .../src/diagrams/gantt/ganttDb.spec.ts | 56 ++++++++++++++++++- packages/mermaid/src/docs/syntax/gantt.md | 9 ++- 4 files changed, 99 insertions(+), 8 deletions(-) diff --git a/docs/syntax/gantt.md b/docs/syntax/gantt.md index 07fc897ec..08d24c036 100644 --- a/docs/syntax/gantt.md +++ b/docs/syntax/gantt.md @@ -67,8 +67,8 @@ gantt Create tests for parser :crit, active, 3d Future task in critical line :crit, 5d Create tests for renderer :2d - Add to mermaid :1d - Functionality added :milestone, 2014-01-25, 0d + Add to mermaid :until isadded + Functionality added :milestone, isadded, 2014-01-25, 0d section Documentation Describe gantt syntax :active, a1, after des1, 3d @@ -100,8 +100,8 @@ gantt Create tests for parser :crit, active, 3d Future task in critical line :crit, 5d Create tests for renderer :2d - Add to mermaid :1d - Functionality added :milestone, 2014-01-25, 0d + Add to mermaid :until isadded + Functionality added :milestone, isadded, 2014-01-25, 0d section Documentation Describe gantt syntax :active, a1, after des1, 3d @@ -114,6 +114,9 @@ gantt Add another diagram to demo page :48h ``` +> **Note** +> Support for keyword `until` was added in (v\+). This can be used to define a task which is running until some other specific task or milestone starts. + It is possible to set multiple dependencies separated by space: ```mermaid-example @@ -121,6 +124,7 @@ gantt apple :a, 2017-07-20, 1w banana :crit, b, 2017-07-23, 1d cherry :active, c, after b a, 1d + kiwi :d, 2017-07-20, until b c ``` ```mermaid @@ -128,6 +132,7 @@ gantt apple :a, 2017-07-20, 1w banana :crit, b, 2017-07-23, 1d cherry :active, c, after b a, 1d + kiwi :d, 2017-07-20, until b c ``` ### Title diff --git a/packages/mermaid/src/diagrams/gantt/ganttDb.js b/packages/mermaid/src/diagrams/gantt/ganttDb.js index 1c73a13ea..4b70f7e85 100644 --- a/packages/mermaid/src/diagrams/gantt/ganttDb.js +++ b/packages/mermaid/src/diagrams/gantt/ganttDb.js @@ -343,6 +343,35 @@ const parseDuration = function (str) { const getEndDate = function (prevTime, dateFormat, str, inclusive = false) { str = str.trim(); + // Test for until + const re = /^until\s+([\d\w- ]+)/; + const untilStatement = re.exec(str.trim()); + + if (untilStatement !== null) { + // check all until ids and take the earliest + let earliestStartingTask = null; + untilStatement[1].split(' ').forEach(function (id) { + let task = findTaskById(id); + if (task !== undefined) { + if (!earliestStartingTask) { + earliestStartingTask = task; + } else { + if (task.startTime < earliestStartingTask.startTime) { + earliestStartingTask = task; + } + } + } + }); + + if (!earliestStartingTask) { + const dt = new Date(); + dt.setHours(0, 0, 0, 0); + return dt; + } else { + return earliestStartingTask.startTime; + } + } + // Check for actual date let mDate = dayjs(str, dateFormat.trim(), true); if (mDate.isValid()) { diff --git a/packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts b/packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts index 416368e8f..e055e2d95 100644 --- a/packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts +++ b/packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts @@ -140,10 +140,10 @@ describe('when using the ganttDb', function () { it('should handle relative start date based on id regardless of sections', function () { ganttDb.setDateFormat('YYYY-MM-DD'); - ganttDb.addSection('testa1'); + ganttDb.addSection('sec1'); ganttDb.addTask('test1', 'id1,2013-01-01,2w'); ganttDb.addTask('test2', 'id2,after id3,1d'); - ganttDb.addSection('testa2'); + ganttDb.addSection('sec2'); ganttDb.addTask('test3', 'id3,after id1,2d'); const tasks = ganttDb.getTasks(); @@ -158,6 +158,58 @@ describe('when using the ganttDb', function () { expect(tasks[2].startTime).toEqual(new Date(2013, 0, 15)); expect(tasks[2].endTime).toEqual(new Date(2013, 0, 17)); }); + + it('should handle relative end date based on id regardless of sections', function () { + ganttDb.setDateFormat('YYYY-MM-DD'); + ganttDb.addSection('sec1'); + ganttDb.addTask('task1', 'id1,2013-01-01,until id3'); + ganttDb.addSection('sec2'); + ganttDb.addTask('task2', 'id2,2013-01-10,until id3'); + ganttDb.addTask('task3', 'id3,2013-02-01,2d'); + + const tasks = ganttDb.getTasks(); + + expect(tasks[0].startTime).toEqual(new Date(2013, 0, 1)); + expect(tasks[0].endTime).toEqual(new Date(2013, 1, 1)); + expect(tasks[0].id).toEqual('id1'); + expect(tasks[0].task).toEqual('task1'); + + expect(tasks[1].id).toEqual('id2'); + expect(tasks[1].task).toEqual('task2'); + expect(tasks[1].startTime).toEqual(new Date(2013, 0, 10)); + expect(tasks[1].endTime).toEqual(new Date(2013, 1, 1)); + }); + + it('should handle relative start date based on multiple id', function () { + ganttDb.setDateFormat('YYYY-MM-DD'); + ganttDb.addSection('sec1'); + ganttDb.addTask('task1', 'id1,after id2 id3 id4,1d'); + ganttDb.addTask('task2', 'id2,2013-01-01,1d'); + ganttDb.addTask('task3', 'id3,2013-02-01,3d'); + ganttDb.addTask('task4', 'id4,2013-02-01,2d'); + + const tasks = ganttDb.getTasks(); + + expect(tasks[0].endTime).toEqual(new Date(2013, 0, 2)); + expect(tasks[0].id).toEqual('id1'); + expect(tasks[0].task).toEqual('task1'); + }); + + it('should handle relative end date based on multiple id', function () { + ganttDb.setDateFormat('YYYY-MM-DD'); + ganttDb.addSection('sec1'); + ganttDb.addTask('task1', 'id1,2013-01-01,until id2 id3 id4'); + ganttDb.addTask('task2', 'id2,2013-01-11,1d'); + ganttDb.addTask('task3', 'id3,2013-02-10,1d'); + ganttDb.addTask('task4', 'id4,2013-02-12,1d'); + + const tasks = ganttDb.getTasks(); + + expect(tasks[0].endTime).toEqual(new Date(2013, 1, 10)); + expect(tasks[0].id).toEqual('id1'); + expect(tasks[0].task).toEqual('task1'); + }); + it('should ignore weekends', function () { ganttDb.setDateFormat('YYYY-MM-DD'); ganttDb.setExcludes('weekends 2019-02-06,friday'); diff --git a/packages/mermaid/src/docs/syntax/gantt.md b/packages/mermaid/src/docs/syntax/gantt.md index 6940f882f..cde1a5504 100644 --- a/packages/mermaid/src/docs/syntax/gantt.md +++ b/packages/mermaid/src/docs/syntax/gantt.md @@ -49,8 +49,8 @@ gantt Create tests for parser :crit, active, 3d Future task in critical line :crit, 5d Create tests for renderer :2d - Add to mermaid :1d - Functionality added :milestone, 2014-01-25, 0d + Add to mermaid :until isadded + Functionality added :milestone, isadded, 2014-01-25, 0d section Documentation Describe gantt syntax :active, a1, after des1, 3d @@ -63,6 +63,10 @@ gantt Add another diagram to demo page :48h ``` +```note +Support for keyword `until` was added in (v+). This can be used to define a task which is running until some other specific task or milestone starts. +``` + It is possible to set multiple dependencies separated by space: ```mermaid-example @@ -70,6 +74,7 @@ gantt apple :a, 2017-07-20, 1w banana :crit, b, 2017-07-23, 1d cherry :active, c, after b a, 1d + kiwi :d, 2017-07-20, until b c ``` ### Title From b44ec7daddf7d4ee4d66b9bfacffbe2281735758 Mon Sep 17 00:00:00 2001 From: Franck Zagala Date: Mon, 22 Jan 2024 21:46:52 +0000 Subject: [PATCH 02/41] fix bad expected values in gantt units tests --- packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts b/packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts index e055e2d95..96aae0b89 100644 --- a/packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts +++ b/packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts @@ -190,7 +190,7 @@ describe('when using the ganttDb', function () { const tasks = ganttDb.getTasks(); - expect(tasks[0].endTime).toEqual(new Date(2013, 0, 2)); + expect(tasks[0].endTime).toEqual(new Date(2013, 1, 5)); expect(tasks[0].id).toEqual('id1'); expect(tasks[0].task).toEqual('task1'); }); @@ -205,7 +205,7 @@ describe('when using the ganttDb', function () { const tasks = ganttDb.getTasks(); - expect(tasks[0].endTime).toEqual(new Date(2013, 1, 10)); + expect(tasks[0].endTime).toEqual(new Date(2013, 0, 11)); expect(tasks[0].id).toEqual('id1'); expect(tasks[0].task).toEqual('task1'); }); From 099f580e520a9721deae8b543f06e97bbe9b98d1 Mon Sep 17 00:00:00 2001 From: Franck Zagala Date: Wed, 24 Jan 2024 09:30:21 +0000 Subject: [PATCH 03/41] address review comment on implementation; apply similar changes on existing impl of keyword 'after' --- .../mermaid/src/diagrams/gantt/ganttDb.js | 72 ++++++++----------- 1 file changed, 30 insertions(+), 42 deletions(-) diff --git a/packages/mermaid/src/diagrams/gantt/ganttDb.js b/packages/mermaid/src/diagrams/gantt/ganttDb.js index 4b70f7e85..b54fe821c 100644 --- a/packages/mermaid/src/diagrams/gantt/ganttDb.js +++ b/packages/mermaid/src/diagrams/gantt/ganttDb.js @@ -256,31 +256,25 @@ const getStartDate = function (prevTime, dateFormat, str) { str = str.trim(); // Test for after - const re = /^after\s+([\d\w- ]+)/; - const afterStatement = re.exec(str.trim()); + const afterRePattern = /^after\s+(?[\d\w- ]+)/; + const afterStatement = afterRePattern.exec(str); if (afterStatement !== null) { // check all after ids and take the latest - let latestEndingTask = null; - afterStatement[1].split(' ').forEach(function (id) { + let latestTask = null; + for (const id of afterStatement.groups.ids.split(' ')) { let task = findTaskById(id); - if (task !== undefined) { - if (!latestEndingTask) { - latestEndingTask = task; - } else { - if (task.endTime > latestEndingTask.endTime) { - latestEndingTask = task; - } - } + if (task !== undefined && (!latestTask || task.endTime > latestTask.endTime)) { + latestTask = task; } - }); + } - if (!latestEndingTask) { - const dt = new Date(); - dt.setHours(0, 0, 0, 0); - return dt; + if (latestTask) { + return latestTask.endTime; } else { - return latestEndingTask.endTime; + const today = new Date(); + today.setHours(0, 0, 0, 0); + return today; } } @@ -343,42 +337,36 @@ const parseDuration = function (str) { const getEndDate = function (prevTime, dateFormat, str, inclusive = false) { str = str.trim(); - // Test for until - const re = /^until\s+([\d\w- ]+)/; - const untilStatement = re.exec(str.trim()); + // test for until + const untilRePattern = /^until\s+(?[\d\w- ]+)/; + const untilStatement = untilRePattern.exec(str); if (untilStatement !== null) { // check all until ids and take the earliest - let earliestStartingTask = null; - untilStatement[1].split(' ').forEach(function (id) { + let earliestTask = null; + for (const id of untilStatement.groups.ids.split(' ')) { let task = findTaskById(id); - if (task !== undefined) { - if (!earliestStartingTask) { - earliestStartingTask = task; - } else { - if (task.startTime < earliestStartingTask.startTime) { - earliestStartingTask = task; - } - } + if (task !== undefined && (!earliestTask || task.startTime < earliestTask.startTime)) { + earliestTask = task; } - }); + } - if (!earliestStartingTask) { - const dt = new Date(); - dt.setHours(0, 0, 0, 0); - return dt; + if (earliestTask) { + return earliestTask.startTime; } else { - return earliestStartingTask.startTime; + const today = new Date(); + today.setHours(0, 0, 0, 0); + return today; } } - // Check for actual date - let mDate = dayjs(str, dateFormat.trim(), true); - if (mDate.isValid()) { + // check for actual date + let parsedDate = dayjs(str, dateFormat.trim(), true); + if (parsedDate.isValid()) { if (inclusive) { - mDate = mDate.add(1, 'd'); + parsedDate = parsedDate.add(1, 'd'); } - return mDate.toDate(); + return parsedDate.toDate(); } let endTime = dayjs(prevTime); From fd3f1caff6c43e8bc39a6700e2058cea735bae88 Mon Sep 17 00:00:00 2001 From: Franck Zagala Date: Sat, 27 Jan 2024 11:27:28 +0000 Subject: [PATCH 04/41] add parsing unit test for after/until keywords --- .../src/diagrams/gantt/parser/gantt.spec.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js b/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js index e7ce1ffa4..8146affac 100644 --- a/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js +++ b/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js @@ -82,6 +82,38 @@ describe('when parsing a gantt diagram it', function () { expect(tasks[0].id).toEqual('des1'); expect(tasks[0].task).toEqual('Design jison grammar'); }); + it('should handle a task with start/end time relative to other tasks', function () { + const str = + 'gantt\n' + + 'dateFormat YYYY-MM-DD\n' + + 'title Adding gantt diagram functionality to mermaid\n' + + 'section Documentation\n' + + 'task A: a, 2024-01-27, 2024-01-28\n' + + 'task B: b, after a, 2024-01-30\n' + + 'task C: c, 2024-01-20, until a\n' + + 'task D: d, after c, until b'; + + expect(parserFnConstructor(str)).not.toThrow(); + + const tasks = parser.yy.getTasks(); + + expect(tasks[0].startTime).toEqual(new Date(2024, 0, 27)); + expect(tasks[0].endTime).toEqual(new Date(2024, 0, 28)); + expect(tasks[0].id).toEqual('b'); + expect(tasks[0].task).toEqual('task B'); + expect(tasks[1].startTime).toEqual(new Date(2024, 0, 28)); + expect(tasks[1].endTime).toEqual(new Date(2024, 0, 30)); + expect(tasks[1].id).toEqual('b'); + expect(tasks[1].task).toEqual('task B'); + expect(tasks[2].startTime).toEqual(new Date(2024, 0, 20)); + expect(tasks[2].endTime).toEqual(new Date(2024, 0, 27)); + expect(tasks[2].id).toEqual('c'); + expect(tasks[2].task).toEqual('task C'); + expect(tasks[3].startTime).toEqual(new Date(2024, 0, 27)); + expect(tasks[3].endTime).toEqual(new Date(2024, 0, 28)); + expect(tasks[3].id).toEqual('d'); + expect(tasks[3].task).toEqual('task D'); + }); it.each(convert` tags | milestone | done | crit | active ${'milestone'} | ${true} | ${false} | ${false} | ${false} From 9fadf621a826ba429e72b6ca2ca817da42251574 Mon Sep 17 00:00:00 2001 From: Franck Zagala Date: Sat, 27 Jan 2024 12:05:23 +0000 Subject: [PATCH 05/41] adapt e2e tests to include new 'until' keyword in gantt chart --- cypress/integration/rendering/gantt.spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cypress/integration/rendering/gantt.spec.js b/cypress/integration/rendering/gantt.spec.js index 73ff4ee00..e045691ef 100644 --- a/cypress/integration/rendering/gantt.spec.js +++ b/cypress/integration/rendering/gantt.spec.js @@ -25,7 +25,8 @@ describe('Gantt diagram', () => { Create tests for parser :crit, active, 3d Future task in critical line :crit, 5d Create tests for renderer :2d - Add to mermaid :1d + Add to mermaid :adding, 1d + Thinking about adding to mermaid :after des1, until adding section Documentation Describe gantt syntax :active, a1, after des1, 3d @@ -88,6 +89,7 @@ describe('Gantt diagram', () => { apple :a, 2017-07-20, 1w banana :crit, b, 2017-07-23, 1d cherry :active, c, after b a, 1d + kiwi :d, 2017-07-20, until b c `, {} ); From cc4dfeab1a5c3e4cb0ba069820f7d018928c398f Mon Sep 17 00:00:00 2001 From: Franck Zagala Date: Sat, 27 Jan 2024 12:32:15 +0000 Subject: [PATCH 06/41] fix minor mistake in parsing test --- packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js b/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js index dc5ee4de9..6665765a4 100644 --- a/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js +++ b/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js @@ -135,8 +135,8 @@ describe('when parsing a gantt diagram it', function () { expect(tasks[0].startTime).toEqual(new Date(2024, 0, 27)); expect(tasks[0].endTime).toEqual(new Date(2024, 0, 28)); - expect(tasks[0].id).toEqual('b'); - expect(tasks[0].task).toEqual('task B'); + expect(tasks[0].id).toEqual('a'); + expect(tasks[0].task).toEqual('task A'); expect(tasks[1].startTime).toEqual(new Date(2024, 0, 28)); expect(tasks[1].endTime).toEqual(new Date(2024, 0, 30)); expect(tasks[1].id).toEqual('b'); From c1b5d527df06a7305401749ab327fac3a7b4c59b Mon Sep 17 00:00:00 2001 From: Franck Zagala Date: Sat, 27 Jan 2024 13:24:12 +0000 Subject: [PATCH 07/41] modify invalid e2e test for gantt chart --- cypress/integration/rendering/gantt.spec.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cypress/integration/rendering/gantt.spec.js b/cypress/integration/rendering/gantt.spec.js index 73ebc325f..e14f0815d 100644 --- a/cypress/integration/rendering/gantt.spec.js +++ b/cypress/integration/rendering/gantt.spec.js @@ -14,19 +14,18 @@ describe('Gantt diagram', () => { excludes weekdays 2014-01-10 section A section - Completed task :done, des1, 2014-01-06,2014-01-08 - Active task :active, des2, 2014-01-09, 3d - Future task : des3, after des2, 5d - Future task2 : des4, after des3, 5d + Completed task :done, des1, 2014-01-06,2014-01-08 + Active task :active, des2, 2014-01-09, 3d + Future task :des3, after des2, 5d + Future task2 :des4, after des3, 5d + Waiting for task 2 :after des1, until des4 section Critical tasks Completed task in the critical line :crit, done, 2014-01-06,24h - Implement parser and jison :crit, done, after des1, 2d + Implement parser and jison :crit, done, after des1, 2d Create tests for parser :crit, active, 3d Future task in critical line :crit, 5d Create tests for renderer :2d - Add to mermaid :adding, 1d - Thinking about adding to mermaid :after des1, until adding section Documentation Describe gantt syntax :active, a1, after des1, 3d From 069a132fe1906adc1dcd08ba0eeda91a1da7b3f6 Mon Sep 17 00:00:00 2001 From: Franck Zagala Date: Sat, 27 Jan 2024 16:05:35 +0000 Subject: [PATCH 08/41] revert changes on existing e2e tests; add new e2e test for nez until keyword --- cypress/integration/rendering/gantt.spec.js | 38 +++++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/cypress/integration/rendering/gantt.spec.js b/cypress/integration/rendering/gantt.spec.js index e14f0815d..756611008 100644 --- a/cypress/integration/rendering/gantt.spec.js +++ b/cypress/integration/rendering/gantt.spec.js @@ -14,18 +14,18 @@ describe('Gantt diagram', () => { excludes weekdays 2014-01-10 section A section - Completed task :done, des1, 2014-01-06,2014-01-08 - Active task :active, des2, 2014-01-09, 3d - Future task :des3, after des2, 5d - Future task2 :des4, after des3, 5d - Waiting for task 2 :after des1, until des4 + Completed task :done, des1, 2014-01-06,2014-01-08 + Active task :active, des2, 2014-01-09, 3d + Future task : des3, after des2, 5d + Future task2 : des4, after des3, 5d section Critical tasks Completed task in the critical line :crit, done, 2014-01-06,24h - Implement parser and jison :crit, done, after des1, 2d + Implement parser and jison :crit, done, after des1, 2d Create tests for parser :crit, active, 3d Future task in critical line :crit, 5d Create tests for renderer :2d + Add to mermaid :1d section Documentation Describe gantt syntax :active, a1, after des1, 3d @@ -88,7 +88,31 @@ describe('Gantt diagram', () => { apple :a, 2017-07-20, 1w banana :crit, b, 2017-07-23, 1d cherry :active, c, after b a, 1d - kiwi :d, 2017-07-20, until b c + `, + {} + ); + }); + it('should handle multiple dependencies syntax with after and until', () => { + imgSnapshotTest( + ` + gantt + dateFormat YYYY-MM-DD + axisFormat %d/%m + title Adding GANTT diagram to mermaid + excludes weekdays 2014-01-10 + todayMarker off + + section team's critical event + deadline A :milestone, crit, deadlineA, 2024-02-01, 0 + deadline B :milestone, crit, deadlineB, 2024-02-15, 0 + boss on leave :bossaway, 2024-01-28, 2024-02-11 + + section new intern + onboarding :onboarding, 2024-01-02, 1w + literature review :litreview, 2024-01-02, 10d + project A :projectA, after onboarding litreview, until deadlineA bossaway + chilling :chilling, after projectA, until deadlineA + project B :projectB, after deadlineA, until deadlineB `, {} ); From 8d2605d5374a290644e4e69270423ab451d6fc62 Mon Sep 17 00:00:00 2001 From: Franck Zagala Date: Sat, 27 Jan 2024 16:33:57 +0000 Subject: [PATCH 09/41] minor stylistic changes --- packages/mermaid/src/diagrams/gantt/ganttDb.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/mermaid/src/diagrams/gantt/ganttDb.js b/packages/mermaid/src/diagrams/gantt/ganttDb.js index b54fe821c..7a9194e2f 100644 --- a/packages/mermaid/src/diagrams/gantt/ganttDb.js +++ b/packages/mermaid/src/diagrams/gantt/ganttDb.js @@ -271,11 +271,10 @@ const getStartDate = function (prevTime, dateFormat, str) { if (latestTask) { return latestTask.endTime; - } else { - const today = new Date(); - today.setHours(0, 0, 0, 0); - return today; } + const today = new Date(); + today.setHours(0, 0, 0, 0); + return today; } // Check for actual date set @@ -353,11 +352,10 @@ const getEndDate = function (prevTime, dateFormat, str, inclusive = false) { if (earliestTask) { return earliestTask.startTime; - } else { - const today = new Date(); - today.setHours(0, 0, 0, 0); - return today; } + const today = new Date(); + today.setHours(0, 0, 0, 0); + return today; } // check for actual date From f5555245f913acea115ec0b3a4cdc8d8d997fe64 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 2 Feb 2024 08:53:29 +0100 Subject: [PATCH 10/41] Mermaid version 10.8.0 --- .../{block.spec.ts => block.spec.js} | 0 packages/mermaid/package.json | 2 +- .../src/docs/community/contributing.md | 2 +- pnpm-lock.yaml | 96 +++++++++++++++---- 4 files changed, 79 insertions(+), 21 deletions(-) rename cypress/integration/rendering/{block.spec.ts => block.spec.js} (100%) diff --git a/cypress/integration/rendering/block.spec.ts b/cypress/integration/rendering/block.spec.js similarity index 100% rename from cypress/integration/rendering/block.spec.ts rename to cypress/integration/rendering/block.spec.js diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index 551e44ed9..6df479481 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -1,6 +1,6 @@ { "name": "mermaid", - "version": "10.7.0", + "version": "10.8.0", "description": "Markdown-ish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.", "type": "module", "module": "./dist/mermaid.core.mjs", diff --git a/packages/mermaid/src/docs/community/contributing.md b/packages/mermaid/src/docs/community/contributing.md index 9a83b5294..153fdc6af 100644 --- a/packages/mermaid/src/docs/community/contributing.md +++ b/packages/mermaid/src/docs/community/contributing.md @@ -371,7 +371,7 @@ If the users have no way to know that things have changed, then you haven't real Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. The documentation has to be updated for users to know that things have been changed and added! -If you are adding a new feature, add `(v+)` in the title or description. It will be replaced automatically with the current version number when the release happens. +If you are adding a new feature, add `(v10.8.0+)` in the title or description. It will be replaced automatically with the current version number when the release happens. eg: `# Feature Name (v+)` diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9b065ff49..c48a18b4c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -517,8 +517,8 @@ importers: specifier: ^0.17.0 version: 0.17.0(vite@4.5.0)(workbox-build@7.0.0)(workbox-window@7.0.0) vitepress: - specifier: 1.0.0-rc.40 - version: 1.0.0-rc.40(@algolia/client-search@4.19.1)(@types/node@20.11.10)(postcss@8.4.33)(search-insights@2.7.0)(typescript@5.1.6) + specifier: 1.0.0-rc.39 + version: 1.0.0-rc.39(@algolia/client-search@4.19.1)(@types/node@20.11.10)(postcss@8.4.33)(search-insights@2.7.0)(typescript@5.1.6) workbox-window: specifier: ^7.0.0 version: 7.0.0 @@ -5992,7 +5992,7 @@ packages: /@vueuse/shared@10.1.0(vue@3.3.4): resolution: {integrity: sha512-2X52ogu12i9DkKOQ01yeb/BKg9UO87RNnpm5sXkQvyORlbq8ONS5l39MYkjkeVWWjdT0teJru7a2S41dmHmqjQ==} dependencies: - vue-demi: 0.14.5(vue@3.3.4) + vue-demi: 0.14.6(vue@3.3.4) transitivePeerDependencies: - '@vue/composition-api' - vue @@ -12850,6 +12850,7 @@ packages: resolution: {integrity: sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + dev: false /nanoid@3.3.7: resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} @@ -13659,7 +13660,7 @@ packages: resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==} engines: {node: ^10 || ^12 || >=14} dependencies: - nanoid: 3.3.6 + nanoid: 3.3.7 picocolors: 1.0.0 source-map-js: 1.0.2 @@ -14571,18 +14572,34 @@ packages: resolution: {integrity: sha512-9Of8HMlF96usXJHmCL3Gd0Fcf0EcyJUF9m8EoAKKd98mHXi0La2AZl1h6PegSFGtiYcBDK/fLuKbDa1l16r1fA==} dev: true + /shikiji-core@0.9.19: + resolution: {integrity: sha512-AFJu/vcNT21t0e6YrfadZ+9q86gvPum6iywRyt1OtIPjPFe25RQnYJyxHQPMLKCCWA992TPxmEmbNcOZCAJclw==} + dev: true + /shikiji-transformers@0.10.2: resolution: {integrity: sha512-7IVTwl1af205ywYEq5bOAYOTOFW4V1dVX1EablP0nWKErqZeD1o93VMytxmtJomqS+YwbB8doY8SE3MFMn0aPQ==} dependencies: shikiji: 0.10.2 dev: true + /shikiji-transformers@0.9.19: + resolution: {integrity: sha512-lGLI7Z8frQrIBbhZ74/eiJtxMoCQRbpaHEB+gcfvdIy+ZFaAtXncJGnc52932/UET+Y4GyKtwwC/vjWUCp+c/Q==} + dependencies: + shikiji: 0.9.19 + dev: true + /shikiji@0.10.2: resolution: {integrity: sha512-wtZg3T0vtYV2PnqusWQs3mDaJBdCPWxFDrBM/SE5LfrX92gjUvfEMlc+vJnoKY6Z/S44OWaCRzNIsdBRWcTAiw==} dependencies: shikiji-core: 0.10.2 dev: true + /shikiji@0.9.19: + resolution: {integrity: sha512-Kw2NHWktdcdypCj1GkKpXH4o6Vxz8B8TykPlPuLHOGSV8VkhoCLcFOH4k19K4LXAQYRQmxg+0X/eM+m2sLhAkg==} + dependencies: + shikiji-core: 0.9.19 + dev: true + /side-channel@1.0.4: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} dependencies: @@ -16205,6 +16222,62 @@ packages: vue: 3.4.15(typescript@5.0.4) dev: true + /vitepress@1.0.0-rc.39(@algolia/client-search@4.19.1)(@types/node@20.11.10)(postcss@8.4.33)(search-insights@2.7.0)(typescript@5.1.6): + resolution: {integrity: sha512-EcgoRlAAp37WOxUOYv45oxyhLrcy3Upey+mKpqW3ldsg6Ol4trPndRBk2GO0QiSvEKlb9BMerk49D/bFICN6kg==} + hasBin: true + peerDependencies: + markdown-it-mathjax3: ^4.3.2 + postcss: ^8.4.33 + peerDependenciesMeta: + markdown-it-mathjax3: + optional: true + postcss: + optional: true + dependencies: + '@docsearch/css': 3.5.2 + '@docsearch/js': 3.5.2(@algolia/client-search@4.19.1)(search-insights@2.7.0) + '@types/markdown-it': 13.0.7 + '@vitejs/plugin-vue': 5.0.3(vite@5.0.12)(vue@3.4.15) + '@vue/devtools-api': 6.5.1 + '@vueuse/core': 10.7.2(vue@3.4.15) + '@vueuse/integrations': 10.7.2(focus-trap@7.5.4)(vue@3.4.15) + focus-trap: 7.5.4 + mark.js: 8.11.1 + minisearch: 6.3.0 + postcss: 8.4.33 + shikiji: 0.9.19 + shikiji-core: 0.9.19 + shikiji-transformers: 0.9.19 + vite: 5.0.12(@types/node@20.11.10) + vue: 3.4.15(typescript@5.1.6) + transitivePeerDependencies: + - '@algolia/client-search' + - '@types/node' + - '@types/react' + - '@vue/composition-api' + - async-validator + - axios + - change-case + - drauu + - fuse.js + - idb-keyval + - jwt-decode + - less + - lightningcss + - nprogress + - qrcode + - react + - react-dom + - sass + - search-insights + - sortablejs + - stylus + - sugarss + - terser + - typescript + - universal-cookie + dev: true + /vitepress@1.0.0-rc.40(@algolia/client-search@4.19.1)(@types/node@20.11.10)(postcss@8.4.33)(search-insights@2.7.0)(typescript@5.1.6): resolution: {integrity: sha512-1x9PCrcsJwqhpccyTR93uD6jpiPDeRC98CBCAQLLBb44a3VSXYBPzhCahi+2kwAYylu49p0XhseMPVM4IVcWcw==} hasBin: true @@ -16417,21 +16490,6 @@ packages: resolution: {integrity: sha512-eOpPHogvorZRobNqJGhapa0JdwaxpjVvyBp0QIUMRMSf8ZAlqOdEquKuRmw9Qwu0qXtJIWqFtMkmvJjUZmMjVA==} dev: true - /vue-demi@0.14.5(vue@3.3.4): - resolution: {integrity: sha512-o9NUVpl/YlsGJ7t+xuqJKx8EBGf1quRhCiT6D/J0pfwmk9zUwYkC7yrF4SZCe6fETvSM3UNL2edcbYrSyc4QHA==} - engines: {node: '>=12'} - hasBin: true - requiresBuild: true - peerDependencies: - '@vue/composition-api': ^1.0.0-rc.1 - vue: ^3.0.0-0 || ^2.6.0 - peerDependenciesMeta: - '@vue/composition-api': - optional: true - dependencies: - vue: 3.3.4 - dev: false - /vue-demi@0.14.6(vue@3.3.4): resolution: {integrity: sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==} engines: {node: '>=12'} From 2fa921935326a78a093b028048428e304875ee46 Mon Sep 17 00:00:00 2001 From: knsv Date: Fri, 2 Feb 2024 07:56:48 +0000 Subject: [PATCH 11/41] Update docs --- docs/community/contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/community/contributing.md b/docs/community/contributing.md index d6afbd90d..badd821d0 100644 --- a/docs/community/contributing.md +++ b/docs/community/contributing.md @@ -370,7 +370,7 @@ If the users have no way to know that things have changed, then you haven't real Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. The documentation has to be updated for users to know that things have been changed and added! -If you are adding a new feature, add `(v+)` in the title or description. It will be replaced automatically with the current version number when the release happens. +If you are adding a new feature, add `(v10.8.0+)` in the title or description. It will be replaced automatically with the current version number when the release happens. eg: `# Feature Name (v+)` From 51e7444b94ab0b872eaabc3b138184b47442fab4 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 2 Feb 2024 11:10:42 +0100 Subject: [PATCH 12/41] #3358 Layoutfix for growing parent when children spans new rows due to updated columns widths --- packages/mermaid/src/diagrams/block/layout.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/block/layout.ts b/packages/mermaid/src/diagrams/block/layout.ts index a9d32d2d2..b16b9971e 100644 --- a/packages/mermaid/src/diagrams/block/layout.ts +++ b/packages/mermaid/src/diagrams/block/layout.ts @@ -122,7 +122,10 @@ function setBlockSizes(block: Block, db: BlockDB, siblingWidth = 0, siblingHeigh } const columns = block.columns || -1; - const numItems = block.children.length; + let numItems = 0; + for (const child of block.children) { + numItems += child.widthInColumns || 1; + } // The width and height in number blocks let xSize = block.children.length; From 3fe7e2dfe878ac4a84b4d8033c655022ef21c74b Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 2 Feb 2024 11:30:29 +0100 Subject: [PATCH 13/41] Updated contributions file --- docs/community/contributing.md | 2 +- packages/mermaid/src/docs/community/contributing.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/community/contributing.md b/docs/community/contributing.md index badd821d0..368ab6a6a 100644 --- a/docs/community/contributing.md +++ b/docs/community/contributing.md @@ -372,7 +372,7 @@ Likewise, if users don't know that there is a new feature that you've implemente The documentation has to be updated for users to know that things have been changed and added! If you are adding a new feature, add `(v10.8.0+)` in the title or description. It will be replaced automatically with the current version number when the release happens. -eg: `# Feature Name (v+)` +eg: `# Feature Name (v10.8.0+)` We know it can sometimes be hard to code _and_ write user documentation. diff --git a/packages/mermaid/src/docs/community/contributing.md b/packages/mermaid/src/docs/community/contributing.md index 153fdc6af..7d8aafa4c 100644 --- a/packages/mermaid/src/docs/community/contributing.md +++ b/packages/mermaid/src/docs/community/contributing.md @@ -373,7 +373,7 @@ Likewise, if users don't know that there is a new feature that you've implemente The documentation has to be updated for users to know that things have been changed and added! If you are adding a new feature, add `(v10.8.0+)` in the title or description. It will be replaced automatically with the current version number when the release happens. -eg: `# Feature Name (v+)` +eg: `# Feature Name (v10.8.0+)` We know it can sometimes be hard to code _and_ write user documentation. From 6682988403ad3612bd20446d48019c69165e0a51 Mon Sep 17 00:00:00 2001 From: futzmonitor Date: Sun, 4 Feb 2024 11:25:40 -0500 Subject: [PATCH 14/41] Changes to intro.md 1. Added a link to the Discord server --- docs/community/intro.md | 2 ++ packages/mermaid/src/docs/community/intro.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/docs/community/intro.md b/docs/community/intro.md index 9f515f8c0..ceecab7bf 100644 --- a/docs/community/intro.md +++ b/docs/community/intro.md @@ -45,6 +45,8 @@ Where to start: [Join our slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) +[You can also join our Discord server!](https://discord.gg/vVDmXwhpaS) + ## A Question Or a Suggestion? > **💡 Tip** > **Have a look at** [**how to open an issue**](./questions-and-suggestions.md). diff --git a/packages/mermaid/src/docs/community/intro.md b/packages/mermaid/src/docs/community/intro.md index e700fde45..7e49f657a 100644 --- a/packages/mermaid/src/docs/community/intro.md +++ b/packages/mermaid/src/docs/community/intro.md @@ -41,6 +41,8 @@ Where to start: [Join our slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) +[You can also join our Discord server!](https://discord.gg/vVDmXwhpaS) + ## A Question Or a Suggestion? ```tip From c45f39e819229ce03cdbea33555d70cebc699e22 Mon Sep 17 00:00:00 2001 From: futzmonitor Date: Mon, 5 Feb 2024 09:19:31 -0500 Subject: [PATCH 15/41] Changes to intro.md 1. Removed the Slack invite and left only the Discord invite --- docs/community/intro.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/community/intro.md b/docs/community/intro.md index ceecab7bf..362ed8396 100644 --- a/docs/community/intro.md +++ b/docs/community/intro.md @@ -43,9 +43,7 @@ Where to start: - You could work on a new feature! [These](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Development%22+label%3A%22Type%3A+Enhancement%22+label%3A%22Status%3A+Approved%22+) are some ideas! - You could confirm the bugs in [these issues](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Status%3A+Triage%22++label%3A%22Type%3A+Bug+%2F+Error%22). -[Join our slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) - -[You can also join our Discord server!](https://discord.gg/vVDmXwhpaS) +[Join our Discord server for closer contact!](https://discord.gg/vVDmXwhpaS) ## A Question Or a Suggestion? From ec7591bfa8723265bf7f45517da116e3adc2eb15 Mon Sep 17 00:00:00 2001 From: futzmonitor Date: Tue, 6 Feb 2024 09:48:39 -0500 Subject: [PATCH 16/41] Changes to intro.md 1. Removed the Slack link 2. Updated the Discord invite link --- docs/community/intro.md | 4 ++-- packages/mermaid/src/docs/community/intro.md | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/community/intro.md b/docs/community/intro.md index 362ed8396..e14c84696 100644 --- a/docs/community/intro.md +++ b/docs/community/intro.md @@ -43,7 +43,7 @@ Where to start: - You could work on a new feature! [These](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Development%22+label%3A%22Type%3A+Enhancement%22+label%3A%22Status%3A+Approved%22+) are some ideas! - You could confirm the bugs in [these issues](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Status%3A+Triage%22++label%3A%22Type%3A+Bug+%2F+Error%22). -[Join our Discord server for closer contact!](https://discord.gg/vVDmXwhpaS) +[You can join our Discord server if you want closer contact!](https://discord.gg/AgrbSrBer3) ## A Question Or a Suggestion? @@ -55,6 +55,6 @@ If you have faced a vulnerability [report it to us](./security.md). Don't get daunted if it is hard in the beginning. We have a great community with only encouraging words. So, if you get stuck, ask for help and hints in the Slack forum. If you want to show off something good, show it off there. -[Join our Slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) +[You can join our Discord server if you want closer contact!](https://discord.gg/AgrbSrBer3) ![Image of superhero wishing you good luck](https://media.giphy.com/media/l49JHz7kJvl6MCj3G/giphy.gif) diff --git a/packages/mermaid/src/docs/community/intro.md b/packages/mermaid/src/docs/community/intro.md index 7e49f657a..a83b96380 100644 --- a/packages/mermaid/src/docs/community/intro.md +++ b/packages/mermaid/src/docs/community/intro.md @@ -39,9 +39,7 @@ Where to start: - You could work on a new feature! [These](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Area%3A+Development%22+label%3A%22Type%3A+Enhancement%22+label%3A%22Status%3A+Approved%22+) are some ideas! - You could confirm the bugs in [these issues](https://github.com/mermaid-js/mermaid/issues?q=is%3Aissue+is%3Aopen+label%3A%22Status%3A+Triage%22++label%3A%22Type%3A+Bug+%2F+Error%22). -[Join our slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) - -[You can also join our Discord server!](https://discord.gg/vVDmXwhpaS) +[You can join our Discord server if you want closer contact!](https://discord.gg/AgrbSrBer3) ## A Question Or a Suggestion? @@ -55,6 +53,6 @@ If you have faced a vulnerability [report it to us](./security.md). Don't get daunted if it is hard in the beginning. We have a great community with only encouraging words. So, if you get stuck, ask for help and hints in the Slack forum. If you want to show off something good, show it off there. -[Join our Slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE) +[You can join our Discord server if you want closer contact!](https://discord.gg/AgrbSrBer3) ![Image of superhero wishing you good luck](https://media.giphy.com/media/l49JHz7kJvl6MCj3G/giphy.gif) From e21643229e4447699755b699e4d151471e549b2d Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Wed, 14 Feb 2024 12:12:49 +0530 Subject: [PATCH 17/41] feat: add name field to the actors --- demos/sequence.html | 7 +++++++ packages/mermaid/src/diagrams/common/commonTypes.ts | 1 + packages/mermaid/src/diagrams/common/svgDrawCommon.ts | 1 + packages/mermaid/src/diagrams/sequence/svgDraw.js | 2 ++ 4 files changed, 11 insertions(+) diff --git a/demos/sequence.html b/demos/sequence.html index 8eecae610..49d2d4285 100644 --- a/demos/sequence.html +++ b/demos/sequence.html @@ -187,6 +187,13 @@ Note left of Bob: Alice/Bob Note end +
+      sequenceDiagram
+        actor Alice
+        actor John
+        Alice-xJohn: Hello John, how are you?
+        John--xAlice: Great!
+