Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlighted the editor in the nav #234

Merged
merged 1 commit into from
Oct 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,20 @@ <h3 id="an-example-of-a-flowchart">An example of a flowchart</h3>
Future task in critical line :crit, 5d
Create tests for renderer :2d
Add to mermaid :1d</code></pre><p>Play with mermaid using this <a href="http://danielmschmidt.github.io/mermaid-demo/">editor</a> or this <a href="live_editor">live editor</a>.</p>
<h2 id="further-reading">Further reading</h2>
<ul>
<li><a href="http://knsv.github.io/mermaid/index.html#usage">Usage</a></li>
<li><a href="http://knsv.github.io/mermaid/index.html#flowcharts-basic-syntax">Flowchart syntax</a></li>
<li><a href="http://knsv.github.io/mermaid/index.html#sequence-diagrams">Sequence diagram syntax</a></li>
<li><a href="http://knsv.github.io/mermaid/index.html#gant-diagrams">Gantt chart syntax</a></li>
<li><a href="http://knsv.github.io/mermaid/index.html#flowcharts-basic-syntax">Mermaid client</a></li>
<li><a href="http://knsv.github.io/mermaid/live_editor">Editor</a></li>
</ul>
<h2 id="credits">Credits</h2>
<p>Many thanks to the <a href="http://d3js.org/">d3</a> and <a href="https://github.com/cpettitt/dagre-d3">dagre-d3</a> projects for providing<br>the graphical layout and drawing libraries! Thanks also to the<br><a href="http://bramp.github.io/js-sequence-diagrams">js-sequence-diagram</a> project for usage of the grammar for the<br>sequence diagrams.</p>
<p><em>Mermaid was created by Knut Sveidqvist for easier documentation.</em></p>
<p>Knut has not done all work by himself, here is the full list of the projects <a href="https://github.com/knsv/mermaid/graphs/contributors">contributors</a>.</p>
<h1 id="online-live-editor">Online live editor</h1>
<p>An editor is available for creating diagrams. With it you can quickly start writing mermaid diagrams. It is possible to:</p>
<ul>
<li>save the result as a svg</li>
<li>get a link to a viewer of the diagram </li>
<li><p>get a link to edit of the diagram to share a diagram so that someone else can tweak it and send a new link back</p>
</li>
<li><p><a href="http://knsv.github.io/mermaid/live_editor">Editor</a></p>
</li>
</ul>

