Removing requirement to add ids for nodes with a shape

This commit is contained in:
Knut Sveidqvist
2022-09-05 14:53:01 +02:00
parent 8b4a08eef4
commit 8ad5f728c0
3 changed files with 36 additions and 29 deletions

View File

@@ -30,7 +30,17 @@ describe('when parsing a mindmap ', function () {
expect(mm.children[0].descr).toEqual('child1');
expect(mm.children[1].descr).toEqual('child2');
});
it('should handle a hierachial mindmap definition', function () {
it('should handle a simple root definition with a shape and without an id abc123', function () {
var str = `mindmap
(root)`;
mindmap.parse(str);
// console.log('Time for checks', mindmap.yy.getMindmap().descr);
expect(mindmap.yy.getMindmap().descr).toEqual('root');
});
it('should handle a deeper hierachial mindmap definition', function () {
var str = `mindmap
root
child1
@@ -131,7 +141,7 @@ root
it('mutiple types (cloud)', function () {
var str = `mindmap
root))the root((
root)the root(
`;
mindmap.parse(str);
@@ -256,7 +266,7 @@ root
expect(child.children[1].nodeId).toEqual('b');
});
});
it('should be possible to have meaningless empty rows in a mindmap abc123', function () {
it('should be possible to have meaningless empty rows in a mindmap abc124', function () {
var str = `mindmap
root(Root)
Child(Child)

View File

@@ -86,6 +86,16 @@ statement
| EOF
;
node
:nodeWithId
|nodeWithoutId
;
nodeWithoutId
: NODE_DSTART NODE_DESCR NODE_DEND
{ console.log("node found ..", $1); $$ = { id: $2, descr: $2, type: yy.getType($1, $3) }; }
;
nodeWithId
: NODE_ID { $$ = { id: $1, descr: $1, type: yy.nodeType.DEFAULT }; }
| NODE_ID NODE_DSTART NODE_DESCR NODE_DEND
{ console.log("node found ..", $1); $$ = { id: $1, descr: $3, type: yy.getType($2, $4) }; }