<h1 id="usage">Usage</h1>
<h2 id="installation">Installation</h2>
Expand Down
131 changes: 129 additions & 2 deletions javascripts/lib/mermaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -30976,7 +30976,7 @@ module.exports = '1.0.7';
},{}],86:[function(require,module,exports){
module.exports={
"name": "mermaid",
"version": "0.5.4",
"version": "0.5.5",
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
"main": "src/mermaid.js",
"keywords": [
Expand Down Expand Up @@ -35112,6 +35112,7 @@ exports.findTaskById = function (id) {
};

exports.getTasks = function () {
//compileTasks();
var i;
for (i = 10000; i < tasks.length; i++) {
tasks[i].startTime = moment(tasks[i].startTime).format(dateFormat);
Expand All @@ -35122,6 +35123,7 @@ exports.getTasks = function () {
};

var getStartDate = function getStartDate(prevTime, dateFormat, str) {
//console.log('Deciding start date:'+JSON.stringify(str));
//log.debug('Deciding start date:'+str);
//log.debug('with dateformat:'+dateFormat);

Expand All @@ -35130,12 +35132,15 @@ var getStartDate = function getStartDate(prevTime, dateFormat, str) {
// Test for after
var re = /^after\s+([\d\w\-]+)/;
var afterStatement = re.exec(str.trim());

if (afterStatement !== null) {
var task = exports.findTaskById(afterStatement[1]);
//console.log('xxx'+JSON.stringify(task));
if (typeof task === 'undefined') {
var dt = new Date();
dt.setHours(0, 0, 0, 0);
return dt;
//return undefined;
}
return task.endTime;
}
Expand Down Expand Up @@ -35272,7 +35277,95 @@ var compileData = function compileData(prevTask, dataStr) {
return task;
};

var parseData = function parseData(dataStr) {
var ds;

if (dataStr.substr(0, 1) === ':') {
ds = dataStr.substr(1, dataStr.length);
} else {
ds = dataStr;
}

var data = ds.split(',');

var task = {};
var df = exports.getDateFormat();

// Get tags like active, done cand crit
var matchFound = true;
while (matchFound) {
matchFound = false;
if (data[0].match(/^\s*active\s*$/)) {
task.active = true;
data.shift(1);
matchFound = true;
}
if (data[0].match(/^\s*done\s*$/)) {
task.done = true;
data.shift(1);
matchFound = true;
}
if (data[0].match(/^\s*crit\s*$/)) {
task.crit = true;
data.shift(1);
matchFound = true;
}
}
var i;
for (i = 0; i < data.length; i++) {
data[i] = data[i].trim();
}

switch (data.length) {
case 1:
task.id = parseId();
task.startTime = { type: 'prevTaskEnd' };
task.endTime = { data: data[0] };
break;
case 2:
task.id = parseId();
task.startTime = { type: 'getStartDate', startData: data[0] };
task.endTime = { data: data[1] };
break;
case 3:
task.id = parseId(data[0]);
task.startTime = { type: 'getStartDate', startData: data[1] };
task.endTime = { data: data[2] };
break;
default:

}

return task;
};

var lastTask;
var lastTaskID;
var rawTasks = [];
var taskDb = {};
exports.addTaskNew = function (descr, data) {
var rawTask = {
section: currentSection,
type: currentSection,
description: descr,
processed: false,
raw: { data: data }
};
var taskInfo = parseData(data);
rawTask.raw.startTime = taskInfo.startTime;
rawTask.raw.endTime = taskInfo.endTime;
rawTask.id = taskInfo.id;
rawTask.prevTaskId = lastTaskID;
rawTask.active = taskInfo.active;
rawTask.done = taskInfo.done;
rawTask.crit = taskInfo.crit;
var pos = rawTasks.push(rawTask);

lastTaskID = rawTask.id;
// Store cross ref
taskDb[rawTask.id] = pos;
};

exports.addTask = function (descr, data) {

var newTask = {
Expand All @@ -35292,6 +35385,40 @@ exports.addTask = function (descr, data) {
tasks.push(newTask);
};

var compileTasks = function compileTasks() {
console.log('Compiling tasks' + rawTasks.length);

var df = exports.getDateFormat();

var compileTask = function compileTask(pos) {
var task = rawTasks[pos];
var startTime = '';
switch (rawTasks[pos].raw.startTime.type) {
case 'prevTaskEnd':
rawTasks[pos].startTime = rawTasks[taskDb[pos].prevTaskId].endTime;
break;
case 'getStartDate':
var startTime = getStartDate(undefined, df, rawTasks[pos].raw.startTime.startData);
if (startTime) {
rawTasks[pos].startTime = startTime;
}
break;
}

if (rawTasks[pos].startTime) {
rawTasks[pos].endTime = getEndDate(rawTasks[pos].startTime, df, rawTasks[pos].raw.endTime.data);
}
};

var i;
for (i = 0; i < rawTasks.length; i++) {
console.log('Pre ompiling: ' + JSON.stringify(rawTasks[i]));
compileTask(i);
//console.log('Compiling: '+rawTasks[taskDb[i]].id);
console.log('Compiling: ' + JSON.stringify(rawTasks[i], null, 2));
}
};

exports.parseError = function (err, hash) {
global.mermaidAPI.parseError(err, hash);
};
Expand Down Expand Up @@ -37502,7 +37629,7 @@ var drawMessage = function drawMessage(elem, startx, stopx, verticalPos, msg) {
line.attr('stroke', 'black');
line.style('fill', 'none'); // remove any fill colour
if (msg.type === sq.yy.LINETYPE.SOLID || msg.type === sq.yy.LINETYPE.DOTTED) {
line.attr('marker-end', 'url(' + url + '#crosshead)');
line.attr('marker-end', 'url(' + url + '#arrowhead)');
}

if (msg.type === sq.yy.LINETYPE.SOLID_CROSS || msg.type === sq.yy.LINETYPE.DOTTED_CROSS) {
Expand Down